Increase CDXA support

This commit is contained in:
Jaby 2024-05-29 18:37:24 +02:00
parent f68f2ec03a
commit f6313a45ca
8 changed files with 66 additions and 32 deletions

View File

@ -3,11 +3,12 @@
namespace JabyEngine { namespace JabyEngine {
namespace CDXA { namespace CDXA {
struct CDFile { void play(const volatile AutoLBAEntry* lba, uint8_t rel_lba_idx, uint8_t channel, bool double_speed);
uint8_t rel_lba_idx;
};
void play(const volatile AutoLBAEntry* lba, const CDFile& file, uint8_t channel);
void stop(); void stop();
void set_channel(uint8_t channel);
void push_play();
void pop_play();
} }
} }

View File

@ -157,6 +157,7 @@ namespace JabyEngine {
static constexpr Desc ReadN{0x06, Interrupt::Type::DataReady}; static constexpr Desc ReadN{0x06, Interrupt::Type::DataReady};
static constexpr Desc Pause{0x09, Interrupt::Type::Complete}; static constexpr Desc Pause{0x09, Interrupt::Type::Complete};
static constexpr Desc Init{0x0A, Interrupt::Type::Complete}; static constexpr Desc Init{0x0A, Interrupt::Type::Complete};
static constexpr Desc Demute{0x0C, Interrupt::Type::Acknowledge};
static constexpr Desc Filter{0x0D, Interrupt::Type::Acknowledge}; static constexpr Desc Filter{0x0D, Interrupt::Type::Acknowledge};
static constexpr Desc SetMode{0x0E, Interrupt::Type::Acknowledge}; static constexpr Desc SetMode{0x0E, Interrupt::Type::Acknowledge};
static constexpr Desc GetLocP{0x11, Interrupt::Type::Acknowledge}; static constexpr Desc GetLocP{0x11, Interrupt::Type::Acknowledge};

View File

@ -43,10 +43,10 @@ namespace JabyEngine {
} }
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator); void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
void read_xa(uint32_t lba);
void continue_reading(); void continue_reading();
void read_n(uint32_t lba); CDTimeStamp get_lock();
void read_s(uint32_t lba);
void enable_CDDA(); void enable_CDDA();
void enable_CDXA(bool double_speed); void enable_CDXA(bool double_speed);

View File

@ -11,6 +11,8 @@ namespace JabyEngine {
Ready = 0, Ready = 0,
Done = 0, Done = 0,
XAMode,
Reading, Reading,
BufferFull, BufferFull,
Error, Error,

View File

@ -43,17 +43,7 @@ namespace JabyEngine {
void push_play() { void push_play() {
stop(); stop();
CD::Command::wait_completed(); last_track = CD::get_lock();
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetLocP);
const auto track = CD_IO::PortIndex0::ResponseFifo.read().raw; // track number (AAh=Lead-out area) (FFh=unknown, toc, none?)
const auto index = CD_IO::PortIndex0::ResponseFifo.read().raw; // index number (Usually 01h)
const auto mm = CD_IO::PortIndex0::ResponseFifo.read().raw; // minute number within track (00h and up)
const auto ss = CD_IO::PortIndex0::ResponseFifo.read().raw; // second number within track (00h to 59h)
const auto sect = CD_IO::PortIndex0::ResponseFifo.read().raw; // sector number within track (00h to 74h)
last_track.min = CD_IO::PortIndex0::ResponseFifo.read().raw; // minute number on entire disk (00h and up)
last_track.sec = CD_IO::PortIndex0::ResponseFifo.read().raw; // second number on entire disk (00h to 59h)
last_track.sector = CD_IO::PortIndex0::ResponseFifo.read().raw; // sector number on entire disk (00h to 74h)
} }
void pop_play() { void pop_play() {

View File

@ -4,17 +4,37 @@
namespace JabyEngine { namespace JabyEngine {
namespace CDXA { namespace CDXA {
namespace CD = JabyEngine::CD::internal; namespace CD = JabyEngine::CD::internal;
static constexpr uint8_t File = 1;
void play(const volatile AutoLBAEntry* lba, const CDFile& file, uint8_t channel) { static CD::CDTimeStamp last_track;
static constexpr uint8_t File = 0;
CD::enable_CDXA(false); void play(const volatile AutoLBAEntry* lba, uint8_t rel_lba_idx, uint8_t channel, bool double_speed) {
CD::enable_CDXA(double_speed);
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::Filter, File, channel); CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::Filter, File, channel);
CD::read_s(lba[file.rel_lba_idx].get_lba()); CD::read_xa(lba[rel_lba_idx].get_lba());
} }
void stop() { void stop() {
CD::pause(); CD::pause();
} }
void set_channel(uint8_t channel) {
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Filter, File, channel);
}
void push_play() {
/*stop();
last_track = CD::get_lock();*/
}
void pop_play() {
/*CD::Command::wait_completed();
CD::enable_CDDA(); // < Command waits
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, last_track.min, last_track.sec, last_track.sector);
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play);*/
}
} }
} }

View File

@ -47,7 +47,7 @@ namespace JabyEngine {
__debug_boot_color_at(::JabyEngine::GPU::Color24::Yellow(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Yellow(), DebugX, DebugY, DebugScale);
Command::send_wait(CD_IO::PortIndex0::CommandFifo, CD_IO::PortIndex0::ParameterFifo, CD_IO::Command::Init); Command::send_wait(CD_IO::PortIndex0::CommandFifo, CD_IO::PortIndex0::ParameterFifo, CD_IO::Command::Init);
// Demute? Command::send<CD_IO::PortIndex0>(CD_IO::Command::Demute);
} }
} }
} }

View File

@ -27,11 +27,15 @@ namespace JabyEngine {
}; };
// Requires Index0 // Requires Index0
static void read_cd(uint32_t lba, CD_IO::Command::Desc desc) { static void send_read_cmd(uint32_t lba, CD_IO::Command::Desc desc) {
const auto loc = CDTimeStamp::from(lba); const auto loc = CDTimeStamp::from(lba);
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd()); Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
Command::send<CD_IO::PortIndex0>(desc); Command::send<CD_IO::PortIndex0>(desc);
}
static void send_read_n(uint32_t lba) {
send_read_cmd(lba, CD_IO::Command::ReadN);
current_state = State::Reading; current_state = State::Reading;
} }
@ -84,7 +88,9 @@ namespace JabyEngine {
cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq); cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq);
if(!CD_IO::IndexStatus.read().is_set(CD_IO::IndexStatus::HasXAFifoData)) { if(current_state != State::XAMode) {
printf("Wuff %i (%i)\n", cur_irq, current_state);
switch(cur_irq) { switch(cur_irq) {
case CD_IO::Interrupt::DataReady: { case CD_IO::Interrupt::DataReady: {
// Obtain sector content here // Obtain sector content here
@ -144,22 +150,36 @@ namespace JabyEngine {
CD_IO::PortIndex0::change_to(); CD_IO::PortIndex0::change_to();
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode); Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode);
read_n(cur_lba); send_read_n(cur_lba);
}
void read_xa(uint32_t lba) {
send_read_cmd(lba, CD_IO::Command::ReadS);
current_state = State::XAMode;
} }
void continue_reading() { void continue_reading() {
if(current_state == State::BufferFull) { if(current_state == State::BufferFull) {
Command::wait_completed(); Command::wait_completed();
read_n(cur_lba); send_read_n(cur_lba);
} }
} }
void read_n(uint32_t lba) { CDTimeStamp get_lock() {
read_cd(lba, CD_IO::Command::ReadN); Command::wait_completed();
} Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetLocP);
void read_s(uint32_t lba) { const auto track = CD_IO::PortIndex0::ResponseFifo.read().raw; // track number (AAh=Lead-out area) (FFh=unknown, toc, none?)
read_cd(lba, CD_IO::Command::ReadS); const auto index = CD_IO::PortIndex0::ResponseFifo.read().raw; // index number (Usually 01h)
const auto mm = CD_IO::PortIndex0::ResponseFifo.read().raw; // minute number within track (00h and up)
const auto ss = CD_IO::PortIndex0::ResponseFifo.read().raw; // second number within track (00h to 59h)
const auto sect = CD_IO::PortIndex0::ResponseFifo.read().raw; // sector number within track (00h to 74h)
return CDTimeStamp{
.min = CD_IO::PortIndex0::ResponseFifo.read().raw, // minute number on entire disk (00h and up)
.sec = CD_IO::PortIndex0::ResponseFifo.read().raw, // second number on entire disk (00h to 59h)
.sector = CD_IO::PortIndex0::ResponseFifo.read().raw, // sector number on entire disk (00h to 74h)
};
} }
void enable_CDDA() { void enable_CDDA() {