src/mess/drivers/sg1000.c
| r9642 | r9643 | |
| 62 | 62 | |
| 63 | 63 | */ |
| 64 | 64 | |
| 65 | #define ADDRESS_MAP_MODERN |
| 66 | |
| 65 | 67 | #include "emu.h" |
| 66 | 68 | #include "cpu/z80/z80.h" |
| 67 | | #include "includes/sg1000.h" |
| 68 | 69 | #include "devices/flopdrv.h" |
| 69 | 70 | #include "devices/cartslot.h" |
| 70 | 71 | #include "devices/cassette.h" |
| r9642 | r9643 | |
| 79 | 80 | #include "sound/sn76496.h" |
| 80 | 81 | #include "video/tms9928a.h" |
| 81 | 82 | #include "crsshair.h" |
| 83 | #include "includes/sg1000.h" |
| 82 | 84 | |
| 83 | 85 | /*************************************************************************** |
| 84 | 86 | READ/WRITE HANDLERS |
| r9642 | r9643 | |
| 105 | 107 | tvdraw_axis_w - TV Draw axis select |
| 106 | 108 | -------------------------------------------------*/ |
| 107 | 109 | |
| 108 | | static WRITE8_HANDLER( tvdraw_axis_w ) |
| 110 | WRITE8_MEMBER( sg1000_state::tvdraw_axis_w ) |
| 109 | 111 | { |
| 110 | | sg1000_state *state = space->machine->driver_data<sg1000_state>(); |
| 111 | | |
| 112 | 112 | if (data & 0x01) |
| 113 | 113 | { |
| 114 | | state->tvdraw_data = input_port_read(space->machine, "TVDRAW_X"); |
| 114 | m_tvdraw_data = input_port_read(machine, "TVDRAW_X"); |
| 115 | 115 | |
| 116 | | if (state->tvdraw_data < 4) state->tvdraw_data = 4; |
| 117 | | if (state->tvdraw_data > 251) state->tvdraw_data = 251; |
| 116 | if (m_tvdraw_data < 4) m_tvdraw_data = 4; |
| 117 | if (m_tvdraw_data > 251) m_tvdraw_data = 251; |
| 118 | 118 | } |
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | | state->tvdraw_data = input_port_read(space->machine, "TVDRAW_Y") + 32; |
| 121 | m_tvdraw_data = input_port_read(machine, "TVDRAW_Y") + 32; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| r9642 | r9643 | |
| 126 | 126 | tvdraw_status_r - TV Draw status read |
| 127 | 127 | -------------------------------------------------*/ |
| 128 | 128 | |
| 129 | | static READ8_HANDLER( tvdraw_status_r ) |
| 129 | READ8_MEMBER( sg1000_state::tvdraw_status_r ) |
| 130 | 130 | { |
| 131 | | return input_port_read(space->machine, "TVDRAW_PEN"); |
| 131 | return input_port_read(machine, "TVDRAW_PEN"); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /*------------------------------------------------- |
| 135 | 135 | tvdraw_data_r - TV Draw data read |
| 136 | 136 | -------------------------------------------------*/ |
| 137 | 137 | |
| 138 | | static READ8_HANDLER( tvdraw_data_r ) |
| 138 | READ8_MEMBER( sg1000_state::tvdraw_data_r ) |
| 139 | 139 | { |
| 140 | | sg1000_state *state = space->machine->driver_data<sg1000_state>(); |
| 141 | | |
| 142 | | return state->tvdraw_data; |
| 140 | return m_tvdraw_data; |
| 143 | 141 | } |
| 144 | 142 | |
| 145 | 143 | /*------------------------------------------------- |
| 146 | | sg1000_joysel_r - |
| 144 | joysel_r - |
| 147 | 145 | -------------------------------------------------*/ |
| 148 | 146 | |
| 149 | | static READ8_HANDLER( sg1000_joysel_r ) |
| 147 | READ8_MEMBER( sg1000_state::joysel_r ) |
| 150 | 148 | { |
| 151 | 149 | return 0x80; |
| 152 | 150 | } |
| r9642 | r9643 | |
| 159 | 157 | ADDRESS_MAP( sg1000_map ) |
| 160 | 158 | -------------------------------------------------*/ |
| 161 | 159 | |
| 162 | | static ADDRESS_MAP_START( sg1000_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 160 | static ADDRESS_MAP_START( sg1000_map, ADDRESS_SPACE_PROGRAM, 8, sg1000_state ) |
| 163 | 161 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 164 | 162 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank1") |
| 165 | 163 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK("bank2") |
| r9642 | r9643 | |
| 169 | 167 | ADDRESS_MAP( sg1000_io_map ) |
| 170 | 168 | -------------------------------------------------*/ |
| 171 | 169 | |
| 172 | | static ADDRESS_MAP_START( sg1000_io_map, ADDRESS_SPACE_IO, 8 ) |
| 170 | static ADDRESS_MAP_START( sg1000_io_map, ADDRESS_SPACE_IO, 8, sg1000_state ) |
| 173 | 171 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 174 | | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE(SN76489A_TAG, sn76496_w) |
| 175 | | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 176 | | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 172 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 173 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 174 | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 177 | 175 | AM_RANGE(0xdc, 0xdc) AM_READ_PORT("PA7") |
| 178 | 176 | AM_RANGE(0xdd, 0xdd) AM_READ_PORT("PB7") |
| 179 | | AM_RANGE(0xde, 0xde) AM_READ(sg1000_joysel_r) AM_WRITENOP |
| 177 | AM_RANGE(0xde, 0xde) AM_READ(joysel_r) AM_WRITENOP |
| 180 | 178 | AM_RANGE(0xdf, 0xdf) AM_NOP |
| 181 | 179 | ADDRESS_MAP_END |
| 182 | 180 | |
| r9642 | r9643 | |
| 184 | 182 | ADDRESS_MAP( omv_map ) |
| 185 | 183 | -------------------------------------------------*/ |
| 186 | 184 | |
| 187 | | static ADDRESS_MAP_START( omv_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 185 | static ADDRESS_MAP_START( omv_map, ADDRESS_SPACE_PROGRAM, 8, sg1000_state ) |
| 188 | 186 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 189 | 187 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank1") |
| 190 | 188 | AM_RANGE(0xc000, 0xc7ff) AM_MIRROR(0x3800) AM_RAM |
| r9642 | r9643 | |
| 194 | 192 | ADDRESS_MAP( omv_io_map ) |
| 195 | 193 | -------------------------------------------------*/ |
| 196 | 194 | |
| 197 | | static ADDRESS_MAP_START( omv_io_map, ADDRESS_SPACE_IO, 8 ) |
| 195 | static ADDRESS_MAP_START( omv_io_map, ADDRESS_SPACE_IO, 8, sg1000_state ) |
| 198 | 196 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 199 | | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE(SN76489A_TAG, sn76496_w) |
| 200 | | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 201 | | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 197 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 198 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 199 | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 202 | 200 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x38) AM_READ_PORT("C0") |
| 203 | 201 | AM_RANGE(0xc1, 0xc1) AM_MIRROR(0x38) AM_READ_PORT("C1") |
| 204 | 202 | AM_RANGE(0xc2, 0xc2) AM_MIRROR(0x38) AM_READ_PORT("C2") |
| r9642 | r9643 | |
| 211 | 209 | ADDRESS_MAP( sc3000_map ) |
| 212 | 210 | -------------------------------------------------*/ |
| 213 | 211 | |
| 214 | | static ADDRESS_MAP_START( sc3000_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 212 | static ADDRESS_MAP_START( sc3000_map, ADDRESS_SPACE_PROGRAM, 8, sg1000_state ) |
| 215 | 213 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 216 | 214 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank1") |
| 217 | 215 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK("bank2") |
| r9642 | r9643 | |
| 221 | 219 | ADDRESS_MAP( sc3000_io_map ) |
| 222 | 220 | -------------------------------------------------*/ |
| 223 | 221 | |
| 224 | | static ADDRESS_MAP_START( sc3000_io_map, ADDRESS_SPACE_IO, 8 ) |
| 222 | static ADDRESS_MAP_START( sc3000_io_map, ADDRESS_SPACE_IO, 8, sg1000_state ) |
| 225 | 223 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 226 | | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE(SN76489A_TAG, sn76496_w) |
| 227 | | AM_RANGE(0xbe, 0xbe) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 228 | | AM_RANGE(0xbf, 0xbf) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 229 | | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE(UPD9255_TAG, i8255a_r, i8255a_w) |
| 224 | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 225 | AM_RANGE(0xbe, 0xbe) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 226 | AM_RANGE(0xbf, 0xbf) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 227 | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE_LEGACY(UPD9255_TAG, i8255a_r, i8255a_w) |
| 230 | 228 | ADDRESS_MAP_END |
| 231 | 229 | |
| 232 | 230 | /* This is how the I/O ports are really mapped, but MAME does not support overlapping ranges |
| 233 | | static ADDRESS_MAP_START( sc3000_io_map, ADDRESS_SPACE_IO, 8 ) |
| 231 | static ADDRESS_MAP_START( sc3000_io_map, ADDRESS_SPACE_IO, 8, sg1000_state ) |
| 234 | 232 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 235 | | AM_RANGE(0x00, 0x00) AM_MIRROR(0xdf) AM_DEVREADWRITE(UPD9255_TAG, i8255a_r, i8255a_w) |
| 236 | | AM_RANGE(0x00, 0x00) AM_MIRROR(0x7f) AM_DEVWRITE(SN76489A_TAG, sn76496_w) |
| 237 | | AM_RANGE(0x00, 0x00) AM_MIRROR(0xae) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 238 | | AM_RANGE(0x01, 0x01) AM_MIRROR(0xae) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 233 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xdf) AM_DEVREADWRITE_LEGACY(UPD9255_TAG, i8255a_r, i8255a_w) |
| 234 | AM_RANGE(0x00, 0x00) AM_MIRROR(0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 235 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xae) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 236 | AM_RANGE(0x01, 0x01) AM_MIRROR(0xae) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 239 | 237 | AM_RANGE(0x60, 0x60) AM_MIRROR(0x9f) AM_READ(sc3000_r_r) |
| 240 | 238 | ADDRESS_MAP_END |
| 241 | 239 | */ |
| r9642 | r9643 | |
| 244 | 242 | ADDRESS_MAP( sf7000_map ) |
| 245 | 243 | -------------------------------------------------*/ |
| 246 | 244 | |
| 247 | | static ADDRESS_MAP_START( sf7000_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 245 | static ADDRESS_MAP_START( sf7000_map, ADDRESS_SPACE_PROGRAM, 8, sf7000_state ) |
| 248 | 246 | AM_RANGE(0x0000, 0x3fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank2") |
| 249 | 247 | AM_RANGE(0x4000, 0xffff) AM_RAM |
| 250 | 248 | ADDRESS_MAP_END |
| r9642 | r9643 | |
| 253 | 251 | ADDRESS_MAP( sf7000_io_map ) |
| 254 | 252 | -------------------------------------------------*/ |
| 255 | 253 | |
| 256 | | static ADDRESS_MAP_START( sf7000_io_map, ADDRESS_SPACE_IO, 8 ) |
| 254 | static ADDRESS_MAP_START( sf7000_io_map, ADDRESS_SPACE_IO, 8, sf7000_state ) |
| 257 | 255 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 258 | | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE(SN76489A_TAG, sn76496_w) |
| 259 | | AM_RANGE(0xbe, 0xbe) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 260 | | AM_RANGE(0xbf, 0xbf) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 261 | | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE(UPD9255_0_TAG, i8255a_r, i8255a_w) |
| 262 | | AM_RANGE(0xe0, 0xe0) AM_DEVREAD(UPD765_TAG, upd765_status_r) |
| 263 | | AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE(UPD765_TAG, upd765_data_r, upd765_data_w) |
| 264 | | AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE(UPD9255_1_TAG, i8255a_r, i8255a_w) |
| 265 | | AM_RANGE(0xe8, 0xe8) AM_DEVREADWRITE(UPD8251_TAG, msm8251_data_r, msm8251_data_w) |
| 266 | | AM_RANGE(0xe9, 0xe9) AM_DEVREADWRITE(UPD8251_TAG, msm8251_status_r, msm8251_control_w) |
| 256 | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 257 | AM_RANGE(0xbe, 0xbe) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 258 | AM_RANGE(0xbf, 0xbf) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 259 | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE_LEGACY(UPD9255_0_TAG, i8255a_r, i8255a_w) |
| 260 | AM_RANGE(0xe0, 0xe0) AM_DEVREAD_LEGACY(UPD765_TAG, upd765_status_r) |
| 261 | AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE_LEGACY(UPD765_TAG, upd765_data_r, upd765_data_w) |
| 262 | AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE_LEGACY(UPD9255_1_TAG, i8255a_r, i8255a_w) |
| 263 | AM_RANGE(0xe8, 0xe8) AM_DEVREADWRITE_LEGACY(UPD8251_TAG, msm8251_data_r, msm8251_data_w) |
| 264 | AM_RANGE(0xe9, 0xe9) AM_DEVREADWRITE_LEGACY(UPD8251_TAG, msm8251_status_r, msm8251_control_w) |
| 267 | 265 | ADDRESS_MAP_END |
| 268 | 266 | |
| 269 | 267 | /*************************************************************************** |
| r9642 | r9643 | |
| 559 | 557 | I8255A_INTERFACE( sc3000_ppi_intf ) |
| 560 | 558 | -------------------------------------------------*/ |
| 561 | 559 | |
| 562 | | static READ8_DEVICE_HANDLER( sc3000_ppi_pa_r ) |
| 560 | READ8_MEMBER( sc3000_state::ppi_pa_r ) |
| 563 | 561 | { |
| 564 | 562 | /* |
| 565 | 563 | Signal Description |
| r9642 | r9643 | |
| 574 | 572 | PA7 Keyboard input |
| 575 | 573 | */ |
| 576 | 574 | |
| 577 | | sg1000_state *state = device->machine->driver_data<sg1000_state>(); |
| 578 | | |
| 579 | 575 | static const char *const keynames[] = { "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7" }; |
| 580 | 576 | |
| 581 | | return input_port_read(device->machine, keynames[state->keylatch]); |
| 577 | return input_port_read(machine, keynames[m_keylatch]); |
| 582 | 578 | } |
| 583 | 579 | |
| 584 | | static READ8_DEVICE_HANDLER( sc3000_ppi_pb_r ) |
| 580 | READ8_MEMBER( sc3000_state::ppi_pb_r ) |
| 585 | 581 | { |
| 586 | 582 | /* |
| 587 | 583 | Signal Description |
| r9642 | r9643 | |
| 596 | 592 | PB7 Cassette tape input |
| 597 | 593 | */ |
| 598 | 594 | |
| 599 | | sg1000_state *state = device->machine->driver_data<sg1000_state>(); |
| 600 | | |
| 601 | 595 | static const char *const keynames[] = { "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7" }; |
| 602 | 596 | |
| 603 | 597 | /* keyboard */ |
| 604 | | UINT8 data = input_port_read(device->machine, keynames[state->keylatch]); |
| 598 | UINT8 data = input_port_read(machine, keynames[m_keylatch]); |
| 605 | 599 | |
| 606 | 600 | /* cartridge contact */ |
| 607 | 601 | data |= 0x10; |
| r9642 | r9643 | |
| 610 | 604 | data |= 0x60; |
| 611 | 605 | |
| 612 | 606 | /* tape input */ |
| 613 | | if (cassette_input(state->cassette) > +0.0) data |= 0x80; |
| 607 | if (cassette_input(m_cassette) > +0.0) data |= 0x80; |
| 614 | 608 | |
| 615 | 609 | return data; |
| 616 | 610 | } |
| 617 | 611 | |
| 618 | | static WRITE8_DEVICE_HANDLER( sc3000_ppi_pc_w ) |
| 612 | WRITE8_MEMBER( sc3000_state::ppi_pc_w ) |
| 619 | 613 | { |
| 620 | 614 | /* |
| 621 | 615 | Signal Description |
| r9642 | r9643 | |
| 630 | 624 | PC7 /FEED to printer |
| 631 | 625 | */ |
| 632 | 626 | |
| 633 | | sg1000_state *state = device->machine->driver_data<sg1000_state>(); |
| 634 | | |
| 635 | 627 | /* keyboard */ |
| 636 | | state->keylatch = data & 0x07; |
| 628 | m_keylatch = data & 0x07; |
| 637 | 629 | |
| 638 | 630 | /* cassette */ |
| 639 | | cassette_output(state->cassette, BIT(data, 4) ? +1.0 : -1.0); |
| 631 | cassette_output(m_cassette, BIT(data, 4) ? +1.0 : -1.0); |
| 640 | 632 | |
| 641 | 633 | /* TODO printer */ |
| 642 | 634 | } |
| 643 | 635 | |
| 644 | 636 | static I8255A_INTERFACE( sc3000_ppi_intf ) |
| 645 | 637 | { |
| 646 | | DEVCB_HANDLER(sc3000_ppi_pa_r), // Port A read |
| 647 | | DEVCB_HANDLER(sc3000_ppi_pb_r), // Port B read |
| 648 | | DEVCB_NULL, // Port C read |
| 649 | | DEVCB_NULL, // Port A write |
| 650 | | DEVCB_NULL, // Port B write |
| 651 | | DEVCB_HANDLER(sc3000_ppi_pc_w), // Port C write |
| 638 | DEVCB_DRIVER_MEMBER(sc3000_state, ppi_pa_r), // Port A read |
| 639 | DEVCB_DRIVER_MEMBER(sc3000_state, ppi_pb_r), // Port B read |
| 640 | DEVCB_NULL, // Port C read |
| 641 | DEVCB_NULL, // Port A write |
| 642 | DEVCB_NULL, // Port B write |
| 643 | DEVCB_DRIVER_MEMBER(sc3000_state, ppi_pc_w), // Port C write |
| 652 | 644 | }; |
| 653 | 645 | |
| 654 | 646 | /*------------------------------------------------- |
| r9642 | r9643 | |
| 667 | 659 | I8255A_INTERFACE( sf7000_ppi_intf ) |
| 668 | 660 | -------------------------------------------------*/ |
| 669 | 661 | |
| 670 | | static READ8_DEVICE_HANDLER( sf7000_ppi_pa_r ) |
| 662 | READ8_MEMBER( sf7000_state::ppi_pa_r ) |
| 671 | 663 | { |
| 672 | 664 | /* |
| 673 | 665 | Signal Description |
| r9642 | r9643 | |
| 682 | 674 | PA7 |
| 683 | 675 | */ |
| 684 | 676 | |
| 685 | | sg1000_state *state = device->machine->driver_data<sg1000_state>(); |
| 686 | | UINT8 result = 0; |
| 677 | UINT8 data = 0; |
| 687 | 678 | |
| 688 | | result |= state->fdc_irq; |
| 689 | | result |= centronics_busy_r(state->centronics) << 1; |
| 690 | | result |= state->fdc_index << 2; |
| 679 | data |= m_fdc_irq; |
| 680 | data |= centronics_busy_r(m_centronics) << 1; |
| 681 | data |= m_fdc_index << 2; |
| 691 | 682 | |
| 692 | | return result; |
| 683 | return data; |
| 693 | 684 | } |
| 694 | 685 | |
| 695 | | static WRITE8_DEVICE_HANDLER( sf7000_ppi_pc_w ) |
| 686 | WRITE8_MEMBER( sf7000_state::ppi_pc_w ) |
| 696 | 687 | { |
| 697 | 688 | /* |
| 698 | 689 | Signal Description |
| r9642 | r9643 | |
| 707 | 698 | PC7 /STROBE to Centronics printer |
| 708 | 699 | */ |
| 709 | 700 | |
| 710 | | sg1000_state *state = device->machine->driver_data<sg1000_state>(); |
| 711 | | |
| 712 | 701 | /* floppy motor */ |
| 713 | | floppy_mon_w(floppy_get_device(device->machine, 0), BIT(data, 1)); |
| 714 | | floppy_drive_set_ready_state(floppy_get_device(device->machine, 0), 1, 1); |
| 702 | floppy_mon_w(m_floppy0, BIT(data, 1)); |
| 703 | floppy_drive_set_ready_state(m_floppy0, 1, 1); |
| 715 | 704 | |
| 716 | 705 | /* FDC terminal count */ |
| 717 | | upd765_tc_w(state->upd765, BIT(data, 2)); |
| 706 | upd765_tc_w(m_fdc, BIT(data, 2)); |
| 718 | 707 | |
| 719 | 708 | /* FDC reset */ |
| 720 | 709 | if (BIT(data, 3)) |
| 721 | 710 | { |
| 722 | | upd765_reset(state->upd765, 0); |
| 711 | upd765_reset(m_fdc, 0); |
| 723 | 712 | } |
| 724 | 713 | |
| 725 | 714 | /* ROM selection */ |
| 726 | | memory_set_bank(device->machine, "bank1", BIT(data, 6)); |
| 715 | memory_set_bank(machine, "bank1", BIT(data, 6)); |
| 727 | 716 | |
| 728 | 717 | /* printer strobe */ |
| 729 | | centronics_strobe_w(state->centronics, BIT(data, 7)); |
| 718 | centronics_strobe_w(m_centronics, BIT(data, 7)); |
| 730 | 719 | } |
| 731 | 720 | |
| 732 | 721 | static I8255A_INTERFACE( sf7000_ppi_intf ) |
| 733 | 722 | { |
| 734 | | DEVCB_HANDLER(sf7000_ppi_pa_r), // Port A read |
| 735 | | DEVCB_NULL, // Port B read |
| 736 | | DEVCB_NULL, // Port C read |
| 737 | | DEVCB_NULL, // Port A write |
| 723 | DEVCB_DRIVER_MEMBER(sf7000_state, ppi_pa_r), // Port A read |
| 724 | DEVCB_NULL, // Port B read |
| 725 | DEVCB_NULL, // Port C read |
| 726 | DEVCB_NULL, // Port A write |
| 738 | 727 | DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w), // Port B write |
| 739 | | DEVCB_HANDLER(sf7000_ppi_pc_w) // Port C write |
| 728 | DEVCB_DRIVER_MEMBER(sf7000_state, ppi_pc_w) // Port C write |
| 740 | 729 | }; |
| 741 | 730 | |
| 742 | 731 | /*------------------------------------------------- |
| 743 | 732 | upd765_interface sf7000_upd765_interface |
| 744 | 733 | -------------------------------------------------*/ |
| 745 | 734 | |
| 746 | | static WRITE_LINE_DEVICE_HANDLER( sf7000_fdc_interrupt ) |
| 735 | WRITE_LINE_MEMBER( sf7000_state::fdc_intrq_w ) |
| 747 | 736 | { |
| 748 | | sg1000_state *driver_state = device->machine->driver_data<sg1000_state>(); |
| 749 | | |
| 750 | | driver_state->fdc_irq = state; |
| 737 | m_fdc_irq = state; |
| 751 | 738 | } |
| 752 | 739 | |
| 753 | 740 | static const struct upd765_interface sf7000_upd765_interface = |
| 754 | 741 | { |
| 755 | | DEVCB_LINE(sf7000_fdc_interrupt), |
| 742 | DEVCB_DRIVER_LINE_MEMBER(sf7000_state, fdc_intrq_w), |
| 756 | 743 | DEVCB_NULL, |
| 757 | 744 | NULL, |
| 758 | 745 | UPD765_RDY_PIN_CONNECTED, |
| r9642 | r9643 | |
| 793 | 780 | ***************************************************************************/ |
| 794 | 781 | |
| 795 | 782 | /*------------------------------------------------- |
| 796 | | sg1000_map_cartridge_memory - |
| 783 | sg1000_install_cartridge - |
| 797 | 784 | -------------------------------------------------*/ |
| 798 | 785 | |
| 799 | | static void sg1000_map_cartridge_memory(running_machine *machine, UINT8 *ptr, int size) |
| 786 | void sg1000_state::install_cartridge(UINT8 *ptr, int size) |
| 800 | 787 | { |
| 801 | | address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 788 | address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM); |
| 802 | 789 | |
| 803 | 790 | switch (size) |
| 804 | 791 | { |
| r9642 | r9643 | |
| 819 | 806 | default: |
| 820 | 807 | if (IS_CARTRIDGE_TV_DRAW(ptr)) |
| 821 | 808 | { |
| 822 | | memory_install_write8_handler(program, 0x6000, 0x6000, 0, 0, &tvdraw_axis_w); |
| 823 | | memory_install_read8_handler(program, 0x8000, 0x8000, 0, 0, &tvdraw_status_r); |
| 824 | | memory_install_read8_handler(program, 0xa000, 0xa000, 0, 0, &tvdraw_data_r); |
| 809 | program->install_handler(0x6000, 0x6000, 0, 0, write8_delegate_create(sg1000_state, tvdraw_axis_w, *this), 0); |
| 810 | program->install_handler(0x8000, 0x8000, 0, 0, read8_delegate_create(sg1000_state, tvdraw_status_r, *this), 0); |
| 811 | program->install_handler(0xa000, 0xa000, 0, 0, read8_delegate_create(sg1000_state, tvdraw_data_r, *this), 0); |
| 825 | 812 | memory_nop_write(program, 0xa000, 0xa000, 0, 0); |
| 826 | 813 | } |
| 827 | 814 | else if (IS_CARTRIDGE_THE_CASTLE(ptr)) |
| r9642 | r9643 | |
| 838 | 825 | |
| 839 | 826 | static DEVICE_IMAGE_LOAD( sg1000_cart ) |
| 840 | 827 | { |
| 841 | | address_space *program = cputag_get_address_space(image.device().machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 828 | running_machine *machine = image.device().machine; |
| 829 | sg1000_state *state = machine->driver_data<sg1000_state>(); |
| 830 | address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 831 | UINT8 *ptr = memory_region(machine, Z80_TAG); |
| 842 | 832 | UINT32 size; |
| 843 | | UINT8 *ptr = memory_region(image.device().machine, Z80_TAG); |
| 844 | 833 | |
| 845 | 834 | if (image.software_entry() == NULL) |
| 846 | 835 | { |
| r9642 | r9643 | |
| 855 | 844 | } |
| 856 | 845 | |
| 857 | 846 | /* cartridge ROM banking */ |
| 858 | | sg1000_map_cartridge_memory(image.device().machine, ptr, size); |
| 847 | state->install_cartridge(ptr, size); |
| 859 | 848 | |
| 860 | 849 | /* work RAM banking */ |
| 861 | 850 | memory_install_readwrite_bank(program, 0xc000, 0xc3ff, 0, 0x3c00, "bank2"); |
| r9642 | r9643 | |
| 869 | 858 | |
| 870 | 859 | static DEVICE_IMAGE_LOAD( omv_cart ) |
| 871 | 860 | { |
| 861 | running_machine *machine = image.device().machine; |
| 862 | sg1000_state *state = machine->driver_data<sg1000_state>(); |
| 872 | 863 | UINT32 size; |
| 873 | | UINT8 *ptr = memory_region(image.device().machine, Z80_TAG); |
| 864 | UINT8 *ptr = memory_region(machine, Z80_TAG); |
| 874 | 865 | |
| 875 | 866 | if (image.software_entry() == NULL) |
| 876 | 867 | { |
| r9642 | r9643 | |
| 885 | 876 | } |
| 886 | 877 | |
| 887 | 878 | /* cartridge ROM banking */ |
| 888 | | sg1000_map_cartridge_memory(image.device().machine, ptr, size); |
| 879 | state->install_cartridge(ptr, size); |
| 889 | 880 | |
| 890 | 881 | return IMAGE_INIT_PASS; |
| 891 | 882 | } |
| 892 | 883 | |
| 893 | 884 | /*------------------------------------------------- |
| 894 | | sc3000_map_cartridge_memory - |
| 885 | sc3000_install_cartridge - |
| 895 | 886 | -------------------------------------------------*/ |
| 896 | 887 | |
| 897 | | static void sc3000_map_cartridge_memory(running_machine *machine, UINT8 *ptr, int size) |
| 888 | void sc3000_state::install_cartridge(UINT8 *ptr, int size) |
| 898 | 889 | { |
| 899 | | address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 890 | address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM); |
| 900 | 891 | |
| 901 | 892 | /* include SG-1000 mapping */ |
| 902 | | sg1000_map_cartridge_memory(machine, ptr, size); |
| 893 | sg1000_state::install_cartridge(ptr, size); |
| 903 | 894 | |
| 904 | 895 | if (IS_CARTRIDGE_BASIC_LEVEL_III(ptr)) |
| 905 | 896 | { |
| r9642 | r9643 | |
| 924 | 915 | |
| 925 | 916 | static DEVICE_IMAGE_LOAD( sc3000_cart ) |
| 926 | 917 | { |
| 918 | running_machine *machine = image.device().machine; |
| 919 | sc3000_state *state = machine->driver_data<sc3000_state>(); |
| 920 | UINT8 *ptr = memory_region(machine, Z80_TAG); |
| 927 | 921 | UINT32 size; |
| 928 | | UINT8 *ptr = memory_region(image.device().machine, Z80_TAG); |
| 929 | 922 | |
| 930 | 923 | if (image.software_entry() == NULL) |
| 931 | 924 | { |
| r9642 | r9643 | |
| 940 | 933 | } |
| 941 | 934 | |
| 942 | 935 | /* cartridge ROM and work RAM banking */ |
| 943 | | sc3000_map_cartridge_memory(image.device().machine, ptr, size); |
| 936 | state->install_cartridge(ptr, size); |
| 944 | 937 | |
| 945 | 938 | return IMAGE_INIT_PASS; |
| 946 | 939 | } |
| r9642 | r9643 | |
| 973 | 966 | MACHINE_START( sg1000 ) |
| 974 | 967 | -------------------------------------------------*/ |
| 975 | 968 | |
| 976 | | static MACHINE_START( sg1000 ) |
| 969 | void sg1000_state::machine_start() |
| 977 | 970 | { |
| 978 | | sg1000_state *state = machine->driver_data<sg1000_state>(); |
| 979 | | |
| 980 | 971 | /* configure VDP */ |
| 981 | 972 | TMS9928A_configure(&tms9928a_interface); |
| 982 | 973 | |
| r9642 | r9643 | |
| 984 | 975 | timer_set(machine, attotime_zero, NULL, 0, lightgun_tick); |
| 985 | 976 | |
| 986 | 977 | /* register for state saving */ |
| 987 | | state_save_register_global(machine, state->tvdraw_data); |
| 978 | state_save_register_global(machine, m_tvdraw_data); |
| 988 | 979 | } |
| 989 | 980 | |
| 990 | 981 | /*------------------------------------------------- |
| 991 | 982 | MACHINE_START( sc3000 ) |
| 992 | 983 | -------------------------------------------------*/ |
| 993 | 984 | |
| 994 | | static MACHINE_START( sc3000 ) |
| 985 | void sc3000_state::machine_start() |
| 995 | 986 | { |
| 996 | | sg1000_state *state = machine->driver_data<sg1000_state>(); |
| 997 | | |
| 998 | | /* find devices */ |
| 999 | | state->cassette = machine->device(CASSETTE_TAG); |
| 1000 | | |
| 1001 | 987 | /* configure VDP */ |
| 1002 | 988 | TMS9928A_configure(&tms9928a_interface); |
| 1003 | 989 | |
| r9642 | r9643 | |
| 1005 | 991 | timer_set(machine, attotime_zero, NULL, 0, lightgun_tick); |
| 1006 | 992 | |
| 1007 | 993 | /* register for state saving */ |
| 1008 | | state_save_register_global(machine, state->tvdraw_data); |
| 1009 | | state_save_register_global(machine, state->keylatch); |
| 994 | state_save_register_global(machine, m_tvdraw_data); |
| 995 | state_save_register_global(machine, m_keylatch); |
| 1010 | 996 | } |
| 1011 | 997 | |
| 1012 | 998 | /*------------------------------------------------- |
| r9642 | r9643 | |
| 1015 | 1001 | |
| 1016 | 1002 | static void sf7000_fdc_index_callback(running_device *controller, running_device *img, int state) |
| 1017 | 1003 | { |
| 1018 | | sg1000_state *driver_state = img->machine->driver_data<sg1000_state>(); |
| 1004 | sf7000_state *driver_state = img->machine->driver_data<sf7000_state>(); |
| 1019 | 1005 | |
| 1020 | | driver_state->fdc_index = state; |
| 1006 | driver_state->m_fdc_index = state; |
| 1021 | 1007 | } |
| 1022 | 1008 | |
| 1023 | 1009 | /*------------------------------------------------- |
| 1024 | 1010 | MACHINE_START( sf7000 ) |
| 1025 | 1011 | -------------------------------------------------*/ |
| 1026 | 1012 | |
| 1027 | | static MACHINE_START( sf7000 ) |
| 1013 | void sf7000_state::machine_start() |
| 1028 | 1014 | { |
| 1029 | | sg1000_state *state = machine->driver_data<sg1000_state>(); |
| 1030 | | |
| 1031 | | /* find devices */ |
| 1032 | | state->upd765 = machine->device(UPD765_TAG); |
| 1033 | | state->cassette = machine->device(CASSETTE_TAG); |
| 1034 | | state->centronics = machine->device(CENTRONICS_TAG); |
| 1035 | | |
| 1036 | 1015 | /* configure VDP */ |
| 1037 | 1016 | TMS9928A_configure(&tms9928a_interface); |
| 1038 | 1017 | |
| 1039 | 1018 | /* configure FDC */ |
| 1040 | | floppy_drive_set_index_pulse_callback(floppy_get_device(machine, 0), sf7000_fdc_index_callback); |
| 1019 | floppy_drive_set_index_pulse_callback(m_floppy0, sf7000_fdc_index_callback); |
| 1041 | 1020 | |
| 1042 | 1021 | /* configure memory banking */ |
| 1043 | 1022 | memory_configure_bank(machine, "bank1", 0, 1, memory_region(machine, Z80_TAG), 0); |
| 1044 | | memory_configure_bank(machine, "bank1", 1, 1, messram_get_ptr(machine->device("messram")), 0); |
| 1045 | | memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(machine->device("messram")), 0); |
| 1023 | memory_configure_bank(machine, "bank1", 1, 1, messram_get_ptr(m_ram), 0); |
| 1024 | memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(m_ram), 0); |
| 1046 | 1025 | |
| 1047 | 1026 | /* register for state saving */ |
| 1048 | | state_save_register_global(machine, state->keylatch); |
| 1049 | | state_save_register_global(machine, state->fdc_irq); |
| 1050 | | state_save_register_global(machine, state->fdc_index); |
| 1027 | state_save_register_global(machine, m_keylatch); |
| 1028 | state_save_register_global(machine, m_fdc_irq); |
| 1029 | state_save_register_global(machine, m_fdc_index); |
| 1051 | 1030 | } |
| 1052 | 1031 | |
| 1053 | 1032 | /*------------------------------------------------- |
| 1054 | 1033 | MACHINE_RESET( sf7000 ) |
| 1055 | 1034 | -------------------------------------------------*/ |
| 1056 | 1035 | |
| 1057 | | static MACHINE_RESET( sf7000 ) |
| 1036 | void sf7000_state::machine_reset() |
| 1058 | 1037 | { |
| 1059 | 1038 | memory_set_bank(machine, "bank1", 0); |
| 1060 | 1039 | memory_set_bank(machine, "bank2", 0); |
| r9642 | r9643 | |
| 1069 | 1048 | -------------------------------------------------*/ |
| 1070 | 1049 | |
| 1071 | 1050 | static MACHINE_CONFIG_START( sg1000, sg1000_state ) |
| 1072 | | |
| 1073 | 1051 | /* basic machine hardware */ |
| 1074 | 1052 | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) |
| 1075 | 1053 | MDRV_CPU_PROGRAM_MAP(sg1000_map) |
| 1076 | 1054 | MDRV_CPU_IO_MAP(sg1000_io_map) |
| 1077 | 1055 | MDRV_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1078 | 1056 | |
| 1079 | | MDRV_MACHINE_START(sg1000) |
| 1080 | | |
| 1081 | 1057 | /* video hardware */ |
| 1082 | 1058 | MDRV_FRAGMENT_ADD(tms9928a) |
| 1083 | 1059 | MDRV_SCREEN_MODIFY(SCREEN_TAG) |
| r9642 | r9643 | |
| 1109 | 1085 | -------------------------------------------------*/ |
| 1110 | 1086 | |
| 1111 | 1087 | static MACHINE_CONFIG_DERIVED( omv, sg1000 ) |
| 1112 | | |
| 1113 | 1088 | MDRV_CPU_MODIFY(Z80_TAG) |
| 1114 | 1089 | MDRV_CPU_PROGRAM_MAP(omv_map) |
| 1115 | 1090 | MDRV_CPU_IO_MAP(omv_io_map) |
| r9642 | r9643 | |
| 1127 | 1102 | MACHINE_CONFIG_START( sc3000, driver_device ) |
| 1128 | 1103 | -------------------------------------------------*/ |
| 1129 | 1104 | |
| 1130 | | static MACHINE_CONFIG_START( sc3000, sg1000_state ) |
| 1131 | | |
| 1105 | static MACHINE_CONFIG_START( sc3000, sc3000_state ) |
| 1132 | 1106 | /* basic machine hardware */ |
| 1133 | 1107 | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) // LH0080A |
| 1134 | 1108 | MDRV_CPU_PROGRAM_MAP(sc3000_map) |
| 1135 | 1109 | MDRV_CPU_IO_MAP(sc3000_io_map) |
| 1136 | 1110 | MDRV_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1137 | 1111 | |
| 1138 | | MDRV_MACHINE_START(sc3000) |
| 1139 | | |
| 1140 | 1112 | /* video hardware */ |
| 1141 | 1113 | MDRV_FRAGMENT_ADD(tms9928a) |
| 1142 | 1114 | MDRV_SCREEN_MODIFY(SCREEN_TAG) |
| r9642 | r9643 | |
| 1171 | 1143 | MACHINE_CONFIG_START( sf7000, driver_device ) |
| 1172 | 1144 | -------------------------------------------------*/ |
| 1173 | 1145 | |
| 1174 | | static MACHINE_CONFIG_START( sf7000, sg1000_state ) |
| 1175 | | |
| 1146 | static MACHINE_CONFIG_START( sf7000, sf7000_state ) |
| 1176 | 1147 | /* basic machine hardware */ |
| 1177 | 1148 | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) |
| 1178 | 1149 | MDRV_CPU_PROGRAM_MAP(sf7000_map) |
| 1179 | 1150 | MDRV_CPU_IO_MAP(sf7000_io_map) |
| 1180 | 1151 | MDRV_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1181 | 1152 | |
| 1182 | | MDRV_MACHINE_START(sf7000) |
| 1183 | | MDRV_MACHINE_RESET(sf7000) |
| 1184 | | |
| 1185 | 1153 | /* video hardware */ |
| 1186 | 1154 | MDRV_FRAGMENT_ADD(tms9928a) |
| 1187 | 1155 | MDRV_SCREEN_MODIFY(SCREEN_TAG) |