Previous 199869 Revisions Next

r30824 Wednesday 4th June, 2014 at 11:24:58 UTC by David Haywood
misc, trying to understand comms (nw)
[src/mame/drivers]kenseim.c

trunk/src/mame/drivers/kenseim.c
r30823r30824
139139public:
140140   kenseim_state(const machine_config &mconfig, device_type type, const char *tag)
141141      : cps_state(mconfig, type, tag),
142      m_to_68k_cmd(0)
142      m_to_68k_cmd_low(0),
143      m_to_68k_cmd_d9(0),
144      m_to_68k_cmd_req(0),
145      m_to_68k_cmd_LVm(0),   
146      m_from68k_ack(0),
147      m_from68k_st4(0),
148      m_from68k_st3(0),
149      m_from68k_st2(0)
150
143151   { }
144152
145153   /* kenseim */
146154   DECLARE_WRITE16_MEMBER(cps1_kensei_w);
147   DECLARE_READ16_MEMBER(kensei_dsw_r);
148155   DECLARE_DRIVER_INIT(kenseim);
149156
150157   // certain
r30823r30824
161168   DECLARE_READ8_MEMBER(portc_r);  // 4 bit in - coins + start btns
162169
163170   // uncertain
164   DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out
165   DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out
166   DECLARE_READ8_MEMBER(portd_r);  // 4 bit in
167   DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out
171   DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out (lamps, coinlock etc.?)
168172
173   DECLARE_READ8_MEMBER(portd_r);  // 4 bit in (comms flags from 68k)
174
175   DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out (command flags to 68k?)
176   DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out (command to 68k?)
177
169178   WRITE8_MEMBER(i8255_porta_w); // maybe molesa output? (6-bits?)
170179   WRITE8_MEMBER(i8255_portb_w); // maybe molesb output? (6-bits?)
171180   WRITE8_MEMBER(i8255_portf_w); // maybe strobe output?
r30823r30824
187196   //DECLARE_WRITE8_MEMBER(porta_default_w) { logerror("%s write %02x to port A but no handler assigned\n", machine().describe_context(), data); }
188197   //DECLARE_WRITE8_MEMBER(portb_default_w) { logerror("%s write %02x to port B but no handler assigned\n", machine().describe_context(), data); }
189198
190   int m_to_68k_cmd;
199   UINT8 m_to_68k_cmd_low;
200   UINT8 m_to_68k_cmd_d9;
201   UINT8 m_to_68k_cmd_req;
202   UINT8 m_to_68k_cmd_LVm;
203
204   int m_from68k_ack;
205   int m_from68k_st4;
206   int m_from68k_st3;
207   int m_from68k_st2;
208
209
191210   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_1234_r);
192211   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_5678_r);
193212   DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_9_r);
r30823r30824
294313WRITE8_MEMBER(kenseim_state::portd_w)
295314{
296315   // port direction is set to 4-in 4-out
297   logerror("%s write %01x to port D (%02x unmasked)\n", machine().describe_context(), data & 0x0f, data) ;
316   printf("%s write %01x to port D (%02x unmasked) (to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ;
298317}
299318
300319WRITE8_MEMBER(kenseim_state::porte_w)
301320{
302321   // only access is at 0ABE, surrounded by port D reads / writes
303   logerror("%s write %02x to port E\n", machine().describe_context(), data);
322   m_to_68k_cmd_low = data;
323   printf("%s write %02x to port E (to 68k command bits?)\n", machine().describe_context(), data);
304324}
305325
306326READ8_MEMBER(kenseim_state::portd_r)
r30823r30824
308328   // port direction is set to 4-in 4-out
309329//   int ret = rand() & 0xf0;
310330
311   int ret = 0xf0;
331   int ret;
312332
333   int in10 = m_from68k_ack; // loop at 0x929 - 0x92e waits for this to be 0
334   int in80 = m_from68k_st4; // loop at 0x931 - 0x936 then waits for this to be 1
335
336   int in20 = m_from68k_st3;
337   int in40 = m_from68k_st2;
338
339   ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7);
340
313341   // 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.
314   logerror("%s read port D\n", machine().describe_context());
342   logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret);
315343   return ret;
316344}
317345
346
318347READ8_MEMBER(kenseim_state::portc_r)
319348{
320349   // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons
r30823r30824
342371
343372WRITE16_MEMBER(kenseim_state::cps1_kensei_w)
344373{
345   if (mem_mask == 0xff00)
374
375   if (ACCESSING_BITS_8_15)
346376   {
377   //   coin_counter_w(machine(), 0, data & 0x0100);
378   //   coin_counter_w(machine(), 1, data & 0x0200);
379   //   coin_lockout_w(machine(), 0, ~data & 0x0400);
380   //   coin_lockout_w(machine(), 1, ~data & 0x0800);
347381
348      data >>= 8;;
382      // bit 15 = CPS-A custom reset?
349383
350      logerror("%s cps1_kensei_w offs %04x (from 68k to DRIVE BOARD via CN2) (%02x) (%d ACK,  %d ST4,  %d ST3,  %d ST2) \n", machine().describe_context(), offset * 2, data, (data & 0x01), ((data & 0x02)>>1),((data & 0x04)>>2),((data & 0x08)>>3)   );
384      m_from68k_ack = (data & 0x0100) >> 8;
385      m_from68k_st4 = (data & 0x0200) >> 9;
386      m_from68k_st2 = (data & 0x0400) >> 10;
387      m_from68k_st3 = (data & 0x0800) >> 11;
388   
389      logerror("%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 );
351390
352
353      if (data & 0xf0)
354         logerror("  ^^ (unknown? %02x)\n", data & 0xf0);
355391   }
356392   else
357393   {
r30823r30824
498534   MCFG_QUANTUM_PERFECT_CPU("maincpu")
499535MACHINE_CONFIG_END
500536
501/* how the DRIVE PCB connects to the inputs, see comments after each line
502537
503
504*/
505
506538CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r)
507539{
508540//   printf("kenseim_cmd_1234_r\n")
509   return (m_to_68k_cmd & 0x00f)>>0;
541   return (m_to_68k_cmd_low & 0x0f)>>0;
510542}
511543
512544CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r)
513545{
514546//   printf("kenseim_cmd_5678_r\n")
515   m_to_68k_cmd++; // hack
516   return (m_to_68k_cmd & 0x0f0)>>4;
547   m_to_68k_cmd_low = rand();// hack;
548
549   return (m_to_68k_cmd_low & 0xf0)>>4;
517550}
518551
519552CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r)
520553{
521   return (m_to_68k_cmd & 0x100) >> 8; // bit 9 of command?
554   return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command?
522555}
523556
524557CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r)
525558{
526   // hack
527   return rand();
559   m_to_68k_cmd_req = rand()&1; // hack
560
561   return m_to_68k_cmd_req;
528562}
529563
564
530565CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r)
531566{
532567   // needed for COMMAND WAIT message..
533   return 0;
568   return m_to_68k_cmd_LVm;
534569}
535570
536571

Previous 199869 Revisions Next


© 1997-2024 The MAME Team