ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/cdrom.cpp
(Generate patch)

Comparing BasiliskII/src/cdrom.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.2 by cebix, 1999-10-12T20:00:42Z

# Line 151 | Line 151 | static DriveInfo *first_drive_info;
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
# Line 336 | Line 342 | bool CDROMMountVolume(void *fh)
342  
343  
344   /*
345 + *  Mount volumes for which the to_be_mounted flag is set
346 + *  (called during interrupt time)
347 + */
348 +
349 + static void mount_mountable_volumes(void)
350 + {
351 +        DriveInfo *info = first_drive_info;
352 +        while (info != NULL) {
353 +
354 +                // Disk in drive?
355 +                if (ReadMacInt8(info->status + dsDiskInPlace) == 0) {
356 +
357 +                        // No, check if disk was inserted
358 +                        if (SysIsDiskInserted(info->fh))
359 +                                CDROMMountVolume(info->fh);
360 +                }
361 +
362 +                // Mount disk if flagged
363 +                if (info->to_be_mounted) {
364 +                        D(bug(" mounting drive %d\n", info->num));
365 +                        M68kRegisters r;
366 +                        r.d[0] = info->num;
367 +                        r.a[0] = 7;     // diskEvent
368 +                        Execute68kTrap(0xa02f, &r);             // PostEvent()
369 +                        info->to_be_mounted = false;
370 +                }
371 +
372 +                info = info->next;
373 +        }
374 + }
375 +
376 +
377 + /*
378   *  Driver Open() routine
379   */
380  
# Line 345 | Line 384 | int16 CDROMOpen(uint32 pb, uint32 dce)
384  
385          // Set up DCE
386          WriteMacInt32(dce + dCtlPosition, 0);
387 +        acc_run_called = false;
388  
389          // Install drives
390          for (DriveInfo *info = first_drive_info; info; info = info->next) {
# Line 456 | Line 496 | int16 CDROMControl(uint32 pb, uint32 dce
496                  case 1:         // KillIO
497                          return noErr;
498  
499 <                case 65: {      // Periodic action ("insert" disks on startup and check for disk changes)
500 <                        DriveInfo *info = first_drive_info;
501 <                        while (info != NULL) {
502 <
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 <                        }
499 >                case 65: {      // Periodic action (accRun, "insert" disks on startup)
500 >                        mount_mountable_volumes();
501 >                        WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000);        // Disable periodic action
502 >                        acc_run_called = true;
503                          return noErr;
504                  }
505  
# Line 939 | Line 959 | int16 CDROMStatus(uint32 pb, uint32 dce)
959                          return statusErr;
960          }
961   }
962 +
963 +
964 + /*
965 + *  Driver interrupt routine - check for volumes to be mounted
966 + */
967 +
968 + void CDROMInterrupt(void)
969 + {
970 +        static int tick_count = 0;
971 +        if (!acc_run_called)
972 +                return;
973 +
974 +        tick_count++;
975 +        if (tick_count > driver_delay) {
976 +                tick_count = 0;
977 +                mount_mountable_volumes();
978 +        }
979 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines