trunk/src/mame/drivers/btime.c
r18890 | r18891 | |
149 | 149 | #define HCLK2 (HCLK1/2) |
150 | 150 | #define HCLK4 (HCLK2/2) |
151 | 151 | |
152 | | |
153 | 152 | enum |
154 | 153 | { |
155 | 154 | AUDIO_ENABLE_NONE, |
r18890 | r18891 | |
157 | 156 | AUDIO_ENABLE_AY8910 /* via ay-8910 port A */ |
158 | 157 | }; |
159 | 158 | |
| 159 | class deco_cpu7_device : public m6502_device { |
| 160 | public: |
| 161 | deco_cpu7_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
160 | 162 | |
| 163 | protected: |
| 164 | class mi_decrypt : public mi_default_normal { |
| 165 | public: |
| 166 | bool had_written; |
161 | 167 | |
162 | | static UINT8 *decrypted; // TODO: put me in btime class |
| 168 | virtual UINT8 read_decrypted(UINT16 adr); |
| 169 | virtual void write(UINT16 adr, UINT8 val); |
| 170 | }; |
163 | 171 | |
164 | | WRITE8_MEMBER(btime_state::audio_nmi_enable_w) |
| 172 | virtual void device_start(); |
| 173 | virtual void device_reset(); |
| 174 | |
| 175 | }; |
| 176 | |
| 177 | static const device_type DECO_CPU7 = &device_creator<deco_cpu7_device>; |
| 178 | |
| 179 | deco_cpu7_device::deco_cpu7_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 180 | m6502_device(mconfig, DECO_CPU7, "DECO CPU-7", tag, owner, clock) |
165 | 181 | { |
166 | | /* for most games, this serves as the NMI enable for the audio CPU; however, |
167 | | lnc and disco use bit 0 of the first AY-8910's port A instead; many other |
168 | | games also write there in addition to this address */ |
169 | | if (m_audio_nmi_enable_type == AUDIO_ENABLE_DIRECT) |
170 | | { |
171 | | m_audio_nmi_enabled = data & 1; |
172 | | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
173 | | } |
174 | 182 | } |
175 | 183 | |
176 | | WRITE8_MEMBER(btime_state::ay_audio_nmi_enable_w) |
| 184 | void deco_cpu7_device::device_start() |
177 | 185 | { |
178 | | /* port A bit 0, when 1, inhibits the NMI */ |
179 | | if (m_audio_nmi_enable_type == AUDIO_ENABLE_AY8910) |
180 | | { |
181 | | m_audio_nmi_enabled = ~data & 1; |
182 | | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
183 | | } |
| 186 | mintf = new mi_decrypt; |
| 187 | init(); |
184 | 188 | } |
185 | 189 | |
186 | | TIMER_DEVICE_CALLBACK_MEMBER(btime_state::audio_nmi_gen) |
| 190 | void deco_cpu7_device::device_reset() |
187 | 191 | { |
188 | | int scanline = param; |
189 | | m_audio_nmi_state = scanline & 8; |
190 | | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
| 192 | m6502_device::device_reset(); |
| 193 | static_cast<mi_decrypt *>(mintf)->had_written = false; |
191 | 194 | } |
192 | 195 | |
193 | | |
194 | | |
195 | | INLINE UINT8 swap_bits_5_6(UINT8 data) |
| 196 | UINT8 deco_cpu7_device::mi_decrypt::read_decrypted(UINT16 adr) |
196 | 197 | { |
197 | | return BITSWAP8(data,7,5,6,4,3,2,1,0); |
| 198 | UINT8 res = direct->read_raw_byte(adr); |
| 199 | if(had_written) { |
| 200 | had_written = false; |
| 201 | if((adr & 0x0104) == 0x0104) |
| 202 | res = BITSWAP8(res, 6,5,3,4,2,7,1,0); |
| 203 | } |
| 204 | return res; |
198 | 205 | } |
199 | 206 | |
200 | | |
201 | | static void btime_decrypt( address_space &space ) |
| 207 | void deco_cpu7_device::mi_decrypt::write(UINT16 adr, UINT8 val) |
202 | 208 | { |
203 | | btime_state *state = space.machine().driver_data<btime_state>(); |
204 | | UINT8 *src, *src1; |
205 | | int addr, addr1; |
| 209 | program->write_byte(adr, val); |
| 210 | had_written = true; |
| 211 | } |
206 | 212 | |
207 | | /* the encryption is a simple bit rotation: 76543210 -> 65342710, but */ |
208 | | /* with a catch: it is only applied if the previous instruction did a */ |
209 | | /* memory write. Also, only opcodes at addresses with this bit pattern: */ |
210 | | /* xxxx xxx1 xxxx x1xx are encrypted. */ |
211 | 213 | |
212 | | /* get the address of the next opcode */ |
213 | | addr = space.device().safe_pc(); |
| 214 | class deco_c10707_device : public m6502_device { |
| 215 | public: |
| 216 | deco_c10707_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
214 | 217 | |
215 | | /* however if the previous instruction was JSR (which caused a write to */ |
216 | | /* the stack), fetch the address of the next instruction. */ |
217 | | addr1 = space.device().safe_pcbase(); |
218 | | src1 = (addr1 < 0x9000) ? state->m_rambase : state->memregion("maincpu")->base(); |
219 | | if (decrypted[addr1] == 0x20) /* JSR $xxxx */ |
220 | | addr = src1[addr1 + 1] + 256 * src1[addr1 + 2]; |
| 218 | protected: |
| 219 | class mi_decrypt : public mi_default_normal { |
| 220 | public: |
| 221 | bool had_written; |
221 | 222 | |
222 | | /* If the address of the next instruction is xxxx xxx1 xxxx x1xx, decode it. */ |
223 | | src = (addr < 0x9000) ? state->m_rambase : state->memregion("maincpu")->base(); |
224 | | if ((addr & 0x0104) == 0x0104) |
225 | | { |
226 | | /* 76543210 -> 65342710 bit rotation */ |
227 | | decrypted[addr] = BITSWAP8(src[addr],6,5,3,4,2,7,1,0); |
228 | | } |
229 | | } |
| 223 | virtual UINT8 read_decrypted(UINT16 adr); |
| 224 | }; |
230 | 225 | |
231 | | WRITE8_MEMBER(btime_state::lnc_w) |
232 | | { |
233 | | if (offset <= 0x3bff) ; |
234 | | else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; } |
235 | | else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; } |
236 | | else if (offset == 0x8000) { return; } /* AM_NOP */ |
237 | | else if (offset == 0x8001) { bnj_video_control_w(space, 0, data); return; } |
238 | | else if (offset == 0x8003) ; |
239 | | else if (offset == 0x9000) { return; } /* AM_NOP */ |
240 | | else if (offset == 0x9002) { audio_command_w(space, 0, data); return; } |
241 | | else if (offset >= 0xb000 && offset <= 0xb1ff) ; |
242 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
| 226 | virtual void device_start(); |
| 227 | virtual void device_reset(); |
243 | 228 | |
244 | | m_rambase[offset] = data; |
| 229 | }; |
245 | 230 | |
246 | | /* Swap bits 5 & 6 for opcodes */ |
247 | | decrypted[offset] = swap_bits_5_6(data); |
248 | | } |
| 231 | static const device_type DECO_C10707 = &device_creator<deco_c10707_device>; |
249 | 232 | |
250 | | WRITE8_MEMBER(btime_state::mmonkey_w) |
| 233 | deco_c10707_device::deco_c10707_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 234 | m6502_device(mconfig, DECO_C10707, "DECO CPU-7", tag, owner, clock) |
251 | 235 | { |
252 | | if (offset <= 0x3bff) ; |
253 | | else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; } |
254 | | else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; } |
255 | | else if (offset == 0x8001) { bnj_video_control_w(space, 0, data); return; } |
256 | | else if (offset == 0x8003) ; |
257 | | else if (offset == 0x9000) { return; } /* AM_NOP */ |
258 | | else if (offset == 0x9002) { audio_command_w(space, 0, data); return; } |
259 | | else if (offset >= 0xb000 && offset <= 0xbfff) { mmonkey_protection_w(space, offset - 0xb000, data); return; } |
260 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
261 | | |
262 | | m_rambase[offset] = data; |
263 | | |
264 | | /* Swap bits 5 & 6 for opcodes */ |
265 | | decrypted[offset] = swap_bits_5_6(data); |
266 | 236 | } |
267 | 237 | |
268 | | WRITE8_MEMBER(btime_state::btime_w) |
| 238 | void deco_c10707_device::device_start() |
269 | 239 | { |
270 | | if (offset <= 0x07ff) ; |
271 | | else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data); |
272 | | else if (offset >= 0x1000 && offset <= 0x17ff) ; |
273 | | else if (offset >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space, offset - 0x1800, data); |
274 | | else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space, offset - 0x1c00, data); |
275 | | else if (offset == 0x4002) btime_video_control_w(space, 0, data); |
276 | | else if (offset == 0x4003) audio_command_w(space, 0, data); |
277 | | else if (offset == 0x4004) bnj_scroll1_w(space, 0, data); |
278 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
279 | | |
280 | | m_rambase[offset] = data; |
281 | | |
282 | | btime_decrypt(space); |
| 240 | mintf = new mi_decrypt; |
| 241 | init(); |
283 | 242 | } |
284 | 243 | |
285 | | WRITE8_MEMBER(btime_state::tisland_w) |
| 244 | void deco_c10707_device::device_reset() |
286 | 245 | { |
287 | | if (offset <= 0x07ff) ; |
288 | | else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data); |
289 | | else if (offset >= 0x1000 && offset <= 0x17ff) ; |
290 | | else if (offset >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space, offset - 0x1800, data); |
291 | | else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space, offset - 0x1c00, data); |
292 | | else if (offset == 0x4002) btime_video_control_w(space, 0, data); |
293 | | else if (offset == 0x4003) audio_command_w(space, 0, data); |
294 | | else if (offset == 0x4004) bnj_scroll1_w(space, 0, data); |
295 | | else if (offset == 0x4005) bnj_scroll2_w(space, 0, data); |
296 | | // else if (offset == 0x8000) btime_video_control_w(space,0,data); |
297 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
298 | | |
299 | | m_rambase[offset] = data; |
300 | | |
301 | | btime_decrypt(space); |
| 246 | m6502_device::device_reset(); |
| 247 | static_cast<mi_decrypt *>(mintf)->had_written = false; |
302 | 248 | } |
303 | 249 | |
304 | | WRITE8_MEMBER(btime_state::zoar_w) |
| 250 | UINT8 deco_c10707_device::mi_decrypt::read_decrypted(UINT16 adr) |
305 | 251 | { |
306 | | if (offset <= 0x07ff) ; |
307 | | else if (offset >= 0x8000 && offset <= 0x87ff) ; |
308 | | else if (offset >= 0x8800 && offset <= 0x8bff) btime_mirrorvideoram_w(space, offset - 0x8800, data); |
309 | | else if (offset >= 0x8c00 && offset <= 0x8fff) btime_mirrorcolorram_w(space, offset - 0x8c00, data); |
310 | | else if (offset == 0x9000) zoar_video_control_w(space, 0, data); |
311 | | else if (offset >= 0x9800 && offset <= 0x9803) ; |
312 | | else if (offset == 0x9804) bnj_scroll2_w(space, 0, data); |
313 | | else if (offset == 0x9805) bnj_scroll1_w(space, 0, data); |
314 | | else if (offset == 0x9806) audio_command_w(space, 0, data); |
315 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
| 252 | return BITSWAP8(direct->read_raw_byte(adr) ,7,5,6,4,3,2,1,0);; |
| 253 | } |
316 | 254 | |
317 | | m_rambase[offset] = data; |
318 | | |
319 | | btime_decrypt(space); |
| 255 | WRITE8_MEMBER(btime_state::audio_nmi_enable_w) |
| 256 | { |
| 257 | /* for most games, this serves as the NMI enable for the audio CPU; however, |
| 258 | lnc and disco use bit 0 of the first AY-8910's port A instead; many other |
| 259 | games also write there in addition to this address */ |
| 260 | if (m_audio_nmi_enable_type == AUDIO_ENABLE_DIRECT) |
| 261 | { |
| 262 | m_audio_nmi_enabled = data & 1; |
| 263 | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
| 264 | } |
320 | 265 | } |
321 | 266 | |
322 | | WRITE8_MEMBER(btime_state::disco_w) |
| 267 | WRITE8_MEMBER(btime_state::ay_audio_nmi_enable_w) |
323 | 268 | { |
324 | | if (offset <= 0x04ff) ; |
325 | | else if (offset >= 0x2000 && offset <= 0x7fff) deco_charram_w(space, offset - 0x2000, data); |
326 | | else if (offset >= 0x8000 && offset <= 0x881f) ; |
327 | | else if (offset == 0x9a00) audio_command_w(space, 0, data); |
328 | | else if (offset == 0x9c00) disco_video_control_w(space, 0, data); |
329 | | else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space.device().tag(), space.device().safe_pc(), data, offset); |
| 269 | /* port A bit 0, when 1, inhibits the NMI */ |
| 270 | if (m_audio_nmi_enable_type == AUDIO_ENABLE_AY8910) |
| 271 | { |
| 272 | m_audio_nmi_enabled = ~data & 1; |
| 273 | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
| 274 | } |
| 275 | } |
330 | 276 | |
331 | | m_rambase[offset] = data; |
332 | | |
333 | | btime_decrypt(space); |
| 277 | TIMER_DEVICE_CALLBACK_MEMBER(btime_state::audio_nmi_gen) |
| 278 | { |
| 279 | int scanline = param; |
| 280 | m_audio_nmi_state = scanline & 8; |
| 281 | m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_nmi_enabled && m_audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); |
334 | 282 | } |
335 | 283 | |
336 | | |
337 | 284 | static ADDRESS_MAP_START( btime_map, AS_PROGRAM, 8, btime_state ) |
338 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(btime_w) /* override the following entries to */ |
339 | | /* support ROM decryption */ |
340 | 285 | AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("rambase") |
341 | 286 | AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_SHARE("paletteram") |
342 | 287 | AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("videoram") |
r18890 | r18891 | |
372 | 317 | ADDRESS_MAP_END |
373 | 318 | |
374 | 319 | static ADDRESS_MAP_START( tisland_map, AS_PROGRAM, 8, btime_state ) |
375 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(tisland_w) /* override the following entries to */ |
376 | | /* support ROM decryption */ |
377 | 320 | AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("rambase") |
378 | 321 | AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_SHARE("paletteram") |
379 | 322 | AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("videoram") |
r18890 | r18891 | |
390 | 333 | ADDRESS_MAP_END |
391 | 334 | |
392 | 335 | static ADDRESS_MAP_START( zoar_map, AS_PROGRAM, 8, btime_state ) |
393 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(zoar_w) /* override the following entries to */ |
394 | | /* support ROM decryption */ |
395 | 336 | AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("rambase") |
396 | 337 | AM_RANGE(0x8000, 0x83ff) AM_WRITEONLY AM_SHARE("videoram") |
397 | 338 | AM_RANGE(0x8400, 0x87ff) AM_WRITEONLY AM_SHARE("colorram") |
r18890 | r18891 | |
410 | 351 | ADDRESS_MAP_END |
411 | 352 | |
412 | 353 | static ADDRESS_MAP_START( lnc_map, AS_PROGRAM, 8, btime_state ) |
413 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(lnc_w) /* override the following entries to */ |
414 | | /* support ROM decryption */ |
415 | 354 | AM_RANGE(0x0000, 0x3bff) AM_RAM AM_SHARE("rambase") |
416 | 355 | AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_SHARE("videoram") |
417 | 356 | AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_SHARE("colorram") /* this is just here to initialize the pointer */ |
r18890 | r18891 | |
427 | 366 | ADDRESS_MAP_END |
428 | 367 | |
429 | 368 | static ADDRESS_MAP_START( mmonkey_map, AS_PROGRAM, 8, btime_state ) |
430 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(mmonkey_w) /* override the following entries to */ |
431 | | /* support ROM decryption */ |
432 | 369 | AM_RANGE(0x0000, 0x3bff) AM_RAM AM_SHARE("rambase") |
433 | 370 | AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_SHARE("videoram") |
434 | 371 | AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_SHARE("colorram") /* this is just here to initialize the pointer */ |
r18890 | r18891 | |
462 | 399 | ADDRESS_MAP_END |
463 | 400 | |
464 | 401 | static ADDRESS_MAP_START( disco_map, AS_PROGRAM, 8, btime_state ) |
465 | | AM_RANGE(0x0000, 0xffff) AM_WRITE(disco_w) /* override the following entries to */ |
466 | | /* support ROM decryption */ |
467 | 402 | AM_RANGE(0x0000, 0x04ff) AM_RAM AM_SHARE("rambase") |
468 | 403 | AM_RANGE(0x2000, 0x7fff) AM_RAM_WRITE(deco_charram_w) AM_SHARE("deco_charram") |
469 | 404 | AM_RANGE(0x8000, 0x83ff) AM_RAM AM_SHARE("videoram") |
r18890 | r18891 | |
1457 | 1392 | static MACHINE_CONFIG_START( btime, btime_state ) |
1458 | 1393 | |
1459 | 1394 | /* basic machine hardware */ |
1460 | | MCFG_CPU_ADD("maincpu", M6502, HCLK2) /* seletable between H2/H4 via jumper */ |
| 1395 | MCFG_CPU_ADD("maincpu", DECO_CPU7, HCLK2) /* seletable between H2/H4 via jumper */ |
1461 | 1396 | MCFG_CPU_PROGRAM_MAP(btime_map) |
1462 | 1397 | |
1463 | 1398 | MCFG_CPU_ADD("audiocpu", M6502, HCLK1/3/2) |
r18890 | r18891 | |
1502 | 1437 | static MACHINE_CONFIG_DERIVED( cookrace, btime ) |
1503 | 1438 | |
1504 | 1439 | /* basic machine hardware */ |
1505 | | MCFG_CPU_MODIFY("maincpu") |
| 1440 | MCFG_CPU_REPLACE("maincpu", DECO_C10707, HCLK2) |
1506 | 1441 | MCFG_CPU_PROGRAM_MAP(cookrace_map) |
1507 | 1442 | |
1508 | 1443 | MCFG_CPU_MODIFY("audiocpu") |
r18890 | r18891 | |
1520 | 1455 | static MACHINE_CONFIG_DERIVED( lnc, btime ) |
1521 | 1456 | |
1522 | 1457 | /* basic machine hardware */ |
1523 | | MCFG_CPU_MODIFY("maincpu") |
| 1458 | MCFG_CPU_REPLACE("maincpu", DECO_C10707, HCLK2) |
1524 | 1459 | MCFG_CPU_PROGRAM_MAP(lnc_map) |
1525 | 1460 | |
1526 | 1461 | MCFG_MACHINE_RESET_OVERRIDE(btime_state,lnc) |
r18890 | r18891 | |
1558 | 1493 | static MACHINE_CONFIG_DERIVED( sdtennis, btime ) |
1559 | 1494 | |
1560 | 1495 | /* basic machine hardware */ |
1561 | | MCFG_CPU_MODIFY("maincpu") |
| 1496 | MCFG_CPU_REPLACE("maincpu", DECO_C10707, HCLK4) |
1562 | 1497 | MCFG_CPU_CLOCK(HCLK4) |
1563 | 1498 | MCFG_CPU_PROGRAM_MAP(bnj_map) |
1564 | 1499 | |
r18890 | r18891 | |
2035 | 1970 | ROM_LOAD( "ao_04.10f", 0x1000, 0x1000, CRC(921952af) SHA1(4e9248f3493a5f4651278f27c11f507571242317) ) |
2036 | 1971 | ROM_END |
2037 | 1972 | |
2038 | | static void decrypt_C10707_cpu(running_machine &machine, const char *cputag) |
2039 | | { |
2040 | | address_space &space = machine.device(cputag)->memory().space(AS_PROGRAM); |
2041 | | UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000); |
2042 | | UINT8 *rom = machine.root_device().memregion(cputag)->base(); |
2043 | | offs_t addr; |
2044 | | |
2045 | | space.set_decrypted_region(0x0000, 0xffff, decrypt); |
2046 | | |
2047 | | /* Swap bits 5 & 6 for opcodes */ |
2048 | | for (addr = 0; addr < 0x10000; addr++) |
2049 | | decrypt[addr] = swap_bits_5_6(rom[addr]); |
2050 | | |
2051 | | if (&space.device() == machine.device("maincpu")) |
2052 | | decrypted = decrypt; |
2053 | | } |
2054 | | |
2055 | 1973 | READ8_MEMBER(btime_state::wtennis_reset_hack_r) |
2056 | 1974 | { |
2057 | 1975 | UINT8 *RAM = memregion("maincpu")->base(); |
r18890 | r18891 | |
2065 | 1983 | return RAM[0xc15f]; |
2066 | 1984 | } |
2067 | 1985 | |
2068 | | static void init_rom1(running_machine &machine) |
2069 | | { |
2070 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
2071 | | UINT8 *rom = machine.root_device().memregion("maincpu")->base(); |
2072 | | |
2073 | | decrypted = auto_alloc_array(machine, UINT8, 0x10000); |
2074 | | space.set_decrypted_region(0x0000, 0xffff, decrypted); |
2075 | | |
2076 | | /* For now, just copy the RAM array over to ROM. Decryption will happen */ |
2077 | | /* at run time, since the CPU applies the decryption only if the previous */ |
2078 | | /* instruction did a memory write. */ |
2079 | | memcpy(decrypted,rom,0x10000); |
2080 | | } |
2081 | | |
2082 | 1986 | DRIVER_INIT_MEMBER(btime_state,btime) |
2083 | 1987 | { |
2084 | | init_rom1(machine()); |
2085 | 1988 | m_audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; |
2086 | 1989 | } |
2087 | 1990 | |
r18890 | r18891 | |
2095 | 1998 | I'm NOPing it out for now. */ |
2096 | 1999 | memset(&rom[0xd50a],0xea,8); |
2097 | 2000 | |
2098 | | init_rom1(machine()); |
2099 | 2001 | m_audio_nmi_enable_type = AUDIO_ENABLE_AY8910; |
2100 | 2002 | } |
2101 | 2003 | |
r18890 | r18891 | |
2104 | 2006 | UINT8 *rom = memregion("maincpu")->base(); |
2105 | 2007 | |
2106 | 2008 | /* At location 0xa2b6 there's a strange RLA followed by a BPL that reads from an |
2107 | | unmapped area that causes the game to fail in several circumstances.On the Cassette |
2108 | | version the RLA (33) is in reality a BIT (24),so I'm guessing that there's something |
2109 | | wrong going on in the encryption scheme.*/ |
| 2009 | unmapped area that causes the game to fail in several circumstances.On the Cassette |
| 2010 | version the RLA (33) is in reality a BIT (24),so I'm guessing that there's something |
| 2011 | wrong going on in the encryption scheme.*/ |
2110 | 2012 | memset(&rom[0xa2b6],0x24,1); |
2111 | 2013 | |
2112 | | init_rom1(machine()); |
2113 | 2014 | m_audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; |
2114 | 2015 | } |
2115 | 2016 | |
2116 | 2017 | DRIVER_INIT_MEMBER(btime_state,lnc) |
2117 | 2018 | { |
2118 | | decrypt_C10707_cpu(machine(), "maincpu"); |
2119 | 2019 | m_audio_nmi_enable_type = AUDIO_ENABLE_AY8910; |
2120 | 2020 | } |
2121 | 2021 | |
2122 | 2022 | DRIVER_INIT_MEMBER(btime_state,bnj) |
2123 | 2023 | { |
2124 | | decrypt_C10707_cpu(machine(), "maincpu"); |
2125 | 2024 | m_audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; |
2126 | 2025 | } |
2127 | 2026 | |
r18890 | r18891 | |
2133 | 2032 | |
2134 | 2033 | DRIVER_INIT_MEMBER(btime_state,cookrace) |
2135 | 2034 | { |
2136 | | decrypt_C10707_cpu(machine(), "maincpu"); |
2137 | | |
2138 | 2035 | machine().device("audiocpu")->memory().space(AS_PROGRAM).install_read_bank(0x0200, 0x0fff, "bank10"); |
2139 | 2036 | membank("bank10")->set_base(memregion("audiocpu")->base() + 0xe200); |
2140 | 2037 | m_audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; |
r18890 | r18891 | |
2148 | 2045 | |
2149 | 2046 | DRIVER_INIT_MEMBER(btime_state,wtennis) |
2150 | 2047 | { |
2151 | | decrypt_C10707_cpu(machine(), "maincpu"); |
2152 | | |
2153 | 2048 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xc15f, 0xc15f, read8_delegate(FUNC(btime_state::wtennis_reset_hack_r),this)); |
2154 | 2049 | |
2155 | 2050 | machine().device("audiocpu")->memory().space(AS_PROGRAM).install_read_bank(0x0200, 0x0fff, "bank10"); |
r18890 | r18891 | |
2159 | 2054 | |
2160 | 2055 | DRIVER_INIT_MEMBER(btime_state,sdtennis) |
2161 | 2056 | { |
2162 | | decrypt_C10707_cpu(machine(), "maincpu"); |
2163 | | decrypt_C10707_cpu(machine(), "audiocpu"); |
2164 | 2057 | m_audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; |
2165 | 2058 | } |
2166 | 2059 | |