src/mess/drivers/pc98.c
| r6000 | r6001 | |
| 2 | 2 | |
| 3 | 3 | NEC PC-98 computer series |
| 4 | 4 | |
| 5 | preliminary driver by Angelo Salese |
| 6 | |
| 7 | Reminder: tests A20 line feature, afaik it's NOT supported by the i386 core (along with protected mode / MMU) |
| 8 | |
| 9 | ======================================================================================== |
| 10 | |
| 5 | 11 | This series features a huge number of models released between 1982 and 1997. They |
| 6 | 12 | were not IBM PC-compatible, but they had similar hardware (and software: in the |
| 7 | 13 | 1990s, they run MS Windows as OS) |
| r6000 | r6001 | |
| 209 | 215 | #include "driver.h" |
| 210 | 216 | #include "cpu/i386/i386.h" |
| 211 | 217 | #include "machine/8255ppi.h" |
| 218 | #include "machine/pit8253.h" |
| 212 | 219 | |
| 213 | 220 | static UINT32 *pc9801_vram; |
| 221 | static UINT32 *gfx_bitmap_ram; |
| 222 | static UINT8 ems_bank; |
| 214 | 223 | |
| 215 | 224 | static VIDEO_START( pc9801 ) |
| 216 | 225 | { |
| 226 | gfx_bitmap_ram = auto_alloc_array(machine, UINT32, 0x18000*2); |
| 217 | 227 | } |
| 218 | 228 | |
| 219 | 229 | static VIDEO_UPDATE( pc9801 ) |
| r6000 | r6001 | |
| 345 | 355 | crtc_cmd_w(space,0,data); |
| 346 | 356 | } |
| 347 | 357 | |
| 358 | static WRITE8_HANDLER( ems_sel_w ) |
| 359 | { |
| 360 | if(offset == 3) |
| 361 | { |
| 362 | if(data == 0x22) |
| 363 | ems_bank = 1; |
| 364 | if(data == 0x20) |
| 365 | ems_bank = 0; |
| 366 | //printf("%02x %02x\n",offset,data); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | static READ8_HANDLER( port_70_r ) |
| 371 | { |
| 372 | if(offset & 1) |
| 373 | { |
| 374 | logerror("pit port $70 R access %02x\n",offset >> 1); |
| 375 | return mame_rand(space->machine);//pit8253_r(devtag_get_device(space->machine, "pit8253"), (offset & 6) >> 1); |
| 376 | } |
| 377 | |
| 378 | logerror("crtc port $70 R access %02x\n",offset >> 1); |
| 379 | return 0xff; |
| 380 | } |
| 381 | |
| 382 | static WRITE8_HANDLER( port_70_w ) |
| 383 | { |
| 384 | if(offset & 1) |
| 385 | { |
| 386 | logerror("pit port $70 W access %02x %02x\n",offset >> 1,data); |
| 387 | pit8253_w(devtag_get_device(space->machine, "pit8253"), (offset & 6) >> 1, data); |
| 388 | } |
| 389 | else |
| 390 | logerror("crtc port $70 W access %02x %02x\n",offset >> 1,data); |
| 391 | } |
| 392 | |
| 393 | /* FIXME */ |
| 394 | static READ8_HANDLER( port_00_r ) |
| 395 | { |
| 396 | if(!(offset & 1)) |
| 397 | { |
| 398 | logerror("pic8259 port $00 R access %02x\n",offset >> 1); |
| 399 | return mame_rand(space->machine);//pic8259_r(devtag_get_device(space->machine, "pic8259"), (offset & 6) >> 1); |
| 400 | } |
| 401 | |
| 402 | logerror("??? port $00 R access %02x\n",offset >> 1); |
| 403 | return 0xff; |
| 404 | } |
| 405 | |
| 406 | static WRITE8_HANDLER( port_00_w ) |
| 407 | { |
| 408 | if(!(offset & 1)) |
| 409 | { |
| 410 | logerror("pic8259 port $00 W access %02x %02x\n",offset >> 1,data); |
| 411 | //pic8259_w(devtag_get_device(space->machine, "pic8259"), (offset & 6) >> 1, data); |
| 412 | } |
| 413 | else |
| 414 | logerror("??? port $00 W access %02x %02x\n",offset >> 1,data); |
| 415 | } |
| 416 | |
| 417 | static READ32_HANDLER( gfx_bitmap_ram_r ) { return gfx_bitmap_ram[offset+ems_bank*0x18000/4]; } |
| 418 | static WRITE32_HANDLER( gfx_bitmap_ram_w ) { gfx_bitmap_ram[offset+ems_bank*0x18000/4] = data; } |
| 419 | |
| 348 | 420 | static ADDRESS_MAP_START( pc9801_mem, ADDRESS_SPACE_PROGRAM, 32) |
| 349 | | AM_RANGE(0x00000000, 0x0009ffff) AM_RAM |
| 350 | | AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE(&pc9801_vram) |
| 421 | AM_RANGE(0x00000000, 0x0009ffff) AM_MIRROR(0x00100000) AM_RAM |
| 422 | AM_RANGE(0x000a0000, 0x000a3fff) AM_RAM AM_BASE(&pc9801_vram) //vram + attr |
| 423 | AM_RANGE(0x000a4000, 0x000a4fff) AM_RAM //cg window |
| 424 | AM_RANGE(0x000a8000, 0x000bffff) AM_READWRITE(gfx_bitmap_ram_r,gfx_bitmap_ram_w) |
| 351 | 425 | AM_RANGE(0x000e0000, 0x000fffff) AM_ROM AM_REGION("maincpu",0) |
| 352 | 426 | AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("maincpu",0) |
| 353 | 427 | ADDRESS_MAP_END |
| r6000 | r6001 | |
| 355 | 429 | |
| 356 | 430 | |
| 357 | 431 | static ADDRESS_MAP_START( pc9801_io, ADDRESS_SPACE_IO, 32) |
| 358 | | // AM_RANGE(0x0000, 0x0000) pic8259 |
| 359 | | // AM_RANGE(0x0002, 0x0002) |
| 432 | AM_RANGE(0x0000, 0x000f) AM_READWRITE8(port_00_r,port_00_w,0xffffffff) // pic8259 (even ports) |
| 360 | 433 | // AM_RANGE(0x0020, 0x0020) rtc |
| 361 | 434 | // AM_RANGE(0x0022, 0x0022) |
| 362 | | // AM_RANGE(0x0030, 0x0030) rs232c (i8251 1) |
| 363 | | // AM_RANGE(0x0032, 0x0032) |
| 364 | | // AM_RANGE(0x0031, 0x0031) system port (ppi8255 1) |
| 365 | | // AM_RANGE(0x0033, 0x0033) |
| 366 | | // AM_RANGE(0x0035, 0x0035) |
| 367 | | // AM_RANGE(0x0037, 0x0037) |
| 368 | | AM_RANGE(0x0030, 0x0037) AM_READWRITE8(sys_port_r,sys_port_w,0xffffffff) |
| 369 | | // AM_RANGE(0x0040, 0x0040) printer port (ppi8255 2) |
| 370 | | // AM_RANGE(0x0042, 0x0042) |
| 371 | | // AM_RANGE(0x0044, 0x0044) |
| 372 | | // AM_RANGE(0x0046, 0x0046) |
| 373 | | // AM_RANGE(0x0041, 0x0041) keyboard (i8251 2) |
| 374 | | // AM_RANGE(0x0043, 0x0043) |
| 375 | | AM_RANGE(0x0040, 0x0047) AM_READWRITE8(sio_port_r,sio_port_w,0xffffffff) |
| 376 | | // AM_RANGE(0x0060, 0x0060) uPD7220 status reg / param write (for chars) |
| 377 | | // AM_RANGE(0x0062, 0x0062) uPD7220 fifo read / cmd write |
| 378 | | AM_RANGE(0x0060, 0x0063) AM_READWRITE8(port_60_r,port_60_w,0xffffffff) |
| 435 | AM_RANGE(0x0030, 0x0037) AM_READWRITE8(sys_port_r,sys_port_w,0xffffffff) // rs232c (even ports) / system ppi8255 (odd ports) |
| 436 | AM_RANGE(0x0040, 0x0047) AM_READWRITE8(sio_port_r,sio_port_w,0xffffffff) // printer ppi8255 (even ports) / keyboard (odd ports) |
| 437 | AM_RANGE(0x0060, 0x0063) AM_READWRITE8(port_60_r,port_60_w,0xffffffff) // uPD7220 status & fifo (R) / param & cmd (W) master (even ports) |
| 379 | 438 | // AM_RANGE(0x0064, 0x0064) V-SYNC related write |
| 380 | 439 | // AM_RANGE(0x0068, 0x0068) Flip-Flop 1 r/w |
| 381 | 440 | // AM_RANGE(0x006a, 0x006a) Flip-Flop 2 r/w |
| r6000 | r6001 | |
| 386 | 445 | // AM_RANGE(0x0076, 0x0076) |
| 387 | 446 | // AM_RANGE(0x0078, 0x0078) |
| 388 | 447 | // AM_RANGE(0x007a, 0x007a) |
| 389 | | // AM_RANGE(0x0071, 0x0071) pit8253 |
| 390 | | // AM_RANGE(0x0073, 0x0073) |
| 391 | | // AM_RANGE(0x0075, 0x0075) |
| 392 | | // AM_RANGE(0x0077, 0x0077) |
| 393 | 448 | // AM_RANGE(0x007c, 0x007c) GRCG mode write |
| 394 | 449 | // AM_RANGE(0x007e, 0x007e) GRCG tile write |
| 395 | | // AM_RANGE(0x00a0, 0x00a0) uPD7220 status reg / param write (for gfx) |
| 396 | | // AM_RANGE(0x00a2, 0x00a2) uPD7220 fifo read / cmd write |
| 397 | | AM_RANGE(0x00a0, 0x00a3) AM_READWRITE8(port_a0_r,port_a0_w,0xffffffff) |
| 450 | AM_RANGE(0x0070, 0x007f) AM_READWRITE8(port_70_r,port_70_w,0xffffffff) // crtc regs (even ports) / pit8253 (odd ports) |
| 451 | AM_RANGE(0x00a0, 0x00a3) AM_READWRITE8(port_a0_r,port_a0_w,0xffffffff) // uPD7220 status & fifo (R) / param & cmd (W) slave (even ports) |
| 398 | 452 | // AM_RANGE(0x00e0, 0x00ef) DMA |
| 399 | | // AM_RANGE(0x043f, 0x043f) EMS select (bankswitch) |
| 453 | AM_RANGE(0x043c, 0x043f) AM_WRITE8(ems_sel_w,0xffffffff) |
| 400 | 454 | |
| 401 | 455 | // (and many more...) |
| 402 | 456 | ADDRESS_MAP_END |
| r6000 | r6001 | |
| 504 | 558 | DEVCB_NULL /* Port C write */ |
| 505 | 559 | }; |
| 506 | 560 | |
| 561 | static PIT8253_OUTPUT_CHANGED( pc_timer0_w ) |
| 562 | { |
| 563 | // pic8259_set_irq_line(filetto_devices.pic8259_1, 0, state); |
| 564 | } |
| 565 | |
| 566 | static const struct pit8253_config pit8253_config = |
| 567 | { |
| 568 | { |
| 569 | { |
| 570 | 4772720/4, /* heartbeat IRQ */ |
| 571 | pc_timer0_w |
| 572 | }, { |
| 573 | 4772720/4, /* dram refresh */ |
| 574 | NULL |
| 575 | }, { |
| 576 | 4772720/4, /* pio port c pin 4, and speaker polling enough */ |
| 577 | NULL |
| 578 | } |
| 579 | } |
| 580 | }; |
| 581 | |
| 507 | 582 | /* I suspect the dump for pc9801 comes from a i386 later model... the original machine would use a i8086 @ 5Mhz CPU (see notes at top) */ |
| 508 | 583 | /* More investigations are required, but in the meanwhile I set a I386 as main CPU */ |
| 509 | 584 | static MACHINE_DRIVER_START( pc9801 ) |
| r6000 | r6001 | |
| 516 | 591 | |
| 517 | 592 | MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf ) |
| 518 | 593 | MDRV_PPI8255_ADD( "ppi8255_1", printer_intf ) |
| 594 | MDRV_PIT8253_ADD( "pit8253", pit8253_config ) |
| 519 | 595 | |
| 520 | 596 | /* video hardware */ |
| 521 | 597 | MDRV_SCREEN_ADD("screen", RASTER) |