Previous 199869 Revisions Next

r30863 Friday 6th June, 2014 at 14:09:31 UTC by David Haywood
shuffle some code around, comms still wrong (nw)
[src/mame/drivers]kenseim.c

trunk/src/mame/drivers/kenseim.c
r30862r30863
200200   UINT8 m_to_68k_cmd_d9;
201201   UINT8 m_to_68k_cmd_req;
202202   UINT8 m_to_68k_cmd_LVm;
203   
204   UINT8 m_to_68k_cmd_flags;
203205
204206   int m_from68k_ack;
205207   int m_from68k_st4;
r30862r30863
220222};
221223
222224
225/*******************************
226  Misc System Functions
227 ******************************/
228
223229void kenseim_state::set_leds(UINT32 ledstates)
224230{
225231   for (int i=0; i<20; i++)
r30862r30863
310316   logerror("%s write %01x to port C (%02x unmasked)\n", machine().describe_context(), (data & 0xf0)>>4, data );
311317}
312318
313WRITE8_MEMBER(kenseim_state::portd_w)
319
320READ8_MEMBER(kenseim_state::portc_r)
314321{
322   // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons
323   // button order not confirmed
324
315325   // port direction is set to 4-in 4-out
316   printf("%s write %01x to port D (%02x unmasked) (to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ;
326   //int ret = rand() & 0x0f;
327   // bits 0x09 checked at 1171
328   //logerror("%s read port C\n", machine().describe_context());
329   return ioport("CAB-IN")->read();
317330}
318331
319WRITE8_MEMBER(kenseim_state::porte_w)
332READ8_MEMBER(kenseim_state::porta_r)
320333{
321   // only access is at 0ABE, surrounded by port D reads / writes
322   m_to_68k_cmd_low = data;
323   printf("%s write %02x to port E (to 68k command bits?)\n", machine().describe_context(), data);
334   return ioport("DSW1")->read(); // confirmed by code
324335}
325336
326READ8_MEMBER(kenseim_state::portd_r)
337READ8_MEMBER(kenseim_state::portb_r)
327338{
328   // port direction is set to 4-in 4-out
329//   int ret = rand() & 0xf0;
339   return ioport("DSW2")->read(); // confirmed by code
340}
330341
331   int ret;
332342
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
343/*******************************
344  Comms?
345 ******************************/
335346
336   int in20 = m_from68k_st3;
337   int in40 = m_from68k_st2;
338347
339   ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7);
340348
341   // 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.
342   logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret);
343   return ret;
344}
345349
350/* 68k side COMMS reads */
346351
347READ8_MEMBER(kenseim_state::portc_r)
352CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r)
348353{
349   // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons
350   // button order not confirmed
354//   printf("kenseim_cmd_1234_r\n")
355   return (m_to_68k_cmd_low & 0x0f)>>0;
356}
351357
352   // port direction is set to 4-in 4-out
353   //int ret = rand() & 0x0f;
354   // bits 0x09 checked at 1171
355   //logerror("%s read port C\n", machine().describe_context());
356   return ioport("CAB-IN")->read();
358CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r)
359{
360//   printf("kenseim_cmd_5678_r\n")
361   return (m_to_68k_cmd_low & 0xf0)>>4;
357362}
358363
359READ8_MEMBER(kenseim_state::porta_r)
364CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r)
360365{
361   return ioport("DSW1")->read(); // confirmed by code
366   return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command?
362367}
363368
364READ8_MEMBER(kenseim_state::portb_r)
369CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r)
365370{
366   return ioport("DSW2")->read(); // confirmed by code
371   logerror("%s kenseim_cmd_req_r\n", machine().describe_context());
372   return m_to_68k_cmd_req;
367373}
368374
375CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r)
376{
377   // needed for COMMAND WAIT message..
378   return m_to_68k_cmd_LVm;;
379}
369380
381/* 68k side COMMS writes */
370382
371383
372384WRITE16_MEMBER(kenseim_state::cps1_kensei_w)
r30862r30863
386398      m_from68k_st2 = (data & 0x0400) >> 10;
387399      m_from68k_st3 = (data & 0x0800) >> 11;
388400   
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 );
401      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 );
390402
391403   }
392404   else
r30862r30863
395407   }
396408}
397409
410
411
412/* Z80 side COMMS writes */
413
414WRITE8_MEMBER(kenseim_state::portd_w)
415{
416   // port direction is set to 4-in 4-out
417   m_to_68k_cmd_flags = data & 0xf;
418
419   // bit 0x4, 0x02 bit 0x1 used.
420   // wrong
421
422   m_to_68k_cmd_req = (m_to_68k_cmd_flags&0x2)>>1;
423   m_to_68k_cmd_LVm = ((m_to_68k_cmd_flags & 0x4) >> 2) ^ 1;
424   m_to_68k_cmd_d9 = (m_to_68k_cmd_flags&0x1)>>0;
425
426   printf("%s write %01x to port D (%02x unmasked) (from DRIVE BOARD to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ;
427}
428
429WRITE8_MEMBER(kenseim_state::porte_w)
430{
431   // only access is at 0ABE, surrounded by port D reads / writes
432   m_to_68k_cmd_low = data;
433   printf("%s write %02x to port E (from DRIVE BOARD to 68k command bits?)\n", machine().describe_context(), data);
434}
435
436/* Z80 side COMMS reads */
437
438READ8_MEMBER(kenseim_state::portd_r)
439{
440   // port direction is set to 4-in 4-out
441//   int ret = rand() & 0xf0;
442
443   int ret;
444
445   int in10 = m_from68k_ack; // loop at 0x929 - 0x92e waits for this to be 0
446   int in80 = m_from68k_st4; // loop at 0x931 - 0x936 then waits for this to be 1
447
448   int in20 = m_from68k_st3;
449   int in40 = m_from68k_st2;
450
451   ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7);
452
453   // 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.
454   logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret);
455   return ret;
456}
457
458
459
460
398461/*
399462    Manufacturer: Fujitsu
400463    Part Number: MB89363 / MB89363B / MB89363R
r30862r30863
534597   MCFG_QUANTUM_PERFECT_CPU("maincpu")
535598MACHINE_CONFIG_END
536599
537
538CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r)
539{
540//   printf("kenseim_cmd_1234_r\n")
541   return (m_to_68k_cmd_low & 0x0f)>>0;
542}
543
544CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r)
545{
546//   printf("kenseim_cmd_5678_r\n")
547   m_to_68k_cmd_low = rand();// hack;
548
549   return (m_to_68k_cmd_low & 0xf0)>>4;
550}
551
552CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r)
553{
554   return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command?
555}
556
557CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r)
558{
559   m_to_68k_cmd_req = rand()&1; // hack
560
561   return m_to_68k_cmd_req;
562}
563
564
565CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r)
566{
567   // needed for COMMAND WAIT message..
568   return m_to_68k_cmd_LVm;
569}
570
571
572600static INPUT_PORTS_START( kenseim )
573601   // the regular CPS1 input ports are used for comms with the extra board
574602   PORT_START("IN0")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team