mirror of
https://github.com/garrettsworkshop/MacIIROMDiskDriver.git
synced 2025-03-04 05:32:10 +00:00
New strategy for patching ROM disk debug/CD
This commit is contained in:
parent
3e519016ac
commit
19bf5c98fe
Binary file not shown.
BIN
bin/rom8M.bin
BIN
bin/rom8M.bin
Binary file not shown.
40
rdisk.c
40
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; }
|
||||
|
||||
|
8
rdisk.h
8
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user