Best guess audio CD from data calls to allow multiple discs and testing different interface identifiers

This commit is contained in:
Seth Polsley 2020-01-08 03:02:08 -06:00
parent 281a8a9f68
commit 35439819d3
2 changed files with 28 additions and 14 deletions

View File

@ -153,6 +153,8 @@ struct cdrom_drive_info {
typedef vector<cdrom_drive_info> drive_vec;
static drive_vec drives;
int last_drive_num; // track last drive called to support multiple audio CDs
// Icon address (Mac address space, set by PatchROM())
uint32 CDROMIconAddr;
@ -168,8 +170,10 @@ static drive_vec::iterator get_drive_info(int num)
{
drive_vec::iterator info, end = drives.end();
for (info = drives.begin(); info != end; ++info) {
if (info->num == num)
if (info->num == num) {
last_drive_num = num;
return info;
}
}
return info;
}
@ -302,6 +306,13 @@ void CDROMInit(void)
if (fh)
drives.push_back(cdrom_drive_info(fh));
}
if (!drives.empty()) { // set to first drive by default
last_drive_num = drives.begin()->num;
}
else {
last_drive_num = 0;
}
}
@ -516,7 +527,9 @@ int16 CDROMControl(uint32 pb, uint32 dce)
if (drives.empty()) {
return nsDrvErr;
} else {
info = drives.begin(); // This is needed for Apple's Audio CD program
// Audio calls tend to end up without correct reference
// Real mac would just play first disc, but we can guess correct one from last data call
info = get_drive_info(last_drive_num);
}
}
@ -563,7 +576,7 @@ int16 CDROMControl(uint32 pb, uint32 dce)
break;
case FOURCC('i','n','t','f'):
case FOURCC('d','A','P','I'):
WriteMacInt32(pb + csParam + 4, FOURCC('s','c','s','i'));
WriteMacInt32(pb + csParam + 4, FOURCC('a','t','p','i'));
break;
case FOURCC('s','y','n','c'):
WriteMacInt32(pb + csParam + 4, 1); // true/false = sync/async
@ -994,7 +1007,7 @@ int16 CDROMStatus(uint32 pb, uint32 dce)
break;
case FOURCC('i','n','t','f'): // Interface type
// WriteMacInt32(pb + csParam + 4, EMULATOR_ID_4);
WriteMacInt32(pb + csParam + 4, FOURCC('s','c','s','i'));
WriteMacInt32(pb + csParam + 4, FOURCC('a','t','p','i'));
break;
case FOURCC('s','y','n','c'): // Only synchronous operation?
WriteMacInt32(pb + csParam + 4, 0x01000000);
@ -1045,10 +1058,11 @@ int16 CDROMStatus(uint32 pb, uint32 dce)
// Drive valid?
if (info == drives.end()) {
if (drives.empty())
if (drives.empty()) {
return nsDrvErr;
else
info = drives.begin(); // This is needed for Apple's Audio CD program
} else {
info = get_drive_info(last_drive_num);
}
}
// Drive-specific codes

View File

@ -411,12 +411,12 @@ static const uint8 sony_driver[] = { // Replacement for .Sony driver
static const uint8 disk_driver[] = { // Generic disk driver
// Driver header
DiskDriverFlags >> 8, DiskDriverFlags & 0xff, 0, 0, 0, 0, 0, 0,
0x00, 0x18, // Open() offset
0x00, 0x1c, // Prime() offset
0x00, 0x20, // Control() offset
0x00, 0x2c, // Status() offset
0x00, 0x52, // Close() offset
0x05, 0x2e, 0x44, 0x69, 0x73, 0x6b, // ".Disk"
0x00, 0x1c, // Open() offset
0x00, 0x20, // Prime() offset
0x00, 0x24, // Control() offset
0x00, 0x30, // Status() offset
0x00, 0x56, // Close() offset
0x08, 0x2e, 0x41, 0x54, 0x41, 0x44, 0x69, 0x73, 0x6b, 0x00, // ".ATADisk"
// Open()
M68K_EMUL_OP_DISK_OPEN >> 8, M68K_EMUL_OP_DISK_OPEN & 0xff,
@ -2419,7 +2419,7 @@ void InstallDrivers(void)
WriteMacInt16(dce + dCtlFlags, DiskDriverFlags);
// Open disk driver
SheepString disk_str("\005.Disk");
SheepString disk_str("\010.ATADisk");
WriteMacInt32(pb + ioNamePtr, disk_str.addr());
r.a[0] = pb;
Execute68kTrap(0xa000, &r); // Open()