Upload Direct16 pic

This commit is contained in:
Jaby
2022-10-02 13:14:30 +02:00
parent 6ea257f650
commit 7c682bdd30
5 changed files with 53 additions and 23 deletions

View File

@@ -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() {

View File

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

View File

@@ -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) {