src/mess/machine/mac.c
| r8331 | r8332 | |
| 78 | 78 | #include "devices/messram.h" |
| 79 | 79 | |
| 80 | 80 | #define ADB_IS_BITBANG (mac->mac_model >= MODEL_MAC_SE && mac->mac_model <= MODEL_MAC_CLASSIC) || (mac->mac_model >= MODEL_MAC_II && mac->mac_model <= MODEL_MAC_IICX) || (mac->mac_model == MODEL_MAC_SE30) |
| 81 | | #define ADB_IS_EGRET (mac->mac_model >= MODEL_MAC_LC && mac->mac_model <= MODEL_MAC_COLOR_CLASSIC) || (mac->mac_model == MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_IISI) |
| 81 | #define ADB_IS_EGRET (mac->mac_model >= MODEL_MAC_LC && mac->mac_model <= MODEL_MAC_COLOR_CLASSIC) || (mac->mac_model == MODEL_MAC_IISI) |
| 82 | 82 | #define ADB_IS_PM (mac->mac_model >= MODEL_MAC_PORTABLE && mac->mac_model <= MODEL_MAC_PB100) |
| 83 | 83 | |
| 84 | 84 | #ifdef MAME_DEBUG |
| r8331 | r8332 | |
| 997 | 997 | { |
| 998 | 998 | running_device *scc = devtag_get_device(space->machine, "scc"); |
| 999 | 999 | UINT8 wdata = data>>8; |
| 1000 | | |
| 1001 | 1000 | scc8530_w(scc, offset, wdata); |
| 1002 | 1001 | } |
| 1003 | 1002 | |
| r8331 | r8332 | |
| 1798 | 1797 | // Egret sending a response to the 680x0? |
| 1799 | 1798 | if (mac->adb_state & 1) |
| 1800 | 1799 | { |
| 1801 | | mac->adb_send = mac->adb_buffer[mac->adb_datasize]; |
| 1802 | | #if LOG_ADB |
| 1803 | | printf("Egret ADB: done sending byte %02x, %d left\n", mac->adb_send, mac->adb_datasize); |
| 1804 | | #endif |
| 1800 | if (mac->adb_datasize > 0) |
| 1801 | { |
| 1802 | mac->adb_send = mac->adb_buffer[mac->adb_datasize]; |
| 1803 | #if LOG_ADB |
| 1804 | printf("Egret ADB: sending byte %02x, %d left\n", mac->adb_send, mac->adb_datasize-1); |
| 1805 | #endif |
| 1805 | 1806 | |
| 1806 | | mac->adb_datasize--; |
| 1807 | | mac->adb_timer_ticks = 8; |
| 1808 | | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1807 | mac->adb_datasize--; |
| 1808 | } |
| 1809 | else |
| 1810 | { |
| 1811 | switch (mac->adb_streaming) |
| 1812 | { |
| 1813 | case MCU_STREAMING_PRAMRD: |
| 1814 | #if LOG_ADB |
| 1815 | printf("Egret ADB: streaming PRAM byte %02x = %02x\n", mac->adb_stream_ptr, mac->rtc_ram[mac->adb_stream_ptr]); |
| 1816 | #endif |
| 1817 | mac->adb_send = mac->rtc_ram[mac->adb_stream_ptr++]; |
| 1818 | if (mac->adb_stream_ptr >= 256) |
| 1819 | { |
| 1820 | #if LOG_ADB |
| 1821 | printf("Egret ADB: this is the last PRAM byte, dropping XS\n"); |
| 1822 | #endif |
| 1823 | mac->adb_state &= ~1; |
| 1824 | } |
| 1825 | break; |
| 1809 | 1826 | |
| 1810 | | if (mac->adb_datasize == 0) |
| 1827 | default: |
| 1828 | #if LOG_ADB |
| 1829 | printf("Egret ADB: trying to stream unhandled type\n"); |
| 1830 | #endif |
| 1831 | mac->adb_send = 0; |
| 1832 | break; |
| 1833 | } |
| 1834 | } |
| 1835 | |
| 1836 | // mac->adb_timer_ticks = 8; |
| 1837 | // timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1838 | |
| 1839 | if ((mac->adb_datasize == 0) && (mac->adb_streaming == MCU_STREAMING_NONE)) |
| 1811 | 1840 | { |
| 1812 | 1841 | #if LOG_ADB |
| 1813 | 1842 | printf("Egret ADB: this is the last byte, dropping XS\n"); |
| r8331 | r8332 | |
| 1817 | 1846 | } |
| 1818 | 1847 | else |
| 1819 | 1848 | { |
| 1820 | | #if LOG_ADB |
| 1821 | | printf("Egret ADB: got command byte %02x\n", mac->adb_command); |
| 1822 | | #endif |
| 1823 | | mac->adb_buffer[mac->adb_datasize++] = mac->adb_command; |
| 1824 | | mac->adb_command = 0; |
| 1849 | // it's not a command byte if SS is low |
| 1850 | if (mac->adb_state & 0x02) |
| 1851 | { |
| 1852 | #if LOG_ADB |
| 1853 | printf("Egret ADB: got command byte %02x [%02x]\n", mac->adb_command, mac->adb_datasize); |
| 1854 | #endif |
| 1855 | mac->adb_buffer[mac->adb_datasize++] = mac->adb_command; |
| 1856 | mac->adb_command = 0; |
| 1857 | } |
| 1825 | 1858 | } |
| 1826 | 1859 | } |
| 1827 | 1860 | } |
| r8331 | r8332 | |
| 1839 | 1872 | ret = (mac->adb_send & 0x80)>>7; |
| 1840 | 1873 | mac->adb_send <<= 1; |
| 1841 | 1874 | |
| 1842 | | // printf("IN CB2 = %x\n", ret); |
| 1875 | // printf("VIA IN CB2 = %x\n", ret); |
| 1843 | 1876 | |
| 1844 | 1877 | return ret; |
| 1845 | 1878 | } |
| r8331 | r8332 | |
| 1848 | 1881 | { |
| 1849 | 1882 | mac_state *mac = (mac_state *)device->machine->driver_data; |
| 1850 | 1883 | |
| 1851 | | // printf("OUT CB2 = %x\n", data); |
| 1884 | // printf("VIA OUT CB2 = %x\n", data); |
| 1852 | 1885 | mac->adb_command <<= 1; |
| 1853 | 1886 | mac->adb_command |= data & 1; |
| 1854 | 1887 | } |
| r8331 | r8332 | |
| 1925 | 1958 | |
| 1926 | 1959 | static void mac_egret_response_read_pram(mac_state *mac, int addr) |
| 1927 | 1960 | { |
| 1928 | | int count = 0x100 - addr; |
| 1961 | mac->adb_datasize = 4; |
| 1929 | 1962 | |
| 1930 | | mac->adb_datasize = count+3; |
| 1963 | mac->adb_send = 0xaa; |
| 1964 | mac->adb_buffer[4] = 1; // type |
| 1965 | mac->adb_buffer[3] = 0; // flag |
| 1966 | mac->adb_buffer[2] = 7; // command |
| 1967 | mac->adb_buffer[1] = mac->rtc_ram[addr]; |
| 1931 | 1968 | |
| 1932 | | mac->adb_buffer[count+3] = 1; |
| 1933 | | mac->adb_buffer[count+2] = 0; |
| 1934 | | mac->adb_buffer[count+1] = 7; |
| 1935 | | while (count) |
| 1936 | | { |
| 1937 | | mac->adb_buffer[count] = mac->rtc_ram[addr]; |
| 1938 | | addr++; |
| 1939 | | count--; |
| 1940 | | } |
| 1941 | | |
| 1942 | | mac->adb_send = 0xaa; |
| 1943 | 1969 | mac->adb_state |= 1; |
| 1944 | 1970 | mac->adb_timer_ticks = 8; |
| 1945 | 1971 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1972 | |
| 1973 | // read PRAM is a "streaming" command, don't drop the state line when we're out of data |
| 1974 | mac->adb_streaming = MCU_STREAMING_PRAMRD; |
| 1975 | mac->adb_stream_ptr = addr+1; |
| 1946 | 1976 | } |
| 1947 | 1977 | |
| 1948 | 1978 | static void mac_egret_mcu_exec(mac_state *mac) |
| 1949 | 1979 | { |
| 1980 | mac->adb_streaming = MCU_STREAMING_NONE; |
| 1950 | 1981 | switch (mac->adb_buffer[1]) |
| 1951 | 1982 | { |
| 1952 | 1983 | case 0x01: // enable/disable ADB auto-polling |
| r8331 | r8332 | |
| 1972 | 2003 | mac_egret_response_read_pram(mac, mac->adb_buffer[2]<<8 | mac->adb_buffer[3]); |
| 1973 | 2004 | break; |
| 1974 | 2005 | |
| 2006 | case 0x08: // write 6805 address |
| 2007 | { |
| 2008 | int addr = mac->adb_buffer[2]<<8 | mac->adb_buffer[3]; |
| 2009 | int len = mac->adb_datasize - 4; |
| 2010 | |
| 2011 | #if LOG_ADB |
| 2012 | printf("ADB: Egret write %d bytes to address %x\n", len, addr); |
| 2013 | #endif |
| 2014 | |
| 2015 | // check if this is a sneaky PRAM write (PRAM is at 6805 address 0x100) |
| 2016 | if ((addr >= 0x100) && (addr <= 0x200)) |
| 2017 | { |
| 2018 | for (int i = 0; i < len; i++) |
| 2019 | { |
| 2020 | mac->rtc_ram[(addr-0x100)+i] = mac->adb_buffer[4+i]; |
| 2021 | } |
| 2022 | } |
| 2023 | #if LOG_ADB |
| 2024 | else |
| 2025 | { |
| 2026 | printf("ADB: Egret unhandled direct write\n"); |
| 2027 | } |
| 2028 | #endif |
| 2029 | |
| 2030 | mac_egret_response_std(mac, 1, 0, 0x08); |
| 2031 | } |
| 2032 | break; |
| 2033 | |
| 2034 | case 0x0c: // write PRAM |
| 2035 | #if LOG_ADB |
| 2036 | printf("ADB: Egret write %02x to PRAM at %x\n", mac->adb_buffer[4], mac->adb_buffer[2]<<8 | mac->adb_buffer[3]); |
| 2037 | #endif |
| 2038 | |
| 2039 | mac->rtc_ram[mac->adb_buffer[2]<<8 | mac->adb_buffer[3]] = mac->adb_buffer[4]; |
| 2040 | |
| 2041 | mac->adb_datasize = 4; |
| 2042 | mac->adb_buffer[4] = 1; // type |
| 2043 | mac->adb_buffer[3] = 0; // flag |
| 2044 | mac->adb_buffer[2] = 0x0c; // command |
| 2045 | mac->adb_buffer[1] = 0; // spare |
| 2046 | mac->adb_state |= 1; |
| 2047 | mac->adb_timer_ticks = 8; |
| 2048 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2049 | break; |
| 2050 | |
| 1975 | 2051 | case 0x0e: // send to DFAC |
| 1976 | 2052 | #if LOG_ADB |
| 1977 | 2053 | printf("ADB: Egret send %02x to DFAC\n", mac->adb_buffer[2]); |
| r8331 | r8332 | |
| 2023 | 2099 | if (state != mac->adb_state) |
| 2024 | 2100 | { |
| 2025 | 2101 | #if LOG_ADB |
| 2026 | | printf("ADB: New Egret state: SS %d VF %d XS %d\n", (state>>2)&1, (state>>1)&1, mac->adb_state&1); |
| 2102 | printf("ADB: New Egret state: SS %d VF %d XS (68k %d MCU %d)\n", (state>>2)&1, (state>>1)&1, state&1, mac->adb_state&1); |
| 2027 | 2103 | #endif |
| 2028 | 2104 | |
| 2029 | | // if bit 2 is high and stays high, the rising edge of bit 1 indicates the start of sending a command |
| 2030 | | if ((state & 0x04) && (mac->adb_state & 0x04) && (state & 0x02) && !(mac->adb_state & 0x02)) |
| 2105 | // if bit 2 is high and stays high, the rising edge of bit 1 indicates the start of sending a byte to the MCU if XS isn't high |
| 2106 | if ((state & 0x04) && (mac->adb_state & 0x04) && (state & 0x02) && !(mac->adb_state & 0x02) && !(mac->adb_state & 0x01)) |
| 2031 | 2107 | { |
| 2032 | | mac->adb_command = mac->adb_send = 0; |
| 2108 | mac->adb_command = 0; |
| 2033 | 2109 | mac->adb_timer_ticks = 8; |
| 2034 | 2110 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2035 | 2111 | } |
| 2036 | 2112 | |
| 2113 | // if bit 2 is high and stays high, the falling edge of bit 1, and we're in send phase, the MCU should clock out a byte |
| 2114 | if ((state & 0x04) && (mac->adb_state & 0x04) && !(state & 0x02) && (mac->adb_state & 0x02) && (mac->adb_state & 0x01)) |
| 2115 | { |
| 2116 | mac->adb_timer_ticks = 8; |
| 2117 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2118 | } |
| 2119 | |
| 2120 | // if bit 2 rises, bit 1 is 0, and MCU XS is high, the MCU should clock out a byte |
| 2121 | if ((state & 0x04) && !(mac->adb_state & 0x04) && !(state & 0x02) && (mac->adb_state & 0x01)) |
| 2122 | { |
| 2123 | mac->adb_timer_ticks = 8; |
| 2124 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2125 | } |
| 2126 | |
| 2127 | // if bit 2 drops and bit 1 is 1, terminate the command |
| 2128 | if ((state & 0x02) && !(state & 0x04) && (mac->adb_state & 0x04)) |
| 2129 | { |
| 2130 | #if LOG_ADB |
| 2131 | printf("Egret ADB: SESSION dropped with VF=1, terminating command\n"); |
| 2132 | #endif |
| 2133 | mac->adb_streaming = MCU_STREAMING_NONE; |
| 2134 | mac->adb_state &= ~1; |
| 2135 | mac->adb_datasize = 0; |
| 2136 | } |
| 2137 | |
| 2037 | 2138 | // if bit 2 drops and bit 1 is zero, execute the command |
| 2038 | | if (!(state & 0x02) && !(state & 0x04) && (mac->adb_state & 0x04) && (mac->adb_datasize)) |
| 2139 | if (!(state & 0x02) && !(state & 0x04) && (mac->adb_state & 0x04) && (mac->adb_datasize > 0)) |
| 2039 | 2140 | { |
| 2040 | 2141 | #if LOG_ADB |
| 2041 | 2142 | int i; |
| 2042 | 2143 | |
| 2043 | | printf("ADB: Egret exec command with %d bytes: ", mac->adb_datasize); |
| 2144 | printf("Egret ADB: exec command with %d bytes: ", mac->adb_datasize); |
| 2044 | 2145 | |
| 2045 | 2146 | for (i = 0; i < mac->adb_datasize; i++) |
| 2046 | 2147 | { |
| r8331 | r8332 | |
| 2138 | 2239 | mac->adb_extclock = 0; |
| 2139 | 2240 | mac->adb_send = 0; |
| 2140 | 2241 | mac->adb_waiting_cmd = 0; |
| 2242 | mac->adb_streaming = MCU_STREAMING_NONE; |
| 2141 | 2243 | if (ADB_IS_BITBANG) |
| 2142 | 2244 | { |
| 2143 | 2245 | mac->adb_state = ADB_STATE_NOTINIT; |
src/mess/drivers/mac.c
| r8331 | r8332 | |
| 5 | 5 | |
| 6 | 6 | Nate Woods, Raphael Nabet, R. Belmont |
| 7 | 7 | |
| 8 | | |
| 9 | 8 | 0x000000 - 0x3fffff RAM/ROM (switches based on overlay) |
| 10 | 9 | 0x400000 - 0x4fffff ROM |
| 11 | 10 | 0x580000 - 0x5fffff 5380 NCR/Symbios SCSI peripherals chip (Mac Plus only) |
| r8331 | r8332 | |
| 85 | 84 | { |
| 86 | 85 | mac_state *mac = (mac_state *)space->machine->driver_data; |
| 87 | 86 | |
| 88 | | // logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu"))); |
| 87 | logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu"))); |
| 89 | 88 | |
| 90 | 89 | switch (offset) |
| 91 | 90 | { |
| 92 | | case 0: // VERSION |
| 91 | case 0x800: // VERSION |
| 92 | // LC/LCII return 0xe8 (V8 ASIC ASC emulation) |
| 93 | if ((mac->mac_model == MODEL_MAC_LC) || (mac->mac_model == MODEL_MAC_LC_II)) |
| 94 | { |
| 95 | return 0xe8; |
| 96 | } |
| 97 | |
| 98 | // LCIII returns 0xbc (Sonora ASIC ASC emulation) |
| 99 | if (mac->mac_model == MODEL_MAC_LC_III) |
| 100 | { |
| 101 | return 0xbc; |
| 102 | } |
| 103 | |
| 93 | 104 | return 0; // original ASC |
| 94 | 105 | |
| 106 | case 0x804: |
| 107 | if ((mac->mac_model == MODEL_MAC_LC) || (mac->mac_model == MODEL_MAC_LC_II)) |
| 108 | { |
| 109 | return 3; |
| 110 | } |
| 111 | break; |
| 112 | |
| 95 | 113 | default: |
| 96 | 114 | break; |
| 97 | 115 | } |
| r8331 | r8332 | |
| 105 | 123 | INT32 i; |
| 106 | 124 | mac_state *mac = (mac_state *)space->machine->driver_data; |
| 107 | 125 | |
| 108 | | // logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu"))); |
| 126 | logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu"))); |
| 109 | 127 | |
| 110 | 128 | mac->mac_asc_regs[offset] = data; |
| 111 | 129 | |
| r8331 | r8332 | |
| 874 | 892 | |
| 875 | 893 | MDRV_CPU_REPLACE("maincpu", M68030, 7833600*2) |
| 876 | 894 | MDRV_CPU_PROGRAM_MAP(macii_map) |
| 895 | MDRV_CPU_VBLANK_INT("screen", mac_cb264_vbl) |
| 877 | 896 | |
| 878 | 897 | MDRV_RAM_MODIFY("messram") |
| 879 | 898 | MDRV_RAM_DEFAULT_SIZE("2M") |