Save state before change

This commit is contained in:
jaby 2024-07-02 20:05:02 +02:00
parent 07756fd180
commit f5020e152b
6 changed files with 24 additions and 10 deletions

View File

@ -13,6 +13,15 @@ namespace JabyEngine {
static constexpr T words_to_sectors(T size) { static constexpr T words_to_sectors(T size) {
return (size + static_cast<T>(DataSector::SizeWords - 1))/static_cast<T>(DataSector::SizeWords); return (size + static_cast<T>(DataSector::SizeWords - 1))/static_cast<T>(DataSector::SizeWords);
} }
constexpr size_t hash() const {
uint32_t value = 0;
for(const auto word : this->data) {
value += word;
}
return value;
}
}; };
enum Index { enum Index {
@ -142,10 +151,10 @@ namespace JabyEngine {
static void ack_extended(IOPort<InterruptFlag>& port) { static void ack_extended(IOPort<InterruptFlag>& port) {
port.write(InterruptFlag::from(InterruptFlag::InterruptTypValue.range_max<uint8_t>(), InterruptEnable::UnknownIRQ, InterruptEnable::CommandStartIRQ)); port.write(InterruptFlag::from(InterruptFlag::InterruptTypValue.range_max<uint8_t>(), InterruptEnable::UnknownIRQ, InterruptEnable::CommandStartIRQ));
// *reinterpret_cast<uint32_t*>(0x0) = 0; }
// *reinterpret_cast<uint32_t*>(0x0) = 0;
// *reinterpret_cast<uint32_t*>(0x0) = 0; static void reset_parameter_fifo(IOPort<InterruptFlag>& port) {
// *reinterpret_cast<uint32_t*>(0x0) = 0; port.write(InterruptFlag{0x40});
} }
}; };

View File

@ -7,6 +7,8 @@
namespace JabyEngine { namespace JabyEngine {
namespace CD { namespace CD {
extern volatile uint8_t zero;
namespace internal { namespace internal {
enum struct State { enum struct State {
Ready = 0, Ready = 0,
@ -84,6 +86,7 @@ namespace JabyEngine {
void continue_reading(); void continue_reading();
BCDTimeStamp get_loc(); BCDTimeStamp get_loc();
BCDTimeStamp get_locL();
void enable_CD(); void enable_CD();
void enable_CDDA(); void enable_CDDA();

View File

@ -48,7 +48,7 @@ namespace JabyEngine {
setting.get_loc_functional = !CD::get_loc().is_zero(); setting.get_loc_functional = !CD::get_loc().is_zero();
CD::enable_CDXA(double_speed); //< Activates PortIndex0 CD::enable_CDXA(double_speed); //< Activates PortIndex0
set_channel(channel); set_channel(channel);printf("!!0-%X %X %X\n", setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector);
CD::NewCommand::send(CD_IO::Command::SetLoc, setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector); CD::NewCommand::send(CD_IO::Command::SetLoc, setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector);
CD::NewCommand::send(CD_IO::Command::ReadS); CD::NewCommand::send(CD_IO::Command::ReadS);
} }
@ -75,8 +75,8 @@ namespace JabyEngine {
void pop_play() { void pop_play() {
CD::enable_CDXA(setting.double_speed); //< Activates PortIndex0 CD::enable_CDXA(setting.double_speed); //< Activates PortIndex0
set_channel(setting.channel); set_channel(setting.channel);printf("!!1-%X %X %X\n", setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
CD::NewCommand::send(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector); CD::NewCommand::send_wait_response(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
CD::NewCommand::send(CD_IO::Command::ReadS); CD::NewCommand::send(CD_IO::Command::ReadS);
} }
} }

View File

@ -56,8 +56,8 @@ namespace JabyEngine {
return self.circular_buffer.allocate(); return self.circular_buffer.allocate();
})); }));
printf(">>> 0x%p\n", this->jobs.files); //printf(">>> 0x%p\n", this->jobs.files);
printf(">>> %i.) CD needs to load LBA: %i -> %i (is LZ4: [%s])\n", cur_job.rel_lba_idx, cur_lba.get_lba(), cur_lba.get_size_in_sectors(), cur_lba.is_lz4() ? "Yes" : "No"); //printf(">>> %i.) CD needs to load LBA: %i -> %i (is LZ4: [%s])\n", cur_job.rel_lba_idx, cur_lba.get_lba(), cur_lba.get_size_in_sectors(), cur_lba.is_lz4() ? "Yes" : "No");
} }
bool CDFileProcessor :: process_data() { bool CDFileProcessor :: process_data() {

View File

@ -104,7 +104,7 @@ namespace JabyEngine {
} }
static Progress switch_state_parse_data(State::Configuration& config, SimpleTIMState& state) { static Progress switch_state_parse_data(State::Configuration& config, SimpleTIMState& state) {
state.words_left = set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), {state.dst_info.get_texture_position(), state.size_info.get_texture_size()}); state.words_left = set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), {state.dst_info.get_texture_position(), state.size_info.get_texture_size()});
return Helper::exchange_and_execute_process_function(parse_data, config, state); return Helper::exchange_and_execute_process_function(parse_data, config, state);
} }

View File

@ -32,7 +32,9 @@ namespace JabyEngine {
void routine(uint32_t irq) { void routine(uint32_t irq) {
while(true) { while(true) {
const auto old_status = CD_IO::IndexStatus.read();
CD_IRQ::process(irq); CD_IRQ::process(irq);
CD_IO::IndexStatus.write(old_status);
irq = Callback::internal::CD::resume(); irq = Callback::internal::CD::resume();
} }
} }