Play CDDA track

This commit is contained in:
2024-05-05 22:12:23 +02:00
parent 01622fd5d6
commit f91a7b470c
9 changed files with 80 additions and 3 deletions

View File

@@ -45,6 +45,8 @@ namespace JabyEngine {
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
void continue_reading();
void enable_CDDA();
}
}
}

View File

@@ -0,0 +1,36 @@
#include "../../internal-include/CD/cd_internal.hpp"
#include <PSX/Audio/CDDA.hpp>
#include <stdio.hpp>
namespace JabyEngine {
namespace CDDA {
namespace CD = JabyEngine::CD::internal;
TrackList get_tracks() {
CD::Command::wait_completed();
CD_IO::PortIndex0::change_to();
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetTN);
const auto stat = CD_IO::PortIndex0::ResponseFifo.read();
const auto first = CD_IO::PortIndex0::ResponseFifo.read().raw;
const auto end = CD_IO::PortIndex0::ResponseFifo.read().raw;
const auto last_track = (end - first) + 1;
if(last_track == 1) {
return TrackList::empty();
}
return TrackList{.first_track = 2, .last_track = static_cast<uint8_t>(last_track)};
}
void play(uint8_t track) {
CD::enable_CDDA(); // < Command waits
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play, track);
}
void stop() {
}
}
}

View File

@@ -15,8 +15,8 @@ namespace JabyEngine {
}
static void clear_cd_and_ext_audio_volume() {
CDVolume::Left.write({0});
CDVolume::Right.write({0});
CDVolume::Left.write(0.5_vol);
CDVolume::Right.write(0.5_vol);
ExternalAudioInputVolume::Left.write({0});
ExternalAudioInputVolume::Right.write({0});

View File

@@ -6,7 +6,8 @@
namespace JabyEngine {
namespace CD {
namespace internal {
static constexpr auto DataSectorMode = CD_IO::Mode::from(CD_IO::Mode::DoubleSpeed, CD_IO::Mode::DataSector);
static constexpr auto AudioSectorMode = CD_IO::Mode::from(CD_IO::Mode::SingleSpeed, CD_IO::Mode::CDDA);
static constexpr auto DataSectorMode = CD_IO::Mode::from(CD_IO::Mode::DoubleSpeed, CD_IO::Mode::DataSector);
static SysCall::InterruptVerifierResult interrupt_verifier();
static uint32_t interrupt_handler(uint32_t);
@@ -136,6 +137,12 @@ namespace JabyEngine {
read_cd(cur_lba);
}
}
void enable_CDDA() {
Command::wait_completed();
CD_IO::PortIndex0::change_to();
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode);
}
}
}
}