Integrate all the progress into master #6
|
@ -48,6 +48,7 @@ namespace Assets {
|
|||
return;
|
||||
}
|
||||
}
|
||||
file_processor.shutdown();
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace JabyEngine {
|
|||
CDFileProcessor() = default;
|
||||
|
||||
void setup(const volatile AutoLBAEntry* lba, JobArray jobs, const BufferConfiguration& buf_cfg);
|
||||
void shutdown();
|
||||
|
||||
template<size_t N>
|
||||
void setup(const volatile AutoLBAEntry* lba, const CDFile (&file_array)[N], const BufferConfiguration& buf_cfg) {
|
||||
|
|
|
@ -20,8 +20,6 @@ namespace JabyEngine {
|
|||
|
||||
extern State current_state;
|
||||
extern volatile uint8_t cmd_interrupt_bit;
|
||||
extern uint8_t rel_last_send_cmd;
|
||||
extern uint8_t last_send_cmd;
|
||||
|
||||
struct Command {
|
||||
struct Internal {
|
||||
|
@ -35,16 +33,11 @@ namespace JabyEngine {
|
|||
|
||||
do {
|
||||
cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
|
||||
if(cur_irq == CD_IO::Interrupt::Acknowledge) {
|
||||
printf("Rand ACK for 0x%X\n", last_send_cmd);
|
||||
}
|
||||
if(cur_irq == CD_IO::Interrupt::Complete) {
|
||||
printf("Rand Comp for 0x%X\n", last_send_cmd);
|
||||
}
|
||||
} while(cur_irq == CD_IO::Interrupt::None);
|
||||
cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
|
||||
|
||||
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
|
||||
cmd_interrupt_bit = bit::set(cmd_interrupt_bit, cur_irq);
|
||||
|
||||
return cur_irq;
|
||||
};
|
||||
CD_IO::PortIndex1::change_to();
|
||||
|
@ -61,9 +54,6 @@ namespace JabyEngine {
|
|||
CD_IO::PortIndex0::change_to();
|
||||
((parameter_fifo.write(CD_IO::ParameterFifo{args})),...);
|
||||
cmd_fifo.write(CD_IO::CommandFifo{cmd.id});
|
||||
|
||||
rel_last_send_cmd = cmd.id;
|
||||
last_send_cmd = cmd.id;
|
||||
SysCall::ExitCriticalSection();
|
||||
}
|
||||
|
||||
|
@ -74,9 +64,6 @@ namespace JabyEngine {
|
|||
CD_IO::PortIndex0::change_to();
|
||||
((parameter_fifo.write(CD_IO::ParameterFifo{args})),...);
|
||||
cmd_fifo.write(CD_IO::CommandFifo{cmd.id});
|
||||
|
||||
rel_last_send_cmd = cmd.id;
|
||||
last_send_cmd = cmd.id;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,6 +92,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
void end_read_file();
|
||||
void continue_reading();
|
||||
|
||||
BCDTimeStamp get_loc();
|
||||
|
|
|
@ -58,7 +58,10 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
inline CD_IO::DataSector* allocate_sector() const {
|
||||
return this->allocate(this->ctx);
|
||||
if(this->allocate) {
|
||||
return this->allocate(this->ctx);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace JabyEngine {
|
|||
} setting;
|
||||
|
||||
CD::State interrupt_handler(uint8_t irq) {
|
||||
/* switch(irq) {
|
||||
switch(irq) {
|
||||
case CD_IO::Interrupt::DataReady: {
|
||||
// The IRQ stack is 0x1000 bytes large so this should fit
|
||||
CD::RawXADataSector xa_file;
|
||||
|
@ -29,7 +29,7 @@ namespace JabyEngine {
|
|||
|
||||
case CD_IO::Interrupt::DiskError:
|
||||
return CD::State::Error;
|
||||
};*/
|
||||
};
|
||||
return CD::State::XAMode;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ namespace JabyEngine {
|
|||
set_channel(channel);
|
||||
CD::Command::send_wait(CD_IO::Command::SetLoc, setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector);
|
||||
CD::Command::send_wait(CD_IO::Command::ReadS);
|
||||
//CD::current_state = CD::State::XAMode;
|
||||
}
|
||||
|
||||
void stop() {
|
||||
|
@ -68,7 +67,6 @@ namespace JabyEngine {
|
|||
set_channel(setting.channel);
|
||||
CD::Command::send_wait(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
|
||||
CD::Command::send_wait(CD_IO::Command::ReadS);
|
||||
//CD::current_state = CD::State::XAMode;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,8 +39,6 @@ namespace JabyEngine {
|
|||
static File cur_file;
|
||||
|
||||
volatile uint8_t cmd_interrupt_bit = 0;
|
||||
uint8_t rel_last_send_cmd = 0;
|
||||
uint8_t last_send_cmd = 0;
|
||||
State current_state = State::Ready;
|
||||
auto irq_callback = SysCall::InterruptCallback::from(IRQ::verifier, IRQ::handler);
|
||||
|
||||
|
@ -95,73 +93,7 @@ namespace JabyEngine {
|
|||
|
||||
static SysCall::InterruptVerifierResult verifier() {
|
||||
if(Interrupt::is_irq(Interrupt::CDROM)) {
|
||||
const auto old_status = CD_IO::IndexStatus.read();
|
||||
|
||||
CD_IO::PortIndex1::change_to();
|
||||
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
|
||||
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
|
||||
CD_IO::PortIndex0::change_to();
|
||||
|
||||
//printf("Before: %i (IRQ: %i)\n", cmd_interrupt_bit, cur_irq);
|
||||
cmd_interrupt_bit = bit::set(cmd_interrupt_bit, cur_irq);
|
||||
//printf("After: %i (IRQ: %i)\n", cmd_interrupt_bit, cur_irq);
|
||||
|
||||
if(current_state != State::XAMode) {
|
||||
switch(cur_irq) {
|
||||
case CD_IO::Interrupt::DataReady: {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to0(sector->data, CD_IO::DataSector::SizeBytes);
|
||||
|
||||
if(cur_file.done_processing()) {
|
||||
printf("Pause1\n");
|
||||
current_state = State::Done;
|
||||
Command::send_wait_irq(CD_IO::Command::Pause);
|
||||
printf("Pause done!\n");
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = State::BufferFull;
|
||||
printf("Pause2\n");
|
||||
Command::send_wait_irq(CD_IO::Command::Pause);
|
||||
printf("Pause done!\n");
|
||||
}
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::Complete: {
|
||||
printf("Complete for 0x%X\n", rel_last_send_cmd);
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::Acknowledge: {
|
||||
if(last_send_cmd != 0x0) {
|
||||
printf("ACK 0x%X\n", last_send_cmd);
|
||||
last_send_cmd = 0x0;
|
||||
}
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DataEnd: {
|
||||
// TODO: Fix this!! This is a freaking static time
|
||||
resume_at0(BCDTimeStamp{.min = 0x0, .sec = 0x09, .sector = 0x0});
|
||||
Command::send_wait_irq(CD_IO::Command::Play);
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DiskError: {
|
||||
printf("CD ERROR\n");
|
||||
current_state = State::Error;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = CDXA::interrupt_handler(cur_irq);
|
||||
}
|
||||
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
CD_IO::IndexStatus.write(old_status);
|
||||
|
||||
Interrupt::ack_irq(Interrupt::CDROM);
|
||||
return SysCall::InterruptVerifierResult::ExecuteHandler;
|
||||
}
|
||||
|
||||
|
@ -171,7 +103,57 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
static void handler(uint32_t) {
|
||||
Interrupt::ack_irq(Interrupt::CDROM);
|
||||
const auto old_status = CD_IO::IndexStatus.read();
|
||||
|
||||
CD_IO::PortIndex1::change_to();
|
||||
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
|
||||
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
|
||||
CD_IO::PortIndex0::change_to();
|
||||
|
||||
//printf("Before: %i (IRQ: %i)\n", cmd_interrupt_bit, cur_irq);
|
||||
cmd_interrupt_bit = bit::set(cmd_interrupt_bit, cur_irq);
|
||||
//printf("After: %i (IRQ: %i)\n", cmd_interrupt_bit, cur_irq);
|
||||
|
||||
if(current_state != State::XAMode) {
|
||||
switch(cur_irq) {
|
||||
case CD_IO::Interrupt::DataReady: {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to0(sector->data, CD_IO::DataSector::SizeBytes);
|
||||
|
||||
if(cur_file.done_processing()) {
|
||||
current_state = State::Done;
|
||||
Command::send_wait_irq(CD_IO::Command::Pause);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = State::BufferFull;
|
||||
Command::send_wait_irq(CD_IO::Command::Pause);
|
||||
}
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DataEnd: {
|
||||
// TODO: Fix this!! This is a freaking static time
|
||||
resume_at0(BCDTimeStamp{.min = 0x0, .sec = 0x09, .sector = 0x0});
|
||||
Command::send_wait_irq(CD_IO::Command::Play);
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DiskError: {
|
||||
printf("CD ERROR\n");
|
||||
current_state = State::Error;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = CDXA::interrupt_handler(cur_irq);
|
||||
}
|
||||
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
CD_IO::IndexStatus.write(old_status);
|
||||
SysCall::ReturnFromException();
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +167,10 @@ namespace JabyEngine {
|
|||
send_read_n0(cur_file.cur_lba);
|
||||
}
|
||||
|
||||
void end_read_file() {
|
||||
sector_allocator = SectorBufferAllocator::invalid();
|
||||
}
|
||||
|
||||
void continue_reading() {
|
||||
if(current_state == State::BufferFull) {
|
||||
CD_IO::PortIndex0::change_to();
|
||||
|
@ -219,6 +205,7 @@ namespace JabyEngine {
|
|||
|
||||
const uint8_t mode = XAAudioSectorMode.raw | (double_speed ? DoubleSpeedBit : SingleSpeedBit);
|
||||
|
||||
current_state = State::XAMode;
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send_wait(CD_IO::Command::SetMode, mode);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@ namespace JabyEngine {
|
|||
CDFileProcessor::start_cur_job(const_cast<const AutoLBAEntry*>(lba), buf_cfg);
|
||||
}
|
||||
|
||||
void CDFileProcessor :: shutdown() {
|
||||
CD::internal::end_read_file();
|
||||
}
|
||||
|
||||
Progress CDFileProcessor :: process() {
|
||||
const auto cur_state = CD::internal::read_current_state();
|
||||
CDFileProcessor::process_data();
|
||||
|
|
|
@ -22,10 +22,7 @@ namespace JabyEngine {
|
|||
|
||||
static SysCall::InterruptVerifierResult interrupt_verifier() {
|
||||
if(Interrupt::is_irq(Interrupt::VBlank)) {
|
||||
vsync_counter++;
|
||||
MasterTime::value++;
|
||||
|
||||
//Callback::internal::VSync::execute();
|
||||
Interrupt::ack_irq(Interrupt::VBlank);
|
||||
return SysCall::InterruptVerifierResult::ExecuteHandler;
|
||||
}
|
||||
|
||||
|
@ -35,7 +32,10 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
static void interrupt_handler(uint32_t) {
|
||||
Interrupt::ack_irq(Interrupt::VBlank);
|
||||
vsync_counter++;
|
||||
MasterTime::value++;
|
||||
|
||||
//Callback::internal::VSync::execute();
|
||||
SysCall::ReturnFromException();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace JabyEngine {
|
|||
namespace Timer {
|
||||
static SysCall::InterruptVerifierResult interrupt_verifier() {
|
||||
if(Interrupt::is_irq(Interrupt::Timer2)) {
|
||||
HighResTime::global_counter_10ms = HighResTime::global_counter_10ms + 1;
|
||||
Interrupt::ack_irq(Interrupt::Timer2);
|
||||
return SysCall::InterruptVerifierResult::ExecuteHandler;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
static void interrupt_handler(uint32_t) {
|
||||
Interrupt::ack_irq(Interrupt::Timer2);
|
||||
HighResTime::global_counter_10ms = HighResTime::global_counter_10ms + 1;
|
||||
SysCall::ReturnFromException();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue