trunk/src/mess/drivers/snes.c
| r21593 | r21594 | |
| 40 | 40 | |
| 41 | 41 | #define MAX_SNES_CART_SIZE 0x600000 |
| 42 | 42 | |
| 43 | class snes_console_state : public snes_state |
| 44 | { |
| 45 | public: |
| 46 | snes_console_state(const machine_config &mconfig, device_type type, const char *tag) |
| 47 | : snes_state(mconfig, type, tag) |
| 48 | { } |
| 49 | |
| 50 | DECLARE_READ8_MEMBER( spc_ram_100_r ); |
| 51 | DECLARE_WRITE8_MEMBER( spc_ram_100_w ); |
| 52 | UINT8 st010_read_ram(UINT16 addr); |
| 53 | void st010_write_ram(UINT16 addr, UINT8 data); |
| 54 | DECLARE_READ8_MEMBER( snes_lo_r ); |
| 55 | DECLARE_READ8_MEMBER( snes_hi_r ); |
| 56 | DECLARE_WRITE8_MEMBER( snes_lo_w ); |
| 57 | DECLARE_WRITE8_MEMBER( snes_hi_w ); |
| 58 | DECLARE_READ8_MEMBER( superfx_r_bank1 ); |
| 59 | DECLARE_READ8_MEMBER( superfx_r_bank2 ); |
| 60 | DECLARE_READ8_MEMBER( superfx_r_bank3 ); |
| 61 | DECLARE_WRITE8_MEMBER( superfx_w_bank3 ); |
| 62 | CUSTOM_INPUT_MEMBER( snes_mouse_speed_input ); |
| 63 | CUSTOM_INPUT_MEMBER( snes_superscope_offscreen_input ); |
| 64 | TIMER_CALLBACK_MEMBER( lightgun_tick ); |
| 65 | void snes_gun_latch( INT16 x, INT16 y ); |
| 66 | void snes_input_read_joy( int port ); |
| 67 | void snes_input_read_mouse( int port ); |
| 68 | void snes_input_read_superscope( int port ); |
| 69 | DECLARE_WRITE8_MEMBER(snes_input_read); |
| 70 | DECLARE_READ8_MEMBER(snes_oldjoy1_read); |
| 71 | DECLARE_READ8_MEMBER(snes_oldjoy2_read); |
| 72 | }; |
| 43 | 73 | |
| 44 | 74 | /************************************* |
| 45 | 75 | * |
| r21593 | r21594 | |
| 47 | 77 | * |
| 48 | 78 | *************************************/ |
| 49 | 79 | |
| 50 | | static READ8_DEVICE_HANDLER( spc_ram_100_r ) |
| 80 | READ8_MEMBER(snes_console_state::spc_ram_100_r ) |
| 51 | 81 | { |
| 52 | | return spc_ram_r(device, space, offset + 0x100); |
| 82 | return spc_ram_r(machine().device("spc700"), space, offset + 0x100); |
| 53 | 83 | } |
| 54 | 84 | |
| 55 | | static WRITE8_DEVICE_HANDLER( spc_ram_100_w ) |
| 85 | WRITE8_MEMBER(snes_console_state::spc_ram_100_w ) |
| 56 | 86 | { |
| 57 | | spc_ram_w(device, space, offset + 0x100, data); |
| 87 | spc_ram_w(machine().device("spc700"), space, offset + 0x100, data); |
| 58 | 88 | } |
| 59 | 89 | |
| 60 | 90 | // DSP accessors |
| 61 | | #define dsp_get_sr() state->m_upd7725->snesdsp_read(false) |
| 62 | | #define dsp_get_dr() state->m_upd7725->snesdsp_read(true) |
| 63 | | #define dsp_set_sr(data) state->m_upd7725->snesdsp_write(false, data) |
| 64 | | #define dsp_set_dr(data) state->m_upd7725->snesdsp_write(true, data) |
| 91 | #define dsp_get_sr() m_upd7725->snesdsp_read(false) |
| 92 | #define dsp_get_dr() m_upd7725->snesdsp_read(true) |
| 93 | #define dsp_set_sr(data) m_upd7725->snesdsp_write(false, data) |
| 94 | #define dsp_set_dr(data) m_upd7725->snesdsp_write(true, data) |
| 65 | 95 | |
| 66 | | #define st010_get_sr() state->m_upd96050->snesdsp_read(false) |
| 67 | | #define st010_get_dr() state->m_upd96050->snesdsp_read(true) |
| 68 | | #define st010_set_sr(data) state->m_upd96050->snesdsp_write(false, data) |
| 69 | | #define st010_set_dr(data) state->m_upd96050->snesdsp_write(true, data) |
| 96 | #define st010_get_sr() m_upd96050->snesdsp_read(false) |
| 97 | #define st010_get_dr() m_upd96050->snesdsp_read(true) |
| 98 | #define st010_set_sr(data) m_upd96050->snesdsp_write(false, data) |
| 99 | #define st010_set_dr(data) m_upd96050->snesdsp_write(true, data) |
| 70 | 100 | |
| 71 | 101 | // ST-010 and ST-011 RAM interface |
| 72 | | UINT8 st010_read_ram(snes_state *state, UINT16 addr) |
| 102 | UINT8 snes_console_state::st010_read_ram(UINT16 addr) |
| 73 | 103 | { |
| 74 | | UINT16 temp = state->m_upd96050->dataram_r(addr/2); |
| 104 | UINT16 temp = m_upd96050->dataram_r(addr/2); |
| 75 | 105 | UINT8 res; |
| 76 | | |
| 106 | |
| 77 | 107 | if (addr & 1) |
| 78 | 108 | { |
| 79 | 109 | res = temp>>8; |
| r21593 | r21594 | |
| 82 | 112 | { |
| 83 | 113 | res = temp & 0xff; |
| 84 | 114 | } |
| 85 | | |
| 115 | |
| 86 | 116 | return res; |
| 87 | 117 | } |
| 88 | 118 | |
| 89 | | void st010_write_ram(snes_state *state, UINT16 addr, UINT8 data) |
| 119 | void snes_console_state::st010_write_ram(UINT16 addr, UINT8 data) |
| 90 | 120 | { |
| 91 | | UINT16 temp = state->m_upd96050->dataram_r(addr/2); |
| 92 | | |
| 121 | UINT16 temp = m_upd96050->dataram_r(addr/2); |
| 122 | |
| 93 | 123 | if (addr & 1) |
| 94 | 124 | { |
| 95 | 125 | temp &= 0xff; |
| r21593 | r21594 | |
| 100 | 130 | temp &= 0xff00; |
| 101 | 131 | temp |= data; |
| 102 | 132 | } |
| 103 | | |
| 104 | | state->m_upd96050->dataram_w(addr/2, temp); |
| 133 | |
| 134 | m_upd96050->dataram_w(addr/2, temp); |
| 105 | 135 | } |
| 106 | 136 | |
| 107 | 137 | |
| 108 | | static READ8_HANDLER( snes_lo_r ) |
| 109 | | { |
| 110 | | snes_state *state = space.machine().driver_data<snes_state>(); |
| 138 | READ8_MEMBER( snes_console_state::snes_lo_r ) |
| 139 | { |
| 111 | 140 | UINT16 address = offset & 0xffff; |
| 112 | 141 | |
| 113 | 142 | // take care of add-on chip access |
| 114 | | if (state->m_has_addon_chip == HAS_OBC1 |
| 143 | if (m_has_addon_chip == HAS_OBC1 |
| 115 | 144 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 116 | 145 | return obc1_read(space, offset, mem_mask); |
| 117 | | if (state->m_has_addon_chip == HAS_CX4 |
| 146 | if (m_has_addon_chip == HAS_CX4 |
| 118 | 147 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 119 | 148 | return CX4_read(address - 0x6000); |
| 120 | | if (state->m_has_addon_chip == HAS_RTC |
| 149 | if (m_has_addon_chip == HAS_RTC |
| 121 | 150 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 122 | 151 | return srtc_read(space, offset); |
| 123 | | if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011) |
| 152 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 124 | 153 | { |
| 125 | 154 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 126 | | return st010_read_ram(state, address); |
| 155 | return st010_read_ram(address); |
| 127 | 156 | if (offset == 0x600000 || offset == 0x600001) |
| 128 | 157 | return (offset & 1) ? st010_get_sr() : st010_get_dr(); |
| 129 | 158 | } |
| 130 | | if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1 |
| 159 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 131 | 160 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 132 | 161 | return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr(); |
| 133 | | if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1) |
| 162 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 134 | 163 | { |
| 135 | 164 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 136 | 165 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 137 | 166 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 138 | 167 | return (address < 0x4000) ? dsp_get_dr() : dsp_get_sr(); |
| 139 | | } |
| 140 | | if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3) |
| 168 | } |
| 169 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 141 | 170 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 142 | 171 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 143 | | if (state->m_has_addon_chip == HAS_DSP4 |
| 172 | if (m_has_addon_chip == HAS_DSP4 |
| 144 | 173 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 145 | 174 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 146 | | if (state->m_has_addon_chip == HAS_SDD1 |
| 175 | if (m_has_addon_chip == HAS_SDD1 |
| 147 | 176 | && (offset < 0x400000 && address >= 0x4800 && address < 0x4808)) |
| 148 | 177 | return sdd1_mmio_read(space, (UINT32)address); |
| 149 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 178 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 150 | 179 | && offset < 0x400000) |
| 151 | | { |
| 152 | | UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 180 | { |
| 181 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 153 | 182 | if (address >= 0x4800 && address <= limit) |
| 154 | 183 | return spc7110_mmio_read(space, (UINT32)address); |
| 155 | 184 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| r21593 | r21594 | |
| 157 | 186 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 158 | 187 | return snes_ram[0x306000 + (address & 0x1fff)]; |
| 159 | 188 | } |
| 160 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 189 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 161 | 190 | && offset >= 0x500000 && offset < 0x510000) |
| 162 | 191 | return spc7110_mmio_read(space, 0x4800); |
| 163 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 192 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 164 | 193 | && offset < 0x400000) |
| 165 | | { |
| 194 | { |
| 166 | 195 | if (address >= 0x3000 && address < 0x3300) |
| 167 | | return superfx_mmio_read(state->m_superfx, address); |
| 168 | | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 169 | | return superfx_access_ram(state->m_superfx) ? snes_ram[0xf00000 + (offset & 0x1fff)] : snes_open_bus_r(space, 0); |
| 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 |
| 198 | return superfx_access_ram(m_superfx) ? snes_ram[0xf00000 + (offset & 0x1fff)] : snes_open_bus_r(space, 0); |
| 170 | 199 | } |
| 171 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 200 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 172 | 201 | && offset >= 0x400000 && offset < 0x600000) |
| 173 | 202 | { |
| 174 | | if (superfx_access_rom(state->m_superfx)) |
| 203 | if (superfx_access_rom(m_superfx)) |
| 175 | 204 | return snes_ram[offset]; |
| 176 | 205 | else |
| 177 | 206 | { |
| r21593 | r21594 | |
| 182 | 211 | return sfx_data[offset & 0x0f]; |
| 183 | 212 | } |
| 184 | 213 | } |
| 185 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 214 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 186 | 215 | && offset >= 0x600000) |
| 187 | | return superfx_access_ram(state->m_superfx) ? snes_ram[0x800000 + offset] : snes_open_bus_r(space, 0); |
| 188 | | |
| 216 | return superfx_access_ram(m_superfx) ? snes_ram[0x800000 + offset] : snes_open_bus_r(space, 0); |
| 217 | |
| 189 | 218 | // base cart access |
| 190 | 219 | if (offset < 0x300000) |
| 191 | 220 | return snes_r_bank1(space, offset, 0xff); |
| r21593 | r21594 | |
| 197 | 226 | return snes_r_bank4(space, offset - 0x600000, 0xff); |
| 198 | 227 | else |
| 199 | 228 | return snes_r_bank5(space, offset - 0x700000, 0xff); |
| 200 | | } |
| 229 | } |
| 201 | 230 | |
| 202 | | static READ8_HANDLER( snes_hi_r ) |
| 231 | READ8_MEMBER( snes_console_state::snes_hi_r ) |
| 203 | 232 | { |
| 204 | | snes_state *state = space.machine().driver_data<snes_state>(); |
| 205 | 233 | UINT16 address = offset & 0xffff; |
| 206 | | |
| 234 | |
| 207 | 235 | // take care of add-on chip access |
| 208 | | if (state->m_has_addon_chip == HAS_OBC1 |
| 236 | if (m_has_addon_chip == HAS_OBC1 |
| 209 | 237 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 210 | 238 | return obc1_read(space, offset, mem_mask); |
| 211 | | if (state->m_has_addon_chip == HAS_CX4 |
| 239 | if (m_has_addon_chip == HAS_CX4 |
| 212 | 240 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 213 | 241 | return CX4_read(address - 0x6000); |
| 214 | | if (state->m_has_addon_chip == HAS_RTC |
| 242 | if (m_has_addon_chip == HAS_RTC |
| 215 | 243 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 216 | 244 | return srtc_read(space, offset); |
| 217 | | if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011) |
| 245 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 218 | 246 | { |
| 219 | 247 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 220 | | return st010_read_ram(state, address); |
| 248 | return st010_read_ram(address); |
| 221 | 249 | if (offset == 0x600000 || offset == 0x600001) |
| 222 | 250 | return (offset & 1) ? st010_get_sr() : st010_get_dr(); |
| 223 | 251 | } |
| 224 | | if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1 |
| 252 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 225 | 253 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 226 | 254 | return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr(); |
| 227 | | if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1) |
| 255 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 228 | 256 | { |
| 229 | 257 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 230 | 258 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 231 | 259 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 232 | 260 | return (address < 0x4000) ? dsp_get_dr() : dsp_get_sr(); |
| 233 | 261 | } |
| 234 | | if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3) |
| 262 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 235 | 263 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 236 | 264 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 237 | | if (state->m_has_addon_chip == HAS_DSP4 |
| 265 | if (m_has_addon_chip == HAS_DSP4 |
| 238 | 266 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 239 | 267 | return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr(); |
| 240 | | if (state->m_has_addon_chip == HAS_SDD1 |
| 268 | if (m_has_addon_chip == HAS_SDD1 |
| 241 | 269 | && (offset < 0x400000 && address >= 0x4800 && address < 0x4808)) |
| 242 | 270 | return sdd1_mmio_read(space, (UINT32)address); |
| 243 | | if (state->m_has_addon_chip == HAS_SDD1 && offset >= 0x400000) |
| 271 | if (m_has_addon_chip == HAS_SDD1 && offset >= 0x400000) |
| 244 | 272 | return sdd1_read(space.machine(), offset - 0x400000); |
| 245 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 273 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 246 | 274 | && offset < 0x400000) |
| 247 | | { |
| 248 | | UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 275 | { |
| 276 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 249 | 277 | if (address >= 0x4800 && address <= limit) |
| 250 | 278 | return spc7110_mmio_read(space, (UINT32)address); |
| 251 | 279 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| r21593 | r21594 | |
| 253 | 281 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 254 | 282 | return snes_ram[0x306000 + (address & 0x1fff)]; |
| 255 | 283 | } |
| 256 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 284 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) |
| 257 | 285 | && offset >= 0x500000) |
| 258 | 286 | return spc7110_bank7_read(space, offset - 0x400000); |
| 259 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 260 | | return space.read_byte(offset); // [80-ff] same as [00-7f] |
| 261 | | |
| 287 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL) |
| 288 | return space.read_byte(offset); // [80-ff] same as [00-7f] |
| 289 | |
| 262 | 290 | // base cart access |
| 263 | 291 | if (offset < 0x400000) |
| 264 | 292 | return snes_r_bank6(space, offset, 0xff); |
| 265 | 293 | else |
| 266 | 294 | return snes_r_bank7(space, offset - 0x400000, 0xff); |
| 267 | | } |
| 295 | } |
| 268 | 296 | |
| 269 | | static WRITE8_HANDLER( snes_lo_w ) |
| 297 | WRITE8_MEMBER( snes_console_state::snes_lo_w ) |
| 270 | 298 | { |
| 271 | | snes_state *state = space.machine().driver_data<snes_state>(); |
| 272 | 299 | UINT16 address = offset & 0xffff; |
| 273 | | |
| 300 | |
| 274 | 301 | // take care of add-on chip access |
| 275 | | if (state->m_has_addon_chip == HAS_OBC1 |
| 302 | if (m_has_addon_chip == HAS_OBC1 |
| 276 | 303 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 277 | | { obc1_write(space, offset, data, mem_mask); return; } |
| 278 | | if (state->m_has_addon_chip == HAS_CX4 |
| 304 | { obc1_write(space, offset, data, mem_mask); return; } |
| 305 | if (m_has_addon_chip == HAS_CX4 |
| 279 | 306 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 280 | | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 281 | | if (state->m_has_addon_chip == HAS_RTC |
| 307 | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 308 | if (m_has_addon_chip == HAS_RTC |
| 282 | 309 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 283 | | { srtc_write(space.machine(), offset, data); return; } |
| 284 | | if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011) |
| 310 | { srtc_write(space.machine(), offset, data); return; } |
| 311 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 285 | 312 | { |
| 286 | 313 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 287 | | { st010_write_ram(state, address, data); return; } |
| 314 | { st010_write_ram(address, data); return; } |
| 288 | 315 | if (offset == 0x600000) |
| 289 | | { st010_set_dr(data); return; } |
| 316 | { st010_set_dr(data); return; } |
| 290 | 317 | if (offset == 0x600001) |
| 291 | | { st010_set_sr(data); return; } |
| 318 | { st010_set_sr(data); return; } |
| 292 | 319 | } |
| 293 | | if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1 |
| 320 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 294 | 321 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 295 | | { dsp_set_dr(data); return; } |
| 296 | | if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1) |
| 322 | { dsp_set_dr(data); return; } |
| 323 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 297 | 324 | { |
| 298 | 325 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 299 | | { dsp_set_dr(data); return; } |
| 326 | { dsp_set_dr(data); return; } |
| 300 | 327 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 301 | | { dsp_set_dr(data); return; } |
| 328 | { dsp_set_dr(data); return; } |
| 302 | 329 | } |
| 303 | | if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3) |
| 330 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 304 | 331 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 305 | 332 | { |
| 306 | 333 | if (address < 0xc000) |
| 307 | | { dsp_set_dr(data); return; } |
| 334 | { dsp_set_dr(data); return; } |
| 308 | 335 | else |
| 309 | | { dsp_set_sr(data); return; } |
| 336 | { dsp_set_sr(data); return; } |
| 310 | 337 | } |
| 311 | | if (state->m_has_addon_chip == HAS_DSP4 |
| 338 | if (m_has_addon_chip == HAS_DSP4 |
| 312 | 339 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 313 | 340 | { |
| 314 | 341 | if (address < 0xc000) |
| 315 | | { dsp_set_dr(data); return; } |
| 342 | { dsp_set_dr(data); return; } |
| 316 | 343 | else |
| 317 | | { dsp_set_sr(data); return; } |
| 344 | { dsp_set_sr(data); return; } |
| 318 | 345 | } |
| 319 | | if (state->m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 346 | if (m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 320 | 347 | { |
| 321 | 348 | if ((address >= 0x4300 && address < 0x4380) || (address >= 0x4800 && address < 0x4808)) |
| 322 | 349 | { |
| r21593 | r21594 | |
| 324 | 351 | // here we don't return, but we let the w_io happen... |
| 325 | 352 | } |
| 326 | 353 | } |
| 327 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 328 | | { |
| 329 | | UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 354 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 355 | { |
| 356 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 330 | 357 | if (address >= 0x4800 && address <= limit) |
| 331 | | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 358 | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 332 | 359 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| 333 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 360 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 334 | 361 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 335 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 362 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 336 | 363 | } |
| 337 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 338 | | && offset < 0x400000) |
| 339 | | { |
| 364 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 365 | && offset < 0x400000) |
| 366 | { |
| 340 | 367 | if (address >= 0x3000 && address < 0x3300) |
| 341 | | { superfx_mmio_write(state->m_superfx, address, data); return; } |
| 342 | | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 343 | | { 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; } |
| 344 | 371 | } |
| 345 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 372 | if (m_has_addon_chip == HAS_SUPERFX && m_superfx != NULL |
| 346 | 373 | && offset >= 0x600000) |
| 347 | | { snes_ram[0x800000 + offset] = data; return; } |
| 348 | | |
| 374 | { snes_ram[0x800000 + offset] = data; return; } |
| 375 | |
| 349 | 376 | // base cart access |
| 350 | 377 | if (offset < 0x300000) |
| 351 | 378 | snes_w_bank1(space, offset, data, 0xff); |
| r21593 | r21594 | |
| 357 | 384 | snes_w_bank4(space, offset - 0x600000, data, 0xff); |
| 358 | 385 | else |
| 359 | 386 | snes_w_bank5(space, offset - 0x700000, data, 0xff); |
| 360 | | } |
| 387 | } |
| 361 | 388 | |
| 362 | | static WRITE8_HANDLER( snes_hi_w ) |
| 389 | WRITE8_MEMBER( snes_console_state::snes_hi_w ) |
| 363 | 390 | { |
| 364 | | snes_state *state = space.machine().driver_data<snes_state>(); |
| 365 | 391 | UINT16 address = offset & 0xffff; |
| 366 | | |
| 392 | |
| 367 | 393 | // take care of add-on chip access |
| 368 | | if (state->m_has_addon_chip == HAS_OBC1 |
| 394 | if (m_has_addon_chip == HAS_OBC1 |
| 369 | 395 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 370 | | { obc1_write(space, offset, data, mem_mask); return; } |
| 371 | | if (state->m_has_addon_chip == HAS_CX4 |
| 396 | { obc1_write(space, offset, data, mem_mask); return; } |
| 397 | if (m_has_addon_chip == HAS_CX4 |
| 372 | 398 | && (offset < 0x400000 && address >= 0x6000 && address < 0x8000)) |
| 373 | | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 374 | | if (state->m_has_addon_chip == HAS_RTC |
| 399 | { CX4_write(space.machine(), address - 0x6000, data); return; } |
| 400 | if (m_has_addon_chip == HAS_RTC |
| 375 | 401 | && (offset < 0x400000 && (address == 0x2800 || address == 0x2801))) |
| 376 | | { srtc_write(space.machine(), offset, data); return; } |
| 377 | | if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011) |
| 402 | { srtc_write(space.machine(), offset, data); return; } |
| 403 | if (m_has_addon_chip == HAS_ST010 || m_has_addon_chip == HAS_ST011) |
| 378 | 404 | { |
| 379 | 405 | if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000) |
| 380 | | { st010_write_ram(state, address, data); return; } |
| 406 | { st010_write_ram(address, data); return; } |
| 381 | 407 | if (offset == 0x600000) |
| 382 | | { st010_set_dr(data); return; } |
| 408 | { st010_set_dr(data); return; } |
| 383 | 409 | if (offset == 0x600001) |
| 384 | | { st010_set_sr(data); return; } |
| 410 | { st010_set_sr(data); return; } |
| 385 | 411 | } |
| 386 | | if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1 |
| 412 | if (m_cart[0].mode == SNES_MODE_21 && m_has_addon_chip == HAS_DSP1 |
| 387 | 413 | && (offset < 0x200000 && address >= 0x6000 && address < 0x8000)) |
| 388 | | { dsp_set_dr(data); return; } |
| 389 | | if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1) |
| 414 | { dsp_set_dr(data); return; } |
| 415 | if (m_cart[0].mode == SNES_MODE_20 && m_has_addon_chip == HAS_DSP1) |
| 390 | 416 | { |
| 391 | 417 | if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000) |
| 392 | | { dsp_set_dr(data); return; } |
| 418 | { dsp_set_dr(data); return; } |
| 393 | 419 | if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000) |
| 394 | | { dsp_set_dr(data); return; } |
| 395 | | } |
| 396 | | if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3) |
| 420 | { dsp_set_dr(data); return; } |
| 421 | } |
| 422 | if ((m_has_addon_chip == HAS_DSP2 || m_has_addon_chip == HAS_DSP3) |
| 397 | 423 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 398 | 424 | { |
| 399 | 425 | if (address < 0xc000) |
| 400 | | { dsp_set_dr(data); return; } |
| 426 | { dsp_set_dr(data); return; } |
| 401 | 427 | else |
| 402 | | { dsp_set_sr(data); return; } |
| 428 | { dsp_set_sr(data); return; } |
| 403 | 429 | } |
| 404 | | if (state->m_has_addon_chip == HAS_DSP4 |
| 430 | if (m_has_addon_chip == HAS_DSP4 |
| 405 | 431 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 406 | 432 | { |
| 407 | 433 | if (address < 0xc000) |
| 408 | | { dsp_set_dr(data); return; } |
| 434 | { dsp_set_dr(data); return; } |
| 409 | 435 | else |
| 410 | | { dsp_set_sr(data); return; } |
| 436 | { dsp_set_sr(data); return; } |
| 411 | 437 | } |
| 412 | | if (state->m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 438 | if (m_has_addon_chip == HAS_SDD1 && offset < 0x400000) |
| 413 | 439 | { |
| 414 | 440 | if ((address >= 0x4300 && address < 0x4380) || (address >= 0x4800 && address < 0x4808)) |
| 415 | 441 | { |
| r21593 | r21594 | |
| 417 | 443 | // here we don't return, but we let the w_io happen... |
| 418 | 444 | } |
| 419 | 445 | } |
| 420 | | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 421 | | { |
| 422 | | UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 446 | if ((m_has_addon_chip == HAS_SPC7110 || m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000) |
| 447 | { |
| 448 | UINT16 limit = (m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 423 | 449 | if (address >= 0x4800 && address <= limit) |
| 424 | | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 450 | { spc7110_mmio_write(space.machine(), (UINT32)address, data); return; } |
| 425 | 451 | if (offset < 0x10000 && address >= 0x6000 && address < 0x8000) |
| 426 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 452 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 427 | 453 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 428 | | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 454 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 429 | 455 | } |
| 430 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 431 | | { space.write_byte(offset, data); return; } // [80-ff] same as [00-7f] |
| 432 | | |
| 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 | |
| 433 | 459 | // base cart access |
| 434 | 460 | if (offset < 0x400000) |
| 435 | 461 | snes_w_bank6(space, offset, data, 0xff); |
| 436 | 462 | else |
| 437 | 463 | snes_w_bank7(space, offset, data - 0x400000, 0xff); |
| 438 | | } |
| 464 | } |
| 439 | 465 | |
| 440 | | static READ8_HANDLER( superfx_r_bank1 ) |
| 466 | READ8_MEMBER( snes_console_state::superfx_r_bank1 ) |
| 441 | 467 | { |
| 442 | 468 | return snes_ram[offset | 0x8000]; |
| 443 | 469 | } |
| 444 | 470 | |
| 445 | | static READ8_HANDLER( superfx_r_bank2 ) |
| 471 | READ8_MEMBER( snes_console_state::superfx_r_bank2 ) |
| 446 | 472 | { |
| 447 | 473 | return snes_ram[0x400000 + offset]; |
| 448 | 474 | } |
| 449 | 475 | |
| 450 | | static READ8_HANDLER( superfx_r_bank3 ) |
| 476 | READ8_MEMBER( snes_console_state::superfx_r_bank3 ) |
| 451 | 477 | { |
| 452 | 478 | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 453 | 479 | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| r21593 | r21594 | |
| 456 | 482 | return snes_ram[0xe00000 + offset]; |
| 457 | 483 | } |
| 458 | 484 | |
| 459 | | static WRITE8_HANDLER( superfx_w_bank3 ) |
| 485 | WRITE8_MEMBER( snes_console_state::superfx_w_bank3 ) |
| 460 | 486 | { |
| 461 | 487 | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 462 | 488 | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| r21593 | r21594 | |
| 471 | 497 | * |
| 472 | 498 | *************************************/ |
| 473 | 499 | |
| 474 | | static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, snes_state ) |
| 475 | | AM_RANGE(0x000000, 0x7dffff) AM_READWRITE_LEGACY(snes_lo_r, snes_lo_w) |
| 500 | static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, snes_console_state ) |
| 501 | AM_RANGE(0x000000, 0x7dffff) AM_READWRITE(snes_lo_r, snes_lo_w) |
| 476 | 502 | AM_RANGE(0x7e0000, 0x7fffff) AM_RAM /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */ |
| 477 | | AM_RANGE(0x800000, 0xffffff) AM_READWRITE_LEGACY(snes_hi_r, snes_hi_w) |
| 503 | AM_RANGE(0x800000, 0xffffff) AM_READWRITE(snes_hi_r, snes_hi_w) |
| 478 | 504 | ADDRESS_MAP_END |
| 479 | 505 | |
| 480 | | static ADDRESS_MAP_START( superfx_map, AS_PROGRAM, 8, snes_state ) |
| 481 | | AM_RANGE(0x000000, 0x3fffff) AM_READ_LEGACY(superfx_r_bank1) |
| 482 | | AM_RANGE(0x400000, 0x5fffff) AM_READ_LEGACY(superfx_r_bank2) |
| 483 | | AM_RANGE(0x600000, 0x7dffff) AM_READWRITE_LEGACY(superfx_r_bank3, superfx_w_bank3) |
| 484 | | AM_RANGE(0x800000, 0xbfffff) AM_READ_LEGACY(superfx_r_bank1) |
| 485 | | AM_RANGE(0xc00000, 0xdfffff) AM_READ_LEGACY(superfx_r_bank2) |
| 486 | | AM_RANGE(0xe00000, 0xffffff) AM_READWRITE_LEGACY(superfx_r_bank3, superfx_w_bank3) |
| 506 | static ADDRESS_MAP_START( superfx_map, AS_PROGRAM, 8, snes_console_state ) |
| 507 | AM_RANGE(0x000000, 0x3fffff) AM_READ(superfx_r_bank1) |
| 508 | AM_RANGE(0x400000, 0x5fffff) AM_READ(superfx_r_bank2) |
| 509 | AM_RANGE(0x600000, 0x7dffff) AM_READWRITE(superfx_r_bank3, superfx_w_bank3) |
| 510 | AM_RANGE(0x800000, 0xbfffff) AM_READ(superfx_r_bank1) |
| 511 | AM_RANGE(0xc00000, 0xdfffff) AM_READ(superfx_r_bank2) |
| 512 | AM_RANGE(0xe00000, 0xffffff) AM_READWRITE(superfx_r_bank3, superfx_w_bank3) |
| 487 | 513 | ADDRESS_MAP_END |
| 488 | 514 | |
| 489 | | static ADDRESS_MAP_START( spc_map, AS_PROGRAM, 8, snes_state ) |
| 515 | static ADDRESS_MAP_START( spc_map, AS_PROGRAM, 8, snes_console_state ) |
| 490 | 516 | AM_RANGE(0x0000, 0x00ef) AM_DEVREADWRITE_LEGACY("spc700", spc_ram_r, spc_ram_w) /* lower 32k ram */ |
| 491 | 517 | AM_RANGE(0x00f0, 0x00ff) AM_DEVREADWRITE_LEGACY("spc700", spc_io_r, spc_io_w) /* spc io */ |
| 492 | | AM_RANGE(0x0100, 0xffff) AM_DEVREADWRITE_LEGACY("spc700", spc_ram_100_r, spc_ram_100_w) |
| 518 | AM_RANGE(0x0100, 0xffff) AM_READWRITE(spc_ram_100_r, spc_ram_100_w) |
| 493 | 519 | ADDRESS_MAP_END |
| 494 | 520 | |
| 495 | | static ADDRESS_MAP_START( dsp_prg_map, AS_PROGRAM, 32, snes_state ) |
| 521 | static ADDRESS_MAP_START( dsp_prg_map, AS_PROGRAM, 32, snes_console_state ) |
| 496 | 522 | AM_RANGE(0x0000, 0x07ff) AM_ROM AM_REGION("dspprg", 0) |
| 497 | 523 | ADDRESS_MAP_END |
| 498 | 524 | |
| 499 | | static ADDRESS_MAP_START( dsp_data_map, AS_DATA, 16, snes_state ) |
| 525 | static ADDRESS_MAP_START( dsp_data_map, AS_DATA, 16, snes_console_state ) |
| 500 | 526 | AM_RANGE(0x0000, 0x03ff) AM_ROM AM_REGION("dspdata", 0) |
| 501 | 527 | ADDRESS_MAP_END |
| 502 | 528 | |
| 503 | | static ADDRESS_MAP_START( setadsp_prg_map, AS_PROGRAM, 32, snes_state ) |
| 529 | static ADDRESS_MAP_START( setadsp_prg_map, AS_PROGRAM, 32, snes_console_state ) |
| 504 | 530 | AM_RANGE(0x0000, 0x3fff) AM_ROM AM_REGION("dspprg", 0) |
| 505 | 531 | ADDRESS_MAP_END |
| 506 | 532 | |
| 507 | | static ADDRESS_MAP_START( setadsp_data_map, AS_DATA, 16, snes_state ) |
| 533 | static ADDRESS_MAP_START( setadsp_data_map, AS_DATA, 16, snes_console_state ) |
| 508 | 534 | AM_RANGE(0x0000, 0x07ff) AM_ROM AM_REGION("dspdata", 0) |
| 509 | 535 | ADDRESS_MAP_END |
| 510 | 536 | |
| r21593 | r21594 | |
| 514 | 540 | * |
| 515 | 541 | *************************************/ |
| 516 | 542 | |
| 517 | | static CUSTOM_INPUT( snes_mouse_speed_input ) |
| 543 | CUSTOM_INPUT_MEMBER( snes_console_state::snes_mouse_speed_input ) |
| 518 | 544 | { |
| 519 | | snes_state *state = field.machine().driver_data<snes_state>(); |
| 520 | 545 | int port = (FPTR)param; |
| 521 | 546 | |
| 522 | | if (state->m_oldjoy1_latch & 0x1) |
| 547 | if (m_oldjoy1_latch & 0x1) |
| 523 | 548 | { |
| 524 | | state->m_mouse[port].speed++; |
| 525 | | if ((state->m_mouse[port].speed & 0x03) == 0x03) |
| 526 | | state->m_mouse[port].speed = 0; |
| 549 | m_mouse[port].speed++; |
| 550 | if ((m_mouse[port].speed & 0x03) == 0x03) |
| 551 | m_mouse[port].speed = 0; |
| 527 | 552 | } |
| 528 | 553 | |
| 529 | | return state->m_mouse[port].speed; |
| 554 | return m_mouse[port].speed; |
| 530 | 555 | } |
| 531 | 556 | |
| 532 | | static CUSTOM_INPUT( snes_superscope_offscreen_input ) |
| 557 | CUSTOM_INPUT_MEMBER( snes_console_state::snes_superscope_offscreen_input ) |
| 533 | 558 | { |
| 534 | | snes_state *state = field.machine().driver_data<snes_state>(); |
| 535 | 559 | int port = (FPTR)param; |
| 536 | 560 | static const char *const portnames[2][3] = |
| 537 | 561 | { |
| r21593 | r21594 | |
| 539 | 563 | { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, |
| 540 | 564 | }; |
| 541 | 565 | |
| 542 | | INT16 x = field.machine().root_device().ioport(portnames[port][1])->read(); |
| 543 | | INT16 y = field.machine().root_device().ioport(portnames[port][2])->read(); |
| 566 | INT16 x = ioport(portnames[port][1])->read(); |
| 567 | INT16 y = ioport(portnames[port][2])->read(); |
| 544 | 568 | |
| 545 | 569 | /* these are the theoretical boundaries, but we currently are always onscreen... */ |
| 546 | | if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= state->m_ppu.m_beam.last_visible_line) |
| 547 | | state->m_scope[port].offscreen = 1; |
| 570 | if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= m_ppu.m_beam.last_visible_line) |
| 571 | m_scope[port].offscreen = 1; |
| 548 | 572 | else |
| 549 | | state->m_scope[port].offscreen = 0; |
| 573 | m_scope[port].offscreen = 0; |
| 550 | 574 | |
| 551 | | return state->m_scope[port].offscreen; |
| 575 | return m_scope[port].offscreen; |
| 552 | 576 | } |
| 553 | 577 | |
| 554 | | static TIMER_CALLBACK( lightgun_tick ) |
| 578 | TIMER_CALLBACK_MEMBER( snes_console_state::lightgun_tick ) |
| 555 | 579 | { |
| 556 | | if ((machine.root_device().ioport("CTRLSEL")->read() & 0x0f) == 0x03 || (machine.root_device().ioport("CTRLSEL")->read() & 0x0f) == 0x04) { |
| 580 | if ((ioport("CTRLSEL")->read() & 0x0f) == 0x03 || (ioport("CTRLSEL")->read() & 0x0f) == 0x04) { |
| 557 | 581 | /* enable lightpen crosshair */ |
| 558 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 582 | crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL); |
| 559 | 583 | } |
| 560 | 584 | else |
| 561 | 585 | { |
| 562 | 586 | /* disable lightpen crosshair */ |
| 563 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 587 | crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE); |
| 564 | 588 | } |
| 565 | 589 | |
| 566 | | if ((machine.root_device().ioport("CTRLSEL")->read() & 0xf0) == 0x30 || (machine.root_device().ioport("CTRLSEL")->read() & 0xf0) == 0x40) |
| 590 | if ((ioport("CTRLSEL")->read() & 0xf0) == 0x30 || (ioport("CTRLSEL")->read() & 0xf0) == 0x40) |
| 567 | 591 | { |
| 568 | 592 | /* enable lightpen crosshair */ |
| 569 | | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL); |
| 593 | crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL); |
| 570 | 594 | } |
| 571 | 595 | else |
| 572 | 596 | { |
| 573 | 597 | /* disable lightpen crosshair */ |
| 574 | | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE); |
| 598 | crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE); |
| 575 | 599 | } |
| 576 | 600 | } |
| 577 | 601 | |
| r21593 | r21594 | |
| 626 | 650 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 627 | 651 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 628 | 652 | /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */ |
| 629 | | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(snes_mouse_speed_input, (void *)0) |
| 653 | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)0) |
| 630 | 654 | /* bits 6,7 = mouse buttons */ |
| 631 | 655 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Mouse Button Left") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 632 | 656 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Mouse Button Right") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| r21593 | r21594 | |
| 644 | 668 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 645 | 669 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 646 | 670 | /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */ |
| 647 | | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(snes_mouse_speed_input, (void *)1) |
| 671 | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)1) |
| 648 | 672 | /* bits 6,7 = mouse buttons */ |
| 649 | 673 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Mouse Button Left") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 650 | 674 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Mouse Button Right") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| r21593 | r21594 | |
| 659 | 683 | static INPUT_PORTS_START( snes_superscope ) |
| 660 | 684 | PORT_START("SUPERSCOPE1") |
| 661 | 685 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // Noise |
| 662 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(snes_superscope_offscreen_input, (void *)0) |
| 686 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)0) |
| 663 | 687 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 664 | 688 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 665 | 689 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port1 Superscope Pause") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| r21593 | r21594 | |
| 675 | 699 | |
| 676 | 700 | PORT_START("SUPERSCOPE2") |
| 677 | 701 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // Noise |
| 678 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(snes_superscope_offscreen_input, (void *)1) |
| 702 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)1) |
| 679 | 703 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 680 | 704 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 681 | 705 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port2 Superscope Pause") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| r21593 | r21594 | |
| 776 | 800 | * |
| 777 | 801 | *************************************/ |
| 778 | 802 | |
| 779 | | static void snes_gun_latch( running_machine &machine, INT16 x, INT16 y ) |
| 803 | void snes_console_state::snes_gun_latch( INT16 x, INT16 y ) |
| 780 | 804 | { |
| 781 | | snes_state *state = machine.driver_data<snes_state>(); |
| 782 | 805 | /* these are the theoretical boundaries */ |
| 783 | 806 | if (x < 0) |
| 784 | 807 | x = 0; |
| r21593 | r21594 | |
| 787 | 810 | |
| 788 | 811 | if (y < 0) |
| 789 | 812 | y = 0; |
| 790 | | if (y > (state->m_ppu.m_beam.last_visible_line - 1)) |
| 791 | | y = state->m_ppu.m_beam.last_visible_line - 1; |
| 813 | if (y > (m_ppu.m_beam.last_visible_line - 1)) |
| 814 | y = m_ppu.m_beam.last_visible_line - 1; |
| 792 | 815 | |
| 793 | | state->m_ppu.m_beam.latch_horz = x; |
| 794 | | state->m_ppu.m_beam.latch_vert = y; |
| 795 | | state->m_ppu.m_stat78 |= 0x40; |
| 816 | m_ppu.m_beam.latch_horz = x; |
| 817 | m_ppu.m_beam.latch_vert = y; |
| 818 | m_ppu.m_stat78 |= 0x40; |
| 796 | 819 | } |
| 797 | 820 | |
| 798 | | static void snes_input_read_joy( running_machine &machine, int port ) |
| 821 | void snes_console_state::snes_input_read_joy( int port ) |
| 799 | 822 | { |
| 800 | | snes_state *state = machine.driver_data<snes_state>(); |
| 801 | 823 | static const char *const portnames[2][4] = |
| 802 | 824 | { |
| 803 | 825 | { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" }, |
| 804 | 826 | { "SERIAL2_DATA1_L", "SERIAL2_DATA1_H", "SERIAL2_DATA2_L", "SERIAL2_DATA2_H" }, |
| 805 | 827 | }; |
| 806 | 828 | |
| 807 | | state->m_data1[port] = machine.root_device().ioport(portnames[port][0])->read() | (machine.root_device().ioport(portnames[port][1])->read() << 8); |
| 808 | | state->m_data2[port] = machine.root_device().ioport(portnames[port][2])->read() | (machine.root_device().ioport(portnames[port][3])->read() << 8); |
| 829 | m_data1[port] = ioport(portnames[port][0])->read() | (ioport(portnames[port][1])->read() << 8); |
| 830 | m_data2[port] = ioport(portnames[port][2])->read() | (ioport(portnames[port][3])->read() << 8); |
| 809 | 831 | |
| 810 | 832 | // avoid sending signals that could crash games |
| 811 | 833 | // if left, no right |
| 812 | | if (state->m_data1[port] & 0x200) |
| 813 | | state->m_data1[port] &= ~0x100; |
| 834 | if (m_data1[port] & 0x200) |
| 835 | m_data1[port] &= ~0x100; |
| 814 | 836 | // if up, no down |
| 815 | | if (state->m_data1[port] & 0x800) |
| 816 | | state->m_data1[port] &= ~0x400; |
| 837 | if (m_data1[port] & 0x800) |
| 838 | m_data1[port] &= ~0x400; |
| 817 | 839 | |
| 818 | | state->m_joypad[port].buttons = state->m_data1[port]; |
| 840 | m_joypad[port].buttons = m_data1[port]; |
| 819 | 841 | } |
| 820 | 842 | |
| 821 | | static void snes_input_read_mouse( running_machine &machine, int port ) |
| 843 | void snes_console_state::snes_input_read_mouse( int port ) |
| 822 | 844 | { |
| 823 | | snes_state *state = machine.driver_data<snes_state>(); |
| 824 | 845 | INT16 var; |
| 825 | 846 | static const char *const portnames[2][3] = |
| 826 | 847 | { |
| r21593 | r21594 | |
| 828 | 849 | { "MOUSE2", "MOUSE2_X", "MOUSE2_Y" }, |
| 829 | 850 | }; |
| 830 | 851 | |
| 831 | | state->m_mouse[port].buttons = machine.root_device().ioport(portnames[port][0])->read(); |
| 832 | | state->m_mouse[port].x = machine.root_device().ioport(portnames[port][1])->read(); |
| 833 | | state->m_mouse[port].y = machine.root_device().ioport(portnames[port][2])->read(); |
| 834 | | var = state->m_mouse[port].x - state->m_mouse[port].oldx; |
| 852 | m_mouse[port].buttons = ioport(portnames[port][0])->read(); |
| 853 | m_mouse[port].x = ioport(portnames[port][1])->read(); |
| 854 | m_mouse[port].y = ioport(portnames[port][2])->read(); |
| 855 | var = m_mouse[port].x - m_mouse[port].oldx; |
| 835 | 856 | |
| 836 | 857 | if (var < -127) |
| 837 | 858 | { |
| 838 | | state->m_mouse[port].deltax = 0xff; |
| 839 | | state->m_mouse[port].oldx -= 127; |
| 859 | m_mouse[port].deltax = 0xff; |
| 860 | m_mouse[port].oldx -= 127; |
| 840 | 861 | } |
| 841 | 862 | else if (var < 0) |
| 842 | 863 | { |
| 843 | | state->m_mouse[port].deltax = 0x80 | (-var); |
| 844 | | state->m_mouse[port].oldx = state->m_mouse[port].x; |
| 864 | m_mouse[port].deltax = 0x80 | (-var); |
| 865 | m_mouse[port].oldx = m_mouse[port].x; |
| 845 | 866 | } |
| 846 | 867 | else if (var > 127) |
| 847 | 868 | { |
| 848 | | state->m_mouse[port].deltax = 0x7f; |
| 849 | | state->m_mouse[port].oldx += 127; |
| 869 | m_mouse[port].deltax = 0x7f; |
| 870 | m_mouse[port].oldx += 127; |
| 850 | 871 | } |
| 851 | 872 | else |
| 852 | 873 | { |
| 853 | | state->m_mouse[port].deltax = var & 0xff; |
| 854 | | state->m_mouse[port].oldx = state->m_mouse[port].x; |
| 874 | m_mouse[port].deltax = var & 0xff; |
| 875 | m_mouse[port].oldx = m_mouse[port].x; |
| 855 | 876 | } |
| 856 | 877 | |
| 857 | | var = state->m_mouse[port].y - state->m_mouse[port].oldy; |
| 878 | var = m_mouse[port].y - m_mouse[port].oldy; |
| 858 | 879 | |
| 859 | 880 | if (var < -127) |
| 860 | 881 | { |
| 861 | | state->m_mouse[port].deltay = 0xff; |
| 862 | | state->m_mouse[port].oldy -= 127; |
| 882 | m_mouse[port].deltay = 0xff; |
| 883 | m_mouse[port].oldy -= 127; |
| 863 | 884 | } |
| 864 | 885 | else if (var < 0) |
| 865 | 886 | { |
| 866 | | state->m_mouse[port].deltay = 0x80 | (-var); |
| 867 | | state->m_mouse[port].oldy = state->m_mouse[port].y; |
| 887 | m_mouse[port].deltay = 0x80 | (-var); |
| 888 | m_mouse[port].oldy = m_mouse[port].y; |
| 868 | 889 | } |
| 869 | 890 | else if (var > 127) |
| 870 | 891 | { |
| 871 | | state->m_mouse[port].deltay = 0x7f; |
| 872 | | state->m_mouse[port].oldy += 127; |
| 892 | m_mouse[port].deltay = 0x7f; |
| 893 | m_mouse[port].oldy += 127; |
| 873 | 894 | } |
| 874 | 895 | else |
| 875 | 896 | { |
| 876 | | state->m_mouse[port].deltay = var & 0xff; |
| 877 | | state->m_mouse[port].oldy = state->m_mouse[port].y; |
| 897 | m_mouse[port].deltay = var & 0xff; |
| 898 | m_mouse[port].oldy = m_mouse[port].y; |
| 878 | 899 | } |
| 879 | 900 | |
| 880 | | state->m_data1[port] = state->m_mouse[port].buttons | (0x00 << 8); |
| 881 | | state->m_data2[port] = 0; |
| 901 | m_data1[port] = m_mouse[port].buttons | (0x00 << 8); |
| 902 | m_data2[port] = 0; |
| 882 | 903 | } |
| 883 | 904 | |
| 884 | | static void snes_input_read_superscope( running_machine &machine, int port ) |
| 905 | void snes_console_state::snes_input_read_superscope( int port ) |
| 885 | 906 | { |
| 886 | | snes_state *state = machine.driver_data<snes_state>(); |
| 887 | 907 | static const char *const portnames[2][3] = |
| 888 | 908 | { |
| 889 | 909 | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| r21593 | r21594 | |
| 892 | 912 | UINT8 input; |
| 893 | 913 | |
| 894 | 914 | /* first read input bits */ |
| 895 | | state->m_scope[port].x = machine.root_device().ioport(portnames[port][1])->read(); |
| 896 | | state->m_scope[port].y = machine.root_device().ioport(portnames[port][2])->read(); |
| 897 | | input = machine.root_device().ioport(portnames[port][0])->read(); |
| 915 | m_scope[port].x = ioport(portnames[port][1])->read(); |
| 916 | m_scope[port].y = ioport(portnames[port][2])->read(); |
| 917 | input = ioport(portnames[port][0])->read(); |
| 898 | 918 | |
| 899 | 919 | /* then start elaborating input bits: only keep old turbo value */ |
| 900 | | state->m_scope[port].buttons &= 0x20; |
| 920 | m_scope[port].buttons &= 0x20; |
| 901 | 921 | |
| 902 | 922 | /* set onscreen/offscreen */ |
| 903 | | state->m_scope[port].buttons |= BIT(input, 1); |
| 923 | m_scope[port].buttons |= BIT(input, 1); |
| 904 | 924 | |
| 905 | 925 | /* turbo is a switch; toggle is edge sensitive */ |
| 906 | | if (BIT(input, 5) && !state->m_scope[port].turbo_lock) |
| 926 | if (BIT(input, 5) && !m_scope[port].turbo_lock) |
| 907 | 927 | { |
| 908 | | state->m_scope[port].buttons ^= 0x20; |
| 909 | | state->m_scope[port].turbo_lock = 1; |
| 928 | m_scope[port].buttons ^= 0x20; |
| 929 | m_scope[port].turbo_lock = 1; |
| 910 | 930 | } |
| 911 | 931 | else if (!BIT(input, 5)) |
| 912 | | state->m_scope[port].turbo_lock = 0; |
| 932 | m_scope[port].turbo_lock = 0; |
| 913 | 933 | |
| 914 | 934 | /* fire is a button; if turbo is active, trigger is level sensitive; otherwise it is edge sensitive */ |
| 915 | | if (BIT(input, 7) && (BIT(state->m_scope[port].buttons, 5) || !state->m_scope[port].fire_lock)) |
| 935 | if (BIT(input, 7) && (BIT(m_scope[port].buttons, 5) || !m_scope[port].fire_lock)) |
| 916 | 936 | { |
| 917 | | state->m_scope[port].buttons |= 0x80; |
| 918 | | state->m_scope[port].fire_lock = 1; |
| 937 | m_scope[port].buttons |= 0x80; |
| 938 | m_scope[port].fire_lock = 1; |
| 919 | 939 | } |
| 920 | 940 | else if (!BIT(input, 7)) |
| 921 | | state->m_scope[port].fire_lock = 0; |
| 941 | m_scope[port].fire_lock = 0; |
| 922 | 942 | |
| 923 | 943 | /* cursor is a button; it is always level sensitive */ |
| 924 | | state->m_scope[port].buttons |= BIT(input, 6); |
| 944 | m_scope[port].buttons |= BIT(input, 6); |
| 925 | 945 | |
| 926 | 946 | /* pause is a button; it is always edge sensitive */ |
| 927 | | if (BIT(input, 4) && !state->m_scope[port].pause_lock) |
| 947 | if (BIT(input, 4) && !m_scope[port].pause_lock) |
| 928 | 948 | { |
| 929 | | state->m_scope[port].buttons |= 0x10; |
| 930 | | state->m_scope[port].pause_lock = 1; |
| 949 | m_scope[port].buttons |= 0x10; |
| 950 | m_scope[port].pause_lock = 1; |
| 931 | 951 | } |
| 932 | 952 | else if (!BIT(input, 4)) |
| 933 | | state->m_scope[port].pause_lock = 0; |
| 953 | m_scope[port].pause_lock = 0; |
| 934 | 954 | |
| 935 | 955 | /* If we have pressed fire or cursor and we are on-screen and SuperScope is in Port2, then latch video signal. |
| 936 | 956 | Notice that we only latch Port2 because its IOBit pin is connected to bit7 of the IO Port, while Port1 has |
| 937 | 957 | IOBit pin connected to bit6 of the IO Port, and the latter is not detected by the H/V Counters. In other |
| 938 | 958 | words, you can connect SuperScope to Port1, but there is no way SNES could detect its on-screen position */ |
| 939 | | if ((state->m_scope[port].buttons & 0xc0) && !(state->m_scope[port].buttons & 0x02) && port == 1) |
| 940 | | snes_gun_latch(machine, state->m_scope[port].x, state->m_scope[port].y); |
| 959 | if ((m_scope[port].buttons & 0xc0) && !(m_scope[port].buttons & 0x02) && port == 1) |
| 960 | snes_gun_latch(m_scope[port].x, m_scope[port].y); |
| 941 | 961 | |
| 942 | | state->m_data1[port] = 0xff | (state->m_scope[port].buttons << 8); |
| 943 | | state->m_data2[port] = 0; |
| 962 | m_data1[port] = 0xff | (m_scope[port].buttons << 8); |
| 963 | m_data2[port] = 0; |
| 944 | 964 | } |
| 945 | 965 | |
| 946 | | static void snes_input_read( running_machine &machine ) |
| 966 | WRITE8_MEMBER(snes_console_state::snes_input_read) |
| 947 | 967 | { |
| 948 | | snes_state *state = machine.driver_data<snes_state>(); |
| 949 | | UINT8 ctrl1 = machine.root_device().ioport("CTRLSEL")->read() & 0x0f; |
| 950 | | UINT8 ctrl2 = (machine.root_device().ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 968 | UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f; |
| 969 | UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 951 | 970 | |
| 952 | 971 | /* Check if lightgun has been chosen as input: if so, enable crosshair */ |
| 953 | | machine.scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); |
| 972 | machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(snes_console_state::lightgun_tick),this)); |
| 954 | 973 | |
| 955 | 974 | switch (ctrl1) |
| 956 | 975 | { |
| 957 | 976 | case 1: /* SNES joypad */ |
| 958 | | snes_input_read_joy(machine, 0); |
| 977 | snes_input_read_joy(0); |
| 959 | 978 | break; |
| 960 | 979 | case 2: /* SNES Mouse */ |
| 961 | | snes_input_read_mouse(machine, 0); |
| 980 | snes_input_read_mouse(0); |
| 962 | 981 | break; |
| 963 | 982 | case 3: /* SNES Superscope */ |
| 964 | | snes_input_read_superscope(machine, 0); |
| 983 | snes_input_read_superscope(0); |
| 965 | 984 | break; |
| 966 | 985 | case 0: /* no controller in port1 */ |
| 967 | 986 | default: |
| 968 | | state->m_data1[0] = 0; |
| 969 | | state->m_data2[0] = 0; |
| 987 | m_data1[0] = 0; |
| 988 | m_data2[0] = 0; |
| 970 | 989 | break; |
| 971 | 990 | } |
| 972 | 991 | |
| 973 | 992 | switch (ctrl2) |
| 974 | 993 | { |
| 975 | 994 | case 1: /* SNES joypad */ |
| 976 | | snes_input_read_joy(machine, 1); |
| 995 | snes_input_read_joy(1); |
| 977 | 996 | break; |
| 978 | 997 | case 2: /* SNES Mouse */ |
| 979 | | snes_input_read_mouse(machine, 1); |
| 998 | snes_input_read_mouse(1); |
| 980 | 999 | break; |
| 981 | 1000 | case 3: /* SNES Superscope */ |
| 982 | | snes_input_read_superscope(machine, 1); |
| 1001 | snes_input_read_superscope(1); |
| 983 | 1002 | break; |
| 984 | 1003 | case 0: /* no controller in port2 */ |
| 985 | 1004 | default: |
| 986 | | state->m_data1[1] = 0; |
| 987 | | state->m_data2[1] = 0; |
| 1005 | m_data1[1] = 0; |
| 1006 | m_data2[1] = 0; |
| 988 | 1007 | break; |
| 989 | 1008 | } |
| 990 | 1009 | |
| 991 | 1010 | // is automatic reading on? if so, copy port data1/data2 to joy1l->joy4h |
| 992 | 1011 | // this actually works like reading the first 16bits from oldjoy1/2 in reverse order |
| 993 | | if (SNES_CPU_REG_STATE(NMITIMEN) & 1) |
| 1012 | if (SNES_CPU_REG(NMITIMEN) & 1) |
| 994 | 1013 | { |
| 995 | | SNES_CPU_REG_STATE(JOY1L) = (state->m_data1[0] & 0x00ff) >> 0; |
| 996 | | SNES_CPU_REG_STATE(JOY1H) = (state->m_data1[0] & 0xff00) >> 8; |
| 997 | | SNES_CPU_REG_STATE(JOY2L) = (state->m_data1[1] & 0x00ff) >> 0; |
| 998 | | SNES_CPU_REG_STATE(JOY2H) = (state->m_data1[1] & 0xff00) >> 8; |
| 999 | | SNES_CPU_REG_STATE(JOY3L) = (state->m_data2[0] & 0x00ff) >> 0; |
| 1000 | | SNES_CPU_REG_STATE(JOY3H) = (state->m_data2[0] & 0xff00) >> 8; |
| 1001 | | SNES_CPU_REG_STATE(JOY4L) = (state->m_data2[1] & 0x00ff) >> 0; |
| 1002 | | SNES_CPU_REG_STATE(JOY4H) = (state->m_data2[1] & 0xff00) >> 8; |
| 1014 | SNES_CPU_REG(JOY1L) = (m_data1[0] & 0x00ff) >> 0; |
| 1015 | SNES_CPU_REG(JOY1H) = (m_data1[0] & 0xff00) >> 8; |
| 1016 | SNES_CPU_REG(JOY2L) = (m_data1[1] & 0x00ff) >> 0; |
| 1017 | SNES_CPU_REG(JOY2H) = (m_data1[1] & 0xff00) >> 8; |
| 1018 | SNES_CPU_REG(JOY3L) = (m_data2[0] & 0x00ff) >> 0; |
| 1019 | SNES_CPU_REG(JOY3H) = (m_data2[0] & 0xff00) >> 8; |
| 1020 | SNES_CPU_REG(JOY4L) = (m_data2[1] & 0x00ff) >> 0; |
| 1021 | SNES_CPU_REG(JOY4H) = (m_data2[1] & 0xff00) >> 8; |
| 1003 | 1022 | |
| 1004 | 1023 | // make sure read_idx starts returning all 1s because the auto-read reads it :-) |
| 1005 | | state->m_read_idx[0] = 16; |
| 1006 | | state->m_read_idx[1] = 16; |
| 1024 | m_read_idx[0] = 16; |
| 1025 | m_read_idx[1] = 16; |
| 1007 | 1026 | } |
| 1008 | 1027 | |
| 1009 | 1028 | } |
| 1010 | 1029 | |
| 1011 | | static UINT8 snes_oldjoy1_read( running_machine &machine ) |
| 1030 | READ8_MEMBER(snes_console_state::snes_oldjoy1_read) |
| 1012 | 1031 | { |
| 1013 | | snes_state *state = machine.driver_data<snes_state>(); |
| 1014 | | UINT8 ctrl1 = machine.root_device().ioport("CTRLSEL")->read() & 0x0f; |
| 1032 | UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f; |
| 1015 | 1033 | UINT8 res = 0; |
| 1016 | 1034 | |
| 1017 | 1035 | switch (ctrl1) |
| 1018 | 1036 | { |
| 1019 | 1037 | case 1: /* SNES joypad */ |
| 1020 | | if (state->m_read_idx[0] >= 16) |
| 1038 | if (m_read_idx[0] >= 16) |
| 1021 | 1039 | res = 0x01; |
| 1022 | 1040 | else |
| 1023 | | res = (state->m_joypad[0].buttons >> (15 - state->m_read_idx[0]++)) & 0x01; |
| 1041 | res = (m_joypad[0].buttons >> (15 - m_read_idx[0]++)) & 0x01; |
| 1024 | 1042 | break; |
| 1025 | 1043 | case 2: /* SNES Mouse */ |
| 1026 | | if (state->m_read_idx[0] >= 32) |
| 1044 | if (m_read_idx[0] >= 32) |
| 1027 | 1045 | res = 0x01; |
| 1028 | | else if (state->m_read_idx[0] >= 24) |
| 1029 | | res = (state->m_mouse[0].deltax >> (31 - state->m_read_idx[0]++)) & 0x01; |
| 1030 | | else if (state->m_read_idx[0] >= 16) |
| 1031 | | res = (state->m_mouse[0].deltay >> (23 - state->m_read_idx[0]++)) & 0x01; |
| 1032 | | else if (state->m_read_idx[0] >= 8) |
| 1033 | | res = (state->m_mouse[0].buttons >> (15 - state->m_read_idx[0]++)) & 0x01; |
| 1046 | else if (m_read_idx[0] >= 24) |
| 1047 | res = (m_mouse[0].deltax >> (31 - m_read_idx[0]++)) & 0x01; |
| 1048 | else if (m_read_idx[0] >= 16) |
| 1049 | res = (m_mouse[0].deltay >> (23 - m_read_idx[0]++)) & 0x01; |
| 1050 | else if (m_read_idx[0] >= 8) |
| 1051 | res = (m_mouse[0].buttons >> (15 - m_read_idx[0]++)) & 0x01; |
| 1034 | 1052 | else |
| 1035 | 1053 | res = 0; |
| 1036 | 1054 | break; |
| 1037 | 1055 | case 3: /* SNES Superscope */ |
| 1038 | | if (state->m_read_idx[0] >= 8) |
| 1056 | if (m_read_idx[0] >= 8) |
| 1039 | 1057 | res = 0x01; |
| 1040 | 1058 | else |
| 1041 | | res = (state->m_scope[0].buttons >> (7 - state->m_read_idx[0]++)) & 0x01; |
| 1059 | res = (m_scope[0].buttons >> (7 - m_read_idx[0]++)) & 0x01; |
| 1042 | 1060 | break; |
| 1043 | 1061 | case 0: /* no controller in port2 */ |
| 1044 | 1062 | default: |
| r21593 | r21594 | |
| 1048 | 1066 | return res; |
| 1049 | 1067 | } |
| 1050 | 1068 | |
| 1051 | | static UINT8 snes_oldjoy2_read( running_machine &machine ) |
| 1069 | READ8_MEMBER(snes_console_state::snes_oldjoy2_read) |
| 1052 | 1070 | { |
| 1053 | | snes_state *state = machine.driver_data<snes_state>(); |
| 1054 | | UINT8 ctrl2 = (machine.root_device().ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 1071 | UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 1055 | 1072 | UINT8 res = 0; |
| 1056 | 1073 | |
| 1057 | 1074 | switch (ctrl2) |
| 1058 | 1075 | { |
| 1059 | 1076 | case 1: /* SNES joypad */ |
| 1060 | | if (state->m_read_idx[1] >= 16) |
| 1077 | if (m_read_idx[1] >= 16) |
| 1061 | 1078 | res = 0x01; |
| 1062 | 1079 | else |
| 1063 | | res = (state->m_joypad[1].buttons >> (15 - state->m_read_idx[1]++)) & 0x01; |
| 1080 | res = (m_joypad[1].buttons >> (15 - m_read_idx[1]++)) & 0x01; |
| 1064 | 1081 | break; |
| 1065 | 1082 | case 2: /* SNES Mouse */ |
| 1066 | | if (state->m_read_idx[1] >= 32) |
| 1083 | if (m_read_idx[1] >= 32) |
| 1067 | 1084 | res = 0x01; |
| 1068 | | else if (state->m_read_idx[1] >= 24) |
| 1069 | | res = (state->m_mouse[1].deltax >> (31 - state->m_read_idx[1]++)) & 0x01; |
| 1070 | | else if (state->m_read_idx[1] >= 16) |
| 1071 | | res = (state->m_mouse[1].deltay >> (23 - state->m_read_idx[1]++)) & 0x01; |
| 1072 | | else if (state->m_read_idx[1] >= 8) |
| 1073 | | res = (state->m_mouse[1].buttons >> (15 - state->m_read_idx[1]++)) & 0x01; |
| 1085 | else if (m_read_idx[1] >= 24) |
| 1086 | res = (m_mouse[1].deltax >> (31 - m_read_idx[1]++)) & 0x01; |
| 1087 | else if (m_read_idx[1] >= 16) |
| 1088 | res = (m_mouse[1].deltay >> (23 - m_read_idx[1]++)) & 0x01; |
| 1089 | else if (m_read_idx[1] >= 8) |
| 1090 | res = (m_mouse[1].buttons >> (15 - m_read_idx[1]++)) & 0x01; |
| 1074 | 1091 | else |
| 1075 | 1092 | res = 0; |
| 1076 | 1093 | break; |
| 1077 | 1094 | case 3: /* SNES Superscope */ |
| 1078 | | if (state->m_read_idx[1] >= 8) |
| 1095 | if (m_read_idx[1] >= 8) |
| 1079 | 1096 | res = 0x01; |
| 1080 | 1097 | else |
| 1081 | | res = (state->m_scope[1].buttons >> (7 - state->m_read_idx[1]++)) & 0x01; |
| 1098 | res = (m_scope[1].buttons >> (7 - m_read_idx[1]++)) & 0x01; |
| 1082 | 1099 | break; |
| 1083 | 1100 | case 0: /* no controller in port2 */ |
| 1084 | 1101 | default: |
| r21593 | r21594 | |
| 1096 | 1113 | |
| 1097 | 1114 | static MACHINE_START( snes_mess ) |
| 1098 | 1115 | { |
| 1099 | | snes_state *state = machine.driver_data<snes_state>(); |
| 1116 | snes_console_state *state = machine.driver_data<snes_console_state>(); |
| 1100 | 1117 | |
| 1101 | 1118 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(snes_machine_stop),&machine)); |
| 1102 | 1119 | MACHINE_START_CALL(snes); |
| 1103 | | |
| 1120 | |
| 1104 | 1121 | switch (state->m_has_addon_chip) |
| 1105 | 1122 | { |
| 1106 | 1123 | case HAS_SDD1: |
| r21593 | r21594 | |
| 1123 | 1140 | |
| 1124 | 1141 | static MACHINE_RESET( snes_mess ) |
| 1125 | 1142 | { |
| 1126 | | snes_state *state = machine.driver_data<snes_state>(); |
| 1143 | snes_console_state *state = machine.driver_data<snes_console_state>(); |
| 1127 | 1144 | |
| 1128 | 1145 | MACHINE_RESET_CALL(snes); |
| 1129 | 1146 | |
| 1130 | | state->m_io_read = snes_input_read; |
| 1131 | | state->m_oldjoy1_read = snes_oldjoy1_read; |
| 1132 | | state->m_oldjoy2_read = snes_oldjoy2_read; |
| 1133 | | |
| 1147 | state->m_io_read = write8_delegate(FUNC(snes_console_state::snes_input_read),state); |
| 1148 | state->m_oldjoy1_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy1_read),state); |
| 1149 | state->m_oldjoy2_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy2_read),state); |
| 1150 | |
| 1134 | 1151 | // see if there's a uPD7725 DSP in the machine config |
| 1135 | 1152 | state->m_upd7725 = machine.device<upd7725_device>("dsp"); |
| 1136 | | |
| 1153 | |
| 1137 | 1154 | // if we have a DSP, halt it for the moment |
| 1138 | 1155 | if (state->m_upd7725) |
| 1139 | 1156 | machine.device("dsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 1140 | | |
| 1157 | |
| 1141 | 1158 | // ditto for a uPD96050 (Seta ST-010 or ST-011) |
| 1142 | 1159 | state->m_upd96050 = machine.device<upd96050_device>("setadsp"); |
| 1143 | 1160 | if (state->m_upd96050) |
| 1144 | 1161 | machine.device("setadsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 1145 | | |
| 1162 | |
| 1146 | 1163 | switch (state->m_has_addon_chip) |
| 1147 | 1164 | { |
| 1148 | 1165 | case HAS_DSP1: |
| r21593 | r21594 | |
| 1158 | 1175 | state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device |
| 1159 | 1176 | } |
| 1160 | 1177 | break; |
| 1161 | | |
| 1178 | |
| 1162 | 1179 | case HAS_RTC: |
| 1163 | 1180 | srtc_init(machine); |
| 1164 | 1181 | break; |
| 1165 | | |
| 1182 | |
| 1166 | 1183 | case HAS_OBC1: |
| 1167 | 1184 | obc1_init(machine); |
| 1168 | 1185 | break; |
| 1169 | | |
| 1186 | |
| 1170 | 1187 | case HAS_ST010: |
| 1171 | 1188 | case HAS_ST011: |
| 1172 | 1189 | // cartridge uses the DSP, let 'er rip |
| r21593 | r21594 | |
| 1178 | 1195 | state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device |
| 1179 | 1196 | } |
| 1180 | 1197 | break; |
| 1181 | | |
| 1198 | |
| 1182 | 1199 | default: |
| 1183 | 1200 | break; |
| 1184 | 1201 | } |
| 1185 | 1202 | } |
| 1186 | 1203 | |
| 1187 | | static MACHINE_CONFIG_START( snes_base, snes_state ) |
| 1204 | static MACHINE_CONFIG_START( snes_base, snes_console_state ) |
| 1188 | 1205 | |
| 1189 | 1206 | /* basic machine hardware */ |
| 1190 | 1207 | MCFG_CPU_ADD("maincpu", _5A22, MCLK_NTSC) /* 2.68 MHz, also 3.58 MHz */ |
| r21593 | r21594 | |
| 1464 | 1481 | #include "machine/sns_sufami.h" |
| 1465 | 1482 | #include "machine/sns_upd.h" |
| 1466 | 1483 | |
| 1467 | | class snsnew_state : public snes_state |
| 1484 | class snsnew_state : public snes_console_state |
| 1468 | 1485 | { |
| 1469 | 1486 | public: |
| 1470 | 1487 | snsnew_state(const machine_config &mconfig, device_type type, const char *tag) |
| 1471 | | : snes_state(mconfig, type, tag), |
| 1488 | : snes_console_state(mconfig, type, tag), |
| 1472 | 1489 | m_slotcart(*this, "snsslot") |
| 1473 | | { } |
| 1490 | { } |
| 1491 | |
| 1492 | DECLARE_READ8_MEMBER( snes20_hi_r ); |
| 1493 | DECLARE_WRITE8_MEMBER( snes20_hi_w ); |
| 1494 | DECLARE_READ8_MEMBER( snes20_lo_r ); |
| 1495 | DECLARE_WRITE8_MEMBER( snes20_lo_w ); |
| 1496 | DECLARE_READ8_MEMBER( snes21_lo_r ); |
| 1497 | DECLARE_WRITE8_MEMBER( snes21_lo_w ); |
| 1498 | DECLARE_READ8_MEMBER( snes21_hi_r ); |
| 1499 | DECLARE_WRITE8_MEMBER( snes21_hi_w ); |
| 1500 | DECLARE_READ8_MEMBER( snesfx_hi_r ); |
| 1501 | DECLARE_READ8_MEMBER( snesfx_lo_r ); |
| 1502 | DECLARE_WRITE8_MEMBER( snesfx_hi_w ); |
| 1503 | DECLARE_WRITE8_MEMBER( snesfx_lo_w ); |
| 1504 | DECLARE_READ8_MEMBER( snespc7110_hi_r ); |
| 1505 | DECLARE_READ8_MEMBER( snespc7110_lo_r ); |
| 1506 | DECLARE_WRITE8_MEMBER( snespc7110_hi_w ); |
| 1507 | DECLARE_WRITE8_MEMBER( snespc7110_lo_w ); |
| 1508 | DECLARE_READ8_MEMBER( snesdd1_lo_r ); |
| 1509 | DECLARE_WRITE8_MEMBER( snesdd1_lo_w ); |
| 1510 | DECLARE_READ8_MEMBER( snesdd1_hi_r ); |
| 1511 | DECLARE_WRITE8_MEMBER( snesdd1_hi_w ); |
| 1512 | DECLARE_READ8_MEMBER( snesbsx_hi_r ); |
| 1513 | DECLARE_WRITE8_MEMBER( snesbsx_hi_w ); |
| 1514 | DECLARE_READ8_MEMBER( snesbsx_lo_r ); |
| 1515 | DECLARE_WRITE8_MEMBER( snesbsx_lo_w ); |
| 1516 | DECLARE_READ8_MEMBER( snesnew_lo_r ); |
| 1517 | DECLARE_READ8_MEMBER( snesnew_hi_r ); |
| 1518 | DECLARE_WRITE8_MEMBER( snesnew_lo_w ); |
| 1519 | DECLARE_WRITE8_MEMBER( snesnew_hi_w ); |
| 1474 | 1520 | |
| 1475 | 1521 | optional_device<sns_cart_slot_device> m_slotcart; |
| 1476 | 1522 | int m_type; |
| r21593 | r21594 | |
| 1485 | 1531 | |
| 1486 | 1532 | // LoROM |
| 1487 | 1533 | |
| 1488 | | static READ8_HANDLER( snes20_hi_r ) |
| 1534 | READ8_MEMBER( snsnew_state::snes20_hi_r ) |
| 1489 | 1535 | { |
| 1490 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1491 | 1536 | UINT16 address = offset & 0xffff; |
| 1492 | | |
| 1537 | |
| 1493 | 1538 | if (offset < 0x400000) |
| 1494 | 1539 | { |
| 1495 | 1540 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1498 | 1543 | return snes_r_io(space, address); |
| 1499 | 1544 | if (address >= 0x6000 && address < 0x8000) |
| 1500 | 1545 | return snes_open_bus_r(space, 0); |
| 1501 | | if (address >= 0x8000) |
| 1502 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1546 | if (address >= 0x8000) |
| 1547 | return m_slotcart->m_cart->read_h(space, offset); |
| 1503 | 1548 | } |
| 1504 | 1549 | else if (offset < 0x700000) |
| 1505 | 1550 | { |
| 1506 | 1551 | if (address < 0x8000) |
| 1507 | 1552 | return snes_open_bus_r(space, 0); |
| 1508 | 1553 | else |
| 1509 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1554 | return m_slotcart->m_cart->read_h(space, offset); |
| 1510 | 1555 | } |
| 1511 | | |
| 1556 | |
| 1512 | 1557 | // ROM & NVRAM access |
| 1513 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1514 | | } |
| 1558 | return m_slotcart->m_cart->read_h(space, offset); |
| 1559 | } |
| 1515 | 1560 | |
| 1516 | | static WRITE8_HANDLER( snes20_hi_w ) |
| 1561 | WRITE8_MEMBER( snsnew_state::snes20_hi_w ) |
| 1517 | 1562 | { |
| 1518 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1519 | 1563 | UINT16 address = offset & 0xffff; |
| 1520 | 1564 | if (offset < 0x400000) |
| 1521 | 1565 | { |
| r21593 | r21594 | |
| 1524 | 1568 | if (address >= 0x2000 && address < 0x6000) |
| 1525 | 1569 | snes_w_io(space, address, data); |
| 1526 | 1570 | } |
| 1527 | | else if (offset >= 0x700000) // NVRAM access |
| 1571 | else if (offset >= 0x700000) // NVRAM access |
| 1528 | 1572 | { |
| 1529 | | state->m_slotcart->m_cart->write_h(space, offset, data); |
| 1573 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1530 | 1574 | } |
| 1531 | | } |
| 1575 | } |
| 1532 | 1576 | |
| 1533 | | static READ8_HANDLER( snes20_lo_r ) |
| 1577 | READ8_MEMBER( snsnew_state::snes20_lo_r ) |
| 1534 | 1578 | { |
| 1535 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1536 | 1579 | UINT16 address = offset & 0xffff; |
| 1537 | | |
| 1580 | |
| 1538 | 1581 | if (offset < 0x400000) |
| 1539 | 1582 | { |
| 1540 | 1583 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1543 | 1586 | return snes_r_io(space, address); |
| 1544 | 1587 | if (address >= 0x6000 && address < 0x8000) |
| 1545 | 1588 | return snes_open_bus_r(space, 0); |
| 1546 | | if (address >= 0x8000) |
| 1547 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1589 | if (address >= 0x8000) |
| 1590 | return m_slotcart->m_cart->read_l(space, offset); |
| 1548 | 1591 | } |
| 1549 | 1592 | else if (offset < 0x700000) |
| 1550 | 1593 | { |
| 1551 | 1594 | if (address < 0x8000) |
| 1552 | 1595 | return snes_open_bus_r(space, 0); |
| 1553 | 1596 | else |
| 1554 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1597 | return m_slotcart->m_cart->read_l(space, offset); |
| 1555 | 1598 | } |
| 1556 | | |
| 1599 | |
| 1557 | 1600 | // ROM & NVRAM access |
| 1558 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1559 | | } |
| 1601 | return m_slotcart->m_cart->read_l(space, offset); |
| 1602 | } |
| 1560 | 1603 | |
| 1561 | | static WRITE8_HANDLER( snes20_lo_w ) |
| 1604 | WRITE8_MEMBER( snsnew_state::snes20_lo_w ) |
| 1562 | 1605 | { |
| 1563 | 1606 | snes20_hi_w(space, offset, data, 0xff); |
| 1564 | | } |
| 1607 | } |
| 1565 | 1608 | |
| 1566 | 1609 | |
| 1567 | 1610 | // HiROM |
| 1568 | 1611 | |
| 1569 | | static READ8_HANDLER( snes21_lo_r ) |
| 1612 | READ8_MEMBER( snsnew_state::snes21_lo_r ) |
| 1570 | 1613 | { |
| 1571 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1572 | 1614 | UINT16 address = offset & 0xffff; |
| 1573 | | |
| 1615 | |
| 1574 | 1616 | if (offset < 0x400000) |
| 1575 | 1617 | { |
| 1576 | 1618 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1579 | 1621 | return snes_r_io(space, address); |
| 1580 | 1622 | if (address >= 0x6000 && address < 0x8000) |
| 1581 | 1623 | { |
| 1582 | | if (state->m_slotcart->m_cart->get_nvram_size()) |
| 1624 | if (m_slotcart->m_cart->get_nvram_size()) |
| 1583 | 1625 | { |
| 1584 | 1626 | // read NVRAM, instead |
| 1585 | 1627 | if (offset >= 0x300000) |
| 1586 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1628 | return m_slotcart->m_cart->read_l(space, offset); |
| 1587 | 1629 | } |
| 1588 | 1630 | return snes_open_bus_r(space, 0); |
| 1589 | 1631 | } |
| 1590 | 1632 | if (address >= 0x8000) |
| 1591 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1633 | return m_slotcart->m_cart->read_l(space, offset); |
| 1592 | 1634 | } |
| 1593 | | |
| 1635 | |
| 1594 | 1636 | // ROM & NVRAM access |
| 1595 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1596 | | } |
| 1637 | return m_slotcart->m_cart->read_l(space, offset); |
| 1638 | } |
| 1597 | 1639 | |
| 1598 | | static WRITE8_HANDLER( snes21_lo_w ) |
| 1640 | WRITE8_MEMBER( snsnew_state::snes21_lo_w ) |
| 1599 | 1641 | { |
| 1600 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1601 | 1642 | UINT16 address = offset & 0xffff; |
| 1602 | 1643 | if (offset < 0x400000) |
| 1603 | 1644 | { |
| r21593 | r21594 | |
| 1607 | 1648 | snes_w_io(space, address, data); |
| 1608 | 1649 | if (address >= 0x6000 && address < 0x8000) |
| 1609 | 1650 | { |
| 1610 | | if (state->m_slotcart->m_cart->get_nvram_size()) |
| 1651 | if (m_slotcart->m_cart->get_nvram_size()) |
| 1611 | 1652 | { |
| 1612 | 1653 | // write to NVRAM, in this case |
| 1613 | 1654 | if (offset >= 0x300000) |
| 1614 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1655 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1615 | 1656 | } |
| 1616 | 1657 | } |
| 1617 | 1658 | } |
| 1618 | | else if (offset >= 0x700000) // NVRAM access |
| 1619 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1620 | | } |
| 1659 | else if (offset >= 0x700000) // NVRAM access |
| 1660 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1661 | } |
| 1621 | 1662 | |
| 1622 | | static READ8_HANDLER( snes21_hi_r ) |
| 1663 | READ8_MEMBER( snsnew_state::snes21_hi_r ) |
| 1623 | 1664 | { |
| 1624 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1625 | 1665 | UINT16 address = offset & 0xffff; |
| 1626 | | |
| 1666 | |
| 1627 | 1667 | if (offset < 0x400000) |
| 1628 | 1668 | { |
| 1629 | 1669 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1632 | 1672 | return snes_r_io(space, address); |
| 1633 | 1673 | if (address >= 0x6000 && address < 0x8000) |
| 1634 | 1674 | { |
| 1635 | | if (state->m_slotcart->m_cart->get_nvram_size()) |
| 1675 | if (m_slotcart->m_cart->get_nvram_size()) |
| 1636 | 1676 | { |
| 1637 | 1677 | // read NVRAM, instead |
| 1638 | 1678 | if (offset >= 0x300000) |
| 1639 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1679 | return m_slotcart->m_cart->read_h(space, offset); |
| 1640 | 1680 | } |
| 1641 | 1681 | return snes_open_bus_r(space, 0); |
| 1642 | 1682 | } |
| 1643 | 1683 | if (address >= 0x8000) |
| 1644 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1684 | return m_slotcart->m_cart->read_h(space, offset); |
| 1645 | 1685 | } |
| 1646 | | |
| 1686 | |
| 1647 | 1687 | // ROM & NVRAM access |
| 1648 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1649 | | } |
| 1688 | return m_slotcart->m_cart->read_h(space, offset); |
| 1689 | } |
| 1650 | 1690 | |
| 1651 | | static WRITE8_HANDLER( snes21_hi_w ) |
| 1691 | WRITE8_MEMBER( snsnew_state::snes21_hi_w ) |
| 1652 | 1692 | { |
| 1653 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1654 | 1693 | UINT16 address = offset & 0xffff; |
| 1655 | 1694 | if (offset < 0x400000) |
| 1656 | 1695 | { |
| r21593 | r21594 | |
| 1660 | 1699 | snes_w_io(space, address, data); |
| 1661 | 1700 | if (address >= 0x6000 && address < 0x8000) |
| 1662 | 1701 | { |
| 1663 | | if (state->m_slotcart->m_cart->get_nvram_size()) |
| 1702 | if (m_slotcart->m_cart->get_nvram_size()) |
| 1664 | 1703 | { |
| 1665 | 1704 | // write to NVRAM, in this case |
| 1666 | 1705 | if (offset >= 0x300000) |
| 1667 | | state->m_slotcart->m_cart->write_h(space, offset, data); |
| 1706 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1668 | 1707 | } |
| 1669 | 1708 | } |
| 1670 | 1709 | } |
| 1671 | | else if (offset >= 0x700000) // NVRAM access |
| 1672 | | state->m_slotcart->m_cart->write_h(space, offset, data); |
| 1673 | | } |
| 1710 | else if (offset >= 0x700000) // NVRAM access |
| 1711 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1712 | } |
| 1674 | 1713 | |
| 1675 | 1714 | // SuperFX / GSU |
| 1676 | 1715 | |
| 1677 | | static READ8_HANDLER( snesfx_hi_r ) |
| 1716 | READ8_MEMBER( snsnew_state::snesfx_hi_r ) |
| 1678 | 1717 | { |
| 1679 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1680 | 1718 | UINT16 address = offset & 0xffff; |
| 1681 | | |
| 1719 | |
| 1682 | 1720 | if (offset < 0x400000) |
| 1683 | 1721 | { |
| 1684 | 1722 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1686 | 1724 | if (address >= 0x2000 && address < 0x6000) |
| 1687 | 1725 | { |
| 1688 | 1726 | if (address >= 0x3000 && address < 0x3300) |
| 1689 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 1727 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1690 | 1728 | else |
| 1691 | 1729 | return snes_r_io(space, address); |
| 1692 | 1730 | } |
| 1693 | 1731 | if (address >= 0x6000 && address < 0x8000) |
| 1694 | 1732 | { |
| 1695 | | return state->m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1733 | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1696 | 1734 | } |
| 1697 | 1735 | if (address >= 0x8000) |
| 1698 | | return state->m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1736 | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1699 | 1737 | } |
| 1700 | 1738 | else if (offset < 0x600000) |
| 1701 | | return state->m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1739 | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1740 | |
| 1741 | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1742 | } |
| 1702 | 1743 | |
| 1703 | | return state->m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1704 | | } |
| 1705 | | |
| 1706 | | static READ8_HANDLER( snesfx_lo_r ) |
| 1744 | READ8_MEMBER( snsnew_state::snesfx_lo_r ) |
| 1707 | 1745 | { |
| 1708 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1709 | 1746 | UINT16 address = offset & 0xffff; |
| 1710 | | |
| 1747 | |
| 1711 | 1748 | if (offset < 0x400000) |
| 1712 | 1749 | { |
| 1713 | 1750 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1715 | 1752 | if (address >= 0x2000 && address < 0x6000) |
| 1716 | 1753 | { |
| 1717 | 1754 | if (address >= 0x3000 && address < 0x3300) |
| 1718 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 1755 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1719 | 1756 | else |
| 1720 | 1757 | return snes_r_io(space, address); |
| 1721 | 1758 | } |
| 1722 | 1759 | if (address >= 0x6000 && address < 0x8000) |
| 1723 | 1760 | { |
| 1724 | | return state->m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1761 | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1725 | 1762 | } |
| 1726 | 1763 | if (address >= 0x8000) |
| 1727 | | return state->m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1764 | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1728 | 1765 | } |
| 1729 | 1766 | else if (offset < 0x600000) |
| 1730 | | return state->m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1767 | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1768 | |
| 1769 | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1770 | } |
| 1731 | 1771 | |
| 1732 | | return state->m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1733 | | } |
| 1734 | | |
| 1735 | | static WRITE8_HANDLER( snesfx_hi_w ) |
| 1772 | WRITE8_MEMBER( snsnew_state::snesfx_hi_w ) |
| 1736 | 1773 | { |
| 1737 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1738 | 1774 | UINT16 address = offset & 0xffff; |
| 1739 | 1775 | if (offset < 0x400000) |
| 1740 | 1776 | { |
| r21593 | r21594 | |
| 1743 | 1779 | if (address >= 0x2000 && address < 0x6000) |
| 1744 | 1780 | { |
| 1745 | 1781 | if (address >= 0x3000 && address < 0x3300) |
| 1746 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 1782 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 1747 | 1783 | else |
| 1748 | 1784 | snes_w_io(space, address, data); |
| 1749 | 1785 | } |
| 1750 | 1786 | if (address >= 0x6000 && address < 0x8000) |
| 1751 | | state->m_slotcart->m_cart->write_h(space, offset, data); |
| 1787 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1752 | 1788 | } |
| 1753 | 1789 | else |
| 1754 | | state->m_slotcart->m_cart->write_h(space, offset, data); |
| 1755 | | } |
| 1790 | m_slotcart->m_cart->write_h(space, offset, data); |
| 1791 | } |
| 1756 | 1792 | |
| 1757 | | static WRITE8_HANDLER( snesfx_lo_w ) |
| 1793 | WRITE8_MEMBER( snsnew_state::snesfx_lo_w ) |
| 1758 | 1794 | { |
| 1759 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1760 | 1795 | UINT16 address = offset & 0xffff; |
| 1761 | 1796 | if (offset < 0x400000) |
| 1762 | 1797 | { |
| r21593 | r21594 | |
| 1765 | 1800 | if (address >= 0x2000 && address < 0x6000) |
| 1766 | 1801 | { |
| 1767 | 1802 | if (address >= 0x3000 && address < 0x3300) |
| 1768 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 1803 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 1769 | 1804 | else |
| 1770 | 1805 | snes_w_io(space, address, data); |
| 1771 | 1806 | } |
| 1772 | 1807 | if (address >= 0x6000 && address < 0x8000) |
| 1773 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1808 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1774 | 1809 | } |
| 1775 | 1810 | else |
| 1776 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1777 | | } |
| 1811 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1812 | } |
| 1778 | 1813 | |
| 1779 | 1814 | // SPC-7110 |
| 1780 | 1815 | |
| 1781 | | static READ8_HANDLER( snespc7110_hi_r ) |
| 1816 | READ8_MEMBER( snsnew_state::snespc7110_hi_r ) |
| 1782 | 1817 | { |
| 1783 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1784 | 1818 | UINT16 address = offset & 0xffff; |
| 1785 | | |
| 1819 | |
| 1786 | 1820 | if (offset < 0x400000) |
| 1787 | 1821 | { |
| 1788 | 1822 | if (address < 0x2000) |
| 1789 | 1823 | return space.read_byte(0x7e0000 + address); |
| 1790 | 1824 | if (address >= 0x2000 && address < 0x6000) |
| 1791 | 1825 | { |
| 1792 | | UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1826 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1793 | 1827 | if (address >= 0x4800 && address < limit) |
| 1794 | | return state->m_slotcart->m_cart->chip_read(space, address); |
| 1795 | | |
| 1828 | return m_slotcart->m_cart->chip_read(space, address); |
| 1829 | |
| 1796 | 1830 | return snes_r_io(space, address); |
| 1797 | 1831 | } |
| 1798 | 1832 | if (address >= 0x6000 && address < 0x8000) |
| 1799 | 1833 | { |
| 1800 | 1834 | if (offset < 0x10000) |
| 1801 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1835 | return m_slotcart->m_cart->read_h(space, offset); |
| 1802 | 1836 | if (offset >= 0x300000 && offset < 0x310000) |
| 1803 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1837 | return m_slotcart->m_cart->read_h(space, offset); |
| 1804 | 1838 | } |
| 1805 | 1839 | if (address >= 0x8000) |
| 1806 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1840 | return m_slotcart->m_cart->read_h(space, offset); |
| 1807 | 1841 | } |
| 1808 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1809 | | } |
| 1842 | return m_slotcart->m_cart->read_h(space, offset); |
| 1843 | } |
| 1810 | 1844 | |
| 1811 | | static READ8_HANDLER( snespc7110_lo_r ) |
| 1845 | READ8_MEMBER( snsnew_state::snespc7110_lo_r ) |
| 1812 | 1846 | { |
| 1813 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1814 | 1847 | UINT16 address = offset & 0xffff; |
| 1815 | | |
| 1848 | |
| 1816 | 1849 | if (offset < 0x400000) |
| 1817 | 1850 | { |
| 1818 | 1851 | if (address < 0x2000) |
| 1819 | 1852 | return space.read_byte(0x7e0000 + address); |
| 1820 | 1853 | if (address >= 0x2000 && address < 0x6000) |
| 1821 | 1854 | { |
| 1822 | | UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1855 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1823 | 1856 | if (address >= 0x4800 && address < limit) |
| 1824 | | return state->m_slotcart->m_cart->chip_read(space, address); |
| 1825 | | |
| 1857 | return m_slotcart->m_cart->chip_read(space, address); |
| 1858 | |
| 1826 | 1859 | return snes_r_io(space, address); |
| 1827 | 1860 | } |
| 1828 | 1861 | if (address >= 0x6000 && address < 0x8000) |
| 1829 | 1862 | { |
| 1830 | 1863 | if (offset < 0x10000) |
| 1831 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1864 | return m_slotcart->m_cart->read_l(space, offset); |
| 1832 | 1865 | if (offset >= 0x300000 && offset < 0x310000) |
| 1833 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1866 | return m_slotcart->m_cart->read_l(space, offset); |
| 1834 | 1867 | } |
| 1835 | 1868 | if (address >= 0x8000) |
| 1836 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1869 | return m_slotcart->m_cart->read_l(space, offset); |
| 1837 | 1870 | } |
| 1838 | 1871 | if (offset >= 0x500000 && offset < 0x510000) |
| 1839 | | return state->m_slotcart->m_cart->chip_read(space, 0x4800); |
| 1872 | return m_slotcart->m_cart->chip_read(space, 0x4800); |
| 1840 | 1873 | |
| 1841 | 1874 | return snes_open_bus_r(space, 0); |
| 1842 | | } |
| 1875 | } |
| 1843 | 1876 | |
| 1844 | | static WRITE8_HANDLER( snespc7110_hi_w ) |
| 1877 | WRITE8_MEMBER( snsnew_state::snespc7110_hi_w ) |
| 1845 | 1878 | { |
| 1846 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1847 | 1879 | UINT16 address = offset & 0xffff; |
| 1848 | 1880 | if (offset < 0x400000) |
| 1849 | 1881 | { |
| r21593 | r21594 | |
| 1851 | 1883 | space.write_byte(0x7e0000 + address, data); |
| 1852 | 1884 | if (address >= 0x2000 && address < 0x6000) |
| 1853 | 1885 | { |
| 1854 | | UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1886 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1855 | 1887 | if (address >= 0x4800 && address < limit) |
| 1856 | 1888 | { |
| 1857 | | state->m_slotcart->m_cart->chip_write(space, address, data); |
| 1889 | m_slotcart->m_cart->chip_write(space, address, data); |
| 1858 | 1890 | return; |
| 1859 | 1891 | } |
| 1860 | 1892 | snes_w_io(space, address, data); |
| r21593 | r21594 | |
| 1862 | 1894 | if (address >= 0x6000 && address < 0x8000) |
| 1863 | 1895 | { |
| 1864 | 1896 | if (offset < 0x10000) |
| 1865 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1897 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1866 | 1898 | if (offset >= 0x300000 && offset < 0x310000) |
| 1867 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1899 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1868 | 1900 | } |
| 1869 | 1901 | } |
| 1870 | | } |
| 1902 | } |
| 1871 | 1903 | |
| 1872 | | static WRITE8_HANDLER( snespc7110_lo_w ) |
| 1904 | WRITE8_MEMBER( snsnew_state::snespc7110_lo_w ) |
| 1873 | 1905 | { |
| 1874 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1875 | 1906 | UINT16 address = offset & 0xffff; |
| 1876 | 1907 | if (offset < 0x400000) |
| 1877 | 1908 | { |
| r21593 | r21594 | |
| 1879 | 1910 | space.write_byte(0x7e0000 + address, data); |
| 1880 | 1911 | if (address >= 0x2000 && address < 0x6000) |
| 1881 | 1912 | { |
| 1882 | | UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1913 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1883 | 1914 | if (address >= 0x4800 && address < limit) |
| 1884 | 1915 | { |
| 1885 | | state->m_slotcart->m_cart->chip_write(space, address, data); |
| 1916 | m_slotcart->m_cart->chip_write(space, address, data); |
| 1886 | 1917 | return; |
| 1887 | 1918 | } |
| 1888 | 1919 | snes_w_io(space, address, data); |
| r21593 | r21594 | |
| 1890 | 1921 | if (address >= 0x6000 && address < 0x8000) |
| 1891 | 1922 | { |
| 1892 | 1923 | if (offset < 0x10000) |
| 1893 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1924 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1894 | 1925 | if (offset >= 0x300000 && offset < 0x310000) |
| 1895 | | state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1926 | m_slotcart->m_cart->write_l(space, offset, data); |
| 1896 | 1927 | } |
| 1897 | 1928 | } |
| 1898 | | } |
| 1929 | } |
| 1899 | 1930 | |
| 1900 | 1931 | |
| 1901 | 1932 | // S-DD1 |
| 1902 | 1933 | |
| 1903 | | static READ8_HANDLER( snesdd1_lo_r ) |
| 1934 | READ8_MEMBER( snsnew_state::snesdd1_lo_r ) |
| 1904 | 1935 | { |
| 1905 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1906 | 1936 | UINT16 address = offset & 0xffff; |
| 1907 | | |
| 1937 | |
| 1908 | 1938 | if (offset < 0x400000) |
| 1909 | 1939 | { |
| 1910 | 1940 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1912 | 1942 | if (address >= 0x2000 && address < 0x6000) |
| 1913 | 1943 | { |
| 1914 | 1944 | if (address >= 0x4800 && address < 0x4808) |
| 1915 | | return state->m_slotcart->m_cart->chip_read(space, address); |
| 1916 | | |
| 1945 | return m_slotcart->m_cart->chip_read(space, address); |
| 1946 | |
| 1917 | 1947 | return snes_r_io(space, address); |
| 1918 | 1948 | } |
| 1919 | 1949 | if (address >= 0x6000 && address < 0x8000) |
| 1920 | 1950 | return snes_open_bus_r(space, 0); |
| 1921 | 1951 | if (address >= 0x8000) |
| 1922 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1952 | return m_slotcart->m_cart->read_l(space, offset); |
| 1923 | 1953 | } |
| 1924 | | |
| 1954 | |
| 1925 | 1955 | // ROM & NVRAM access |
| 1926 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 1927 | | } |
| 1956 | return m_slotcart->m_cart->read_l(space, offset); |
| 1957 | } |
| 1928 | 1958 | |
| 1929 | | static WRITE8_HANDLER( snesdd1_lo_w ) |
| 1959 | WRITE8_MEMBER( snsnew_state::snesdd1_lo_w ) |
| 1930 | 1960 | { |
| 1931 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1932 | 1961 | UINT16 address = offset & 0xffff; |
| 1933 | 1962 | if (offset < 0x400000) |
| 1934 | 1963 | { |
| r21593 | r21594 | |
| 1938 | 1967 | { |
| 1939 | 1968 | if (address >= 0x4300 && address < 0x4380) |
| 1940 | 1969 | { |
| 1941 | | state->m_slotcart->m_cart->chip_write(space, address, data); |
| 1970 | m_slotcart->m_cart->chip_write(space, address, data); |
| 1942 | 1971 | // here we don't return, but we let the w_io happen... |
| 1943 | 1972 | } |
| 1944 | 1973 | if (address >= 0x4800 && address < 0x4808) |
| 1945 | 1974 | { |
| 1946 | | state->m_slotcart->m_cart->chip_write(space, address, data); |
| 1975 | m_slotcart->m_cart->chip_write(space, address, data); |
| 1947 | 1976 | return; |
| 1948 | 1977 | } |
| 1949 | 1978 | snes_w_io(space, address, data); |
| 1950 | 1979 | } |
| 1951 | 1980 | } |
| 1952 | | if (offset >= 0x700000 && address < 0x8000 && state->m_slotcart->m_cart->get_nvram_size()) |
| 1953 | | return state->m_slotcart->m_cart->write_l(space, offset, data); |
| 1954 | | } |
| 1981 | if (offset >= 0x700000 && address < 0x8000 && m_slotcart->m_cart->get_nvram_size()) |
| 1982 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 1983 | } |
| 1955 | 1984 | |
| 1956 | | static READ8_HANDLER( snesdd1_hi_r ) |
| 1957 | | { |
| 1958 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1959 | | |
| 1985 | READ8_MEMBER( snsnew_state::snesdd1_hi_r ) |
| 1986 | { |
| 1960 | 1987 | if (offset >= 0x400000) |
| 1961 | | return state->m_slotcart->m_cart->read_h(space, offset); |
| 1962 | | else |
| 1988 | return m_slotcart->m_cart->read_h(space, offset); |
| 1989 | else |
| 1963 | 1990 | return snesdd1_lo_r(space, offset, 0xff); |
| 1964 | | } |
| 1991 | } |
| 1965 | 1992 | |
| 1966 | | static WRITE8_HANDLER( snesdd1_hi_w ) |
| 1993 | WRITE8_MEMBER( snsnew_state::snesdd1_hi_w ) |
| 1967 | 1994 | { |
| 1968 | 1995 | snesdd1_lo_w(space, offset, data, 0xff); |
| 1969 | | } |
| 1996 | } |
| 1970 | 1997 | |
| 1971 | 1998 | |
| 1972 | 1999 | // BS-X |
| 1973 | 2000 | |
| 1974 | | static READ8_HANDLER( snesbsx_hi_r ) |
| 2001 | READ8_MEMBER( snsnew_state::snesbsx_hi_r ) |
| 1975 | 2002 | { |
| 1976 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 1977 | 2003 | UINT16 address = offset & 0xffff; |
| 1978 | | |
| 2004 | |
| 1979 | 2005 | if (offset < 0x400000) |
| 1980 | 2006 | { |
| 1981 | 2007 | if (address < 0x2000) |
| r21593 | r21594 | |
| 1983 | 2009 | if (address >= 0x2000 && address < 0x6000) |
| 1984 | 2010 | { |
| 1985 | 2011 | if (address >= 0x2188 && address < 0x21a0) |
| 1986 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2012 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1987 | 2013 | if (address >= 0x5000) |
| 1988 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2014 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1989 | 2015 | return snes_r_io(space, address); |
| 1990 | 2016 | } |
| 1991 | 2017 | if (address >= 0x6000 && address < 0x8000) |
| 1992 | 2018 | { |
| 1993 | | if (offset >= 0x200000) |
| 1994 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 2019 | if (offset >= 0x200000) |
| 2020 | return m_slotcart->m_cart->read_l(space, offset); |
| 1995 | 2021 | else |
| 1996 | 2022 | return snes_open_bus_r(space, 0); |
| 1997 | 2023 | } |
| 1998 | | if (address >= 0x8000) |
| 1999 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 2024 | if (address >= 0x8000) |
| 2025 | return m_slotcart->m_cart->read_l(space, offset); |
| 2000 | 2026 | } |
| 2001 | | return state->m_slotcart->m_cart->read_l(space, offset); |
| 2002 | | } |
| 2027 | return m_slotcart->m_cart->read_l(space, offset); |
| 2028 | } |
| 2003 | 2029 | |
| 2004 | | static WRITE8_HANDLER( snesbsx_hi_w ) |
| 2030 | WRITE8_MEMBER( snsnew_state::snesbsx_hi_w ) |
| 2005 | 2031 | { |
| 2006 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 2007 | 2032 | UINT16 address = offset & 0xffff; |
| 2008 | 2033 | if (offset < 0x400000) |
| 2009 | 2034 | { |
| r21593 | r21594 | |
| 2013 | 2038 | { |
| 2014 | 2039 | if (address >= 0x2188 && address < 0x21a0) |
| 2015 | 2040 | { |
| 2016 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2041 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2017 | 2042 | return; |
| 2018 | 2043 | } |
| 2019 | 2044 | if (address >= 0x5000) |
| 2020 | 2045 | { |
| 2021 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2046 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2022 | 2047 | return; |
| 2023 | 2048 | } |
| 2024 | 2049 | snes_w_io(space, address, data); |
| 2025 | 2050 | } |
| 2026 | 2051 | if (address >= 0x6000 && address < 0x8000) |
| 2027 | 2052 | { |
| 2028 | | if (offset >= 0x200000) |
| 2029 | | return state->m_slotcart->m_cart->write_l(space, offset, data); |
| 2053 | if (offset >= 0x200000) |
| 2054 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2030 | 2055 | } |
| 2031 | | if (address >= 0x8000) |
| 2032 | | return state->m_slotcart->m_cart->write_l(space, offset, data); |
| 2056 | if (address >= 0x8000) |
| 2057 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2033 | 2058 | } |
| 2034 | | return state->m_slotcart->m_cart->write_l(space, offset, data); |
| 2035 | | } |
| 2059 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2060 | } |
| 2036 | 2061 | |
| 2037 | | static READ8_HANDLER( snesbsx_lo_r ) |
| 2062 | READ8_MEMBER( snsnew_state::snesbsx_lo_r ) |
| 2038 | 2063 | { |
| 2039 | 2064 | return snesbsx_hi_r(space, offset, 0xff); |
| 2040 | | } |
| 2065 | } |
| 2041 | 2066 | |
| 2042 | | static WRITE8_HANDLER( snesbsx_lo_w ) |
| 2067 | WRITE8_MEMBER( snsnew_state::snesbsx_lo_w ) |
| 2043 | 2068 | { |
| 2044 | 2069 | snesbsx_hi_w(space, offset, data, 0xff); |
| 2045 | | } |
| 2070 | } |
| 2046 | 2071 | |
| 2047 | 2072 | |
| 2048 | | static READ8_HANDLER( snesnew_lo_r ) |
| 2073 | READ8_MEMBER( snsnew_state::snesnew_lo_r ) |
| 2049 | 2074 | { |
| 2050 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 2051 | | |
| 2052 | 2075 | // take care of add-on IO |
| 2053 | | if (state->m_slotcart->get_type() == SNES_DSP |
| 2076 | if (m_slotcart->get_type() == SNES_DSP |
| 2054 | 2077 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2055 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2056 | | else if (state->m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2078 | return m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2079 | else if (m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2057 | 2080 | && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2058 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x1fff); |
| 2059 | | else if (state->m_slotcart->get_type() == SNES_DSP4 |
| 2081 | return m_slotcart->m_cart->chip_read(space, offset & 0x1fff); |
| 2082 | else if (m_slotcart->get_type() == SNES_DSP4 |
| 2060 | 2083 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2061 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2062 | | else if (state->m_slotcart->get_type() == SNES_OBC1 |
| 2084 | return m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2085 | else if (m_slotcart->get_type() == SNES_OBC1 |
| 2063 | 2086 | && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2064 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2065 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2087 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2088 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2066 | 2089 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2067 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2068 | | else if (state->m_slotcart->get_type() == SNES_SRTC |
| 2090 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2091 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2069 | 2092 | && (offset < 0x400000 && (offset & 0xffff) == 0x2800)) |
| 2070 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0xffff); |
| 2093 | return m_slotcart->m_cart->chip_read(space, offset & 0xffff); |
| 2071 | 2094 | else |
| 2072 | 2095 | { |
| 2073 | | switch (state->m_type) |
| 2096 | switch (m_type) |
| 2074 | 2097 | { |
| 2075 | 2098 | case SNES_MODE20: |
| 2076 | 2099 | case SNES_ST010: |
| r21593 | r21594 | |
| 2084 | 2107 | case SNES_POKEMON: |
| 2085 | 2108 | case SNES_BANANA: |
| 2086 | 2109 | return snes20_lo_r(space, offset, 0xff); |
| 2087 | | |
| 2110 | |
| 2088 | 2111 | case SNES_MODE21: |
| 2089 | 2112 | case SNES_DSP_MODE21: |
| 2090 | 2113 | case SNES_SRTC: |
| 2091 | 2114 | case SNES_BSXHI: |
| 2092 | 2115 | return snes21_lo_r(space, offset, 0xff); |
| 2093 | | |
| 2116 | |
| 2094 | 2117 | case SNES_SFX: |
| 2095 | 2118 | return snesfx_lo_r(space, offset, 0xff); |
| 2096 | | |
| 2119 | |
| 2097 | 2120 | case SNES_SPC7110: |
| 2098 | 2121 | case SNES_SPC7110_RTC: |
| 2099 | 2122 | return snespc7110_lo_r(space, offset, 0xff); |
| 2100 | | |
| 2123 | |
| 2101 | 2124 | case SNES_SDD1: |
| 2102 | 2125 | return snesdd1_lo_r(space, offset, 0xff); |
| 2103 | | |
| 2126 | |
| 2104 | 2127 | case SNES_BSX: |
| 2105 | 2128 | return snesbsx_lo_r(space, offset, 0xff); |
| 2106 | 2129 | } |
| 2107 | 2130 | } |
| 2108 | 2131 | return snes_open_bus_r(space, 0); |
| 2109 | | } |
| 2132 | } |
| 2110 | 2133 | |
| 2111 | | static READ8_HANDLER( snesnew_hi_r ) |
| 2134 | READ8_MEMBER( snsnew_state::snesnew_hi_r ) |
| 2112 | 2135 | { |
| 2113 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 2114 | | |
| 2115 | 2136 | // take care of add-on IO |
| 2116 | | if (state->m_slotcart->get_type() == SNES_DSP |
| 2137 | if (m_slotcart->get_type() == SNES_DSP |
| 2117 | 2138 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2118 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2119 | | else if (state->m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2139 | return m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2140 | else if (m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2120 | 2141 | && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2121 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x1fff); |
| 2122 | | else if (state->m_slotcart->get_type() == SNES_DSP4 |
| 2142 | return m_slotcart->m_cart->chip_read(space, offset & 0x1fff); |
| 2143 | else if (m_slotcart->get_type() == SNES_DSP4 |
| 2123 | 2144 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2124 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2125 | | else if (state->m_slotcart->get_type() == SNES_OBC1 |
| 2145 | return m_slotcart->m_cart->chip_read(space, offset & 0x7fff); |
| 2146 | else if (m_slotcart->get_type() == SNES_OBC1 |
| 2126 | 2147 | && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2127 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2128 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2148 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2149 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2129 | 2150 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2130 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2131 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2151 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2152 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2132 | 2153 | && (offset == 0x600000 || offset == 0x600001)) |
| 2133 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2134 | | else if (state->m_slotcart->get_type() == SNES_SRTC |
| 2154 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2155 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2135 | 2156 | && (offset < 0x400000 && (offset & 0xffff) == 0x2800)) |
| 2136 | | return state->m_slotcart->m_cart->chip_read(space, offset & 0xffff); |
| 2137 | | else if ((state->m_slotcart->get_type() == SNES_POKEMON || state->m_slotcart->get_type() == SNES_BANANA) |
| 2157 | return m_slotcart->m_cart->chip_read(space, offset & 0xffff); |
| 2158 | else if ((m_slotcart->get_type() == SNES_POKEMON || m_slotcart->get_type() == SNES_BANANA) |
| 2138 | 2159 | && (offset & 0x70000) == 0x0000) |
| 2139 | 2160 | { |
| 2140 | | // printf("hi read %x\n", offset); |
| 2141 | | return state->m_slotcart->m_cart->chip_read(space, offset); |
| 2161 | // printf("hi read %x\n", offset); |
| 2162 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2142 | 2163 | } |
| 2143 | 2164 | else |
| 2144 | 2165 | { |
| 2145 | | switch (state->m_type) |
| 2166 | switch (m_type) |
| 2146 | 2167 | { |
| 2147 | 2168 | case SNES_MODE20: |
| 2148 | 2169 | case SNES_ST010: |
| r21593 | r21594 | |
| 2156 | 2177 | case SNES_POKEMON: |
| 2157 | 2178 | case SNES_BANANA: |
| 2158 | 2179 | return snes20_hi_r(space, offset, 0xff); |
| 2159 | | |
| 2180 | |
| 2160 | 2181 | case SNES_MODE21: |
| 2161 | 2182 | case SNES_DSP_MODE21: |
| 2162 | 2183 | case SNES_SRTC: |
| 2163 | 2184 | case SNES_BSXHI: |
| 2164 | 2185 | return snes21_hi_r(space, offset, 0xff); |
| 2165 | | |
| 2186 | |
| 2166 | 2187 | case SNES_SFX: |
| 2167 | 2188 | return snesfx_hi_r(space, offset, 0xff); |
| 2168 | | |
| 2189 | |
| 2169 | 2190 | case SNES_SPC7110: |
| 2170 | 2191 | case SNES_SPC7110_RTC: |
| 2171 | 2192 | return snespc7110_hi_r(space, offset, 0xff); |
| 2172 | | |
| 2193 | |
| 2173 | 2194 | case SNES_SDD1: |
| 2174 | 2195 | return snesdd1_hi_r(space, offset, 0xff); |
| 2175 | | |
| 2196 | |
| 2176 | 2197 | case SNES_BSX: |
| 2177 | 2198 | return snesbsx_hi_r(space, offset, 0xff); |
| 2178 | 2199 | } |
| 2179 | 2200 | } |
| 2180 | 2201 | return snes_open_bus_r(space, 0); |
| 2181 | | } |
| 2202 | } |
| 2182 | 2203 | |
| 2183 | | static WRITE8_HANDLER( snesnew_lo_w ) |
| 2204 | WRITE8_MEMBER( snsnew_state::snesnew_lo_w ) |
| 2184 | 2205 | { |
| 2185 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 2186 | | |
| 2187 | 2206 | // take care of add-on IO |
| 2188 | | if (state->m_slotcart->get_type() == SNES_DSP |
| 2207 | if (m_slotcart->get_type() == SNES_DSP |
| 2189 | 2208 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2190 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2191 | | else if (state->m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2209 | m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2210 | else if (m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2192 | 2211 | && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2193 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data); |
| 2194 | | else if (state->m_slotcart->get_type() == SNES_DSP4 |
| 2212 | m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data); |
| 2213 | else if (m_slotcart->get_type() == SNES_DSP4 |
| 2195 | 2214 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2196 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2197 | | else if (state->m_slotcart->get_type() == SNES_OBC1 |
| 2215 | m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2216 | else if (m_slotcart->get_type() == SNES_OBC1 |
| 2198 | 2217 | && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2199 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2200 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2218 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2219 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2201 | 2220 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2202 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2203 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2221 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2222 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2204 | 2223 | && (offset == 0x600000 || offset == 0x600001)) |
| 2205 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2206 | | else if (state->m_slotcart->get_type() == SNES_SRTC |
| 2224 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2225 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2207 | 2226 | && (offset < 0x400000 && (offset & 0xffff) == 0x2801)) |
| 2208 | | state->m_slotcart->m_cart->chip_write(space, offset & 0xffff, data); |
| 2209 | | else if (state->m_slotcart->get_type() == SNES_BANANA |
| 2227 | m_slotcart->m_cart->chip_write(space, offset & 0xffff, data); |
| 2228 | else if (m_slotcart->get_type() == SNES_BANANA |
| 2210 | 2229 | && (offset & 0x78000) == 0x8000) |
| 2211 | 2230 | { |
| 2212 | 2231 | // printf("lo write %x\n", offset); |
| 2213 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2232 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2214 | 2233 | } |
| 2215 | 2234 | else |
| 2216 | 2235 | { |
| 2217 | | switch (state->m_type) |
| 2236 | switch (m_type) |
| 2218 | 2237 | { |
| 2219 | 2238 | case SNES_MODE20: |
| 2220 | 2239 | case SNES_ST010: |
| r21593 | r21594 | |
| 2229 | 2248 | case SNES_BANANA: |
| 2230 | 2249 | snes20_lo_w(space, offset, data, 0xff); |
| 2231 | 2250 | break; |
| 2232 | | |
| 2251 | |
| 2233 | 2252 | case SNES_MODE21: |
| 2234 | 2253 | case SNES_DSP_MODE21: |
| 2235 | 2254 | case SNES_SRTC: |
| 2236 | 2255 | case SNES_BSXHI: |
| 2237 | 2256 | snes21_lo_w(space, offset, data, 0xff); |
| 2238 | 2257 | break; |
| 2239 | | |
| 2258 | |
| 2240 | 2259 | case SNES_SFX: |
| 2241 | 2260 | snesfx_lo_w(space, offset, data, 0xff); |
| 2242 | 2261 | break; |
| 2243 | | |
| 2262 | |
| 2244 | 2263 | case SNES_SPC7110: |
| 2245 | 2264 | case SNES_SPC7110_RTC: |
| 2246 | 2265 | snespc7110_lo_w(space, offset, data, 0xff); |
| 2247 | 2266 | break; |
| 2248 | | |
| 2267 | |
| 2249 | 2268 | case SNES_SDD1: |
| 2250 | 2269 | snesdd1_lo_w(space, offset, data, 0xff); |
| 2251 | 2270 | break; |
| 2252 | | |
| 2271 | |
| 2253 | 2272 | case SNES_BSX: |
| 2254 | 2273 | snesbsx_lo_w(space, offset, data, 0xff); |
| 2255 | 2274 | break; |
| 2256 | 2275 | } |
| 2257 | 2276 | } |
| 2258 | | } |
| 2277 | } |
| 2259 | 2278 | |
| 2260 | | static WRITE8_HANDLER( snesnew_hi_w ) |
| 2279 | WRITE8_MEMBER( snsnew_state::snesnew_hi_w ) |
| 2261 | 2280 | { |
| 2262 | | snsnew_state *state = space.machine().driver_data<snsnew_state>(); |
| 2263 | | |
| 2264 | 2281 | // take care of add-on IO |
| 2265 | | if (state->m_slotcart->get_type() == SNES_DSP |
| 2282 | if (m_slotcart->get_type() == SNES_DSP |
| 2266 | 2283 | && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2267 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2268 | | else if (state->m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2284 | m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2285 | else if (m_slotcart->get_type() == SNES_DSP_MODE21 |
| 2269 | 2286 | && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2270 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data); |
| 2271 | | else if (state->m_slotcart->get_type() == SNES_DSP4 |
| 2287 | m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data); |
| 2288 | else if (m_slotcart->get_type() == SNES_DSP4 |
| 2272 | 2289 | && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)) |
| 2273 | | state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2274 | | else if (state->m_slotcart->get_type() == SNES_OBC1 |
| 2290 | m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data); |
| 2291 | else if (m_slotcart->get_type() == SNES_OBC1 |
| 2275 | 2292 | && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)) |
| 2276 | | return state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2277 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2293 | return m_slotcart->m_cart->chip_write(space, offset, data); |
| 2294 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2278 | 2295 | && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000)) |
| 2279 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2280 | | else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011) |
| 2296 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2297 | else if ((m_slotcart->get_type() == SNES_ST010 || m_slotcart->get_type() == SNES_ST011) |
| 2281 | 2298 | && (offset == 0x600000 || offset == 0x600001)) |
| 2282 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2283 | | else if (state->m_slotcart->get_type() == SNES_SRTC |
| 2299 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2300 | else if (m_slotcart->get_type() == SNES_SRTC |
| 2284 | 2301 | && (offset < 0x400000 && (offset & 0xffff) == 0x2801)) |
| 2285 | | state->m_slotcart->m_cart->chip_write(space, offset & 0xffff, data); |
| 2286 | | else if ((state->m_slotcart->get_type() == SNES_POKEMON) |
| 2302 | m_slotcart->m_cart->chip_write(space, offset & 0xffff, data); |
| 2303 | else if ((m_slotcart->get_type() == SNES_POKEMON) |
| 2287 | 2304 | && (offset & 0x70000) == 0x0000) |
| 2288 | 2305 | { |
| 2289 | 2306 | // printf("hi write %x\n", offset); |
| 2290 | | state->m_slotcart->m_cart->chip_write(space, offset, data); |
| 2307 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 2291 | 2308 | } |
| 2292 | 2309 | else |
| 2293 | 2310 | { |
| 2294 | | switch (state->m_type) |
| 2311 | switch (m_type) |
| 2295 | 2312 | { |
| 2296 | 2313 | case SNES_MODE20: |
| 2297 | 2314 | case SNES_ST010: |
| r21593 | r21594 | |
| 2306 | 2323 | case SNES_BANANA: |
| 2307 | 2324 | snes20_hi_w(space, offset, data, 0xff); |
| 2308 | 2325 | break; |
| 2309 | | |
| 2326 | |
| 2310 | 2327 | case SNES_MODE21: |
| 2311 | 2328 | case SNES_DSP_MODE21: |
| 2312 | 2329 | case SNES_SRTC: |
| 2313 | 2330 | case SNES_BSXHI: |
| 2314 | 2331 | snes21_hi_w(space, offset, data, 0xff); |
| 2315 | 2332 | break; |
| 2316 | | |
| 2333 | |
| 2317 | 2334 | case SNES_SFX: |
| 2318 | 2335 | snesfx_hi_w(space, offset, data, 0xff); |
| 2319 | 2336 | break; |
| 2320 | | |
| 2337 | |
| 2321 | 2338 | case SNES_SPC7110: |
| 2322 | 2339 | case SNES_SPC7110_RTC: |
| 2323 | 2340 | snespc7110_hi_w(space, offset, data, 0xff); |
| 2324 | 2341 | break; |
| 2325 | | |
| 2342 | |
| 2326 | 2343 | case SNES_SDD1: |
| 2327 | 2344 | snesdd1_hi_w(space, offset, data, 0xff); |
| 2328 | 2345 | break; |
| 2329 | | |
| 2346 | |
| 2330 | 2347 | case SNES_BSX: |
| 2331 | 2348 | snesbsx_hi_w(space, offset, data, 0xff); |
| 2332 | 2349 | break; |
| 2333 | 2350 | } |
| 2334 | 2351 | } |
| 2335 | | } |
| 2352 | } |
| 2336 | 2353 | |
| 2337 | 2354 | |
| 2338 | 2355 | static ADDRESS_MAP_START( snesnew_map, AS_PROGRAM, 8, snsnew_state ) |
| 2339 | | AM_RANGE(0x000000, 0x7dffff) AM_READWRITE_LEGACY(snesnew_lo_r, snesnew_lo_w) |
| 2356 | AM_RANGE(0x000000, 0x7dffff) AM_READWRITE(snesnew_lo_r, snesnew_lo_w) |
| 2340 | 2357 | AM_RANGE(0x7e0000, 0x7fffff) AM_RAM /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */ |
| 2341 | | AM_RANGE(0x800000, 0xffffff) AM_READWRITE_LEGACY(snesnew_hi_r, snesnew_hi_w) |
| 2358 | AM_RANGE(0x800000, 0xffffff) AM_READWRITE(snesnew_hi_r, snesnew_hi_w) |
| 2342 | 2359 | ADDRESS_MAP_END |
| 2343 | 2360 | |
| 2344 | 2361 | static SLOT_INTERFACE_START(snes_cart) |
| 2345 | 2362 | SLOT_INTERFACE_INTERNAL("lorom", SNS_LOROM) |
| 2346 | | SLOT_INTERFACE_INTERNAL("lorom_bsx", SNS_LOROM_BSX) // LoROM + BS-X slot - unsupported |
| 2347 | | SLOT_INTERFACE_INTERNAL("lorom_cx4", SNS_LOROM) // Cart + CX4 - unsupported |
| 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 |
| 2348 | 2365 | SLOT_INTERFACE_INTERNAL("lorom_dsp", SNS_LOROM_NECDSP) |
| 2349 | 2366 | SLOT_INTERFACE_INTERNAL("lorom_dsp4", SNS_LOROM_NECDSP) |
| 2350 | 2367 | SLOT_INTERFACE_INTERNAL("lorom_obc1", SNS_LOROM_OBC1) |
| 2351 | | SLOT_INTERFACE_INTERNAL("lorom_sa1", SNS_LOROM) // Cart + SA1 - unsupported |
| 2368 | SLOT_INTERFACE_INTERNAL("lorom_sa1", SNS_LOROM) // Cart + SA1 - unsupported |
| 2352 | 2369 | SLOT_INTERFACE_INTERNAL("lorom_sdd1", SNS_LOROM_SDD1) |
| 2353 | 2370 | SLOT_INTERFACE_INTERNAL("lorom_sfx", SNS_LOROM_SUPERFX) |
| 2354 | | SLOT_INTERFACE_INTERNAL("lorom_sgb", SNS_LOROM) // SuperGB base cart - unsupported |
| 2371 | SLOT_INTERFACE_INTERNAL("lorom_sgb", SNS_LOROM) // SuperGB base cart - unsupported |
| 2355 | 2372 | SLOT_INTERFACE_INTERNAL("lorom_st010", SNS_LOROM_SETA10) |
| 2356 | 2373 | SLOT_INTERFACE_INTERNAL("lorom_st011", SNS_LOROM_SETA11) |
| 2357 | | SLOT_INTERFACE_INTERNAL("lorom_st018", SNS_LOROM) // Cart + ST018 - unsupported |
| 2358 | | SLOT_INTERFACE_INTERNAL("lorom_sufami", SNS_LOROM_SUFAMI) // Sufami Turbo base cart |
| 2374 | SLOT_INTERFACE_INTERNAL("lorom_st018", SNS_LOROM) // Cart + ST018 - unsupported |
| 2375 | SLOT_INTERFACE_INTERNAL("lorom_sufami", SNS_LOROM_SUFAMI) // Sufami Turbo base cart |
| 2359 | 2376 | SLOT_INTERFACE_INTERNAL("hirom", SNS_HIROM) |
| 2360 | | SLOT_INTERFACE_INTERNAL("hirom_bsx", SNS_HIROM_BSX) // HiROM + BS-X slot - unsupported |
| 2377 | SLOT_INTERFACE_INTERNAL("hirom_bsx", SNS_HIROM_BSX) // HiROM + BS-X slot - unsupported |
| 2361 | 2378 | SLOT_INTERFACE_INTERNAL("hirom_dsp", SNS_HIROM_NECDSP) |
| 2362 | 2379 | SLOT_INTERFACE_INTERNAL("hirom_spc7110", SNS_HIROM_SPC7110) |
| 2363 | 2380 | SLOT_INTERFACE_INTERNAL("hirom_spcrtc", SNS_HIROM_SPC7110_RTC) |
| 2364 | 2381 | SLOT_INTERFACE_INTERNAL("hirom_srtc", SNS_HIROM_SRTC) |
| 2365 | | SLOT_INTERFACE_INTERNAL("bsxrom", SNS_ROM_BSX) // BS-X base cart - partial support only |
| 2382 | SLOT_INTERFACE_INTERNAL("bsxrom", SNS_ROM_BSX) // BS-X base cart - partial support only |
| 2366 | 2383 | // pirate carts |
| 2367 | 2384 | SLOT_INTERFACE_INTERNAL("lorom_poke", SNS_LOROM_POKEMON) |
| 2368 | 2385 | SLOT_INTERFACE_END |
| r21593 | r21594 | |
| 2380 | 2397 | switch (state->m_type) |
| 2381 | 2398 | { |
| 2382 | 2399 | case SNES_MODE21: |
| 2383 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w)); |
| 2384 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w)); |
| 2400 | 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)); |
| 2401 | 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)); |
| 2385 | 2402 | set_5a22_map(*state->m_maincpu); |
| 2386 | 2403 | break; |
| 2387 | 2404 | case SNES_DSP_MODE21: |