Previous 199869 Revisions Next

r18069 Friday 21st September, 2012 at 20:44:07 UTC by Tafoid
Better simulation of Metal Slug X's protection device.  [IQ_132]
[src/mame/includes]neogeo.h
[src/mame/machine]neoprot.c

trunk/src/mame/machine/neoprot.c
r18068r18069
151151
152152
153153/************************ Metal Slug X *************************
154  todo: emulate, not patch!
155154  Special board is used: NEO-MVS PROGEOP (1999.2.2)
156155  The board has a ALTERA (EPM7128SQC100-15) chip which is tied to 250-P1
157156  Also found on this special board is a QFP144 labeled with 0103
158157***************************************************************/
159158
160void mslugx_install_protection( running_machine &machine )
159static WRITE16_HANDLER( mslugx_protection_16_w )
161160{
162   int i;
163   UINT16 *mem16 = (UINT16 *)machine.root_device().memregion("maincpu")->base();
161   neogeo_state *state = space.machine().driver_data<neogeo_state>();
164162
165   for (i = 0;i < (0x100000/2) - 4;i++)
163   switch (offset)
166164   {
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
189static 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++;
173200      }
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;
174212   }
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;
181213
182   mem16[0x3c36/2] = 0x4e71;
183   mem16[0x3c38/2] = 0x4e71;
214   return res;
184215}
185216
186217
218void mslugx_install_protection( running_machine &machine )
219{
220   neogeo_state *state = machine.driver_data<neogeo_state>();
187221
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
188229/************************ SMA Protection************************
189230  thanks to Razoola
190231***************************************************************/
trunk/src/mame/includes/neogeo.h
r18068r18069
108108   UINT16     m_neogeo_rng;
109109   UINT16     *m_pvc_cartridge_ram;
110110   int        m_fixed_layer_bank_type;
111   UINT16     m_mslugx_counter;
112   UINT16     m_mslugx_command;
111113
112114   /* devices */
113115   cpu_device *m_maincpu;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team