Improve CDDA track list

This commit is contained in:
jaby 2024-05-05 23:12:08 +02:00
parent f91a7b470c
commit fe88157aba
4 changed files with 19 additions and 5 deletions

View File

@ -15,6 +15,6 @@ namespace JabyEngine {
TrackList get_tracks(); TrackList get_tracks();
void play(uint8_t track); void play(uint8_t track);
void stop(); void pause();
} }
} }

View File

@ -29,8 +29,9 @@ namespace JabyEngine {
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play, track); CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play, track);
} }
void stop() { void pause() {
CD::Command::wait_completed();
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Pause);
} }
} }
} }

View File

@ -72,6 +72,10 @@ impl Time {
Time{sector, second, minute} Time{sector, second, minute}
} }
pub fn as_sectors(&self) -> usize {
self.sector as usize + self.second as usize*Self::MAX_SECTORS + self.minute as usize*Self::MAX_SECONDS*Self::MAX_SECTORS
}
pub fn dump(&self) -> String { pub fn dump(&self) -> String {
format!("min: {}, sec: {}, sector: {}", self.minute, self.second, self.sector) format!("min: {}, sec: {}, sector: {}", self.minute, self.second, self.sector)
} }

View File

@ -50,7 +50,16 @@ impl SectorWriter for BinCueWriter {
fn cd_da_start(&mut self) -> Result<(), Error> { fn cd_da_start(&mut self) -> Result<(), Error> {
self.track += 1; self.track += 1;
self.cue.push(CueSpecifier::Track{number: self.track, data_type: CueDataType::Audio}); self.cue.push(CueSpecifier::Track{number: self.track, data_type: CueDataType::Audio});
// Skip pregap because why have one?
if self.track == 2 {
self.cue.push(CueSpecifier::PreGap{time: Time::cd_pregap()});
}
else {
self.cue.push(CueSpecifier::Index{number: 0, time: self.cd_time.clone()});
self.cd_time.add_sectors(Time::cd_pregap().as_sectors())?;
}
self.cue.push(CueSpecifier::Index{number: 1, time: self.cd_time.clone()}); self.cue.push(CueSpecifier::Index{number: 1, time: self.cd_time.clone()});
Ok(()) Ok(())
} }