diff --git a/bin/driver7M5.bin b/bin/driver7M5.bin index 12c3eb8..fef9a0b 100755 Binary files a/bin/driver7M5.bin and b/bin/driver7M5.bin differ diff --git a/bin/rom8M.bin b/bin/rom8M.bin index 2a3571d..c8cc38d 100755 Binary files a/bin/rom8M.bin and b/bin/rom8M.bin differ diff --git a/rdisk.c b/rdisk.c index 17973f1..51a7b29 100644 --- a/rdisk.c +++ b/rdisk.c @@ -36,7 +36,7 @@ static void RDDecodeSettings(Ptr unmountEN, Ptr mountEN, Ptr ramEN, Ptr dbgEN, P } } - // MacsBug enabled if bit 3 == 1 or DBGDis addr invalid or not boot + // MacsBug enabled if bit 2 == 1 or DBGDis addr invalid or not boot *dbgEN = *unmountEN || (legacy_startup & 0x04) || (*RDiskDBGDisPos == 0); @@ -48,14 +48,25 @@ static void RDDecodeSettings(Ptr unmountEN, Ptr mountEN, Ptr ramEN, Ptr dbgEN, P } // Switch to 32-bit mode and copy -#pragma parameter RDCopy24(__A0, __A1, __D0) -void RDCopy24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) { +#pragma parameter C24(__A0, __A1, __D0) +void C24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) { signed char mode = true32b; SwapMMUMode(&mode); BlockMove(sourcePtr, destPtr, byteCount); SwapMMUMode(&mode); } +// Switch to 32-bit mode and patch +void P24(Ptr ramdisk, char dbgEN, char cdromEN) { + if (!ramdisk) { return; } + signed char mode = true32b; + SwapMMUMode(&mode); + // Patch debug and CD-ROM disable bytes + if (!dbgEN) { ramdisk[*RDiskDBGDisPos] = *RDiskDBGDisByte; } + if (!cdromEN) { ramdisk[*RDiskCDROMDisPos] = *RDiskCDROMDisByte; } + SwapMMUMode(&mode); +} + // Figure out the first available drive number >= 5 static int RDFindDrvNum() { DrvQElPtr dq; @@ -126,8 +137,6 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) { c->dbgEN = dbgEN; c->cdromEN = cdromEN; - char dis = 0x44; - // If RAM disk enabled, try to allocate RAM disk buffer if not already if (ramEN & !c->ramdisk) { if (*MMU32bit) { // 32-bit mode @@ -144,33 +153,24 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) { BlockMove(RDiskBuf, c->ramdisk, RDiskSize); // Clearing write protect marks RAM disk enabled c->status.writeProt = 0; - - // Patch debug and CD-ROM enable bytes - BlockMove(&c->ramdisk[*RDiskDBGDisPos], &dis, 1); - BlockMove(&c->ramdisk[*RDiskCDROMDisPos], &dis, 1); } } else { // 24-bit mode // Put RAM disk just past 8MB c->ramdisk = (Ptr)(8 * 1024 * 1024); // Copy ROM disk image to RAM disk - copy24(RDiskBuf, c->ramdisk, RDiskSize); - // Clearing write protect marks RAM disk enabled - c->status.writeProt = 0; //FIXME: what if we don't have enough RAM? // Will this wrap around and overwrite low memory? // That's not the worst, since the system would just crash, // but it would be better to switch to read-only status - // Patch debug and CD-ROM enable bytes - copy24(&c->ramdisk[*RDiskDBGDisPos], &dis, 1); - copy24(&c->ramdisk[*RDiskCDROMDisPos], &dis, 1); + copy24(RDiskBuf, c->ramdisk, RDiskSize); + // Clearing write protect marks RAM disk enabled + c->status.writeProt = 0; } - // Patch debug and CD-ROM enable bytes - //if (!c->dbgEN) { - //} - //if (!c->cdromEN) { - //} } + // Patch debug and CD-ROM enable bytes + patch24(c->ramdisk, dbgEN, cdromEN); + // Unmount if not booting from ROM disk if (unmountEN) { c->status.diskInPlace = 0; } diff --git a/rdisk.h b/rdisk.h index e947293..efd6492 100644 --- a/rdisk.h +++ b/rdisk.h @@ -19,9 +19,6 @@ OSErr RDiskAddDrive(short drvrRefNum, short drvNum, DrvQElPtr dq) = {0x4840, 0x3 static inline char RDiskIsRPressed() { return *((char*)0x175) & 0x80; } static inline char RDiskIsAPressed() { return *((char*)0x174) & 0x01; } -typedef void (*RDiskCopy_t)(Ptr, Ptr, unsigned long); -#define copy24(s, d, b) { RDiskCopy_t copy24 = (RDiskCopy_t)RDCopy24; copy24(s, d, b); } - //#define RDISK_COMPRESS_ICON_ENABLE #define RDISK_ICON_SIZE (285) typedef struct RDiskStorage_s { @@ -35,6 +32,11 @@ typedef struct RDiskStorage_s { #endif } RDiskStorage_t; +typedef void (*RDiskCopy_t)(Ptr, Ptr, unsigned long); +#define copy24(s, d, b) { RDiskCopy_t copy24 = (RDiskCopy_t)C24; copy24(s, d, b); } +typedef void (*RDiskPatch_t)(Ptr, char, char); +#define patch24(s, d, b) { RDiskPatch_t patch24 = (RDiskPatch_t)P24; patch24(s, d, b); } + #define PackBits_Repeat(count) (-1 * (count - 1)) #define PackBits_Literal(count) (count - 1)