src/mess/drivers/pc8801.c
| r10029 | r10030 | |
| 10 | 10 | - macros for the various rom / ram areas, it might require various attempts in order to finally get a reasonable arrangement ... |
| 11 | 11 | - dipswitches are WRONG |
| 12 | 12 | - currently it's too slow ... why? |
| 13 | - implement proper i8214 routing, also add irq latch mechanism. |
| 13 | 14 | - below notes states that plain PC-8801 doesn't have a disk CPU, but the BIOS clearly checks the floppy ports. Wrong info? |
| 14 | 15 | |
| 15 | 16 | Notes: |
| r10029 | r10030 | |
| 103 | 104 | #include "machine/i8255a.h" |
| 104 | 105 | #include "machine/upd1990a.h" |
| 105 | 106 | #include "machine/upd765.h" |
| 107 | #include "machine/i8214.h" |
| 106 | 108 | #include "sound/2203intf.h" |
| 107 | 109 | #include "sound/beep.h" |
| 108 | 110 | |
| 109 | 111 | static UINT32 bankr[5],bankw[5]; |
| 110 | | static UINT8 bank_wp[5]; |
| 111 | 112 | static UINT8 i8255_0_pc,i8255_1_pc; |
| 112 | 113 | static UINT8 fdc_irq_opcode; |
| 113 | | static UINT8 ext_rom_bank,gfx_ctrl,vram_sel; |
| 114 | | static UINT8 vrtc_irq_mask; |
| 114 | static UINT8 ext_rom_bank,gfx_ctrl,vram_sel,misc_ctrl; |
| 115 | static UINT8 vrtc_irq_mask,sound_irq_mask; |
| 115 | 116 | static UINT8 window_offset_bank; |
| 116 | 117 | |
| 117 | 118 | #define NBASIC_BASE 0x20000 |
| r10029 | r10030 | |
| 171 | 172 | { |
| 172 | 173 | UINT8 *ram = space->machine->region("maincpu")->base(); |
| 173 | 174 | |
| 174 | | if(bank_wp[0]) |
| 175 | | return; |
| 176 | | |
| 177 | 175 | ram[offset + bankw[0]] = data; |
| 178 | 176 | } |
| 179 | 177 | |
| r10029 | r10030 | |
| 188 | 186 | { |
| 189 | 187 | UINT8 *ram = space->machine->region("maincpu")->base(); |
| 190 | 188 | |
| 191 | | if(bank_wp[1]) |
| 192 | | return; |
| 193 | | |
| 194 | 189 | ram[offset + bankw[1]] = data; |
| 195 | 190 | } |
| 196 | 191 | |
| r10029 | r10030 | |
| 207 | 202 | { |
| 208 | 203 | UINT8 *ram = space->machine->region("maincpu")->base(); |
| 209 | 204 | |
| 210 | | if(bank_wp[2]) |
| 211 | | return; |
| 212 | | |
| 213 | 205 | offset &= 0x3ff; |
| 214 | 206 | |
| 215 | 207 | ram[offset + bankw[2]] = data; |
| r10029 | r10030 | |
| 226 | 218 | { |
| 227 | 219 | UINT8 *ram = space->machine->region("maincpu")->base(); |
| 228 | 220 | |
| 229 | | if(bank_wp[3]) |
| 230 | | return; |
| 231 | | |
| 232 | 221 | ram[offset + bankw[3]] = data; |
| 233 | 222 | } |
| 234 | 223 | |
| r10029 | r10030 | |
| 243 | 232 | { |
| 244 | 233 | UINT8 *ram = space->machine->region("maincpu")->base(); |
| 245 | 234 | |
| 246 | | if(bank_wp[4]) |
| 247 | | return; |
| 248 | | |
| 249 | 235 | ram[offset + bankw[4]] = data; |
| 250 | 236 | } |
| 251 | 237 | |
| r10029 | r10030 | |
| 266 | 252 | return WRAM_BASE + 0x6000; |
| 267 | 253 | |
| 268 | 254 | if(gfx_ctrl & 0x4) //n basic select |
| 269 | | { |
| 270 | 255 | return NBASIC_BASE + 0x6000; |
| 271 | | } |
| 272 | 256 | |
| 273 | 257 | if(ext_rom_bank & 1) // NOT ext ROM bank |
| 274 | 258 | return N88BASIC_BASE + 0x6000; |
| r10029 | r10030 | |
| 326 | 310 | if(vram_sel == 3) |
| 327 | 311 | return WRAM_BASE + 0xf000; |
| 328 | 312 | |
| 329 | | return GRAM_BASE + 0x3000 + 0x4000 * vram_sel; |
| 313 | return GRAM_BASE + 0x3000 + (0x4000 * vram_sel); |
| 330 | 314 | } |
| 331 | 315 | |
| 332 | 316 | |
| r10029 | r10030 | |
| 389 | 373 | bankw[1] = pc8801_bankswitch_1_w(space->machine); |
| 390 | 374 | } |
| 391 | 375 | |
| 376 | static READ8_HANDLER( pc8801_vram_select_r ) |
| 377 | { |
| 378 | return (0xf8) | (vram_sel << 1); |
| 379 | } |
| 380 | |
| 392 | 381 | static WRITE8_HANDLER( pc8801_vram_select_w ) |
| 393 | 382 | { |
| 394 | 383 | vram_sel = offset & 3; |
| r10029 | r10030 | |
| 418 | 407 | static WRITE8_HANDLER( pc8801_window_bank_inc_w ) |
| 419 | 408 | { |
| 420 | 409 | window_offset_bank++; |
| 410 | window_offset_bank&=0xff; |
| 421 | 411 | bankr[2] = pc8801_bankswitch_2_r(space->machine); |
| 422 | 412 | bankw[2] = pc8801_bankswitch_2_w(space->machine); |
| 423 | 413 | } |
| 424 | 414 | |
| 415 | static READ8_HANDLER( pc8801_misc_ctrl_r ) |
| 416 | { |
| 417 | return misc_ctrl; |
| 418 | } |
| 419 | |
| 420 | static WRITE8_HANDLER( pc8801_misc_ctrl_w ) |
| 421 | { |
| 422 | misc_ctrl = data; |
| 423 | |
| 424 | if(!(data & 0x80)) |
| 425 | sound_irq_mask = ((data & 0x80) == 0); |
| 426 | } |
| 427 | |
| 428 | |
| 425 | 429 | static ADDRESS_MAP_START( pc8801_io, ADDRESS_SPACE_IO, 8 ) |
| 426 | 430 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 427 | 431 | ADDRESS_MAP_UNMAP_HIGH |
| r10029 | r10030 | |
| 445 | 449 | // AM_RANGE(0x20, 0x21) AM_NOP /* RS-232C and cassette */ |
| 446 | 450 | AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") //AM_WRITE(pc88sr_outport_30) |
| 447 | 451 | AM_RANGE(0x31, 0x31) AM_READ_PORT("DSW2") AM_WRITE(pc8801_gfx_ctrl_w) |
| 448 | | // AM_RANGE(0x32, 0x32) AM_READWRITE(pc88sr_inport_32, pc88sr_outport_32) |
| 452 | AM_RANGE(0x32, 0x32) AM_READWRITE(pc8801_misc_ctrl_r, pc8801_misc_ctrl_w) |
| 449 | 453 | // AM_RANGE(0x34, 0x35) AM_WRITE(pc88sr_alu) |
| 450 | 454 | AM_RANGE(0x40, 0x40) AM_READ(pc8801_ctrl_r) //, pc88sr_outport_40) |
| 451 | 455 | AM_RANGE(0x44, 0x45) AM_DEVREADWRITE("ym2203", ym2203_r,ym2203_w) |
| 452 | 456 | // AM_RANGE(0x46, 0x47) AM_NOP /* OPNA extra port */ |
| 453 | 457 | // AM_RANGE(0x50, 0x51) AM_READWRITE(pc88_crtc_r, pc88_crtc_w) |
| 454 | 458 | // AM_RANGE(0x52, 0x5b) AM_WRITE(pc88_palette_w) |
| 455 | | // AM_RANGE(0x5c, 0x5c) AM_READ(pc88_vramtest_r) |
| 459 | AM_RANGE(0x5c, 0x5c) AM_READ(pc8801_vram_select_r) |
| 456 | 460 | AM_RANGE(0x5c, 0x5f) AM_WRITE(pc8801_vram_select_w) |
| 457 | 461 | // AM_RANGE(0x60, 0x68) AM_READWRITE(pc88_dmac_r, pc88_dmac_w) |
| 458 | 462 | // AM_RANGE(0x6e, 0x6e) AM_NOP /* CPU clock info */ |
| r10029 | r10030 | |
| 470 | 474 | // AM_RANGE(0xd8, 0xd8) AM_NOP /* GP-IB */ |
| 471 | 475 | // AM_RANGE(0xdc, 0xdf) AM_NOP /* MODEM */ |
| 472 | 476 | // AM_RANGE(0xe2, 0xe3) AM_READWRITE(pc88_extmem_r, pc88_extmem_w) /* expand RAM select */ |
| 473 | | // AM_RANGE(0xe4, 0xe4) AM_WRITE(pc8801_write_interrupt_level) |
| 477 | AM_RANGE(0xe4, 0xe4) AM_WRITENOP //AM_WRITE(pc8801_write_interrupt_level) |
| 474 | 478 | AM_RANGE(0xe6, 0xe6) AM_WRITE(pc8801_irq_mask_w) |
| 475 | 479 | // AM_RANGE(0xe7, 0xe7) AM_NOP /* (unknown) */ |
| 476 | 480 | // AM_RANGE(0xe8, 0xeb) AM_READWRITE(pc88_kanji_r, pc88_kanji_w) |
| r10029 | r10030 | |
| 484 | 488 | |
| 485 | 489 | static READ8_DEVICE_HANDLER( cpu_8255_c_r ) |
| 486 | 490 | { |
| 491 | timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync |
| 492 | |
| 487 | 493 | return i8255_1_pc >> 4; |
| 488 | 494 | } |
| 489 | 495 | |
| 490 | 496 | static WRITE8_DEVICE_HANDLER( cpu_8255_c_w ) |
| 491 | 497 | { |
| 498 | timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync |
| 499 | |
| 492 | 500 | i8255_0_pc = data; |
| 493 | 501 | } |
| 494 | 502 | |
| r10029 | r10030 | |
| 504 | 512 | |
| 505 | 513 | static READ8_DEVICE_HANDLER( fdc_8255_c_r ) |
| 506 | 514 | { |
| 515 | timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync |
| 516 | |
| 507 | 517 | return i8255_0_pc >> 4; |
| 508 | 518 | } |
| 509 | 519 | |
| 510 | 520 | static WRITE8_DEVICE_HANDLER( fdc_8255_c_w ) |
| 511 | 521 | { |
| 522 | timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync |
| 523 | |
| 512 | 524 | i8255_1_pc = data; |
| 513 | 525 | } |
| 514 | 526 | |
| r10029 | r10030 | |
| 847 | 859 | }; |
| 848 | 860 | |
| 849 | 861 | /* YM2203 Interface */ |
| 862 | static void pc8801_sound_irq( device_t *device, int irq ) |
| 863 | { |
| 864 | if(sound_irq_mask) |
| 865 | cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 4*2); |
| 866 | } |
| 850 | 867 | |
| 868 | |
| 851 | 869 | static READ8_DEVICE_HANDLER( opn_dummy_input ) { return 0xff; } |
| 852 | 870 | |
| 853 | 871 | static const ym2203_interface pc88_ym2203_intf = |
| r10029 | r10030 | |
| 860 | 878 | DEVCB_NULL, |
| 861 | 879 | DEVCB_NULL |
| 862 | 880 | }, |
| 863 | | NULL//pc88sr_sound_interupt |
| 881 | pc8801_sound_irq |
| 864 | 882 | }; |
| 865 | 883 | |
| 866 | 884 | /* Floppy Configuration */ |
| r10029 | r10030 | |
| 897 | 915 | ext_rom_bank = 0xff; |
| 898 | 916 | gfx_ctrl = 0x31; |
| 899 | 917 | window_offset_bank = 0x00; |
| 918 | misc_ctrl = 0x90; |
| 900 | 919 | bankr[0] = pc8801_bankswitch_0_r(machine); |
| 901 | 920 | bankr[1] = pc8801_bankswitch_1_r(machine); |
| 902 | 921 | bankw[0] = pc8801_bankswitch_0_w(machine); |
| r10029 | r10030 | |
| 911 | 930 | bankw[3] = pc8801_bankswitch_3_w(machine); |
| 912 | 931 | bankw[4] = pc8801_bankswitch_4_w(machine); |
| 913 | 932 | |
| 914 | | bank_wp[0] = 0; |
| 915 | | bank_wp[1] = 0; |
| 916 | | bank_wp[2] = 0; |
| 917 | | bank_wp[3] = 0; |
| 918 | | bank_wp[4] = 0; |
| 933 | fdc_irq_opcode = 0; //TODO: copied from PC-88VA, could be wrong here ... should be 0x7f ld a,a in the latter case |
| 919 | 934 | |
| 920 | | fdc_irq_opcode = 0; //TODO: copied from PC-88VA, could be wrong here ... should be 0x7f ld a,a in the latter case |
| 935 | vrtc_irq_mask = 0; |
| 936 | sound_irq_mask = 0; |
| 937 | |
| 938 | cpu_set_input_line_vector(machine->device("fdccpu"), 0, 0); |
| 921 | 939 | } |
| 922 | 940 | |
| 923 | 941 | static PALETTE_INIT( pc8801 ) |
| r10029 | r10030 | |
| 928 | 946 | palette_set_color_rgb(machine, i, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 929 | 947 | } |
| 930 | 948 | |
| 931 | | static WRITE_LINE_DEVICE_HANDLER(pc8801_upd765_interrupt) |
| 932 | | { |
| 933 | | cputag_set_input_line_and_vector(device->machine, "fdccpu", 0, HOLD_LINE, fdc_irq_opcode); |
| 934 | | }; |
| 935 | | |
| 936 | 949 | static const struct upd765_interface pc8801_upd765_interface = |
| 937 | 950 | { |
| 938 | | DEVCB_LINE(pc8801_upd765_interrupt), |
| 951 | DEVCB_CPU_INPUT_LINE("fdccpu", INPUT_LINE_IRQ0), |
| 939 | 952 | DEVCB_NULL, //DRQ, TODO |
| 940 | 953 | NULL, |
| 941 | 954 | UPD765_RDY_PIN_CONNECTED, |