Do not use threads for CD IRQs anymore

This commit is contained in:
2024-10-05 11:14:33 +02:00
parent 7de81f2d40
commit fce03319ab
7 changed files with 163 additions and 156 deletions

View File

@@ -8,6 +8,21 @@
namespace JabyEngine {
namespace CD {
namespace internal {
struct File {
uint32_t cur_lba;
uint32_t dst_lba;
void set_from(const AutoLBAEntry& file_info) {
this->cur_lba = file_info.get_lba();
this->dst_lba = this->cur_lba + file_info.get_size_in_sectors();
}
bool done_processing() {
this->cur_lba++;
return this->cur_lba == this->dst_lba;
}
};
enum struct State {
Ready = 0,
Done = 0,
@@ -50,12 +65,6 @@ namespace JabyEngine {
}
};
namespace IRQ {
void process(uint32_t irq);
void read_sector_to0(uint32_t* dst, size_t bytes);
void resume_at0(const BCDTimeStamp& cd_time);
}
static State read_current_state() {
return const_cast<volatile State&>(current_state);
}
@@ -64,6 +73,15 @@ namespace JabyEngine {
void end_read_file();
void continue_reading();
void copy_from_sector(uint32_t* dst, size_t bytes);
template<typename T>
T copy_from_sector() {
T data;
copy_from_sector(reinterpret_cast<uint32_t*>(&data), sizeof(T));
return data;
}
BCDTimeStamp get_loc();
BCDTimeStamp get_locL();
@@ -71,6 +89,10 @@ namespace JabyEngine {
void enable_CDDA();
void enable_CDXA(bool double_speed);
static void set_loc(const BCDTimeStamp& cd_time) {
Command::send_no_wait(CD_IO::Command::SetLoc, cd_time.min, cd_time.sec, cd_time.sector);
}
static void pause() {
Command::send(CD_IO::Command::Pause);
}