src/mess/drivers/pc6001.c
| r8710 | r8711 | |
| 1 | | /********************************************************************************* |
| 1 | /******************************************************************************************************************************************************* |
| 2 | 2 | |
| 3 | | NEC PC-6001 series |
| 4 | | NEC PC-6600 series |
| 3 | PC-6001 series (c) 1981 NEC |
| 5 | 4 | |
| 6 | 5 | preliminary driver by Angelo Salese |
| 7 | 6 | |
| r8710 | r8711 | |
| 11 | 10 | - cassette handling requires a decap of the MCU. It could be possible to |
| 12 | 11 | do some tight synch between the master CPU and a code simulation,but I think |
| 13 | 12 | 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. |
| 15 | 14 | - make the later model to work; |
| 16 | 15 | - Currently rewriting the video part without the MC6847 for two reasons: |
| 17 | 16 | A) the later models have a custom video chip in the place of the MC6847, |
| r8710 | r8711 | |
| 20 | 19 | have any docs atm. |
| 21 | 20 | |
| 22 | 21 | 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 |
| 25 | 23 | BASIC -> PC-6001Mk2 game actually; |
| 26 | 24 | |
| 27 | 25 | ================================================================================== |
| r8710 | r8711 | |
| 79 | 77 | |
| 80 | 78 | ================================================================================== |
| 81 | 79 | |
| 82 | | irq vector 00: writes 0x00 to [$fa19] |
| 83 | | irq 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 |
| 84 | | irq vector 04: uart irq |
| 85 | | irq vector 06: operates with $fa28, $fa2e, $fd1b ;hblank? joypad irq? |
| 86 | | irq vector 08: tests ppi port c, puts port A to $fa1d,puts 0x02 to [$fa19] ;tape data ready |
| 87 | | irq vector 0A: writes 0x00 to [$fa19] |
| 88 | | irq vector 0C: writes 0x00 to [$fa19] |
| 89 | | irq vector 0E: same as 2, (A = 0x03, B = 0x00) ;? any press has the same effect as enter pressed twice, break input? |
| 90 | | irq vector 10: same as 2, (A = 0x03, B = 0x00) |
| 91 | | irq vector 12: writes 0x10 to [$fa19] ;end of tape reached |
| 92 | | irq vector 14: same as 2, (A = 0x00, B = 0x01) ;kanji lock enabled |
| 93 | | irq vector 16: tests ppi port c, writes the result to $feca. ;vblank |
| 80 | PC-6001 irq table: |
| 81 | irq vector 0x00: writes 0x00 to [$fa19] ;(unused) |
| 82 | irq 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 |
| 83 | irq vector 0x04: ;uart irq |
| 84 | irq vector 0x06: operates with $fa28, $fa2e, $fd1b ;timer irq |
| 85 | irq vector 0x08: tests ppi port c, puts port A to $fa1d,puts 0x02 to [$fa19] ;tape data ready |
| 86 | irq vector 0x0a: writes 0x00 to [$fa19] ;(unused) |
| 87 | irq vector 0x0c: writes 0x00 to [$fa19] ;(unused) |
| 88 | irq vector 0x0e: same as 2, (A = 0x03, B = 0x00) ;keyboard data ready, unknown type |
| 89 | irq vector 0x10: same as 2, (A = 0x03, B = 0x00) ;(unused) |
| 90 | irq vector 0x12: writes 0x10 to [$fa19] ;end of tape reached |
| 91 | irq vector 0x14: same as 2, (A = 0x00, B = 0x01) ;kanji lock enabled |
| 92 | irq vector 0x16: tests ppi port c, writes the result to $feca. ;joystick |
| 93 | irq vector 0x18: ;TVR (?) |
| 94 | irq vector 0x1a: ;Date |
| 95 | irq vector 0x1c: ;(unused) |
| 96 | irq vector 0x1e: ;(unused) |
| 97 | irq vector 0x20: ;voice |
| 98 | irq vector 0x22: ;VRTC (?) |
| 99 | irq vector 0x24: ;(unused) |
| 100 | irq vector 0x26: ;(unused) |
| 94 | 101 | |
| 95 | 102 | |
| 96 | | *********************************************************************************/ |
| 103 | *******************************************************************************************************************************************************/ |
| 97 | 104 | |
| 98 | 105 | #include "emu.h" |
| 99 | 106 | #include "cpu/z80/z80.h" |
| r8710 | r8711 | |
| 352 | 359 | } |
| 353 | 360 | |
| 354 | 361 | sys_latch = data; |
| 355 | | printf("%02x\n",data); |
| 362 | //printf("%02x\n",data); |
| 356 | 363 | } |
| 357 | 364 | |
| 358 | 365 | #if 0 |
| r8710 | r8711 | |
| 385 | 392 | |
| 386 | 393 | static UINT8 port_c_8255,cur_keycode; |
| 387 | 394 | |
| 388 | | static READ8_DEVICE_HANDLER(nec_ppi8255_r) { |
| 389 | | if (offset==2) { |
| 395 | static 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) |
| 390 | 417 | return port_c_8255; |
| 391 | | } |
| 392 | 418 | else if(offset==0) |
| 393 | 419 | { |
| 394 | 420 | UINT8 res; |
| 395 | 421 | res = cur_keycode; |
| 396 | | cur_keycode = 0; |
| 422 | //cur_keycode = 0; |
| 397 | 423 | return res; |
| 398 | 424 | } |
| 399 | | else { |
| 400 | | return i8255a_r(device,offset); |
| 401 | | } |
| 425 | |
| 426 | return i8255a_r(device,offset); |
| 402 | 427 | } |
| 403 | 428 | |
| 404 | | static WRITE8_DEVICE_HANDLER(nec_ppi8255_w) { |
| 405 | | if (offset==3) { |
| 406 | | if(data & 1) { |
| 429 | static 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) |
| 407 | 436 | port_c_8255 |= 1<<((data>>1)&0x07); |
| 408 | | } else { |
| 437 | else |
| 409 | 438 | port_c_8255 &= ~(1<<((data>>1)&0x07)); |
| 410 | | } |
| 439 | |
| 411 | 440 | switch(data) { |
| 412 | 441 | case 0x08: port_c_8255 |= 0x88; break; |
| 413 | 442 | case 0x09: port_c_8255 &= 0xf7; break; |
| r8710 | r8711 | |
| 415 | 444 | case 0x0d: port_c_8255 &= 0xf7; break; |
| 416 | 445 | default: break; |
| 417 | 446 | } |
| 447 | |
| 418 | 448 | port_c_8255 |= 0xa8; |
| 419 | 449 | |
| 420 | 450 | { |
| r8710 | r8711 | |
| 737 | 767 | |
| 738 | 768 | static WRITE8_DEVICE_HANDLER (pc6001_8255_porta_w ) |
| 739 | 769 | { |
| 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); |
| 742 | 772 | } |
| 743 | 773 | |
| 744 | 774 | static READ8_DEVICE_HANDLER (pc6001_8255_portb_r ) |
| r8710 | r8711 | |
| 831 | 861 | return 0; |
| 832 | 862 | } |
| 833 | 863 | |
| 864 | static 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 | |
| 834 | 893 | static TIMER_CALLBACK(cassette_callback) |
| 835 | 894 | { |
| 836 | 895 | if(cas_switch == 1) |
| r8710 | r8711 | |
| 889 | 948 | UINT32 key2 = input_port_read(machine,"key2"); |
| 890 | 949 | UINT32 key3 = input_port_read(machine,"key3"); |
| 891 | 950 | static UINT32 old_key1,old_key2,old_key3; |
| 951 | // UINT8 p1_key = input_port_read(machine, "P1");; |
| 892 | 952 | |
| 893 | 953 | if(cas_switch == 0) |
| 894 | 954 | { |
| r8710 | r8711 | |
| 901 | 961 | old_key2 = key2; |
| 902 | 962 | old_key3 = key3; |
| 903 | 963 | } |
| 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 | } |
| 904 | 973 | } |
| 905 | 974 | } |
| 906 | 975 | |