src/mess/drivers/vcs80.c
| r5152 | r5153 | |
| 77 | 77 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 78 | 78 | |
| 79 | 79 | PORT_START("ROW2") |
| 80 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A+") PORT_CODE(KEYCODE_F1) |
| 81 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A-") PORT_CODE(KEYCODE_F2) |
| 82 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("MA") PORT_CODE(KEYCODE_F3) |
| 83 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RE") PORT_CODE(KEYCODE_F4) |
| 84 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("GO") PORT_CODE(KEYCODE_F5) |
| 85 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("TR") PORT_CODE(KEYCODE_F6) |
| 86 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("ST") PORT_CODE(KEYCODE_F7) |
| 87 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("PE") PORT_CODE(KEYCODE_F8) |
| 80 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A+") PORT_CODE(KEYCODE_UP) |
| 81 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A-") PORT_CODE(KEYCODE_DOWN) |
| 82 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("MA") PORT_CODE(KEYCODE_M) |
| 83 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RE") PORT_CODE(KEYCODE_R) |
| 84 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("GO") PORT_CODE(KEYCODE_G) |
| 85 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("TR") PORT_CODE(KEYCODE_T) |
| 86 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("ST") PORT_CODE(KEYCODE_S) |
| 87 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("PE") PORT_CODE(KEYCODE_P) |
| 88 | 88 | INPUT_PORTS_END |
| 89 | 89 | |
| 90 | | /* Keyboard HACK */ |
| 90 | /* Z80-PIO Interface */ |
| 91 | 91 | |
| 92 | 92 | static TIMER_DEVICE_CALLBACK( vcs80_keyboard_tick ) |
| 93 | 93 | { |
| 94 | | vcs80_state *state = timer->machine->driver_data; |
| 95 | | |
| 96 | | UINT8 data = 0xf7; |
| 97 | | |
| 98 | | if (!BIT(input_port_read(timer->machine, "ROW0"), state->keylatch)) data &= ~0x10; |
| 99 | | if (!BIT(input_port_read(timer->machine, "ROW1"), state->keylatch)) data &= ~0x20; |
| 100 | | if (!BIT(input_port_read(timer->machine, "ROW2"), state->keylatch)) data &= ~0x40; |
| 101 | | |
| 102 | | z80pio_p_w(state->z80pio, 0, data); |
| 103 | | |
| 104 | | z80pio_p_w(state->z80pio, 1, 0x80); |
| 105 | | z80pio_p_w(state->z80pio, 1, 0x00); |
| 106 | | } |
| 107 | | |
| 108 | | /* Z80-PIO Interface */ |
| 109 | | |
| 110 | | static READ8_DEVICE_HANDLER( pio_port_a_r ) |
| 111 | | { |
| 112 | 94 | /* |
| 113 | 95 | |
| 114 | 96 | bit description |
| 115 | 97 | |
| 116 | | 0 keyboard and led latch bit 0 |
| 117 | | 1 keyboard and led latch bit 1 |
| 118 | | 2 keyboard and led latch bit 2 |
| 119 | | 3 GND |
| 120 | | 4 keyboard row input 0 |
| 121 | | 5 keyboard row input 1 |
| 122 | | 6 keyboard row input 2 |
| 123 | | 7 demultiplexer clock output |
| 98 | PA0 keyboard and led latch bit 0 |
| 99 | PA1 keyboard and led latch bit 1 |
| 100 | PA2 keyboard and led latch bit 2 |
| 101 | PA3 GND |
| 102 | PA4 keyboard row input 0 |
| 103 | PA5 keyboard row input 1 |
| 104 | PA6 keyboard row input 2 |
| 105 | PA7 demultiplexer clock input |
| 124 | 106 | |
| 125 | 107 | */ |
| 126 | 108 | |
| 127 | | vcs80_state *state = device->machine->driver_data; |
| 109 | vcs80_state *state = timer->machine->driver_data; |
| 128 | 110 | |
| 129 | | UINT8 data = 0xf7; |
| 111 | UINT8 data = 0; |
| 130 | 112 | |
| 131 | | if (!BIT(input_port_read(device->machine, "ROW0"), state->keylatch)) data &= ~0x10; |
| 132 | | if (!BIT(input_port_read(device->machine, "ROW1"), state->keylatch)) data &= ~0x20; |
| 133 | | if (!BIT(input_port_read(device->machine, "ROW2"), state->keylatch)) data &= ~0x40; |
| 113 | if (state->keyclk) |
| 114 | { |
| 115 | state->keylatch++; |
| 116 | state->keylatch &= 0x07; |
| 117 | } |
| 134 | 118 | |
| 135 | | return data; |
| 136 | | } |
| 119 | data = (state->keyclk << 7) | 0x70 | state->keylatch; |
| 137 | 120 | |
| 138 | | static WRITE8_DEVICE_HANDLER( pio_port_a_w ) |
| 139 | | { |
| 140 | | /* |
| 141 | | |
| 142 | | bit description |
| 121 | if (!BIT(input_port_read(timer->machine, "ROW0"), state->keylatch)) data &= ~0x10; |
| 122 | if (!BIT(input_port_read(timer->machine, "ROW1"), state->keylatch)) data &= ~0x20; |
| 123 | if (!BIT(input_port_read(timer->machine, "ROW2"), state->keylatch)) data &= ~0x40; |
| 143 | 124 | |
| 144 | | 0 keyboard and led latch bit 0 |
| 145 | | 1 keyboard and led latch bit 1 |
| 146 | | 2 keyboard and led latch bit 2 |
| 147 | | 3 GND |
| 148 | | 4 keyboard row input 0 |
| 149 | | 5 keyboard row input 1 |
| 150 | | 6 keyboard row input 2 |
| 151 | | 7 demultiplexer clock output |
| 125 | z80pio_p_w(state->z80pio, 0, data); |
| 152 | 126 | |
| 153 | | */ |
| 154 | | |
| 155 | | vcs80_state *state = device->machine->driver_data; |
| 156 | | |
| 157 | | state->keylatch = data & 0x07; |
| 127 | state->keyclk = !state->keyclk; |
| 158 | 128 | } |
| 159 | 129 | |
| 160 | 130 | static WRITE8_DEVICE_HANDLER( pio_port_b_w ) |
| r5152 | r5153 | |
| 163 | 133 | |
| 164 | 134 | bit description |
| 165 | 135 | |
| 166 | | 0 VQD30 segment A |
| 167 | | 1 VQD30 segment B |
| 168 | | 2 VQD30 segment C |
| 169 | | 3 VQD30 segment D |
| 170 | | 4 VQD30 segment E |
| 171 | | 5 VQD30 segment F |
| 172 | | 6 VQD30 segment G |
| 173 | | 7 PIO B/_A |
| 136 | PB0 VQD30 segment A |
| 137 | PB1 VQD30 segment B |
| 138 | PB2 VQD30 segment C |
| 139 | PB3 VQD30 segment D |
| 140 | PB4 VQD30 segment E |
| 141 | PB5 VQD30 segment G |
| 142 | PB6 VQD30 segment F |
| 143 | PB7 _A0 |
| 174 | 144 | |
| 175 | 145 | */ |
| 176 | 146 | |
| 177 | 147 | vcs80_state *state = device->machine->driver_data; |
| 178 | 148 | |
| 149 | UINT8 led_data = BITSWAP8(data & 0x7f, 7, 5, 6, 4, 3, 2, 1, 0); |
| 179 | 150 | int digit = state->keylatch; |
| 180 | 151 | |
| 181 | 152 | /* skip middle digit */ |
| 182 | 153 | if (digit > 3) digit++; |
| 183 | 154 | |
| 184 | | output_set_digit_value(digit, data & 0x7f); |
| 155 | output_set_digit_value(8 - digit, led_data); |
| 185 | 156 | } |
| 186 | 157 | |
| 187 | 158 | static const z80pio_interface pio_intf = |
| 188 | 159 | { |
| 189 | 160 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), /* callback when change interrupt status */ |
| 190 | | DEVCB_HANDLER(pio_port_a_r), /* port A read callback */ |
| 161 | DEVCB_NULL, /* port A read callback */ |
| 191 | 162 | DEVCB_NULL, /* port B read callback */ |
| 192 | | DEVCB_HANDLER(pio_port_a_w), /* port A write callback */ |
| 163 | DEVCB_NULL, /* port A write callback */ |
| 193 | 164 | DEVCB_HANDLER(pio_port_b_w), /* port B write callback */ |
| 194 | 165 | DEVCB_NULL, /* portA ready active callback */ |
| 195 | 166 | DEVCB_NULL /* portB ready active callback */ |
| r5152 | r5153 | |
| 214 | 185 | |
| 215 | 186 | /* register for state saving */ |
| 216 | 187 | state_save_register_global(machine, state->keylatch); |
| 188 | state_save_register_global(machine, state->keyclk); |
| 217 | 189 | } |
| 218 | 190 | |
| 219 | 191 | /* Machine Driver */ |
| r5152 | r5153 | |
| 229 | 201 | |
| 230 | 202 | MDRV_MACHINE_START(vcs80) |
| 231 | 203 | |
| 232 | | /* keyboard HACK */ |
| 204 | /* keyboard timer */ |
| 233 | 205 | MDRV_TIMER_ADD_PERIODIC("keyboard", vcs80_keyboard_tick, HZ(1000)) |
| 234 | 206 | |
| 235 | 207 | /* video hardware */ |
| r5152 | r5153 | |
| 248 | 220 | |
| 249 | 221 | /* System Configuration */ |
| 250 | 222 | |
| 251 | | static SYSTEM_CONFIG_START(vcs80) |
| 223 | static SYSTEM_CONFIG_START( vcs80 ) |
| 252 | 224 | CONFIG_RAM_DEFAULT( 1 * 1024 ) |
| 253 | 225 | SYSTEM_CONFIG_END |
| 254 | 226 | |
| 227 | /* Driver Initialization */ |
| 228 | |
| 229 | static DIRECT_UPDATE_HANDLER( vcs80_direct_update_handler ) |
| 230 | { |
| 231 | vcs80_state *state = space->machine->driver_data; |
| 232 | |
| 233 | /* _A0 is connected to PIO PB7 */ |
| 234 | z80pio_p_w(state->z80pio, 1, (!BIT(address, 0)) << 7); |
| 235 | |
| 236 | return address; |
| 237 | } |
| 238 | |
| 239 | static DRIVER_INIT( vcs80 ) |
| 240 | { |
| 241 | memory_set_direct_update_handler(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), vcs80_direct_update_handler); |
| 242 | memory_set_direct_update_handler(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_IO), vcs80_direct_update_handler); |
| 243 | } |
| 244 | |
| 255 | 245 | /* System Drivers */ |
| 256 | 246 | |
| 257 | 247 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 258 | | COMP( 1983, vcs80, 0, 0, vcs80, vcs80, 0, vcs80, "Eckhard Schiller", "VCS-80", GAME_NOT_WORKING) |
| 248 | COMP( 1983, vcs80, 0, 0, vcs80, vcs80, vcs80, vcs80, "Eckhard Schiller", "VCS-80", GAME_SUPPORTS_SAVE ) |