trunk/src/mess/drivers/atari400.c
r32749 | r32750 | |
270 | 270 | DECLARE_READ8_MEMBER(read_d5xx); // at least one cart type can enable/disable roms when reading |
271 | 271 | DECLARE_WRITE8_MEMBER(disable_cart); |
272 | 272 | |
| 273 | // these are needed to handle carts which can disable ROM without |
| 274 | // installing/disinstalling continuously RAM and ROM (with e.g. big |
| 275 | // preformance hit in Williams carts) |
| 276 | DECLARE_READ8_MEMBER(special_read_8000); |
| 277 | DECLARE_WRITE8_MEMBER(special_write_8000); |
| 278 | DECLARE_READ8_MEMBER(special_read_a000); |
| 279 | DECLARE_WRITE8_MEMBER(special_write_a000); |
| 280 | |
273 | 281 | DECLARE_READ8_MEMBER(a600xl_low_r); |
274 | 282 | DECLARE_READ8_MEMBER(a1200xl_low_r); |
275 | 283 | DECLARE_READ8_MEMBER(a800xl_low_r); |
r32749 | r32750 | |
299 | 307 | optional_device<a800_cart_slot_device> m_cart; |
300 | 308 | optional_device<a800_cart_slot_device> m_cart2; |
301 | 309 | |
302 | | int m_cart_disabled; |
| 310 | int m_cart_disabled, m_cart_helper; |
303 | 311 | int m_last_offs; |
304 | 312 | UINT8 m_mmu, m_ext_bank; |
305 | 313 | |
r32749 | r32750 | |
1727 | 1735 | } |
1728 | 1736 | } |
1729 | 1737 | |
| 1738 | |
| 1739 | // these handle cart enable/disable without calling setup_ram thousands of times |
| 1740 | READ8_MEMBER(a400_state::special_read_8000) |
| 1741 | { |
| 1742 | if (!m_cart_disabled) |
| 1743 | return m_cart->read_80xx(space, offset); |
| 1744 | else |
| 1745 | { |
| 1746 | offset += 0x8000; |
| 1747 | if (m_ram->size() < offset) |
| 1748 | return 0; |
| 1749 | else |
| 1750 | return m_ram->pointer()[offset]; |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | WRITE8_MEMBER(a400_state::special_write_8000) |
| 1755 | { |
| 1756 | if (m_cart_disabled) |
| 1757 | { |
| 1758 | offset += 0x8000; |
| 1759 | if (m_ram->size() >= offset) |
| 1760 | m_ram->pointer()[offset] = data; |
| 1761 | } |
| 1762 | } |
| 1763 | |
| 1764 | READ8_MEMBER(a400_state::special_read_a000) |
| 1765 | { |
| 1766 | if (!m_cart_disabled) |
| 1767 | return m_cart->read_80xx(space, offset); |
| 1768 | else |
| 1769 | { |
| 1770 | offset += 0xa000; |
| 1771 | if (m_ram->size() < offset) |
| 1772 | return 0; |
| 1773 | else |
| 1774 | return m_ram->pointer()[offset]; |
| 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | WRITE8_MEMBER(a400_state::special_write_a000) |
| 1779 | { |
| 1780 | if (m_cart_disabled) |
| 1781 | { |
| 1782 | offset += 0xa000; |
| 1783 | if (m_ram->size() >= offset) |
| 1784 | m_ram->pointer()[offset] = data; |
| 1785 | } |
| 1786 | } |
| 1787 | |
| 1788 | |
1730 | 1789 | READ8_MEMBER(a400_state::read_d5xx) |
1731 | 1790 | { |
1732 | 1791 | disable_cart(space, offset, 0); |
r32749 | r32750 | |
1742 | 1801 | case A800_PHOENIX: |
1743 | 1802 | case A800_BLIZZARD: |
1744 | 1803 | if (!m_cart_disabled) |
1745 | | { |
1746 | 1804 | m_cart_disabled = 1; |
1747 | | setup_ram(2, m_ram->size()); |
1748 | | } |
1749 | 1805 | break; |
1750 | 1806 | case A800_OSS034M: |
1751 | 1807 | case A800_OSS043M: |
r32749 | r32750 | |
1755 | 1811 | // use m_cart_disabled & m_last_offs to avoid continuous remapping of |
1756 | 1812 | // the memory space in some games (e.g. dropzone) |
1757 | 1813 | if (offset & 0x8 && !m_cart_disabled) |
1758 | | { |
1759 | 1814 | m_cart_disabled = 1; |
1760 | | setup_ram(2, m_ram->size()); |
1761 | | } |
1762 | 1815 | else if (!(offset & 0x8)) |
1763 | 1816 | { |
1764 | 1817 | if (m_cart_disabled) |
1765 | | { |
1766 | 1818 | m_cart_disabled = 0; |
1767 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)m_cart)); |
1768 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
1769 | | } |
1770 | 1819 | |
1771 | 1820 | if ((offset & 0x7) != m_last_offs) |
1772 | 1821 | { |
r32749 | r32750 | |
1779 | 1828 | case A800_TURBO64: |
1780 | 1829 | case A800_TURBO128: |
1781 | 1830 | if (offset & 0x10 && !m_cart_disabled) |
1782 | | { |
1783 | 1831 | m_cart_disabled = 1; |
1784 | | setup_ram(2, m_ram->size()); |
1785 | | } |
1786 | 1832 | else if (!(offset & 0x10)) |
1787 | 1833 | { |
1788 | 1834 | if (m_cart_disabled) |
1789 | | { |
1790 | 1835 | m_cart_disabled = 0; |
1791 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)m_cart)); |
1792 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
1793 | | } |
1794 | 1836 | |
1795 | 1837 | if ((offset & 0x0f) != m_last_offs) |
1796 | 1838 | { |
r32749 | r32750 | |
1807 | 1849 | case A800_OSSM091: |
1808 | 1850 | case A800_OSS8K: |
1809 | 1851 | if ((offset & 0x9) == 0x08) |
1810 | | setup_ram(2, m_ram->size()); |
| 1852 | m_cart_disabled = 1; |
1811 | 1853 | else |
1812 | 1854 | { |
1813 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)m_cart)); |
1814 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1855 | m_cart_disabled = 0; |
1815 | 1856 | m_cart->write_d5xx(space, offset, data); |
1816 | 1857 | } |
1817 | 1858 | break; |
1818 | 1859 | case A800_MICROCALC: |
1819 | | m_cart_disabled = (m_cart_disabled + 1) % 5; |
1820 | | if (m_cart_disabled == 4) |
1821 | | setup_ram(2, m_ram->size()); |
| 1860 | m_cart_helper = (m_cart_helper + 1) % 5; |
| 1861 | if (m_cart_helper == 4) |
| 1862 | m_cart_disabled = 1; |
1822 | 1863 | else |
1823 | 1864 | { |
1824 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)m_cart)); |
1825 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
1826 | | m_cart->write_d5xx(space, offset, m_cart_disabled); |
| 1865 | m_cart_disabled = 0; |
| 1866 | m_cart->write_d5xx(space, offset, m_cart_helper); |
1827 | 1867 | } |
1828 | 1868 | break; |
1829 | 1869 | default: |
r32749 | r32750 | |
1853 | 1893 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x8000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1854 | 1894 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
1855 | 1895 | break; |
1856 | | case A800_PHOENIX: |
1857 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1858 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
1859 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1860 | | break; |
1861 | 1896 | case A800_BBSB: |
1862 | 1897 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x8000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1863 | 1898 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x8000, 0x9fff, write8_delegate(FUNC(a800_cart_slot_device::write_80xx),(a800_cart_slot_device*)slot)); |
r32749 | r32750 | |
1869 | 1904 | case A800_OSS8K: |
1870 | 1905 | case A800_TURBO64: |
1871 | 1906 | case A800_TURBO128: |
1872 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1873 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1907 | case A800_PHOENIX: |
| 1908 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
1874 | 1909 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1875 | 1910 | break; |
1876 | | case A800_MICROCALC: |
1877 | | // this can also disable ROM when reading in 0xd500-0xd5ff |
1878 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1879 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
1880 | | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xd500, 0xd5ff, read8_delegate(FUNC(a400_state::read_d5xx), this), write8_delegate(FUNC(a400_state::disable_cart), this)); |
1881 | | break; |
1882 | 1911 | case A800_EXPRESS: |
1883 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1884 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1912 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
1885 | 1913 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd570, 0xd57f, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1886 | 1914 | break; |
1887 | 1915 | case A800_DIAMOND: |
1888 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1889 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1916 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
1890 | 1917 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd5d0, 0xd5df, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1891 | 1918 | break; |
1892 | 1919 | case A800_WILLIAMS: |
1893 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1894 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1920 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
1895 | 1921 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd50f, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1896 | 1922 | break; |
1897 | 1923 | case A800_SPARTADOS: |
1898 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1899 | | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1924 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
1900 | 1925 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd5e0, 0xd5ef, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1901 | 1926 | break; |
| 1927 | case A800_BLIZZARD: |
| 1928 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x8000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_8000), this), write8_delegate(FUNC(a400_state::special_write_8000), this)); |
| 1929 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::disable_cart), this)); |
| 1930 | break; |
| 1931 | case A800_MICROCALC: |
| 1932 | // this can also disable ROM when reading in 0xd500-0xd5ff |
| 1933 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa000, 0xbfff, read8_delegate(FUNC(a400_state::special_read_a000), this), write8_delegate(FUNC(a400_state::special_write_a000), this)); |
| 1934 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xd500, 0xd5ff, read8_delegate(FUNC(a400_state::read_d5xx), this), write8_delegate(FUNC(a400_state::disable_cart), this)); |
| 1935 | break; |
1902 | 1936 | case A800_TELELINK2: |
1903 | 1937 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x8000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1904 | 1938 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x9000, 0x90ff, write8_delegate(FUNC(a800_cart_slot_device::write_80xx),(a800_cart_slot_device*)slot)); |
r32749 | r32750 | |
1906 | 1940 | m_maincpu->space(AS_PROGRAM).install_read_handler(0xd501, 0xd501, read8_delegate(FUNC(a800_cart_slot_device::read_d5xx),(a800_cart_slot_device*)slot)); |
1907 | 1941 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd502, 0xd502, write8_delegate(FUNC(a800_cart_slot_device::write_d5xx),(a800_cart_slot_device*)slot)); |
1908 | 1942 | break; |
1909 | | case A800_BLIZZARD: |
1910 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x8000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1911 | | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
1912 | | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::disable_cart), this)); |
1913 | | break; |
1914 | 1943 | case A800_XEGS: |
1915 | 1944 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x8000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot)); |
1916 | 1945 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
r32749 | r32750 | |
1964 | 1993 | setup_cart(m_cart); |
1965 | 1994 | |
1966 | 1995 | save_item(NAME(m_cart_disabled)); |
| 1996 | save_item(NAME(m_cart_helper)); |
1967 | 1997 | save_item(NAME(m_last_offs)); |
1968 | 1998 | } |
1969 | 1999 | |
r32749 | r32750 | |
1977 | 2007 | setup_cart(m_cart2); |
1978 | 2008 | |
1979 | 2009 | save_item(NAME(m_cart_disabled)); |
| 2010 | save_item(NAME(m_cart_helper)); |
1980 | 2011 | save_item(NAME(m_last_offs)); |
1981 | 2012 | } |
1982 | 2013 | |
r32749 | r32750 | |
1987 | 2018 | setup_cart(m_cart); |
1988 | 2019 | |
1989 | 2020 | save_item(NAME(m_cart_disabled)); |
| 2021 | save_item(NAME(m_cart_helper)); |
1990 | 2022 | save_item(NAME(m_last_offs)); |
1991 | 2023 | save_item(NAME(m_mmu)); |
1992 | 2024 | save_item(NAME(m_ext_bank)); |
r32749 | r32750 | |
1998 | 2030 | setup_cart(m_cart); |
1999 | 2031 | |
2000 | 2032 | save_item(NAME(m_cart_disabled)); |
| 2033 | save_item(NAME(m_cart_helper)); |
2001 | 2034 | save_item(NAME(m_last_offs)); |
2002 | 2035 | } |
2003 | 2036 | |