More TODO improvements
This commit is contained in:
parent
85ae5629cd
commit
dc3e5095e4
|
@ -28,10 +28,23 @@ namespace JabyEngine {
|
||||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
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) {
|
constexpr void processed(size_t bytes) {
|
||||||
this->data_adr += bytes;
|
this->data_adr += bytes;
|
||||||
this->data_bytes -= bytes;
|
this->data_bytes -= bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr void skip(size_t bytes) {
|
||||||
|
Configuration::processed(bytes);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Configuration config;
|
Configuration config;
|
||||||
|
|
|
@ -6,14 +6,6 @@
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace FileProcessor {
|
namespace FileProcessor {
|
||||||
namespace Helper {
|
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>
|
template<typename T>
|
||||||
static Progress exchange_and_execute_process_function(State::GenericProcessRoutine<T> process_routine, State::Configuration& config, T& state) {
|
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);
|
config.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);
|
||||||
|
|
|
@ -38,18 +38,18 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SimpleTIMState : public TIMFileProcessor::GenericTIM {
|
struct SimpleTIMState : public TIMFileProcessor::GenericTIM {
|
||||||
// TODO: Create function???
|
static SimpleTIMState create(const SimpleTIM& dst_info) {
|
||||||
SimpleTIMState(const SimpleTIM& dst_info) {
|
SimpleTIMState state;
|
||||||
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));
|
state.tex_area = AreaU16::create(dst_info.get_texture_position(), SizeU16::create(0, 0));
|
||||||
this->words_left = 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 {
|
virtual Progress parse_header(State::Configuration& config) override {
|
||||||
if(config.data_bytes >= sizeof(SimpleTIMSize)) {
|
if(config.data_bytes >= sizeof(SimpleTIMSize)) {
|
||||||
// TODO: Return value???
|
const auto size_info = config.simple_read_r<SimpleTIMSize>();
|
||||||
SimpleTIMSize size_info;
|
|
||||||
Helper::simple_read(size_info, config);
|
|
||||||
|
|
||||||
this->clut_area.size = size_info.get_clut_size();
|
this->clut_area.size = size_info.get_clut_size();
|
||||||
this->tex_area.size = size_info.get_texture_size();
|
this->tex_area.size = size_info.get_texture_size();
|
||||||
|
@ -67,7 +67,7 @@ namespace JabyEngine {
|
||||||
|
|
||||||
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
||||||
using Callback = Progress(*)(State::Configuration& config, SimpleTIMState& simple_tim);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,23 +15,22 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TIMState : public TIMFileProcessor::GenericTIM {
|
struct TIMState : public TIMFileProcessor::GenericTIM {
|
||||||
// TODO: Create function???
|
static TIMState create() {
|
||||||
TIMState() {
|
TIMState state;
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Progress parse_header(State::Configuration& config) override {
|
virtual Progress parse_header(State::Configuration& config) override {
|
||||||
static constexpr auto HEADER_SIZE = 2*sizeof(uint32_t);
|
static constexpr auto HEADER_SIZE = 2*sizeof(uint32_t);
|
||||||
|
|
||||||
if(config.data_bytes >= (HEADER_SIZE + sizeof(BlockInfo))) {
|
if(config.data_bytes >= (HEADER_SIZE + sizeof(BlockInfo))) {
|
||||||
uint32_t flag;
|
static constexpr auto HAS_CLUT_BIT = (0x1 << 3);
|
||||||
|
|
||||||
config.processed(sizeof(uint32_t));
|
config.processed(sizeof(uint32_t));
|
||||||
Helper::simple_read(flag, config);
|
const auto flag = config.simple_read_r<uint32_t>();
|
||||||
|
|
||||||
if(flag & (0x1 << 3)) {
|
if(flag & HAS_CLUT_BIT) {
|
||||||
BlockInfo block_info;
|
const auto block_info = config.simple_read_r<BlockInfo>();
|
||||||
|
|
||||||
Helper::simple_read(block_info, config);
|
|
||||||
this->clut_area = AreaU16::create(block_info.x, block_info.y, block_info.w, block_info.h);
|
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) {
|
virtual Progress pre_data_parsing(State::Configuration& config) {
|
||||||
if(config.data_bytes >= sizeof(BlockInfo)) {
|
if(config.data_bytes >= sizeof(BlockInfo)) {
|
||||||
BlockInfo block_info;
|
const auto block_info = config.simple_read_r<BlockInfo>();
|
||||||
|
|
||||||
Helper::simple_read(block_info, config);
|
|
||||||
this->tex_area = AreaU16::create(block_info.x, block_info.y, block_info.w, block_info.h);
|
this->tex_area = AreaU16::create(block_info.x, block_info.y, block_info.w, block_info.h);
|
||||||
return Progress::Done;
|
return Progress::Done;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +55,7 @@ namespace JabyEngine {
|
||||||
|
|
||||||
State create(const uint32_t* data_adr, const TIM& file) {
|
State create(const uint32_t* data_adr, const TIM& file) {
|
||||||
using Callback = Progress(*)(State::Configuration& config, TIMState& simple_tim);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue