Upload Direct16 pic

This commit is contained in:
Jaby 2022-10-02 13:14:30 +02:00 committed by Jaby
parent 32e136701a
commit c255c9259f
5 changed files with 53 additions and 23 deletions

View File

@ -13,19 +13,19 @@ struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
this->raw = 0; this->raw = 0;
} }
constexpr SimpleTIM(uint16_t texX, uint16_t texY, uint16_t clutX, uint16_t clutY) : ComplexBitMap(ComplexBitMap::with(TextureX.with(texX), TextureY.with(texY), ClutX.with(clutX), ClutY.with(clutY))) { constexpr SimpleTIM(uint16_t texX, uint16_t texY, uint16_t clutX, uint16_t clutY) : ComplexBitMap(ComplexBitMap::with(TextureX.with(texX >> 1), TextureY.with(texY >> 1), ClutX.with(clutX >> 4), ClutY.with(clutY))) {
} }
constexpr uint16_t getTextureX() const { constexpr uint16_t getTextureX() const {
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX); return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX) << 1);
} }
constexpr uint16_t getTextureY() const { constexpr uint16_t getTextureY() const {
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureY); return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureY) << 1);
} }
constexpr uint16_t getClutX() const { constexpr uint16_t getClutX() const {
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX); return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX) << 4);
} }
constexpr uint16_t getClutY() const { constexpr uint16_t getClutY() const {

View File

@ -10,7 +10,7 @@ namespace FileProcessor {
}; };
struct Configuration; struct Configuration;
typedef bool (*ProcessRoutine)(Configuration&, Reserved&); typedef bool (*ProcessRoutine)(Configuration&, Reserved&, bool);
struct Configuration { struct Configuration {
ProcessRoutine process_routine = nullptr; ProcessRoutine process_routine = nullptr;
@ -18,7 +18,7 @@ namespace FileProcessor {
size_t data_size = 0ull; size_t data_size = 0ull;
template<typename T> template<typename T>
static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&), const uint32_t* data_adr) { static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&, bool), const uint32_t* data_adr) {
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr}; return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
} }
}; };
@ -28,15 +28,15 @@ namespace FileProcessor {
Reserved reserved; Reserved reserved;
template<typename T> template<typename T>
static __always_inline State from(const T& reserved, const uint32_t* data_adr, bool (*process_routine)(Configuration&, T&)) { static __always_inline State from(const T& reserved, const uint32_t* data_adr, bool (*process_routine)(Configuration&, T&, bool)) {
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)}; return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)};
static_assert(sizeof(T) <= sizeof(Reserved)); static_assert(sizeof(T) <= sizeof(Reserved));
} }
public: public:
bool process(size_t size) { bool process(size_t size, bool is_last) {
this->config.data_size += size; this->config.data_size += size;
return (*this->config.process_routine)(this->config, this->reserved); return (*this->config.process_routine)(this->config, this->reserved, is_last);
} }
}; };

View File

@ -35,11 +35,11 @@ namespace GPU {
DMA::end(); DMA::end();
//DMA End //DMA End
Display::enable();
//For now //For now
auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(0, 0, 0, 0)); auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(93, 0, 0, 0));
while(state.process((sizeof(SplashScreen)/sizeof(uint32_t)))); while(state.process((sizeof(SplashScreen)/sizeof(uint32_t)), true));
Display::enable();
} }
void setup() { void setup() {

View File

@ -17,9 +17,9 @@ namespace FileProcessor {
} }
template<typename T> template<typename T>
static bool exchange_and_execute_process_function(bool (*process_routine)(State::Configuration&, T&), State::Configuration& config, T& state) { static bool exchange_and_execute_process_function(bool (*process_routine)(State::Configuration&, T&, bool), State::Configuration& config, T& state, bool is_last) {
config.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine); config.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);
return process_routine(config, state); return process_routine(config, state, is_last);
} }
} }
} }

View File

@ -1,5 +1,6 @@
#include "../../../include/GPU/GPU.h" #include "../../../include/GPU/GPU.h"
#include "SimpleHelper.hpp" #include "SimpleHelper.hpp"
#include <limits.h>
#include <stdio.h> #include <stdio.h>
namespace FileProcessor { namespace FileProcessor {
@ -30,6 +31,7 @@ namespace FileProcessor {
struct SimpleTIMState { struct SimpleTIMState {
SimpleTIM dst_info; SimpleTIM dst_info;
SimpleTIMSize size_info; SimpleTIMSize size_info;
size_t words_left; //32bit values
constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info) { constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info) {
} }
@ -41,15 +43,43 @@ namespace FileProcessor {
GPU::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src)); GPU::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src));
} }
static void set_gpu_receive_data(const uint32_t* src, const SimpleTIMState& state) { static void set_gpu_receive_data(const uint32_t* src, SimpleTIMState& state) {
set_gpu_receive(src, state.dst_info.getTextureX(), state.dst_info.getTextureY(), state.size_info.getTextureWidth(), state.size_info.getTextureWidth()); const auto width = state.size_info.getTextureWidth();
const auto height = state.size_info.getTextureHeight();
state.words_left = (width*height)/2;
set_gpu_receive(src, state.dst_info.getTextureX(), state.dst_info.getTextureY(), width, height);
} }
static bool parse_data(State::Configuration& config, SimpleTIMState& state) { static bool parse_data(State::Configuration& config, SimpleTIMState& state, bool is_last) {
return false; auto block_count = (state.words_left >> 4);
state.words_left &= 0b1111;
while(block_count > 0) {
const auto block_send = (block_count > UI16_MAX) ? UI16_MAX : block_count;
// Send data!
GPU::DMA::wait();
GPU::DMA::Receive::start(block_send);
block_count -= block_send;
}
if(is_last) {
// Send words
if(state.words_left > 0) {
GPU::DMA::wait();
GPU::DMA::Receive::start(1, state.words_left);
}
GPU::DMA::wait();
GPU::DMA::end();
return false;
}
return true;
} }
static bool parse_header(State::Configuration& config, SimpleTIMState& state) { static bool parse_header(State::Configuration& config, SimpleTIMState& state, bool is_last) {
if(config.data_size >= sizeof(SimpleTIMSize)) { if(config.data_size >= sizeof(SimpleTIMSize)) {
Helper::simple_read(state.size_info, config); Helper::simple_read(state.size_info, config);
@ -63,11 +93,11 @@ namespace FileProcessor {
//We have direct data //We have direct data
else { else {
set_gpu_receive_data(config.data_adr, state); set_gpu_receive_data(config.data_adr, state);
return Helper::exchange_and_execute_process_function(parse_data, config, state); return Helper::exchange_and_execute_process_function(parse_data, config, state, is_last);
} }
} }
return true; return !is_last;
} }
State create(const uint32_t* data_adr, const SimpleTIM& file) { State create(const uint32_t* data_adr, const SimpleTIM& file) {