Fixed some bugs regarding ramdisk mode

This commit is contained in:
Zane Kaminski 2020-06-26 05:21:49 -04:00
parent ccd35d1c68
commit a44f8668e9
4 changed files with 13 additions and 8 deletions

Binary file not shown.

Binary file not shown.

20
rdisk.c
View File

@ -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) {

View File

@ -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};