jabyengine/examples/PoolBox/application/src/main.cpp

61 lines
1.7 KiB
C++

#include "FontWriter/font_writer.hpp"
#include "assets.hpp"
#include <PSX/GPU/gpu.hpp>
#include <PSX/GPU/gpu_primitives.hpp>
#include <PSX/Timer/frame_timer.hpp>
#include <stdio.h>
using namespace JabyEngine;
static SimpleTimer<uint8_t> timer;
static auto paco_texpage = GPU::TexPage(
{Assets::PacoTIM.get_texture_x(), Assets::PacoTIM.get_texture_y()},
GPU::TexturePageColor::$4bit
).linked();
static auto paco = GPU::SPRT(
// This pic used to be 122px (file size) and every tool would except it - however the display would be corrupt. Try it!!
GPU::AreaI16({0, 100}, {120, 128}),
GPU::PagePositionClut({0, 0}, GPU::PageClut(Assets::PacoTIM.get_clut_x(), Assets::PacoTIM.get_clut_y())),
GPU::Color24::Blue()
).linked();
static const GPU::Color24 paco_color[] = {
GPU::Color24::Red(), GPU::Color24::Green(), GPU::Color24::Blue(), GPU::Color24::Yellow()
};
static uint8_t color_idx = 0;
static void setup() {
Assets::load_for_main();
FontWriter::setup();
timer.reset();
paco_texpage.concat(paco);
}
static void update() {
const auto end_pos = FontWriter::write({0, 32}, "Cody is cute\n&\na \x1b[8;0;0mBAAAAABY!!!");
FontWriter::write(end_pos, "\x1b[0;7;7mJaby was\nhere c:");
if(timer.is_expired_for(325_ms)) {
static constexpr uint8_t last_idx = (sizeof(paco_color)/sizeof(paco_color[0])) - 1;
color_idx = (color_idx == last_idx) ? 0 : color_idx + 1;
timer.reset();
}
}
static void render() {
GPU::swap_buffers_vsync(1);
paco->color = paco_color[color_idx];
GPU::render(paco_texpage);
FontWriter::render();
}
void main() {
setup();
while(true) {
update();
render();
}
}