src/mess/machine/ap2_slot.c
| r8049 | r8050 | |
| 7 | 7 | *********************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "ap2_slot.h" |
| 10 | #include "includes/apple2.h" |
| 10 | 11 | |
| 11 | | |
| 12 | 12 | /*************************************************************************** |
| 13 | 13 | TYPE DEFINITIONS |
| 14 | 14 | ***************************************************************************/ |
| r8049 | r8050 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /*------------------------------------------------- |
| 170 | | apple2_slot_ROM_w - slot write function |
| 170 | apple2_slot_ROM_w - slot ROM read function |
| 171 | 171 | -------------------------------------------------*/ |
| 172 | READ8_DEVICE_HANDLER(apple2_slot_ROM_r) |
| 173 | { |
| 174 | const apple2_slot_config *config = get_config(device); |
| 175 | apple2_slot_token *token = get_token(device); |
| 172 | 176 | |
| 177 | /* do we actually have a device, and can we read? */ |
| 178 | if ((token->slot_device != NULL) && (config->rhcnxx != NULL)) |
| 179 | { |
| 180 | return (*config->rhcnxx)(token->slot_device, offset); |
| 181 | } |
| 182 | |
| 183 | if (config->slotnum > 0) |
| 184 | { |
| 185 | return apple2_slotram_r(device->machine, config->slotnum, offset + ((config->slotnum-1)<<8)); |
| 186 | } |
| 187 | |
| 188 | return apple2_getfloatingbusvalue(device->machine); |
| 189 | } |
| 190 | |
| 191 | /*------------------------------------------------- |
| 192 | apple2_slot_ROM_w - slot ROM write function |
| 193 | -------------------------------------------------*/ |
| 194 | |
| 173 | 195 | WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w) |
| 174 | 196 | { |
| 175 | 197 | const apple2_slot_config *config = get_config(device); |
| 176 | 198 | apple2_slot_token *token = get_token(device); |
| 177 | 199 | |
| 178 | | /* do we actually have a device, and can we read? */ |
| 200 | /* do we actually have a device, and can we write? */ |
| 179 | 201 | if ((token->slot_device != NULL) && (config->whcnxx != NULL)) |
| 180 | 202 | { |
| 181 | 203 | (*config->whcnxx)(token->slot_device, offset, data); |
src/mess/machine/ap2_slot.h
| r8049 | r8050 | |
| 11 | 11 | |
| 12 | 12 | #include "emu.h" |
| 13 | 13 | |
| 14 | | |
| 15 | 14 | /*************************************************************************** |
| 16 | 15 | CONSTANTS |
| 17 | 16 | ***************************************************************************/ |
| r8049 | r8050 | |
| 28 | 27 | struct _apple2_slot_config |
| 29 | 28 | { |
| 30 | 29 | const char *tag; |
| 31 | | read8_device_func rh; |
| 30 | int slotnum; // slot number |
| 31 | |
| 32 | read8_device_func rh; // C0nX I/O space (DEVSEL) |
| 32 | 33 | write8_device_func wh; |
| 33 | | read8_device_func rhc800; |
| 34 | |
| 35 | read8_device_func rhcnxx; // CnXX ROM space (IOSEL) |
| 36 | write8_device_func whcnxx; |
| 37 | |
| 38 | read8_device_func rhc800; // C800 ROM extension space (IOSTB) |
| 34 | 39 | write8_device_func whc800; |
| 35 | | write8_device_func whcnxx; |
| 36 | 40 | }; |
| 37 | 41 | |
| 38 | 42 | |
| r8049 | r8050 | |
| 41 | 45 | DEVICE CONFIGURATION MACROS |
| 42 | 46 | ***************************************************************************/ |
| 43 | 47 | |
| 44 | | #define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _whcnxx) \ |
| 48 | #define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _rhcnxx, _whcnxx) \ |
| 45 | 49 | MDRV_DEVICE_ADD("slot_" #_slot_number, APPLE2_SLOT, 0) \ |
| 46 | 50 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, tag, _slot_device_tag) \ |
| 51 | MDRV_DEVICE_CONFIG_DATA32(apple2_slot_config, slotnum, _slot_number) \ |
| 47 | 52 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rh, _rh) \ |
| 48 | 53 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, wh, _wh) \ |
| 49 | 54 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhc800, _rhc800) \ |
| 50 | 55 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whc800, _whc800) \ |
| 56 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhcnxx, _rhcnxx) \ |
| 51 | 57 | MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whcnxx, _whcnxx) \ |
| 52 | 58 | |
| 53 | 59 | |
| r8049 | r8050 | |
| 65 | 71 | /* slot write function */ |
| 66 | 72 | WRITE8_DEVICE_HANDLER(apple2_slot_w); |
| 67 | 73 | |
| 74 | /* slot ROM read function */ |
| 75 | READ8_DEVICE_HANDLER(apple2_slot_ROM_r); |
| 76 | |
| 68 | 77 | /* slot ROM write function */ |
| 69 | 78 | WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w); |
| 70 | 79 | |
src/mess/machine/apple2.c
| r8049 | r8050 | |
| 44 | 44 | static UINT32 a2_mask; |
| 45 | 45 | static UINT32 a2_set; |
| 46 | 46 | |
| 47 | | static INT32 a2_cnxx_slot; |
| 47 | INT32 a2_cnxx_slot; |
| 48 | 48 | |
| 49 | 49 | /* local */ |
| 50 | 50 | static int a2_speaker_state; |
| r8049 | r8050 | |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | | static READ8_HANDLER( apple2_c1xx_r ) |
| 436 | /* returns default CnXX slotram for a slot space */ |
| 437 | INT8 apple2_slotram_r(running_machine *machine, int slotnum, int offset) |
| 437 | 438 | { |
| 438 | | int slotnum; |
| 439 | 439 | UINT8 *rom, *slot_ram; |
| 440 | 440 | UINT32 rom_length, slot_length; |
| 441 | 441 | |
| 442 | 442 | // find slot_ram if any |
| 443 | | rom = memory_region(space->machine, "maincpu"); |
| 444 | | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 445 | | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 443 | rom = memory_region(machine, "maincpu"); |
| 444 | rom_length = memory_region_length(machine, "maincpu") & ~0xFFF; |
| 445 | slot_length = memory_region_length(machine, "maincpu") - rom_length; |
| 446 | 446 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 447 | 447 | |
| 448 | 448 | if (slot_ram) |
| 449 | 449 | { |
| 450 | | slotnum = ((offset>>8) & 0xf) + 1; |
| 451 | | if (a2_cnxx_slot != slotnum) |
| 450 | if (a2_cnxx_slot == -1) |
| 452 | 451 | { |
| 453 | 452 | a2_cnxx_slot = slotnum; |
| 454 | | apple2_update_memory(space->machine); |
| 453 | apple2_update_memory(machine); |
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | return slot_ram[offset]; |
| 458 | 457 | } |
| 458 | |
| 459 | 459 | // else fall through to floating bus |
| 460 | return apple2_getfloatingbusvalue(machine); |
| 461 | } |
| 460 | 462 | |
| 463 | static READ8_HANDLER( apple2_c1xx_r ) |
| 464 | { |
| 465 | int slotnum; |
| 466 | running_device *slotdevice; |
| 467 | |
| 468 | slotnum = ((offset>>8) & 0xf) + 1; |
| 469 | slotdevice = apple2_slot(space->machine, slotnum); |
| 470 | |
| 471 | if (a2_cnxx_slot == -1) |
| 472 | { |
| 473 | a2_cnxx_slot = slotnum; |
| 474 | apple2_update_memory(space->machine); |
| 475 | } |
| 476 | |
| 477 | if (slotdevice != NULL) |
| 478 | { |
| 479 | return apple2_slot_ROM_r(slotdevice, offset&0xff); |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | return apple2_slotram_r(space->machine, slotnum, offset); |
| 484 | } |
| 485 | |
| 486 | // else fall through to floating bus |
| 461 | 487 | return apple2_getfloatingbusvalue(space->machine); |
| 462 | 488 | } |
| 463 | 489 | |
| r8049 | r8050 | |
| 492 | 518 | static READ8_HANDLER( apple2_c4xx_r ) |
| 493 | 519 | { |
| 494 | 520 | int slotnum; |
| 495 | | UINT8 *rom, *slot_ram; |
| 496 | | UINT32 rom_length, slot_length; |
| 521 | running_device *slotdevice; |
| 497 | 522 | |
| 498 | | // find slot_ram if any |
| 499 | | rom = memory_region(space->machine, "maincpu"); |
| 500 | | rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF; |
| 501 | | slot_length = memory_region_length(space->machine, "maincpu") - rom_length; |
| 502 | | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 523 | slotnum = ((offset>>8) & 0xf) + 4; |
| 524 | slotdevice = apple2_slot(space->machine, slotnum); |
| 503 | 525 | |
| 504 | | if (slot_ram) |
| 526 | if (a2_cnxx_slot == -1) |
| 505 | 527 | { |
| 506 | | slotnum = ((offset>>8) & 0xf) + 4; |
| 507 | | if (a2_cnxx_slot != slotnum) |
| 508 | | { |
| 509 | | a2_cnxx_slot = slotnum; |
| 510 | | apple2_update_memory(space->machine); |
| 511 | | } |
| 528 | a2_cnxx_slot = slotnum; |
| 529 | apple2_update_memory(space->machine); |
| 530 | } |
| 512 | 531 | |
| 513 | | return slot_ram[offset+0x300]; |
| 532 | // is a card installed in this slot? |
| 533 | if (slotdevice != NULL) |
| 534 | { |
| 535 | return apple2_slot_ROM_r(slotdevice, offset&0xff); |
| 514 | 536 | } |
| 537 | else |
| 538 | { |
| 539 | return apple2_slotram_r(space->machine, slotnum, offset); |
| 540 | } |
| 541 | |
| 515 | 542 | // else fall through to floating bus |
| 516 | | |
| 517 | 543 | return apple2_getfloatingbusvalue(space->machine); |
| 518 | 544 | } |
| 519 | 545 | |
| r8049 | r8050 | |
| 531 | 557 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 532 | 558 | |
| 533 | 559 | slotnum = ((offset>>8) & 0xf) + 4; |
| 534 | | |
| 535 | 560 | slotdevice = apple2_slot(space->machine, slotnum); |
| 536 | 561 | |
| 562 | if (a2_cnxx_slot == -1) |
| 563 | { |
| 564 | a2_cnxx_slot = slotnum; |
| 565 | apple2_update_memory(space->machine); |
| 566 | } |
| 567 | |
| 537 | 568 | if (slotdevice != NULL) |
| 538 | 569 | { |
| 539 | 570 | apple2_slot_ROM_w(slotdevice, offset&0xff, data); |
src/mess/drivers/apple2.c
| r8049 | r8050 | |
| 627 | 627 | MDRV_APPLEFDC_ADD("fdc", apple2_fdc_interface) |
| 628 | 628 | |
| 629 | 629 | /* slots */ |
| 630 | | MDRV_APPLE2_SLOT_ADD(0, "langcard", apple2_langcard_r, apple2_langcard_w, 0, 0, 0) |
| 631 | | MDRV_APPLE2_SLOT_ADD(4, "mockingboard", mockingboard_r, mockingboard_w, 0, 0, 0) |
| 632 | | MDRV_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w, 0, 0, 0) |
| 630 | MDRV_APPLE2_SLOT_ADD(0, "langcard", apple2_langcard_r, apple2_langcard_w, 0, 0, 0, 0) |
| 631 | MDRV_APPLE2_SLOT_ADD(4, "mockingboard", mockingboard_r, mockingboard_w, 0, 0, 0, 0) |
| 632 | MDRV_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w, 0, 0, 0, 0) |
| 633 | 633 | |
| 634 | 634 | MDRV_FLOPPY_APPLE_2_DRIVES_ADD(apple2_floppy_config,15,16) |
| 635 | 635 | MACHINE_DRIVER_END |
| r8049 | r8050 | |
| 666 | 666 | |
| 667 | 667 | ROM_REGION(0x8700,"maincpu",0) |
| 668 | 668 | ROM_LOAD ( "las3000.rom", 0x0000, 0x8000, CRC(9C7AEB09) SHA1(3302ADF41E258CF50210C19736948C8FA65E91DE)) |
| 669 | | ROM_LOAD ( "l3kdisk.rom", 0x0500, 0x0100, CRC(2D4B1584) SHA1(989780B77E100598124DF7B72663E5A31A3339C0)) |
| 669 | ROM_LOAD ( "l3kdisk.rom", 0x8500, 0x0100, CRC(2D4B1584) SHA1(989780B77E100598124DF7B72663E5A31A3339C0)) |
| 670 | 670 | ROM_END |
| 671 | 671 | |
| 672 | 672 | MACHINE_DRIVER_START( apple2e ) |