--- BasiliskII/src/cdrom.cpp 2000/04/10 18:52:19 1.5 +++ BasiliskII/src/cdrom.cpp 2000/10/11 17:40:07 1.10 @@ -151,9 +151,6 @@ static DriveInfo *first_drive_info; // Icon address (Mac address space, set by PatchROM()) uint32 CDROMIconAddr; -// Number of ticks between checks for disk insertion -const int driver_delay = 120; - // Flag: Control(accRun) has been called, interrupt routine is now active static bool acc_run_called = false; @@ -188,19 +185,15 @@ static void find_hfs_partition(DriveInfo if (Sys_read(info->fh, map, i * 512, 512) != 512) break; - // Skip driver descriptor - uint16 sig = ntohs(((uint16 *)map)[0]); - if (sig == 'ER') - continue; - - // No partition map? Then look at next block - if (sig != 'PM') + // Not a partition map block? Then look at next block + uint16 sig = (map[0] << 8) | map[1]; + if (sig != 0x504d) continue; - // Partition map found, Apple HFS partition? + // Partition map block found, Apple HFS partition? if (strcmp((char *)(map + 48), "Apple_HFS") == 0) { info->start_byte = ntohl(((uint32 *)map)[2]) << 9; - D(bug(" HFS partition found at %ld, %ld blocks\n", info->start_byte, ntohl(((uint32 *)map)[3]))); + D(bug(" HFS partition found at %d, %d blocks\n", info->start_byte, ntohl(((uint32 *)map)[3]))); break; } } @@ -677,7 +670,7 @@ int16 CDROMControl(uint32 pb, uint32 dce return controlErr; case 103: { // AudioTrackSearch - D(bug(" AudioTrackSearch postype %d, pos %08lx, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); + D(bug(" AudioTrackSearch postype %d, pos %08x, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; @@ -874,38 +867,38 @@ int16 CDROMStatus(uint32 pb, uint32 dce) uint32 sel = ReadMacInt32(pb + csParam); D(bug(" driver gestalt %c%c%c%c\n", sel >> 24, sel >> 16, sel >> 8, sel)); switch (sel) { - case 'vers': // Version + case FOURCC('v','e','r','s'): // Version WriteMacInt32(pb + csParam + 4, 0x05208000); break; - case 'devt': // Device type - WriteMacInt32(pb + csParam + 4, 'cdrm'); + case FOURCC('d','e','v','t'): // Device type + WriteMacInt32(pb + csParam + 4, FOURCC('c','d','r','m')); break; - case 'intf': // Interface type - WriteMacInt32(pb + csParam + 4, 'basi'); + case FOURCC('i','n','t','f'): // Interface type + WriteMacInt32(pb + csParam + 4, EMULATOR_ID_4); break; - case 'sync': // Only synchronous operation? + case FOURCC('s','y','n','c'): // Only synchronous operation? WriteMacInt32(pb + csParam + 4, 0x01000000); break; - case 'boot': // Boot ID + case FOURCC('b','o','o','t'): // Boot ID if (info != NULL) WriteMacInt16(pb + csParam + 4, info->num); else WriteMacInt16(pb + csParam + 4, 0); WriteMacInt16(pb + csParam + 6, (uint16)CDROMRefNum); break; - case 'wide': // 64-bit access supported? + case FOURCC('w','i','d','e'): // 64-bit access supported? WriteMacInt16(pb + csParam + 4, 0); break; - case 'purg': // Purge flags + case FOURCC('p','u','r','g'): // Purge flags WriteMacInt32(pb + csParam + 4, 0); break; - case 'ejec': // Eject flags + case FOURCC('e','j','e','c'): // Eject flags WriteMacInt32(pb + csParam + 4, 0x00030003); // Don't eject on shutdown/restart break; - case 'flus': // Flush flags + case FOURCC('f','l','u','s'): // Flush flags WriteMacInt16(pb + csParam + 4, 0); break; - case 'vmop': // Virtual memory attributes + case FOURCC('v','m','o','p'): // Virtual memory attributes WriteMacInt32(pb + csParam + 4, 0); // Drive not available for VM break; default: @@ -924,6 +917,16 @@ int16 CDROMStatus(uint32 pb, uint32 dce) // Drive-specific codes switch (code) { + case 6: // Return format list + if (ReadMacInt16(pb + csParam) > 0) { + uint32 adr = ReadMacInt32(pb + csParam + 2); + WriteMacInt16(pb + csParam, 1); // 1 format + WriteMacInt32(adr, SysGetFileSize(info->fh) / 512); // Number of blocks + WriteMacInt32(adr + 4, 0); // heads/track/sectors + return noErr; + } else + return paramErr; + case 8: // DriveStatus Mac2Mac_memcpy(pb + csParam, info->status, 22); return noErr; @@ -964,18 +967,13 @@ int16 CDROMStatus(uint32 pb, uint32 dce) /* - * Driver interrupt routine - check for volumes to be mounted + * Driver interrupt routine (1Hz) - check for volumes to be mounted */ void CDROMInterrupt(void) { - static int tick_count = 0; if (!acc_run_called) return; - tick_count++; - if (tick_count > driver_delay) { - tick_count = 0; - mount_mountable_volumes(); - } + mount_mountable_volumes(); }