Add ROM disk disable

This commit is contained in:
Zane Kaminski 2021-04-02 03:51:40 -04:00
parent 809c78f9dc
commit dfd35cef2d
4 changed files with 27 additions and 19 deletions

Binary file not shown.

Binary file not shown.

36
rdisk.c
View File

@ -54,10 +54,10 @@ void C24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) {
// Switch to 32-bit mode and patch // Switch to 32-bit mode and patch
#pragma parameter P24(__A2, __D3) #pragma parameter P24(__A2, __D3)
void __attribute__ ((noinline)) P24(Ptr ptr, char patch) { void __attribute__ ((noinline)) P24(Ptr pos, char patch) {
signed char mode = true32b; signed char mode = true32b;
SwapMMUMode(&mode); SwapMMUMode(&mode);
*ptr = patch; // Patch byte *pos = patch; // Patch byte
SwapMMUMode(&mode); SwapMMUMode(&mode);
} }
@ -127,10 +127,12 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
c->initialized = 1; c->initialized = 1;
// Decode settings // Decode settings
RDDecodeSettings(&unmountEN, &mountEN, &ramEN, &dbgEN, &cdrEN); RDDecodeSettings(&unmountEN, &mountEN, &ramEN, &dbgEN, &cdrEN);
// Set debug and CD-ROM enable flags in storage struct // Set debug and CD-ROM disable stuff in storage struct
c->dbgEN = dbgEN; c->dbgDisPos = dbgEN ? *((long*)0x40851D98) : -1;
c->cdrEN = cdrEN; c->cdrDisPos = cdrEN ? *((long*)0x40851D9C) : -1;
c->dbgDisByte = *((char*)0x40851DA8);
c->cdrDisByte = *((char*)0x40851DA9);
// If RAM disk enabled, try to allocate RAM disk buffer if not already // If RAM disk enabled, try to allocate RAM disk buffer if not already
if (ramEN & !c->ramdisk) { if (ramEN & !c->ramdisk) {
if (*MMU32bit) { // 32-bit mode if (*MMU32bit) { // 32-bit mode
@ -162,14 +164,12 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
} }
} }
// Patch debug and CD-ROM enable bytes // Apply patches to RAM disk
if (c->ramdisk) { if (c->ramdisk) {
Ptr pos = c->ramdisk + *((long*)0x40851D98); // Patch debugger enable byte
char patch = *((char*)0x40851DA8); if (c->dbgDisPos >=0) { patch24(c->ramdisk + c->dbgDisPos, c->dbgDisByte); }
if (!dbgEN /*&& *RDiskDBGDisPos >= 0*/) { patch24(pos, patch); } // Patch CD-R enable byte
pos = c->ramdisk + *((long*)0x40851D9C); if (c->cdrDisPos >=0) { patch24(c->ramdisk + c->dbgDisPos, c->dbgDisByte); }
patch = *((char*)0x40851DA9);
if (!cdrEN /*&& *RDiskCDRDisPos >= 0*/) { patch24(pos, patch); }
} }
// Unmount if not booting from ROM disk // Unmount if not booting from ROM disk
@ -211,6 +211,16 @@ OSErr RDPrime(IOParamPtr p, DCtlPtr d) {
// Read from disk into buffer. // Read from disk into buffer.
if (*MMU32bit) { BlockMove(disk, p->ioBuffer, p->ioReqCount); } if (*MMU32bit) { BlockMove(disk, p->ioBuffer, p->ioReqCount); }
else { copy24(disk, StripAddress(p->ioBuffer), p->ioReqCount); } else { copy24(disk, StripAddress(p->ioBuffer), p->ioReqCount); }
if (c->dbgDisPos >= 0 &&
c->dbgDisPos >= d->dCtlPosition &&
c->dbgDisPos < d->dCtlPosition + p->ioReqCount) {
p->ioBuffer[c->dbgDisPos - d->dCtlPosition] = c->dbgDisByte;
}
if (c->dbgDisPos >= 0 &&
c->cdrDisPos >= d->dCtlPosition &&
c->cdrDisPos < d->dCtlPosition + p->ioReqCount) {
p->ioBuffer[c->cdrDisPos - d->dCtlPosition] = c->cdrDisByte;
}
} else if (cmd == aWrCmd) { // Write } else if (cmd == aWrCmd) { // Write
// Fail if write protected or RAM disk buffer not set up // Fail if write protected or RAM disk buffer not set up
if (c->status.writeProt || !c->ramdisk) { return wPrErr; } if (c->status.writeProt || !c->ramdisk) { return wPrErr; }

10
rdisk.h
View File

@ -2,10 +2,6 @@
#define RDISK_H #define RDISK_H
#define RDiskBuf ((char*)0x40880000) #define RDiskBuf ((char*)0x40880000)
extern uint32_t *RDiskDBGDisPos;
extern char *RDiskDBGDisByte;
extern uint32_t *RDiskCDRDisPos;
extern char *RDiskCDRDisByte;
#define BufPtr ((Ptr*)0x10C) #define BufPtr ((Ptr*)0x10C)
#define MemTop ((Ptr*)0x108) #define MemTop ((Ptr*)0x108)
#define MMU32bit ((char*)0xCB2) #define MMU32bit ((char*)0xCB2)
@ -27,8 +23,10 @@ typedef struct RDiskStorage_s {
DrvSts2 status; DrvSts2 status;
char initialized; char initialized;
Ptr ramdisk; Ptr ramdisk;
char dbgEN; long dbgDisPos;
char cdrEN; long cdrDisPos;
char dbgDisByte;
char cdrDisByte;
#ifdef RDISK_COMPRESS_ICON_ENABLE #ifdef RDISK_COMPRESS_ICON_ENABLE
char icon[RDISK_ICON_SIZE]; char icon[RDISK_ICON_SIZE];
#endif #endif