src/mess/drivers/a2600.c
| r14955 | r14956 | |
| 66 | 66 | unsigned m_FVlocked; |
| 67 | 67 | UINT16 m_current_screen_height; |
| 68 | 68 | int m_FETimer; |
| 69 | |
| 70 | direct_update_delegate m_FE_old_opbase_handler; |
| 71 | |
| 72 | DECLARE_DIRECT_UPDATE_MEMBER(modeF6_opbase); |
| 73 | DECLARE_DIRECT_UPDATE_MEMBER(modeSS_opbase); |
| 74 | DECLARE_DIRECT_UPDATE_MEMBER(modeDPC_opbase_handler); |
| 75 | DECLARE_DIRECT_UPDATE_MEMBER(modeFE_opbase_handler); |
| 69 | 76 | }; |
| 70 | 77 | |
| 71 | 78 | |
| r14955 | r14956 | |
| 741 | 748 | } |
| 742 | 749 | |
| 743 | 750 | |
| 744 | | DIRECT_UPDATE_HANDLER( modeF6_opbase ) |
| 751 | DIRECT_UPDATE_MEMBER(a2600_state::modeF6_opbase) |
| 745 | 752 | { |
| 746 | 753 | if ( ( address & 0x1FFF ) >= 0x1FF6 && ( address & 0x1FFF ) <= 0x1FF9 ) |
| 747 | 754 | { |
| 748 | | modeF6_switch_w( machine.device("maincpu")->memory().space(AS_PROGRAM), ( address & 0x1FFF ) - 0x1FF6, 0 ); |
| 755 | modeF6_switch_w( machine().device("maincpu")->memory().space(AS_PROGRAM), ( address & 0x1FFF ) - 0x1FF6, 0 ); |
| 749 | 756 | } |
| 750 | 757 | return address; |
| 751 | 758 | } |
| 752 | 759 | |
| 753 | | DIRECT_UPDATE_HANDLER( modeSS_opbase ) |
| 760 | DIRECT_UPDATE_MEMBER(a2600_state::modeSS_opbase) |
| 754 | 761 | { |
| 755 | | a2600_state *state = machine.driver_data<a2600_state>(); |
| 756 | 762 | if ( address & 0x1000 ) |
| 757 | 763 | { |
| 758 | 764 | if ( address & 0x800 ) |
| 759 | 765 | { |
| 760 | | direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, state->m_bank_base[2]); |
| 766 | direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, m_bank_base[2]); |
| 761 | 767 | } |
| 762 | 768 | else |
| 763 | 769 | { |
| 764 | | direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, state->m_bank_base[1]); |
| 770 | direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, m_bank_base[1]); |
| 765 | 771 | } |
| 766 | 772 | return ~0; |
| 767 | 773 | } |
| r14955 | r14956 | |
| 936 | 942 | } |
| 937 | 943 | } |
| 938 | 944 | |
| 939 | | DIRECT_UPDATE_HANDLER(modeDPC_opbase_handler) |
| 945 | DIRECT_UPDATE_MEMBER(a2600_state::modeDPC_opbase_handler) |
| 940 | 946 | { |
| 941 | | a2600_state *state = machine.driver_data<a2600_state>(); |
| 942 | 947 | UINT8 new_bit; |
| 943 | | new_bit = ( state->m_dpc.shift_reg & 0x80 ) ^ ( ( state->m_dpc.shift_reg & 0x20 ) << 2 ); |
| 944 | | new_bit = new_bit ^ ( ( ( state->m_dpc.shift_reg & 0x10 ) << 3 ) ^ ( ( state->m_dpc.shift_reg & 0x08 ) << 4 ) ); |
| 948 | new_bit = ( m_dpc.shift_reg & 0x80 ) ^ ( ( m_dpc.shift_reg & 0x20 ) << 2 ); |
| 949 | new_bit = new_bit ^ ( ( ( m_dpc.shift_reg & 0x10 ) << 3 ) ^ ( ( m_dpc.shift_reg & 0x08 ) << 4 ) ); |
| 945 | 950 | new_bit = new_bit ^ 0x80; |
| 946 | | state->m_dpc.shift_reg = new_bit | ( state->m_dpc.shift_reg >> 1 ); |
| 951 | m_dpc.shift_reg = new_bit | ( m_dpc.shift_reg >> 1 ); |
| 947 | 952 | return address; |
| 948 | 953 | } |
| 949 | 954 | |
| r14955 | r14956 | |
| 1085 | 1090 | |
| 1086 | 1091 | */ |
| 1087 | 1092 | |
| 1088 | | direct_update_delegate FE_old_opbase_handler; |
| 1089 | 1093 | |
| 1090 | | DIRECT_UPDATE_HANDLER(modeFE_opbase_handler) |
| 1094 | DIRECT_UPDATE_MEMBER(a2600_state::modeFE_opbase_handler) |
| 1091 | 1095 | { |
| 1092 | | a2600_state *state = machine.driver_data<a2600_state>(); |
| 1093 | | if ( ! state->m_FETimer ) |
| 1096 | if ( ! m_FETimer ) |
| 1094 | 1097 | { |
| 1095 | 1098 | /* Still cheating a bit here by looking bit 13 of the address..., but the high byte of the |
| 1096 | 1099 | cpu should be the last byte that was on the data bus and so should determine the bank |
| 1097 | 1100 | we should switch in. */ |
| 1098 | | state->m_bank_base[1] = machine.region("user1")->base() + 0x1000 * ( ( address & 0x2000 ) ? 0 : 1 ); |
| 1099 | | memory_set_bankptr(machine, "bank1", state->m_bank_base[1] ); |
| 1101 | m_bank_base[1] = machine().region("user1")->base() + 0x1000 * ( ( address & 0x2000 ) ? 0 : 1 ); |
| 1102 | memory_set_bankptr(machine(), "bank1", m_bank_base[1] ); |
| 1100 | 1103 | /* and restore old opbase handler */ |
| 1101 | | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(FE_old_opbase_handler); |
| 1104 | machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(m_FE_old_opbase_handler); |
| 1102 | 1105 | } |
| 1103 | 1106 | else |
| 1104 | 1107 | { |
| 1105 | 1108 | /* Wait for one memory access to have passed (reading of new PCH either from code or from stack) */ |
| 1106 | | state->m_FETimer--; |
| 1109 | m_FETimer--; |
| 1107 | 1110 | } |
| 1108 | 1111 | return address; |
| 1109 | 1112 | } |
| r14955 | r14956 | |
| 1116 | 1119 | should be the last byte that was on the data bus |
| 1117 | 1120 | */ |
| 1118 | 1121 | state->m_FETimer = 1; |
| 1119 | | FE_old_opbase_handler = space->set_direct_update_handler(direct_update_delegate(FUNC(modeFE_opbase_handler), &machine)); |
| 1122 | state->m_FE_old_opbase_handler = space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeFE_opbase_handler), state)); |
| 1120 | 1123 | } |
| 1121 | 1124 | |
| 1122 | 1125 | static READ8_HANDLER(modeFE_switch_r) |
| r14955 | r14956 | |
| 1907 | 1910 | case modeF6: |
| 1908 | 1911 | space->install_legacy_write_handler(0x1ff6, 0x1ff9, FUNC(modeF6_switch_w)); |
| 1909 | 1912 | space->install_legacy_read_handler(0x1ff6, 0x1ff9, FUNC(modeF6_switch_r)); |
| 1910 | | space->set_direct_update_handler(direct_update_delegate(FUNC(modeF6_opbase), &machine)); |
| 1913 | space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeF6_opbase), state)); |
| 1911 | 1914 | break; |
| 1912 | 1915 | |
| 1913 | 1916 | case modeF4: |
| r14955 | r14956 | |
| 1962 | 1965 | memory_set_bankptr(machine, "bank2", state->m_bank_base[2] ); |
| 1963 | 1966 | state->m_modeSS_write_enabled = 0; |
| 1964 | 1967 | state->m_modeSS_byte_started = 0; |
| 1965 | | space->set_direct_update_handler(direct_update_delegate(FUNC(modeSS_opbase), &machine)); |
| 1968 | space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeSS_opbase), state)); |
| 1966 | 1969 | /* The Supercharger has no motor control so just enable it */ |
| 1967 | 1970 | machine.device<cassette_image_device>(CASSETTE_TAG)->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MOTOR_DISABLED ); |
| 1968 | 1971 | break; |
| r14955 | r14956 | |
| 1977 | 1980 | space->install_legacy_write_handler(0x1040, 0x107f, FUNC(modeDPC_w)); |
| 1978 | 1981 | space->install_legacy_write_handler(0x1ff8, 0x1ff9, FUNC(modeF8_switch_w)); |
| 1979 | 1982 | space->install_legacy_read_handler(0x1ff8, 0x1ff9, FUNC(modeF8_switch_r)); |
| 1980 | | space->set_direct_update_handler(direct_update_delegate(FUNC(modeDPC_opbase_handler), &machine)); |
| 1983 | space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeDPC_opbase_handler), state)); |
| 1981 | 1984 | { |
| 1982 | 1985 | int data_fetcher; |
| 1983 | 1986 | for( data_fetcher = 0; data_fetcher < 8; data_fetcher++ ) |