Include SplashImage and detect right type
This commit is contained in:
parent
1daeefc407
commit
e69974672b
|
@ -9,6 +9,10 @@ struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
|
||||||
static constexpr auto ClutX = BitRange<uint32_t>(17, 22);
|
static constexpr auto ClutX = BitRange<uint32_t>(17, 22);
|
||||||
static constexpr auto ClutY = BitRange<uint32_t>(23, 31);
|
static constexpr auto ClutY = BitRange<uint32_t>(23, 31);
|
||||||
|
|
||||||
|
constexpr SimpleTIM() {
|
||||||
|
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), TextureY.with(texY), ClutX.with(clutX), ClutY.with(clutY))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace FileProcessor {
|
||||||
class State {
|
class State {
|
||||||
private:
|
private:
|
||||||
struct Reserved {
|
struct Reserved {
|
||||||
uint32_t reserved[2];
|
uint32_t reserved[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Configuration;
|
struct Configuration;
|
||||||
|
@ -26,6 +26,12 @@ namespace FileProcessor {
|
||||||
Configuration config;
|
Configuration config;
|
||||||
Reserved reserved;
|
Reserved reserved;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static __always_inline State from(const T& reserved, const uint32_t* data_adr, bool (*process_routine)(Configuration&, T&, size_t)) {
|
||||||
|
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)};
|
||||||
|
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool process(size_t size) {
|
bool process(size_t size) {
|
||||||
return (*this->config.process_routine)(this->config, this->reserved, size);
|
return (*this->config.process_routine)(this->config, this->reserved, size);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include <PSX/File/Processor/File_Processor.hpp>
|
#include <PSX/File/Processor/File_Processor.hpp>
|
||||||
#include <PSX/GPU/GPU.h>
|
#include <PSX/GPU/GPU.h>
|
||||||
|
|
||||||
|
#include "splash_image_boot.hpp"
|
||||||
|
|
||||||
namespace GPU {
|
namespace GPU {
|
||||||
static const Color TestSequence[] = {
|
static const Color TestSequence[] = {
|
||||||
Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()),
|
Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()), Color::from(Color24::Blue()), Color::from(Color24::Red()), Color::from(Color24::Green()),
|
||||||
|
@ -36,8 +38,8 @@ namespace GPU {
|
||||||
Display::enable();
|
Display::enable();
|
||||||
|
|
||||||
//For now
|
//For now
|
||||||
auto state = FileProcessor::create(nullptr, SimpleTIM(0, 0, 0, 0));
|
auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(0, 0, 0, 0));
|
||||||
while(state.process(0ull));
|
while(state.process((sizeof(SplashScreen)/sizeof(uint32_t))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#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,28 +1,70 @@
|
||||||
#define private public
|
#define private public
|
||||||
#include <PSX/File/Processor/File_Processor.hpp>
|
#include "../../../include/GPU/GPU.h"
|
||||||
|
#include "SimpleRead.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace FileProcessor {
|
namespace FileProcessor {
|
||||||
union SimpleTIMState {
|
using GPU::PositionU16;
|
||||||
State::Reserved _reserved;
|
using GPU::SizeU16;
|
||||||
struct {
|
|
||||||
uint32_t test;
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SimpleTIMState(uint32_t test = 0) : test(test) {
|
struct SimpleTIMSize : private SimpleTIM {
|
||||||
|
constexpr SimpleTIMSize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t getTextureWidth() const {
|
||||||
|
return SimpleTIM::getTextureX();
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t getTextureHeight() const {
|
||||||
|
return SimpleTIM::getTextureY();
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t getClutWidth() const {
|
||||||
|
return SimpleTIM::getClutX();
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t getClutHeight() const {
|
||||||
|
return SimpleTIM::getClutY();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SimpleTIMState {
|
||||||
|
SimpleTIM dst_info;
|
||||||
|
SimpleTIMSize size_info;
|
||||||
|
|
||||||
|
constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SimpleTIMState) <= sizeof(State::Reserved));
|
static_assert(sizeof(SimpleTIMState) <= sizeof(State::Reserved));
|
||||||
|
|
||||||
static bool process(State::Configuration& config, SimpleTIMState& state, size_t size) {
|
static void set_gpu_receive(const uint32_t* src, uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||||
printf("Dino: %i\n", state.test);
|
GPU::DMA::Receive::prepare();
|
||||||
return false;
|
GPU::DMA::Receive::set_dst(PositionU16(x, y), SizeU16(w, h));
|
||||||
|
GPU::DMA::Receive::set_src(reinterpret_cast<const uintptr_t>(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
static bool parse_header(State::Configuration& config, SimpleTIMState& state, size_t size) {
|
||||||
SimpleTIMState test(123);
|
if(size >= sizeof(SimpleTIMSize)) {
|
||||||
|
size -= simple_read(state.size_info, config);
|
||||||
return State{.config = State::Configuration::from(process, data_adr), .reserved = test._reserved};
|
|
||||||
|
//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");
|
||||||
|
}
|
||||||
|
|
||||||
|
//We have direct data
|
||||||
|
else {
|
||||||
|
printf("We found direct data!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
static_assert(sizeof(SimpleTIMSize) == sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
||||||
|
return State::from(SimpleTIMState(file), data_adr, parse_header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue