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 |
|
|
599 |
|
break; |
600 |
|
|
601 |
|
case 3: { // Get track starting address |
602 |
< |
uint8 *buf = Mac2HostAddr(ReadMacInt32(pb + csParam + 2)); |
602 |
> |
uint32 buf = ReadMacInt32(pb + csParam + 2); |
603 |
|
uint16 buf_size = ReadMacInt16(pb + csParam + 6); |
604 |
|
int track = bcd2bin[ReadMacInt8(pb + csParam + 8)]; |
605 |
|
|
613 |
|
// Fill buffer |
614 |
|
if (i != 804) |
615 |
|
while (buf_size > 0) { |
616 |
< |
*buf++ = info->toc[i+1] & 0x0f; // Control |
617 |
< |
*buf++ = bin2bcd[info->toc[i+5]]; // M |
618 |
< |
*buf++ = bin2bcd[info->toc[i+6]]; // S |
619 |
< |
*buf++ = bin2bcd[info->toc[i+7]]; // F |
616 |
> |
WriteMacInt8(buf, info->toc[i+1] & 0x0f); buf++; // Control |
617 |
> |
WriteMacInt8(buf, bin2bcd[info->toc[i+5]]); buf++; // M |
618 |
> |
WriteMacInt8(buf, bin2bcd[info->toc[i+6]]); buf++; // S |
619 |
> |
WriteMacInt8(buf, bin2bcd[info->toc[i+7]]); buf++; // F |
620 |
|
|
621 |
|
// Lead-Out? Then stop |
622 |
|
if (info->toc[i+2] == 0xaa) |
647 |
|
|
648 |
|
case 101: { // ReadTheQSubcode |
649 |
|
if (ReadMacInt8(info->status + dsDiskInPlace) == 0) { |
650 |
< |
memset(Mac2HostAddr(pb + csParam), 0, 10); |
650 |
> |
Mac_memset(pb + csParam, 0, 10); |
651 |
|
return offLinErr; |
652 |
|
} |
653 |
|
|
654 |
|
uint8 pos[16]; |
655 |
|
if (SysCDGetPosition(info->fh, pos)) { |
656 |
< |
uint8 *p = Mac2HostAddr(pb + csParam); |
657 |
< |
*p++ = pos[5] & 0x0f; // Control |
658 |
< |
*p++ = bin2bcd[pos[6]]; // Track number |
659 |
< |
*p++ = bin2bcd[pos[7]]; // Index number |
660 |
< |
*p++ = bin2bcd[pos[13]]; // M (rel) |
661 |
< |
*p++ = bin2bcd[pos[14]]; // S (rel) |
662 |
< |
*p++ = bin2bcd[pos[15]]; // F (rel) |
663 |
< |
*p++ = bin2bcd[pos[9]]; // M (abs) |
664 |
< |
*p++ = bin2bcd[pos[10]]; // S (abs) |
665 |
< |
*p++ = bin2bcd[pos[11]]; // F (abs) |
666 |
< |
*p++ = 0; |
656 |
> |
uint32 p = pb + csParam; |
657 |
> |
WriteMacInt8(p, pos[5] & 0x0f); p++; // Control |
658 |
> |
WriteMacInt8(p, bin2bcd[pos[6]]); p++; // Track number |
659 |
> |
WriteMacInt8(p, bin2bcd[pos[7]]); p++; // Index number |
660 |
> |
WriteMacInt8(p, bin2bcd[pos[13]]); p++; // M (rel) |
661 |
> |
WriteMacInt8(p, bin2bcd[pos[14]]); p++; // S (rel) |
662 |
> |
WriteMacInt8(p, bin2bcd[pos[15]]); p++; // F (rel) |
663 |
> |
WriteMacInt8(p, bin2bcd[pos[9]]); p++; // M (abs) |
664 |
> |
WriteMacInt8(p, bin2bcd[pos[10]]); p++; // S (abs) |
665 |
> |
WriteMacInt8(p, bin2bcd[pos[11]]); p++; // F (abs) |
666 |
> |
WriteMacInt8(p, 0); |
667 |
|
return noErr; |
668 |
|
} else |
669 |
|
return ioErr; |
751 |
|
if (!SysCDGetPosition(info->fh, pos)) |
752 |
|
return paramErr; |
753 |
|
|
754 |
< |
uint8 *p = Mac2HostAddr(pb + csParam); |
754 |
> |
uint32 p = pb + csParam; |
755 |
|
switch (pos[1]) { |
756 |
|
case 0x11: |
757 |
< |
*p++ = 0; // Audio play in progress |
757 |
> |
WriteMacInt8(p, 0); // Audio play in progress |
758 |
|
break; |
759 |
|
case 0x12: |
760 |
< |
*p++ = 1; // Audio play paused |
760 |
> |
WriteMacInt8(p, 1); // Audio play paused |
761 |
|
break; |
762 |
|
case 0x13: |
763 |
< |
*p++ = 3; // Audio play completed |
763 |
> |
WriteMacInt8(p, 3); // Audio play completed |
764 |
|
break; |
765 |
|
case 0x14: |
766 |
< |
*p++ = 4; // Error occurred |
766 |
> |
WriteMacInt8(p, 4); // Error occurred |
767 |
|
break; |
768 |
|
default: |
769 |
< |
*p++ = 5; // No audio play operation requested |
769 |
> |
WriteMacInt8(p, 5); // No audio play operation requested |
770 |
|
break; |
771 |
|
} |
772 |
< |
*p++ = info->play_mode; |
773 |
< |
*p++ = pos[5] & 0x0f; // Control |
774 |
< |
*p++ = bin2bcd[pos[9]]; // M (abs) |
775 |
< |
*p++ = bin2bcd[pos[10]]; // S (abs) |
776 |
< |
*p++ = bin2bcd[pos[11]]; // F (abs) |
772 |
> |
p++; |
773 |
> |
WriteMacInt8(p, info->play_mode); p++; |
774 |
> |
WriteMacInt8(p, pos[5] & 0x0f); p++; // Control |
775 |
> |
WriteMacInt8(p, bin2bcd[pos[9]]); p++; // M (abs) |
776 |
> |
WriteMacInt8(p, bin2bcd[pos[10]]); p++; // S (abs) |
777 |
> |
WriteMacInt8(p, bin2bcd[pos[11]]); p++; // F (abs) |
778 |
|
return noErr; |
779 |
|
} |
780 |
|
|
922 |
|
// Drive-specific codes |
923 |
|
switch (code) { |
924 |
|
case 8: // DriveStatus |
925 |
< |
memcpy(Mac2HostAddr(pb + csParam), Mac2HostAddr(info->status), 22); |
925 |
> |
Mac2Mac_memcpy(pb + csParam, info->status, 22); |
926 |
|
return noErr; |
927 |
|
|
928 |
|
case 70: // GetPowerMode |
961 |
|
|
962 |
|
|
963 |
|
/* |
964 |
< |
* Driver interrupt routine - check for volumes to be mounted |
964 |
> |
* Driver interrupt routine (1Hz) - check for volumes to be mounted |
965 |
|
*/ |
966 |
|
|
967 |
|
void CDROMInterrupt(void) |
968 |
|
{ |
971 |
– |
static int tick_count = 0; |
969 |
|
if (!acc_run_called) |
970 |
|
return; |
971 |
|
|
972 |
< |
tick_count++; |
976 |
< |
if (tick_count > driver_delay) { |
977 |
< |
tick_count = 0; |
978 |
< |
mount_mountable_volumes(); |
979 |
< |
} |
972 |
> |
mount_mountable_volumes(); |
973 |
|
} |