src/mess/machine/mac.c
| r6327 | r6328 | |
| 42 | 42 | but A/UX can run 32. |
| 43 | 43 | - There are 5 known kinds of host-side ADB hardware: |
| 44 | 44 | * "Mac II ADB" used in the SE, II, IIx, IIcx, SE/30, IIci, Quadra 610, Quadra 650, Quadra 700, |
| 45 | | Quadra 800, Centris 610 and Centris 650. This is a dumb state machine using the VIA. |
| 45 | Quadra 800, Centris 610 and Centris 650. This is a bit-banger using the VIA and a simple PIC. |
| 46 | 46 | * "ADB-PMU" used in the Mac Portable and all 680x0-based PowerBooks. |
| 47 | 47 | * "ADB-EGRET" used in the IIsi, IIvi, IIvx, Classic II, LC, LC II, LC III, Performa 460, |
| 48 | 48 | and Performa 600. This is a 68HC05 with a different internal ROM than CUDA. |
| r6327 | r6328 | |
| 50 | 50 | Quadra 900, and Quadra 950. |
| 51 | 51 | * "ADB-CUDA" (Apple's CUDA chip, which is a 68HC05 MCU) used in the Color Classic, LC 520, |
| 52 | 52 | LC 55x, LC 57x, LC 58x, Quadra 630, Quadra 660AV, Quadra 840AV, PowerMac 6100/7100/8100, |
| 53 | | IIcx, IIci, and PowerMac 5200. |
| 53 | IIci, and PowerMac 5200. |
| 54 | 54 | |
| 55 | 55 | ` TODO: |
| 56 | 56 | - Mac Portable and PowerBook 100 are similar to this hardware, but we need ROMs! |
| r6327 | r6328 | |
| 76 | 76 | #include "debug/debugcpu.h" |
| 77 | 77 | #include "devices/messram.h" |
| 78 | 78 | |
| 79 | #define ADB_IS_BITBANG (mac_model >= MODEL_MAC_SE && mac_model <= MODEL_MAC_CLASSIC) || (mac_model >= MODEL_MAC_II && mac_model <= MODEL_MAC_IICX) || (mac_model == MODEL_MAC_SE30) |
| 80 | #define ADB_IS_EGRET (mac_model >= MODEL_MAC_LC && mac_model <= MODEL_MAC_COLOR_CLASSIC) || (mac_model == MODEL_MAC_IICI) || (mac_model == MODEL_MAC_IISI) |
| 81 | |
| 79 | 82 | #ifdef MAME_DEBUG |
| 80 | 83 | #define LOG_VIA 0 |
| 81 | 84 | #define LOG_RTC 0 |
| r6327 | r6328 | |
| 99 | 102 | #define ADB_STATE_XFER_EVEN (1) |
| 100 | 103 | #define ADB_STATE_XFER_ODD (2) |
| 101 | 104 | #define ADB_STATE_IDLE (3) |
| 105 | #define ADB_STATE_NOTINIT (4) |
| 102 | 106 | |
| 103 | 107 | // ADB commands |
| 104 | 108 | #define ADB_CMD_RESET (0) |
| r6327 | r6328 | |
| 229 | 233 | |
| 230 | 234 | memory_set_bankptr(machine,bank, memory_data); |
| 231 | 235 | |
| 232 | | if (LOG_MEMORY) |
| 236 | if (1) //LOG_MEMORY) |
| 233 | 237 | { |
| 234 | 238 | logerror("mac_install_memory(): bank=%d range=[0x%06x...0x%06x] mask=0x%06x ptr=0x%p\n", |
| 235 | 239 | bank, memory_begin, memory_end, memory_mask, memory_data); |
| r6327 | r6328 | |
| 369 | 373 | /* install the memory */ |
| 370 | 374 | if (((mac_model >= MODEL_MAC_LC) && (mac_model <= MODEL_MAC_COLOR_CLASSIC))|| (mac_model == MODEL_MAC_LC_II)) |
| 371 | 375 | { |
| 372 | | mac_install_memory(machine, 0x00000000, 0x009fffff, memory_size, memory_data, is_rom, 1); |
| 376 | mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, 1); |
| 373 | 377 | } |
| 374 | 378 | else if ((mac_model == MODEL_MAC_IICI) || (mac_model == MODEL_MAC_IISI)) |
| 375 | 379 | { |
| r6327 | r6328 | |
| 1312 | 1316 | { |
| 1313 | 1317 | if (LOG_RTC) |
| 1314 | 1318 | logerror("trashing PRAM\n"); |
| 1319 | |
| 1320 | memset(rtc_ram, 0, sizeof(rtc_ram)); |
| 1321 | |
| 1322 | // some Mac ROMs are buggy in the presence of |
| 1323 | // no NVRAM, so let's initialize it right |
| 1324 | rtc_ram[0] = 0xa8; // valid |
| 1325 | rtc_ram[4] = 0xcc; |
| 1326 | rtc_ram[5] = 0x0a; |
| 1327 | rtc_ram[6] = 0xcc; |
| 1328 | rtc_ram[7] = 0x0a; |
| 1329 | rtc_ram[0xc] = 0x42; // XPRAM valid for Plus/SE |
| 1330 | rtc_ram[0xd] = 0x75; |
| 1331 | rtc_ram[0xe] = 0x67; |
| 1332 | rtc_ram[0xf] = 0x73; |
| 1333 | rtc_ram[0x10] = 0x18; |
| 1334 | rtc_ram[0x11] = 0x88; |
| 1335 | rtc_ram[0x12] = 0x01; |
| 1336 | rtc_ram[0x13] = 0x4c; |
| 1337 | |
| 1338 | if (mac_model >= MODEL_MAC_II) |
| 1339 | { |
| 1340 | rtc_ram[0xc] = 0x4e; // XPRAM valid is different for these |
| 1341 | rtc_ram[0xd] = 0x75; |
| 1342 | rtc_ram[0xe] = 0x4d; |
| 1343 | rtc_ram[0xf] = 0x63; |
| 1344 | rtc_ram[0x77] = 0x01; |
| 1345 | rtc_ram[0x78] = 0xff; |
| 1346 | rtc_ram[0x79] = 0xff; |
| 1347 | rtc_ram[0x7a] = 0xff; |
| 1348 | rtc_ram[0x7b] = 0xdf; |
| 1349 | } |
| 1315 | 1350 | } |
| 1316 | 1351 | |
| 1317 | 1352 | { |
| r6327 | r6328 | |
| 1387 | 1422 | * *************************************************************************/ |
| 1388 | 1423 | |
| 1389 | 1424 | // Mac ADB state |
| 1390 | | static int adb_irq_pending, adb_waiting_cmd, adb_datasize, adb_buffer[8]; |
| 1425 | static int adb_irq_pending, adb_waiting_cmd, adb_datasize, adb_buffer[16]; |
| 1391 | 1426 | static int adb_state, adb_command, adb_send, adb_timer_ticks, adb_extclock, adb_direction; |
| 1392 | | static int adb_listenreg, adb_listenaddr; |
| 1427 | static int adb_listenreg, adb_listenaddr, adb_last_talk; |
| 1393 | 1428 | |
| 1394 | 1429 | // ADB mouse state |
| 1395 | 1430 | static int adb_mouseaddr = 3; |
| r6327 | r6328 | |
| 1407 | 1442 | { |
| 1408 | 1443 | int NewX, NewY, NewButton; |
| 1409 | 1444 | |
| 1445 | if (!adb_mouse_initialized) |
| 1446 | { |
| 1447 | return; |
| 1448 | } |
| 1449 | |
| 1410 | 1450 | NewButton = input_port_read(machine, "MOUSE0") & 0x01; |
| 1411 | 1451 | NewX = input_port_read(machine, "MOUSE2"); |
| 1412 | 1452 | NewY = input_port_read(machine, "MOUSE1"); |
| r6327 | r6328 | |
| 1495 | 1535 | |
| 1496 | 1536 | adb_direction = 0; |
| 1497 | 1537 | adb_send = 0; |
| 1498 | | |
| 1499 | | #if 0 |
| 1500 | | adb_buffer[0] = 0xff; |
| 1501 | | adb_datasize = 1; |
| 1502 | | |
| 1503 | | // it's not documented how to respond, but yanking SRQ seems to work |
| 1504 | | adb_extclock ^= 1; |
| 1505 | | via_cb1_w(via_0, 0, adb_extclock); |
| 1506 | | adb_extclock ^= 1; |
| 1507 | | via_cb1_w(via_0, 0, adb_extclock); |
| 1508 | | #endif |
| 1509 | 1538 | break; |
| 1510 | 1539 | |
| 1511 | 1540 | default: // reserved/unused |
| r6327 | r6328 | |
| 1521 | 1550 | adb_direction = 1; // input from Mac |
| 1522 | 1551 | adb_listenreg = reg; |
| 1523 | 1552 | adb_listenaddr = addr; |
| 1553 | adb_command = 0; |
| 1524 | 1554 | break; |
| 1525 | 1555 | |
| 1526 | 1556 | case 3: // talk |
| r6327 | r6328 | |
| 1528 | 1558 | printf("ADB TALK: reg %x address %x\n", reg, addr); |
| 1529 | 1559 | #endif |
| 1530 | 1560 | |
| 1561 | // keep track of what device the Mac last TALKed to |
| 1562 | adb_last_talk = addr; |
| 1563 | |
| 1531 | 1564 | adb_direction = 0; // output to Mac |
| 1532 | 1565 | if (addr == adb_mouseaddr) |
| 1533 | 1566 | { |
| r6327 | r6328 | |
| 1600 | 1633 | #if LOG_ADB |
| 1601 | 1634 | printf("ADB: talking to unconnected device\n"); |
| 1602 | 1635 | #endif |
| 1603 | | adb_buffer[0] = adb_buffer[1] = 0xff; |
| 1636 | adb_buffer[0] = adb_buffer[1] = 0; |
| 1604 | 1637 | adb_datasize = 0; |
| 1605 | 1638 | } |
| 1606 | 1639 | break; |
| r6327 | r6328 | |
| 1610 | 1643 | } |
| 1611 | 1644 | else |
| 1612 | 1645 | { |
| 1613 | | printf("Got LISTEN data %x for device %x reg %x\n", adb_command, adb_listenreg, adb_listenaddr); |
| 1646 | #if LOG_ADB |
| 1647 | printf("Got LISTEN data %x for device %x reg %x\n", adb_command, adb_listenaddr, adb_listenreg); |
| 1648 | #endif |
| 1649 | #if 0 |
| 1650 | if (adb_listenaddr == adb_mouseaddr) |
| 1651 | { |
| 1652 | if ((adb_listenreg == 3) && (adb_command > 0) && (adb_command < 16)) |
| 1653 | { |
| 1654 | #if LOG_ADB |
| 1655 | printf("MOUSE: moving to address %x\n", adb_command); |
| 1656 | #endif |
| 1657 | adb_mouseaddr = adb_command&0x0f; |
| 1658 | } |
| 1659 | } |
| 1660 | else if (adb_listenaddr == adb_keybaddr) |
| 1661 | { |
| 1662 | if ((adb_listenreg == 3) && (adb_command > 0) && (adb_command < 16)) |
| 1663 | { |
| 1664 | #if LOG_ADB |
| 1665 | printf("KEYBOARD: moving to address %x\n", adb_command); |
| 1666 | #endif |
| 1667 | adb_keybaddr = adb_command&0x0f; |
| 1668 | } |
| 1669 | } |
| 1670 | #endif |
| 1614 | 1671 | } |
| 1615 | 1672 | } |
| 1616 | 1673 | |
| r6327 | r6328 | |
| 1629 | 1686 | { |
| 1630 | 1687 | timer_adjust_oneshot(mac_adb_timer, attotime_never, 0); |
| 1631 | 1688 | |
| 1632 | | if (adb_direction) |
| 1689 | if ((adb_direction) && (ADB_IS_BITBANG)) |
| 1633 | 1690 | { |
| 1634 | 1691 | mac_adb_talk(machine); |
| 1635 | 1692 | } |
| 1693 | else if (ADB_IS_EGRET) |
| 1694 | { |
| 1695 | #if LOG_ADB |
| 1696 | printf("Egret ADB: got command byte %02x\n", adb_command); |
| 1697 | #endif |
| 1698 | } |
| 1636 | 1699 | } |
| 1637 | 1700 | else |
| 1638 | 1701 | { |
| r6327 | r6328 | |
| 1654 | 1717 | |
| 1655 | 1718 | static WRITE8_DEVICE_HANDLER(mac_adb_via_out_cb2) |
| 1656 | 1719 | { |
| 1657 | | // printf("OUT CB2 = %x\n", data); |
| 1720 | // printf("OUT CB2 = %x\n", data); |
| 1658 | 1721 | adb_command <<= 1; |
| 1659 | 1722 | adb_command |= data & 1; |
| 1660 | 1723 | } |
| r6327 | r6328 | |
| 1676 | 1739 | adb_command = adb_send = 0; |
| 1677 | 1740 | adb_direction = 1; // Mac is shifting us a command |
| 1678 | 1741 | adb_waiting_cmd = 1; // we're going to get a command |
| 1742 | adb_irq_pending = 0; |
| 1679 | 1743 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1680 | 1744 | break; |
| 1681 | 1745 | |
| r6327 | r6328 | |
| 1698 | 1762 | adb_buffer[i] = adb_buffer[i+1]; |
| 1699 | 1763 | } |
| 1700 | 1764 | } |
| 1765 | |
| 1701 | 1766 | } |
| 1702 | 1767 | else |
| 1703 | 1768 | { |
| 1704 | 1769 | adb_send = 0; |
| 1770 | adb_irq_pending = 1; |
| 1705 | 1771 | } |
| 1706 | 1772 | |
| 1707 | 1773 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1708 | 1774 | break; |
| 1709 | 1775 | |
| 1710 | 1776 | case ADB_STATE_IDLE: |
| 1777 | adb_irq_pending = 0; |
| 1778 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1711 | 1779 | break; |
| 1712 | 1780 | } |
| 1713 | 1781 | } |
| 1714 | 1782 | } |
| 1715 | 1783 | |
| 1784 | static void mac_egret_newaction(int state) |
| 1785 | { |
| 1786 | if (state != adb_state) |
| 1787 | { |
| 1788 | #if LOG_ADB |
| 1789 | printf("ADB: New Egret state: SS %d VF %d XS %d\n", (state>>2)&1, (state>>1)&1, state&1); |
| 1790 | #endif |
| 1791 | |
| 1792 | // rising edge of VIA bit 5 (bit 2 here) seems to mean the 68k wants to send something |
| 1793 | if ((state & 0x04) && !(adb_state & 0x4)) |
| 1794 | { |
| 1795 | adb_command = adb_send = 0; |
| 1796 | adb_timer_ticks = 8; |
| 1797 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1798 | } |
| 1799 | |
| 1800 | adb_state = state; |
| 1801 | } |
| 1802 | } |
| 1803 | |
| 1716 | 1804 | static void adb_vblank(running_machine *machine) |
| 1717 | 1805 | { |
| 1718 | 1806 | // if any device has a service request, show it on the VIA |
| 1719 | 1807 | // (no need to actually generate an IRQ, the Mac will see it) |
| 1720 | 1808 | if ((adb_mouse_wanted_srq) || (adb_keyb_wanted_srq)) |
| 1721 | 1809 | { |
| 1722 | | // printf("ADB IRQ: kb %d ms %d\n", adb_keyb_wanted_srq, adb_mouse_wanted_srq); |
| 1810 | // printf("ADB IRQ: kb %d ms %d (last talk %d)\n", adb_keyb_wanted_srq, adb_mouse_wanted_srq, adb_last_talk); |
| 1723 | 1811 | adb_irq_pending = 1; |
| 1724 | 1812 | } |
| 1725 | 1813 | else |
| r6327 | r6328 | |
| 1729 | 1817 | |
| 1730 | 1818 | if ((adb_state == ADB_STATE_IDLE) && (adb_mouse_wanted_srq)) |
| 1731 | 1819 | { |
| 1732 | | // repeat last TALK to get updated data |
| 1733 | | adb_waiting_cmd = 1; |
| 1734 | | mac_adb_talk(machine); |
| 1820 | // if the mouse was the last TALK, we can just send the new data |
| 1821 | // otherwise we need to pull SRQ |
| 1822 | if (adb_last_talk == adb_mouseaddr) |
| 1823 | { |
| 1824 | // repeat last TALK to get updated data |
| 1825 | adb_waiting_cmd = 1; |
| 1826 | mac_adb_talk(machine); |
| 1735 | 1827 | |
| 1736 | | adb_timer_ticks = 8; |
| 1737 | | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1738 | | adb_mouse_wanted_srq = 0; |
| 1828 | adb_timer_ticks = 8; |
| 1829 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1830 | adb_mouse_wanted_srq = 0; |
| 1831 | } |
| 1832 | #if 0 |
| 1833 | else |
| 1834 | { |
| 1835 | printf("IDLE, mouse moved, mouse not last TALK, pulling SRQ\n"); |
| 1836 | adb_irq_pending = 1; |
| 1837 | |
| 1838 | adb_command = adb_send = 0; |
| 1839 | adb_timer_ticks = 8; |
| 1840 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1841 | } |
| 1842 | #endif |
| 1739 | 1843 | } |
| 1740 | 1844 | } |
| 1741 | 1845 | } |
| r6327 | r6328 | |
| 1748 | 1852 | adb_extclock = 0; |
| 1749 | 1853 | adb_send = 0; |
| 1750 | 1854 | adb_waiting_cmd = 0; |
| 1751 | | adb_state = ADB_STATE_IDLE; |
| 1855 | adb_state = ADB_STATE_NOTINIT; |
| 1752 | 1856 | adb_direction = 0; |
| 1753 | 1857 | adb_datasize = 0; |
| 1754 | | |
| 1858 | adb_last_talk = -1; |
| 1859 | |
| 1755 | 1860 | // mouse |
| 1756 | 1861 | adb_mouseaddr = 3; |
| 1757 | 1862 | adb_lastmousex = adb_lastmousey = adb_lastbutton = 0; |
| r6327 | r6328 | |
| 1759 | 1864 | adb_mouse_initialized = 0; |
| 1760 | 1865 | |
| 1761 | 1866 | // keyboard |
| 1762 | | adb_keybaddr = 2; |
| 1867 | adb_keybaddr = 2; |
| 1763 | 1868 | adb_keyb_wanted_srq = 0; |
| 1764 | 1869 | adb_keybinitialized = 0; |
| 1765 | 1870 | } |
| r6327 | r6328 | |
| 1805 | 1910 | // printf("VIA1 IN_A (PC %x)\n", cpu_get_pc(cputag_get_cpu(device->machine, "maincpu"))); |
| 1806 | 1911 | |
| 1807 | 1912 | if ((mac_model == MODEL_MAC_CLASSIC) || |
| 1808 | | (mac_model == MODEL_MAC_LC_II) || (mac_model == MODEL_MAC_II) || |
| 1809 | | (mac_model == MODEL_MAC_II_FDHD) || (mac_model == MODEL_MAC_IIX)) |
| 1913 | (mac_model == MODEL_MAC_II) || (mac_model == MODEL_MAC_II_FDHD) || |
| 1914 | (mac_model == MODEL_MAC_IIX)) |
| 1810 | 1915 | { |
| 1811 | 1916 | return 0x81; // bit 0 must be set to avoid attempting to boot from AppleTalk |
| 1812 | 1917 | } |
| r6327 | r6328 | |
| 1816 | 1921 | return 0x81 | PA6; |
| 1817 | 1922 | } |
| 1818 | 1923 | |
| 1819 | | if (mac_model == MODEL_MAC_LC) |
| 1924 | if ((mac_model == MODEL_MAC_LC) || (mac_model == MODEL_MAC_LC_II)) // these both use the V8 ASIC and should in theory ID the same |
| 1820 | 1925 | { |
| 1821 | 1926 | return 0x81 | PA6 | PA4 | PA2; |
| 1822 | 1927 | } |
| r6327 | r6328 | |
| 1848 | 1953 | { |
| 1849 | 1954 | int val = 0; |
| 1850 | 1955 | |
| 1851 | | // printf("VIA1 IN_B (PC %x)\n", cpu_get_pc(cputag_get_cpu(device->machine, "maincpu"))); |
| 1852 | | |
| 1853 | 1956 | /* video beam in display (! VBLANK && ! HBLANK basically) */ |
| 1854 | 1957 | if (video_screen_get_vpos(device->machine->primary_screen) >= MAC_V_VIS) |
| 1855 | 1958 | val |= 0x40; |
| 1856 | 1959 | |
| 1857 | | if (has_adb()) |
| 1960 | if ((ADB_IS_BITBANG) || (ADB_IS_EGRET)) |
| 1858 | 1961 | { |
| 1859 | 1962 | val |= adb_state<<4; |
| 1860 | 1963 | |
| r6327 | r6328 | |
| 1875 | 1978 | if (rtc_data_out) |
| 1876 | 1979 | val |= 1; |
| 1877 | 1980 | |
| 1981 | // printf("VIA1 IN_B = %02x (PC %x)\n", val, cpu_get_pc(cputag_get_cpu(device->machine, "maincpu"))); |
| 1982 | |
| 1878 | 1983 | return val; |
| 1879 | 1984 | } |
| 1880 | 1985 | |
| r6327 | r6328 | |
| 1947 | 2052 | rtc_shift_data(data & 0x01); |
| 1948 | 2053 | rtc_rTCClk = new_rtc_rTCClk; |
| 1949 | 2054 | |
| 1950 | | if (has_adb()) |
| 2055 | if (ADB_IS_BITBANG) |
| 1951 | 2056 | { |
| 1952 | 2057 | mac_adb_newaction((data & 0x30) >> 4); |
| 1953 | 2058 | } |
| 2059 | else if (ADB_IS_EGRET) |
| 2060 | { |
| 2061 | mac_egret_newaction((data & 0x38) >> 3); |
| 2062 | } |
| 1954 | 2063 | } |
| 1955 | 2064 | |
| 1956 | 2065 | static void mac_via_irq(const device_config *device, int state) |
| r6327 | r6328 | |
| 2006 | 2115 | offset &= 0x0f; |
| 2007 | 2116 | |
| 2008 | 2117 | if (LOG_VIA) |
| 2009 | | logerror("mac_via2_r: offset=0x%02x\n", offset); |
| 2118 | logerror("mac_via2_r: offset=0x%02x\n", offset*2); |
| 2010 | 2119 | data = via_r(via_1, offset); |
| 2011 | 2120 | |
| 2012 | 2121 | return (data & 0xff) | (data << 8); |
| r6327 | r6328 | |
| 2020 | 2129 | offset &= 0x0f; |
| 2021 | 2130 | |
| 2022 | 2131 | if (LOG_VIA) |
| 2023 | | logerror("mac_via2_w: offset=0x%02x data=0x%08x\n", offset, data); |
| 2132 | logerror("mac_via2_w: offset=%x data=0x%08x\n", offset, data); |
| 2024 | 2133 | |
| 2025 | 2134 | if (ACCESSING_BITS_8_15) |
| 2026 | 2135 | via_w(via_1, offset, (data >> 8) & 0xff); |
| r6327 | r6328 | |
| 2043 | 2152 | { |
| 2044 | 2153 | // logerror("VIA2 IN B (PC %x)\n", cpu_get_pc(cputag_get_cpu(device->machine, "maincpu"))); |
| 2045 | 2154 | |
| 2155 | if ((mac_model == MODEL_MAC_LC) || (mac_model == MODEL_MAC_LC_II)) |
| 2156 | { |
| 2157 | return 0x4f; |
| 2158 | } |
| 2159 | |
| 2046 | 2160 | if (mac_model == MODEL_MAC_SE30) |
| 2047 | 2161 | { |
| 2048 | 2162 | return 0x87; // bits 3 and 6 are tied low on SE/30 |
| r6327 | r6328 | |
| 2062 | 2176 | |
| 2063 | 2177 | // logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(cputag_get_cpu(device->machine, "maincpu"))); |
| 2064 | 2178 | |
| 2179 | // printf("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08); |
| 2180 | |
| 2065 | 2181 | // chain 60.15 Hz to VIA1 |
| 2066 | 2182 | via_ca1_w(via_0, 0, data>>7); |
| 2067 | 2183 | } |
| r6327 | r6328 | |
| 2175 | 2291 | } |
| 2176 | 2292 | else if ((model == MODEL_MAC_LC) || (model == MODEL_MAC_LC_II)) |
| 2177 | 2293 | { |
| 2178 | | mac_install_memory(machine, 0x000000, 0x9fffff, messram_get_size(devtag_get_device(machine, "messram")), messram_get_ptr(devtag_get_device(machine, "messram")), FALSE, 2); |
| 2294 | mac_install_memory(machine, 0x000000, messram_get_size(devtag_get_device(machine, "messram"))-1, messram_get_size(devtag_get_device(machine, "messram")), messram_get_ptr(devtag_get_device(machine, "messram")), FALSE, 2); |
| 2179 | 2295 | } |
| 2180 | 2296 | else if ((mac_model == MODEL_MAC_CLASSIC_II) || ((mac_model >= MODEL_MAC_II) && (mac_model <= MODEL_MAC_SE30))) |
| 2181 | 2297 | { |
src/mess/drivers/mac.c
| r6327 | r6328 | |
| 35 | 35 | PB_EXT from mouse Y circuitry |
| 36 | 36 | PA_EXT from mouse X circuitry |
| 37 | 37 | |
| 38 | | RBV @ 43f80, alt 48000 |
| 38 | LC ram sizer: a46576, stores size at 7ffc |
| 39 | 39 | |
| 40 | 40 | ****************************************************************************/ |
| 41 | 41 | |
| r6327 | r6328 | |
| 192 | 192 | if (rbv_count == 3) |
| 193 | 193 | { |
| 194 | 194 | rbv_count = 0; |
| 195 | | rbv_clutoffs++; |
| 196 | 195 | palette_set_color(space->machine, rbv_clutoffs, MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2])); |
| 197 | 196 | rbv_palette[rbv_clutoffs] = MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2]); |
| 197 | rbv_clutoffs++; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | } |
| r6327 | r6328 | |
| 244 | 244 | via_w(via_1, offset, (data >> 8) & 0xff); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | // LC/LC II "V8" video and friends |
| 248 | |
| 249 | static UINT8 v8_regs[256]; |
| 250 | static UINT32 v8_colors[3], v8_count, v8_clutoffs; |
| 251 | static UINT32 v8_palette[256]; |
| 252 | |
| 253 | static READ16_HANDLER ( mac_v8_r ) |
| 254 | { |
| 255 | int data, viaoffs; |
| 256 | const device_config *via_1 = devtag_get_device(space->machine, "via6522_1"); |
| 257 | |
| 258 | printf("v8_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu)); |
| 259 | |
| 260 | viaoffs = (offset >> 8) & 0x0f; |
| 261 | |
| 262 | switch (offset) |
| 263 | { |
| 264 | case 0: |
| 265 | data = via_r(via_1, viaoffs); |
| 266 | return (data<<8) | v8_regs[0]; |
| 267 | |
| 268 | default: |
| 269 | data = via_r(via_1, viaoffs); |
| 270 | return (data<<8)|data; |
| 271 | } |
| 272 | |
| 273 | } |
| 274 | |
| 275 | static WRITE16_HANDLER ( mac_v8_w ) |
| 276 | { |
| 277 | const device_config *via_1 = devtag_get_device(space->machine, "via6522_1"); |
| 278 | int viaoffs; |
| 279 | |
| 280 | printf("v8_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu)); |
| 281 | |
| 282 | viaoffs = (offset >> 8) & 0x0f; |
| 283 | |
| 284 | switch (offset) |
| 285 | { |
| 286 | case 0: |
| 287 | if (ACCESSING_BITS_8_15) |
| 288 | { |
| 289 | via_w(via_1, viaoffs, (data >> 8) & 0xff); |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | v8_regs[0] = data&0xe7; |
| 294 | } |
| 295 | break; |
| 296 | |
| 297 | default: |
| 298 | if (ACCESSING_BITS_8_15) |
| 299 | { |
| 300 | via_w(via_1, viaoffs, (data >> 8) & 0xff); |
| 301 | } |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | static WRITE32_HANDLER( mac_v8_ramdac_w ) |
| 307 | { |
| 308 | if (mem_mask == 0xff000000) |
| 309 | { |
| 310 | v8_clutoffs = data>>24; |
| 311 | v8_count = 0; |
| 312 | } |
| 313 | else if (mem_mask == 0x00ff0000) |
| 314 | { |
| 315 | v8_colors[v8_count++] = data>>16; |
| 316 | |
| 317 | if (v8_count == 3) |
| 318 | { |
| 319 | v8_count = 0; |
| 320 | palette_set_color(space->machine, v8_clutoffs, MAKE_RGB(v8_colors[0], v8_colors[1], v8_colors[2])); |
| 321 | v8_palette[v8_clutoffs] = MAKE_RGB(v8_colors[0], v8_colors[1], v8_colors[2]); |
| 322 | v8_clutoffs++; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | static VIDEO_START( maclc ) |
| 328 | { |
| 329 | memset(v8_regs, 0, sizeof(v8_regs)); |
| 330 | |
| 331 | v8_regs[1] = 0x6; // set init value |
| 332 | } |
| 333 | |
| 334 | static VIDEO_UPDATE( maclc ) |
| 335 | { |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 247 | 339 | /*************************************************************************** |
| 248 | 340 | ADDRESS MAPS |
| 249 | 341 | ***************************************************************************/ |
| r6327 | r6328 | |
| 279 | 371 | // 50f18000-9fff = PWMs |
| 280 | 372 | |
| 281 | 373 | // 50f24000-5fff = VDAC (palette) |
| 282 | | AM_RANGE(0x50f24000, 0x50f25fff) AM_RAM |
| 283 | | AM_RANGE(0x50f26000, 0x50f27fff) AM_READWRITE16(mac_via2_r, mac_via2_w, 0xffffffff) // VIA2 (RBV) |
| 374 | AM_RANGE(0x50f24000, 0x50f24003) AM_WRITE(mac_v8_ramdac_w) |
| 375 | AM_RANGE(0x50f26000, 0x50f27fff) AM_READWRITE16(mac_v8_r, mac_v8_w, 0xffffffff) // VIA2 (V8) |
| 284 | 376 | |
| 285 | 377 | AM_RANGE(0xfeff8000, 0xfeffffff) AM_ROM AM_REGION("user1", 0x78000) |
| 286 | 378 | ADDRESS_MAP_END |
| r6327 | r6328 | |
| 398 | 490 | AM_RANGE(0xfeff8000, 0xfeffffff) AM_ROM AM_REGION("user1", 0x78000) |
| 399 | 491 | ADDRESS_MAP_END |
| 400 | 492 | |
| 401 | | static VIDEO_START( maclc ) |
| 402 | | { |
| 403 | | } |
| 404 | | |
| 405 | | static VIDEO_UPDATE( maclc ) |
| 406 | | { |
| 407 | | return 0; |
| 408 | | } |
| 409 | | |
| 410 | | |
| 411 | 493 | /*************************************************************************** |
| 412 | 494 | DEVICE CONFIG |
| 413 | 495 | ***************************************************************************/ |