trunk/src/mame/machine/neoprot.c
| r18068 | r18069 | |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | /************************ Metal Slug X ************************* |
| 154 | | todo: emulate, not patch! |
| 155 | 154 | Special board is used: NEO-MVS PROGEOP (1999.2.2) |
| 156 | 155 | The board has a ALTERA (EPM7128SQC100-15) chip which is tied to 250-P1 |
| 157 | 156 | Also found on this special board is a QFP144 labeled with 0103 |
| 158 | 157 | ***************************************************************/ |
| 159 | 158 | |
| 160 | | void mslugx_install_protection( running_machine &machine ) |
| 159 | static WRITE16_HANDLER( mslugx_protection_16_w ) |
| 161 | 160 | { |
| 162 | | int i; |
| 163 | | UINT16 *mem16 = (UINT16 *)machine.root_device().memregion("maincpu")->base(); |
| 161 | neogeo_state *state = space.machine().driver_data<neogeo_state>(); |
| 164 | 162 | |
| 165 | | for (i = 0;i < (0x100000/2) - 4;i++) |
| 163 | switch (offset) |
| 166 | 164 | { |
| 167 | | if (mem16[i + 0] == 0x0243 && |
| 168 | | mem16[i + 1] == 0x0001 && /* andi.w #$1, D3 */ |
| 169 | | mem16[i + 2] == 0x6600) /* bne xxxx */ |
| 170 | | { |
| 171 | | mem16[i + 2] = 0x4e71; |
| 172 | | mem16[i + 3] = 0x4e71; |
| 165 | case 0x0/2: // start new read? |
| 166 | state->m_mslugx_command = 0; |
| 167 | break; |
| 168 | |
| 169 | case 0x2/2: // command? These are pulsed with data and then 0 |
| 170 | case 0x4/2: |
| 171 | state->m_mslugx_command |= data; |
| 172 | break; |
| 173 | |
| 174 | case 0x6/2: // finished? |
| 175 | break; |
| 176 | |
| 177 | case 0xa/2: // init? |
| 178 | state->m_mslugx_counter = 0; |
| 179 | state->m_mslugx_command = 0; |
| 180 | break; |
| 181 | |
| 182 | default: |
| 183 | logerror("unknown protection write at pc %06x, offset %08x, data %02x\n", space.device().safe_pc(), offset << 1, data); |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | |
| 189 | static READ16_HANDLER( mslugx_protection_16_r ) |
| 190 | { |
| 191 | neogeo_state *state = space.machine().driver_data<neogeo_state>(); |
| 192 | |
| 193 | UINT16 res = 0; |
| 194 | |
| 195 | switch (state->m_mslugx_command) |
| 196 | { |
| 197 | case 0x0001: { // $3bdc(?) and $3c30 (Register D7) |
| 198 | res = (space.read_byte(0xdedd2 + ((state->m_mslugx_counter >> 3) & 0xfff)) >> (~state->m_mslugx_counter & 0x07)) & 1; |
| 199 | state->m_mslugx_counter++; |
| 173 | 200 | } |
| 201 | break; |
| 202 | |
| 203 | case 0x0fff: { // All other accesses (Register D2) |
| 204 | INT32 select = space.read_word(0x10f00a) - 1; // How should this be calculated? |
| 205 | res = (space.read_byte(0xdedd2 + ((select >> 3) & 0x0fff)) >> (~select & 0x07)) & 1; |
| 206 | } |
| 207 | break; |
| 208 | |
| 209 | default: |
| 210 | logerror("unknown protection read at pc %06x, offset %08x\n", space.device().safe_pc(), offset << 1); |
| 211 | break; |
| 174 | 212 | } |
| 175 | | mem16[0x3bdc/2] = 0x4e71; |
| 176 | | mem16[0x3bde/2] = 0x4e71; |
| 177 | | mem16[0x3be0/2] = 0x4e71; |
| 178 | | mem16[0x3c0c/2] = 0x4e71; |
| 179 | | mem16[0x3c0e/2] = 0x4e71; |
| 180 | | mem16[0x3c10/2] = 0x4e71; |
| 181 | 213 | |
| 182 | | mem16[0x3c36/2] = 0x4e71; |
| 183 | | mem16[0x3c38/2] = 0x4e71; |
| 214 | return res; |
| 184 | 215 | } |
| 185 | 216 | |
| 186 | 217 | |
| 218 | void mslugx_install_protection( running_machine &machine ) |
| 219 | { |
| 220 | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 187 | 221 | |
| 222 | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fffe0, 0x2fffef, FUNC(mslugx_protection_16_r), FUNC(mslugx_protection_16_w)); |
| 223 | |
| 224 | state->save_item(NAME(state->m_mslugx_command)); |
| 225 | state->save_item(NAME(state->m_mslugx_counter)); |
| 226 | } |
| 227 | |
| 228 | |
| 188 | 229 | /************************ SMA Protection************************ |
| 189 | 230 | thanks to Razoola |
| 190 | 231 | ***************************************************************/ |