mirror of
https://github.com/garrettsworkshop/MacIIROMDiskDriver.git
synced 2024-12-27 03:32:24 +00:00
Fixed some bugs regarding ramdisk mode
This commit is contained in:
parent
ccd35d1c68
commit
a44f8668e9
BIN
bin/driver.bin
BIN
bin/driver.bin
Binary file not shown.
BIN
bin/rom.bin
BIN
bin/rom.bin
Binary file not shown.
20
rdisk.c
20
rdisk.c
@ -107,16 +107,20 @@ OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
||||
// Set RAM disk buffer pointer. Defer copying until accRun
|
||||
// Don't set ramdisk_alloc because there is nothing to free.
|
||||
c->ramdisk = *BufPtr;
|
||||
// Copy ROM disk image to RAM disk
|
||||
BlockMove(RDiskBuf, c->ramdisk, RDiskSize);
|
||||
c->ramdisk_valid = 1;
|
||||
} else {
|
||||
// Enable accRun to allocate and copy later
|
||||
d->dCtlFlags |= dNeedTimeMask;
|
||||
d->dCtlDelay = 0x10;
|
||||
}
|
||||
// Enable accRun to allocate and copy later
|
||||
d->dCtlFlags |= dNeedTimeMask;
|
||||
d->dCtlDelay = 0x10;
|
||||
}
|
||||
return noErr;
|
||||
} else { // Otherwise if R not held down and ROM boot not set in PRAM,
|
||||
// Remove our driver from the drive queue
|
||||
DrvQElPtr dq;
|
||||
QHdrPtr QHead = (QHdrPtr)0x308;
|
||||
QHdrPtr QHead = DrvQHdr;
|
||||
|
||||
// Loop through entire drive queue, searching for our device or stopping at the end.
|
||||
dq = (DrvQElPtr)QHead->qHead;
|
||||
@ -157,7 +161,7 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
|
||||
}
|
||||
|
||||
// Get pointer to RAM or ROM disk buffer
|
||||
disk = RDiskBuf; // c->ramdisk && c->ramdisk_valid ? c->ramdisk : RDiskBuf;
|
||||
disk = c->ramdisk && c->ramdisk_valid ? c->ramdisk : RDiskBuf;
|
||||
// Add offset to buffer pointer according to positioning mode
|
||||
switch (p->ioPosMode & 0x000F) {
|
||||
case fsAtMark: offset = d->dCtlPosition; break;
|
||||
@ -167,9 +171,9 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
|
||||
}
|
||||
disk += offset;
|
||||
// Bounds checking
|
||||
if (offset >= RDiskSize || p->ioReqCount >= RDiskSize ||
|
||||
/*if (offset >= RDiskSize || p->ioReqCount >= RDiskSize ||
|
||||
offset + p->ioReqCount >= RDiskSize ||
|
||||
disk + offset < disk) { return posErr; }
|
||||
disk + offset < disk) { return posErr; }*/
|
||||
|
||||
// Service read or write request
|
||||
cmd = p->ioTrap & 0x00FF;
|
||||
@ -191,7 +195,6 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
|
||||
p->ioPosOffset = d->dCtlPosition;
|
||||
return noErr;
|
||||
} else if (cmd == aWrCmd) { // Write
|
||||
return wPrErr;
|
||||
// Fail if write protected or RAM disk buffer not set up
|
||||
if (c->drvsts.writeProt || !c->ramdisk || !c->ramdisk_valid) { return wPrErr; }
|
||||
// Write from buffer into disk.
|
||||
@ -213,6 +216,7 @@ OSErr RDiskAccRun(CntrlParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
||||
// Disable accRun
|
||||
d->dCtlDelay = 0;
|
||||
d->dCtlFlags &= ~dNeedTimeMask;
|
||||
RDiskBreak();
|
||||
|
||||
// Set RAM disk buffer if our disk is writable and no RAM buffer set
|
||||
if (!c->drvsts.writeProt && !c->ramdisk) {
|
||||
|
1
rdisk.h
1
rdisk.h
@ -7,6 +7,7 @@
|
||||
#define MemTop ((Ptr*)0x108)
|
||||
#define MMU32bit ((char*)0xCB2)
|
||||
#define JIODone ((char*)0x8FC)
|
||||
#define DrvQHdr ((QHdrPtr)0x308)
|
||||
|
||||
#pragma parameter __D0 RDReadXPRAM(__D0, __D1, __A0)
|
||||
OSErr RDiskReadXPRAM(short numBytes, short whichByte, void *dest) = {0x4840, 0x3001, 0xA051};
|
||||
|
Loading…
Reference in New Issue
Block a user