Previous 199869 Revisions Next

r36786 Sunday 29th March, 2015 at 23:20:16 UTC by hap
cdkong, cgalaxn, pbqbert WIP

cgalaxn doesnt work at all, suspect mcu core bug?
[src/emu/cpu/hmcs40]hmcs40.c
[src/mess/drivers]hh_hmcs40.c

trunk/src/emu/cpu/hmcs40/hmcs40.c
r245297r245298
291291   m_pc = m_pcmask;
292292   m_prev_op = m_op = 0;
293293
294   // clear interrupts
295   m_cf = 0;
296   m_ie = 0;
297   m_iri = m_irt = 0;
298   m_if[0] = m_if[1] = m_tf = 1;
299
294300   // clear i/o
295301   m_d = m_polarity;
296302   for (int i = 0; i < 16; i++)
r245297r245298
298304
299305   for (int i = 0; i < 8; i++)
300306      hmcs40_cpu_device::write_r(i, 0);
301
302   // clear interrupts
303   m_cf = 0;
304   m_ie = 0;
305   m_iri = m_irt = 0;
306   m_if[0] = m_if[1] = m_tf = 1;
307307}
308308
309309
trunk/src/mess/drivers/hh_hmcs40.c
r245297r245298
6868   optional_device<speaker_sound_device> m_speaker;
6969
7070   // misc common
71   UINT8 m_r[8];                       // MCU R ports write data
72   UINT16 m_d;                         // MCU D port write data
73   UINT8 m_int[2];                     // MCU INT0/1 pins state
7174   UINT16 m_inp_mux;                   // multiplexed inputs mask
7275
7376   UINT16 read_inputs(int columns);
77   void refresh_interrupts(void);
78   void set_interrupt(int line, int state);
79   DECLARE_INPUT_CHANGED_MEMBER(single_interrupt_line);
7480
75   virtual void machine_start();
76
7781   // display common
7882   int m_display_wait;                 // led/lamp off-delay in microseconds (default 33ms)
7983   int m_display_maxy;                 // display matrix number of rows
r245297r245298
101105   DECLARE_WRITE16_MEMBER(alnattck_grid_w);
102106   DECLARE_READ16_MEMBER(alnattck_input_r);
103107
108   void cdkong_display();
109   DECLARE_WRITE8_MEMBER(cdkong_plate_w);
110   DECLARE_WRITE16_MEMBER(cdkong_grid_w);
111
112   void cgalaxn_display();
113   DECLARE_WRITE16_MEMBER(cgalaxn_plate_w);
114   DECLARE_WRITE8_MEMBER(cgalaxn_grid_w);
115   DECLARE_READ8_MEMBER(cgalaxn_input_r);
116
104117   DECLARE_WRITE8_MEMBER(cpacman_plate_w);
105118   DECLARE_WRITE16_MEMBER(cpacman_grid_w);
106119   DECLARE_READ8_MEMBER(cpacman_input_r);
r245297r245298
113126   DECLARE_WRITE8_MEMBER(egalaxn2_plate_w);
114127   DECLARE_WRITE16_MEMBER(egalaxn2_grid_w);
115128   DECLARE_READ8_MEMBER(egalaxn2_input_r);
129
130   DECLARE_WRITE8_MEMBER(pbqbert_plate_w);
131   DECLARE_WRITE16_MEMBER(pbqbert_grid_w);
132
133protected:
134   virtual void machine_start();
135   virtual void machine_reset();
116136};
117137
118138
139// machine start/reset
140
119141void hh_hmcs40_state::machine_start()
120142{
121143   // zerofill
r245297r245298
124146   memset(m_display_decay, 0, sizeof(m_display_decay));
125147   memset(m_display_segmask, 0, sizeof(m_display_segmask));
126148
149   memset(m_r, 0, sizeof(m_r));
150   memset(m_int, 0, sizeof(m_int));
151   m_d = 0;
127152   m_inp_mux = 0;
128153   m_grid = 0;
129154   m_plate = 0;
r245297r245298
138163   save_item(NAME(m_display_decay));
139164   save_item(NAME(m_display_segmask));
140165
166   save_item(NAME(m_r));
167   save_item(NAME(m_int));
168   save_item(NAME(m_d));
141169   save_item(NAME(m_inp_mux));
142170   save_item(NAME(m_grid));
143171   save_item(NAME(m_plate));
144172}
145173
174void hh_hmcs40_state::machine_reset()
175{
176   refresh_interrupts();
177}
146178
147179
180
148181/***************************************************************************
149182
150183  Helper Functions
r245297r245298
240273}
241274
242275
276// interrupt handling
243277
278void hh_hmcs40_state::refresh_interrupts()
279{
280   for (int i = 0; i < 2; i++)
281      m_maincpu->set_input_line(i, m_int[i] ? ASSERT_LINE : CLEAR_LINE);
282}
283
284void hh_hmcs40_state::set_interrupt(int line, int state)
285{
286   line = line ? 1 : 0;
287   state = state ? 1 : 0;
288   
289   if (state != m_int[line])
290   {
291      if (machine().phase() >= MACHINE_PHASE_RESET)
292         m_maincpu->set_input_line(line, state ? ASSERT_LINE : CLEAR_LINE);
293      m_int[line] = state;
294   }
295}
296
297INPUT_CHANGED_MEMBER(hh_hmcs40_state::single_interrupt_line)
298{
299   set_interrupt((int)(FPTR)param, newval);
300}
301
302
303
244304/***************************************************************************
245305
246306  Minidrivers (I/O, Inputs, Machine Config)
r245297r245298
453513
454514READ16_MEMBER(hh_hmcs40_state::alnattck_input_r)
455515{
456   // D5: inputs
457   return (read_inputs(7) & 1) << 5;
516   // D5: multiplexed inputs
517   return read_inputs(7);
458518}
459519
460520
461521static INPUT_PORTS_START( alnattck )
462522   PORT_START("IN.0") // D5 D7
463   PORT_CONFNAME( 0x01, 0x00, "Skill Level" )
523   PORT_CONFNAME( 0x20, 0x00, "Skill Level" )
464524   PORT_CONFSETTING(    0x00, "1" )
465   PORT_CONFSETTING(    0x01, "2" )
525   PORT_CONFSETTING(    0x20, "2" )
466526
467527   PORT_START("IN.1") // D5 D8
468   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
528   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
469529
470530   PORT_START("IN.2") // D5 D9
471   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
531   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
472532
473533   PORT_START("IN.3") // D5 D10
474   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )
534   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )
475535
476536   PORT_START("IN.4") // D5 D11
477   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
537   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
478538
479539   PORT_START("IN.5") // D5 D12
480   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Move")
540   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Move")
481541
482542   PORT_START("IN.6") // D5 D13
483   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Fire")
543   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Fire")
484544INPUT_PORTS_END
485545
486546
r245297r245298
521581
522582***************************************************************************/
523583
584void hh_hmcs40_state::cdkong_display()
585{
586   UINT32 plate = BITSWAP32(m_plate,31,30,29,24,0,16,8,1,23,17,9,2,18,10,25,27,26,3,15,27,11,11,14,22,6,13,21,5,19,12,20,4);
587   plate |= 0x800800; // plates 11,23 are always on
588
589   display_matrix(29, 11, plate, m_grid);
590}
591
592WRITE8_MEMBER(hh_hmcs40_state::cdkong_plate_w)
593{
594   // R13: speaker on?
595   if (offset == HMCS40_PORT_R1X)
596   {
597      //strobes at the start of a sound.. on+slow decay?
598      //printf("%d",data>>3&1);
599      data &= 7;
600   }
601   
602   // R0x-R6x: vfd matrix plate
603   int shift = offset * 4;
604   m_plate = (m_plate & ~(0xf << shift)) | (data << shift);
605   cdkong_display();
606
607   //             12
608   //             16,15,17,28,nc, 8, 5, 1, 3,19,22,26,13, 9, 6, 2,10,18,21,25,sp, 7, 4, 0,14,20,24,27
609   // 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
610   //   ,  ,  ,24, 0,16, 8, 1,  ,17, 9, 2,18,10,25,27,26, 3,15,27,  ,11,14,22, 6,13,21, 5,19,12,20, 4
611   
612}
613
614WRITE16_MEMBER(hh_hmcs40_state::cdkong_grid_w)
615{
616   // D3: speaker out
617   m_speaker->level_w(data >> 3 & 1);
618
619   // D4-D14: vfd matrix grid
620   m_grid = data >> 4 & 0x7ff;
621   cdkong_display();
622}
623
624
524625static INPUT_PORTS_START( cdkong )
626   PORT_START("IN.0") // port D
627   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )
628   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
629   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
630   PORT_BIT( 0x7ff8, IP_ACTIVE_HIGH, IPT_UNUSED )
631   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
632
633   PORT_START("IN.1") // INT0
634   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)0)
525635INPUT_PORTS_END
526636
527637
r245297r245298
529639
530640   /* basic machine hardware */
531641   MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc.
642   MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, cdkong_plate_w))
643   MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cdkong_plate_w))
644   MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cdkong_plate_w))
645   MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cdkong_plate_w))
646   MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, cdkong_plate_w))
647   MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, cdkong_plate_w))
648   MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, cdkong_plate_w))
649   MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cdkong_grid_w))
650   MCFG_HMCS40_READ_D_CB(IOPORT("IN.0"))
532651
533//  MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
652   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
534653   MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test)
535654
536655   /* no video! */
r245297r245298
556675
557676***************************************************************************/
558677
678void hh_hmcs40_state::cgalaxn_display()
679{
680   UINT16 grid = BITSWAP16(m_grid,15,14,13,12,1,2,0,11,10,9,8,7,6,5,4,3);
681   UINT16 plate = BITSWAP16(m_plate,15,14,5,4,3,2,1,0,7,11,12,9,8,10,6,13);
682
683   //display_matrix(14, 12, plate, grid);
684   
685   grid<<=1; //todo -1
686   display_matrix(14, 13, plate, grid);
687}
688
689WRITE8_MEMBER(hh_hmcs40_state::cgalaxn_grid_w)
690{
691   // D0: speaker out
692   m_speaker->level_w(data & 1);
693   
694   // D1: speaker on?
695
696   // D2-D15: vfd matrix plate
697   m_plate = data >> 2 & 0x3fff;
698   cgalaxn_display();
699   
700   //        a, f, g, c, e, d, h, b, p, o, n, m, k, i
701   
702   //        0, 5, 6, 2, 4, 3, 7, 1,13,12,11,10, 9, 8
703   // 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
704   // 15,14, 5, 4, 3, 2, 1, 0, 7,11,12, 9, 8,10, 6,13
705}
706
707WRITE16_MEMBER(hh_hmcs40_state::cgalaxn_plate_w)
708{
709   // R10,R11: input mux
710   if (offset == HMCS40_PORT_R1X)
711      m_inp_mux = data & 3;
712   
713   // R1x-R3x: vfd matrix grid
714   int shift = (offset - HMCS40_PORT_R1X) * 4;
715   m_grid = (m_grid & ~(0xf << shift)) | (data << shift);
716   
717   cgalaxn_display();
718
719   //              9, 8, 7, 6, 5, 4, 3, 2, 1,11,12,10
720   
721   //              8, 7, 6, 5, 4, 3, 2, 1, 0,10,11, 9
722   // 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
723   // 15,14,13,12, 1, 2, 0,11,10, 9, 8, 7, 6, 5, 4, 3
724}
725
726READ8_MEMBER(hh_hmcs40_state::cgalaxn_input_r)
727{
728   // R0x: multiplexed inputs
729   return read_inputs(2);
730}
731
732
559733static INPUT_PORTS_START( cgalaxn )
734   PORT_START("IN.0") // R10 port R0x
735   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
736   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
737   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
738   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
739
740   PORT_START("IN.1") // R11 port R0x
741   PORT_CONFNAME( 0x01, 0x01, "Players" )
742   PORT_CONFSETTING(    0x01, "1" )
743   PORT_CONFSETTING(    0x00, "2" )
744   PORT_BIT( 0x0e, IP_ACTIVE_HIGH, IPT_UNUSED )
745
746   PORT_START("IN.2") // INT0
747   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)0)
748
749   PORT_START("IN.3") // INT1
750   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)1)
560751INPUT_PORTS_END
561752
562753
r245297r245298
564755
565756   /* basic machine hardware */
566757   MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc.
758   MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, cgalaxn_input_r))
759   MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cgalaxn_grid_w))
760   MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cgalaxn_grid_w))
761   MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cgalaxn_grid_w))
762   MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cgalaxn_plate_w))
567763
568//  MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
764   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
569765   MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test)
570766
571767   /* no video! */
r245297r245298
796992{
797993   UINT16 grid = BITSWAP16(m_grid,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
798994   UINT32 plate = BITSWAP24(m_plate,23,22,21,20,15,14,13,12,7,6,5,4,3,2,1,0,19,18,17,16,11,10,9,8);
995   plate |= 1 << 24; // for always-on plates
799996
800   display_matrix(24, 15, plate, grid);
997   display_matrix(24+1, 15, plate, grid);
801998}
802999
8031000WRITE16_MEMBER(hh_hmcs40_state::egalaxn2_grid_w)
r245297r245298
8991096***************************************************************************/
9001097
9011098// i/o hookup is identical to Galaxian 2, so we can use those handlers
902// note: plate numbers are 0-23, not 1-24(with 0 always-on)
1099// note: plate numbers are 0-23, not 1-24(with 24 always-on)
9031100
9041101static INPUT_PORTS_START( epacman2 )
9051102   PORT_START("IN.0") // D1 port R0x
r245297r245298
9701167
9711168***************************************************************************/
9721169
1170WRITE8_MEMBER(hh_hmcs40_state::pbqbert_plate_w)
1171{
1172   // R0x-R3x,D8: vfd matrix plate
1173   int shift = offset * 4;
1174   m_plate = (m_plate & ~(0xf << shift)) | (data << shift);
1175   
1176   // 31,30,29,25,26,27,28,29, 0, 1, 2, 3, 4, 5, 6, 7,24,23,21,20,19,18,17,16,15,14,13,12,11,10, 9, 8
1177   // 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
1178   // 31,30,24,25,26,27,28,15,14,29,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,16,17,18,19,20,21,22,23
1179
1180   // update display
1181   UINT32 plate = BITSWAP32(m_plate,31,30,24,25,26,27,28,15,14,29,13,12,11,10,9,8,7,6,5,4,3,2,1,0,16,17,18,19,20,21,22,23);
1182   plate |= 0x400000; // plate 22 is always on
1183   
1184   display_matrix(30, 8, plate, m_grid);
1185}
1186
1187WRITE16_MEMBER(hh_hmcs40_state::pbqbert_grid_w)
1188{
1189   // D14: speaker out
1190   m_speaker->level_w(data >> 14 & 1);
1191
1192   // D0-D7: vfd matrix grid
1193   m_grid = data & 0xff;
1194
1195   // D8: plate 25 (update display there)
1196   pbqbert_plate_w(space, 7, data >> 8 & 1);
1197}
1198
1199
9731200static INPUT_PORTS_START( pbqbert )
1201   PORT_START("IN.0") // port D
1202   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) // up-left
1203   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) // up-right
1204   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) // down-right
1205   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) // down-left
1206   PORT_BIT( 0xe1ff, IP_ACTIVE_HIGH, IPT_UNUSED )
9741207INPUT_PORTS_END
9751208
9761209
r245297r245298
9781211
9791212   /* basic machine hardware */
9801213   MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc.
1214   MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1215   MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1216   MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1217   MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1218   MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1219   MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1220   MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, pbqbert_plate_w))
1221   MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, pbqbert_grid_w))
1222   MCFG_HMCS40_READ_D_CB(IOPORT("IN.0"))
9811223
982//  MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
1224   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1))
9831225   MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test)
9841226
9851227   /* no video! */


Previous 199869 Revisions Next


© 1997-2024 The MAME Team