151 |
|
// Icon address (Mac address space, set by PatchROM()) |
152 |
|
uint32 CDROMIconAddr; |
153 |
|
|
154 |
+ |
// Number of ticks between checks for disk insertion |
155 |
+ |
const int driver_delay = 120; |
156 |
+ |
|
157 |
+ |
// Flag: Control(accRun) has been called, interrupt routine is now active |
158 |
+ |
static bool acc_run_called = false; |
159 |
+ |
|
160 |
|
|
161 |
|
/* |
162 |
|
* Get pointer to drive info, NULL = invalid drive number |
310 |
|
{ |
311 |
|
DriveInfo *info = first_drive_info, *next; |
312 |
|
while (info != NULL) { |
313 |
+ |
SysAllowRemoval(info->fh); |
314 |
|
Sys_close(info->fh); |
315 |
|
next = info->next; |
316 |
|
delete info; |
343 |
|
|
344 |
|
|
345 |
|
/* |
346 |
+ |
* Mount volumes for which the to_be_mounted flag is set |
347 |
+ |
* (called during interrupt time) |
348 |
+ |
*/ |
349 |
+ |
|
350 |
+ |
static void mount_mountable_volumes(void) |
351 |
+ |
{ |
352 |
+ |
DriveInfo *info = first_drive_info; |
353 |
+ |
while (info != NULL) { |
354 |
+ |
|
355 |
+ |
// Disk in drive? |
356 |
+ |
if (ReadMacInt8(info->status + dsDiskInPlace) == 0) { |
357 |
+ |
|
358 |
+ |
// No, check if disk was inserted |
359 |
+ |
if (SysIsDiskInserted(info->fh)) |
360 |
+ |
CDROMMountVolume(info->fh); |
361 |
+ |
} |
362 |
+ |
|
363 |
+ |
// Mount disk if flagged |
364 |
+ |
if (info->to_be_mounted) { |
365 |
+ |
D(bug(" mounting drive %d\n", info->num)); |
366 |
+ |
M68kRegisters r; |
367 |
+ |
r.d[0] = info->num; |
368 |
+ |
r.a[0] = 7; // diskEvent |
369 |
+ |
Execute68kTrap(0xa02f, &r); // PostEvent() |
370 |
+ |
info->to_be_mounted = false; |
371 |
+ |
} |
372 |
+ |
|
373 |
+ |
info = info->next; |
374 |
+ |
} |
375 |
+ |
} |
376 |
+ |
|
377 |
+ |
|
378 |
+ |
/* |
379 |
|
* Driver Open() routine |
380 |
|
*/ |
381 |
|
|
385 |
|
|
386 |
|
// Set up DCE |
387 |
|
WriteMacInt32(dce + dCtlPosition, 0); |
388 |
+ |
acc_run_called = false; |
389 |
|
|
390 |
|
// Install drives |
391 |
|
for (DriveInfo *info = first_drive_info; info; info = info->next) { |
497 |
|
case 1: // KillIO |
498 |
|
return noErr; |
499 |
|
|
500 |
< |
case 65: { // Periodic action ("insert" disks on startup and check for disk changes) |
501 |
< |
DriveInfo *info = first_drive_info; |
502 |
< |
while (info != NULL) { |
503 |
< |
|
463 |
< |
// Disk in drive? |
464 |
< |
if (ReadMacInt8(info->status + dsDiskInPlace) == 0) { |
465 |
< |
|
466 |
< |
// No, check if disk was inserted |
467 |
< |
if (SysIsDiskInserted(info->fh)) |
468 |
< |
CDROMMountVolume(info->fh); |
469 |
< |
} |
470 |
< |
|
471 |
< |
// Mount disk if flagged |
472 |
< |
if (info->to_be_mounted) { |
473 |
< |
D(bug(" mounting drive %d\n", info->num)); |
474 |
< |
M68kRegisters r; |
475 |
< |
r.d[0] = info->num; |
476 |
< |
r.a[0] = 7; // diskEvent |
477 |
< |
Execute68kTrap(0xa02f, &r); // PostEvent() |
478 |
< |
info->to_be_mounted = false; |
479 |
< |
} |
480 |
< |
|
481 |
< |
info = info->next; |
482 |
< |
} |
500 |
> |
case 65: { // Periodic action (accRun, "insert" disks on startup) |
501 |
> |
mount_mountable_volumes(); |
502 |
> |
WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000); // Disable periodic action |
503 |
> |
acc_run_called = true; |
504 |
|
return noErr; |
505 |
|
} |
506 |
|
|
960 |
|
return statusErr; |
961 |
|
} |
962 |
|
} |
963 |
+ |
|
964 |
+ |
|
965 |
+ |
/* |
966 |
+ |
* Driver interrupt routine - check for volumes to be mounted |
967 |
+ |
*/ |
968 |
+ |
|
969 |
+ |
void CDROMInterrupt(void) |
970 |
+ |
{ |
971 |
+ |
static int tick_count = 0; |
972 |
+ |
if (!acc_run_called) |
973 |
+ |
return; |
974 |
+ |
|
975 |
+ |
tick_count++; |
976 |
+ |
if (tick_count > driver_delay) { |
977 |
+ |
tick_count = 0; |
978 |
+ |
mount_mountable_volumes(); |
979 |
+ |
} |
980 |
+ |
} |