mirror of
https://github.com/garrettsworkshop/MacIIROMDiskDriver.git
synced 2024-11-24 17:32:39 +00:00
...
This commit is contained in:
parent
dfd35cef2d
commit
e4b2775f11
Binary file not shown.
BIN
bin/rom8M.bin
BIN
bin/rom8M.bin
Binary file not shown.
46
rdisk.c
46
rdisk.c
@ -52,12 +52,30 @@ void C24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) {
|
|||||||
SwapMMUMode(&mode);
|
SwapMMUMode(&mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to 32-bit mode and patch
|
// Switch to 32-bit mode and get
|
||||||
#pragma parameter P24(__A2, __D3)
|
#pragma parameter G24(__A2)
|
||||||
void __attribute__ ((noinline)) P24(Ptr pos, char patch) {
|
char __attribute__ ((noinline)) G24(Ptr pos) {
|
||||||
signed char mode = true32b;
|
signed char mode = true32b;
|
||||||
SwapMMUMode(&mode);
|
SwapMMUMode(&mode);
|
||||||
*pos = patch; // Patch byte
|
return *pos; // Peek
|
||||||
|
SwapMMUMode(&mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch to 32-bit mode and get
|
||||||
|
#pragma parameter G24L(__A2)
|
||||||
|
long __attribute__ ((noinline)) G24L(long *pos) {
|
||||||
|
signed char mode = true32b;
|
||||||
|
SwapMMUMode(&mode);
|
||||||
|
return *pos; // Peek
|
||||||
|
SwapMMUMode(&mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch to 32-bit mode and set
|
||||||
|
#pragma parameter S24(__A2, __D3)
|
||||||
|
void __attribute__ ((noinline)) S24(Ptr pos, char patch) {
|
||||||
|
signed char mode = true32b;
|
||||||
|
SwapMMUMode(&mode);
|
||||||
|
*pos = patch; // Poke
|
||||||
SwapMMUMode(&mode);
|
SwapMMUMode(&mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +146,12 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
|||||||
// Decode settings
|
// Decode settings
|
||||||
RDDecodeSettings(&unmountEN, &mountEN, &ramEN, &dbgEN, &cdrEN);
|
RDDecodeSettings(&unmountEN, &mountEN, &ramEN, &dbgEN, &cdrEN);
|
||||||
// Set debug and CD-ROM disable stuff in storage struct
|
// Set debug and CD-ROM disable stuff in storage struct
|
||||||
c->dbgDisPos = dbgEN ? *((long*)0x40851D98) : -1;
|
peek24L((long*)0x40851D98, c->dbgDisPos);
|
||||||
c->cdrDisPos = cdrEN ? *((long*)0x40851D9C) : -1;
|
peek24L((long*)0x40851D9C, c->cdrDisPos);
|
||||||
c->dbgDisByte = *((char*)0x40851DA8);
|
peek24((char*)0x40851DA8, c->dbgDisByte);
|
||||||
c->cdrDisByte = *((char*)0x40851DA9);
|
peek24((char*)0x40851DA9, c->cdrDisByte);
|
||||||
|
if (dbgEN) { peek24(RDiskBuf + c->dbgDisPos, c->dbgDisByte); }
|
||||||
|
if (cdrEN) { peek24(RDiskBuf + c->cdrDisPos, c->cdrDisByte); }
|
||||||
|
|
||||||
// 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) {
|
||||||
@ -167,9 +187,9 @@ static void RDInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
|||||||
// Apply patches to RAM disk
|
// Apply patches to RAM disk
|
||||||
if (c->ramdisk) {
|
if (c->ramdisk) {
|
||||||
// Patch debugger enable byte
|
// Patch debugger enable byte
|
||||||
if (c->dbgDisPos >=0) { patch24(c->ramdisk + c->dbgDisPos, c->dbgDisByte); }
|
poke24(c->ramdisk + c->dbgDisPos, c->dbgDisByte);
|
||||||
// Patch CD-R enable byte
|
// Patch CD-R enable byte
|
||||||
if (c->cdrDisPos >=0) { patch24(c->ramdisk + c->dbgDisPos, c->dbgDisByte); }
|
poke24(c->ramdisk + c->cdrDisPos, c->cdrDisByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmount if not booting from ROM disk
|
// Unmount if not booting from ROM disk
|
||||||
@ -211,13 +231,11 @@ 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 &&
|
if (!c->ramdisk && c->dbgDisPos >= d->dCtlPosition &&
|
||||||
c->dbgDisPos >= d->dCtlPosition &&
|
|
||||||
c->dbgDisPos < d->dCtlPosition + p->ioReqCount) {
|
c->dbgDisPos < d->dCtlPosition + p->ioReqCount) {
|
||||||
p->ioBuffer[c->dbgDisPos - d->dCtlPosition] = c->dbgDisByte;
|
p->ioBuffer[c->dbgDisPos - d->dCtlPosition] = c->dbgDisByte;
|
||||||
}
|
}
|
||||||
if (c->dbgDisPos >= 0 &&
|
if (!c->ramdisk && c->cdrDisPos >= d->dCtlPosition &&
|
||||||
c->cdrDisPos >= d->dCtlPosition &&
|
|
||||||
c->cdrDisPos < d->dCtlPosition + p->ioReqCount) {
|
c->cdrDisPos < d->dCtlPosition + p->ioReqCount) {
|
||||||
p->ioBuffer[c->cdrDisPos - d->dCtlPosition] = c->cdrDisByte;
|
p->ioBuffer[c->cdrDisPos - d->dCtlPosition] = c->cdrDisByte;
|
||||||
}
|
}
|
||||||
|
10
rdisk.h
10
rdisk.h
@ -35,8 +35,14 @@ typedef struct RDiskStorage_s {
|
|||||||
typedef void (*RDiskCopy_t)(Ptr, Ptr, unsigned long);
|
typedef void (*RDiskCopy_t)(Ptr, Ptr, unsigned long);
|
||||||
#define copy24(s, d, b) { RDiskCopy_t f = C24; f(s, d, b); }
|
#define copy24(s, d, b) { RDiskCopy_t f = C24; f(s, d, b); }
|
||||||
|
|
||||||
typedef void (*RDiskPatch_t)(Ptr, char);
|
typedef char (*RDiskPeek_t)(Ptr);
|
||||||
#define patch24(a, d) { RDiskPatch_t f = P24; f(a, d); }
|
#define peek24(a, d) { RDiskPeek_t f = G24; d = f(a); }
|
||||||
|
|
||||||
|
typedef long (*RDiskPeekL_t)(long*);
|
||||||
|
#define peek24L(a, d) { RDiskPeekL_t f = G24L; d = f(a); }
|
||||||
|
|
||||||
|
typedef void (*RDiskPoke_t)(Ptr, char);
|
||||||
|
#define poke24(a, d) { RDiskPoke_t f = S24; f(a, d); }
|
||||||
|
|
||||||
#define PackBits_Repeat(count) (-1 * (count - 1))
|
#define PackBits_Repeat(count) (-1 * (count - 1))
|
||||||
#define PackBits_Literal(count) (count - 1)
|
#define PackBits_Literal(count) (count - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user