Better copy24

This commit is contained in:
Zane Kaminski 2020-07-15 02:24:27 -04:00
parent 83af6e36f8
commit 27f3f5c947
2 changed files with 5 additions and 17 deletions

20
rdisk.c
View File

@ -290,8 +290,6 @@ static void RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
c->status.writeProt = 0;
}
} else { // 24-bit mode
// Get address of copy24 routine
RDiskCopy_t copy24 = (RDiskCopy_t)RDiskCopy24;
// Put RAM disk just past 8MB
c->ramdisk = (Ptr)(8 * 1024 * 1024);
// Copy ROM disk image to RAM disk
@ -345,21 +343,13 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
if (cmd == aRdCmd) { // Read
// Read from disk into buffer.
if (*MMU32bit) { BlockMove(disk, p->ioBuffer, p->ioReqCount); }
else {
// Get address of copy24 routine and then copy
RDiskCopy_t copy24 = (RDiskCopy_t)RDiskCopy24;
copy24(disk, StripAddress(p->ioBuffer), p->ioReqCount);
}
else { copy24(disk, StripAddress(p->ioBuffer), p->ioReqCount); }
} else if (cmd == aWrCmd) { // Write
// Fail if write protected or RAM disk buffer not set up
if (c->status.writeProt || !c->ramdisk) { return wPrErr; }
// Write from buffer into disk.
if (*MMU32bit) { BlockMove(p->ioBuffer, disk, p->ioReqCount); }
else {
// Get address of copy24 routine and then copy
RDiskCopy_t copy24 = (RDiskCopy_t)RDiskCopy24;
copy24(StripAddress(p->ioBuffer), disk, p->ioReqCount);
}
else { copy24(StripAddress(p->ioBuffer), disk, p->ioReqCount); }
} else { return noErr; } //FIXME: Fail if cmd isn't read or write?
// Update count and position/offset, then return
@ -385,11 +375,7 @@ OSErr RDiskControl(CntrlParamPtr p, DCtlPtr d) {
zero[0] = 0;
for (int i = 0; i < 256; i++) {
if (*MMU32bit) { BlockMove(zero, c->ramdisk, sizeof(zero)); }
else {
// Get address of copy24 routine and then copy
RDiskCopy_t copy24 = (RDiskCopy_t)RDiskCopy24;
copy24((Ptr)zero, c->ramdisk, sizeof(zero));
}
else { copy24((Ptr)zero, c->ramdisk, sizeof(zero)); }
}
return noErr;
case kVerify:

View File

@ -47,6 +47,8 @@ typedef struct RDiskStorage_s {
#endif
} RDiskStorage_t;
#define copy24(s, d, b) { RDiskCopy_t copy24 = (RDiskCopy_t)RDiskCopy24; copy24(s, d, b); }
#define PackBits_Repeat(count) ((-1) * (count - 1))
#define PackBits_Literal(count) (count - 1)