Better AudioPlay support and CDScan implemented

This commit is contained in:
Seth Polsley 2019-11-10 18:24:35 -06:00
parent 9a18393fc5
commit 447c7b365d
2 changed files with 32 additions and 21 deletions

View File

@ -659,11 +659,10 @@ bool CDPause_bincue(void *fh)
{
CueSheet *cs = (CueSheet *) fh;
if (cs && cs == player.cs) {
if (player.audiostatus == CDROM_AUDIO_PLAY) {
// doesn't matter if it was playing, just ensure it's now paused
player.audiostatus = CDROM_AUDIO_PAUSED;
return true;
}
}
return false;
}
@ -686,11 +685,9 @@ bool CDResume_bincue(void *fh)
{
CueSheet *cs = (CueSheet *) fh;
if (cs && cs == player.cs) {
// if (player.audiostatus == CDROM_AUDIO_PAUSED) {
// don't care if it was paused or not, just ensure it's playing after this call
// doesn't matter if it was paused, just ensure it now plays
player.audiostatus = CDROM_AUDIO_PLAY;
return true;
// }
}
return false;
}
@ -769,7 +766,22 @@ bool CDPlay_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f,
bool CDScan_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f, bool reverse) {
CueSheet *cs = (CueSheet *)fh;
if (cs && cs == player.cs) {
// stub
uint8 scanrate = 8; // 8x scan default but could use different value or make configurable
MSF msf;
msf.m = start_m; msf.s = start_s; msf.f = start_f;
int current_frame = MSFToFrames(msf);
if (reverse) {
msf.s -= scanrate;
int goto_frame = MSFToFrames(msf);
player.audioposition -= (current_frame - goto_frame) * player.cs->raw_sector_size;
}
else {
msf.s += scanrate;
int goto_frame = MSFToFrames(msf);
player.audioposition += (goto_frame - current_frame) * player.cs->raw_sector_size;
}
return true;
}
return false;

View File

@ -140,6 +140,7 @@ struct cdrom_drive_info {
uint8 toc[804]; // TOC of currently inserted disk
uint8 lead_out[3]; // MSF address of lead-out track
uint8 stop_at[3]; // MSF address of audio play stopping point
uint8 start_at[3]; // MSF address of position set by track search or audio play
uint8 play_mode; // Audio play mode
uint8 play_order; // Play mode order (normal, shuffle, program)
@ -785,14 +786,13 @@ int16 CDROMControl(uint32 pb, uint32 dce)
if (ReadMacInt8(info->status + dsDiskInPlace) == 0)
return offLinErr;
uint8 start_m, start_s, start_f;
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f))
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2]))
return paramErr;
info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f;
if (!SysCDPlay(info->fh, start_m, start_s, start_f, info->stop_at[0], info->stop_at[1], info->stop_at[2]))
if (!SysCDPlay(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], info->stop_at[0], info->stop_at[1], info->stop_at[2]))
return paramErr;
// if (ReadMacInt16(pb + csParam + 6) == 0) // Hold
// SysCDPause(info->fh);
if (ReadMacInt16(pb + csParam + 6) == 0) // Hold
SysCDPause(info->fh);
return noErr;
}
@ -808,13 +808,13 @@ int16 CDROMControl(uint32 pb, uint32 dce)
return paramErr;
} else {
// Given starting address
uint8 start_m, start_s, start_f;
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f))
return paramErr;
info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f;
if (!SysCDPlay(info->fh, start_m, start_s, start_f, info->stop_at[0], info->stop_at[1], info->stop_at[2]))
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2]))
return paramErr;
}
// Still need to process the AudioPlay command
info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f;
if (!SysCDPlay(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], info->stop_at[0], info->stop_at[1], info->stop_at[2]))
return paramErr;
return noErr;
case 105: // AudioPause
@ -890,11 +890,10 @@ int16 CDROMControl(uint32 pb, uint32 dce)
if (ReadMacInt8(info->status + dsDiskInPlace) == 0)
return offLinErr;
uint8 start_m, start_s, start_f;
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f))
if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2]))
return paramErr;
if (!SysCDScan(info->fh, start_m, start_s, start_f, ReadMacInt16(pb + csParam + 6) != 0)) {
if (!SysCDScan(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], ReadMacInt16(pb + csParam + 6) != 0)) {
return paramErr;
} else {
return noErr;