1 |
|
/* |
2 |
|
* rom_patches.cpp - ROM patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
44 |
|
uint32 ROMBreakpoint = 0; // ROM offset of breakpoint (0 = disabled, 0x2310 = CritError) |
45 |
|
bool PrintROMInfo = false; // Flag: print ROM information in PatchROM() |
46 |
|
|
47 |
< |
static uint32 sony_offset; // ROM offset of .Sony driver |
48 |
< |
static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) |
49 |
< |
static uint32 microseconds_offset; // ROM offset of Microseconds() replacement routine |
50 |
< |
static uint32 memory_dispatch_offset; // ROM offset of MemoryDispatch() replacement routine |
47 |
> |
static uint32 sony_offset; // ROM offset of .Sony driver |
48 |
> |
static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) |
49 |
> |
static uint32 microseconds_offset; // ROM offset of Microseconds() replacement routine |
50 |
> |
static uint32 debugutil_offset; // ROM offset of DebugUtil() replacement routine |
51 |
|
|
52 |
|
// Prototypes |
53 |
|
uint16 ROMVersion; |
82 |
|
|
83 |
|
if (!cont) |
84 |
|
rsrc_ptr = x; |
85 |
+ |
else |
86 |
+ |
rsrc_ptr = ReadMacInt32(ROMBaseMac + rsrc_ptr + 8); |
87 |
|
|
88 |
|
for (;;) { |
89 |
|
lp = ROMBaseMac + rsrc_ptr; |
271 |
|
printf("Universal Table at %08x:\n", q); |
272 |
|
printf("Offset\t ID\tHWCfg\tROM85\tModel\n"); |
273 |
|
printf("------------------------------------------------\n"); |
274 |
< |
while (ofs = ReadMacInt32(ROMBaseMac + q)) { |
274 |
> |
while ((ofs = ReadMacInt32(ROMBaseMac + q))) { |
275 |
|
print_universal_info(ROMBaseMac + ofs + q); |
276 |
|
q += 4; |
277 |
|
} |
694 |
|
|
695 |
|
void InstallDrivers(uint32 pb) |
696 |
|
{ |
697 |
< |
D(bug("InstallDrivers\n")); |
697 |
> |
D(bug("InstallDrivers, pb %08x\n", pb)); |
698 |
|
M68kRegisters r; |
699 |
|
|
700 |
|
// Install Microseconds() replacement routine |
702 |
|
r.d[0] = 0xa093; |
703 |
|
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
704 |
|
|
705 |
< |
// Install MemoryDispatch() replacement routine |
706 |
< |
r.a[0] = ROMBaseMac + memory_dispatch_offset; |
707 |
< |
r.d[0] = 0xa05c; |
705 |
> |
// Install DebugUtil() replacement routine |
706 |
> |
r.a[0] = ROMBaseMac + debugutil_offset; |
707 |
> |
r.d[0] = 0xa08d; |
708 |
|
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
709 |
|
|
710 |
|
// Install disk driver |
936 |
|
*wp++ = htons(M68K_RTS); |
937 |
|
microseconds_offset = (uint8 *)wp - ROMBaseHost; |
938 |
|
*wp++ = htons(M68K_EMUL_OP_MICROSECONDS); |
939 |
+ |
*wp++ = htons(M68K_RTS); |
940 |
+ |
|
941 |
+ |
// Replace DebugUtil |
942 |
+ |
debugutil_offset = (uint8 *)wp - ROMBaseHost; |
943 |
+ |
*wp++ = htons(M68K_EMUL_OP_DEBUGUTIL); |
944 |
|
*wp = htons(M68K_RTS); |
945 |
|
|
946 |
|
// Replace SCSIDispatch() |
1203 |
|
*wp = htons(M68K_RTS); |
1204 |
|
|
1205 |
|
// Fake CPU speed test (SetupTimeK) |
1206 |
+ |
// *** increased jl : MacsBug uses TimeDBRA for kbd repeat timing |
1207 |
|
wp = (uint16 *)(ROMBaseHost + 0x800); |
1208 |
|
*wp++ = htons(0x31fc); // move.w #xxx,TimeDBRA |
1209 |
< |
*wp++ = htons(100); |
1209 |
> |
*wp++ = htons(10000); |
1210 |
|
*wp++ = htons(0x0d00); |
1211 |
|
*wp++ = htons(0x31fc); // move.w #xxx,TimeSCCDBRA |
1212 |
< |
*wp++ = htons(100); |
1212 |
> |
*wp++ = htons(10000); |
1213 |
|
*wp++ = htons(0x0d02); |
1214 |
|
*wp++ = htons(0x31fc); // move.w #xxx,TimeSCSIDBRA |
1215 |
< |
*wp++ = htons(100); |
1215 |
> |
*wp++ = htons(10000); |
1216 |
|
*wp++ = htons(0x0b24); |
1217 |
|
*wp++ = htons(0x31fc); // move.w #xxx,TimeRAMDBRA |
1218 |
< |
*wp++ = htons(100); |
1218 |
> |
*wp++ = htons(10000); |
1219 |
|
*wp++ = htons(0x0cea); |
1220 |
|
*wp = htons(M68K_RTS); |
1221 |
|
|
1467 |
|
static const uint8 memdisp_dat[] = {0x30, 0x3c, 0xa8, 0x9f, 0xa7, 0x46, 0x30, 0x3c, 0xa0, 0x5c, 0xa2, 0x47}; |
1468 |
|
base = find_rom_data(0x4f100, 0x4f180, memdisp_dat, sizeof(memdisp_dat)); |
1469 |
|
D(bug("memdisp %08lx\n", base)); |
1470 |
< |
if (base) { // ROM15/32 |
1470 |
> |
if (base) { // ROM15/22/23/26/27/32 |
1471 |
|
wp = (uint16 *)(ROMBaseHost + base + 10); |
1472 |
|
*wp = htons(M68K_NOP); |
1473 |
|
} |
1474 |
|
|
1475 |
|
// Patch .EDisk driver (don't scan for EDisks in the area ROMBase..0xe00000) |
1476 |
< |
uint32 edisk_offset = find_rom_resource('DRVR', 51); |
1476 |
> |
uint32 edisk_offset = find_rom_resource(FOURCC('D','R','V','R'), 51); |
1477 |
|
if (edisk_offset) { |
1478 |
|
static const uint8 edisk_dat[] = {0xd5, 0xfc, 0x00, 0x01, 0x00, 0x00, 0xb5, 0xfc, 0x00, 0xe0, 0x00, 0x00}; |
1479 |
|
base = find_rom_data(edisk_offset, edisk_offset + 0x10000, edisk_dat, sizeof(edisk_dat)); |
1486 |
|
} |
1487 |
|
|
1488 |
|
// Replace .Sony driver |
1489 |
< |
sony_offset = find_rom_resource('DRVR', 4); |
1489 |
> |
sony_offset = find_rom_resource(FOURCC('D','R','V','R'), 4); |
1490 |
|
D(bug("sony %08lx\n", sony_offset)); |
1491 |
|
memcpy(ROMBaseHost + sony_offset, sony_driver, sizeof(sony_driver)); |
1492 |
|
|
1505 |
|
memcpy(ROMBaseHost + sony_offset + 0xa00, CDROMIcon, sizeof(CDROMIcon)); |
1506 |
|
|
1507 |
|
// Install SERD patch and serial drivers |
1508 |
< |
serd_offset = find_rom_resource('SERD', 0); |
1508 |
> |
serd_offset = find_rom_resource(FOURCC('S','E','R','D'), 0); |
1509 |
|
D(bug("serd %08lx\n", serd_offset)); |
1510 |
|
wp = (uint16 *)(ROMBaseHost + serd_offset + 12); |
1511 |
|
*wp++ = htons(M68K_EMUL_OP_SERD); |
1538 |
|
*wp++ = htons(M68K_RTS); |
1539 |
|
microseconds_offset = (uint8 *)wp - ROMBaseHost; |
1540 |
|
*wp++ = htons(M68K_EMUL_OP_MICROSECONDS); |
1541 |
+ |
*wp++ = htons(M68K_RTS); |
1542 |
+ |
|
1543 |
+ |
// Replace DebugUtil |
1544 |
+ |
debugutil_offset = (uint8 *)wp - ROMBaseHost; |
1545 |
+ |
*wp++ = htons(M68K_EMUL_OP_DEBUGUTIL); |
1546 |
|
*wp = htons(M68K_RTS); |
1547 |
|
|
1548 |
|
// Replace SCSIDispatch() |
1578 |
|
*wp++ = htons(base >> 16); |
1579 |
|
*wp = htons(base & 0xffff); |
1580 |
|
|
1568 |
– |
// Install MemoryDispatch() replacement routine (activated in PatchAfterStartup()) |
1569 |
– |
memory_dispatch_offset = sony_offset + 0xc20; |
1570 |
– |
wp = (uint16 *)(ROMBaseHost + memory_dispatch_offset); |
1571 |
– |
*wp++ = htons(M68K_EMUL_OP_MEMORY_DISPATCH); |
1572 |
– |
*wp = htons(M68K_RTS); |
1573 |
– |
|
1581 |
|
#if EMULATED_68K |
1582 |
|
// Replace BlockMove() |
1583 |
|
wp = (uint16 *)(ROMBaseHost + find_rom_trap(0xa02e)); // BlockMove() |
1586 |
|
*wp = htons(M68K_RTS); |
1587 |
|
#endif |
1588 |
|
|
1589 |
+ |
// Look for double PACK 4 resources |
1590 |
+ |
if ((base = find_rom_resource(FOURCC('P','A','C','K'), 4)) == 0) return false; |
1591 |
+ |
if ((base = find_rom_resource(FOURCC('P','A','C','K'), 4, true)) == 0 && FPUType == 0) |
1592 |
+ |
printf("WARNING: This ROM seems to require an FPU\n"); |
1593 |
+ |
|
1594 |
|
// Patch VIA interrupt handler |
1595 |
|
wp = (uint16 *)(ROMBaseHost + 0x9bc4); // Level 1 handler |
1596 |
|
*wp++ = htons(0x7002); // moveq #2,d0 (always 60Hz interrupt) |