Previous 15994 Revisions Next

r8711 Wednesday 4th August, 2010 at 21:18:30 UTC by Angelo Salese
[PC-6001]: Added preliminary MCU-driven joypad polling
[src/mess/drivers]pc6001.c

src/mess/drivers/pc6001.c
r8710r8711
1/*********************************************************************************
1/*******************************************************************************************************************************************************
22
3    NEC PC-6001 series
4    NEC PC-6600 series
3    PC-6001 series (c) 1981 NEC
54
65    preliminary driver by Angelo Salese
76
r8710r8711
1110    - cassette handling requires a decap of the MCU. It could be possible to
1211      do some tight synch between the master CPU and a code simulation,but I think
1312      it's not worth the effort...
14    - many games won't boot, check why;
13   - joypad polling probably needs some kind of masking when you're on BASIC.
1514    - make the later model to work;
1615    - Currently rewriting the video part without the MC6847 for two reasons:
1716        A) the later models have a custom video chip in the place of the MC6847,
r8710r8711
2019           have any docs atm.
2120
2221   TODO (game specific):
23   - 3D Asteroid Fire (and others): inputs doesn't work during gameplay;
24   - Arm Wrestling: returns an "?OM Error" during loading, it seems to be a N66
22   - Arm Wrestling (PD): returns an "?OM Error" during loading, it seems to be a N66
2523     BASIC -> PC-6001Mk2 game actually;
2624
2725==================================================================================
r8710r8711
7977
8078==================================================================================
8179
82irq vector 00: writes 0x00 to [$fa19]
83irq vector 02: (A = 0, B = 0) tests ppi port c, does something with ay ports (plus more?) ;keyboard data ready, no kanji lock, no caps lock
84irq vector 04: uart irq
85irq vector 06: operates with $fa28, $fa2e, $fd1b ;hblank? joypad irq?
86irq vector 08: tests ppi port c, puts port A to $fa1d,puts 0x02 to [$fa19] ;tape data ready
87irq vector 0A: writes 0x00 to [$fa19]
88irq vector 0C: writes 0x00 to [$fa19]
89irq vector 0E: same as 2, (A = 0x03, B = 0x00) ;? any press has the same effect as enter pressed twice, break input?
90irq vector 10: same as 2, (A = 0x03, B = 0x00)
91irq vector 12: writes 0x10 to [$fa19] ;end of tape reached
92irq vector 14: same as 2, (A = 0x00, B = 0x01) ;kanji lock enabled
93irq vector 16: tests ppi port c, writes the result to $feca. ;vblank
80PC-6001 irq table:
81irq vector 0x00: writes 0x00 to [$fa19]                                            ;(unused)
82irq vector 0x02: (A = 0, B = 0) tests ppi port c, does something with ay ports (plus more?) ;keyboard data ready, no kanji lock, no caps lock
83irq vector 0x04:                                                          ;uart irq
84irq vector 0x06: operates with $fa28, $fa2e, $fd1b                                  ;timer irq
85irq vector 0x08: tests ppi port c, puts port A to $fa1d,puts 0x02 to [$fa19]             ;tape data ready
86irq vector 0x0a: writes 0x00 to [$fa19]                                          ;(unused)
87irq vector 0x0c: writes 0x00 to [$fa19]                                          ;(unused)
88irq vector 0x0e: same as 2, (A = 0x03, B = 0x00)                                  ;keyboard data ready, unknown type
89irq vector 0x10: same as 2, (A = 0x03, B = 0x00)                                 ;(unused)
90irq vector 0x12: writes 0x10 to [$fa19]                                        ;end of tape reached
91irq vector 0x14: same as 2, (A = 0x00, B = 0x01)                                  ;kanji lock enabled
92irq vector 0x16: tests ppi port c, writes the result to $feca.                         ;joystick
93irq vector 0x18:                                                          ;TVR (?)
94irq vector 0x1a:                                                          ;Date
95irq vector 0x1c:                                                          ;(unused)
96irq vector 0x1e:                                                          ;(unused)
97irq vector 0x20:                                                          ;voice
98irq vector 0x22:                                                          ;VRTC (?)
99irq vector 0x24:                                                          ;(unused)
100irq vector 0x26:                                                          ;(unused)
94101
95102
96*********************************************************************************/
103*******************************************************************************************************************************************************/
97104
98105#include "emu.h"
99106#include "cpu/z80/z80.h"
r8710r8711
352359   }
353360
354361   sys_latch = data;
355   printf("%02x\n",data);
362   //printf("%02x\n",data);
356363}
357364
358365#if 0
r8710r8711
385392
386393static UINT8 port_c_8255,cur_keycode;
387394
388static READ8_DEVICE_HANDLER(nec_ppi8255_r) {
389   if (offset==2) {
395static READ8_DEVICE_HANDLER(nec_ppi8255_r)
396{
397   //printf("%02x R\n",offset);
398   static UINT8 test;
399
400   if(input_code_pressed_once(device->machine,KEYCODE_Z))
401      test^=1;
402
403   if(test)
404   {
405      static int test2;
406
407      if(input_code_pressed_once(device->machine,KEYCODE_A))
408         test2++;
409      if(input_code_pressed_once(device->machine,KEYCODE_S))
410         test2--;
411
412      cur_keycode = test2;
413      popmessage("%02x",test2);
414   }
415
416   if (offset==2)
390417      return port_c_8255;
391   }
392418   else if(offset==0)
393419   {
394420      UINT8 res;
395421      res = cur_keycode;
396      cur_keycode = 0;
422      //cur_keycode = 0;
397423      return res;
398424   }
399   else {
400      return i8255a_r(device,offset);
401   }
425
426   return i8255a_r(device,offset);
402427}
403428
404static WRITE8_DEVICE_HANDLER(nec_ppi8255_w) {
405   if (offset==3) {
406      if(data & 1) {
429static WRITE8_DEVICE_HANDLER(nec_ppi8255_w)
430{
431//   printf("%02x %02x W\n",offset,data);
432
433   if (offset==3)
434   {
435      if(data & 1)
407436         port_c_8255 |=   1<<((data>>1)&0x07);
408      } else {
437      else
409438         port_c_8255 &= ~(1<<((data>>1)&0x07));
410      }
439
411440      switch(data) {
412441           case 0x08: port_c_8255 |= 0x88; break;
413442           case 0x09: port_c_8255 &= 0xf7; break;
r8710r8711
415444           case 0x0d: port_c_8255 &= 0xf7; break;
416445           default: break;
417446      }
447
418448      port_c_8255 |= 0xa8;
419449
420450      {
r8710r8711
737767
738768static WRITE8_DEVICE_HANDLER (pc6001_8255_porta_w )
739769{
740   if(data != 0x06)
741      printf("pc6001_8255_porta_w %02x\n",data);
770//   if(data != 0x06)
771//      printf("pc6001_8255_porta_w %02x\n",data);
742772}
743773
744774static READ8_DEVICE_HANDLER (pc6001_8255_portb_r )
r8710r8711
831861   return 0;
832862}
833863
864static UINT8 check_joy_press(running_machine *machine)
865{
866   /* check joycode */
867   {
868      UINT8 p1_key = input_port_read(machine,"P1") ^ 0xff;
869
870      popmessage("%02x",p1_key);
871
872      /*
873         PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
874         PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
875         PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
876         PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
877         PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
878         PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
879         PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
880         PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
881      */
882
883      if(p1_key & 0x01) return 0x64; //up
884      if(p1_key & 0x02) return 0x68; //down
885      if(p1_key & 0x04) return 0x60; //left
886      if(p1_key & 0x08) return 0x70; //right
887      if(p1_key & 0x10) return 0x80; //fire
888   }
889
890   return 0;
891}
892
834893static TIMER_CALLBACK(cassette_callback)
835894{
836895   if(cas_switch == 1)
r8710r8711
889948   UINT32 key2 = input_port_read(machine,"key2");
890949   UINT32 key3 = input_port_read(machine,"key3");
891950   static UINT32 old_key1,old_key2,old_key3;
951//   UINT8 p1_key = input_port_read(machine, "P1");;
892952
893953   if(cas_switch == 0)
894954   {
r8710r8711
901961         old_key2 = key2;
902962         old_key3 = key3;
903963      }
964      else /* joypad polling */
965      {
966         cur_keycode = check_joy_press(space->machine);
967         if(cur_keycode)
968         {
969            irq_vector = 0x02;
970            cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
971         }
972      }
904973   }
905974}
906975

Previous 15994 Revisions Next


© 1998-2018 The MESS Team