trunk/src/mess/drivers/snes.c
| r21690 | r21691 | |
| 55 | 55 | DECLARE_READ8_MEMBER( snes_hi_r ); |
| 56 | 56 | DECLARE_WRITE8_MEMBER( snes_lo_w ); |
| 57 | 57 | DECLARE_WRITE8_MEMBER( snes_hi_w ); |
| 58 | DECLARE_READ8_MEMBER( sfx_r ); |
| 59 | DECLARE_WRITE8_MEMBER( sfx_w ); |
| 58 | 60 | DECLARE_READ8_MEMBER( superfx_r_bank1 ); |
| 59 | 61 | DECLARE_READ8_MEMBER( superfx_r_bank2 ); |
| 60 | 62 | DECLARE_READ8_MEMBER( superfx_r_bank3 ); |
| r21690 | r21691 | |
| 137 | 139 | } |
| 138 | 140 | |
| 139 | 141 | |
| 142 | READ8_MEMBER( snes_console_state::sfx_r ) |
| 143 | { |
| 144 | UINT16 address = offset & 0xffff; |
| 145 | if (offset < 0x400000) |
| 146 | { |
| 147 | if (address < 0x2000) |
| 148 | return space.read_byte(0x7e0000 + address); |
| 149 | else if (address < 0x6000) |
| 150 | { |
| 151 | if (address >= 0x3000 && address < 0x3300) |
| 152 | return superfx_mmio_read(m_superfx, address); |
| 153 | else |
| 154 | return snes_r_io(space, address); |
| 155 | } |
| 156 | else if (address < 0x8000) |
| 157 | return superfx_access_ram(m_superfx) ? m_sfx_ram[offset & 0x1fff] : snes_open_bus_r(space, 0); |
| 158 | else |
| 159 | return snes_ram[offset]; |
| 160 | } |
| 161 | else if (offset < 0x600000) |
| 162 | { |
| 163 | if (superfx_access_rom(m_superfx)) |
| 164 | return snes_ram[offset]; |
| 165 | else |
| 166 | { |
| 167 | static const UINT8 sfx_data[16] = { |
| 168 | 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, |
| 169 | 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01, |
| 170 | }; |
| 171 | return sfx_data[offset & 0x0f]; |
| 172 | } |
| 173 | } |
| 174 | else |
| 175 | return superfx_access_ram(m_superfx) ? m_sfx_ram[offset & 0xfffff] : snes_open_bus_r(space, 0); |
| 176 | } |
| 177 | |
| 178 | WRITE8_MEMBER( snes_console_state::sfx_w ) |
| 179 | { |
| 180 | UINT16 address = offset & 0xffff; |
| 181 | if (offset < 0x400000) |
| 182 | { |
| 183 | if (address < 0x2000) |
| 184 | space.write_byte(0x7e0000 + address, data); |
| 185 | else if (address < 0x6000) |
| 186 | { |
| 187 | if (address >= 0x3000 && address < 0x3300) |
| 188 | superfx_mmio_write(m_superfx, address, data); |
| 189 | else |
| 190 | snes_w_io(space, address, data); |
| 191 | } |
| 192 | else if (address < 0x8000) |
| 193 | m_sfx_ram[offset & 0x1fff] = data; |
| 194 | } |
| 195 | else if (offset >= 0x600000) |
| 196 | m_sfx_ram[offset & 0xfffff] = data; |
| 197 | } |
| 198 | |
| 140 | 199 | READ8_MEMBER( snes_console_state::snes_lo_r ) |
| 141 | 200 | { |
| 142 | 201 | UINT16 address = offset & 0xffff; |
| r21690 | r21691 | |
| 192 | 251 | && offset >= 0x500000 && offset < 0x510000) |
| 193 | 252 | return spc7110_mmio_read(space, 0x4800); |
| 194 | 253 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 195 | | return space.read_byte(offset + 0x800000); // [00-7f] same as [80-ff] |
| 254 | return sfx_r(space, offset, 0xff); |
| 196 | 255 | |
| 197 | 256 | // base cart access |
| 198 | 257 | return snes_r_bank1(space, offset, 0xff); |
| r21690 | r21691 | |
| 254 | 313 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 255 | 314 | && offset >= 0x500000) |
| 256 | 315 | return spc7110_bank7_read(space, offset - 0x400000); |
| 257 | | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 258 | | && offset < 0x400000) |
| 259 | | { |
| 260 | | if (address >= 0x3000 && address < 0x3300) |
| 261 | | return superfx_mmio_read(m_superfx, address); |
| 262 | | if (address >= 0x6000 && address < 0x8000) |
| 263 | | return superfx_access_ram(m_superfx) ? m_sfx_ram[offset & 0x1fff] : snes_open_bus_r(space, 0); |
| 264 | | } |
| 265 | | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 266 | | && offset >= 0x400000 && offset < 0x600000) |
| 267 | | { |
| 268 | | if (superfx_access_rom(m_superfx)) |
| 269 | | return snes_ram[offset]; |
| 270 | | else |
| 271 | | { |
| 272 | | static const UINT8 sfx_data[16] = { |
| 273 | | 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, |
| 274 | | 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01, |
| 275 | | }; |
| 276 | | return sfx_data[offset & 0x0f]; |
| 277 | | } |
| 278 | | } |
| 279 | | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 280 | | && offset >= 0x600000) |
| 281 | | return superfx_access_ram(m_superfx) ? m_sfx_ram[offset & 0xfffff] : snes_open_bus_r(space, 0); |
| 316 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 317 | return sfx_r(space, offset, 0xff); |
| 282 | 318 | |
| 283 | 319 | // base cart access |
| 284 | 320 | return snes_r_bank2(space, offset, 0xff); |
| r21690 | r21691 | |
| 352 | 388 | { spc7110_ram_write(address & 0x1fff, data); return; } |
| 353 | 389 | } |
| 354 | 390 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 355 | | { space.write_byte(offset + 0x800000, data); return; } // [00-7f] same as [80-ff] |
| 391 | { sfx_w(space, offset, data, 0xff); return; } |
| 356 | 392 | |
| 357 | 393 | // base cart access |
| 358 | 394 | snes_w_bank1(space, offset, data, 0xff); |
| r21690 | r21691 | |
| 425 | 461 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 426 | 462 | { spc7110_ram_write(address & 0x1fff, data); return; } |
| 427 | 463 | } |
| 428 | | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 429 | | && offset < 0x400000) |
| 430 | | { |
| 431 | | if (address >= 0x3000 && address < 0x3300) |
| 432 | | { superfx_mmio_write(m_superfx, address, data); return; } |
| 433 | | if (address >= 0x6000 && address < 0x8000) |
| 434 | | { m_sfx_ram[offset & 0x1fff] = data; return; } |
| 435 | | } |
| 436 | | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 437 | | && offset >= 0x600000) |
| 438 | | { m_sfx_ram[offset & 0xfffff] = data; return; } |
| 464 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 465 | { sfx_w(space, offset, data, 0xff); return; } |
| 439 | 466 | |
| 440 | 467 | // base cart access |
| 441 | 468 | snes_w_bank2(space, offset, data, 0xff); |