src/mess/machine/apple2gs.c
| r10340 | r10341 | |
| 118 | 118 | #include "sound/es5503.h" |
| 119 | 119 | #include "machine/ram.h" |
| 120 | 120 | #include "debugger.h" |
| 121 | #include "machine/ap2_slot.h" |
| 121 | 122 | |
| 122 | 123 | #define LOG_C0XX 0 |
| 123 | 124 | #define LOG_ADB 0 |
| r10340 | r10341 | |
| 1507 | 1508 | UINT8 result; |
| 1508 | 1509 | int slot; |
| 1509 | 1510 | |
| 1510 | | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1511 | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) // shadow all banks and C0xx? |
| 1511 | 1512 | { |
| 1512 | 1513 | result = ram_get_ptr(machine->device(RAM_TAG))[address]; |
| 1513 | 1514 | } |
| 1514 | | else if ((address & 0x000F00) == 0x000000) |
| 1515 | else if ((address & 0x000F00) == 0x000000) // accessing C0xx? |
| 1515 | 1516 | { |
| 1517 | state->a2_cnxx_slot = -1; |
| 1516 | 1518 | result = apple2gs_c0xx_r(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), address); |
| 1517 | 1519 | } |
| 1518 | 1520 | else |
| 1519 | 1521 | { |
| 1522 | device_t *slotdevice; |
| 1523 | |
| 1520 | 1524 | slot = (address & 0x000F00) / 0x100; |
| 1525 | if (slot <= 7) // slots 1-7, it's the slot |
| 1526 | { |
| 1527 | slotdevice = apple2_slot(machine, slot); |
| 1521 | 1528 | |
| 1522 | | if ((slot > 7) || ((state->sltromsel & (1 << slot)) == 0)) |
| 1523 | | result = *apple2gs_getslotmem(machine, address); |
| 1524 | | else |
| 1525 | | result = apple2_getfloatingbusvalue(machine); |
| 1529 | // is this slot internal or "Your Card"? |
| 1530 | if ((state->sltromsel & (1 << slot)) == 0) |
| 1531 | { |
| 1532 | // accessing a slot mapped to internal, let's put back the internal ROM |
| 1533 | state->a2_cnxx_slot = -1; |
| 1534 | result = *apple2gs_getslotmem(machine, address); |
| 1535 | } |
| 1536 | else |
| 1537 | { |
| 1538 | // accessing a slot mapped to "Your Card", C800 should belong to that card |
| 1539 | if (state->a2_cnxx_slot == -1) |
| 1540 | { |
| 1541 | state->a2_cnxx_slot = slot; |
| 1542 | } |
| 1543 | |
| 1544 | if (slotdevice != NULL) |
| 1545 | { |
| 1546 | result = apple2_slot_ROM_r(slotdevice, address&0xff); |
| 1547 | } |
| 1548 | else |
| 1549 | { |
| 1550 | result = apple2_getfloatingbusvalue(machine); |
| 1551 | } |
| 1552 | } |
| 1553 | } |
| 1554 | else // C800-CFFF, not cards |
| 1555 | { |
| 1556 | slotdevice = NULL; |
| 1557 | |
| 1558 | // if CFFF accessed, reset C800 area to internal ROM |
| 1559 | if ((address & 0xfff) == 0xfff) |
| 1560 | { |
| 1561 | state->a2_cnxx_slot = -1; |
| 1562 | } |
| 1563 | |
| 1564 | slotdevice = apple2_slot(machine, state->a2_cnxx_slot); |
| 1565 | |
| 1566 | if (slotdevice) |
| 1567 | { |
| 1568 | result = apple2_c800_slot_r(slotdevice, address&0x7ff); |
| 1569 | } |
| 1570 | else |
| 1571 | { |
| 1572 | result = *apple2gs_getslotmem(machine, address); |
| 1573 | } |
| 1574 | } |
| 1526 | 1575 | } |
| 1527 | 1576 | return result; |
| 1528 | 1577 | } |
| r10340 | r10341 | |
| 1534 | 1583 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1535 | 1584 | int slot; |
| 1536 | 1585 | |
| 1586 | // if CFFF accessed, reset C800 area to internal ROM |
| 1587 | if ((address & 0xfff) == 0xfff) |
| 1588 | { |
| 1589 | state->a2_cnxx_slot = -1; |
| 1590 | } |
| 1591 | |
| 1537 | 1592 | if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000)) |
| 1538 | 1593 | { |
| 1539 | 1594 | ram_get_ptr(machine->device(RAM_TAG))[address] = data; |
| r10340 | r10341 | |
| 1637 | 1692 | |
| 1638 | 1693 | /* allocate memory for E00000-E1FFFF */ |
| 1639 | 1694 | state->slowmem = auto_alloc_array_clear(machine, UINT8, 128*1024); |
| 1695 | state_save_register_item_pointer(machine, "APPLE2GS_SLOWMEM", NULL, 0, state->slowmem, 128*1024); |
| 1640 | 1696 | |
| 1641 | | state_save_register_item_array(machine, "APPLE2GS_SLOWMEM", NULL, 0, state->slowmem); |
| 1642 | | |
| 1643 | 1697 | /* install expanded memory */ |
| 1644 | 1698 | memory_install_readwrite_bank(space, 0x010000, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1"); |
| 1645 | 1699 | memory_set_bankptr(machine,"bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x010000); |
| r10340 | r10341 | |
| 1758 | 1812 | |
| 1759 | 1813 | /* save state stuff. note that the driver takes care of docram. */ |
| 1760 | 1814 | UINT8* ram = ram_get_ptr(machine->device(RAM_TAG)); |
| 1761 | | state_save_register_global_array(machine, ram); |
| 1815 | state_save_register_item_pointer(machine, "APPLE2GS_RAM", NULL, 0, ram, ram_get_size(machine->device(RAM_TAG))); |
| 1762 | 1816 | |
| 1763 | 1817 | state_save_register_item(machine, "NEWVIDEO", NULL, 0, state->newvideo); |
| 1764 | 1818 | |
| r10340 | r10341 | |
| 1781 | 1835 | state_save_register_item(machine, "CLKREG1", NULL,0, state->clock_reg1); |
| 1782 | 1836 | state_save_register_item(machine, "CLKCURTIME", NULL,0, state->clock_curtime); |
| 1783 | 1837 | state_save_register_item(machine, "CLKCURTIMEINT", NULL,0, state->clock_curtime_interval); |
| 1784 | | state_save_register_item(machine, "CLKMODE", NULL,0, state->clock_mode); |
| 1838 | // state_save_register_item(machine, "CLKMODE", NULL,0, state->clock_mode); |
| 1785 | 1839 | state->save_item(NAME(state->clock_bram)); |
| 1786 | 1840 | |
| 1787 | 1841 | state->save_item(NAME(state->adb_memory)); |
| 1788 | 1842 | state->save_item(NAME(state->adb_command_bytes)); |
| 1789 | 1843 | state->save_item(NAME(state->adb_response_bytes)); |
| 1790 | | state_save_register_item(machine, "ADB", NULL,0, state->adb_state); |
| 1844 | // state_save_register_item(machine, "ADB", NULL,0, state->adb_state); |
| 1791 | 1845 | state_save_register_item(machine, "ADB", NULL,0, state->adb_command); |
| 1792 | 1846 | state_save_register_item(machine, "ADB", NULL,0, state->adb_mode); |
| 1793 | 1847 | state_save_register_item(machine, "ADB", NULL,0, state->adb_kmstatus); |