| 90 |
// Icon address (Mac address space, set by PatchROM()) |
// Icon address (Mac address space, set by PatchROM()) |
| 91 |
uint32 DiskIconAddr; |
uint32 DiskIconAddr; |
| 92 |
|
|
| 93 |
|
// Number of ticks between checks for disk insertion |
| 94 |
|
const int driver_delay = 120; |
| 95 |
|
|
| 96 |
|
// Flag: Control(accRun) has been called, interrupt routine is now active |
| 97 |
|
static bool acc_run_called = false; |
| 98 |
|
|
| 99 |
|
|
| 100 |
/* |
/* |
| 101 |
* Get pointer to drive info, NULL = invalid drive number |
* Get pointer to drive info, NULL = invalid drive number |
| 190 |
|
|
| 191 |
|
|
| 192 |
/* |
/* |
| 193 |
|
* Mount volumes for which the to_be_mounted flag is set |
| 194 |
|
* (called during interrupt time) |
| 195 |
|
*/ |
| 196 |
|
|
| 197 |
|
static void mount_mountable_volumes(void) |
| 198 |
|
{ |
| 199 |
|
DriveInfo *info = first_drive_info; |
| 200 |
|
while (info != NULL) { |
| 201 |
|
|
| 202 |
|
// Disk in drive? |
| 203 |
|
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
| 204 |
|
|
| 205 |
|
// No, check if disk was inserted |
| 206 |
|
if (SysIsDiskInserted(info->fh)) |
| 207 |
|
DiskMountVolume(info->fh); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
// Mount disk if flagged |
| 211 |
|
if (info->to_be_mounted) { |
| 212 |
|
D(bug(" mounting drive %d\n", info->num)); |
| 213 |
|
M68kRegisters r; |
| 214 |
|
r.d[0] = info->num; |
| 215 |
|
r.a[0] = 7; // diskEvent |
| 216 |
|
Execute68kTrap(0xa02f, &r); // PostEvent() |
| 217 |
|
info->to_be_mounted = false; |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
info = info->next; |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
|
| 225 |
|
/* |
| 226 |
* Driver Open() routine |
* Driver Open() routine |
| 227 |
*/ |
*/ |
| 228 |
|
|
| 232 |
|
|
| 233 |
// Set up DCE |
// Set up DCE |
| 234 |
WriteMacInt32(dce + dCtlPosition, 0); |
WriteMacInt32(dce + dCtlPosition, 0); |
| 235 |
|
acc_run_called = false; |
| 236 |
|
|
| 237 |
// Install drives |
// Install drives |
| 238 |
for (DriveInfo *info = first_drive_info; info; info = info->next) { |
for (DriveInfo *info = first_drive_info; info; info = info->next) { |
| 346 |
case 1: // KillIO |
case 1: // KillIO |
| 347 |
return noErr; |
return noErr; |
| 348 |
|
|
| 349 |
case 65: { // Periodic action ("insert" disks on startup and check for disk changes) |
case 65: { // Periodic action (accRun, "insert" disks on startup) |
| 350 |
DriveInfo *info = first_drive_info; |
mount_mountable_volumes(); |
| 351 |
while (info != NULL) { |
WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000); // Disable periodic action |
| 352 |
|
acc_run_called = true; |
|
// Disk in drive? |
|
|
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
|
|
|
|
|
// No, check if disk was inserted |
|
|
if (SysIsDiskInserted(info->fh)) |
|
|
DiskMountVolume(info->fh); |
|
|
} |
|
|
|
|
|
// Mount disk if flagged |
|
|
if (info->to_be_mounted) { |
|
|
D(bug(" mounting drive %d\n", info->num)); |
|
|
M68kRegisters r; |
|
|
r.d[0] = info->num; |
|
|
r.a[0] = 7; // diskEvent |
|
|
Execute68kTrap(0xa02f, &r); // PostEvent() |
|
|
info->to_be_mounted = false; |
|
|
} |
|
|
|
|
|
info = info->next; |
|
|
} |
|
| 353 |
return noErr; |
return noErr; |
| 354 |
} |
} |
| 355 |
} |
} |
| 492 |
return statusErr; |
return statusErr; |
| 493 |
} |
} |
| 494 |
} |
} |
| 495 |
|
|
| 496 |
|
|
| 497 |
|
/* |
| 498 |
|
* Driver interrupt routine - check for volumes to be mounted |
| 499 |
|
*/ |
| 500 |
|
|
| 501 |
|
void DiskInterrupt(void) |
| 502 |
|
{ |
| 503 |
|
static int tick_count = 0; |
| 504 |
|
if (!acc_run_called) |
| 505 |
|
return; |
| 506 |
|
|
| 507 |
|
tick_count++; |
| 508 |
|
if (tick_count > driver_delay) { |
| 509 |
|
tick_count = 0; |
| 510 |
|
mount_mountable_volumes(); |
| 511 |
|
} |
| 512 |
|
} |