src/mess/drivers/beta.c
| r5776 | r5777 | |
| 4 | 4 | |
| 5 | 5 | http://retro.hansotten.nl/index.php?page=beta-computer |
| 6 | 6 | |
| 7 | | 17/07/2009 Skeleton driver. |
| 8 | | |
| 9 | 7 | ****************************************************************************/ |
| 10 | 8 | |
| 9 | /* |
| 10 | |
| 11 | TODO: |
| 12 | |
| 13 | - write EPROM back to file |
| 14 | - fix display flickering |
| 15 | |
| 16 | */ |
| 17 | |
| 11 | 18 | #include "driver.h" |
| 12 | 19 | #include "includes/beta.h" |
| 13 | 20 | #include "cpu/m6502/m6502.h" |
| 21 | #include "devices/cartslot.h" |
| 14 | 22 | #include "machine/6532riot.h" |
| 15 | 23 | #include "sound/speaker.h" |
| 16 | 24 | #include "beta.lh" |
| r5776 | r5777 | |
| 25 | 33 | |
| 26 | 34 | /* Input Ports */ |
| 27 | 35 | |
| 36 | static INPUT_CHANGED( trigger_reset ) |
| 37 | { |
| 38 | cputag_set_input_line(field->port->machine, M6502_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE); |
| 39 | } |
| 40 | |
| 28 | 41 | static INPUT_PORTS_START( beta ) |
| 29 | 42 | PORT_START("Q6") |
| 30 | 43 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| r5776 | r5777 | |
| 57 | 70 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 58 | 71 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("AD") PORT_CODE(KEYCODE_F1) |
| 59 | 72 | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 73 | |
| 74 | PORT_START("SPECIAL") |
| 75 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RESET") PORT_CODE(KEYCODE_R) PORT_CHANGED(trigger_reset, 0) |
| 60 | 76 | INPUT_PORTS_END |
| 61 | 77 | |
| 62 | 78 | /* M6532 Interface */ |
| r5776 | r5777 | |
| 66 | 82 | if (state->ls145_p < 6) |
| 67 | 83 | { |
| 68 | 84 | output_set_digit_value(state->ls145_p, state->segment); |
| 69 | | logerror("update display %u with %02x\n", state->ls145_p, state->segment); |
| 85 | //logerror("update display %u with %02x\n", state->ls145_p, state->segment); |
| 70 | 86 | } |
| 71 | 87 | } |
| 72 | 88 | |
| r5776 | r5777 | |
| 89 | 105 | |
| 90 | 106 | beta_state *state = device->machine->driver_data; |
| 91 | 107 | |
| 92 | | UINT8 data = 0xff; // TODO: read 2716 data |
| 108 | UINT8 data = 0xff; |
| 93 | 109 | |
| 94 | 110 | switch (state->ls145_p) |
| 95 | 111 | { |
| r5776 | r5777 | |
| 97 | 113 | case 7: data &= input_port_read(device->machine, "Q7"); break; |
| 98 | 114 | case 8: data &= input_port_read(device->machine, "Q8"); break; |
| 99 | 115 | case 9: data &= input_port_read(device->machine, "Q9"); break; |
| 116 | default: |
| 117 | if (!state->eprom_oe && !state->eprom_ce) |
| 118 | { |
| 119 | data = memory_region(device->machine, EPROM_TAG)[state->eprom_addr & 0x7ff]; |
| 120 | popmessage("EPROM read %04x = %02x\n", state->eprom_addr & 0x7ff, data); |
| 121 | } |
| 100 | 122 | } |
| 101 | 123 | |
| 102 | 124 | return data; |
| r5776 | r5777 | |
| 121 | 143 | |
| 122 | 144 | beta_state *state = device->machine->driver_data; |
| 123 | 145 | |
| 124 | | logerror("PA %02x\n", data); |
| 146 | // logerror("PA %02x\n", data); |
| 125 | 147 | |
| 148 | /* display */ |
| 126 | 149 | state->segment = BITSWAP8(data, 7, 3, 4, 1, 0, 2, 5, 6) & 0x7f; |
| 127 | 150 | update_display(state); |
| 151 | |
| 152 | /* EPROM data */ |
| 153 | state->eprom_data = data; |
| 128 | 154 | } |
| 129 | 155 | |
| 130 | 156 | static UINT8 beta_riot_b_r(const device_config *device, UINT8 olddata) |
| r5776 | r5777 | |
| 151 | 177 | |
| 152 | 178 | beta_state *state = device->machine->driver_data; |
| 153 | 179 | |
| 154 | | logerror("PB %02x\n", data); |
| 180 | // logerror("PB %02x %02x\n", data, olddata); |
| 155 | 181 | |
| 156 | 182 | /* display */ |
| 157 | 183 | state->ls145_p = data & 0x0f; |
| 158 | | update_display(state); |
| 159 | 184 | |
| 160 | 185 | /* speaker */ |
| 161 | 186 | speaker_level_w(state->speaker, !BIT(data, 4)); |
| r5776 | r5777 | |
| 166 | 191 | /* data led */ |
| 167 | 192 | output_set_led_value(1, !BIT(data, 5)); |
| 168 | 193 | |
| 169 | | /* EPROM address */ |
| 170 | | if (!state->ls164_cp && BIT(data, 5)) |
| 194 | /* EPROM address shift */ |
| 195 | if (!BIT(olddata, 5) && BIT(data, 5)) |
| 171 | 196 | { |
| 172 | 197 | state->eprom_addr <<= 1; |
| 173 | | state->eprom_addr |= BIT(data, 3); |
| 174 | | state->ls164_cp = BIT(data, 5); |
| 175 | | logerror("EPROM address %04x\n", state->eprom_addr & 0x7ff); |
| 198 | state->eprom_addr |= BIT(olddata, 3); |
| 176 | 199 | } |
| 200 | |
| 201 | /* EPROM output enable */ |
| 202 | state->eprom_oe = BIT(data, 6); |
| 203 | |
| 204 | /* EPROM chip enable */ |
| 205 | state->eprom_ce = BIT(data, 7); |
| 206 | |
| 207 | if (BIT(data, 6) && (!BIT(olddata, 7) && BIT(data, 7))) |
| 208 | { |
| 209 | popmessage("EPROM write %04x = %02x\n", state->eprom_addr & 0x7ff, state->eprom_data); |
| 210 | memory_region(device->machine, EPROM_TAG)[state->eprom_addr & 0x7ff] &= state->eprom_data; |
| 211 | } |
| 177 | 212 | } |
| 178 | 213 | |
| 179 | 214 | static void beta_riot_irq(const device_config *device, int state) |
| 180 | 215 | { |
| 181 | | //cputag_set_input_line(device->machine, M6502_TAG, M6502_IRQ_LINE, state ? HOLD_LINE : CLEAR_LINE); |
| 216 | cputag_set_input_line(device->machine, M6502_TAG, M6502_IRQ_LINE, state ? HOLD_LINE : CLEAR_LINE); |
| 182 | 217 | } |
| 183 | 218 | |
| 184 | 219 | static const riot6532_interface beta_riot_interface = |
| r5776 | r5777 | |
| 190 | 225 | beta_riot_irq |
| 191 | 226 | }; |
| 192 | 227 | |
| 228 | /* Quickload */ |
| 229 | |
| 230 | static DEVICE_IMAGE_UNLOAD( beta_eprom ) |
| 231 | { |
| 232 | UINT8 *ptr = memory_region(image->machine, EPROM_TAG); |
| 233 | |
| 234 | image_fwrite(image, ptr, 0x800); |
| 235 | } |
| 236 | |
| 193 | 237 | /* Machine Initialization */ |
| 194 | 238 | |
| 195 | 239 | static MACHINE_START( beta ) |
| r5776 | r5777 | |
| 198 | 242 | |
| 199 | 243 | /* find devices */ |
| 200 | 244 | state->speaker = devtag_get_device(machine, SPEAKER_TAG); |
| 245 | |
| 246 | /* register for state saving */ |
| 247 | state_save_register_global(machine, state->eprom_oe); |
| 248 | state_save_register_global(machine, state->eprom_ce); |
| 249 | state_save_register_global(machine, state->eprom_addr); |
| 250 | state_save_register_global(machine, state->eprom_data); |
| 251 | state_save_register_global(machine, state->ls145_p); |
| 252 | state_save_register_global(machine, state->segment); |
| 201 | 253 | } |
| 202 | 254 | |
| 203 | 255 | /* Machine Driver */ |
| r5776 | r5777 | |
| 206 | 258 | MDRV_DRIVER_DATA(beta_state) |
| 207 | 259 | |
| 208 | 260 | /* basic machine hardware */ |
| 209 | | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_1MHz) |
| 261 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_4MHz/4) |
| 210 | 262 | MDRV_CPU_PROGRAM_MAP(beta_mem) |
| 211 | 263 | |
| 212 | 264 | MDRV_MACHINE_START(beta) |
| r5776 | r5777 | |
| 220 | 272 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 221 | 273 | |
| 222 | 274 | /* devices */ |
| 223 | | MDRV_RIOT6532_ADD(M6532_TAG, XTAL_1MHz, beta_riot_interface) |
| 275 | MDRV_RIOT6532_ADD(M6532_TAG, XTAL_4MHz/4, beta_riot_interface) |
| 276 | |
| 277 | /* EPROM socket */ |
| 278 | MDRV_CARTSLOT_ADD(EPROM_TAG) |
| 279 | MDRV_CARTSLOT_EXTENSION_LIST("bin,rom") |
| 280 | MDRV_CARTSLOT_NOT_MANDATORY |
| 281 | MDRV_CARTSLOT_UNLOAD(beta_eprom) |
| 224 | 282 | MACHINE_DRIVER_END |
| 225 | 283 | |
| 226 | 284 | /* ROMs */ |
| r5776 | r5777 | |
| 229 | 287 | ROM_REGION( 0x10000, M6502_TAG, 0 ) |
| 230 | 288 | ROM_LOAD( "beta.rom", 0x8000, 0x0800, CRC(d42fdb17) SHA1(595225a0cd43dd76c46b2aff6c0f27d5991cc4f0)) |
| 231 | 289 | |
| 232 | | ROM_REGION( 0x800, "2716", ROMREGION_ERASEFF ) |
| 290 | ROM_REGION( 0x800, EPROM_TAG, ROMREGION_ERASEFF ) |
| 291 | ROM_CART_LOAD( EPROM_TAG, 0x0000, 0x0800, ROM_FULLSIZE ) |
| 233 | 292 | ROM_END |
| 234 | 293 | |
| 235 | 294 | /* System Configuration */ |
| 236 | 295 | |
| 237 | 296 | static SYSTEM_CONFIG_START( beta ) |
| 238 | | CONFIG_RAM_DEFAULT( 1 * 1024 ) |
| 297 | CONFIG_RAM_DEFAULT( 256 ) |
| 239 | 298 | SYSTEM_CONFIG_END |
| 240 | 299 | |
| 241 | 300 | /* System Drivers */ |
| 242 | 301 | |
| 243 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 244 | | COMP( 1984, beta, 0, 0, beta, beta, 0, beta, "Pitronics", "Beta Computer", GAME_NOT_WORKING) |
| 302 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 303 | COMP( 1984, beta, 0, 0, beta, beta, 0, beta, "Pitronics", "Beta", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |