1 |
|
/* |
2 |
|
* cdrom.cpp - CD-ROM driver |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
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 |
– |
|
154 |
|
// Flag: Control(accRun) has been called, interrupt routine is now active |
155 |
|
static bool acc_run_called = false; |
156 |
|
|
185 |
|
if (Sys_read(info->fh, map, i * 512, 512) != 512) |
186 |
|
break; |
187 |
|
|
188 |
< |
// Skip driver descriptor |
189 |
< |
uint16 sig = ntohs(((uint16 *)map)[0]); |
190 |
< |
if (sig == 'ER') |
194 |
< |
continue; |
195 |
< |
|
196 |
< |
// No partition map? Then look at next block |
197 |
< |
if (sig != 'PM') |
188 |
> |
// Not a partition map block? Then look at next block |
189 |
> |
uint16 sig = (map[0] << 8) | map[1]; |
190 |
> |
if (sig != 0x504d) |
191 |
|
continue; |
192 |
|
|
193 |
< |
// Partition map found, Apple HFS partition? |
193 |
> |
// Partition map block found, Apple HFS partition? |
194 |
|
if (strcmp((char *)(map + 48), "Apple_HFS") == 0) { |
195 |
|
info->start_byte = ntohl(((uint32 *)map)[2]) << 9; |
196 |
< |
D(bug(" HFS partition found at %ld, %ld blocks\n", info->start_byte, ntohl(((uint32 *)map)[3]))); |
196 |
> |
D(bug(" HFS partition found at %d, %d blocks\n", info->start_byte, ntohl(((uint32 *)map)[3]))); |
197 |
|
break; |
198 |
|
} |
199 |
|
} |
670 |
|
return controlErr; |
671 |
|
|
672 |
|
case 103: { // AudioTrackSearch |
673 |
< |
D(bug(" AudioTrackSearch postype %d, pos %08lx, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); |
673 |
> |
D(bug(" AudioTrackSearch postype %d, pos %08x, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); |
674 |
|
if (ReadMacInt8(info->status + dsDiskInPlace) == 0) |
675 |
|
return offLinErr; |
676 |
|
|
867 |
|
uint32 sel = ReadMacInt32(pb + csParam); |
868 |
|
D(bug(" driver gestalt %c%c%c%c\n", sel >> 24, sel >> 16, sel >> 8, sel)); |
869 |
|
switch (sel) { |
870 |
< |
case 'vers': // Version |
870 |
> |
case FOURCC('v','e','r','s'): // Version |
871 |
|
WriteMacInt32(pb + csParam + 4, 0x05208000); |
872 |
|
break; |
873 |
< |
case 'devt': // Device type |
874 |
< |
WriteMacInt32(pb + csParam + 4, 'cdrm'); |
873 |
> |
case FOURCC('d','e','v','t'): // Device type |
874 |
> |
WriteMacInt32(pb + csParam + 4, FOURCC('c','d','r','m')); |
875 |
|
break; |
876 |
< |
case 'intf': // Interface type |
877 |
< |
WriteMacInt32(pb + csParam + 4, 'basi'); |
876 |
> |
case FOURCC('i','n','t','f'): // Interface type |
877 |
> |
WriteMacInt32(pb + csParam + 4, EMULATOR_ID_4); |
878 |
|
break; |
879 |
< |
case 'sync': // Only synchronous operation? |
879 |
> |
case FOURCC('s','y','n','c'): // Only synchronous operation? |
880 |
|
WriteMacInt32(pb + csParam + 4, 0x01000000); |
881 |
|
break; |
882 |
< |
case 'boot': // Boot ID |
882 |
> |
case FOURCC('b','o','o','t'): // Boot ID |
883 |
|
if (info != NULL) |
884 |
|
WriteMacInt16(pb + csParam + 4, info->num); |
885 |
|
else |
886 |
|
WriteMacInt16(pb + csParam + 4, 0); |
887 |
|
WriteMacInt16(pb + csParam + 6, (uint16)CDROMRefNum); |
888 |
|
break; |
889 |
< |
case 'wide': // 64-bit access supported? |
889 |
> |
case FOURCC('w','i','d','e'): // 64-bit access supported? |
890 |
|
WriteMacInt16(pb + csParam + 4, 0); |
891 |
|
break; |
892 |
< |
case 'purg': // Purge flags |
892 |
> |
case FOURCC('p','u','r','g'): // Purge flags |
893 |
|
WriteMacInt32(pb + csParam + 4, 0); |
894 |
|
break; |
895 |
< |
case 'ejec': // Eject flags |
895 |
> |
case FOURCC('e','j','e','c'): // Eject flags |
896 |
|
WriteMacInt32(pb + csParam + 4, 0x00030003); // Don't eject on shutdown/restart |
897 |
|
break; |
898 |
< |
case 'flus': // Flush flags |
898 |
> |
case FOURCC('f','l','u','s'): // Flush flags |
899 |
|
WriteMacInt16(pb + csParam + 4, 0); |
900 |
|
break; |
901 |
< |
case 'vmop': // Virtual memory attributes |
901 |
> |
case FOURCC('v','m','o','p'): // Virtual memory attributes |
902 |
|
WriteMacInt32(pb + csParam + 4, 0); // Drive not available for VM |
903 |
|
break; |
904 |
|
default: |
957 |
|
|
958 |
|
|
959 |
|
/* |
960 |
< |
* Driver interrupt routine - check for volumes to be mounted |
960 |
> |
* Driver interrupt routine (1Hz) - check for volumes to be mounted |
961 |
|
*/ |
962 |
|
|
963 |
|
void CDROMInterrupt(void) |
964 |
|
{ |
972 |
– |
static int tick_count = 0; |
965 |
|
if (!acc_run_called) |
966 |
|
return; |
967 |
|
|
968 |
< |
tick_count++; |
977 |
< |
if (tick_count > driver_delay) { |
978 |
< |
tick_count = 0; |
979 |
< |
mount_mountable_volumes(); |
980 |
< |
} |
968 |
> |
mount_mountable_volumes(); |
969 |
|
} |