Fix CD/debug patch bug

This commit is contained in:
Zane Kaminski 2022-01-08 01:53:49 -05:00
parent 551b0d23e3
commit e6b8367a8e
8 changed files with 23 additions and 28 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

51
rdisk.c
View File

@ -92,6 +92,21 @@ void __attribute__ ((noinline)) S24(Ptr pos, char patch) {
SwapMMUMode(&mode); SwapMMUMode(&mode);
} }
static void RDUnpatch(unsigned long pos, Ptr patch) {
char (*peek)(Ptr) = G24;
*patch = peek(RDiskBuf + pos);
}
static void RDPatch(char enable, Ptr patch, Ptr ramdisk, unsigned long pos, char data) {
if (!enable) {
*patch = data;
if (ramdisk) {
void (*poke)(Ptr, char) = S24;
poke(ramdisk + pos, data);
}
}
}
// Figure out the first available drive number >= 5 // Figure out the first available drive number >= 5
static int RDFindDrvNum() { static int RDFindDrvNum() {
DrvQElPtr dq; DrvQElPtr dq;
@ -144,9 +159,9 @@ OSErr RDOpen(IOParamPtr p, DCtlPtr d) {
// Find first available drive number // Find first available drive number
drvNum = RDFindDrvNum(); drvNum = RDFindDrvNum();
// Get debug and CD-ROM disable settings from ROM table // Enable debugger and CD-ROM
c->dbgDisByte = RDiskDBGDisByte; RDUnpatch(RDiskDBGDisPos, &c->dbgDisByte);
c->cdrDisByte = RDiskCDRDisByte; RDUnpatch(RDiskCDRDisPos, &c->cdrDisByte);
// Set drive status // Set drive status
//c->status.track = 0; //c->status.track = 0;
@ -173,19 +188,6 @@ OSErr RDOpen(IOParamPtr p, DCtlPtr d) {
return noErr; return noErr;
} }
static void RDPatchRAMDisk(char enable, Ptr ram, Ptr rom,
unsigned long pos, unsigned long size, Ptr patch) {
if (pos < size) {
if (enable) {
void (*poke)(Ptr, char) = S24;
poke(ram + pos, *patch);
} else {
char (*peek)(Ptr) = G24;
*patch = peek(rom + pos);
}
}
}
// Init is called at beginning of first prime (read/write) call // Init is called at beginning of first prime (read/write) call
static void RDBootInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) { static void RDBootInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
// Mark init done // Mark init done
@ -216,19 +218,12 @@ static void RDBootInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
// but it would be better to switch to read-only status // but it would be better to switch to read-only status
} }
} }
if (c->ramdisk) {
// Copy ROM disk image to RAM disk // Copy ROM disk image to RAM disk
copy24(RDiskBuf, c->ramdisk, RDiskSize); if (c->ramdisk) { copy24(RDiskBuf, c->ramdisk, RDiskSize); }
// Clearing write protect marks RAM disk enabled
c->status.writeProt = 0; // Patch to disable debugger and CD-ROM
// Patch debug RDPatch(c->dbgEN, &c->dbgDisByte, c->ramdisk, RDiskDBGDisPos, RDiskDBGDisByte);
RDPatchRAMDisk(!c->dbgEN, c->ramdisk, RDiskBuf, RDPatch(c->cdrEN, &c->cdrDisByte, c->ramdisk, RDiskCDRDisPos, RDiskCDRDisByte);
RDiskDBGDisPos, RDiskSize, &c->dbgDisByte);
// Patch CD
RDPatchRAMDisk(!c->cdrEN, c->ramdisk, RDiskBuf,
RDiskCDRDisPos, RDiskSize, &c->cdrDisByte);
}
// Unmount if not booting from ROM disk // Unmount if not booting from ROM disk
if (c->unmountEN) { c->status.diskInPlace = 0; } if (c->unmountEN) { c->status.diskInPlace = 0; }