Fix image conversion and CLUT placement
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#include "../../../internal-include/GPU/gpu_internal.hpp"
|
||||
#include "simplehelper.hpp"
|
||||
#include <PSX/GPU/gpu_types.hpp>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
using GPU::AreaU16;
|
||||
using GPU::PositionU16;
|
||||
using GPU::SizeU16;
|
||||
|
||||
@@ -12,20 +14,28 @@ namespace JabyEngine {
|
||||
constexpr SimpleTIMSize() {
|
||||
}
|
||||
|
||||
constexpr uint16_t getTextureWidth() const {
|
||||
return SimpleTIM::getTextureX();
|
||||
constexpr uint16_t get_texture_width() const {
|
||||
return SimpleTIM::get_texture_x();
|
||||
}
|
||||
|
||||
constexpr uint16_t getTextureHeight() const {
|
||||
return SimpleTIM::getTextureY();
|
||||
constexpr uint16_t get_texture_height() const {
|
||||
return SimpleTIM::get_texture_y();
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutWidth() const {
|
||||
return SimpleTIM::getClutX();
|
||||
constexpr SizeU16 get_texture_size() const {
|
||||
return {SimpleTIMSize::get_texture_width(), SimpleTIMSize::get_texture_height()};
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutHeight() const {
|
||||
return SimpleTIM::getClutY();
|
||||
constexpr uint16_t get_clut_width() const {
|
||||
return SimpleTIM::get_clut_x();
|
||||
}
|
||||
|
||||
constexpr uint16_t get_clut_height() const {
|
||||
return SimpleTIM::get_clut_y();
|
||||
}
|
||||
|
||||
constexpr SizeU16 get_clut_size() const {
|
||||
return {SimpleTIMSize::get_clut_width(), SimpleTIMSize::get_clut_height()};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,9 +54,12 @@ namespace JabyEngine {
|
||||
GPU::internal::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src));
|
||||
}
|
||||
|
||||
static void set_gpu_receive_data(const uint32_t* src, SimpleTIMState& state, uint16_t width, uint16_t height) {
|
||||
state.words_left = (width*height)/2;
|
||||
set_gpu_receive(src, state.dst_info.getTextureX(), state.dst_info.getTextureY(), width, height);
|
||||
static size_t set_gpu_receive_data(const uint32_t* src, const AreaU16& dst) {
|
||||
const auto width = dst.size.width;
|
||||
const auto height = dst.size.height;
|
||||
|
||||
set_gpu_receive(src, dst.position.x, dst.position.y, width, height);
|
||||
return (width*height)/2;
|
||||
}
|
||||
|
||||
static Progress parse_data(State::Configuration& config, SimpleTIMState& state) {
|
||||
@@ -91,7 +104,7 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
static Progress switch_state_parse_data(State::Configuration& config, SimpleTIMState& state) {
|
||||
set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), state, state.size_info.getTextureWidth(), state.size_info.getTextureHeight());
|
||||
state.words_left = set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), {state.dst_info.get_texture_position(), state.size_info.get_texture_size()});
|
||||
return Helper::exchange_and_execute_process_function(parse_data, config, state);
|
||||
}
|
||||
|
||||
@@ -110,9 +123,9 @@ namespace JabyEngine {
|
||||
Helper::simple_read(state.size_info, config);
|
||||
|
||||
//Check if we have a clut to care about
|
||||
if(state.size_info.getClutWidth() > 0) {
|
||||
if(state.size_info.get_clut_width() > 0) {
|
||||
//CLUTs are 16bit full color anyway
|
||||
set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), state, state.size_info.getClutWidth(), state.size_info.getClutHeight());
|
||||
state.words_left = set_gpu_receive_data(reinterpret_cast<const uint32_t*>(config.data_adr), {state.dst_info.get_clut_position(), state.size_info.get_clut_size()});
|
||||
return Helper::exchange_and_execute_process_function(parse_clut, config, state);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user