Play CDDA track
This commit is contained in:
@@ -45,6 +45,8 @@ namespace JabyEngine {
|
||||
|
||||
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
void continue_reading();
|
||||
|
||||
void enable_CDDA();
|
||||
}
|
||||
}
|
||||
}
|
36
src/Library/src/Audio/CDDA.cpp
Normal file
36
src/Library/src/Audio/CDDA.cpp
Normal 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() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -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});
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user