Improvements to parse Texture data
This commit is contained in:
27
src/Library/src/File/Processor/SimpleHelper.hpp
Normal file
27
src/Library/src/File/Processor/SimpleHelper.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__
|
||||
#define __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__
|
||||
#define private public
|
||||
#include <PSX/File/Processor/File_Processor.hpp>
|
||||
|
||||
namespace FileProcessor {
|
||||
namespace Helper {
|
||||
template<typename T>
|
||||
static void simple_read(T& dst, State::Configuration& config) {
|
||||
static constexpr size_t UINT32_SIZE = (sizeof(T)/sizeof(uint32_t));
|
||||
|
||||
dst = *reinterpret_cast<const T*>(config.data_adr);
|
||||
config.data_adr += UINT32_SIZE;
|
||||
config.data_size -= UINT32_SIZE;
|
||||
|
||||
static_assert((UINT32_SIZE*sizeof(uint32_t)) == sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool exchange_and_execute_process_function(bool (*process_routine)(State::Configuration&, T&), State::Configuration& config, T& state) {
|
||||
config.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);
|
||||
return process_routine(config, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !__JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__
|
@@ -1,18 +0,0 @@
|
||||
#ifndef __JABYENGINE_INTERNAL_SIMPLE_READ_HPP__
|
||||
#define __JABYENGINE_INTERNAL_SIMPLE_READ_HPP__
|
||||
#include <PSX/File/Processor/File_Processor.hpp>
|
||||
|
||||
namespace FileProcessor {
|
||||
template<typename T>
|
||||
static size_t simple_read(T& dst, State::Configuration& config) {
|
||||
static constexpr size_t UINT32_SIZE = (sizeof(T)/sizeof(uint32_t));
|
||||
|
||||
dst = *reinterpret_cast<const T*>(config.data_adr);
|
||||
config.data_adr += UINT32_SIZE;
|
||||
|
||||
return UINT32_SIZE;
|
||||
static_assert((UINT32_SIZE*sizeof(uint32_t)) == sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !__JABYENGINE_INTERNAL_SIMPLE_READ_HPP__
|
@@ -1,6 +1,5 @@
|
||||
#define private public
|
||||
#include "../../../include/GPU/GPU.h"
|
||||
#include "SimpleRead.hpp"
|
||||
#include "SimpleHelper.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace FileProcessor {
|
||||
@@ -35,7 +34,6 @@ namespace FileProcessor {
|
||||
constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info) {
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(SimpleTIMState) <= sizeof(State::Reserved));
|
||||
|
||||
static void set_gpu_receive(const uint32_t* src, uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
GPU::DMA::Receive::prepare();
|
||||
@@ -43,24 +41,33 @@ namespace FileProcessor {
|
||||
GPU::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src));
|
||||
}
|
||||
|
||||
static bool parse_header(State::Configuration& config, SimpleTIMState& state, size_t size) {
|
||||
if(size >= sizeof(SimpleTIMSize)) {
|
||||
size -= simple_read(state.size_info, config);
|
||||
static void set_gpu_receive_data(const uint32_t* src, const SimpleTIMState& state) {
|
||||
set_gpu_receive(src, state.dst_info.getTextureX(), state.dst_info.getTextureY(), state.size_info.getTextureWidth(), state.size_info.getTextureWidth());
|
||||
}
|
||||
|
||||
static bool parse_data(State::Configuration& config, SimpleTIMState& state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parse_header(State::Configuration& config, SimpleTIMState& state) {
|
||||
if(config.data_size >= sizeof(SimpleTIMSize)) {
|
||||
Helper::simple_read(state.size_info, config);
|
||||
|
||||
//Check if we have a clut to care about
|
||||
if(state.size_info.getClutWidth() > 0) {
|
||||
//CLUTs are 16bit full color anyway
|
||||
printf("We found a CLUT!\n");
|
||||
printf("We found a CLUT which is not yet implemented!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//We have direct data
|
||||
else {
|
||||
printf("We found direct data!\n");
|
||||
set_gpu_receive_data(config.data_adr, state);
|
||||
return Helper::exchange_and_execute_process_function(parse_data, config, state);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
static_assert(sizeof(SimpleTIMSize) == sizeof(uint32_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
||||
|
Reference in New Issue
Block a user