34 |
|
#include "prefs.h" |
35 |
|
#include "rom_patches.h" |
36 |
|
|
37 |
< |
#define DEBUG 1 |
37 |
> |
#define DEBUG 0 |
38 |
|
#include "debug.h" |
39 |
|
|
40 |
|
|
41 |
< |
// Breakpoint |
42 |
< |
//#define M68K_BREAKPOINT 0x2310 // CritError |
43 |
< |
//#define M68K_BREAKPOINT 0x1d10 // BootMe |
41 |
> |
// Breakpoint (offset into ROM) |
42 |
> |
uint32 ROMBreakpoint = 0; // 0 = disabled, 0x2310 = CritError |
43 |
|
|
44 |
|
// Global variables |
45 |
|
uint32 UniversalInfo; // ROM offset of UniversalInfo |
546 |
|
r.d[0] = 0xa093; |
547 |
|
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
548 |
|
|
549 |
+ |
// Install MemoryDispatch() replacement routine |
550 |
+ |
r.a[0] = ROMBaseMac + memory_dispatch_offset; |
551 |
+ |
r.d[0] = 0xa05c; |
552 |
+ |
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
553 |
+ |
|
554 |
|
// Install disk driver |
555 |
|
r.a[0] = ROMBaseMac + sony_offset + 0x100; |
556 |
|
r.d[0] = (uint32)DiskRefNum; |
646 |
|
|
647 |
|
void PatchAfterStartup(void) |
648 |
|
{ |
645 |
– |
// Install MemoryDispatch() replacement routine |
646 |
– |
M68kRegisters r; |
647 |
– |
r.a[0] = ROMBaseMac + memory_dispatch_offset; |
648 |
– |
r.d[0] = 0xa05c; |
649 |
– |
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
650 |
– |
|
649 |
|
#if SUPPORTS_EXTFS |
650 |
|
// Install external file system |
651 |
|
InstallExtFS(); |
1301 |
|
} |
1302 |
|
} |
1303 |
|
|
1304 |
+ |
// Don't set MemoryDispatch() to unimplemented trap |
1305 |
+ |
static const uint8 memdisp_dat[] = {0x30, 0x3c, 0xa8, 0x9f, 0xa7, 0x46, 0x30, 0x3c, 0xa0, 0x5c, 0xa2, 0x47}; |
1306 |
+ |
base = find_rom_data(0x4f100, 0x4f180, memdisp_dat, sizeof(memdisp_dat)); |
1307 |
+ |
D(bug("memdisp %08lx\n", base)); |
1308 |
+ |
if (base) { // ROM15/32 |
1309 |
+ |
wp = (uint16 *)(ROMBaseHost + base + 10); |
1310 |
+ |
*wp = htons(M68K_NOP); |
1311 |
+ |
} |
1312 |
+ |
|
1313 |
|
// Patch .EDisk driver (don't scan for EDisks in the area ROMBase..0xe00000) |
1314 |
|
uint32 edisk_offset = find_rom_resource('DRVR', 51); |
1315 |
|
if (edisk_offset) { |
1462 |
|
return false; |
1463 |
|
} |
1464 |
|
|
1458 |
– |
#ifdef M68K_BREAKPOINT |
1465 |
|
// Install breakpoint |
1466 |
< |
uint16 *wp = (uint16 *)(ROMBaseHost + M68K_BREAKPOINT); |
1467 |
< |
*wp = htons(M68K_EMUL_BREAK); |
1468 |
< |
#endif |
1466 |
> |
if (ROMBreakpoint) { |
1467 |
> |
uint16 *wp = (uint16 *)(ROMBaseHost + ROMBreakpoint); |
1468 |
> |
*wp = htons(M68K_EMUL_BREAK); |
1469 |
> |
} |
1470 |
|
|
1471 |
|
// Clear caches as we loaded and patched code |
1472 |
|
FlushCodeCache(ROMBaseHost, ROMSize); |