trunk/src/mess/drivers/snes.c
| r21594 | r21595 | |
| 45 | 45 | public: |
| 46 | 46 | snes_console_state(const machine_config &mconfig, device_type type, const char *tag) |
| 47 | 47 | : snes_state(mconfig, type, tag) |
| 48 | | { } |
| 49 | | |
| 48 | { } |
| 49 | |
| 50 | 50 | DECLARE_READ8_MEMBER( spc_ram_100_r ); |
| 51 | 51 | DECLARE_WRITE8_MEMBER( spc_ram_100_w ); |
| 52 | 52 | UINT8 st010_read_ram(UINT16 addr); |
| r21594 | r21595 | |
| 68 | 68 | void snes_input_read_superscope( int port ); |
| 69 | 69 | DECLARE_WRITE8_MEMBER(snes_input_read); |
| 70 | 70 | DECLARE_READ8_MEMBER(snes_oldjoy1_read); |
| 71 | | DECLARE_READ8_MEMBER(snes_oldjoy2_read); |
| 71 | DECLARE_READ8_MEMBER(snes_oldjoy2_read); |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | 74 | /************************************* |
| r21594 | r21595 | |
| 103 | 103 | { |
| 104 | 104 | UINT16 temp = m_upd96050->dataram_r(addr/2); |
| 105 | 105 | UINT8 res; |
| 106 | | |
| 106 | |
| 107 | 107 | if (addr & 1) |
| 108 | 108 | { |
| 109 | 109 | res = temp>>8; |
| r21594 | r21595 | |
| 112 | 112 | { |
| 113 | 113 | res = temp & 0xff; |
| 114 | 114 | } |
| 115 | | |
| 115 | |
| 116 | 116 | return res; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | void snes_console_state::st010_write_ram(UINT16 addr, UINT8 data) |
| 120 | 120 | { |
| 121 | 121 | UINT16 temp = m_upd96050->dataram_r(addr/2); |
| 122 | | |
| 122 | |
| 123 | 123 | if (addr & 1) |
| 124 | 124 | { |
| 125 | 125 | temp &= 0xff; |
| r21594 | r21595 | |
| 130 | 130 | temp &= 0xff00; |
| 131 | 131 | temp |= data; |
| 132 | 132 | } |
| 133 | | |
| 133 | |
| 134 | 134 | m_upd96050->dataram_w(addr/2, temp); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | READ8_MEMBER( snes_console_state::snes_lo_r ) |
| 139 | | { |
| 139 | { |
| 140 | 140 | UINT16 address = offset & 0xffff; |
| 141 | 141 | |
| 142 | 142 | // take care of add-on chip access |
| 143 | | if (m_has_addon_chip == HAS_OBC1 |
| 143 | if (m_has_addon_chip == HAS_OBC1 |
| 144 | 144 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 145 | 145 | return obc1_read(space, offset, mem_mask); |
| 146 | | if (m_has_addon_chip == HAS_CX4 |
| 146 | if (m_has_addon_chip == HAS_CX4 |
| 147 | 147 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 148 | 148 | return CX4_read(address - 0x6000); |
| 149 | 149 | if (m_has_addon_chip == HAS_RTC |
| r21594 | r21595 | |
| 156 | 156 | if (offset == 0x600000 || offset == 0x600001) |
| 157 | 157 | return (offset & 1) ? st010_get_sr() : st010_get_dr(); |
| 158 | 158 | } |
| 159 | | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 159 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 160 | 160 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 161 | 161 | return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr(); |
| 162 | 162 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| r21594 | r21595 | |
| 165 | 165 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 166 | 166 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 167 | 167 | return (address < 0x4000) ? dsp_get_dr() : dsp_get_sr(); |
| 168 | | } |
| 168 | } |
| 169 | 169 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 170 | 170 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 171 | 171 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 172 | | if (m_has_addon_chip == HAS_DSP4 |
| 172 | if (m_has_addon_chip == HAS_DSP4 |
| 173 | 173 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 174 | 174 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 175 | 175 | if (m_has_addon_chip == HAS_SDD1 |
| r21594 | r21595 | |
| 177 | 177 | return sdd1_mmio_read(space, (UINT32)address); |
| 178 | 178 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 179 | 179 | && offset < 0x400000) |
| 180 | | { |
| 180 | { |
| 181 | 181 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 182 | 182 | if (address >= 0x4800 && address <= limit) |
| 183 | 183 | return spc7110_mmio_read(space, (UINT32)address); |
| r21594 | r21595 | |
| 191 | 191 | return spc7110_mmio_read(space, 0x4800); |
| 192 | 192 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 193 | 193 | && offset < 0x400000) |
| 194 | | { |
| 194 | { |
| 195 | 195 | if (address >= 0x3000 && address < 0x3300) |
| 196 | 196 | return superfx_mmio_read(m_superfx, address); |
| 197 | | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 197 | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 198 | 198 | return superfx_access_ram(m_superfx) ? snes_ram[0xf00000 + (offset & 0x1fff)] : snes_open_bus_r(space, 0); |
| 199 | 199 | } |
| 200 | 200 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| r21594 | r21595 | |
| 214 | 214 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 215 | 215 | && offset >= 0x600000) |
| 216 | 216 | return superfx_access_ram(m_superfx) ? snes_ram[0x800000 + offset] : snes_open_bus_r(space, 0); |
| 217 | | |
| 217 | |
| 218 | 218 | // base cart access |
| 219 | 219 | if (offset < 0x300000) |
| 220 | 220 | return snes_r_bank1(space, offset, 0xff); |
| r21594 | r21595 | |
| 226 | 226 | return snes_r_bank4(space, offset - 0x600000, 0xff); |
| 227 | 227 | else |
| 228 | 228 | return snes_r_bank5(space, offset - 0x700000, 0xff); |
| 229 | | } |
| 229 | } |
| 230 | 230 | |
| 231 | 231 | READ8_MEMBER( snes_console_state::snes_hi_r ) |
| 232 | 232 | { |
| 233 | 233 | UINT16 address = offset & 0xffff; |
| 234 | | |
| 234 | |
| 235 | 235 | // take care of add-on chip access |
| 236 | | if (m_has_addon_chip == HAS_OBC1 |
| 236 | if (m_has_addon_chip == HAS_OBC1 |
| 237 | 237 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 238 | 238 | return obc1_read(space, offset, mem_mask); |
| 239 | | if (m_has_addon_chip == HAS_CX4 |
| 239 | if (m_has_addon_chip == HAS_CX4 |
| 240 | 240 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 241 | 241 | return CX4_read(address - 0x6000); |
| 242 | 242 | if (m_has_addon_chip == HAS_RTC |
| r21594 | r21595 | |
| 249 | 249 | if (offset == 0x600000 || offset == 0x600001) |
| 250 | 250 | return (offset & 1) ? st010_get_sr() : st010_get_dr(); |
| 251 | 251 | } |
| 252 | | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 252 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 253 | 253 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 254 | 254 | return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr(); |
| 255 | 255 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| r21594 | r21595 | |
| 262 | 262 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 263 | 263 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 264 | 264 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 265 | | if (m_has_addon_chip == HAS_DSP4 |
| 265 | if (m_has_addon_chip == HAS_DSP4 |
| 266 | 266 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 267 | 267 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 268 | 268 | if (m_has_addon_chip == HAS_SDD1 |
| r21594 | r21595 | |
| 272 | 272 | return sdd1_read(space.machine(), offset - 0x400000); |
| 273 | 273 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 274 | 274 | && offset < 0x400000) |
| 275 | | { |
| 275 | { |
| 276 | 276 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 277 | 277 | if (address >= 0x4800 && address <= limit) |
| 278 | 278 | return spc7110_mmio_read(space, (UINT32)address); |
| r21594 | r21595 | |
| 281 | 281 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 282 | 282 | return snes_ram[0x306000 + (address & 0x1fff)]; |
| 283 | 283 | } |
| 284 | | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 284 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 285 | 285 | && offset >= 0x500000) |
| 286 | 286 | return spc7110_bank7_read(space, offset - 0x400000); |
| 287 | 287 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 288 | | return space.read_byte(offset); // [80-ff] same as [00-7f] |
| 289 | | |
| 288 | return space.read_byte(offset); // [80-ff] same as [00-7f] |
| 289 | |
| 290 | 290 | // base cart access |
| 291 | 291 | if (offset < 0x400000) |
| 292 | 292 | return snes_r_bank6(space, offset, 0xff); |
| 293 | 293 | else |
| 294 | 294 | return snes_r_bank7(space, offset - 0x400000, 0xff); |
| 295 | | } |
| 295 | } |
| 296 | 296 | |
| 297 | 297 | WRITE8_MEMBER( snes_console_state::snes_lo_w ) |
| 298 | 298 | { |
| 299 | 299 | UINT16 address = offset & 0xffff; |
| 300 | | |
| 300 | |
| 301 | 301 | // take care of add-on chip access |
| 302 | | if (m_has_addon_chip == HAS_OBC1 |
| 302 | if (m_has_addon_chip == HAS_OBC1 |
| 303 | 303 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 304 | | { obc1_write(space, offset, data, mem_mask); return; } |
| 305 | | if (m_has_addon_chip == HAS_CX4 |
| 304 | { obc1_write(space, offset, data, mem_mask); return; } |
| 305 | if (m_has_addon_chip == HAS_CX4 |
| 306 | 306 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 307 | | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 307 | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 308 | 308 | if (m_has_addon_chip == HAS_RTC |
| 309 | 309 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 310 | | { srtc_write(space.machine(), offset, data); return; } |
| 310 | { srtc_write(space.machine(), offset, data); return; } |
| 311 | 311 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 312 | 312 | { |
| 313 | 313 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 314 | | { st010_write_ram(address, data); return; } |
| 314 | { st010_write_ram(address, data); return; } |
| 315 | 315 | if (offset == 0x600000) |
| 316 | | { st010_set_dr(data); return; } |
| 316 | { st010_set_dr(data); return; } |
| 317 | 317 | if (offset == 0x600001) |
| 318 | | { st010_set_sr(data); return; } |
| 318 | { st010_set_sr(data); return; } |
| 319 | 319 | } |
| 320 | | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 320 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 321 | 321 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 322 | | { dsp_set_dr(data); return; } |
| 322 | { dsp_set_dr(data); return; } |
| 323 | 323 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 324 | 324 | { |
| 325 | 325 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 326 | | { dsp_set_dr(data); return; } |
| 326 | { dsp_set_dr(data); return; } |
| 327 | 327 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 328 | | { dsp_set_dr(data); return; } |
| 328 | { dsp_set_dr(data); return; } |
| 329 | 329 | } |
| 330 | 330 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 331 | 331 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 332 | 332 | { |
| 333 | 333 | if (address < 0xc000) |
| 334 | | { dsp_set_dr(data); return; } |
| 334 | { dsp_set_dr(data); return; } |
| 335 | 335 | else |
| 336 | | { dsp_set_sr(data); return; } |
| 336 | { dsp_set_sr(data); return; } |
| 337 | 337 | } |
| 338 | | if (m_has_addon_chip == HAS_DSP4 |
| 338 | if (m_has_addon_chip == HAS_DSP4 |
| 339 | 339 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 340 | 340 | { |
| 341 | 341 | if (address < 0xc000) |
| 342 | | { dsp_set_dr(data); return; } |
| 342 | { dsp_set_dr(data); return; } |
| 343 | 343 | else |
| 344 | | { dsp_set_sr(data); return; } |
| 344 | { dsp_set_sr(data); return; } |
| 345 | 345 | } |
| 346 | 346 | if (m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 347 | 347 | { |
| r21594 | r21595 | |
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 355 | | { |
| 355 | { |
| 356 | 356 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 357 | 357 | if (address >= 0x4800 && address <= limit) |
| 358 | | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 358 | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 359 | 359 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| 360 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 360 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 361 | 361 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 362 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 362 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 363 | 363 | } |
| 364 | 364 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 365 | | && offset < 0x400000) |
| 366 | | { |
| 365 | && offset < 0x400000) |
| 366 | { |
| 367 | 367 | if (address >= 0x3000 && address < 0x3300) |
| 368 | | { superfx_mmio_write(m_superfx, address, data); return; } |
| 369 | | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 370 | | { snes_ram[0xf00000 + (offset & 0x1fff)] = data; return; } |
| 368 | { superfx_mmio_write(m_superfx, address, data); return; } |
| 369 | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 370 | { snes_ram[0xf00000 + (offset & 0x1fff)] = data; return; } |
| 371 | 371 | } |
| 372 | 372 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 373 | 373 | && offset >= 0x600000) |
| 374 | | { snes_ram[0x800000 + offset] = data; return; } |
| 375 | | |
| 374 | { snes_ram[0x800000 + offset] = data; return; } |
| 375 | |
| 376 | 376 | // base cart access |
| 377 | 377 | if (offset < 0x300000) |
| 378 | 378 | snes_w_bank1(space, offset, data, 0xff); |
| r21594 | r21595 | |
| 384 | 384 | snes_w_bank4(space, offset - 0x600000, data, 0xff); |
| 385 | 385 | else |
| 386 | 386 | snes_w_bank5(space, offset - 0x700000, data, 0xff); |
| 387 | | } |
| 387 | } |
| 388 | 388 | |
| 389 | 389 | WRITE8_MEMBER( snes_console_state::snes_hi_w ) |
| 390 | 390 | { |
| 391 | 391 | UINT16 address = offset & 0xffff; |
| 392 | | |
| 392 | |
| 393 | 393 | // take care of add-on chip access |
| 394 | | if (m_has_addon_chip == HAS_OBC1 |
| 394 | if (m_has_addon_chip == HAS_OBC1 |
| 395 | 395 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 396 | | { obc1_write(space, offset, data, mem_mask); return; } |
| 397 | | if (m_has_addon_chip == HAS_CX4 |
| 396 | { obc1_write(space, offset, data, mem_mask); return; } |
| 397 | if (m_has_addon_chip == HAS_CX4 |
| 398 | 398 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 399 | | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 399 | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 400 | 400 | if (m_has_addon_chip == HAS_RTC |
| 401 | 401 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 402 | | { srtc_write(space.machine(), offset, data); return; } |
| 402 | { srtc_write(space.machine(), offset, data); return; } |
| 403 | 403 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 404 | 404 | { |
| 405 | 405 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 406 | | { st010_write_ram(address, data); return; } |
| 406 | { st010_write_ram(address, data); return; } |
| 407 | 407 | if (offset == 0x600000) |
| 408 | | { st010_set_dr(data); return; } |
| 408 | { st010_set_dr(data); return; } |
| 409 | 409 | if (offset == 0x600001) |
| 410 | | { st010_set_sr(data); return; } |
| 410 | { st010_set_sr(data); return; } |
| 411 | 411 | } |
| 412 | | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 412 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 413 | 413 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 414 | | { dsp_set_dr(data); return; } |
| 414 | { dsp_set_dr(data); return; } |
| 415 | 415 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 416 | 416 | { |
| 417 | 417 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 418 | | { dsp_set_dr(data); return; } |
| 418 | { dsp_set_dr(data); return; } |
| 419 | 419 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 420 | | { dsp_set_dr(data); return; } |
| 421 | | } |
| 420 | { dsp_set_dr(data); return; } |
| 421 | } |
| 422 | 422 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 423 | 423 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 424 | 424 | { |
| 425 | 425 | if (address < 0xc000) |
| 426 | | { dsp_set_dr(data); return; } |
| 426 | { dsp_set_dr(data); return; } |
| 427 | 427 | else |
| 428 | | { dsp_set_sr(data); return; } |
| 428 | { dsp_set_sr(data); return; } |
| 429 | 429 | } |
| 430 | | if (m_has_addon_chip == HAS_DSP4 |
| 430 | if (m_has_addon_chip == HAS_DSP4 |
| 431 | 431 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 432 | 432 | { |
| 433 | 433 | if (address < 0xc000) |
| 434 | | { dsp_set_dr(data); return; } |
| 434 | { dsp_set_dr(data); return; } |
| 435 | 435 | else |
| 436 | | { dsp_set_sr(data); return; } |
| 436 | { dsp_set_sr(data); return; } |
| 437 | 437 | } |
| 438 | 438 | if (m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 439 | 439 | { |
| r21594 | r21595 | |
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 447 | | { |
| 447 | { |
| 448 | 448 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 449 | 449 | if (address >= 0x4800 && address <= limit) |
| 450 | | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 450 | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 451 | 451 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| 452 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 452 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 453 | 453 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 454 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 454 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 455 | 455 | } |
| 456 | 456 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 457 | | { space.write_byte(offset, data); return; } // [80-ff] same as [00-7f] |
| 458 | | |
| 457 | { space.write_byte(offset, data); return; } // [80-ff] same as [00-7f] |
| 458 | |
| 459 | 459 | // base cart access |
| 460 | 460 | if (offset < 0x400000) |
| 461 | 461 | snes_w_bank6(space, offset, data, 0xff); |
| 462 | 462 | else |
| 463 | 463 | snes_w_bank7(space, offset, data - 0x400000, 0xff); |
| 464 | | } |
| 464 | } |
| 465 | 465 | |
| 466 | 466 | READ8_MEMBER( snes_console_state::superfx_r_bank1 ) |
| 467 | 467 | { |
| r21594 | r21595 | |
| 1117 | 1117 | |
| 1118 | 1118 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(snes_machine_stop),&machine)); |
| 1119 | 1119 | MACHINE_START_CALL(snes); |
| 1120 | | |
| 1120 | |
| 1121 | 1121 | switch (state->m_has_addon_chip) |
| 1122 | 1122 | { |
| 1123 | 1123 | case HAS_SDD1: |
| r21594 | r21595 | |
| 1147 | 1147 | state->m_io_read = write8_delegate(FUNC(snes_console_state::snes_input_read),state); |
| 1148 | 1148 | state->m_oldjoy1_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy1_read),state); |
| 1149 | 1149 | state->m_oldjoy2_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy2_read),state); |
| 1150 | | |
| 1150 | |
| 1151 | 1151 | // see if there's a uPD7725 DSP in the machine config |
| 1152 | 1152 | state->m_upd7725 = machine.device<upd7725_device>("dsp"); |
| 1153 | | |
| 1153 | |
| 1154 | 1154 | // if we have a DSP, halt it for the moment |
| 1155 | 1155 | if (state->m_upd7725) |
| 1156 | 1156 | machine.device("dsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 1157 | | |
| 1157 | |
| 1158 | 1158 | // ditto for a uPD96050 (Seta ST-010 or ST-011) |
| 1159 | 1159 | state->m_upd96050 = machine.device<upd96050_device>("setadsp"); |
| 1160 | 1160 | if (state->m_upd96050) |
| 1161 | 1161 | machine.device("setadsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 1162 | | |
| 1162 | |
| 1163 | 1163 | switch (state->m_has_addon_chip) |
| 1164 | 1164 | { |
| 1165 | 1165 | case HAS_DSP1: |
| r21594 | r21595 | |
| 1175 | 1175 | state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device |
| 1176 | 1176 | } |
| 1177 | 1177 | break; |
| 1178 | | |
| 1178 | |
| 1179 | 1179 | case HAS_RTC: |
| 1180 | 1180 | srtc_init(machine); |
| 1181 | 1181 | break; |
| 1182 | | |
| 1182 | |
| 1183 | 1183 | case HAS_OBC1: |
| 1184 | 1184 | obc1_init(machine); |
| 1185 | 1185 | break; |
| 1186 | | |
| 1186 | |
| 1187 | 1187 | case HAS_ST010: |
| 1188 | 1188 | case HAS_ST011: |
| 1189 | 1189 | // cartridge uses the DSP, let 'er rip |
| r21594 | r21595 | |
| 1195 | 1195 | state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device |
| 1196 | 1196 | } |
| 1197 | 1197 | break; |
| 1198 | | |
| 1198 | |
| 1199 | 1199 | default: |
| 1200 | 1200 | break; |
| 1201 | 1201 | } |
| r21594 | r21595 | |
| 1487 | 1487 | snsnew_state(const machine_config &mconfig, device_type type, const char *tag) |
| 1488 | 1488 | : snes_console_state(mconfig, type, tag), |
| 1489 | 1489 | m_slotcart(*this, "snsslot") |
| 1490 | | { } |
| 1491 | | |
| 1490 | { } |
| 1491 | |
| 1492 | 1492 | DECLARE_READ8_MEMBER( snes20_hi_r ); |
| 1493 | 1493 | DECLARE_WRITE8_MEMBER( snes20_hi_w ); |
| 1494 | 1494 | DECLARE_READ8_MEMBER( snes20_lo_r ); |
| r21594 | r21595 | |
| 1534 | 1534 | READ8_MEMBER( snsnew_state::snes20_hi_r ) |
| 1535 | 1535 | { |
| 1536 | 1536 | UINT16 address = offset & 0xffff; |
| 1537 | | |
| 1537 | |
| 1538 | 1538 | if (offset < 0x400000) |
| 1539 | 1539 | { |
| 1540 | 1540 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1543 | 1543 | return snes_r_io(space, address); |
| 1544 | 1544 | if (address >= 0x6000 && address < 0x8000) |
| 1545 | 1545 | return snes_open_bus_r(space, 0); |
| 1546 | | if (address >= 0x8000) |
| 1546 | if (address >= 0x8000) |
| 1547 | 1547 | return m_slotcart->m_cart->read_h(space, offset); |
| 1548 | 1548 | } |
| 1549 | 1549 | else if (offset < 0x700000) |
| r21594 | r21595 | |
| 1553 | 1553 | else |
| 1554 | 1554 | return m_slotcart->m_cart->read_h(space, offset); |
| 1555 | 1555 | } |
| 1556 | | |
| 1556 | |
| 1557 | 1557 | // ROM & NVRAM access |
| 1558 | 1558 | return m_slotcart->m_cart->read_h(space, offset); |
| 1559 | | } |
| 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | WRITE8_MEMBER( snsnew_state::snes20_hi_w ) |
| 1562 | 1562 | { |
| r21594 | r21595 | |
| 1568 | 1568 | if (address >= 0x2000 && address < 0x6000) |
| 1569 | 1569 | snes_w_io(space, address, data); |
| 1570 | 1570 | } |
| 1571 | | else if (offset >= 0x700000) // NVRAM access |
| 1571 | else if (offset >= 0x700000) // NVRAM access |
| 1572 | 1572 | { |
| 1573 | 1573 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1574 | 1574 | } |
| 1575 | | } |
| 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | READ8_MEMBER( snsnew_state::snes20_lo_r ) |
| 1578 | 1578 | { |
| 1579 | 1579 | UINT16 address = offset & 0xffff; |
| 1580 | | |
| 1580 | |
| 1581 | 1581 | if (offset < 0x400000) |
| 1582 | 1582 | { |
| 1583 | 1583 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1586 | 1586 | return snes_r_io(space, address); |
| 1587 | 1587 | if (address >= 0x6000 && address < 0x8000) |
| 1588 | 1588 | return snes_open_bus_r(space, 0); |
| 1589 | | if (address >= 0x8000) |
| 1589 | if (address >= 0x8000) |
| 1590 | 1590 | return m_slotcart->m_cart->read_l(space, offset); |
| 1591 | 1591 | } |
| 1592 | 1592 | else if (offset < 0x700000) |
| r21594 | r21595 | |
| 1596 | 1596 | else |
| 1597 | 1597 | return m_slotcart->m_cart->read_l(space, offset); |
| 1598 | 1598 | } |
| 1599 | | |
| 1599 | |
| 1600 | 1600 | // ROM & NVRAM access |
| 1601 | 1601 | return m_slotcart->m_cart->read_l(space, offset); |
| 1602 | | } |
| 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | WRITE8_MEMBER( snsnew_state::snes20_lo_w ) |
| 1605 | 1605 | { |
| 1606 | 1606 | snes20_hi_w(space, offset, data, 0xff); |
| 1607 | | } |
| 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | |
| 1610 | 1610 | // HiROM |
| r21594 | r21595 | |
| 1612 | 1612 | READ8_MEMBER( snsnew_state::snes21_lo_r ) |
| 1613 | 1613 | { |
| 1614 | 1614 | UINT16 address = offset & 0xffff; |
| 1615 | | |
| 1615 | |
| 1616 | 1616 | if (offset < 0x400000) |
| 1617 | 1617 | { |
| 1618 | 1618 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1632 | 1632 | if (address >= 0x8000) |
| 1633 | 1633 | return m_slotcart->m_cart->read_l(space, offset); |
| 1634 | 1634 | } |
| 1635 | | |
| 1635 | |
| 1636 | 1636 | // ROM & NVRAM access |
| 1637 | 1637 | return m_slotcart->m_cart->read_l(space, offset); |
| 1638 | | } |
| 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | WRITE8_MEMBER( snsnew_state::snes21_lo_w ) |
| 1641 | 1641 | { |
| r21594 | r21595 | |
| 1656 | 1656 | } |
| 1657 | 1657 | } |
| 1658 | 1658 | } |
| 1659 | | else if (offset >= 0x700000) // NVRAM access |
| 1659 | else if (offset >= 0x700000) // NVRAM access |
| 1660 | 1660 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1661 | | } |
| 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | READ8_MEMBER( snsnew_state::snes21_hi_r ) |
| 1664 | 1664 | { |
| 1665 | 1665 | UINT16 address = offset & 0xffff; |
| 1666 | | |
| 1666 | |
| 1667 | 1667 | if (offset < 0x400000) |
| 1668 | 1668 | { |
| 1669 | 1669 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1683 | 1683 | if (address >= 0x8000) |
| 1684 | 1684 | return m_slotcart->m_cart->read_h(space, offset); |
| 1685 | 1685 | } |
| 1686 | | |
| 1686 | |
| 1687 | 1687 | // ROM & NVRAM access |
| 1688 | 1688 | return m_slotcart->m_cart->read_h(space, offset); |
| 1689 | | } |
| 1689 | } |
| 1690 | 1690 | |
| 1691 | 1691 | WRITE8_MEMBER( snsnew_state::snes21_hi_w ) |
| 1692 | 1692 | { |
| r21594 | r21595 | |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | } |
| 1710 | | else if (offset >= 0x700000) // NVRAM access |
| 1710 | else if (offset >= 0x700000) // NVRAM access |
| 1711 | 1711 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1712 | | } |
| 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | // SuperFX / GSU |
| 1715 | 1715 | |
| 1716 | 1716 | READ8_MEMBER( snsnew_state::snesfx_hi_r ) |
| 1717 | 1717 | { |
| 1718 | 1718 | UINT16 address = offset & 0xffff; |
| 1719 | | |
| 1719 | |
| 1720 | 1720 | if (offset < 0x400000) |
| 1721 | 1721 | { |
| 1722 | 1722 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1730 | 1730 | } |
| 1731 | 1731 | if (address >= 0x6000 && address < 0x8000) |
| 1732 | 1732 | { |
| 1733 | | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1733 | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1734 | 1734 | } |
| 1735 | 1735 | if (address >= 0x8000) |
| 1736 | | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1736 | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1737 | 1737 | } |
| 1738 | 1738 | else if (offset < 0x600000) |
| 1739 | | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1740 | | |
| 1741 | | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1742 | | } |
| 1739 | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1743 | 1740 | |
| 1741 | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1742 | } |
| 1743 | |
| 1744 | 1744 | READ8_MEMBER( snsnew_state::snesfx_lo_r ) |
| 1745 | 1745 | { |
| 1746 | 1746 | UINT16 address = offset & 0xffff; |
| 1747 | | |
| 1747 | |
| 1748 | 1748 | if (offset < 0x400000) |
| 1749 | 1749 | { |
| 1750 | 1750 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1758 | 1758 | } |
| 1759 | 1759 | if (address >= 0x6000 && address < 0x8000) |
| 1760 | 1760 | { |
| 1761 | | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1761 | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1762 | 1762 | } |
| 1763 | 1763 | if (address >= 0x8000) |
| 1764 | | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1764 | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1765 | 1765 | } |
| 1766 | 1766 | else if (offset < 0x600000) |
| 1767 | | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1768 | | |
| 1769 | | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1770 | | } |
| 1767 | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1771 | 1768 | |
| 1769 | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1770 | } |
| 1771 | |
| 1772 | 1772 | WRITE8_MEMBER( snsnew_state::snesfx_hi_w ) |
| 1773 | 1773 | { |
| 1774 | 1774 | UINT16 address = offset & 0xffff; |
| r21594 | r21595 | |
| 1788 | 1788 | } |
| 1789 | 1789 | else |
| 1790 | 1790 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1791 | | } |
| 1791 | } |
| 1792 | 1792 | |
| 1793 | 1793 | WRITE8_MEMBER( snsnew_state::snesfx_lo_w ) |
| 1794 | 1794 | { |
| r21594 | r21595 | |
| 1809 | 1809 | } |
| 1810 | 1810 | else |
| 1811 | 1811 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1812 | | } |
| 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | // SPC-7110 |
| 1815 | 1815 | |
| 1816 | 1816 | READ8_MEMBER( snsnew_state::snespc7110_hi_r ) |
| 1817 | 1817 | { |
| 1818 | 1818 | UINT16 address = offset & 0xffff; |
| 1819 | | |
| 1819 | |
| 1820 | 1820 | if (offset < 0x400000) |
| 1821 | 1821 | { |
| 1822 | 1822 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1826 | 1826 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1827 | 1827 | if (address >= 0x4800 && address < limit) |
| 1828 | 1828 | return m_slotcart->m_cart->chip_read(space, address); |
| 1829 | | |
| 1829 | |
| 1830 | 1830 | return snes_r_io(space, address); |
| 1831 | 1831 | } |
| 1832 | 1832 | if (address >= 0x6000 && address < 0x8000) |
| r21594 | r21595 | |
| 1840 | 1840 | return m_slotcart->m_cart->read_h(space, offset); |
| 1841 | 1841 | } |
| 1842 | 1842 | return m_slotcart->m_cart->read_h(space, offset); |
| 1843 | | } |
| 1843 | } |
| 1844 | 1844 | |
| 1845 | 1845 | READ8_MEMBER( snsnew_state::snespc7110_lo_r ) |
| 1846 | 1846 | { |
| 1847 | 1847 | UINT16 address = offset & 0xffff; |
| 1848 | | |
| 1848 | |
| 1849 | 1849 | if (offset < 0x400000) |
| 1850 | 1850 | { |
| 1851 | 1851 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1855 | 1855 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1856 | 1856 | if (address >= 0x4800 && address < limit) |
| 1857 | 1857 | return m_slotcart->m_cart->chip_read(space, address); |
| 1858 | | |
| 1858 | |
| 1859 | 1859 | return snes_r_io(space, address); |
| 1860 | 1860 | } |
| 1861 | 1861 | if (address >= 0x6000 && address < 0x8000) |
| r21594 | r21595 | |
| 1872 | 1872 | return m_slotcart->m_cart->chip_read(space, 0x4800); |
| 1873 | 1873 | |
| 1874 | 1874 | return snes_open_bus_r(space, 0); |
| 1875 | | } |
| 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | WRITE8_MEMBER( snsnew_state::snespc7110_hi_w ) |
| 1878 | 1878 | { |
| r21594 | r21595 | |
| 1899 | 1899 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| 1902 | | } |
| 1902 | } |
| 1903 | 1903 | |
| 1904 | 1904 | WRITE8_MEMBER( snsnew_state::snespc7110_lo_w ) |
| 1905 | 1905 | { |
| r21594 | r21595 | |
| 1926 | 1926 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1927 | 1927 | } |
| 1928 | 1928 | } |
| 1929 | | } |
| 1929 | } |
| 1930 | 1930 | |
| 1931 | 1931 | |
| 1932 | 1932 | // S-DD1 |
| r21594 | r21595 | |
| 1934 | 1934 | READ8_MEMBER( snsnew_state::snesdd1_lo_r ) |
| 1935 | 1935 | { |
| 1936 | 1936 | UINT16 address = offset & 0xffff; |
| 1937 | | |
| 1937 | |
| 1938 | 1938 | if (offset < 0x400000) |
| 1939 | 1939 | { |
| 1940 | 1940 | if (address < 0x2000) |
| r21594 | r21595 | |
| 1943 | 1943 | { |
| 1944 | 1944 | if (address >= 0x4800 && address < 0x4808) |
| 1945 | 1945 | return m_slotcart->m_cart->chip_read(space, address); |
| 1946 | | |
| 1946 | |
| 1947 | 1947 | return snes_r_io(space, address); |
| 1948 | 1948 | } |
| 1949 | 1949 | if (address >= 0x6000 && address < 0x8000) |
| r21594 | r21595 | |
| 1951 | 1951 | if (address >= 0x8000) |
| 1952 | 1952 | return m_slotcart->m_cart->read_l(space, offset); |
| 1953 | 1953 | } |
| 1954 | | |
| 1954 | |
| 1955 | 1955 | // ROM & NVRAM access |
| 1956 | 1956 | return m_slotcart->m_cart->read_l(space, offset); |
| 1957 | | } |
| 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | WRITE8_MEMBER( snsnew_state::snesdd1_lo_w ) |
| 1960 | 1960 | { |
| r21594 | r21595 | |
| 1980 | 1980 | } |
| 1981 | 1981 | if (offset >= 0x700000 && address < 0x8000 && m_slotcart->m_cart->get_nvram_size()) |
| 1982 | 1982 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 1983 | | } |
| 1983 | } |
| 1984 | 1984 | |
| 1985 | 1985 | READ8_MEMBER( snsnew_state::snesdd1_hi_r ) |
| 1986 | | { |
| 1986 | { |
| 1987 | 1987 | if (offset >= 0x400000) |
| 1988 | 1988 | return m_slotcart->m_cart->read_h(space, offset); |
| 1989 | | else |
| 1989 | else |
| 1990 | 1990 | return snesdd1_lo_r(space, offset, 0xff); |
| 1991 | | } |
| 1991 | } |
| 1992 | 1992 | |
| 1993 | 1993 | WRITE8_MEMBER( snsnew_state::snesdd1_hi_w ) |
| 1994 | 1994 | { |
| 1995 | 1995 | snesdd1_lo_w(space, offset, data, 0xff); |
| 1996 | | } |
| 1996 | } |
| 1997 | 1997 | |
| 1998 | 1998 | |
| 1999 | 1999 | // BS-X |
| r21594 | r21595 | |
| 2001 | 2001 | READ8_MEMBER( snsnew_state::snesbsx_hi_r ) |
| 2002 | 2002 | { |
| 2003 | 2003 | UINT16 address = offset & 0xffff; |
| 2004 | | |
| 2004 | |
| 2005 | 2005 | if (offset < 0x400000) |
| 2006 | 2006 | { |
| 2007 | 2007 | if (address < 0x2000) |
| r21594 | r21595 | |
| 2016 | 2016 | } |
| 2017 | 2017 | if (address >= 0x6000 && address < 0x8000) |
| 2018 | 2018 | { |
| 2019 | | if (offset >= 0x200000) |
| 2019 | if (offset >= 0x200000) |
| 2020 | 2020 | return m_slotcart->m_cart->read_l(space, offset); |
| 2021 | 2021 | else |
| 2022 | 2022 | return snes_open_bus_r(space, 0); |
| 2023 | 2023 | } |
| 2024 | | if (address >= 0x8000) |
| 2024 | if (address >= 0x8000) |
| 2025 | 2025 | return m_slotcart->m_cart->read_l(space, offset); |
| 2026 | 2026 | } |
| 2027 | 2027 | return m_slotcart->m_cart->read_l(space, offset); |
| 2028 | | } |
| 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | WRITE8_MEMBER( snsnew_state::snesbsx_hi_w ) |
| 2031 | 2031 | { |
| r21594 | r21595 | |
| 2050 | 2050 | } |
| 2051 | 2051 | if (address >= 0x6000 && address < 0x8000) |
| 2052 | 2052 | { |
| 2053 | | if (offset >= 0x200000) |
| 2053 | if (offset >= 0x200000) |
| 2054 | 2054 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2055 | 2055 | } |
| 2056 | | if (address >= 0x8000) |
| 2056 | if (address >= 0x8000) |
| 2057 | 2057 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2058 | 2058 | } |
| 2059 | 2059 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2060 | | } |
| 2060 | } |
| 2061 | 2061 | |
| 2062 | 2062 | READ8_MEMBER( snsnew_state::snesbsx_lo_r ) |
| 2063 | 2063 | { |
| 2064 | 2064 | return snesbsx_hi_r(space, offset, 0xff); |
| 2065 | | } |
| 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | WRITE8_MEMBER( snsnew_state::snesbsx_lo_w ) |
| 2068 | 2068 | { |
| 2069 | 2069 | snesbsx_hi_w(space, offset, data, 0xff); |
| 2070 | | } |
| 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | |
| 2073 | 2073 | READ8_MEMBER( snsnew_state::snesnew_lo_r ) |
| r21594 | r21595 | |
| 2088 | 2088 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2089 | 2089 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2090 | 2090 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2091 | else if ((m_slotcart->get_type() == SNES_ST010 /*|| m_slotcart->get_type() == SNES_ST011*/) // why does this freeze moritash? |
| 2092 | && (offset == 0x600000 || offset == 0x600001)) |
| 2093 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2091 | 2094 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2092 | 2095 | && (offset < 0x400000 && (offset & 0xffff) == 0x2800)) |
| 2093 | 2096 | return m_slotcart->m_cart->chip_read(space, offset & 0xffff); |
| r21594 | r21595 | |
| 2107 | 2110 | case SNES_POKEMON: |
| 2108 | 2111 | case SNES_BANANA: |
| 2109 | 2112 | return snes20_lo_r(space, offset, 0xff); |
| 2110 | | |
| 2113 | |
| 2111 | 2114 | case SNES_MODE21: |
| 2112 | 2115 | case SNES_DSP_MODE21: |
| 2113 | 2116 | case SNES_SRTC: |
| 2114 | 2117 | case SNES_BSXHI: |
| 2115 | 2118 | return snes21_lo_r(space, offset, 0xff); |
| 2116 | | |
| 2119 | |
| 2117 | 2120 | case SNES_SFX: |
| 2118 | 2121 | return snesfx_lo_r(space, offset, 0xff); |
| 2119 | | |
| 2122 | |
| 2120 | 2123 | case SNES_SPC7110: |
| 2121 | 2124 | case SNES_SPC7110_RTC: |
| 2122 | 2125 | return snespc7110_lo_r(space, offset, 0xff); |
| 2123 | | |
| 2126 | |
| 2124 | 2127 | case SNES_SDD1: |
| 2125 | 2128 | return snesdd1_lo_r(space, offset, 0xff); |
| 2126 | | |
| 2129 | |
| 2127 | 2130 | case SNES_BSX: |
| 2128 | 2131 | return snesbsx_lo_r(space, offset, 0xff); |
| 2129 | 2132 | } |
| 2130 | 2133 | } |
| 2131 | 2134 | return snes_open_bus_r(space, 0); |
| 2132 | | } |
| 2135 | } |
| 2133 | 2136 | |
| 2134 | 2137 | READ8_MEMBER( snsnew_state::snesnew_hi_r ) |
| 2135 | 2138 | { |
| r21594 | r21595 | |
| 2150 | 2153 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2151 | 2154 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2152 | 2155 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2153 | | && (offset == 0x600000 || offset == 0x600001)) |
| 2156 | && (offset == 0x600000 || offset == 0x600001)) |
| 2154 | 2157 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2155 | 2158 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2156 | 2159 | && (offset < 0x400000 && (offset & 0xffff) == 0x2800)) |
| r21594 | r21595 | |
| 2158 | 2161 | else if ((m_slotcart->get_type() == SNES_POKEMON || m_slotcart->get_type() == SNES_BANANA) |
| 2159 | 2162 | && (offset & 0x70000) == 0x0000) |
| 2160 | 2163 | { |
| 2161 | | // printf("hi read %x\n", offset); |
| 2164 | // printf("hi read %x\n", offset); |
| 2162 | 2165 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2163 | 2166 | } |
| 2164 | 2167 | else |
| r21594 | r21595 | |
| 2177 | 2180 | case SNES_POKEMON: |
| 2178 | 2181 | case SNES_BANANA: |
| 2179 | 2182 | return snes20_hi_r(space, offset, 0xff); |
| 2180 | | |
| 2183 | |
| 2181 | 2184 | case SNES_MODE21: |
| 2182 | 2185 | case SNES_DSP_MODE21: |
| 2183 | 2186 | case SNES_SRTC: |
| 2184 | 2187 | case SNES_BSXHI: |
| 2185 | 2188 | return snes21_hi_r(space, offset, 0xff); |
| 2186 | | |
| 2189 | |
| 2187 | 2190 | case SNES_SFX: |
| 2188 | 2191 | return snesfx_hi_r(space, offset, 0xff); |
| 2189 | | |
| 2192 | |
| 2190 | 2193 | case SNES_SPC7110: |
| 2191 | 2194 | case SNES_SPC7110_RTC: |
| 2192 | 2195 | return snespc7110_hi_r(space, offset, 0xff); |
| 2193 | | |
| 2196 | |
| 2194 | 2197 | case SNES_SDD1: |
| 2195 | 2198 | return snesdd1_hi_r(space, offset, 0xff); |
| 2196 | | |
| 2199 | |
| 2197 | 2200 | case SNES_BSX: |
| 2198 | 2201 | return snesbsx_hi_r(space, offset, 0xff); |
| 2199 | 2202 | } |
| 2200 | 2203 | } |
| 2201 | 2204 | return snes_open_bus_r(space, 0); |
| 2202 | | } |
| 2205 | } |
| 2203 | 2206 | |
| 2204 | 2207 | WRITE8_MEMBER( snsnew_state::snesnew_lo_w ) |
| 2205 | 2208 | { |
| r21594 | r21595 | |
| 2220 | 2223 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2221 | 2224 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2222 | 2225 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2223 | | && (offset == 0x600000 || offset == 0x600001)) |
| 2226 | && (offset == 0x600000 || offset == 0x600001)) |
| 2224 | 2227 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2225 | 2228 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2226 | 2229 | && (offset < 0x400000 && (offset & 0xffff) == 0x2801)) |
| r21594 | r21595 | |
| 2248 | 2251 | case SNES_BANANA: |
| 2249 | 2252 | snes20_lo_w(space, offset, data, 0xff); |
| 2250 | 2253 | break; |
| 2251 | | |
| 2254 | |
| 2252 | 2255 | case SNES_MODE21: |
| 2253 | 2256 | case SNES_DSP_MODE21: |
| 2254 | 2257 | case SNES_SRTC: |
| 2255 | 2258 | case SNES_BSXHI: |
| 2256 | 2259 | snes21_lo_w(space, offset, data, 0xff); |
| 2257 | 2260 | break; |
| 2258 | | |
| 2261 | |
| 2259 | 2262 | case SNES_SFX: |
| 2260 | 2263 | snesfx_lo_w(space, offset, data, 0xff); |
| 2261 | 2264 | break; |
| 2262 | | |
| 2265 | |
| 2263 | 2266 | case SNES_SPC7110: |
| 2264 | 2267 | case SNES_SPC7110_RTC: |
| 2265 | 2268 | snespc7110_lo_w(space, offset, data, 0xff); |
| 2266 | 2269 | break; |
| 2267 | | |
| 2270 | |
| 2268 | 2271 | case SNES_SDD1: |
| 2269 | 2272 | snesdd1_lo_w(space, offset, data, 0xff); |
| 2270 | 2273 | break; |
| 2271 | | |
| 2274 | |
| 2272 | 2275 | case SNES_BSX: |
| 2273 | 2276 | snesbsx_lo_w(space, offset, data, 0xff); |
| 2274 | 2277 | break; |
| 2275 | 2278 | } |
| 2276 | 2279 | } |
| 2277 | | } |
| 2280 | } |
| 2278 | 2281 | |
| 2279 | 2282 | WRITE8_MEMBER( snsnew_state::snesnew_hi_w ) |
| 2280 | 2283 | { |
| r21594 | r21595 | |
| 2295 | 2298 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2296 | 2299 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2297 | 2300 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2298 | | && (offset == 0x600000 || offset == 0x600001)) |
| 2301 | && (offset == 0x600000 || offset == 0x600001)) |
| 2299 | 2302 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2300 | 2303 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2301 | 2304 | && (offset < 0x400000 && (offset & 0xffff) == 0x2801)) |
| r21594 | r21595 | |
| 2323 | 2326 | case SNES_BANANA: |
| 2324 | 2327 | snes20_hi_w(space, offset, data, 0xff); |
| 2325 | 2328 | break; |
| 2326 | | |
| 2329 | |
| 2327 | 2330 | case SNES_MODE21: |
| 2328 | 2331 | case SNES_DSP_MODE21: |
| 2329 | 2332 | case SNES_SRTC: |
| 2330 | 2333 | case SNES_BSXHI: |
| 2331 | 2334 | snes21_hi_w(space, offset, data, 0xff); |
| 2332 | 2335 | break; |
| 2333 | | |
| 2336 | |
| 2334 | 2337 | case SNES_SFX: |
| 2335 | 2338 | snesfx_hi_w(space, offset, data, 0xff); |
| 2336 | 2339 | break; |
| 2337 | | |
| 2340 | |
| 2338 | 2341 | case SNES_SPC7110: |
| 2339 | 2342 | case SNES_SPC7110_RTC: |
| 2340 | 2343 | snespc7110_hi_w(space, offset, data, 0xff); |
| 2341 | 2344 | break; |
| 2342 | | |
| 2345 | |
| 2343 | 2346 | case SNES_SDD1: |
| 2344 | 2347 | snesdd1_hi_w(space, offset, data, 0xff); |
| 2345 | 2348 | break; |
| 2346 | | |
| 2349 | |
| 2347 | 2350 | case SNES_BSX: |
| 2348 | 2351 | snesbsx_hi_w(space, offset, data, 0xff); |
| 2349 | 2352 | break; |
| 2350 | 2353 | } |
| 2351 | 2354 | } |
| 2352 | | } |
| 2355 | } |
| 2353 | 2356 | |
| 2354 | 2357 | |
| 2355 | 2358 | static ADDRESS_MAP_START( snesnew_map, AS_PROGRAM, 8, snsnew_state ) |
| r21594 | r21595 | |
| 2360 | 2363 | |
| 2361 | 2364 | static SLOT_INTERFACE_START(snes_cart) |
| 2362 | 2365 | SLOT_INTERFACE_INTERNAL("lorom", SNS_LOROM) |
| 2363 | | SLOT_INTERFACE_INTERNAL("lorom_bsx", SNS_LOROM_BSX) // LoROM + BS-X slot - unsupported |
| 2364 | | SLOT_INTERFACE_INTERNAL("lorom_cx4", SNS_LOROM) // Cart + CX4 - unsupported |
| 2366 | SLOT_INTERFACE_INTERNAL("lorom_bsx", SNS_LOROM_BSX) // LoROM + BS-X slot - unsupported |
| 2367 | SLOT_INTERFACE_INTERNAL("lorom_cx4", SNS_LOROM) // Cart + CX4 - unsupported |
| 2365 | 2368 | SLOT_INTERFACE_INTERNAL("lorom_dsp", SNS_LOROM_NECDSP) |
| 2366 | 2369 | SLOT_INTERFACE_INTERNAL("lorom_dsp4", SNS_LOROM_NECDSP) |
| 2367 | 2370 | SLOT_INTERFACE_INTERNAL("lorom_obc1", SNS_LOROM_OBC1) |
| 2368 | | SLOT_INTERFACE_INTERNAL("lorom_sa1", SNS_LOROM) // Cart + SA1 - unsupported |
| 2371 | SLOT_INTERFACE_INTERNAL("lorom_sa1", SNS_LOROM) // Cart + SA1 - unsupported |
| 2369 | 2372 | SLOT_INTERFACE_INTERNAL("lorom_sdd1", SNS_LOROM_SDD1) |
| 2370 | 2373 | SLOT_INTERFACE_INTERNAL("lorom_sfx", SNS_LOROM_SUPERFX) |
| 2371 | | SLOT_INTERFACE_INTERNAL("lorom_sgb", SNS_LOROM) // SuperGB base cart - unsupported |
| 2374 | SLOT_INTERFACE_INTERNAL("lorom_sgb", SNS_LOROM) // SuperGB base cart - unsupported |
| 2372 | 2375 | SLOT_INTERFACE_INTERNAL("lorom_st010", SNS_LOROM_SETA10) |
| 2373 | 2376 | SLOT_INTERFACE_INTERNAL("lorom_st011", SNS_LOROM_SETA11) |
| 2374 | | SLOT_INTERFACE_INTERNAL("lorom_st018", SNS_LOROM) // Cart + ST018 - unsupported |
| 2375 | | SLOT_INTERFACE_INTERNAL("lorom_sufami", SNS_LOROM_SUFAMI) // Sufami Turbo base cart |
| 2377 | SLOT_INTERFACE_INTERNAL("lorom_st018", SNS_LOROM) // Cart + ST018 - unsupported |
| 2378 | SLOT_INTERFACE_INTERNAL("lorom_sufami", SNS_LOROM_SUFAMI) // Sufami Turbo base cart |
| 2376 | 2379 | SLOT_INTERFACE_INTERNAL("hirom", SNS_HIROM) |
| 2377 | | SLOT_INTERFACE_INTERNAL("hirom_bsx", SNS_HIROM_BSX) // HiROM + BS-X slot - unsupported |
| 2380 | SLOT_INTERFACE_INTERNAL("hirom_bsx", SNS_HIROM_BSX) // HiROM + BS-X slot - unsupported |
| 2378 | 2381 | SLOT_INTERFACE_INTERNAL("hirom_dsp", SNS_HIROM_NECDSP) |
| 2379 | 2382 | SLOT_INTERFACE_INTERNAL("hirom_spc7110", SNS_HIROM_SPC7110) |
| 2380 | 2383 | SLOT_INTERFACE_INTERNAL("hirom_spcrtc", SNS_HIROM_SPC7110_RTC) |
| 2381 | 2384 | SLOT_INTERFACE_INTERNAL("hirom_srtc", SNS_HIROM_SRTC) |
| 2382 | | SLOT_INTERFACE_INTERNAL("bsxrom", SNS_ROM_BSX) // BS-X base cart - partial support only |
| 2385 | SLOT_INTERFACE_INTERNAL("bsxrom", SNS_ROM_BSX) // BS-X base cart - partial support only |
| 2383 | 2386 | // pirate carts |
| 2384 | 2387 | SLOT_INTERFACE_INTERNAL("lorom_poke", SNS_LOROM_POKEMON) |
| 2385 | 2388 | SLOT_INTERFACE_END |
| r21594 | r21595 | |
| 2402 | 2405 | set_5a22_map(*state->m_maincpu); |
| 2403 | 2406 | break; |
| 2404 | 2407 | case SNES_DSP_MODE21: |
| 2405 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w)); |
| 2406 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w)); |
| 2407 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x006000, 0x007fff, 0x9f0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart)); |
| 2408 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x006000, 0x007fff, 0x9f0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart)); |
| 2409 | | // set_5a22_map(*state->m_maincpu); |
| 2408 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000000, 0x7dffff, read8_delegate(FUNC(snsnew_state::snes21_lo_r),state), write8_delegate(FUNC(snsnew_state::snes21_lo_w),state)); |
| 2409 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x800000, 0xffffff, read8_delegate(FUNC(snsnew_state::snes21_hi_r),state), write8_delegate(FUNC(snsnew_state::snes21_hi_w),state)); |
| 2410 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x006000, 0x007fff, 0x9f0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart)); |
| 2411 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x006000, 0x007fff, 0x9f0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart)); |
| 2412 | // set_5a22_map(*state->m_maincpu); |
| 2410 | 2413 | break; |
| 2411 | 2414 | case SNES_SRTC: |
| 2412 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w)); |
| 2413 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w)); |
| 2414 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002800, 0x002800, 0xbf0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart)); |
| 2415 | | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x002801, 0x002801, 0xbf0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart)); |
| 2416 | | // set_5a22_map(*state->m_maincpu); |
| 2415 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000000, 0x7dffff, read8_delegate(FUNC(snsnew_state::snes21_lo_r),state), write8_delegate(FUNC(snsnew_state::snes21_lo_w),state)); |
| 2416 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x800000, 0xffffff, read8_delegate(FUNC(snsnew_state::snes21_hi_r),state), write8_delegate(FUNC(snsnew_state::snes21_hi_w),state)); |
| 2417 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002800, 0x002800, 0xbf0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart)); |
| 2418 | // machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x002801, 0x002801, 0xbf0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart)); |
| 2419 | // set_5a22_map(*state->m_maincpu); |
| 2417 | 2420 | break; |
| 2418 | 2421 | } |
| 2419 | 2422 | } |