src/mess/machine/apple2.c
| r14984 | r14985 | |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /* returns default CnXX slotram for a slot space */ |
| 437 | | INT8 apple2_slotram_r(running_machine &machine, int slotnum, int offset) |
| 437 | INT8 apple2_slotram_r(address_space &space, int slotnum, int offset) |
| 438 | 438 | { |
| 439 | | apple2_state *state = machine.driver_data<apple2_state>(); |
| 439 | apple2_state *state = space.machine().driver_data<apple2_state>(); |
| 440 | 440 | UINT8 *rom, *slot_ram; |
| 441 | 441 | UINT32 rom_length, slot_length; |
| 442 | 442 | |
| 443 | 443 | // find slot_ram if any |
| 444 | | rom = machine.root_device().memregion("maincpu")->base(); |
| 445 | | rom_length = machine.root_device().memregion("maincpu")->bytes() & ~0xFFF; |
| 444 | rom = space.machine().root_device().memregion("maincpu")->base(); |
| 445 | rom_length = space.machine().root_device().memregion("maincpu")->bytes() & ~0xFFF; |
| 446 | 446 | slot_length = state->memregion("maincpu")->bytes() - rom_length; |
| 447 | 447 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 448 | 448 | |
| 449 | 449 | if (slot_ram) |
| 450 | 450 | { |
| 451 | | state->m_a2_cnxx_slot = -1; |
| 452 | | apple2_update_memory(machine); |
| 451 | if (!space.debugger_access()) |
| 452 | { |
| 453 | // printf("slotram_r: taking cnxx_slot to -1\n"); |
| 454 | state->m_a2_cnxx_slot = -1; |
| 455 | apple2_update_memory(space.machine()); |
| 456 | } |
| 453 | 457 | |
| 454 | 458 | return slot_ram[offset]; |
| 455 | 459 | } |
| 456 | 460 | |
| 457 | 461 | // else fall through to floating bus |
| 458 | | return apple2_getfloatingbusvalue(machine); |
| 462 | return apple2_getfloatingbusvalue(space.machine()); |
| 459 | 463 | } |
| 460 | 464 | |
| 461 | 465 | static READ8_HANDLER( apple2_c1xx_r ) |
| r14984 | r14985 | |
| 467 | 471 | slotnum = ((offset>>8) & 0xf) + 1; |
| 468 | 472 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 469 | 473 | |
| 470 | | state->m_a2_cnxx_slot = slotnum; |
| 471 | | apple2_update_memory(space->machine()); |
| 472 | | |
| 473 | 474 | if (slotdevice != NULL) |
| 474 | 475 | { |
| 476 | if (slotdevice->take_c800()) |
| 477 | { |
| 478 | // printf("c1xx_r: taking cnxx_slot to %d\n", slotnum); |
| 479 | state->m_a2_cnxx_slot = slotnum; |
| 480 | apple2_update_memory(space->machine()); |
| 481 | } |
| 482 | |
| 475 | 483 | return slotdevice->read_cnxx(*space, offset&0xff); |
| 476 | 484 | } |
| 477 | 485 | else |
| 478 | 486 | { |
| 479 | | return apple2_slotram_r(space->machine(), slotnum, offset); |
| 487 | return apple2_slotram_r(*space, slotnum, offset); |
| 480 | 488 | } |
| 481 | 489 | |
| 482 | 490 | // else fall through to floating bus |
| r14984 | r14985 | |
| 521 | 529 | slotnum = 3; |
| 522 | 530 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 523 | 531 | |
| 524 | | state->m_a2_cnxx_slot = slotnum; |
| 525 | | apple2_update_memory(space->machine()); |
| 526 | | |
| 527 | 532 | // is a card installed in this slot? |
| 528 | 533 | if (slotdevice != NULL) |
| 529 | 534 | { |
| 535 | if (slotdevice->take_c800()) |
| 536 | { |
| 537 | // printf("c3xx_r: taking cnxx_slot to %d\n", slotnum); |
| 538 | state->m_a2_cnxx_slot = slotnum; |
| 539 | apple2_update_memory(space->machine()); |
| 540 | } |
| 530 | 541 | return slotdevice->read_cnxx(*space, offset&0xff); |
| 531 | 542 | } |
| 532 | 543 | else |
| 533 | 544 | { |
| 534 | | return apple2_slotram_r(space->machine(), slotnum, offset); |
| 545 | return apple2_slotram_r(*space, slotnum, offset); |
| 535 | 546 | } |
| 536 | 547 | |
| 537 | 548 | // else fall through to floating bus |
| r14984 | r14985 | |
| 555 | 566 | slotnum = 3; |
| 556 | 567 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 557 | 568 | |
| 558 | | state->m_a2_cnxx_slot = slotnum; |
| 559 | | apple2_update_memory(space->machine()); |
| 560 | | |
| 561 | 569 | if (slotdevice != NULL) |
| 562 | 570 | { |
| 571 | if (slotdevice->take_c800()) |
| 572 | { |
| 573 | // printf("c3xx_w: taking cnxx_slot to %d\n", slotnum); |
| 574 | state->m_a2_cnxx_slot = slotnum; |
| 575 | apple2_update_memory(space->machine()); |
| 576 | } |
| 563 | 577 | slotdevice->write_cnxx(*space, offset&0xff, data); |
| 564 | 578 | } |
| 565 | 579 | else |
| r14984 | r14985 | |
| 578 | 592 | slotnum = ((offset>>8) & 0xf) + 4; |
| 579 | 593 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 580 | 594 | |
| 581 | | state->m_a2_cnxx_slot = slotnum; |
| 582 | | apple2_update_memory(space->machine()); |
| 583 | | |
| 584 | 595 | // is a card installed in this slot? |
| 585 | 596 | if (slotdevice != NULL) |
| 586 | 597 | { |
| 598 | if (slotdevice->take_c800()) |
| 599 | { |
| 600 | // printf("c4xx_r: taking cnxx_slot to %d\n", slotnum); |
| 601 | state->m_a2_cnxx_slot = slotnum; |
| 602 | apple2_update_memory(space->machine()); |
| 603 | } |
| 587 | 604 | return slotdevice->read_cnxx(*space, offset&0xff); |
| 588 | 605 | } |
| 589 | 606 | else |
| 590 | 607 | { |
| 591 | | return apple2_slotram_r(space->machine(), slotnum, offset); |
| 608 | return apple2_slotram_r(*space, slotnum, offset); |
| 592 | 609 | } |
| 593 | 610 | |
| 594 | 611 | // else fall through to floating bus |
| r14984 | r14985 | |
| 612 | 629 | slotnum = ((offset>>8) & 0xf) + 4; |
| 613 | 630 | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 614 | 631 | |
| 615 | | state->m_a2_cnxx_slot = slotnum; |
| 616 | | apple2_update_memory(space->machine()); |
| 617 | | |
| 618 | 632 | if (slotdevice != NULL) |
| 619 | 633 | { |
| 634 | if (slotdevice->take_c800()) |
| 635 | { |
| 636 | // printf("c4xx_w: taking cnxx_slot to %d\n", slotnum); |
| 637 | state->m_a2_cnxx_slot = slotnum; |
| 638 | apple2_update_memory(space->machine()); |
| 639 | } |
| 620 | 640 | slotdevice->write_cnxx(*space, offset&0xff, data); |
| 621 | 641 | } |
| 622 | 642 | else |
| r14984 | r14985 | |
| 632 | 652 | if (!space->debugger_access()) |
| 633 | 653 | { |
| 634 | 654 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 655 | // printf("cfff_r: taking cnxx_slot to -1\n"); |
| 635 | 656 | state->m_a2_cnxx_slot = -1; |
| 636 | 657 | apple2_update_memory(space->machine()); |
| 637 | 658 | } |
| r14984 | r14985 | |
| 644 | 665 | if (!space->debugger_access()) |
| 645 | 666 | { |
| 646 | 667 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 668 | // printf("cfff_w: taking cnxx_slot to -1\n"); |
| 647 | 669 | state->m_a2_cnxx_slot = -1; |
| 648 | 670 | apple2_update_memory(space->machine()); |
| 649 | 671 | } |