src/mess/machine/a7800.c
| r4185 | r4186 | |
| 21 | 21 | ***************************************************************************/ |
| 22 | 22 | |
| 23 | 23 | #include "driver.h" |
| 24 | #include "includes/a7800.h" |
| 24 | 25 | #include "cpu/m6502/m6502.h" |
| 25 | 26 | #include "sound/tiasound.h" |
| 26 | | #include "hash.h" |
| 27 | | #include "image.h" |
| 28 | 27 | #include "machine/6532riot.h" |
| 29 | 28 | #include "sound/pokey.h" |
| 30 | 29 | #include "sound/tiaintf.h" |
| 30 | #include "hash.h" |
| 31 | 31 | |
| 32 | | #include "includes/a7800.h" |
| 33 | 32 | |
| 34 | 33 | int a7800_lines; |
| 35 | 34 | int a7800_ispal; |
| r4185 | r4186 | |
| 48 | 47 | static UINT8 *ROM; |
| 49 | 48 | |
| 50 | 49 | |
| 51 | | /****** RIOT ****************************************/ |
| 50 | /*************************************************************************** |
| 51 | 6532 RIOT |
| 52 | ***************************************************************************/ |
| 52 | 53 | |
| 53 | | /* TODO: Convert the definitions into a syntax accepting input_port_read */ |
| 54 | | |
| 55 | | static UINT8 riot_input_port_0_r(const device_config *device, UINT8 olddata) |
| 54 | static UINT8 riot_joystick_r(const device_config *device, UINT8 olddata) |
| 56 | 55 | { |
| 57 | | return input_port_0_r(cpu_get_address_space(device->machine->cpu[0],ADDRESS_SPACE_PROGRAM), 0); |
| 56 | return input_port_read(device->machine, "joysticks"); |
| 58 | 57 | } |
| 59 | 58 | |
| 60 | | static UINT8 riot_input_port_3_r(const device_config *device, UINT8 olddata) |
| 59 | static UINT8 riot_console_button_r(const device_config *device, UINT8 olddata) |
| 61 | 60 | { |
| 62 | | return input_port_3_r(cpu_get_address_space(device->machine->cpu[0],ADDRESS_SPACE_PROGRAM), 0); |
| 61 | return input_port_read(device->machine, "console_buttons"); |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | const riot6532_interface r6532_interface = |
| 66 | 65 | { |
| 67 | | riot_input_port_0_r, |
| 68 | | riot_input_port_3_r, |
| 66 | riot_joystick_r, |
| 67 | riot_console_button_r, |
| 69 | 68 | NULL, |
| 70 | 69 | NULL |
| 71 | 70 | }; |
| 72 | 71 | |
| 73 | 72 | |
| 74 | | /* ----------------------------------------------------------------------- |
| 75 | | * Driver/Machine Init |
| 76 | | * ----------------------------------------------------------------------- */ |
| 73 | /*************************************************************************** |
| 74 | DRIVER INIT |
| 75 | ***************************************************************************/ |
| 77 | 76 | |
| 78 | 77 | static void a7800_driver_init(running_machine *machine, int ispal, int lines) |
| 79 | 78 | { |
| r4185 | r4186 | |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 | |
| 100 | | |
| 101 | 99 | DRIVER_INIT( a7800_ntsc ) |
| 102 | 100 | { |
| 103 | 101 | a7800_driver_init(machine, FALSE, 262); |
| 104 | 102 | } |
| 105 | 103 | |
| 106 | 104 | |
| 107 | | |
| 108 | 105 | DRIVER_INIT( a7800_pal ) |
| 109 | 106 | { |
| 110 | 107 | a7800_driver_init(machine, TRUE, 312); |
| 111 | 108 | } |
| 112 | 109 | |
| 113 | 110 | |
| 114 | | |
| 115 | 111 | MACHINE_RESET( a7800 ) |
| 116 | 112 | { |
| 117 | 113 | UINT8 *memory; |
| r4185 | r4186 | |
| 137 | 133 | } |
| 138 | 134 | |
| 139 | 135 | |
| 136 | /*************************************************************************** |
| 137 | CARTRIDGE HANDLING |
| 138 | ***************************************************************************/ |
| 140 | 139 | |
| 141 | | /* ----------------------------------------------------------------------- */ |
| 142 | | |
| 143 | 140 | #define MBANK_TYPE_ATARI 0x0000 |
| 144 | 141 | #define MBANK_TYPE_ACTIVISION 0x0100 |
| 145 | 142 | #define MBANK_TYPE_ABSOLUTE 0x0200 |
| r4185 | r4186 | |
| 185 | 182 | } |
| 186 | 183 | |
| 187 | 184 | |
| 188 | | |
| 189 | 185 | static int a7800_verify_cart(char header[128]) |
| 190 | 186 | { |
| 191 | 187 | const char* tag = "ATARI7800"; |
| r4185 | r4186 | |
| 200 | 196 | return IMAGE_VERIFY_PASS; |
| 201 | 197 | } |
| 202 | 198 | |
| 199 | |
| 203 | 200 | DEVICE_START( a7800_cart ) |
| 204 | 201 | { |
| 205 | 202 | UINT8 *memory; |
| r4185 | r4186 | |
| 220 | 217 | a7800_stick_type = 1; |
| 221 | 218 | } |
| 222 | 219 | |
| 220 | |
| 223 | 221 | DEVICE_IMAGE_LOAD( a7800_cart ) |
| 224 | 222 | { |
| 225 | 223 | long len,start; |
| r4185 | r4186 | |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | 332 | |
| 335 | | /****** TIA *****************************************/ |
| 336 | | |
| 337 | | READ8_HANDLER( a7800_TIA_r ) |
| 338 | | { |
| 339 | | switch(offset) |
| 340 | | { |
| 341 | | case 0x08: |
| 342 | | return((input_port_read(space->machine, "buttons") & 0x02) << 6); |
| 343 | | case 0x09: |
| 344 | | return((input_port_read(space->machine, "buttons") & 0x08) << 4); |
| 345 | | case 0x0A: |
| 346 | | return((input_port_read(space->machine, "buttons") & 0x01) << 7); |
| 347 | | case 0x0B: |
| 348 | | return((input_port_read(space->machine, "buttons") & 0x04) << 5); |
| 349 | | case 0x0c: |
| 350 | | if((input_port_read(space->machine, "buttons") & 0x08) ||(input_port_read(space->machine, "buttons") & 0x02)) |
| 351 | | return 0x00; |
| 352 | | else |
| 353 | | return 0x80; |
| 354 | | case 0x0d: |
| 355 | | if((input_port_read(space->machine, "buttons") & 0x01) ||(input_port_read(space->machine, "buttons") & 0x04)) |
| 356 | | return 0x00; |
| 357 | | else |
| 358 | | return 0x80; |
| 359 | | default: |
| 360 | | logerror("undefined TIA read %x\n",offset); |
| 361 | | |
| 362 | | } |
| 363 | | return 0xFF; |
| 364 | | } |
| 365 | | |
| 366 | | WRITE8_HANDLER( a7800_TIA_w ) |
| 367 | | { |
| 368 | | switch(offset) { |
| 369 | | case 0x01: |
| 370 | | if(data & 0x01) |
| 371 | | { |
| 372 | | maria_flag=1; |
| 373 | | } |
| 374 | | if(!a7800_ctrl_lock) |
| 375 | | { |
| 376 | | a7800_ctrl_lock = data & 0x01; |
| 377 | | a7800_ctrl_reg = data; |
| 378 | | |
| 379 | | if (data & 0x04) |
| 380 | | memcpy( ROM + 0xC000, a7800_cart_bkup, 0x4000 ); |
| 381 | | else |
| 382 | | memcpy( ROM + 0xC000, a7800_bios_bkup, 0x4000 ); |
| 383 | | } |
| 384 | | break; |
| 385 | | } |
| 386 | | tia_sound_w(space, offset,data); |
| 387 | | ROM[offset] = data; |
| 388 | | } |
| 389 | | |
| 390 | | |
| 391 | | |
| 392 | | /****** RAM Mirroring ******************************/ |
| 393 | | |
| 394 | 333 | WRITE8_HANDLER( a7800_RAM0_w ) |
| 395 | 334 | { |
| 396 | 335 | ROM[0x2040 + offset] = data; |
| 397 | 336 | ROM[0x40 + offset] = data; |
| 398 | 337 | } |
| 399 | 338 | |
| 339 | |
| 400 | 340 | WRITE8_HANDLER( a7800_cart_w ) |
| 401 | 341 | { |
| 402 | 342 | UINT8 *memory = memory_region(space->machine, "main"); |
| r4185 | r4186 | |
| 458 | 398 | } |
| 459 | 399 | |
| 460 | 400 | |
| 401 | /*************************************************************************** |
| 402 | TIA |
| 403 | ***************************************************************************/ |
| 404 | |
| 405 | READ8_HANDLER( a7800_TIA_r ) |
| 406 | { |
| 407 | switch(offset) |
| 408 | { |
| 409 | case 0x08: |
| 410 | return((input_port_read(space->machine, "buttons") & 0x02) << 6); |
| 411 | case 0x09: |
| 412 | return((input_port_read(space->machine, "buttons") & 0x08) << 4); |
| 413 | case 0x0A: |
| 414 | return((input_port_read(space->machine, "buttons") & 0x01) << 7); |
| 415 | case 0x0B: |
| 416 | return((input_port_read(space->machine, "buttons") & 0x04) << 5); |
| 417 | case 0x0c: |
| 418 | if((input_port_read(space->machine, "buttons") & 0x08) ||(input_port_read(space->machine, "buttons") & 0x02)) |
| 419 | return 0x00; |
| 420 | else |
| 421 | return 0x80; |
| 422 | case 0x0d: |
| 423 | if((input_port_read(space->machine, "buttons") & 0x01) ||(input_port_read(space->machine, "buttons") & 0x04)) |
| 424 | return 0x00; |
| 425 | else |
| 426 | return 0x80; |
| 427 | default: |
| 428 | logerror("undefined TIA read %x\n",offset); |
| 429 | |
| 430 | } |
| 431 | return 0xFF; |
| 432 | } |
| 433 | |
| 434 | |
| 435 | WRITE8_HANDLER( a7800_TIA_w ) |
| 436 | { |
| 437 | switch(offset) { |
| 438 | case 0x01: |
| 439 | if(data & 0x01) |
| 440 | { |
| 441 | maria_flag=1; |
| 442 | } |
| 443 | if(!a7800_ctrl_lock) |
| 444 | { |
| 445 | a7800_ctrl_lock = data & 0x01; |
| 446 | a7800_ctrl_reg = data; |
| 447 | |
| 448 | if (data & 0x04) |
| 449 | memcpy( ROM + 0xC000, a7800_cart_bkup, 0x4000 ); |
| 450 | else |
| 451 | memcpy( ROM + 0xC000, a7800_bios_bkup, 0x4000 ); |
| 452 | } |
| 453 | break; |
| 454 | } |
| 455 | tia_sound_w(space, offset,data); |
| 456 | ROM[offset] = data; |
| 457 | } |