Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
4 changed files with 36 additions and 34 deletions
Showing only changes of commit dc3e5095e4 - Show all commits

View File

@ -28,10 +28,23 @@ namespace JabyEngine {
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
}
template<typename T>
T simple_read_r() {
static constexpr size_t T_SIZE = sizeof(T);
T value = *reinterpret_cast<const T*>(this->data_adr);
Configuration::processed(T_SIZE);
return value;
}
constexpr void processed(size_t bytes) {
this->data_adr += bytes;
this->data_bytes -= bytes;
}
constexpr void skip(size_t bytes) {
Configuration::processed(bytes);
}
};
Configuration config;

View File

@ -6,14 +6,6 @@
namespace JabyEngine {
namespace FileProcessor {
namespace Helper {
template<typename T>
static void simple_read(T& dst, State::Configuration& config) {
static constexpr size_t T_SIZE = sizeof(T);
dst = *reinterpret_cast<const T*>(config.data_adr);
config.processed(T_SIZE);
}
template<typename T>
static Progress exchange_and_execute_process_function(State::GenericProcessRoutine<T> process_routine, State::Configuration& config, T& state) {
config.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);

View File

@ -37,20 +37,20 @@ namespace JabyEngine {
}
};
struct SimpleTIMState : public TIMFileProcessor::GenericTIM {
// TODO: Create function???
SimpleTIMState(const SimpleTIM& dst_info) {
this->tex_area = AreaU16::create(dst_info.get_texture_position(), SizeU16::create(0, 0));
this->clut_area = AreaU16::create(dst_info.get_clut_position(), SizeU16::create(0, 0));
this->words_left = 0;
struct SimpleTIMState : public TIMFileProcessor::GenericTIM {
static SimpleTIMState create(const SimpleTIM& dst_info) {
SimpleTIMState state;
state.tex_area = AreaU16::create(dst_info.get_texture_position(), SizeU16::create(0, 0));
state.clut_area = AreaU16::create(dst_info.get_clut_position(), SizeU16::create(0, 0));
state.words_left = 0;
return state;
}
virtual Progress parse_header(State::Configuration& config) override {
if(config.data_bytes >= sizeof(SimpleTIMSize)) {
// TODO: Return value???
SimpleTIMSize size_info;
Helper::simple_read(size_info, config);
const auto size_info = config.simple_read_r<SimpleTIMSize>();
this->clut_area.size = size_info.get_clut_size();
this->tex_area.size = size_info.get_texture_size();
return Progress::Done;
@ -67,7 +67,7 @@ namespace JabyEngine {
State create(const uint32_t* data_adr, const SimpleTIM& file) {
using Callback = Progress(*)(State::Configuration& config, SimpleTIMState& simple_tim);
return State::from(SimpleTIMState(file), data_adr, reinterpret_cast<Callback>(TIMFileProcessor::parse_header));
return State::from(SimpleTIMState::create(file), data_adr, reinterpret_cast<Callback>(TIMFileProcessor::parse_header));
}
}
}

View File

@ -14,24 +14,23 @@ namespace JabyEngine {
uint16_t h;
};
struct TIMState : public TIMFileProcessor::GenericTIM {
// TODO: Create function???
TIMState() {
struct TIMState : public TIMFileProcessor::GenericTIM {
static TIMState create() {
TIMState state;
return state;
}
virtual Progress parse_header(State::Configuration& config) override {
static constexpr auto HEADER_SIZE = 2*sizeof(uint32_t);
if(config.data_bytes >= (HEADER_SIZE + sizeof(BlockInfo))) {
uint32_t flag;
config.processed(sizeof(uint32_t));
Helper::simple_read(flag, config);
if(flag & (0x1 << 3)) {
BlockInfo block_info;
static constexpr auto HAS_CLUT_BIT = (0x1 << 3);
Helper::simple_read(block_info, config);
config.processed(sizeof(uint32_t));
const auto flag = config.simple_read_r<uint32_t>();
if(flag & HAS_CLUT_BIT) {
const auto block_info = config.simple_read_r<BlockInfo>();
this->clut_area = AreaU16::create(block_info.x, block_info.y, block_info.w, block_info.h);
}
@ -45,9 +44,7 @@ namespace JabyEngine {
virtual Progress pre_data_parsing(State::Configuration& config) {
if(config.data_bytes >= sizeof(BlockInfo)) {
BlockInfo block_info;
Helper::simple_read(block_info, config);
const auto block_info = config.simple_read_r<BlockInfo>();
this->tex_area = AreaU16::create(block_info.x, block_info.y, block_info.w, block_info.h);
return Progress::Done;
}
@ -58,7 +55,7 @@ namespace JabyEngine {
State create(const uint32_t* data_adr, const TIM& file) {
using Callback = Progress(*)(State::Configuration& config, TIMState& simple_tim);
return State::from(TIMState(), data_adr, reinterpret_cast<Callback>(TIMFileProcessor::parse_header));
return State::from(TIMState::create(), data_adr, reinterpret_cast<Callback>(TIMFileProcessor::parse_header));
}
}
}