src/mess/machine/c64_cpm.c
| r14814 | r14815 | |
| 2 | 2 | |
| 3 | 3 | Commodore 64 CP/M cartridge emulation |
| 4 | 4 | |
| 5 | http://www.baltissen.org/newhtm/c64_cpm.htm |
| 6 | |
| 5 | 7 | Copyright MESS Team. |
| 6 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | 9 | |
| r14814 | r14815 | |
| 68 | 70 | |
| 69 | 71 | |
| 70 | 72 | //************************************************************************** |
| 73 | // INLINE HELPERS |
| 74 | //************************************************************************** |
| 75 | |
| 76 | //------------------------------------------------- |
| 77 | // update_signals - |
| 78 | //------------------------------------------------- |
| 79 | |
| 80 | inline void c64_cpm_cartridge_device::update_signals() |
| 81 | { |
| 82 | // NOTE: none of this works until the Z80 core has been rewritten |
| 83 | |
| 84 | // C64 DMA |
| 85 | m_slot->dma_w(m_enabled ? ASSERT_LINE : CLEAR_LINE); |
| 86 | |
| 87 | // Z80 BUSRQ |
| 88 | int busrq = !(m_enabled & !m_ba) ? CLEAR_LINE : ASSERT_LINE; |
| 89 | m_maincpu->set_input_line(Z80_INPUT_LINE_BUSRQ, busrq); |
| 90 | |
| 91 | // Z80 WAIT |
| 92 | m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, m_enabled ? CLEAR_LINE : ASSERT_LINE); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |
| 97 | //************************************************************************** |
| 71 | 98 | // LIVE DEVICE |
| 72 | 99 | //************************************************************************** |
| 73 | 100 | |
| r14814 | r14815 | |
| 78 | 105 | c64_cpm_cartridge_device::c64_cpm_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 79 | 106 | device_t(mconfig, C64_CPM, "C64 CP/M cartridge", tag, owner, clock), |
| 80 | 107 | device_c64_expansion_card_interface(mconfig, *this), |
| 81 | | m_maincpu(*this, Z80_TAG) |
| 108 | m_maincpu(*this, Z80_TAG), |
| 109 | m_enabled(0), |
| 110 | m_ba(1) |
| 82 | 111 | { |
| 83 | 112 | } |
| 84 | 113 | |
| r14814 | r14815 | |
| 89 | 118 | |
| 90 | 119 | void c64_cpm_cartridge_device::device_start() |
| 91 | 120 | { |
| 92 | | // TODO stop the Z80 here before it gets any ideas |
| 121 | // state saving |
| 122 | save_item(NAME(m_enabled)); |
| 123 | save_item(NAME(m_ba)); |
| 93 | 124 | } |
| 94 | 125 | |
| 95 | 126 | |
| r14814 | r14815 | |
| 99 | 130 | |
| 100 | 131 | void c64_cpm_cartridge_device::device_reset() |
| 101 | 132 | { |
| 102 | | m_slot->dma_w(CLEAR_LINE); |
| 103 | | m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); |
| 133 | m_enabled = 0; |
| 134 | |
| 135 | update_signals(); |
| 104 | 136 | } |
| 105 | 137 | |
| 106 | 138 | |
| r14814 | r14815 | |
| 112 | 144 | { |
| 113 | 145 | if (!io1) |
| 114 | 146 | { |
| 115 | | // HACK |
| 116 | | m_slot->dma_w(BIT(data, 0) ? ASSERT_LINE : CLEAR_LINE); |
| 117 | | m_maincpu->set_input_line(INPUT_LINE_HALT, BIT(data, 0) ? CLEAR_LINE : ASSERT_LINE); |
| 147 | m_enabled = !BIT(data, 0); |
| 148 | |
| 149 | update_signals(); |
| 118 | 150 | } |
| 119 | 151 | } |
| 120 | 152 | |
| 121 | 153 | |
| 122 | 154 | //------------------------------------------------- |
| 155 | // c64_game_r - GAME read |
| 156 | //------------------------------------------------- |
| 157 | |
| 158 | int c64_cpm_cartridge_device::c64_game_r(offs_t offset, int ba, int rw, int hiram) |
| 159 | { |
| 160 | if (m_ba != ba) |
| 161 | { |
| 162 | m_ba = ba; |
| 163 | |
| 164 | update_signals(); |
| 165 | } |
| 166 | |
| 167 | return 1; |
| 168 | } |
| 169 | |
| 170 | |
| 171 | //------------------------------------------------- |
| 123 | 172 | // dma_r - |
| 124 | 173 | //------------------------------------------------- |
| 125 | 174 | |
| 126 | 175 | READ8_MEMBER( c64_cpm_cartridge_device::dma_r ) |
| 127 | 176 | { |
| 128 | | return m_slot->dma_cd_r(offset | 0x1000); |
| 177 | UINT8 data = 0xff; |
| 178 | |
| 179 | if (m_enabled) |
| 180 | { |
| 181 | offs_t addr = (offset + 0x1000) & 0xffff; |
| 182 | |
| 183 | data = m_slot->dma_cd_r(addr); |
| 184 | } |
| 185 | |
| 186 | return data; |
| 129 | 187 | } |
| 130 | 188 | |
| 131 | 189 | |
| r14814 | r14815 | |
| 135 | 193 | |
| 136 | 194 | WRITE8_MEMBER( c64_cpm_cartridge_device::dma_w ) |
| 137 | 195 | { |
| 138 | | m_slot->dma_cd_w(offset | 0x1000, data); |
| 196 | if (m_enabled) |
| 197 | { |
| 198 | offs_t addr = (offset + 0x1000) & 0xffff; |
| 199 | |
| 200 | m_slot->dma_cd_w(addr, data); |
| 201 | } |
| 139 | 202 | } |