src/mess/machine/apple2.c
| r14877 | r14878 | |
| 66 | 66 | |
| 67 | 67 | static READ8_HANDLER ( apple2_c1xx_r ); |
| 68 | 68 | static WRITE8_HANDLER ( apple2_c1xx_w ); |
| 69 | static READ8_HANDLER ( apple2_c3xx_r ); |
| 70 | static WRITE8_HANDLER ( apple2_c3xx_w ); |
| 69 | 71 | static READ8_HANDLER ( apple2_c4xx_r ); |
| 70 | 72 | static WRITE8_HANDLER ( apple2_c4xx_w ); |
| 71 | 73 | |
| r14877 | r14878 | |
| 108 | 110 | read8_space_func rh; const char *rh_name = NULL; |
| 109 | 111 | write8_space_func wh; const char *wh_name = NULL; |
| 110 | 112 | offs_t begin, end_r, end_w; |
| 111 | | UINT8 *rbase, *wbase, *rom; //, *slot_ram; |
| 112 | | UINT32 rom_length, offset; //, slot_length; |
| 113 | UINT8 *rbase, *wbase, *rom; |
| 114 | UINT32 rom_length, offset; |
| 113 | 115 | bank_disposition_t bank_disposition; |
| 114 | 116 | int wh_nop = 0; |
| 115 | 117 | |
| r14877 | r14878 | |
| 125 | 127 | /* get critical info */ |
| 126 | 128 | rom = machine.region("maincpu")->base(); |
| 127 | 129 | rom_length = machine.region("maincpu")->bytes() & ~0xFFF; |
| 128 | | // slot_length = machine.region("maincpu")->bytes() - rom_length; |
| 129 | | // slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 130 | 130 | |
| 131 | 131 | /* loop through the entire memory map */ |
| 132 | 132 | bank = state->m_mem_config.first_bank; |
| r14877 | r14878 | |
| 180 | 180 | rh = apple2_c1xx_r; |
| 181 | 181 | rh_name = "apple2_c1xx_r"; |
| 182 | 182 | } |
| 183 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x200) |
| 184 | { // slot 3 |
| 185 | rh = apple2_c3xx_r; |
| 186 | rh_name = "apple2_c3xx_r"; |
| 187 | } |
| 183 | 188 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300) |
| 184 | 189 | { // slots 4-7 |
| 185 | 190 | rh = apple2_c4xx_r; |
| 186 | 191 | rh_name = "apple2_c4xx_r"; |
| 187 | 192 | } |
| 193 | else |
| 194 | { |
| 195 | printf("ERROR: Unhandled case for APPLE2_MEM_SLOT write_mem = %x!\n", (meminfo.write_mem & APPLE2_MEM_MASK)); |
| 196 | } |
| 188 | 197 | } |
| 189 | 198 | else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_ROM) |
| 190 | 199 | { |
| r14877 | r14878 | |
| 267 | 276 | wh = apple2_c1xx_w; |
| 268 | 277 | wh_name = "apple2_c1xx_w"; |
| 269 | 278 | } |
| 279 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x200) |
| 280 | { // slot 3 |
| 281 | wh = apple2_c3xx_w; |
| 282 | wh_name = "apple2_c3xx_w"; |
| 283 | } |
| 270 | 284 | else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300) |
| 271 | 285 | { // slots 4-7 |
| 272 | 286 | wh = apple2_c4xx_w; |
| r14877 | r14878 | |
| 435 | 449 | |
| 436 | 450 | if (slot_ram) |
| 437 | 451 | { |
| 438 | | if (1) //state->m_a2_cnxx_slot == -1) |
| 439 | | { |
| 440 | | // printf("slotram_r: cnxx_slot now %d\n", slotnum); |
| 441 | | state->m_a2_cnxx_slot = slotnum; |
| 442 | | apple2_update_memory(machine); |
| 443 | | } |
| 452 | state->m_a2_cnxx_slot = -1; |
| 453 | apple2_update_memory(machine); |
| 444 | 454 | |
| 445 | 455 | return slot_ram[offset]; |
| 446 | 456 | } |
| r14877 | r14878 | |
| 458 | 468 | slotnum = ((offset>>8) & 0xf) + 1; |
| 459 | 469 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 460 | 470 | |
| 461 | | if (1) //state->m_a2_cnxx_slot == -1) |
| 462 | | { |
| 463 | | // printf("c1xx_r: cnxx_slot now %d\n", slotnum); |
| 464 | | state->m_a2_cnxx_slot = slotnum; |
| 465 | | apple2_update_memory(space->machine()); |
| 466 | | } |
| 471 | state->m_a2_cnxx_slot = slotnum; |
| 472 | apple2_update_memory(space->machine()); |
| 467 | 473 | |
| 468 | 474 | if (slotdevice != NULL) |
| 469 | 475 | { |
| r14877 | r14878 | |
| 507 | 513 | } |
| 508 | 514 | } |
| 509 | 515 | |
| 510 | | static READ8_HANDLER( apple2_c4xx_r ) |
| 516 | static READ8_HANDLER( apple2_c3xx_r ) |
| 511 | 517 | { |
| 512 | 518 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 513 | 519 | int slotnum; |
| 514 | 520 | device_a2bus_card_interface *slotdevice; |
| 515 | 521 | |
| 516 | | slotnum = ((offset>>8) & 0xf) + 4; |
| 522 | slotnum = 3; |
| 517 | 523 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 518 | 524 | |
| 519 | | if (1) //state->m_a2_cnxx_slot == -1) |
| 525 | state->m_a2_cnxx_slot = slotnum; |
| 526 | apple2_update_memory(space->machine()); |
| 527 | |
| 528 | // is a card installed in this slot? |
| 529 | if (slotdevice != NULL) |
| 520 | 530 | { |
| 521 | | state->m_a2_cnxx_slot = slotnum; |
| 522 | | // printf("c4xx_r: cnxx_slot now %d\n", slotnum); |
| 523 | | apple2_update_memory(space->machine()); |
| 531 | return slotdevice->read_cnxx(*space, offset&0xff); |
| 524 | 532 | } |
| 533 | else |
| 534 | { |
| 535 | return apple2_slotram_r(space->machine(), slotnum, offset); |
| 536 | } |
| 525 | 537 | |
| 538 | // else fall through to floating bus |
| 539 | return apple2_getfloatingbusvalue(space->machine()); |
| 540 | } |
| 541 | |
| 542 | static WRITE8_HANDLER ( apple2_c3xx_w ) |
| 543 | { |
| 544 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 545 | int slotnum; |
| 546 | device_a2bus_card_interface *slotdevice; |
| 547 | UINT8 *rom, *slot_ram; |
| 548 | UINT32 rom_length, slot_length; |
| 549 | |
| 550 | // find slot_ram if any |
| 551 | rom = space->machine().region("maincpu")->base(); |
| 552 | rom_length = space->machine().region("maincpu")->bytes() & ~0xFFF; |
| 553 | slot_length = space->machine().region("maincpu")->bytes() - rom_length; |
| 554 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 555 | |
| 556 | slotnum = 3; |
| 557 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 558 | |
| 559 | state->m_a2_cnxx_slot = slotnum; |
| 560 | apple2_update_memory(space->machine()); |
| 561 | |
| 562 | if (slotdevice != NULL) |
| 563 | { |
| 564 | slotdevice->write_cnxx(*space, offset&0xff, data); |
| 565 | } |
| 566 | else |
| 567 | { |
| 568 | if (slot_ram) |
| 569 | slot_ram[offset] = data; |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | static READ8_HANDLER( apple2_c4xx_r ) |
| 574 | { |
| 575 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 576 | int slotnum; |
| 577 | device_a2bus_card_interface *slotdevice; |
| 578 | |
| 579 | slotnum = ((offset>>8) & 0xf) + 4; |
| 580 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 581 | |
| 582 | state->m_a2_cnxx_slot = slotnum; |
| 583 | apple2_update_memory(space->machine()); |
| 584 | |
| 526 | 585 | // is a card installed in this slot? |
| 527 | 586 | if (slotdevice != NULL) |
| 528 | 587 | { |
| r14877 | r14878 | |
| 554 | 613 | slotnum = ((offset>>8) & 0xf) + 4; |
| 555 | 614 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 556 | 615 | |
| 557 | | if (1) //state->m_a2_cnxx_slot == -1) |
| 558 | | { |
| 559 | | // printf("c4xx_w: cnxx_slot now %d\n", slotnum); |
| 560 | | state->m_a2_cnxx_slot = slotnum; |
| 561 | | apple2_update_memory(space->machine()); |
| 562 | | } |
| 616 | state->m_a2_cnxx_slot = slotnum; |
| 617 | apple2_update_memory(space->machine()); |
| 563 | 618 | |
| 564 | 619 | if (slotdevice != NULL) |
| 565 | 620 | { |
| r14877 | r14878 | |
| 578 | 633 | if (!space->debugger_access()) |
| 579 | 634 | { |
| 580 | 635 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 581 | | // printf("cfff_r: cnxx_slot now %d\n", -1); |
| 582 | 636 | state->m_a2_cnxx_slot = -1; |
| 583 | 637 | apple2_update_memory(space->machine()); |
| 584 | 638 | } |
| r14877 | r14878 | |
| 591 | 645 | if (!space->debugger_access()) |
| 592 | 646 | { |
| 593 | 647 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 594 | | // printf("cfff_w: cnxx_slot now %d\n", -1); |
| 595 | 648 | state->m_a2_cnxx_slot = -1; |
| 596 | 649 | apple2_update_memory(space->machine()); |
| 597 | 650 | } |
| r14877 | r14878 | |
| 760 | 813 | static void apple2_mem_C800(running_machine &machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 761 | 814 | { |
| 762 | 815 | apple2_state *state = machine.driver_data<apple2_state>(); |
| 763 | | if (state->m_flags & VAR_INTCXROM) |
| 816 | if ((state->m_flags & VAR_INTCXROM) || (state->m_a2_cnxx_slot == -1)) |
| 764 | 817 | { |
| 765 | 818 | meminfo->read_mem = (begin & 0x0FFF) | (state->m_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 766 | 819 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| r14877 | r14878 | |
| 782 | 835 | } |
| 783 | 836 | else |
| 784 | 837 | { |
| 785 | | if (state->m_flags & VAR_INTCXROM) |
| 838 | if ((state->m_flags & VAR_INTCXROM) || (state->m_a2_cnxx_slot == -1)) |
| 786 | 839 | { |
| 787 | 840 | meminfo->read_mem = (begin & 0x0FFF) | (state->m_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 788 | 841 | meminfo->write_mem = APPLE2_MEM_FLOATING; |