Re-create PoolBox Paco
This commit is contained in:
32
examples/PoolBox/application/src/application.cpp
Normal file
32
examples/PoolBox/application/src/application.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "include/paco.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace JabyEngine;
|
||||
|
||||
// Do we want this namespace?
|
||||
// Do we want Paco to be HERE?!
|
||||
static object::Paco paco;
|
||||
|
||||
static void setup() {
|
||||
Assets::Main::load();
|
||||
paco.setup();
|
||||
}
|
||||
|
||||
static void update() {
|
||||
paco.update();
|
||||
}
|
||||
|
||||
static void render() {
|
||||
paco.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
47
examples/PoolBox/application/src/asset_mgr.cpp
Normal file
47
examples/PoolBox/application/src/asset_mgr.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Assets {
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.BIN"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
static void load(const CDFile* assets, size_t size) {
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, CDFileProcessor::JobArray{assets, size}, buffer_cfg);
|
||||
while(true) {
|
||||
switch(file_processor.process()) {
|
||||
case Progress::InProgress:
|
||||
break;
|
||||
|
||||
case Progress::Done:
|
||||
if(!file_processor.next(lba, buffer_cfg)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case Progress::Error:
|
||||
printf("Error detected! Aborting load\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Main {
|
||||
static const CDFile Files[] = {
|
||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM)
|
||||
};
|
||||
|
||||
void load() {
|
||||
::Assets::load(Files, sizeof(Files)/sizeof(Files[0]));
|
||||
}
|
||||
}
|
||||
}
|
34
examples/PoolBox/application/src/include/paco.hpp
Normal file
34
examples/PoolBox/application/src/include/paco.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "../../include/asset_mgr.hpp"
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace object {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Paco {
|
||||
private:
|
||||
static const GPU::Color24 Colors[];
|
||||
|
||||
GPU::TexPage::Linked tex_page;
|
||||
GPU::SPRT::Linked sprite;
|
||||
SimpleTimer<uint8_t> timer;
|
||||
uint8_t color_idx;
|
||||
|
||||
public:
|
||||
constexpr Paco() :
|
||||
tex_page(Make::TexPage(Make::PositionU16(
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TexturePageColor::$4bit).linked()),
|
||||
sprite(Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(0, 100), Make::SizeI16(120, 128)),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked()),
|
||||
timer(),
|
||||
color_idx(0) {}
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
void render();
|
||||
};
|
||||
}
|
33
examples/PoolBox/application/src/paco.cpp
Normal file
33
examples/PoolBox/application/src/paco.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "include/paco.hpp"
|
||||
|
||||
namespace object {
|
||||
const GPU::Color24 Paco :: Colors[] = {GPU::Color24::Red(), GPU::Color24::Green(), GPU::Color24::Blue(), GPU::Color24::Yellow()};
|
||||
|
||||
void Paco :: setup() {
|
||||
/*this->tex_page = Make::TexPage(Make::PositionU16(
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TexturePageColor::$4bit).linked();
|
||||
|
||||
this->sprite = Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(0, 100), Make::SizeI16(120, 128)),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked();*/
|
||||
|
||||
this->timer.reset();
|
||||
this->tex_page.concat(this->sprite);
|
||||
}
|
||||
|
||||
void Paco :: update() {
|
||||
if(this->timer.is_expired_for(325_ms)) {
|
||||
static constexpr uint8_t LastIDX = (sizeof(Paco::Colors)/sizeof(Paco::Colors[0])) - 1;
|
||||
|
||||
this->color_idx = (this->color_idx == LastIDX) ? 0 : this->color_idx + 1;
|
||||
this->timer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Paco :: render() {
|
||||
this->sprite->color = Paco::Colors[this->color_idx];
|
||||
GPU::render(this->tex_page);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user