Upload Direct16 pic
This commit is contained in:
parent
6ea257f650
commit
7c682bdd30
|
@ -13,19 +13,19 @@ struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
|
|||
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 {
|
||||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX);
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX) << 1);
|
||||
}
|
||||
|
||||
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 {
|
||||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX);
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX) << 4);
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutY() const {
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace FileProcessor {
|
|||
};
|
||||
|
||||
struct Configuration;
|
||||
typedef bool (*ProcessRoutine)(Configuration&, Reserved&);
|
||||
typedef bool (*ProcessRoutine)(Configuration&, Reserved&, bool);
|
||||
|
||||
struct Configuration {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
|
@ -18,7 +18,7 @@ namespace FileProcessor {
|
|||
size_t data_size = 0ull;
|
||||
|
||||
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};
|
||||
}
|
||||
};
|
||||
|
@ -28,15 +28,15 @@ namespace FileProcessor {
|
|||
Reserved reserved;
|
||||
|
||||
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)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
public:
|
||||
bool process(size_t size) {
|
||||
bool process(size_t size, bool is_last) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ namespace GPU {
|
|||
DMA::end();
|
||||
//DMA End
|
||||
|
||||
Display::enable();
|
||||
|
||||
//For now
|
||||
auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(0, 0, 0, 0));
|
||||
while(state.process((sizeof(SplashScreen)/sizeof(uint32_t))));
|
||||
auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(93, 0, 0, 0));
|
||||
while(state.process((sizeof(SplashScreen)/sizeof(uint32_t)), true));
|
||||
|
||||
Display::enable();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
|
|
@ -17,9 +17,9 @@ namespace FileProcessor {
|
|||
}
|
||||
|
||||
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);
|
||||
return process_routine(config, state);
|
||||
return process_routine(config, state, is_last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "../../../include/GPU/GPU.h"
|
||||
#include "SimpleHelper.hpp"
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace FileProcessor {
|
||||
|
@ -29,7 +30,8 @@ namespace FileProcessor {
|
|||
|
||||
struct SimpleTIMState {
|
||||
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) {
|
||||
}
|
||||
|
@ -41,15 +43,43 @@ namespace FileProcessor {
|
|||
GPU::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src));
|
||||
}
|
||||
|
||||
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 void set_gpu_receive_data(const uint32_t* src, SimpleTIMState& state) {
|
||||
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) {
|
||||
return false;
|
||||
static bool parse_data(State::Configuration& config, SimpleTIMState& state, bool is_last) {
|
||||
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)) {
|
||||
Helper::simple_read(state.size_info, config);
|
||||
|
||||
|
@ -63,11 +93,11 @@ namespace FileProcessor {
|
|||
//We have direct data
|
||||
else {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue