Load TIM files (broken currently)
This commit is contained in:
parent
658d092315
commit
8b94760130
|
@ -30,7 +30,7 @@ namespace JabyEngine {
|
||||||
LZ4Decompressor lz4_decomp;
|
LZ4Decompressor lz4_decomp;
|
||||||
JobArray jobs;
|
JobArray jobs;
|
||||||
const AutoLBAEntry* lba = nullptr;
|
const AutoLBAEntry* lba = nullptr;
|
||||||
uint32_t*const tmp_area = nullptr; //< The start of the area to copy data to for the file processor
|
uint32_t* tmp_area = nullptr;
|
||||||
|
|
||||||
void start_cur_job();
|
void start_cur_job();
|
||||||
bool process_data();
|
bool process_data();
|
||||||
|
@ -38,8 +38,15 @@ namespace JabyEngine {
|
||||||
public:
|
public:
|
||||||
CDFileProcessor() = default;
|
CDFileProcessor() = default;
|
||||||
|
|
||||||
void setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint32_t* tmp_area = &__heap_base);
|
void setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint32_t* tmp_area = &__heap_base);
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
void setup(const volatile AutoLBAEntry* lba, const CDFile (&file_array)[N], uint32_t* tmp_area = &__heap_base) {
|
||||||
|
CDFileProcessor::setup(lba, JobArray{file_array, N}, tmp_area);
|
||||||
|
}
|
||||||
|
|
||||||
Progress process();
|
Progress process();
|
||||||
|
|
||||||
bool next() {
|
bool next() {
|
||||||
if(this->jobs.next()) {
|
if(this->jobs.next()) {
|
||||||
CDFileProcessor::start_cur_job();
|
CDFileProcessor::start_cur_job();
|
||||||
|
|
|
@ -8,34 +8,41 @@ namespace JabyEngine {
|
||||||
void CDFileProcessor :: start_cur_job() {
|
void CDFileProcessor :: start_cur_job() {
|
||||||
using CD::internal::FileInfo;
|
using CD::internal::FileInfo;
|
||||||
using CD::internal::SectorBufferAllocator;
|
using CD::internal::SectorBufferAllocator;
|
||||||
const auto configurate_for = [this](const CDFile& file) -> SectorBufferAllocator {
|
const auto configurate_for = [this](const CDFile& file) {
|
||||||
static const auto circular_buffer_callback = [](void* ctx) -> CD_IO::DataSector* {
|
const auto disable_lz4 = [this](uint32_t* work_area, size_t size) -> uint32_t* {
|
||||||
CDFileProcessor &self = *reinterpret_cast<CDFileProcessor*>(ctx);
|
uint8_t* dst_adr = reinterpret_cast<uint8_t*>(this->circular_buffer.setup(reinterpret_cast<CD_IO::DataSector*>(work_area), size));
|
||||||
return self.circular_buffer.allocate();
|
|
||||||
|
this->lz4_decomp.disable();
|
||||||
|
return reinterpret_cast<uint32_t*>(dst_adr);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto enable_lz4 = [this](uint32_t* work_area, size_t size) -> uint32_t* {
|
||||||
|
uint8_t* dst_adr = reinterpret_cast<uint8_t*>(this->circular_buffer.setup(reinterpret_cast<CD_IO::DataSector*>(work_area), size));
|
||||||
|
|
||||||
|
this->lz4_decomp.setup(dst_adr);
|
||||||
|
return reinterpret_cast<uint32_t*>(dst_adr);
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(file.type) {
|
switch(file.type) {
|
||||||
case CDFileType::SimpleTIM:
|
case CDFileType::SimpleTIM:
|
||||||
printf("CDFileProcessor: SimpleTIM not supported yet\n");
|
this->file_state = FileProcessor::create(enable_lz4(this->tmp_area, NormalCircularBufferSize), file.payload.simple_tim);
|
||||||
return SectorBufferAllocator::invalid();
|
break;
|
||||||
|
|
||||||
case CDFileType::CopyTo:
|
case CDFileType::CopyTo:
|
||||||
this->circular_buffer.setup(reinterpret_cast<CD_IO::DataSector*>(file.payload.copy_to.dst), 512);
|
this->file_state = FileProcessor::create(disable_lz4(file.payload.copy_to.dst, 512), Nothing());
|
||||||
this->lz4_decomp.disable();
|
break;
|
||||||
|
|
||||||
this->file_state = FileProcessor::create(this->tmp_area, Nothing());
|
|
||||||
return SectorBufferAllocator::create(this, circular_buffer_callback);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return SectorBufferAllocator::invalid();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto& cur_job = *this->jobs.files;
|
const auto& cur_job = *this->jobs.files;
|
||||||
const auto& cur_lba = this->lba[cur_job.rel_lba_idx];
|
const auto& cur_lba = this->lba[cur_job.rel_lba_idx];
|
||||||
const auto cfg = configurate_for(cur_job);
|
|
||||||
|
configurate_for(cur_job);
|
||||||
CD::internal::read_file(FileInfo::from(cur_lba), cfg);
|
CD::internal::read_file(FileInfo::from(cur_lba), SectorBufferAllocator::create(this,
|
||||||
|
[](void* ctx) -> CD_IO::DataSector* {
|
||||||
|
CDFileProcessor &self = *reinterpret_cast<CDFileProcessor*>(ctx);
|
||||||
|
return self.circular_buffer.allocate();
|
||||||
|
}));
|
||||||
|
|
||||||
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.lba, cur_lba.size_words);
|
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.lba, cur_lba.size_words);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +73,7 @@ namespace JabyEngine {
|
||||||
this->lba = const_cast<const AutoLBAEntry*>(lba);
|
this->lba = const_cast<const AutoLBAEntry*>(lba);
|
||||||
this->jobs = jobs;
|
this->jobs = jobs;
|
||||||
|
|
||||||
// Setsup the circular buffer and determines where to place the temp area in
|
this->tmp_area = tmp_area;
|
||||||
const_cast<uint32_t*&>(this->tmp_area) = reinterpret_cast<uint32_t*>(this->circular_buffer.setup(reinterpret_cast<CD_IO::DataSector*>(tmp_area), NormalCircularBufferSize));
|
|
||||||
CDFileProcessor::start_cur_job();
|
CDFileProcessor::start_cur_job();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue