trunk/src/mess/drivers/snes.c
| r21570 | r21571 | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
| 61 | static READ8_HANDLER( snes_lo_r ) |
| 62 | { |
| 63 | if (offset < 0x300000) |
| 64 | return snes_r_bank1(space, offset, 0xff); |
| 65 | else if (offset < 0x400000) |
| 66 | return snes_r_bank2(space, offset - 0x300000, 0xff); |
| 67 | else if (offset < 0x600000) |
| 68 | return snes_r_bank3(space, offset - 0x400000, 0xff); |
| 69 | else if (offset < 0x700000) |
| 70 | return snes_r_bank4(space, offset - 0x600000, 0xff); |
| 71 | else |
| 72 | return snes_r_bank5(space, offset - 0x700000, 0xff); |
| 73 | } |
| 61 | 74 | |
| 75 | static READ8_HANDLER( snes_hi_r ) |
| 76 | { |
| 77 | if (offset < 0x400000) |
| 78 | return snes_r_bank6(space, offset, 0xff); |
| 79 | else |
| 80 | return snes_r_bank7(space, offset - 0x400000, 0xff); |
| 81 | } |
| 82 | |
| 83 | static WRITE8_HANDLER( snes_lo_w ) |
| 84 | { |
| 85 | if (offset < 0x300000) |
| 86 | snes_w_bank1(space, offset, data, 0xff); |
| 87 | else if (offset < 0x400000) |
| 88 | snes_w_bank2(space, offset - 0x300000, data, 0xff); |
| 89 | else if (offset < 0x600000) |
| 90 | return; |
| 91 | else if (offset < 0x700000) |
| 92 | snes_w_bank4(space, offset - 0x600000, data, 0xff); |
| 93 | else |
| 94 | snes_w_bank5(space, offset - 0x700000, data, 0xff); |
| 95 | } |
| 96 | |
| 97 | static WRITE8_HANDLER( snes_hi_w ) |
| 98 | { |
| 99 | if (offset < 0x400000) |
| 100 | snes_w_bank6(space, offset, data, 0xff); |
| 101 | else |
| 102 | snes_w_bank7(space, offset, data - 0x400000, 0xff); |
| 103 | } |
| 104 | |
| 105 | static READ8_HANDLER( superfx_r_bank1 ) |
| 106 | { |
| 107 | return snes_ram[offset | 0x8000]; |
| 108 | } |
| 109 | |
| 110 | static READ8_HANDLER( superfx_r_bank2 ) |
| 111 | { |
| 112 | return snes_ram[0x400000 + offset]; |
| 113 | } |
| 114 | |
| 115 | static READ8_HANDLER( superfx_r_bank3 ) |
| 116 | { |
| 117 | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 118 | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| 119 | as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */ |
| 120 | //printf("superfx_r_bank3: %08x = %02x\n", offset, snes_ram[0xe00000 + offset]); |
| 121 | return snes_ram[0xe00000 + offset]; |
| 122 | } |
| 123 | |
| 124 | static WRITE8_HANDLER( superfx_w_bank1 ) |
| 125 | { |
| 126 | printf("Attempting to write to cart ROM: %08x = %02x\n", offset, data); |
| 127 | // Do nothing; can't write to cart ROM. |
| 128 | } |
| 129 | |
| 130 | static WRITE8_HANDLER( superfx_w_bank2 ) |
| 131 | { |
| 132 | printf("Attempting to write to cart ROM: %08x = %02x\n", 0x400000 + offset, data); |
| 133 | // Do nothing; can't write to cart ROM. |
| 134 | } |
| 135 | |
| 136 | static WRITE8_HANDLER( superfx_w_bank3 ) |
| 137 | { |
| 138 | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 139 | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| 140 | as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */ |
| 141 | //printf("superfx_w_bank3: %08x = %02x\n", offset, data); |
| 142 | snes_ram[0xe00000 + offset] = data; |
| 143 | } |
| 144 | |
| 62 | 145 | /************************************* |
| 63 | 146 | * |
| 64 | 147 | * Address maps |
| r21570 | r21571 | |
| 66 | 149 | *************************************/ |
| 67 | 150 | |
| 68 | 151 | static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, snes_state ) |
| 69 | | AM_RANGE(0x000000, 0x2fffff) AM_READWRITE_LEGACY(snes_r_bank1, snes_w_bank1) /* I/O and ROM (repeats for each bank) */ |
| 70 | | AM_RANGE(0x300000, 0x3fffff) AM_READWRITE_LEGACY(snes_r_bank2, snes_w_bank2) /* I/O and ROM (repeats for each bank) */ |
| 71 | | AM_RANGE(0x400000, 0x5fffff) AM_READ_LEGACY(snes_r_bank3) /* ROM (and reserved in Mode 20) */ |
| 72 | | AM_RANGE(0x600000, 0x6fffff) AM_READWRITE_LEGACY(snes_r_bank4, snes_w_bank4) /* used by Mode 20 DSP-1 */ |
| 73 | | AM_RANGE(0x700000, 0x7dffff) AM_READWRITE_LEGACY(snes_r_bank5, snes_w_bank5) |
| 152 | AM_RANGE(0x000000, 0x7dffff) AM_READWRITE_LEGACY(snes_lo_r, snes_lo_w) |
| 74 | 153 | AM_RANGE(0x7e0000, 0x7fffff) AM_RAM /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */ |
| 75 | | AM_RANGE(0x800000, 0xbfffff) AM_READWRITE_LEGACY(snes_r_bank6, snes_w_bank6) /* Mirror and ROM */ |
| 76 | | AM_RANGE(0xc00000, 0xffffff) AM_READWRITE_LEGACY(snes_r_bank7, snes_w_bank7) /* Mirror and ROM */ |
| 154 | AM_RANGE(0x800000, 0xffffff) AM_READWRITE_LEGACY(snes_hi_r, snes_hi_w) |
| 77 | 155 | ADDRESS_MAP_END |
| 78 | 156 | |
| 79 | 157 | static ADDRESS_MAP_START( superfx_map, AS_PROGRAM, 8, snes_state ) |
trunk/src/mame/machine/snes.c
| r21570 | r21571 | |
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | 2244 | } |
| 2245 | | |
| 2246 | | READ8_HANDLER( superfx_r_bank1 ) |
| 2247 | | { |
| 2248 | | return snes_ram[offset | 0x8000]; |
| 2249 | | } |
| 2250 | | |
| 2251 | | READ8_HANDLER( superfx_r_bank2 ) |
| 2252 | | { |
| 2253 | | return snes_ram[0x400000 + offset]; |
| 2254 | | } |
| 2255 | | |
| 2256 | | READ8_HANDLER( superfx_r_bank3 ) |
| 2257 | | { |
| 2258 | | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 2259 | | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| 2260 | | as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */ |
| 2261 | | //printf("superfx_r_bank3: %08x = %02x\n", offset, snes_ram[0xe00000 + offset]); |
| 2262 | | return snes_ram[0xe00000 + offset]; |
| 2263 | | } |
| 2264 | | |
| 2265 | | WRITE8_HANDLER( superfx_w_bank1 ) |
| 2266 | | { |
| 2267 | | printf("Attempting to write to cart ROM: %08x = %02x\n", offset, data); |
| 2268 | | // Do nothing; can't write to cart ROM. |
| 2269 | | } |
| 2270 | | |
| 2271 | | WRITE8_HANDLER( superfx_w_bank2 ) |
| 2272 | | { |
| 2273 | | printf("Attempting to write to cart ROM: %08x = %02x\n", 0x400000 + offset, data); |
| 2274 | | // Do nothing; can't write to cart ROM. |
| 2275 | | } |
| 2276 | | |
| 2277 | | WRITE8_HANDLER( superfx_w_bank3 ) |
| 2278 | | { |
| 2279 | | /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES |
| 2280 | | has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror |
| 2281 | | as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */ |
| 2282 | | //printf("superfx_w_bank3: %08x = %02x\n", offset, data); |
| 2283 | | snes_ram[0xe00000 + offset] = data; |
| 2284 | | } |