src/mess/drivers/x1.c
| r5511 | r5512 | |
| 18 | 18 | - Gaia/Space Harrier: Hits the FDC drive assert, the latter boots but has heavy emulation |
| 19 | 19 | video/logic problems; |
| 20 | 20 | |
| 21 | Notes: |
| 22 | - An interesting feature of the Sharp X-1 is the extended i/o bank. When the ppi port c bit 5 |
| 23 | does a 1->0 transition, the HW i/o is banked with an extra bitmap RAM to the entire 0-ffff |
| 24 | space, presumably for 640x200 bitmap gfxs. Any i/o read disables this extended bitmap ram. |
| 25 | |
| 21 | 26 | ================================================================================================= |
| 22 | 27 | |
| 23 | 28 | X1 (CZ-800C) - November, 1982 |
| r5511 | r5512 | |
| 129 | 134 | #include "machine/wd17xx.h" |
| 130 | 135 | #include "devices/basicdsk.h" |
| 131 | 136 | |
| 132 | | static UINT8 hres_320,io_switch; |
| 137 | static UINT8 hres_320,io_switch,io_sys; |
| 138 | static UINT8 io_bank_mode; |
| 133 | 139 | static UINT8 *gfx_bitmap_ram; |
| 134 | 140 | |
| 141 | |
| 135 | 142 | static VIDEO_START( x1 ) |
| 136 | 143 | { |
| 144 | colorram = auto_alloc_array(machine, UINT8, 0x1000); |
| 145 | videoram = auto_alloc_array(machine, UINT8, 0x1000); |
| 146 | gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000); |
| 137 | 147 | } |
| 138 | 148 | |
| 139 | 149 | static VIDEO_UPDATE( x1 ) |
| r5511 | r5512 | |
| 479 | 489 | } |
| 480 | 490 | } |
| 481 | 491 | |
| 492 | static READ8_HANDLER( x1_io_r ) |
| 493 | { |
| 494 | io_bank_mode = 0; //any read disables the extended mode. |
| 482 | 495 | |
| 496 | if (offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 497 | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 498 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 499 | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 500 | else if(offset >= 0x1a00 && offset <= 0x1aff) { return ppi8255_r(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3); } |
| 501 | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(devtag_get_device(space->machine, "ay"), 0); } |
| 502 | // else if(offset >= 0x1f90 && offset <= 0x1f93) { return x1_sio_r(space,(offset-0x1f90) & 3); } |
| 503 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); } |
| 504 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); } |
| 505 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 506 | else if(offset >= 0x2000 && offset <= 0x2fff) { return colorram[offset-0x2000]; } |
| 507 | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 508 | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000]; } |
| 509 | else |
| 510 | { |
| 511 | //... |
| 512 | } |
| 513 | return 0xff; |
| 514 | } |
| 515 | |
| 516 | static WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 517 | { |
| 518 | if(data) |
| 519 | fatalerror("Extended GFX RAM write %02x %04x",data,offset); |
| 520 | } |
| 521 | |
| 522 | static WRITE8_HANDLER( x1_io_w ) |
| 523 | { |
| 524 | if(io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 525 | else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x0704,data); } |
| 526 | // else if(offset >= 0x0c00 && offset <= 0x0cff) { x1_rs232c_w(space->machine, 0, data); } |
| 527 | else if(offset >= 0x0e00 && offset <= 0x0e02) { x1_rom_w(space, offset-0xe00,data); } |
| 528 | // else if(offset >= 0x0e80 && offset <= 0x0e82) { x1_kanji_w(space->machine, offset-0xe80,data); } |
| 529 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { x1_fdc_w(space, offset-0xff8,data); } |
| 530 | else if(offset >= 0x1000 && offset <= 0x10ff) { x1_pal_b_w(space, 0,data); } |
| 531 | else if(offset >= 0x1100 && offset <= 0x11ff) { x1_pal_g_w(space, 0,data); } |
| 532 | else if(offset >= 0x1200 && offset <= 0x12ff) { x1_pal_r_w(space, 0,data); } |
| 533 | // else if(offset >= 0x1300 && offset <= 0x13ff) { x1_ply_w(space->machine, 0,data; } |
| 534 | else if(offset >= 0x1400 && offset <= 0x17ff) { x1_pcg_w(space, offset-0x1400,data); } |
| 535 | else if(offset == 0x1800 ) { mc6845_address_w(devtag_get_device(space->machine, "crtc"), 0,data); } |
| 536 | else if(offset == 0x1801 ) { mc6845_register_w(devtag_get_device(space->machine, "crtc"), 0,data); } |
| 537 | else if(offset >= 0x1900 && offset <= 0x19ff) { sub_io_w(space, 0,data); } |
| 538 | else if(offset >= 0x1a00 && offset <= 0x1aff) { ppi8255_w(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3,data); } |
| 539 | else if(offset >= 0x1b00 && offset <= 0x1bff) { ay8910_data_w(devtag_get_device(space->machine, "ay"), 0,data); } |
| 540 | else if(offset >= 0x1c00 && offset <= 0x1cff) { ay8910_address_w(devtag_get_device(space->machine, "ay"), 0,data); } |
| 541 | else if(offset >= 0x1d00 && offset <= 0x1dff) { rom_bank_1_w(space,0,data); } |
| 542 | else if(offset >= 0x1e00 && offset <= 0x1eff) { rom_bank_0_w(space,0,data); } |
| 543 | else if(offset >= 0x1f80 && offset <= 0x1f80) { x1_dma_w(space,offset-0x1f80,data); } |
| 544 | // else if(offset >= 0x1f90 && offset <= 0x1f93) { x1_sio_w(space->machine,(offset-0x1f90) & 3),data; } |
| 545 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa3,data); } |
| 546 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa8,data); } |
| 547 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space->machine,offset-0x1fd0,data); } |
| 548 | else if(offset >= 0x2000 && offset <= 0x2fff) { colorram[offset-0x2000] = data; } |
| 549 | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = data; } |
| 550 | else if(offset >= 0x4000 && offset <= 0xffff) { gfx_bitmap_ram[offset-0x4000] = data; } |
| 551 | else |
| 552 | { |
| 553 | //... |
| 554 | } |
| 555 | } |
| 556 | |
| 483 | 557 | static ADDRESS_MAP_START( x1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 484 | 558 | ADDRESS_MAP_UNMAP_HIGH |
| 485 | 559 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(1) AM_WRITE(rom_data_w) |
| r5511 | r5512 | |
| 488 | 562 | |
| 489 | 563 | static ADDRESS_MAP_START( x1_io , ADDRESS_SPACE_IO, 8 ) |
| 490 | 564 | ADDRESS_MAP_UNMAP_HIGH |
| 491 | | // AM_RANGE(0x0700, 0x0701) AM_WRITENOP //YM-2151 reg/data |
| 492 | | AM_RANGE(0x0704, 0x0707) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w) |
| 493 | | // 0x0c00 rs232c port |
| 494 | | AM_RANGE(0x0e00, 0x0e02) AM_WRITE(x1_rom_w) |
| 495 | | AM_RANGE(0x0e03, 0x0e03) AM_READ(x1_rom_r) |
| 496 | | // AM_RANGE(0x0e80, 0x0e82) AM_WRITENOP //kanji registers? |
| 497 | | AM_RANGE(0x0ff8, 0x0fff) AM_READWRITE(x1_fdc_r,x1_fdc_w) //fdc registers |
| 498 | | AM_RANGE(0x1000, 0x10ff) AM_WRITE(x1_pal_b_w) //paletteram |
| 499 | | AM_RANGE(0x1100, 0x11ff) AM_WRITE(x1_pal_g_w) //paletteram |
| 500 | | AM_RANGE(0x1200, 0x12ff) AM_WRITE(x1_pal_r_w) //paletteram |
| 501 | | // AM_RANGE(0x1300, 0x13ff) AM_WRITENOP //ply port, mirrored |
| 502 | | AM_RANGE(0x1400, 0x17ff) AM_WRITE(x1_pcg_w) //PCG = Programmable Character Generator |
| 503 | | AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w) |
| 504 | | AM_RANGE(0x1801, 0x1801) AM_DEVWRITE("crtc", mc6845_register_w) |
| 505 | | AM_RANGE(0x1900, 0x19ff) AM_READWRITE(sub_io_r,sub_io_w) //sub port comms, mirrored |
| 506 | | AM_RANGE(0x1a00, 0x1a03) AM_MIRROR(0xfc) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w) //8255, mirrored |
| 507 | | AM_RANGE(0x1b00, 0x1bff) AM_DEVREADWRITE("ay", ay8910_r, ay8910_data_w) //PSG / ay-3-8910 data port |
| 508 | | AM_RANGE(0x1c00, 0x1cff) AM_DEVWRITE("ay", ay8910_address_w) //PSG / ay-3-8910 reg port |
| 509 | | AM_RANGE(0x1d00, 0x1dff) AM_READNOP AM_WRITE(rom_bank_1_w) //ROM/RAM bankswitch = ROM |
| 510 | | AM_RANGE(0x1e00, 0x1eff) AM_WRITE(rom_bank_0_w) //ROM/RAM bankswitch = RAM |
| 511 | | AM_RANGE(0x1f80, 0x1f8f) AM_WRITE(x1_dma_w) //dma |
| 512 | | // AM_RANGE(0x1f90, 0x1f93) AM_NOP //sio |
| 513 | | AM_RANGE(0x1fa0, 0x1fa3) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w) |
| 514 | | AM_RANGE(0x1fa8, 0x1fab) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w) |
| 515 | | // AM_RANGE(0x1fd0, 0x1fdf) AM_RAM //scrn? |
| 516 | | AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&colorram)//txt mode RAM |
| 517 | | AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE(&videoram)//txt mode RAM |
| 518 | | AM_RANGE(0x4000, 0xffff) AM_RAM AM_BASE(&gfx_bitmap_ram)//gfx mode bank b/g/r RAM |
| 565 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1_io_r, x1_io_w) |
| 519 | 566 | ADDRESS_MAP_END |
| 520 | 567 | |
| 521 | 568 | static const gfx_layout x1_chars_8x8 = |
| r5511 | r5512 | |
| 683 | 730 | -x-- ---- 320 mode (r/w) |
| 684 | 731 | --x- ---- i/o mode (r/w) |
| 685 | 732 | */ |
| 686 | | return (input_port_read(device->machine, "IOSYS") & 0x9f) | hres_320 | io_switch; |
| 733 | return (io_sys & 0x9f) | hres_320 | ~io_switch; |
| 687 | 734 | } |
| 688 | 735 | |
| 689 | 736 | static WRITE8_DEVICE_HANDLER( x1_porta_w ) |
| r5511 | r5512 | |
| 700 | 747 | { |
| 701 | 748 | //printf("PPI Port C write %02x\n",data); |
| 702 | 749 | hres_320 = data & 0x40; |
| 703 | | io_switch = ~data & 0x20; |
| 750 | |
| 751 | // if(hres_320 && data & 0x20 && io_switch & 0x20 && (data & 0xa0) != 0) |
| 752 | |
| 753 | if(((data & 0x20) == 0) && (io_switch & 0x20)) |
| 754 | io_bank_mode = 1; |
| 755 | |
| 756 | io_switch = data & 0x20; |
| 757 | io_sys = data & 0xff; |
| 758 | |
| 759 | //if(io_sys_state != io_sys) |
| 760 | // io_sys_state = io_sys; |
| 704 | 761 | } |
| 705 | 762 | |
| 706 | 763 | static const ppi8255_interface ppi8255_intf = |
| r5511 | r5512 | |
| 984 | 1041 | gfx_element_mark_dirty(machine->gfx[6], i); |
| 985 | 1042 | gfx_element_mark_dirty(machine->gfx[7], i); |
| 986 | 1043 | } |
| 1044 | |
| 1045 | io_bank_mode = 0; |
| 987 | 1046 | } |
| 988 | 1047 | |
| 989 | 1048 | static void ctc0_interrupt(const device_config *device, int state) |