trunk/src/mess/drivers/a2600.c
r18250 | r18251 | |
136 | 136 | void mode3E_RAM_switch(UINT16 offset, UINT8 data); |
137 | 137 | void modeFV_switch(UINT16 offset, UINT8 data); |
138 | 138 | void modeJVP_switch(UINT16 offset, UINT8 data); |
| 139 | void modeFE_switch(UINT16 offset, UINT8 data); |
| 140 | void install_banks(int count, unsigned init); |
139 | 141 | |
140 | 142 | UINT8 *m_cart; |
141 | 143 | }; |
r18250 | r18251 | |
1160 | 1162 | return address; |
1161 | 1163 | } |
1162 | 1164 | |
1163 | | static void modeFE_switch(running_machine &machine,UINT16 offset, UINT8 data) |
| 1165 | void a2600_state::modeFE_switch(UINT16 offset, UINT8 data) |
1164 | 1166 | { |
1165 | | a2600_state *state = machine.driver_data<a2600_state>(); |
1166 | | address_space& space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 1167 | address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
1167 | 1168 | /* Retrieve last byte read by the cpu (for this mapping scheme this |
1168 | 1169 | should be the last byte that was on the data bus |
1169 | 1170 | */ |
1170 | | state->m_FETimer = 1; |
1171 | | state->m_FE_old_opbase_handler = space.set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeFE_opbase_handler), state)); |
| 1171 | m_FETimer = 1; |
| 1172 | m_FE_old_opbase_handler = space.set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeFE_opbase_handler), this)); |
1172 | 1173 | } |
1173 | 1174 | |
1174 | 1175 | READ8_MEMBER(a2600_state::modeFE_switch_r) |
1175 | 1176 | { |
1176 | | modeFE_switch(machine(),offset, 0 ); |
| 1177 | modeFE_switch(offset, 0 ); |
1177 | 1178 | return space.read_byte(0xFE ); |
1178 | 1179 | } |
1179 | 1180 | |
1180 | 1181 | WRITE8_MEMBER(a2600_state::modeFE_switch_w) |
1181 | 1182 | { |
1182 | 1183 | space.write_byte(0xFE, data ); |
1183 | | modeFE_switch(machine(),offset, 0 ); |
| 1184 | modeFE_switch(offset, 0 ); |
1184 | 1185 | } |
1185 | 1186 | |
1186 | 1187 | READ8_MEMBER(a2600_state::current_bank_r) |
r18250 | r18251 | |
1291 | 1292 | }; |
1292 | 1293 | |
1293 | 1294 | |
1294 | | static void install_banks(running_machine &machine, int count, unsigned init) |
| 1295 | void a2600_state::install_banks(int count, unsigned init) |
1295 | 1296 | { |
1296 | | a2600_state *state = machine.driver_data<a2600_state>(); |
1297 | 1297 | int i; |
1298 | | UINT8 *cart = CART; |
1299 | 1298 | |
1300 | 1299 | for (i = 0; i < count; i++) |
1301 | 1300 | { |
r18250 | r18251 | |
1307 | 1306 | "bank4", |
1308 | 1307 | }; |
1309 | 1308 | |
1310 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank( |
| 1309 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank( |
1311 | 1310 | 0x1000 + (i + 0) * 0x1000 / count - 0, |
1312 | 1311 | 0x1000 + (i + 1) * 0x1000 / count - 1, handler[i]); |
1313 | 1312 | |
1314 | | state->m_bank_base[i + 1] = cart + init; |
1315 | | state->membank(handler[i])->set_base(state->m_bank_base[i + 1]); |
| 1313 | m_bank_base[i + 1] = m_cart + init; |
| 1314 | membank(handler[i])->set_base(m_bank_base[i + 1]); |
1316 | 1315 | } |
1317 | 1316 | } |
1318 | 1317 | |
r18250 | r18251 | |
1824 | 1823 | switch (m_banking_mode) |
1825 | 1824 | { |
1826 | 1825 | case mode2K: |
1827 | | install_banks(machine(), 2, 0x0000); |
| 1826 | install_banks(2, 0x0000); |
1828 | 1827 | break; |
1829 | 1828 | |
1830 | 1829 | case mode4K: |
1831 | | install_banks(machine(), 1, 0x0000); |
| 1830 | install_banks(1, 0x0000); |
1832 | 1831 | break; |
1833 | 1832 | |
1834 | 1833 | case modeF8: |
1835 | 1834 | if (!memcmp(&CART_MEMBER[0x1ffc],snowwhite,sizeof(snowwhite))) |
1836 | 1835 | { |
1837 | | install_banks(machine(), 1, 0x0000); |
| 1836 | install_banks(1, 0x0000); |
1838 | 1837 | } |
1839 | 1838 | else |
1840 | 1839 | { |
1841 | | install_banks(machine(), 1, 0x1000); |
| 1840 | install_banks(1, 0x1000); |
1842 | 1841 | } |
1843 | 1842 | break; |
1844 | 1843 | |
1845 | 1844 | case modeFA: |
1846 | | install_banks(machine(), 1, 0x2000); |
| 1845 | install_banks(1, 0x2000); |
1847 | 1846 | break; |
1848 | 1847 | |
1849 | 1848 | case modeF6: |
1850 | | install_banks(machine(), 1, 0x0000); |
| 1849 | install_banks(1, 0x0000); |
1851 | 1850 | break; |
1852 | 1851 | |
1853 | 1852 | case modeF4: |
1854 | | install_banks(machine(), 1, 0x7000); |
| 1853 | install_banks(1, 0x7000); |
1855 | 1854 | break; |
1856 | 1855 | |
1857 | 1856 | case modeFE: |
1858 | | install_banks(machine(), 1, 0x0000); |
| 1857 | install_banks(1, 0x0000); |
1859 | 1858 | break; |
1860 | 1859 | |
1861 | 1860 | case modeE0: |
1862 | | install_banks(machine(), 4, 0x1c00); |
| 1861 | install_banks(4, 0x1c00); |
1863 | 1862 | break; |
1864 | 1863 | |
1865 | 1864 | case mode3F: |
1866 | | install_banks(machine(), 2, m_cart_size - 0x800); |
| 1865 | install_banks(2, m_cart_size - 0x800); |
1867 | 1866 | m_number_banks = m_cart_size / 0x800; |
1868 | 1867 | break; |
1869 | 1868 | |
1870 | 1869 | case modeUA: |
1871 | | install_banks(machine(), 1, 0x1000); |
| 1870 | install_banks(1, 0x1000); |
1872 | 1871 | break; |
1873 | 1872 | |
1874 | 1873 | case modeE7: |
1875 | | install_banks(machine(), 2, 0x3800); |
| 1874 | install_banks(2, 0x3800); |
1876 | 1875 | break; |
1877 | 1876 | |
1878 | 1877 | case modeDC: |
1879 | | install_banks(machine(), 1, 0x1000 * m_current_bank); |
| 1878 | install_banks(1, 0x1000 * m_current_bank); |
1880 | 1879 | break; |
1881 | 1880 | |
1882 | 1881 | case modeCV: |
1883 | | install_banks(machine(), 2, 0x0000); |
| 1882 | install_banks(2, 0x0000); |
1884 | 1883 | break; |
1885 | 1884 | |
1886 | 1885 | case mode3E: |
1887 | | install_banks(machine(), 2, m_cart_size - 0x800); |
| 1886 | install_banks(2, m_cart_size - 0x800); |
1888 | 1887 | m_number_banks = m_cart_size / 0x800; |
1889 | 1888 | m_mode3E_ram_enabled = 0; |
1890 | 1889 | break; |
1891 | 1890 | |
1892 | 1891 | case modeSS: |
1893 | | install_banks(machine(), 2, 0x0000); |
| 1892 | install_banks(2, 0x0000); |
1894 | 1893 | break; |
1895 | 1894 | |
1896 | 1895 | case modeFV: |
1897 | | install_banks(machine(), 1, 0x0000); |
| 1896 | install_banks(1, 0x0000); |
1898 | 1897 | m_current_bank = 0; |
1899 | 1898 | break; |
1900 | 1899 | |
1901 | 1900 | case modeDPC: |
1902 | | install_banks(machine(), 1, 0x0000); |
| 1901 | install_banks(1, 0x0000); |
1903 | 1902 | break; |
1904 | 1903 | |
1905 | 1904 | case mode32in1: |
1906 | | install_banks(machine(), 2, 0x0000); |
| 1905 | install_banks(2, 0x0000); |
1907 | 1906 | m_current_reset_bank_counter = m_current_reset_bank_counter & 0x1F; |
1908 | 1907 | break; |
1909 | 1908 | |
r18250 | r18251 | |
1912 | 1911 | if ( m_cart_size == 0x2000 ) |
1913 | 1912 | m_current_reset_bank_counter = 0; |
1914 | 1913 | m_current_bank = m_current_reset_bank_counter * 2; |
1915 | | install_banks(machine(), 1, 0x1000 * m_current_bank); |
| 1914 | install_banks(1, 0x1000 * m_current_bank); |
1916 | 1915 | break; |
1917 | 1916 | } |
1918 | 1917 | |