src/mess/machine/c64_ide64.c
| r15016 | r15017 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | | - kill port |
| 15 | | - DS1302 |
| 14 | - flash write |
| 16 | 15 | - FT245 |
| 17 | 16 | |
| 18 | 17 | */ |
| r15016 | r15017 | |
| 98 | 97 | device_t(mconfig, C64_IDE64, "C64 IDE64 cartridge", tag, owner, clock), |
| 99 | 98 | device_c64_expansion_card_interface(mconfig, *this), |
| 100 | 99 | m_flash_rom(*this, AT29C010A_TAG), |
| 100 | m_rtc(*this, DS1302_TAG), |
| 101 | 101 | m_ide(*this, "ide") |
| 102 | 102 | { |
| 103 | 103 | } |
| r15016 | r15017 | |
| 115 | 115 | // state saving |
| 116 | 116 | save_item(NAME(m_bank)); |
| 117 | 117 | save_item(NAME(m_ide_data)); |
| 118 | save_item(NAME(m_enable)); |
| 119 | save_item(NAME(m_rtc_ce)); |
| 118 | 120 | } |
| 119 | 121 | |
| 120 | 122 | |
| r15016 | r15017 | |
| 127 | 129 | m_bank = 0; |
| 128 | 130 | m_game = 1; |
| 129 | 131 | m_exrom = 1; |
| 132 | m_enable = 1; |
| 133 | m_rtc_ce = 0; |
| 130 | 134 | |
| 131 | 135 | m_wp = input_port_read(*this, "JP1"); |
| 132 | 136 | } |
| r15016 | r15017 | |
| 138 | 142 | |
| 139 | 143 | UINT8 c64_ide64_cartridge_device::c64_cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2) |
| 140 | 144 | { |
| 145 | if (!m_enable) return 0; |
| 146 | |
| 141 | 147 | UINT8 data = 0; |
| 142 | 148 | int rom_oe = 1, ram_oe = 1; |
| 143 | 149 | |
| r15016 | r15017 | |
| 186 | 192 | { |
| 187 | 193 | data = m_ide_data >> 8; |
| 188 | 194 | } |
| 195 | else if (io1_offset == 0x32) |
| 196 | { |
| 197 | /* |
| 198 | |
| 199 | bit description |
| 200 | |
| 201 | 0 GAME |
| 202 | 1 EXROM |
| 203 | 2 A14 |
| 204 | 3 A15 |
| 205 | 4 A16 |
| 206 | 5 v4.x |
| 207 | 6 |
| 208 | 7 |
| 209 | |
| 210 | */ |
| 211 | |
| 212 | data = 0x20 | (m_bank << 2) | (m_exrom << 1) | m_game; |
| 213 | } |
| 214 | else if ((io1_offset == 0x5f) && m_rtc_ce) |
| 215 | { |
| 216 | m_rtc->ds1302_clk_w(0, 0); |
| 217 | |
| 218 | m_rtc->ds1302_dat_w(0, BIT(data, 0)); |
| 219 | |
| 220 | m_rtc->ds1302_clk_w(0, 1); |
| 221 | } |
| 189 | 222 | else if (io1_offset >= 0x60) |
| 190 | 223 | { |
| 191 | 224 | rom_oe = 0; |
| r15016 | r15017 | |
| 213 | 246 | |
| 214 | 247 | void c64_ide64_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2) |
| 215 | 248 | { |
| 249 | if (!m_enable) return; |
| 250 | |
| 216 | 251 | if (!m_game && m_exrom) |
| 217 | 252 | { |
| 218 | 253 | if (offset >= 0x1000 && offset < 0x8000) |
| r15016 | r15017 | |
| 251 | 286 | { |
| 252 | 287 | m_ide_data = (data << 8) | (m_ide_data & 0xff); |
| 253 | 288 | } |
| 254 | | else if (io1_offset >= 0x32 && io1_offset < 0x36) |
| 289 | else if ((io1_offset == 0x5f) && m_rtc_ce) |
| 255 | 290 | { |
| 256 | | m_bank = io1_offset - 0x32; |
| 291 | m_rtc->ds1302_clk_w(0, 0); |
| 292 | |
| 293 | data = m_rtc->ds1302_read(0); |
| 294 | |
| 295 | m_rtc->ds1302_clk_w(0, 1); |
| 257 | 296 | } |
| 258 | 297 | else if (io1_offset >= 0x60 && io1_offset < 0x68) |
| 259 | 298 | { |
| 260 | 299 | m_bank = offset & 0x07; |
| 261 | 300 | } |
| 301 | else if (io1_offset >= 0xfb) |
| 302 | { |
| 303 | /* |
| 304 | |
| 305 | bit description |
| 306 | |
| 307 | 0 disable cartridge |
| 308 | 1 RTC CE |
| 309 | 2 |
| 310 | 3 |
| 311 | 4 |
| 312 | 5 |
| 313 | 6 |
| 314 | 7 |
| 315 | |
| 316 | */ |
| 317 | |
| 318 | m_enable = !BIT(data, 0); |
| 319 | m_rtc_ce = BIT(data, 1); |
| 320 | |
| 321 | m_game = BIT(offset, 0); |
| 322 | m_exrom = BIT(offset, 1); |
| 323 | } |
| 262 | 324 | else if (io1_offset >= 0xfc) |
| 263 | 325 | { |
| 264 | 326 | m_game = BIT(offset, 0); |