jabyengine/include/PSX/File/Processor/cd_file_processor.hpp

60 lines
1.9 KiB
C++

#ifndef __JABYENGINE_CD_FILE_PROCESSOR_HPP__
#define __JABYENGINE_CD_FILE_PROCESSOR_HPP__
#include "../../AutoLBA/auto_lba.hpp"
#include "../../Auxiliary/circular_buffer.hpp"
#include "../../Auxiliary/lz4_decompressor.hpp"
#include "../../System/IOPorts/cd_io.hpp"
#include "../cd_file_types.hpp"
#include "file_processor.hpp"
extern "C" uint32_t __heap_base;
namespace JabyEngine {
class CDFileProcessor {
public:
struct JobArray {
const CDFile* files = nullptr;
size_t size = 0;
bool next() {
this->files += 1;
this->size -= 1;
return this->size > 0;
}
};
private:
FileProcessor::State file_pro_state;
CircularBuffer<CD_IO::DataSector> circular_buffer;
LZ4Decompressor lz4_decomp;
JobArray jobs;
const AutoLBAEntry* lba = nullptr;
uint32_t*const tmp_area = nullptr; //< The start of the area to copy data to
uint32_t* dst_area = nullptr; //< Current target for copying the data
void start_cur_job();
void reading_state(const CDFile& file);
void done_state(const CDFile& file);
public:
CDFileProcessor() = default;
void setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint32_t* tmp_area = &__heap_base);
Progress process();
bool next() {
if(this->jobs.next()) {
CDFileProcessor::start_cur_job();
return true;
}
return false;
}
};
}
// This will be used as the file processor but will work on cd types
// Will probably use file_processor
// Will also setup the circular buffer for the CD code
#endif //!__JABYENGINE_CD_FILE_PROCESSOR_HPP__