src/mess/drivers/vidbrain.c
| r9244 | r9245 | |
| 5 | 5 | http://www.atariprotos.com/othersystems/videobrain/videobrain.htm |
| 6 | 6 | http://www.seanriddle.com/vbinfo.html |
| 7 | 7 | http://www.seanriddle.com/videobrain.html |
| 8 | http://www.google.com/patents?q=4232374 |
| 8 | 9 | |
| 9 | 10 | 07/04/2009 Skeleton driver. |
| 10 | 11 | |
| r9244 | r9245 | |
| 14 | 15 | |
| 15 | 16 | TODO: |
| 16 | 17 | |
| 17 | | - SMI 3853 |
| 18 | | - colors |
| 19 | | - low resolution mode |
| 18 | - use machine/f3853.h |
| 20 | 19 | - discrete sound |
| 21 | 20 | - joystick scan timer 555 |
| 22 | 21 | - reset on cartridge eject |
| r9244 | r9245 | |
| 38 | 37 | ***************************************************************************/ |
| 39 | 38 | |
| 40 | 39 | /*------------------------------------------------- |
| 41 | | vlsi_r - video VLSI read |
| 42 | | -------------------------------------------------*/ |
| 43 | | |
| 44 | | static READ8_HANDLER( vlsi_r ) |
| 45 | | { |
| 46 | | switch (offset) |
| 47 | | { |
| 48 | | case 0xfa: |
| 49 | | return 0xff; |
| 50 | | |
| 51 | | case 0xfb: |
| 52 | | // alternate this between 0xf5 and 0x34 to make Checkers boot |
| 53 | | return 0xff; |
| 54 | | } |
| 55 | | |
| 56 | | return 0; |
| 57 | | } |
| 58 | | |
| 59 | | /*------------------------------------------------- |
| 60 | | vlsi_w - video VLSI write |
| 61 | | -------------------------------------------------*/ |
| 62 | | |
| 63 | | static WRITE8_HANDLER( vlsi_w ) |
| 64 | | { |
| 65 | | vidbrain_state *state = space->machine->driver_data<vidbrain_state>(); |
| 66 | | |
| 67 | | switch (offset) |
| 68 | | { |
| 69 | | case 0xf5: |
| 70 | | state->bg_color = data; |
| 71 | | break; |
| 72 | | |
| 73 | | case 0xf7: |
| 74 | | /* |
| 75 | | |
| 76 | | bit description |
| 77 | | |
| 78 | | 0 |
| 79 | | 1 |
| 80 | | 2 |
| 81 | | 3 |
| 82 | | 4 keyboard column 8 |
| 83 | | 5 |
| 84 | | 6 |
| 85 | | 7 |
| 86 | | |
| 87 | | */ |
| 88 | | |
| 89 | | state->uv201_31 = BIT(data, 4); |
| 90 | | break; |
| 91 | | } |
| 92 | | |
| 93 | | state->vlsi[offset] = data; |
| 94 | | |
| 95 | | logerror("VLSI %02x = %02x\n", offset, data); |
| 96 | | } |
| 97 | | |
| 98 | | /*------------------------------------------------- |
| 99 | 40 | keyboard_w - keyboard column write |
| 100 | 41 | -------------------------------------------------*/ |
| 101 | 42 | |
| r9244 | r9245 | |
| 154 | 95 | if (BIT(state->keylatch, 5)) data |= input_port_read(space->machine, "IO05"); |
| 155 | 96 | if (BIT(state->keylatch, 6)) data |= input_port_read(space->machine, "IO06"); |
| 156 | 97 | if (BIT(state->keylatch, 7)) data |= input_port_read(space->machine, "IO07"); |
| 157 | | if (state->uv201_31) data |= input_port_read(space->machine, "UV201-31"); |
| 98 | if (!BIT(state->cmd, 4)) data |= input_port_read(space->machine, "UV201-31"); |
| 158 | 99 | |
| 159 | 100 | return data; |
| 160 | 101 | } |
| r9244 | r9245 | |
| 184 | 125 | |
| 185 | 126 | /* sound clock */ |
| 186 | 127 | int sound_clk = BIT(data, 7); |
| 187 | | |
| 128 | |
| 188 | 129 | if (!state->sound_clk && sound_clk) |
| 189 | 130 | { |
| 190 | 131 | state->sound_q[0] = BIT(state->keylatch, 0); |
| r9244 | r9245 | |
| 200 | 141 | state->joy_enable = BIT(data, 7); |
| 201 | 142 | } |
| 202 | 143 | |
| 144 | /*------------------------------------------------- |
| 145 | vidbrain_interrupt_check - check interrupts |
| 146 | -------------------------------------------------*/ |
| 147 | |
| 148 | void vidbrain_interrupt_check(running_machine *machine) |
| 149 | { |
| 150 | vidbrain_state *state = machine->driver_data<vidbrain_state>(); |
| 151 | |
| 152 | int interrupt = CLEAR_LINE; |
| 153 | |
| 154 | switch (state->int_enable) |
| 155 | { |
| 156 | case 1: |
| 157 | if (state->ext_int_latch) interrupt = ASSERT_LINE; |
| 158 | break; |
| 159 | |
| 160 | case 3: |
| 161 | if (state->timer_int_latch) interrupt = ASSERT_LINE; |
| 162 | break; |
| 163 | } |
| 164 | |
| 165 | cputag_set_input_line(machine, F3850_TAG, F8_INPUT_LINE_INT_REQ, interrupt); |
| 166 | } |
| 167 | |
| 168 | /*------------------------------------------------- |
| 169 | f3853_w - F3853 SMI write |
| 170 | -------------------------------------------------*/ |
| 171 | |
| 172 | static WRITE8_HANDLER( f3853_w ) |
| 173 | { |
| 174 | vidbrain_state *state = space->machine->driver_data<vidbrain_state>(); |
| 175 | |
| 176 | switch (offset) |
| 177 | { |
| 178 | case 0: |
| 179 | // interrupt vector address high |
| 180 | state->vector = (data << 8) | (state->vector & 0xff); |
| 181 | logerror("F3853 Interrupt Vector %04x\n", state->vector); |
| 182 | break; |
| 183 | |
| 184 | case 1: |
| 185 | // interrupt vector address low |
| 186 | state->vector = (state->vector & 0xff00) | data; |
| 187 | logerror("F3853 Interrupt Vector %04x\n", state->vector); |
| 188 | break; |
| 189 | |
| 190 | case 2: |
| 191 | // interrupt control |
| 192 | state->int_enable = data & 0x03; |
| 193 | logerror("F3853 Interrupt Control %u\n", state->int_enable); |
| 194 | vidbrain_interrupt_check(space->machine); |
| 195 | |
| 196 | if (state->int_enable == 0x03) fatalerror("F3853 Timer not supported!"); |
| 197 | break; |
| 198 | |
| 199 | case 3: |
| 200 | // timer 8-bit polynomial counter |
| 201 | fatalerror("F3853 Timer not supported!"); |
| 202 | break; |
| 203 | } |
| 204 | } |
| 205 | |
| 203 | 206 | /*************************************************************************** |
| 204 | 207 | MEMORY MAPS |
| 205 | 208 | ***************************************************************************/ |
| r9244 | r9245 | |
| 210 | 213 | |
| 211 | 214 | static ADDRESS_MAP_START( vidbrain_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 212 | 215 | AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0xc000) AM_ROM |
| 213 | | AM_RANGE(0x0800, 0x08ff) AM_READWRITE(vlsi_r, vlsi_w) |
| 214 | | AM_RANGE(0x0c00, 0x0fff) AM_MIRROR(0xe000) AM_RAM AM_BASE_MEMBER(vidbrain_state, video_ram) |
| 215 | | AM_RANGE(0x1000, 0x1fff) AM_ROM |
| 216 | AM_RANGE(0x0800, 0x08ff) AM_READWRITE(vidbrain_vlsi_r, vidbrain_vlsi_w) |
| 217 | AM_RANGE(0x0c00, 0x0fff) AM_MIRROR(0xe000) AM_RAM |
| 218 | AM_RANGE(0x1000, 0x1fff) AM_MIRROR(0xe000) AM_ROM |
| 216 | 219 | AM_RANGE(0x2000, 0x27ff) AM_MIRROR(0xc000) AM_ROM |
| 217 | 220 | ADDRESS_MAP_END |
| 218 | 221 | |
| r9244 | r9245 | |
| 223 | 226 | static ADDRESS_MAP_START( vidbrain_io, ADDRESS_SPACE_IO, 8 ) |
| 224 | 227 | AM_RANGE(0x00, 0x00) AM_WRITE(keyboard_w) |
| 225 | 228 | AM_RANGE(0x01, 0x01) AM_READWRITE(keyboard_r, sound_w) |
| 229 | AM_RANGE(0x0c, 0x0f) AM_WRITE(f3853_w) |
| 230 | // AM_RANGE(0x0c, 0x0f) AM_DEVREADWRITE(F3853_TAG, f3853_r, f3853_w) |
| 226 | 231 | ADDRESS_MAP_END |
| 227 | 232 | |
| 228 | 233 | /*************************************************************************** |
| r9244 | r9245 | |
| 328 | 333 | INPUT_PORTS_END |
| 329 | 334 | |
| 330 | 335 | /*************************************************************************** |
| 331 | | VIDEO |
| 332 | | ***************************************************************************/ |
| 333 | | |
| 334 | | /*------------------------------------------------- |
| 335 | | PALETTE_INIT( vidbrain ) |
| 336 | | -------------------------------------------------*/ |
| 337 | | |
| 338 | | static PALETTE_INIT( vidbrain ) |
| 339 | | { |
| 340 | | palette_set_color_rgb(machine, 0, 0x00, 0x00, 0x00 ); // |
| 341 | | palette_set_color_rgb(machine, 1, 0xff, 0x00, 0x00 ); // red |
| 342 | | palette_set_color_rgb(machine, 2, 0x00, 0xff, 0x00 ); // |
| 343 | | palette_set_color_rgb(machine, 3, 0xff, 0xff, 0x00 ); // |
| 344 | | palette_set_color_rgb(machine, 4, 0x00, 0x00, 0xff ); // blue |
| 345 | | palette_set_color_rgb(machine, 5, 0xff, 0x00, 0xff ); // |
| 346 | | palette_set_color_rgb(machine, 6, 0x00, 0xff, 0xff ); // |
| 347 | | palette_set_color_rgb(machine, 7, 0xff, 0xff, 0xff ); // |
| 348 | | |
| 349 | | palette_set_color_rgb(machine, 8, 0x00, 0x00, 0x00 ); // |
| 350 | | palette_set_color_rgb(machine, 9, 0x80, 0x00, 0x00 ); // red |
| 351 | | palette_set_color_rgb(machine, 10, 0x00, 0x80, 0x00 ); // |
| 352 | | palette_set_color_rgb(machine, 11, 0x80, 0x80, 0x00 ); // |
| 353 | | palette_set_color_rgb(machine, 12, 0x00, 0x00, 0x80 ); // blue |
| 354 | | palette_set_color_rgb(machine, 13, 0x80, 0x00, 0x80 ); // |
| 355 | | palette_set_color_rgb(machine, 14, 0x00, 0x80, 0x80 ); // |
| 356 | | palette_set_color_rgb(machine, 15, 0x80, 0x80, 0x80 ); // |
| 357 | | } |
| 358 | | |
| 359 | | /*------------------------------------------------- |
| 360 | | VIDEO_START( vidbrain ) |
| 361 | | -------------------------------------------------*/ |
| 362 | | |
| 363 | | static VIDEO_START( vidbrain ) |
| 364 | | { |
| 365 | | } |
| 366 | | |
| 367 | | /*------------------------------------------------- |
| 368 | | VIDEO_UPDATE( vidbrain ) |
| 369 | | -------------------------------------------------*/ |
| 370 | | |
| 371 | | static VIDEO_UPDATE( vidbrain ) |
| 372 | | { |
| 373 | | vidbrain_state *state = screen->machine->driver_data<vidbrain_state>(); |
| 374 | | |
| 375 | | UINT16 addr = 0x2f; |
| 376 | | |
| 377 | | for (int y = 0; y < 49; y++) |
| 378 | | { |
| 379 | | int row = y / 7; |
| 380 | | |
| 381 | | for (int sx = 0; sx < 16; sx++) |
| 382 | | { |
| 383 | | UINT8 data = state->video_ram[addr++]; |
| 384 | | |
| 385 | | for (int x = 0; x < 8; x++) |
| 386 | | { |
| 387 | | *BITMAP_ADDR16(bitmap, y, (sx * 8) + x) = BIT(data, 7) ? (state->vlsi[0x10+row] >> 5) : state->bg_color; |
| 388 | | data <<= 1; |
| 389 | | } |
| 390 | | } |
| 391 | | } |
| 392 | | |
| 393 | | return 0; |
| 394 | | } |
| 395 | | |
| 396 | | /*------------------------------------------------- |
| 397 | | gfx_layout vidbrain_charlayout |
| 398 | | -------------------------------------------------*/ |
| 399 | | |
| 400 | | static const gfx_layout vidbrain_charlayout = |
| 401 | | { |
| 402 | | 8, 7, /* 8 x 7 characters */ |
| 403 | | 59, /* 59 characters */ |
| 404 | | 1, /* 1 bits per pixel */ |
| 405 | | { 0 }, /* no bitplanes */ |
| 406 | | /* x offsets */ |
| 407 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 408 | | /* y offsets */ |
| 409 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 410 | | 8*7 /* every char takes 7 bytes */ |
| 411 | | }; |
| 412 | | |
| 413 | | /*------------------------------------------------- |
| 414 | | GFXDECODE( vidbrain ) |
| 415 | | -------------------------------------------------*/ |
| 416 | | |
| 417 | | static GFXDECODE_START( vidbrain ) |
| 418 | | GFXDECODE_ENTRY( F3850_TAG, 0x2010, vidbrain_charlayout, 0, 1 ) |
| 419 | | GFXDECODE_END |
| 420 | | |
| 421 | | /*************************************************************************** |
| 422 | 336 | SOUND |
| 423 | 337 | ***************************************************************************/ |
| 424 | 338 | |
| r9244 | r9245 | |
| 437 | 351 | ***************************************************************************/ |
| 438 | 352 | |
| 439 | 353 | /*------------------------------------------------- |
| 354 | f3853_interface smi_intf |
| 355 | -------------------------------------------------*/ |
| 356 | /* |
| 357 | static void f3853_int_req_w(running_device *device, UINT16 addr, int level) |
| 358 | { |
| 359 | cpu_set_input_line_vector(device->machine->device(F3850_TAG), 0, addr); |
| 360 | |
| 361 | cputag_set_input_line(device->machine, F3850_TAG, F8_INPUT_LINE_INT_REQ, level); |
| 362 | } |
| 363 | |
| 364 | static const f3853_interface smi_intf = |
| 365 | { |
| 366 | f3853_int_req_w |
| 367 | }; |
| 368 | */ |
| 369 | /*------------------------------------------------- |
| 440 | 370 | cassette_config vidbrain_cassette_config |
| 441 | 371 | -------------------------------------------------*/ |
| 442 | 372 | |
| r9244 | r9245 | |
| 476 | 406 | MACHINE INITIALIZATION |
| 477 | 407 | ***************************************************************************/ |
| 478 | 408 | |
| 409 | static IRQ_CALLBACK( vidbrain_int_ack ) |
| 410 | { |
| 411 | vidbrain_state *state = device->machine->driver_data<vidbrain_state>(); |
| 412 | |
| 413 | switch (state->int_enable) |
| 414 | { |
| 415 | case 1: |
| 416 | state->ext_int_latch = 0; |
| 417 | break; |
| 418 | |
| 419 | case 3: |
| 420 | state->timer_int_latch = 0; |
| 421 | break; |
| 422 | } |
| 423 | |
| 424 | vidbrain_interrupt_check(device->machine); |
| 425 | |
| 426 | return state->vector; |
| 427 | } |
| 428 | |
| 479 | 429 | /*------------------------------------------------- |
| 480 | 430 | MACHINE_START( vidbrain ) |
| 481 | 431 | -------------------------------------------------*/ |
| r9244 | r9245 | |
| 484 | 434 | { |
| 485 | 435 | vidbrain_state *state = machine->driver_data<vidbrain_state>(); |
| 486 | 436 | |
| 437 | /* register IRQ callback */ |
| 438 | cpu_set_irq_callback(machine->device(F3850_TAG), vidbrain_int_ack); |
| 439 | |
| 487 | 440 | /* find devices */ |
| 488 | 441 | state->discrete = machine->device(DISCRETE_TAG); |
| 489 | 442 | |
| 490 | 443 | /* register for state saving */ |
| 444 | state_save_register_global(machine, state->vector); |
| 445 | state_save_register_global(machine, state->int_enable); |
| 446 | state_save_register_global(machine, state->ext_int_latch); |
| 447 | state_save_register_global(machine, state->timer_int_latch); |
| 491 | 448 | state_save_register_global(machine, state->keylatch); |
| 492 | 449 | state_save_register_global(machine, state->joy_enable); |
| 493 | | state_save_register_global(machine, state->uv201_31); |
| 494 | | state_save_register_global(machine, state->bg_color); |
| 495 | 450 | state_save_register_global(machine, state->sound_clk); |
| 496 | 451 | state_save_register_global_array(machine, state->sound_q); |
| 497 | 452 | } |
| r9244 | r9245 | |
| 501 | 456 | ***************************************************************************/ |
| 502 | 457 | |
| 503 | 458 | /*------------------------------------------------- |
| 504 | | MACHINE_CONFIG_START( vidbrain, driver_device ) |
| 459 | MACHINE_CONFIG( vidbrain ) |
| 505 | 460 | -------------------------------------------------*/ |
| 506 | 461 | |
| 507 | 462 | static MACHINE_CONFIG_START( vidbrain, vidbrain_state ) |
| 508 | | |
| 509 | 463 | /* basic machine hardware */ |
| 510 | 464 | MDRV_CPU_ADD(F3850_TAG, F8, XTAL_14_31818MHz/8) |
| 511 | 465 | MDRV_CPU_PROGRAM_MAP(vidbrain_mem) |
| r9244 | r9245 | |
| 513 | 467 | |
| 514 | 468 | MDRV_MACHINE_START(vidbrain) |
| 515 | 469 | |
| 516 | | /* video hardware */ |
| 517 | | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 518 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 519 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 520 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 521 | | MDRV_SCREEN_SIZE(128, 49) |
| 522 | | MDRV_SCREEN_VISIBLE_AREA(0, 128-1, 0, 49-1) |
| 523 | | MDRV_GFXDECODE(vidbrain) |
| 524 | | MDRV_PALETTE_LENGTH(16) |
| 525 | | MDRV_PALETTE_INIT(vidbrain) |
| 470 | /* video hardware */ |
| 471 | MDRV_FRAGMENT_ADD(vidbrain_video) |
| 526 | 472 | |
| 527 | | MDRV_VIDEO_START(vidbrain) |
| 528 | | MDRV_VIDEO_UPDATE(vidbrain) |
| 529 | | |
| 530 | 473 | /* sound hardware */ |
| 531 | 474 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 532 | 475 | |
| r9244 | r9245 | |
| 535 | 478 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) |
| 536 | 479 | |
| 537 | 480 | /* devices */ |
| 481 | // MDRV_F3853_ADD(F3853_TAG, XTAL_14_31818MHz/8, smi_intf) |
| 538 | 482 | MDRV_CASSETTE_ADD(CASSETTE_TAG, vidbrain_cassette_config) |
| 539 | 483 | |
| 540 | 484 | /* cartridge */ |
| r9244 | r9245 | |
| 544 | 488 | MDRV_CARTSLOT_LOAD(vidbrain_cart) |
| 545 | 489 | |
| 546 | 490 | /* software lists */ |
| 547 | | MDRV_SOFTWARE_LIST_ADD("cart_list","vidbrain") |
| 491 | MDRV_SOFTWARE_LIST_ADD("cart_list", "vidbrain") |
| 548 | 492 | |
| 549 | 493 | /* internal ram */ |
| 550 | 494 | MDRV_RAM_ADD("messram") |