void CommandAudioStartPos() { switch (CommandBuffer[9] & 0xC0) { case 0x00: // Set start offset in LBA units audioStartLBA = (CommandBuffer[3] << 16) | (CommandBuffer[4] << 8) | CommandBuffer[5]; break; case 0x40: // Set start offset in absolute MSF units byte m = CommandBuffer[2].BCDtoBin(); byte s = CommandBuffer[3].BCDtoBin(); byte f = CommandBuffer[4].BCDtoBin(); audioStartLBA = DiscUtils.Convert_AMSF_To_LBA(m, s, f); break; case 0x80: // Set start offset in track units byte trackNo = CommandBuffer[2].BCDtoBin(); audioStartLBA = disc.Session1.Tracks[trackNo].LBA; break; } if (CommandBuffer[1] == 0) { pce.CDAudio.PlayStartingAtLba(audioStartLBA); pce.CDAudio.Pause(); } else { pce.CDAudio.PlayStartingAtLba(audioStartLBA); } SetStatusMessage(STATUS_GOOD, 0); pce.IntDataTransferComplete = true; }
void CommandAudioEndPos() { switch (CommandBuffer[9] & 0xC0) { case 0x00: // Set end offset in LBA units audioEndLBA = (CommandBuffer[3] << 16) | (CommandBuffer[4] << 8) | CommandBuffer[5]; break; case 0x40: // Set end offset in absolute MSF units byte m = CommandBuffer[2].BCDtoBin(); byte s = CommandBuffer[3].BCDtoBin(); byte f = CommandBuffer[4].BCDtoBin(); audioEndLBA = DiscUtils.Convert_AMSF_To_LBA(m, s, f); break; case 0x80: // Set end offset in track units byte trackNo = CommandBuffer[2].BCDtoBin(); if (trackNo - 1 >= disc.Session1.Tracks.Count) { audioEndLBA = disc.Session1.LeadoutLBA; } else { audioEndLBA = disc.Session1.Tracks[trackNo].LBA; } break; } switch (CommandBuffer[1]) { case 0: // end immediately pce.CDAudio.Stop(); break; case 1: // play in loop mode. I guess this constitues A-B looping pce.CDAudio.PlayStartingAtLba(audioStartLBA); pce.CDAudio.EndLBA = audioEndLBA; pce.CDAudio.PlayMode = CDAudio.PlaybackMode_LoopOnCompletion; break; case 2: // Play audio, fire IRQ2 when end position reached, maybe pce.CDAudio.PlayStartingAtLba(audioStartLBA); pce.CDAudio.EndLBA = audioEndLBA; pce.CDAudio.PlayMode = CDAudio.PlaybackMode_CallbackOnCompletion; break; case 3: // Play normal pce.CDAudio.PlayStartingAtLba(audioStartLBA); pce.CDAudio.EndLBA = audioEndLBA; pce.CDAudio.PlayMode = CDAudio.PlaybackMode_StopOnCompletion; break; } SetStatusMessage(STATUS_GOOD, 0); }