--- BasiliskII/src/rsrc_patches.cpp 1999/10/03 14:16:25 1.1.1.1 +++ BasiliskII/src/rsrc_patches.cpp 2000/10/09 17:45:58 1.7 @@ -1,7 +1,7 @@ /* * rsrc_patches.cpp - Resource 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 @@ -22,12 +22,17 @@ #include "sysdeps.h" #include "cpu_emulation.h" +#include "macos_util.h" #include "main.h" #include "emul_op.h" #include "audio.h" #include "audio_defs.h" #include "rsrc_patches.h" +#if ENABLE_MON +#include "mon.h" +#endif + #define DEBUG 0 #include "debug.h" @@ -63,9 +68,9 @@ void CheckLoad(uint32 type, int16 id, ui { uint16 *p16; uint32 base; - D(bug("vCheckLoad %c%c%c%c (%08lx) ID %d, data %08lx, size %ld\n", (char)(type >> 24), (char)((type >> 16) & 0xff), (char )((type >> 8) & 0xff), (char )(type & 0xff), type, id, p, size)); - - if (type == 'boot' && id == 3) { + D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %08x, size %d\n", (char)(type >> 24), (char)((type >> 16) & 0xff), (char )((type >> 8) & 0xff), (char )(type & 0xff), type, id, p, size)); + + if (type == FOURCC('b','o','o','t') && id == 3) { D(bug(" boot 3 found\n")); // Set boot stack pointer (7.5, 7.6, 7.6.1, 8.0) @@ -85,12 +90,13 @@ void CheckLoad(uint32 type, int16 id, ui if (base) { p16 = (uint16 *)(p + base); -#if defined(AMIGA) +#if defined(AMIGA) || defined(__NetBSD__) || defined(USE_SCRATCHMEM_SUBTERFUGE) // Set 0x0000 to scratch memory area - extern uint32 ScratchMem; + extern uint8 *ScratchMem; + const uint32 ScratchMemBase = Host2MacAddr(ScratchMem); *p16++ = htons(0x207c); // move.l #ScratchMem,a0 - *p16++ = htons(ScratchMem >> 16); - *p16++ = htons(ScratchMem); + *p16++ = htons(ScratchMemBase >> 16); + *p16++ = htons(ScratchMemBase); *p16++ = htons(M68K_NOP); *p16 = htons(M68K_NOP); #else @@ -100,7 +106,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 2 applied\n")); } - } else if (type == 'boot' && id == 2) { + } else if (type == FOURCC('b','o','o','t') && id == 2) { D(bug(" boot 2 found\n")); // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0) @@ -109,12 +115,13 @@ void CheckLoad(uint32 type, int16 id, ui if (base) { p16 = (uint16 *)(p + base); -#if defined(AMIGA) +#if defined(AMIGA) || defined(__NetBSD__) || defined(USE_SCRATCHMEM_SUBTERFUGE) // Set 0x0000 to scratch memory area - extern uint32 ScratchMem; + extern uint8 *ScratchMem; + const uint32 ScratchMemBase = Host2MacAddr(ScratchMem); *p16++ = htons(0x207c); // move.l #ScratchMem,a0 - *p16++ = htons(ScratchMem >> 16); - *p16++ = htons(ScratchMem); + *p16++ = htons(ScratchMemBase >> 16); + *p16++ = htons(ScratchMemBase); *p16++ = htons(M68K_NOP); *p16 = htons(M68K_NOP); #else @@ -125,7 +132,7 @@ void CheckLoad(uint32 type, int16 id, ui } #endif - } else if (type == 'PTCH' && id == 630) { + } else if (type == FOURCC('P','T','C','H') && id == 630) { D(bug("PTCH 630 found\n")); // Don't replace Time Manager (Classic ROM, 6.0.3) @@ -152,7 +159,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 1 applied\n")); } - } else if (type == 'ptch' && id == 26) { + } else if (type == FOURCC('p','t','c','h') && id == 26) { D(bug(" ptch 26 found\n")); // Trap ABC4 is initialized with absolute ROM address (7.5, 7.6, 7.6.1, 8.0) @@ -166,7 +173,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 1 applied\n")); } - } else if (type == 'ptch' && id == 34) { + } else if (type == FOURCC('p','t','c','h') && id == 34) { D(bug(" ptch 34 found\n")); // Don't wait for VIA (Classic ROM, 6.0.8) @@ -191,7 +198,7 @@ void CheckLoad(uint32 type, int16 id, ui } #if !EMULATED_68K - } else if (CPUIs68060 && (type == 'gpch' && id == 669 || type == 'lpch' && id == 63)) { + } else if (CPUIs68060 && (type == FOURCC('g','p','c','h') && id == 669 || type == FOURCC('l','p','c','h') && id == 63)) { D(bug(" gpch 669/lpch 63 found\n")); static uint16 ThPatchSpace[1024]; // Replacement routines are constructed here @@ -450,20 +457,22 @@ void CheckLoad(uint32 type, int16 id, ui } #endif - } else if (type == 'gpch' && id == 750) { + } else if (type == FOURCC('g','p','c','h') && id == 750) { D(bug(" gpch 750 found\n")); // Don't use PTEST instruction in BlockMove() (7.5, 7.6, 7.6.1, 8.0) - static const uint8 dat[] = {0xa0, 0x8d, 0x0c, 0x81, 0x00, 0x00, 0x0c, 0x00, 0x65, 0x06, 0x4e, 0x71, 0xf4, 0xf8}; + static const uint8 dat[] = {0x20, 0x5f, 0x22, 0x5f, 0x0c, 0x38, 0x00, 0x04, 0x01, 0x2f}; base = find_rsrc_data(p, size, dat, sizeof(dat)); if (base) { - p16 = (uint16 *)(p + base + 8); - *p16 = htons(M68K_NOP); - FlushCodeCache(p + base + 8, 2); + p16 = (uint16 *)(p + base + 4); + *p16++ = htons(M68K_EMUL_OP_BLOCK_MOVE); + *p16++ = htons(0x7000); + *p16 = htons(M68K_RTS); + FlushCodeCache(p + base + 4, 6); D(bug(" patch 1 applied\n")); } - } else if (type == 'lpch' && id == 24) { + } else if (type == FOURCC('l','p','c','h') && id == 24) { D(bug(" lpch 24 found\n")); // Don't replace Time Manager (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0) @@ -480,7 +489,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 1 applied\n")); } - } else if (type == 'lpch' && id == 31) { + } else if (type == FOURCC('l','p','c','h') && id == 31) { D(bug(" lpch 31 found\n")); // Don't write to VIA in vSoundDead() (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0) @@ -506,7 +515,7 @@ void CheckLoad(uint32 type, int16 id, ui } #if !EMULATED_68K - } else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) { + } else if (CPUIs68060 && type == FOURCC('s','c','o','d') && (id == -16463 || id == -16464)) { D(bug(" scod -16463/-16464 found\n")); // Correct 68060 FP frame handling in Process Manager task switches (7.1, 7.5, 8.0) @@ -534,14 +543,14 @@ void CheckLoad(uint32 type, int16 id, ui } #endif - } else if (type == 'thng' && id == -16563) { + } else if (type == FOURCC('t','h','n','g') && id == -16563) { D(bug(" thng -16563 found\n")); // Set audio component flags (7.5, 7.6, 7.6.1, 8.0) *(uint32 *)(p + componentFlags) = htonl(audio_component_flags); D(bug(" patch 1 applied\n")); - } else if (type == 'sift' && id == -16563) { + } else if (type == FOURCC('s','i','f','t') && id == -16563) { D(bug(" sift -16563 found\n")); // Replace audio component (7.5, 7.6, 7.6.1, 8.0) @@ -558,7 +567,7 @@ void CheckLoad(uint32 type, int16 id, ui FlushCodeCache(p, 32); D(bug(" patch 1 applied\n")); - } else if (type == 'inst' && id == -19069) { + } else if (type == FOURCC('i','n','s','t') && id == -19069) { D(bug(" inst -19069 found\n")); // Don't replace Microseconds (QuickTime 2.0) @@ -571,7 +580,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 1 applied\n")); } - } else if (type == 'DRVR' && id == -20066) { + } else if (type == FOURCC('D','R','V','R') && id == -20066) { D(bug("DRVR -20066 found\n")); // Don't access SCC in .Infra driver @@ -584,7 +593,7 @@ void CheckLoad(uint32 type, int16 id, ui D(bug(" patch 1 applied\n")); } - } else if (type == 'ltlk' && id == 0) { + } else if (type == FOURCC('l','t','l','k') && id == 0) { D(bug(" ltlk 0 found\n")); // Disable LocalTalk (7.0.1, 7.5, 7.6, 7.6.1, 8.0) @@ -595,4 +604,27 @@ void CheckLoad(uint32 type, int16 id, ui FlushCodeCache(p, 6); D(bug(" patch 1 applied\n")); } +#if REAL_ADDRESSING && !defined(AMIGA) + else if (type == FOURCC('D','R','V','R') && id == 41) { + D(bug(" DRVR 41 found\n")); + + // gb-- [0x28E (ROM85)] contains 0x3fff that will be placed into a0 + // Seems to be caused by the AppleShare extension from MacOS 8.1 (3.7.4) + // .AFPTranslator (DRVR addr 0x2372) + static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40}; + base = find_rsrc_data(p, size, dat, sizeof(dat)); + if (base) { + p16 = (uint16 *)(p + base + 4); + *p16++ = htons(0x3078); // movea.w ROM85,%a0 + *p16++ = htons(0x028e); + *p16++ = htons(0xd1fc); // adda.l #RAMBaseMac,%a0 + *p16++ = htons((RAMBaseMac >> 16) & 0xffff); + *p16++ = htons(RAMBaseMac & 0xffff); + *p16++ = htons(0x2448); // movea.l %a0,%a2 + *p16++ = htons(M68K_NOP); + FlushCodeCache(p + base + 4, 14); + D(bug(" patch 1 applied\n")); + } + } +#endif }