src/mess/drivers/pegasus.c
| r10067 | r10068 | |
| 28 | 28 | - Work on the other non-working programs |
| 29 | 29 | |
| 30 | 30 | ****************************************************************************/ |
| 31 | #define ADDRESS_MAP_MODERN |
| 31 | 32 | |
| 32 | 33 | #include "emu.h" |
| 33 | | #include "cpu/m6809/m6809.h" |
| 34 | | #include "machine/6821pia.h" |
| 35 | | #include "imagedev/cartslot.h" |
| 36 | | #include "imagedev/cassette.h" |
| 37 | 34 | #include "includes/pegasus.h" |
| 38 | 35 | |
| 39 | 36 | static TIMER_DEVICE_CALLBACK( pegasus_firq ) |
| r10067 | r10068 | |
| 42 | 39 | cpu_set_input_line(cpu, M6809_FIRQ_LINE, HOLD_LINE); |
| 43 | 40 | } |
| 44 | 41 | |
| 45 | | static WRITE_LINE_DEVICE_HANDLER( pegasus_firq_clr ) |
| 42 | WRITE_LINE_MEMBER( pegasus_state::pegasus_firq_clr ) |
| 46 | 43 | { |
| 47 | | cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, CLEAR_LINE); |
| 44 | cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, CLEAR_LINE); |
| 48 | 45 | } |
| 49 | 46 | |
| 50 | | static READ8_DEVICE_HANDLER( pegasus_keyboard_r ) |
| 47 | READ8_MEMBER( pegasus_state::pegasus_keyboard_r ) |
| 51 | 48 | { |
| 52 | | pegasus_state *state = device->machine->driver_data<pegasus_state>(); |
| 53 | 49 | static const char *const keynames[] = { "X0", "X1", "X2", "X3", "X4", "X5", "X6", "X7" }; |
| 54 | 50 | UINT8 bit,data = 0xff; |
| 55 | 51 | for (bit = 0; bit < 8; bit++) |
| 56 | | if (!BIT(state->kbd_row, bit)) data &= input_port_read(device->machine, keynames[bit]); |
| 52 | if (!BIT(m_kbd_row, bit)) data &= input_port_read(machine, keynames[bit]); |
| 57 | 53 | |
| 58 | | state->kbd_irq = (data == 0xff) ? 1 : 0; |
| 59 | | if (state->control_bits & 8) data<<=4; |
| 54 | m_kbd_irq = (data == 0xff) ? 1 : 0; |
| 55 | if (m_control_bits & 8) data<<=4; |
| 60 | 56 | return data; |
| 61 | 57 | } |
| 62 | 58 | |
| 63 | | static WRITE8_DEVICE_HANDLER( pegasus_keyboard_w ) |
| 59 | WRITE8_MEMBER( pegasus_state::pegasus_keyboard_w ) |
| 64 | 60 | { |
| 65 | | pegasus_state *state = device->machine->driver_data<pegasus_state>(); |
| 66 | | state->kbd_row = data; |
| 61 | m_kbd_row = data; |
| 67 | 62 | } |
| 68 | 63 | |
| 69 | | static WRITE8_DEVICE_HANDLER( pegasus_controls ) |
| 64 | WRITE8_MEMBER( pegasus_state::pegasus_controls_w ) |
| 70 | 65 | { |
| 71 | | pegasus_state *state = device->machine->driver_data<pegasus_state>(); |
| 72 | 66 | /* d0,d2 - not emulated |
| 73 | 67 | d0 - Blank - Video blanking |
| 74 | 68 | d1 - Char - select character rom or ram |
| r10067 | r10068 | |
| 76 | 70 | d3 - Asc - Select which half of the keyboard to read |
| 77 | 71 | */ |
| 78 | 72 | |
| 79 | | state->control_bits = data; |
| 73 | m_control_bits = data; |
| 80 | 74 | } |
| 81 | 75 | |
| 82 | | static READ_LINE_DEVICE_HANDLER( pegasus_keyboard_irq ) |
| 76 | READ_LINE_MEMBER( pegasus_state::pegasus_keyboard_irq ) |
| 83 | 77 | { |
| 84 | | pegasus_state *state = device->machine->driver_data<pegasus_state>(); |
| 85 | | return state->kbd_irq; |
| 78 | return m_kbd_irq; |
| 86 | 79 | } |
| 87 | 80 | |
| 88 | | static READ_LINE_DEVICE_HANDLER( pegasus_cassette_r ) |
| 81 | READ_LINE_MEMBER( pegasus_state::pegasus_cassette_r ) |
| 89 | 82 | { |
| 90 | | pegasus_state *state = device->machine->driver_data<pegasus_state>(); |
| 91 | | return cassette_input(state->cass); |
| 83 | return cassette_input(m_cass); |
| 92 | 84 | } |
| 93 | 85 | |
| 94 | | static WRITE_LINE_DEVICE_HANDLER( pegasus_cassette_w ) |
| 86 | WRITE_LINE_MEMBER( pegasus_state::pegasus_cassette_w ) |
| 95 | 87 | { |
| 96 | | pegasus_state *drvstate = device->machine->driver_data<pegasus_state>(); |
| 97 | | cassette_output(drvstate->cass, state ? 1 : -1); |
| 88 | cassette_output(m_cass, state ? 1 : -1); |
| 98 | 89 | } |
| 99 | 90 | |
| 100 | | static READ8_HANDLER( pegasus_pcg_r ) |
| 91 | READ8_MEMBER( pegasus_state::pegasus_pcg_r ) |
| 101 | 92 | { |
| 102 | | pegasus_state *state = space->machine->driver_data<pegasus_state>(); |
| 103 | | UINT8 code = state->video_ram[offset] & 0x7f; |
| 104 | | return state->FNT[(code << 4) | (~state->kbd_row & 15)]; |
| 93 | UINT8 code = m_videoram[offset] & 0x7f; |
| 94 | return m_pcgram[(code << 4) | (~m_kbd_row & 15)]; |
| 105 | 95 | } |
| 106 | 96 | |
| 107 | | static WRITE8_HANDLER( pegasus_pcg_w ) |
| 97 | WRITE8_MEMBER( pegasus_state::pegasus_pcg_w ) |
| 108 | 98 | { |
| 109 | | pegasus_state *state = space->machine->driver_data<pegasus_state>(); |
| 110 | | // if (state->control_bits & 2) |
| 99 | // if (state->m_control_bits & 2) |
| 111 | 100 | { |
| 112 | | UINT8 code = state->video_ram[offset] & 0x7f; |
| 113 | | state->FNT[(code << 4) | (~state->kbd_row & 15)] = data; |
| 101 | UINT8 code = m_videoram[offset] & 0x7f; |
| 102 | m_pcgram[(code << 4) | (~m_kbd_row & 15)] = data; |
| 114 | 103 | } |
| 115 | 104 | } |
| 116 | 105 | |
| 117 | 106 | /* Must return the A register except when it is doing a rom search */ |
| 118 | | static READ8_HANDLER( pegasus_protection_r ) |
| 107 | READ8_MEMBER( pegasus_state::pegasus_protection_r ) |
| 119 | 108 | { |
| 120 | | UINT8 data = cpu_get_reg(space->machine->device("maincpu"), M6809_A); |
| 109 | UINT8 data = cpu_get_reg(m_maincpu, M6809_A); |
| 121 | 110 | if (data == 0x20) data = 0xff; |
| 122 | 111 | return data; |
| 123 | 112 | } |
| 124 | 113 | |
| 125 | | static ADDRESS_MAP_START(pegasus_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 114 | static ADDRESS_MAP_START(pegasus_mem, ADDRESS_SPACE_PROGRAM, 8, pegasus_state) |
| 126 | 115 | ADDRESS_MAP_UNMAP_HIGH |
| 127 | 116 | AM_RANGE(0x0000, 0x2fff) AM_ROM |
| 128 | 117 | AM_RANGE(0xb000, 0xbdff) AM_RAM |
| 129 | | AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE_MEMBER(pegasus_state, video_ram) |
| 118 | AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE(m_videoram) |
| 130 | 119 | AM_RANGE(0xc000, 0xdfff) AM_ROM AM_WRITENOP |
| 131 | 120 | AM_RANGE(0xe000, 0xe1ff) AM_READ(pegasus_protection_r) |
| 132 | 121 | AM_RANGE(0xe200, 0xe3ff) AM_READWRITE(pegasus_pcg_r,pegasus_pcg_w) |
| 133 | | AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_u", pia6821_r, pia6821_w) |
| 134 | | AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_s", pia6821_r, pia6821_w) |
| 122 | AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_u", pia6821_r, pia6821_w) |
| 123 | AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_s", pia6821_r, pia6821_w) |
| 135 | 124 | AM_RANGE(0xf000, 0xffff) AM_ROM |
| 136 | 125 | ADDRESS_MAP_END |
| 137 | 126 | |
| 138 | | static ADDRESS_MAP_START(pegasusm_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 127 | static ADDRESS_MAP_START(pegasusm_mem, ADDRESS_SPACE_PROGRAM, 8, pegasus_state) |
| 139 | 128 | ADDRESS_MAP_UNMAP_HIGH |
| 140 | 129 | AM_RANGE(0x0000, 0x2fff) AM_ROM |
| 141 | 130 | AM_RANGE(0x5000, 0xbdff) AM_RAM |
| 142 | | AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE_MEMBER(pegasus_state, video_ram) |
| 131 | AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE(m_videoram) |
| 143 | 132 | AM_RANGE(0xc000, 0xdfff) AM_ROM AM_WRITENOP |
| 144 | 133 | AM_RANGE(0xe000, 0xe1ff) AM_READ(pegasus_protection_r) |
| 145 | 134 | AM_RANGE(0xe200, 0xe3ff) AM_READWRITE(pegasus_pcg_r,pegasus_pcg_w) |
| 146 | | AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_u", pia6821_r, pia6821_w) |
| 147 | | AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_s", pia6821_r, pia6821_w) |
| 135 | AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_u", pia6821_r, pia6821_w) |
| 136 | AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_s", pia6821_r, pia6821_w) |
| 148 | 137 | AM_RANGE(0xf000, 0xffff) AM_ROM |
| 149 | 138 | ADDRESS_MAP_END |
| 150 | 139 | |
| r10067 | r10068 | |
| 235 | 224 | static const pia6821_interface pegasus_pia_s_intf= |
| 236 | 225 | { |
| 237 | 226 | DEVCB_NULL, /* port A input */ |
| 238 | | DEVCB_HANDLER(pegasus_keyboard_r), /* port B input */ |
| 239 | | DEVCB_LINE(pegasus_cassette_r), /* CA1 input */ |
| 240 | | DEVCB_LINE(pegasus_keyboard_irq), /* CB1 input */ |
| 227 | DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_keyboard_r), /* port B input */ |
| 228 | DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_cassette_r), /* CA1 input */ |
| 229 | DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_keyboard_irq), /* CB1 input */ |
| 241 | 230 | DEVCB_NULL, /* CA2 input */ |
| 242 | 231 | DEVCB_NULL, /* CB2 input */ |
| 243 | | DEVCB_HANDLER(pegasus_keyboard_w), /* port A output */ |
| 244 | | DEVCB_HANDLER(pegasus_controls), /* port B output */ |
| 245 | | DEVCB_LINE(pegasus_cassette_w), /* CA2 output */ |
| 246 | | DEVCB_DEVICE_LINE("maincpu", pegasus_firq_clr), /* CB2 output */ |
| 232 | DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_keyboard_w), /* port A output */ |
| 233 | DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_controls_w), /* port B output */ |
| 234 | DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_cassette_w), /* CA2 output */ |
| 235 | DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_firq_clr), /* CB2 output */ |
| 247 | 236 | DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE), /* IRQA output */ |
| 248 | 237 | DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE) /* IRQB output */ |
| 249 | 238 | }; |
| r10067 | r10068 | |
| 337 | 326 | static MACHINE_START( pegasus ) |
| 338 | 327 | { |
| 339 | 328 | pegasus_state *state = machine->driver_data<pegasus_state>(); |
| 340 | | state->cass = machine->device("cassette"); |
| 341 | | state->FNT = machine->region("pcg")->base(); |
| 329 | state->m_pcgram = machine->region("pcg")->base(); |
| 342 | 330 | } |
| 343 | 331 | |
| 344 | 332 | static MACHINE_RESET( pegasus ) |
| 345 | 333 | { |
| 346 | 334 | pegasus_state *state = machine->driver_data<pegasus_state>(); |
| 347 | | state->kbd_row = 0; |
| 348 | | state->kbd_irq = 1; |
| 349 | | state->control_bits = 0; |
| 335 | state->m_kbd_row = 0; |
| 336 | state->m_kbd_irq = 1; |
| 337 | state->m_control_bits = 0; |
| 350 | 338 | } |
| 351 | 339 | |
| 352 | 340 | static DRIVER_INIT( pegasus ) |
| r10067 | r10068 | |
| 374 | 362 | MCFG_VIDEO_UPDATE(pegasus) |
| 375 | 363 | |
| 376 | 364 | /* devices */ |
| 377 | | MCFG_PIA6821_ADD( "pegasus_pia_s", pegasus_pia_s_intf ) |
| 378 | | MCFG_PIA6821_ADD( "pegasus_pia_u", pegasus_pia_u_intf ) |
| 365 | MCFG_PIA6821_ADD( "pia_s", pegasus_pia_s_intf ) |
| 366 | MCFG_PIA6821_ADD( "pia_u", pegasus_pia_u_intf ) |
| 379 | 367 | MCFG_CARTSLOT_ADD("cart1") |
| 380 | 368 | MCFG_CARTSLOT_EXTENSION_LIST("bin") |
| 381 | 369 | MCFG_CARTSLOT_LOAD(pegasus_cart_1) |