Get rough shape of CD file processing code
This commit is contained in:
parent
9e255fa668
commit
26cd4bd4c4
|
@ -1,34 +1,35 @@
|
|||
#ifndef __JABYENGINE_CD_FILE_PROCESSOR_HPP__
|
||||
#define __JABYENGINE_CD_FILE_PROCESSOR_HPP__
|
||||
#include "../../AutoLBA/auto_lba.hpp"
|
||||
#include "../../Auxiliary/lz4_decompressor.hpp"
|
||||
#include "../cd_file_types.hpp"
|
||||
#include "file_processor.hpp"
|
||||
|
||||
extern "C" uint32_t __heap_base;
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CDFileProcessor {
|
||||
class State {
|
||||
private:
|
||||
FileProcessor::State file_processor_state;
|
||||
const uint32_t* data_adr;
|
||||
|
||||
public:
|
||||
State() = default;
|
||||
|
||||
void setup(uint16_t lba, uint16_t size, const CDFile::Payload& payload);
|
||||
bool process();
|
||||
class CDFileProcessor {
|
||||
public:
|
||||
struct JobArray {
|
||||
const CDFile* files = nullptr;
|
||||
size_t size = 0;
|
||||
};
|
||||
|
||||
template<size_t Size>
|
||||
static void load_from_cd(const OverlayLBA* overlay_lbas, const CDFile (&cd_files)[Size]) {
|
||||
State state;
|
||||
private:
|
||||
FileProcessor::State file_pro_state;
|
||||
LZ4Decompressor lz4_decomp;
|
||||
JobArray jobs;
|
||||
uint8_t* work_area = nullptr;
|
||||
const AutoLBAEntry* lba = nullptr;
|
||||
|
||||
for(const auto& file : cd_files) {
|
||||
const auto& lba_info = overlay_lbas[file.rel_lba_idx];
|
||||
void start_cur_job();
|
||||
|
||||
state.setup(lba_info.lba, lba_info.size, file.payload);
|
||||
//while(state.process());???
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
CDFileProcessor() = default;
|
||||
|
||||
void setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint8_t* work_area = reinterpret_cast<uint8_t*>(&__heap_base));
|
||||
Progress process();
|
||||
};
|
||||
}
|
||||
|
||||
// This will be used as the file processor but will work on cd types
|
||||
|
|
|
@ -6,24 +6,31 @@
|
|||
namespace JabyEngine {
|
||||
enum struct CDFileType : uint8_t {
|
||||
SimpleTIM = 0,
|
||||
Custom
|
||||
CopyTo,
|
||||
};
|
||||
|
||||
struct __no_align CDFile {
|
||||
union __no_align Payload {
|
||||
uint32_t empty;
|
||||
SimpleTIM simple_tim;
|
||||
CopyTo copy_to;
|
||||
};
|
||||
|
||||
uint8_t rel_lba_idx;
|
||||
CDFileType type;
|
||||
Payload payload;
|
||||
|
||||
static_assert(sizeof(Payload) == sizeof(uint32_t));
|
||||
};
|
||||
|
||||
namespace CDFileBuilder {
|
||||
struct CDFileBuilder {
|
||||
static constexpr CDFile simple_tim(uint8_t rel_lba_idx, SimpleTIM simple_tim) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::SimpleTIM, .payload = {.simple_tim = simple_tim}};
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr CDFile copy_to(uint8_t rel_lba_idx, uint32_t* dst) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::CopyTo, .payload = {.copy_to = CopyTo{dst}}};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //!__JABYENGINE_CD_FILE_TYPES_HPP__
|
|
@ -33,5 +33,9 @@ namespace JabyEngine {
|
|||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
|
||||
}
|
||||
};
|
||||
|
||||
struct __no_align CopyTo {
|
||||
uint32_t* dst;
|
||||
};
|
||||
}
|
||||
#endif // !__JABYENGINE_FILE_TYPES_HPP__
|
|
@ -5,7 +5,61 @@
|
|||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
enum struct State {
|
||||
Free = 0,
|
||||
Done = 0,
|
||||
|
||||
Reading,
|
||||
BufferFull,
|
||||
Error,
|
||||
};
|
||||
|
||||
extern VolatilePOD<CD_IO::Interrupt::Type> last_interrupt;
|
||||
extern VolatilePOD<State> state;
|
||||
|
||||
struct Sector {
|
||||
uint32_t data[512];
|
||||
};
|
||||
|
||||
struct FileInfo {
|
||||
uint16_t lba;
|
||||
uint16_t sectors;
|
||||
|
||||
constexpr FileInfo(uint16_t lba, uint16_t sectors) : lba(lba), sectors(sectors) {
|
||||
}
|
||||
};
|
||||
|
||||
class SectorBufferAllocator {
|
||||
private:
|
||||
struct Dummy {
|
||||
};
|
||||
|
||||
typedef Sector* (*SimpleAllocator)();
|
||||
typedef Sector* (Dummy::*ComplexAllocator)();
|
||||
|
||||
private:
|
||||
Dummy* this_ctx = nullptr;
|
||||
union {
|
||||
SimpleAllocator allocate;
|
||||
ComplexAllocator this_allocate;
|
||||
};
|
||||
|
||||
SectorBufferAllocator(SimpleAllocator allocate) : this_ctx(nullptr), allocate(allocate) {
|
||||
}
|
||||
|
||||
SectorBufferAllocator(Dummy* ctx, ComplexAllocator this_allocate) : this_ctx(ctx), this_allocate(this_allocate) {
|
||||
}
|
||||
|
||||
public:
|
||||
static SectorBufferAllocator create(SimpleAllocator allocate) {
|
||||
return SectorBufferAllocator(allocate);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static SectorBufferAllocator create(T &obj, Sector* (T::*obj_allocate)()) {
|
||||
return SectorBufferAllocator(reinterpret_cast<Dummy*>(&obj), reinterpret_cast<ComplexAllocator>(obj_allocate));
|
||||
}
|
||||
};
|
||||
|
||||
struct Command {
|
||||
static void wait_until(CD_IO::Interrupt::Type irq) {
|
||||
|
@ -26,6 +80,8 @@ namespace JabyEngine {
|
|||
wait_until(cmd.complete_irq);
|
||||
}
|
||||
};
|
||||
|
||||
State start_reading(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "../../../include/BootLoader/boot_loader.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
|
||||
extern JabyEngine::NextRoutine main();
|
||||
|
||||
namespace JabyEngine {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/syscalls.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
|
@ -35,6 +37,11 @@ namespace JabyEngine {
|
|||
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
|
||||
.verifier_function = interrupt_verifier
|
||||
};
|
||||
|
||||
State start_reading(FileInfo file_info, const SectorBufferAllocator& buffer_allocator) {
|
||||
printf("I'm not implemented! %s\n", __FUNCTION__);
|
||||
return State::Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +1,22 @@
|
|||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
void CDFileProcessor :: start_cur_job() {
|
||||
const auto& cur_lba = this->lba[this->jobs.files->rel_lba_idx];
|
||||
|
||||
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.lba, cur_lba.size_words);
|
||||
}
|
||||
|
||||
void CDFileProcessor :: setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint8_t* work_area) {
|
||||
this->lba = const_cast<const AutoLBAEntry*>(lba);
|
||||
this->work_area = work_area;
|
||||
this->jobs = jobs;
|
||||
|
||||
CDFileProcessor::start_cur_job();
|
||||
}
|
||||
|
||||
Progress CDFileProcessor :: process() {
|
||||
return Progress::Error;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue