Add format capability

This commit is contained in:
Zane Kaminski 2020-07-02 03:58:25 -04:00
parent 2457313b5a
commit dd24df4f34
3 changed files with 27 additions and 10 deletions

Binary file not shown.

Binary file not shown.

37
rdisk.c
View File

@ -149,10 +149,10 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
c = *(RDiskStorage_t**)d->dCtlStorage; c = *(RDiskStorage_t**)d->dCtlStorage;
// Initialize storage struct fields // Initialize storage struct fields
c->initialized = 0; //c->initialized = 0;
c->removed = 0; //c->removed = 0;
c->postBoot = 0; //c->postBoot = 0;
c->ramdisk = NULL; //c->ramdisk = NULL;
c->copy24 = (RDiskCopy_t)copy24; c->copy24 = (RDiskCopy_t)copy24;
// Set drive status // Set drive status
@ -164,9 +164,9 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
c->status.driveS1 = (RDiskSize / 512) >> 16; c->status.driveS1 = (RDiskSize / 512) >> 16;
// Set driver flags // Set driver flags
d->dCtlFlags |= dReadEnableMask | dWritEnableMask | /*d->dCtlFlags |= dReadEnableMask | dWritEnableMask |
dCtlEnableMask | dStatEnableMask | dCtlEnableMask | dStatEnableMask |
dNeedLockMask; // 0x4F dNeedLockMask;*/ // 0x4F
// Add drive to drive queue and return // Add drive to drive queue and return
RDiskAddDrive(c->status.dQRefNum, drvNum, (DrvQElPtr)&c->status.qLink); RDiskAddDrive(c->status.dQRefNum, drvNum, (DrvQElPtr)&c->status.qLink);
@ -218,7 +218,7 @@ static OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
BlockMove(RDiskBuf, c->ramdisk, RDiskSize); BlockMove(RDiskBuf, c->ramdisk, RDiskSize);
// Clearing write protect marks RAM disk enabled // Clearing write protect marks RAM disk enabled
c->status.writeProt = 0; c->status.writeProt = 0;
} else { c->status.writeProt = -1; } // Not enough RAM. Stay write-only }
} else { // 24-bit mode } else { // 24-bit mode
// Put RAM disk just past 8MB // Put RAM disk just past 8MB
c->ramdisk = (char*)(8 * 1024 * 1024); c->ramdisk = (char*)(8 * 1024 * 1024);
@ -232,7 +232,7 @@ static OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
// That's not the worst, since the system would just crash, // That's not the worst, since the system would just crash,
// but it would be better to switch to read-only status // but it would be better to switch to read-only status
} }
} else { c->status.writeProt = -1; } // Otherwise write-only }
// If boot disabled... // If boot disabled...
if (!bootEN) { if (!bootEN) {
@ -329,8 +329,25 @@ OSErr RDiskControl(CntrlParamPtr p, DCtlPtr d) {
c = *(RDiskStorage_t**)d->dCtlStorage; c = *(RDiskStorage_t**)d->dCtlStorage;
// Handle control request based on csCode // Handle control request based on csCode
switch (p->csCode) { switch (p->csCode) {
case 6: // Format not implemented case 6: // Format
case 5: return controlErr; // Verify (after format) not implemented if (!c->status.diskInPlace || c->status.writeProt || !c->ramdisk) {
return controlErr;
} else {
char zero[64];
for (int i = 0; i < sizeof(zero); i++) { zero[i] = 0; }
for (int i = 0; i < RDiskSize / 64; i++) {
if (*MMU32bit) { BlockMove(zero, c->ramdisk, sizeof(zero)); }
else {
((RDiskCopy_t)StripAddress(c->copy24))(
StripAddress(zero), c->ramdisk, sizeof(zero));
}
}
}
return noErr;
case 5: // Verify (after format)
if (!c->status.diskInPlace || c->status.writeProt || !c->ramdisk) {
return controlErr;
} else { return noErr; }
case accRun: case accRun:
// Disable accRun // Disable accRun
d->dCtlFlags &= ~dNeedTimeMask; d->dCtlFlags &= ~dNeedTimeMask;