Support custom file parsing

This commit is contained in:
2024-08-04 13:15:58 -05:00
parent 40c7dea1f0
commit 3db5a19595
12 changed files with 91 additions and 37 deletions

View File

@@ -1,11 +1,11 @@
#pragma once
#include "../../Auxiliary/types.hpp"
#include "../file_types.hpp"
#include "../cd_file_types.hpp"
namespace JabyEngine {
namespace FileProcessor {
class State {
__friends:
public:
struct Reserved {
uint32_t reserved[4];
};
@@ -18,9 +18,9 @@ namespace JabyEngine {
typedef GenericProcessRoutine<Reserved> ProcessRoutine;
struct Configuration {
ProcessRoutine process_routine = nullptr;
const uint8_t* data_adr = nullptr;
size_t data_bytes = 0ull;
ProcessRoutine process_routine = nullptr;
const uint8_t* data_adr = nullptr;
size_t data_bytes = 0ull;
template<typename T>
static __always_inline Configuration from(GenericProcessRoutine<T> process_routine, const uint8_t* data_adr) {
@@ -33,13 +33,12 @@ namespace JabyEngine {
}
};
__friends:
Configuration config;
Reserved reserved;
template<typename T>
static __always_inline State from(const T& reserved, const uint8_t* data_adr, GenericProcessRoutine<T> process_routine) {
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)};
static __always_inline State from(const T& state, const uint8_t* data_adr, GenericProcessRoutine<T> process_routine) {
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&state)};
static_assert(sizeof(T) <= sizeof(Reserved));
}
@@ -53,5 +52,7 @@ namespace JabyEngine {
// The nothing state
State create(const uint32_t* data_adr, const Nothing& nothing);
State create(const uint32_t* data_adr, const SimpleTIM& file);
State create_custom(const uint32_t* data_adr, const CDFileType_t& file_type, const CDFile::Payload& payload);
}
}