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

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

# Line 123 | Line 123 | static DriveInfo *first_drive_info;
123   uint32 SonyDiskIconAddr;
124   uint32 SonyDriveIconAddr;
125  
126 < // Flag: accRun called for the first time, run PatchAfterStartup()
127 < static bool periodic_first_time = false;
126 > // Number of ticks between checks for disk insertion
127 > const int driver_delay = 120;
128 >
129 > // Flag: Control(accRun) has been called, interrupt routine is now active
130 > static bool acc_run_called = false;
131  
132  
133   /*
# Line 216 | Line 219 | bool SonyMountVolume(void *fh)
219  
220  
221   /*
222 + *  Mount volumes for which the to_be_mounted flag is set
223 + *  (called during interrupt time)
224 + */
225 +
226 + static void mount_mountable_volumes(void)
227 + {
228 +        DriveInfo *info = first_drive_info;
229 +        while (info != NULL) {
230 +
231 + #if DISK_INSERT_CHECK
232 +                // Disk in drive?
233 +                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
234 +
235 +                        // No, check if disk was inserted
236 +                        if (SysIsDiskInserted(info->fh))
237 +                                SonyMountVolume(info->fh);
238 +                }
239 + #endif
240 +
241 +                // Mount disk if flagged
242 +                if (info->to_be_mounted) {
243 +                        D(bug(" mounting drive %d\n", info->num));
244 +                        M68kRegisters r;
245 +                        r.d[0] = info->num;
246 +                        r.a[0] = 7;     // diskEvent
247 +                        Execute68kTrap(0xa02f, &r);             // PostEvent()
248 +                        info->to_be_mounted = false;
249 +                }
250 +
251 +                info = info->next;
252 +        }
253 + }
254 +
255 +
256 + /*
257   *  Driver Open() routine
258   */
259  
# Line 226 | Line 264 | int16 SonyOpen(uint32 pb, uint32 dce)
264          // Set up DCE
265          WriteMacInt32(dce + dCtlPosition, 0);
266          WriteMacInt16(dce + dCtlQHdr + qFlags, ReadMacInt16(dce + dCtlQHdr + qFlags) & 0xff00 | 3);     // Version number, must be >=3 or System 8 will replace us
267 <        periodic_first_time = true;
267 >        acc_run_called = false;
268  
269          // Install driver again with refnum -2 (HD20)
270          uint32 utab = ReadMacInt32(0x11c);
# Line 354 | Line 392 | int16 SonyControl(uint32 pb, uint32 dce)
392                  case 9:         // Track cache
393                          return noErr;
394  
395 <                case 65: {      // Periodic action ("insert" disks on startup and check for disk changes)
396 <                        DriveInfo *info = first_drive_info;
397 <                        while (info != NULL) {
398 <
399 <                                // Disk in drive?
362 <                                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
363 <
364 < #if DISK_INSERT_CHECK
365 <                                        // No, check if disk was inserted
366 <                                        if (SysIsDiskInserted(info->fh))
367 <                                                SonyMountVolume(info->fh);
368 < #endif
369 <                                }
370 <
371 <                                // Mount disk if flagged
372 <                                if (info->to_be_mounted) {
373 <                                        D(bug(" mounting drive %d\n", info->num));
374 <                                        M68kRegisters r;
375 <                                        r.d[0] = info->num;
376 <                                        r.a[0] = 7;     // diskEvent
377 <                                        Execute68kTrap(0xa02f, &r);             // PostEvent()
378 <                                        info->to_be_mounted = false;
379 <                                }
380 <
381 <                                info = info->next;
382 <                        }
383 <                        if (periodic_first_time) {
384 <                                periodic_first_time = false;
385 <                                PatchAfterStartup();            // Install patches after system startup
386 <                        }
395 >                case 65:        // Periodic action (accRun, "insert" disks on startup)
396 >                        mount_mountable_volumes();
397 >                        PatchAfterStartup();            // Install patches after system startup
398 >                        WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000);        // Disable periodic action
399 >                        acc_run_called = true;
400                          return noErr;
388                }
401          }
402  
403          // Drive valid?
# Line 505 | Line 517 | int16 SonyStatus(uint32 pb, uint32 dce)
517                          return statusErr;
518          }
519   }
520 +
521 +
522 + /*
523 + *  Driver interrupt routine - check for volumes to be mounted
524 + */
525 +
526 + void SonyInterrupt(void)
527 + {
528 +        static int tick_count = 0;
529 +        if (!acc_run_called)
530 +                return;
531 +
532 +        tick_count++;
533 +        if (tick_count > driver_delay) {
534 +                tick_count = 0;
535 +                mount_mountable_volumes();
536 +        }
537 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines