Previous 199869 Revisions Next

r30914 Monday 9th June, 2014 at 17:26:32 UTC by hap
some cleanup, got rid of unneeded trampolines
[src/mame/drivers]kenseim.c

trunk/src/mame/drivers/kenseim.c
r30913r30914
5454  --------------------------------------------------------------------------------------------------------------|
5555
5656  TMPZ84C011 - Toshiba Z80 + CTC + custom I/O, chip is rated 8MHz
57  MB89363B   - Fujitsu 6-port I/O chip, basically two 8255. See below for more info!
57  MB89363B   - Fujitsu 6-port I/O chip, basically two 8255
5858  TC55257BFL - Toshiba 32KB SRAM
5959  62381      - Toshiba TD62381F, common LED driver
6060  62064      - Toshiba TD62064AF, 4ch high current darlington sink driver
r30913r30914
207207
208208   // certain
209209
210   DECLARE_READ8_MEMBER(porta_r); // dsw1 - 8 bit in
211   DECLARE_READ8_MEMBER(portb_r); // dsw2 - 8 bit in
210   DECLARE_WRITE8_MEMBER(mb8936_portc_w); // 20x LEDs
212211
213   DECLARE_WRITE8_MEMBER(i8255_portc_w); // 20x LEDs
214212
215   // likely
216213
217   DECLARE_READ8_MEMBER(i8255_portd_r); // mole input 1?
218   DECLARE_READ8_MEMBER(i8255_porte_r); // mole input 2?
219   DECLARE_READ8_MEMBER(portc_r);  // 4 bit in - coins + start btns
220
221214   // uncertain
222   DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out (lamps, coinlock etc.?)
215   DECLARE_WRITE8_MEMBER(cpu_portc_w); // 4 bit out (lamps, coinlock etc.?)
223216
224   DECLARE_READ8_MEMBER(portd_r);  // 4 bit in (comms flags from 68k)
217   DECLARE_READ8_MEMBER(cpu_portd_r);  // 4 bit in (comms flags from 68k)
225218
226   DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out (command flags to 68k?)
227   DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out (command to 68k?)
219   DECLARE_WRITE8_MEMBER(cpu_portd_w); // 4 bit out (command flags to 68k?)
220   DECLARE_WRITE8_MEMBER(cpu_porte_w); // 8 bit out (command to 68k?)
228221
229   WRITE8_MEMBER(i8255_porta_w); // maybe molesa output? (6-bits?)
230   WRITE8_MEMBER(i8255_portb_w); // maybe molesb output? (6-bits?)
231   WRITE8_MEMBER(i8255_portf_w); // maybe strobe output?
222   WRITE8_MEMBER(mb8936_porta_w); // maybe molesa output? (6-bits?)
223   WRITE8_MEMBER(mb8936_portb_w); // maybe molesb output? (6-bits?)
224   WRITE8_MEMBER(mb8936_portf_w); // maybe strobe output?
232225
233   // unused based on port direction assignments
234   //DECLARE_READ8_MEMBER(porte_default_r) { logerror("%s read port E but no handler assigned\n", machine().describe_context()); return 0xff; }
235   //DECLARE_WRITE8_MEMBER(porta_default_w) { logerror("%s write %02x to port A but no handler assigned\n", machine().describe_context(), data); }
236   //DECLARE_WRITE8_MEMBER(portb_default_w) { logerror("%s write %02x to port B but no handler assigned\n", machine().describe_context(), data); }
237
238226   UINT8 m_to_68k_cmd_low;
239227   UINT8 m_to_68k_cmd_d9;
240228   UINT8 m_to_68k_cmd_req;
r30913r30914
275263}
276264
277265// could be wrong
278WRITE8_MEMBER(kenseim_state::i8255_portc_w)
266WRITE8_MEMBER(kenseim_state::mb8936_portc_w)
279267{
280268   // I'm guessing these are the 20 'power meter' LEDs, 10 for each player? (it writes 42 times, with the last write being some terminator?)
281269
282//   printf("%s i8255 write %02x to port C but no handler assigned (serial data?)\n", machine().describe_context(), data);
270//   printf("%s mb8936 write %02x to port C but no handler assigned (serial data?)\n", machine().describe_context(), data);
283271
284272   if (data & 0x08)
285273   {
r30913r30914
312300
313301}
314302
315// i8255 ports D and E tend to be used together in the code, and the input gets masked with 6 bits (0x3f)
316READ8_MEMBER(kenseim_state::i8255_portd_r)
317{
318   int retvalue = 0xc0; // todo, check if upper bits are used
319303
320   retvalue |= ioport("MOLEA")->read() & 0x3f;
321
322   return retvalue;
323}
324
325READ8_MEMBER(kenseim_state::i8255_porte_r)
304WRITE8_MEMBER(kenseim_state::mb8936_porta_w) // maybe molesa output? (6-bits?)
326305{
327   int retvalue = 0xc0; // todo, check if upper bits are used
306   //if (data&0xc0) printf("%s mb8936 write %02x to port A (mole output 1?)\n", machine().describe_context(), data);
328307
329   retvalue |= ioport("MOLEB")->read() & 0x3f;
330308
331   return retvalue;
332}
333
334WRITE8_MEMBER(kenseim_state::i8255_porta_w) // maybe molesa output? (6-bits?)
335{
336   //if (data&0xc0) printf("%s i8255 write %02x to port A (mole output 1?)\n", machine().describe_context(), data);
337
338
339309   for (int i = 0; i < 6; i++)
340310   {
341311      int bit = (data >> i) & 1;
r30913r30914
350320
351321}
352322
353WRITE8_MEMBER(kenseim_state::i8255_portb_w) // maybe molesb output? (6-bits?)
323WRITE8_MEMBER(kenseim_state::mb8936_portb_w) // maybe molesb output? (6-bits?)
354324{
355   //if (data&0xc0) printf("%s i8255 write %02x to port B (mole output 2?)\n", machine().describe_context(), data);
325   //if (data&0xc0) printf("%s mb8936 write %02x to port B (mole output 2?)\n", machine().describe_context(), data);
356326
357327   for (int i = 0; i < 6; i++)
358328   {
r30913r30914
368338
369339}
370340
371WRITE8_MEMBER(kenseim_state::i8255_portf_w)
341WRITE8_MEMBER(kenseim_state::mb8936_portf_w)
372342{
373343   // typically written when the 'moles' output is, maybe the 2 strobes?
374   //printf("%s i8255 write %02x to port F (strobe?)\n", machine().describe_context(), data);
344   //printf("%s mb8936 write %02x to port F (strobe?)\n", machine().describe_context(), data);
375345}
376346
377347
378WRITE8_MEMBER(kenseim_state::portc_w)
348WRITE8_MEMBER(kenseim_state::cpu_portc_w)
379349{
380350   // port direction is set to 4-in 4-out
381//   printf("%s write %01x to port C (%02x unmasked)\n", machine().describe_context(), (data & 0x30)>>4, data );
382
351   // d4: coin counter
352   // d5: coin lock
353   // d6: left start button lamp
354   // d7: right start button lamp
355   coin_lockout_w(machine(), 0, (data & 0x10) ? 0 : 1); // toggles if you attempt to insert a coin when there are already 15 coins inserted
356   coin_counter_w(machine(), 0, (data & 0x20) ? 0 : 1);
383357   output_set_value("startlamp1", (data & 0x80) ? 0 : 1);
384358   output_set_value("startlamp2", (data & 0x40) ? 0 : 1);
385   coin_counter_w(machine(), 0, (data & 0x20) ? 0 : 1);
386   coin_lockout_w(machine(), 0, (data & 0x10) ? 0 : 1); // toggles if you attempt to insert a coin when there are already 15 coins inserted
387
388359}
389360
390361
391READ8_MEMBER(kenseim_state::portc_r)
392{
393   // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons
394   // button order not confirmed
395362
396   // port direction is set to 4-in 4-out
397   //int ret = rand() & 0x0f;
398   // bits 0x09 checked at 1171
399   //logerror("%s read port C\n", machine().describe_context());
400   return ioport("CAB-IN")->read();
401}
402363
403READ8_MEMBER(kenseim_state::porta_r)
404{
405   return ioport("DSW1")->read(); // confirmed by code
406}
407364
408READ8_MEMBER(kenseim_state::portb_r)
409{
410   return ioport("DSW2")->read(); // confirmed by code
411}
412
413
414365/*******************************
415  Comms?
366  Comms
416367 ******************************/
417368
418
419
420
421369/* 68k side COMMS reads */
422370
423371CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r)
424372{
425//   printf("kenseim_cmd_1234_r\n")
426   return (m_to_68k_cmd_low & 0x0f)>>0;
373   return (m_to_68k_cmd_low & 0x0f) >> 0;
427374}
428375
429376CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r)
430377{
431//   printf("kenseim_cmd_5678_r\n")
432   return (m_to_68k_cmd_low & 0xf0)>>4;
378   return (m_to_68k_cmd_low & 0xf0) >> 4;
433379}
434380
435381CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r)
436382{
437   return m_to_68k_cmd_d9; // bit 9 of command?
383   return m_to_68k_cmd_d9;
438384}
439385
440386CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r)
441387{
442   //logerror("%s kenseim_cmd_req_r\n", machine().describe_context());
443388   return m_to_68k_cmd_req;
444389}
445390
r30913r30914
450395
451396/* 68k side COMMS writes */
452397
453
454398WRITE16_MEMBER(kenseim_state::cps1_kensei_w)
455399{
456
457400   if (ACCESSING_BITS_8_15)
458401   {
459   //   coin_counter_w(machine(), 0, data & 0x0100);
460   //   coin_counter_w(machine(), 1, data & 0x0200);
461   //   coin_lockout_w(machine(), 0, ~data & 0x0400);
462   //   coin_lockout_w(machine(), 1, ~data & 0x0800);
402      // NOTE: remapped from default jamma output pins:
403      // coin_counter_w(machine(), 0, data & 0x0100);
404      // coin_counter_w(machine(), 1, data & 0x0200);
405      // coin_lockout_w(machine(), 0, ~data & 0x0400);
406      // coin_lockout_w(machine(), 1, ~data & 0x0800);
463407
464408      // bit 15 = CPS-A custom reset?
465409
r30913r30914
467411      m_from68k_st4 = (data & 0x0200) >> 9;
468412      m_from68k_st2 = (data & 0x0400) >> 10;
469413      m_from68k_st3 = (data & 0x0800) >> 11;
470   
471      //printf("%s cps1_kensei_w offs %04x (from 68k to DRIVE BOARD via CN2) (%02x) (%d ACK,  %d ST4,  %d ST2,  %d ST3) \n", machine().describe_context(), offset * 2, data, m_from68k_ack, m_from68k_st4, m_from68k_st2, m_from68k_st3 );
472
473414   }
474   else
475   {
476      logerror("%s cps1_kensei_w offs %04x, %04x (%04x) (other byte)\n", machine().describe_context(), offset * 2, data, mem_mask);
477   }
478415}
479416
480417
418/* Z80 side COMMS reads */
481419
420READ8_MEMBER(kenseim_state::cpu_portd_r)
421{
422   // port direction is set to 4-in 4-out
423   // d4: ACK
424   // d5: ST2
425   // d6: ST3
426   // d7: ST4
427   return (m_from68k_ack << 4) | (m_from68k_st2 << 5) | (m_from68k_st3 << 6) | (m_from68k_st4 << 7);
428}
429
482430/* Z80 side COMMS writes */
483431
484WRITE8_MEMBER(kenseim_state::portd_w)
432WRITE8_MEMBER(kenseim_state::cpu_portd_w)
485433{
486434   // port direction is set to 4-in 4-out
487435   // d0: D9
r30913r30914
493441   m_to_68k_cmd_LVm = data >> 2 & 1;
494442}
495443
496WRITE8_MEMBER(kenseim_state::porte_w)
444WRITE8_MEMBER(kenseim_state::cpu_porte_w)
497445{
498446   // DT1-DT8
499447   m_to_68k_cmd_low = data;
500448}
501449
502/* Z80 side COMMS reads */
503450
504READ8_MEMBER(kenseim_state::portd_r)
505{
506   // port direction is set to 4-in 4-out
507   // d4: ACK
508   // d5: ST2
509   // d6: ST3
510   // d7: ST4
511   return (m_from68k_ack << 4) | (m_from68k_st2 << 5) | (m_from68k_st3 << 6) | (m_from68k_st4 << 7);
512}
513451
514452
515453
516454
517/*
518 
519*/
520455
521456static ADDRESS_MAP_START( kenseim_map, AS_PROGRAM, 8, kenseim_state )
522457   AM_RANGE(0x0000, 0x7fff) AM_ROM
r30913r30914
526461static ADDRESS_MAP_START( kenseim_io_map, AS_IO, 8, kenseim_state )
527462   ADDRESS_MAP_GLOBAL_MASK(0xff)
528463   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE("gamecpu_ctc", z80ctc_device, read, write)
529
530   AM_RANGE(0x20, 0x27) AM_DEVREADWRITE("mb89363b",   mb89363b_device, read, write)
531
464   AM_RANGE(0x20, 0x27) AM_DEVREADWRITE("mb89363b", mb89363b_device, read, write)
532465ADDRESS_MAP_END
533466
534467
r30913r30914
541474
542475static MACHINE_CONFIG_DERIVED_CLASS( kenseim, cps1_12MHz, kenseim_state )
543476
477   /* basic machine hardware */
544478   MCFG_CPU_ADD("gamecpu", TMPZ84C011, XTAL_16MHz/2) // tmpz84c011-8
545479   MCFG_CPU_PROGRAM_MAP(kenseim_map)
546480   MCFG_CPU_IO_MAP(kenseim_io_map)
547   //MCFG_TMPZ84C011_PORTA_WRITE_CB(WRITE8(kenseim_state, porta_default_w)) // unused?
548   //MCFG_TMPZ84C011_PORTB_WRITE_CB(WRITE8(kenseim_state, portb_default_w)) // unused?
549   MCFG_TMPZ84C011_PORTC_WRITE_CB(WRITE8(kenseim_state, portc_w))
550   MCFG_TMPZ84C011_PORTD_WRITE_CB(WRITE8(kenseim_state, portd_w))
551   MCFG_TMPZ84C011_PORTE_WRITE_CB(WRITE8(kenseim_state, porte_w))   
552   MCFG_TMPZ84C011_PORTA_READ_CB(READ8(kenseim_state, porta_r))
553   MCFG_TMPZ84C011_PORTB_READ_CB(READ8(kenseim_state, portb_r))
554   MCFG_TMPZ84C011_PORTC_READ_CB(READ8(kenseim_state, portc_r))
555   MCFG_TMPZ84C011_PORTD_READ_CB(READ8(kenseim_state, portd_r))
556   //MCFG_TMPZ84C011_PORTE_READ_CB(READ8(kenseim_state, porte_default_r)) // unused?
481   MCFG_TMPZ84C011_PORTC_WRITE_CB(WRITE8(kenseim_state, cpu_portc_w))
482   MCFG_TMPZ84C011_PORTD_WRITE_CB(WRITE8(kenseim_state, cpu_portd_w))
483   MCFG_TMPZ84C011_PORTE_WRITE_CB(WRITE8(kenseim_state, cpu_porte_w))
484   MCFG_TMPZ84C011_PORTA_READ_CB(IOPORT("DSW1"))
485   MCFG_TMPZ84C011_PORTB_READ_CB(IOPORT("DSW2"))
486   MCFG_TMPZ84C011_PORTC_READ_CB(IOPORT("CAB-IN"))
487   MCFG_TMPZ84C011_PORTD_READ_CB(READ8(kenseim_state, cpu_portd_r))
557488   MCFG_CPU_CONFIG(daisy_chain_gamecpu)
558489
559   MCFG_DEVICE_ADD("gamecpu_ctc", Z80CTC, XTAL_16MHz/2 ) // part of the tmpz84
490   MCFG_DEVICE_ADD("gamecpu_ctc", Z80CTC, XTAL_16MHz/2) // part of the tmpz84
560491   MCFG_Z80CTC_INTR_CB(INPUTLINE("gamecpu", INPUT_LINE_IRQ0))
561492
493   MCFG_MB89363B_ADD("mb89363b")
562494   // a,b,c always $80: all ports set as output
563495   // d,e,f always $92: port D and E as input, port F as output
564   
565   MCFG_MB89363B_ADD("mb89363b")
566   MCFG_MB89363B_OUT_PORTA_CB(WRITE8(kenseim_state, i8255_porta_w))
567   MCFG_MB89363B_OUT_PORTB_CB(WRITE8(kenseim_state, i8255_portb_w))
568   MCFG_MB89363B_OUT_PORTC_CB(WRITE8(kenseim_state, i8255_portc_w))
569   MCFG_MB89363B_IN_PORTD_CB(READ8(kenseim_state, i8255_portd_r))
570   MCFG_MB89363B_IN_PORTE_CB(READ8(kenseim_state, i8255_porte_r))
571   MCFG_MB89363B_OUT_PORTF_CB(WRITE8(kenseim_state, i8255_portf_w))
496   MCFG_MB89363B_OUT_PORTA_CB(WRITE8(kenseim_state, mb8936_porta_w))
497   MCFG_MB89363B_OUT_PORTB_CB(WRITE8(kenseim_state, mb8936_portb_w))
498   MCFG_MB89363B_OUT_PORTC_CB(WRITE8(kenseim_state, mb8936_portc_w))
499   MCFG_MB89363B_IN_PORTD_CB(IOPORT("MOLEA"))
500   MCFG_MB89363B_IN_PORTE_CB(IOPORT("MOLEB"))
501   MCFG_MB89363B_OUT_PORTF_CB(WRITE8(kenseim_state, mb8936_portf_w))
572502
573
574503   MCFG_QUANTUM_PERFECT_CPU("maincpu")
575504MACHINE_CONFIG_END
576505
r30913r30914
693622   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
694623
695624   PORT_START("MOLEA")
696   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_W) // big mole (2pts)
697   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_Q)
698   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_E)
699   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_A)
700   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_S)
701   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_D)
625   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_W) // big mole (2pts)
626   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_Q)
627   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_E)
628   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_A)
629   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_S)
630   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_D)
631   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
702632
703633   PORT_START("MOLEB")
704   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_8_PAD) // big mole (2pts)
705   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_7_PAD)
706   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_9_PAD)
707   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_4_PAD)
708   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_5_PAD)
709   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_6_PAD)
634   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_8_PAD) // big mole (2pts)
635   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_7_PAD)
636   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_9_PAD)
637   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_4_PAD)
638   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_5_PAD)
639   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_6_PAD)
640   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
641   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // ? (see disasm, it gets checked but seems to have no noticeable effect in-game)
710642INPUT_PORTS_END
711643
712644ROM_START( kenseim )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team