More TODO improvements

This commit is contained in:
Jaby
2024-12-29 23:16:35 +01:00
parent 85ae5629cd
commit dc3e5095e4
4 changed files with 36 additions and 34 deletions

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));
}
}
}