Get rough shape of CD file processing code
This commit is contained in:
parent
c1b8b54eb5
commit
672ad04c83
|
@ -1,34 +1,35 @@
|
||||||
#ifndef __JABYENGINE_CD_FILE_PROCESSOR_HPP__
|
#ifndef __JABYENGINE_CD_FILE_PROCESSOR_HPP__
|
||||||
#define __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 "../cd_file_types.hpp"
|
||||||
#include "file_processor.hpp"
|
#include "file_processor.hpp"
|
||||||
|
|
||||||
|
extern "C" uint32_t __heap_base;
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace CDFileProcessor {
|
class CDFileProcessor {
|
||||||
class State {
|
|
||||||
private:
|
|
||||||
FileProcessor::State file_processor_state;
|
|
||||||
const uint32_t* data_adr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State() = default;
|
struct JobArray {
|
||||||
|
const CDFile* files = nullptr;
|
||||||
void setup(uint16_t lba, uint16_t size, const CDFile::Payload& payload);
|
size_t size = 0;
|
||||||
bool process();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<size_t Size>
|
private:
|
||||||
static void load_from_cd(const OverlayLBA* overlay_lbas, const CDFile (&cd_files)[Size]) {
|
FileProcessor::State file_pro_state;
|
||||||
State state;
|
LZ4Decompressor lz4_decomp;
|
||||||
|
JobArray jobs;
|
||||||
|
uint8_t* work_area = nullptr;
|
||||||
|
const AutoLBAEntry* lba = nullptr;
|
||||||
|
|
||||||
for(const auto& file : cd_files) {
|
void start_cur_job();
|
||||||
const auto& lba_info = overlay_lbas[file.rel_lba_idx];
|
|
||||||
|
|
||||||
state.setup(lba_info.lba, lba_info.size, file.payload);
|
public:
|
||||||
//while(state.process());???
|
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
|
// This will be used as the file processor but will work on cd types
|
||||||
|
|
|
@ -6,24 +6,31 @@
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
enum struct CDFileType : uint8_t {
|
enum struct CDFileType : uint8_t {
|
||||||
SimpleTIM = 0,
|
SimpleTIM = 0,
|
||||||
Custom
|
CopyTo,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __no_align CDFile {
|
struct __no_align CDFile {
|
||||||
union __no_align Payload {
|
union __no_align Payload {
|
||||||
uint32_t empty;
|
uint32_t empty;
|
||||||
SimpleTIM simple_tim;
|
SimpleTIM simple_tim;
|
||||||
|
CopyTo copy_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t rel_lba_idx;
|
uint8_t rel_lba_idx;
|
||||||
CDFileType type;
|
CDFileType type;
|
||||||
Payload payload;
|
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) {
|
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}};
|
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__
|
#endif //!__JABYENGINE_CD_FILE_TYPES_HPP__
|
|
@ -33,5 +33,9 @@ namespace JabyEngine {
|
||||||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
|
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct __no_align CopyTo {
|
||||||
|
uint32_t* dst;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
#endif // !__JABYENGINE_FILE_TYPES_HPP__
|
#endif // !__JABYENGINE_FILE_TYPES_HPP__
|
|
@ -5,7 +5,61 @@
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace CD {
|
namespace CD {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
enum struct State {
|
||||||
|
Free = 0,
|
||||||
|
Done = 0,
|
||||||
|
|
||||||
|
Reading,
|
||||||
|
BufferFull,
|
||||||
|
Error,
|
||||||
|
};
|
||||||
|
|
||||||
extern VolatilePOD<CD_IO::Interrupt::Type> last_interrupt;
|
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 {
|
struct Command {
|
||||||
static void wait_until(CD_IO::Interrupt::Type irq) {
|
static void wait_until(CD_IO::Interrupt::Type irq) {
|
||||||
|
@ -26,6 +80,8 @@ namespace JabyEngine {
|
||||||
wait_until(cmd.complete_irq);
|
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 "../../../include/BootLoader/boot_loader.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||||
|
|
||||||
extern JabyEngine::NextRoutine main();
|
extern JabyEngine::NextRoutine main();
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||||
#include <PSX/System/syscalls.h>
|
#include <PSX/System/syscalls.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace CD {
|
namespace CD {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -35,6 +37,11 @@ namespace JabyEngine {
|
||||||
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
|
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
|
||||||
.verifier_function = interrupt_verifier
|
.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 <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