Previous 199869 Revisions Next

r30818 Wednesday 4th June, 2014 at 00:53:02 UTC by David Haywood
refactor slightly (nw)
[src/mame/drivers]kenseim.c

trunk/src/mame/drivers/kenseim.c
r30817r30818
138138{
139139public:
140140   kenseim_state(const machine_config &mconfig, device_type type, const char *tag)
141      : cps_state(mconfig, type, tag) { }
141      : cps_state(mconfig, type, tag),
142      m_to_68k_cmd(0)
143   { }
142144
143145   /* kenseim */
144   DECLARE_READ16_MEMBER(cps1_kensei_r);
145146   DECLARE_WRITE16_MEMBER(cps1_kensei_w);
146147   DECLARE_READ16_MEMBER(kensei_dsw_r);
147148   DECLARE_DRIVER_INIT(kenseim);
r30817r30818
157158
158159   DECLARE_READ8_MEMBER(i8255_portd_r); // mole input 1?
159160   DECLARE_READ8_MEMBER(i8255_porte_r); // mole input 2?
161   DECLARE_READ8_MEMBER(portc_r);  // 4 bit in - coins + start btns
160162
161163   // uncertain
162164   DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out
163165   DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out
164   DECLARE_READ8_MEMBER(portc_r);  // 4 bit in
165166   DECLARE_READ8_MEMBER(portd_r);  // 4 bit in
166167   DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out
167168
r30817r30818
170171   WRITE8_MEMBER(i8255_portf_w); // maybe strobe output?
171172
172173
173
174
175174   DECLARE_READ8_MEMBER(i8255_porta_default_r) { logerror("%s i8255 read port A but no handler assigned\n", machine().describe_context()); return 0xff; }
176175   DECLARE_READ8_MEMBER(i8255_portb_default_r) { logerror("%s i8255 read port B but no handler assigned\n", machine().describe_context()); return 0xff; }
177176   DECLARE_READ8_MEMBER(i8255_portc_default_r) { logerror("%s i8255 read port C but no handler assigned\n", machine().describe_context()); return 0xff; }
r30817r30818
188187   //DECLARE_WRITE8_MEMBER(porta_default_w) { logerror("%s write %02x to port A but no handler assigned\n", machine().describe_context(), data); }
189188   //DECLARE_WRITE8_MEMBER(portb_default_w) { logerror("%s write %02x to port B but no handler assigned\n", machine().describe_context(), data); }
190189
191   UINT32 m_led_serial_data;
192   int m_led_clock;
193   int m_led_latch;
190   int m_to_68k_cmd;
191   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_1234_r);
192   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_5678_r);
193   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_9_r);
194   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_req_r);
195   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_LVm_r);
196
194197   void set_leds(UINT32 ledstates);
198   int m_led_latch;
199   int m_led_serial_data;
200   int m_led_clock;
195201};
196202
203
197204void kenseim_state::set_leds(UINT32 ledstates)
198205{
199206   for (int i=0; i<20; i++)
r30817r30818
242249READ8_MEMBER(kenseim_state::i8255_portd_r)
243250{
244251   logerror("%s i8255 read port D (mole matrix / sensors input 1?)\n", machine().describe_context());
252   static int i = 0;
253   i++;
254
245255   //return 0xff;
246   return rand();// 0x00;
256   if (i&8) return 0x3f;
257   else return 0x00;
247258}
248259
249260READ8_MEMBER(kenseim_state::i8255_porte_r)
250261{
251262   logerror("%s i8255 read port E (mole matrix / sensors input 2?)\n", machine().describe_context());
263   static int i = 0;
264   i++;
265
252266   //return 0xff;
253   return rand();// 0x00;
267   if (i&8) return 0x3f;
268   else return 0x00;
254269}
255270
256271WRITE8_MEMBER(kenseim_state::i8255_porta_w) // maybe molesa output? (6-bits?)
r30817r30818
273288WRITE8_MEMBER(kenseim_state::portc_w)
274289{
275290   // port direction is set to 4-in 4-out
276   logerror("%s write %02x to port C (%02x masked)\n", machine().describe_context(), data, data & 0xf0);
291   logerror("%s write %01x to port C (%02x unmasked)\n", machine().describe_context(), (data & 0xf0)>>4, data );
277292}
278293
279294WRITE8_MEMBER(kenseim_state::portd_w)
280295{
281296   // port direction is set to 4-in 4-out
282   logerror("%s write %02x to port D (%02x masked)\n", machine().describe_context(), data, data & 0x0f);
297   logerror("%s write %01x to port D (%02x unmasked)\n", machine().describe_context(), data & 0x0f, data) ;
283298}
284299
285300WRITE8_MEMBER(kenseim_state::porte_w)
r30817r30818
291306READ8_MEMBER(kenseim_state::portd_r)
292307{
293308   // port direction is set to 4-in 4-out
294   int ret = rand() & 0xf0;
309//   int ret = rand() & 0xf0;
295310
311   int ret = 0xf0;
312
296313   // comms port maybe? checks for 0x10 (bit 4,a) to be clear in a tight loop (092B) then for bit 0x80 to be set in another tight loop  (0933) then at (0947) it checks that bits 0xe0 aren't set.
297314   logerror("%s read port D\n", machine().describe_context());
298315   return ret;
r30817r30818
300317
301318READ8_MEMBER(kenseim_state::portc_r)
302319{
303   // port direction is set to 4-in 4-out
304   int ret = rand() & 0x0f;
320   // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons
321   // button order not confirmed
305322
323   // port direction is set to 4-in 4-out
324   //int ret = rand() & 0x0f;
306325   // bits 0x09 checked at 1171
307   logerror("%s read port C\n", machine().describe_context());
308
309   return ret;
326   //logerror("%s read port C\n", machine().describe_context());
327   return ioport("CAB-IN")->read();
310328}
311329
312330READ8_MEMBER(kenseim_state::porta_r)
r30817r30818
320338}
321339
322340
323READ16_MEMBER(kenseim_state::cps1_kensei_r)
324{
325   //
326   static int i = 0;
327   
328   int ret;
329341
330   ret = ((i & 0xf0) >> 4) | ((i & 0x0f) << 8);
331342
332   if (mem_mask & 0xff00) i++;
333
334   logerror("%s cps1_kensei_r offs %04x, (%04x) (68k reading command port %04x)\n", machine().describe_context(), offset *2, mem_mask, ret);
335
336   return ret | 0xf0f0;
337}
338
339343WRITE16_MEMBER(kenseim_state::cps1_kensei_w)
340344{
341345   if (mem_mask == 0xff00)
r30817r30818
452456   { NULL }
453457};
454458
455READ16_MEMBER(kenseim_state::kensei_dsw_r)
456{
457459
458
459   static const char *const dswname[] = { "IN0", "DSWA", "DSWB", "DSWC" };
460   
461   if (offset > 0)
462   {
463      //logerror("%s kensei_dsw_r offs %04x, (%04x)\n", machine().describe_context(), offset *2, mem_mask);
464
465      int in = ioport(dswname[offset])->read();
466      return (in << 8) | 0xff;
467   }
468   else
469   {  // connected to the other board instead of IN0? (or at least some bits are)
470
471      static int togglecount = 0;
472     
473      togglecount++;
474
475
476      int in = 0x00;
477      in |= 0x40; // don't want cps1 test mode (leftover) (not connected)
478     
479      in |= 0x04;// line D9
480
481      if (togglecount == 3)
482      {
483         in |= 0x10; // won't read commands otherwise? (REQ line)
484         togglecount = 0;
485      }   
486     
487     
488      //in |= 0x20; // LVm line
489
490      logerror("%s kensei_dsw_r offs %04x (comms?), (%04x) (returning %02x)\n", machine().describe_context(), offset *2, mem_mask, in);
491
492
493      return (in << 8) | 0xff;
494
495   }
496}
497
498
499460static MACHINE_CONFIG_DERIVED_CLASS( kenseim, cps1_12MHz, kenseim_state )
500461
501462   MCFG_CPU_ADD("gamecpu", TMPZ84C011, XTAL_16MHz/2) // tmpz84c011 - divider unknown
r30817r30818
539500
540501/* how the DRIVE PCB connects to the inputs, see comments after each line
541502
542   PORT_START("IN0")
543   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) // n/c
544   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) // n/c
545   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) // D9
546   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
547   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) // REQ
548   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) // LVm
549   PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) // n/c
550   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
551503
552   PORT_START("IN1")
553   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) // D5
554   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) // D6
555   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) // D7
556   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) // D8
557   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) // n/c
558   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) // n/c
559   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) // n/c
560   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
561   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) // D1
562   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) // D2
563   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) // D3
564   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) // D4
565   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) // n/c
566   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) // n/c
567   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) // n/c
568   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
569504*/
570505
506CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r)
507{
508//   printf("kenseim_cmd_1234_r\n")
509   return (m_to_68k_cmd & 0x00f)>>0;
510}
511
512CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r)
513{
514//   printf("kenseim_cmd_5678_r\n")
515   m_to_68k_cmd++; // hack
516   return (m_to_68k_cmd & 0x0f0)>>4;
517}
518
519CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r)
520{
521   return (m_to_68k_cmd & 0x100) >> 8; // bit 9 of command?
522}
523
524CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r)
525{
526   // hack
527   return rand();
528}
529
530CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r)
531{
532   // needed for COMMAND WAIT message..
533   return 0;
534}
535
536
571537static INPUT_PORTS_START( kenseim )
572538   // the regular CPS1 input ports are used for comms with the extra board
573   PORT_START("IN0")
574   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
539   PORT_START("IN0")
540   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED /*IPT_COIN1*/ ) // n/c
541   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED /*IPT_COIN2*/ ) // n/c
542   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, kenseim_state, kenseim_cmd_9_r, NULL) //   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) // D9
543   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
544   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, kenseim_state, kenseim_cmd_req_r, NULL) //   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) // REQ
545   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, kenseim_state, kenseim_cmd_LVm_r, NULL) //   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) // LVm
546   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) // PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) n/c
547   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
575548
576549   PORT_START("IN1")
577   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
550//   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) // D5
551//   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) // D6
552//   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) // D7
553//   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) // D8
554   PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, kenseim_state, kenseim_cmd_5678_r, NULL)
555   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED/*IPT_BUTTON1*/ ) /*PORT_PLAYER(1)*/ // n/c
556   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED/*IPT_BUTTON2*/ ) /*PORT_PLAYER(1)*/ // n/c
557   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED/*IPT_BUTTON3*/ ) /*PORT_PLAYER(1)*/ // n/c
558   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
578559
560//   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) // D1
561//   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) // D2
562//   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) // D3
563//   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) // D4
564   PORT_BIT( 0x0f00, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, kenseim_state, kenseim_cmd_1234_r, NULL)
565   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED /*IPT_BUTTON1*/ ) /*PORT_PLAYER(2)*/ // n/c
566   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED /*IPT_BUTTON2*/ ) /*PORT_PLAYER(2)*/ // n/c
567   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED /*IPT_BUTTON3*/ ) /*PORT_PLAYER(2)*/ // n/c
568   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // n/c?
569
579570   // most of the regular CPS1 dips are unused 
580571   PORT_START("DSWA")
581572   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "CPSA SW(A):1" )
r30817r30818
656647   PORT_DIPNAME( 0x80, 0x00, "Test Mode" )                           PORT_DIPLOCATION("DRV SW(2):8")
657648   PORT_DIPSETTING(    0x00, "0" )
658649   PORT_DIPSETTING(    0x80, "1" )
650
651   PORT_START("CAB-IN")
652   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
653   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START1 )
654   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
655   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
659656INPUT_PORTS_END
660657
661658ROM_START( kenseim )
r30817r30818
709706
710707DRIVER_INIT_MEMBER(kenseim_state,kenseim)
711708{
712   m_maincpu->space(AS_PROGRAM).install_read_handler(0x800000, 0x800007, read16_delegate(FUNC(kenseim_state::cps1_kensei_r),this));
713   m_maincpu->space(AS_PROGRAM).install_read_handler(0x800018, 0x80001f, read16_delegate(FUNC(kenseim_state::kensei_dsw_r),this));
714
715709   m_maincpu->space(AS_PROGRAM).install_write_handler(0x800030, 0x800037, write16_delegate(FUNC(kenseim_state::cps1_kensei_w),this));
716710
717711   DRIVER_INIT_CALL(cps1);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team