--- BasiliskII/src/rom_patches.cpp 1999/10/27 16:59:38 1.11 +++ BasiliskII/src/rom_patches.cpp 2000/07/22 16:07:17 1.15 @@ -1,7 +1,7 @@ /* * rom_patches.cpp - ROM patches * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2000 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,6 @@ bool PrintROMInfo = false; // Flag: prin static uint32 sony_offset; // ROM offset of .Sony driver static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) static uint32 microseconds_offset; // ROM offset of Microseconds() replacement routine -static uint32 memory_dispatch_offset; // ROM offset of MemoryDispatch() replacement routine // Prototypes uint16 ROMVersion; @@ -82,6 +81,8 @@ static uint32 find_rom_resource(uint32 s if (!cont) rsrc_ptr = x; + else + rsrc_ptr = ReadMacInt32(ROMBaseMac + rsrc_ptr + 8); for (;;) { lp = ROMBaseMac + rsrc_ptr; @@ -269,7 +270,7 @@ static void list_universal_infos(void) printf("Universal Table at %08x:\n", q); printf("Offset\t ID\tHWCfg\tROM85\tModel\n"); printf("------------------------------------------------\n"); - while (ofs = ReadMacInt32(ROMBaseMac + q)) { + while ((ofs = ReadMacInt32(ROMBaseMac + q))) { print_universal_info(ROMBaseMac + ofs + q); q += 4; } @@ -692,7 +693,7 @@ static const uint8 adbop_patch[] = { // void InstallDrivers(uint32 pb) { - D(bug("InstallDrivers\n")); + D(bug("InstallDrivers, pb %08x\n", pb)); M68kRegisters r; // Install Microseconds() replacement routine @@ -700,11 +701,6 @@ void InstallDrivers(uint32 pb) r.d[0] = 0xa093; Execute68kTrap(0xa247, &r); // SetOSTrapAddress() - // Install MemoryDispatch() replacement routine - r.a[0] = ROMBaseMac + memory_dispatch_offset; - r.d[0] = 0xa05c; - Execute68kTrap(0xa247, &r); // SetOSTrapAddress() - // Install disk driver r.a[0] = ROMBaseMac + sony_offset + 0x100; r.d[0] = (uint32)DiskRefNum; @@ -1219,7 +1215,7 @@ static bool patch_rom_32(void) #endif #if !ROM_IS_WRITE_PROTECTED -#if defined(AMIGA) +#if defined(AMIGA) || defined(__NetBSD__) // Set fake handle at 0x0000 to scratch memory area (so broken Mac programs won't write into Mac ROM) extern uint32 ScratchMem; wp = (uint16 *)(ROMBaseHost + 0xccaa); @@ -1459,13 +1455,13 @@ static bool patch_rom_32(void) static const uint8 memdisp_dat[] = {0x30, 0x3c, 0xa8, 0x9f, 0xa7, 0x46, 0x30, 0x3c, 0xa0, 0x5c, 0xa2, 0x47}; base = find_rom_data(0x4f100, 0x4f180, memdisp_dat, sizeof(memdisp_dat)); D(bug("memdisp %08lx\n", base)); - if (base) { // ROM15/32 + if (base) { // ROM15/22/23/26/27/32 wp = (uint16 *)(ROMBaseHost + base + 10); *wp = htons(M68K_NOP); } // Patch .EDisk driver (don't scan for EDisks in the area ROMBase..0xe00000) - uint32 edisk_offset = find_rom_resource('DRVR', 51); + uint32 edisk_offset = find_rom_resource(FOURCC('D','R','V','R'), 51); if (edisk_offset) { static const uint8 edisk_dat[] = {0xd5, 0xfc, 0x00, 0x01, 0x00, 0x00, 0xb5, 0xfc, 0x00, 0xe0, 0x00, 0x00}; base = find_rom_data(edisk_offset, edisk_offset + 0x10000, edisk_dat, sizeof(edisk_dat)); @@ -1478,7 +1474,7 @@ static bool patch_rom_32(void) } // Replace .Sony driver - sony_offset = find_rom_resource('DRVR', 4); + sony_offset = find_rom_resource(FOURCC('D','R','V','R'), 4); D(bug("sony %08lx\n", sony_offset)); memcpy(ROMBaseHost + sony_offset, sony_driver, sizeof(sony_driver)); @@ -1497,7 +1493,7 @@ static bool patch_rom_32(void) memcpy(ROMBaseHost + sony_offset + 0xa00, CDROMIcon, sizeof(CDROMIcon)); // Install SERD patch and serial drivers - serd_offset = find_rom_resource('SERD', 0); + serd_offset = find_rom_resource(FOURCC('S','E','R','D'), 0); D(bug("serd %08lx\n", serd_offset)); wp = (uint16 *)(ROMBaseHost + serd_offset + 12); *wp++ = htons(M68K_EMUL_OP_SERD); @@ -1565,12 +1561,6 @@ static bool patch_rom_32(void) *wp++ = htons(base >> 16); *wp = htons(base & 0xffff); - // Install MemoryDispatch() replacement routine (activated in PatchAfterStartup()) - memory_dispatch_offset = sony_offset + 0xc20; - wp = (uint16 *)(ROMBaseHost + memory_dispatch_offset); - *wp++ = htons(M68K_EMUL_OP_MEMORY_DISPATCH); - *wp = htons(M68K_RTS); - #if EMULATED_68K // Replace BlockMove() wp = (uint16 *)(ROMBaseHost + find_rom_trap(0xa02e)); // BlockMove() @@ -1579,6 +1569,11 @@ static bool patch_rom_32(void) *wp = htons(M68K_RTS); #endif + // Look for double PACK 4 resources + if ((base = find_rom_resource(FOURCC('P','A','C','K'), 4)) == 0) return false; + if ((base = find_rom_resource(FOURCC('P','A','C','K'), 4, true)) == 0 && FPUType == 0) + printf("WARNING: This ROM seems to require an FPU\n"); + // Patch VIA interrupt handler wp = (uint16 *)(ROMBaseHost + 0x9bc4); // Level 1 handler *wp++ = htons(0x7002); // moveq #2,d0 (always 60Hz interrupt)