Remove all old code
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
#include "../assets.hpp"
|
||||
#include "font_writer.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/gpu_primitives.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
FontWriter::Pool::Buffer FontWriter::Pool :: buffer[2];
|
||||
GPU::Link* FontWriter::Pool :: last_link = nullptr;
|
||||
GPU::SPRT_16::Linked* FontWriter::Pool :: text_ptr = nullptr;
|
||||
|
||||
void FontWriter::Pool :: reset_links() {
|
||||
Pool::last_link = &Pool::buffer[GPU::Display::current_id].page;
|
||||
Pool::text_ptr = Pool::buffer[GPU::Display::current_id].text_buffer;
|
||||
}
|
||||
|
||||
void FontWriter::Pool::Buffer :: setup() {
|
||||
this->page = GPU::TexPage::create(GPU::PositionU16::create(Assets::FontTIM.get_texture_x(), Assets::FontTIM.get_texture_y()), GPU::TexturePageColor::$4bit).linked();
|
||||
for(auto& single_char : this->text_buffer) {
|
||||
single_char.set_link_identitiy();
|
||||
single_char->set_identitiy();
|
||||
single_char->clut = GPU::PageClut::create(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y());
|
||||
}
|
||||
}
|
||||
|
||||
void FontWriter::Pool :: setup() {
|
||||
Pool::reset_links();
|
||||
for(auto& buffer : Pool::buffer) {
|
||||
buffer.setup();
|
||||
}
|
||||
}
|
||||
|
||||
void FontWriter::Pool :: render() {
|
||||
const auto render_id = GPU::Display::current_id ^ 1;
|
||||
|
||||
Pool::last_link->terminate();
|
||||
GPU::render(Pool::buffer[render_id].page);
|
||||
reset_links();
|
||||
}
|
||||
|
||||
Position FontWriter :: write(Position pos, const char* text) {
|
||||
static const auto parse_esc = [](const char* text, const GPU::Color24& color) -> pair<const char*, GPU::Color24> {
|
||||
static const auto char_to_color = [](char number) constexpr -> uint8_t {
|
||||
return (1 << (number - '0')) - 1;
|
||||
};
|
||||
if(text[0] != '[' || text[2] != ';' || text[4] != ';' || text[6] != 'm') {
|
||||
return {text, color};
|
||||
}
|
||||
|
||||
return {text + 7, GPU::Color24::from_rgb(char_to_color(text[1]), char_to_color(text[3]), char_to_color(text[5]))};
|
||||
};
|
||||
const auto* cur_text_end = &Pool::buffer[GPU::Display::current_id].text_buffer[Pool::Buffer::BufferSize];
|
||||
const auto org_x = pos.x;
|
||||
auto font_color = GPU::Color24::Grey();
|
||||
|
||||
while(Pool::text_ptr < cur_text_end) {
|
||||
const char cur_char = *text;
|
||||
text++;
|
||||
|
||||
(*Pool::text_ptr)->position = pos;
|
||||
switch(cur_char) {
|
||||
case '\0':
|
||||
goto end;
|
||||
|
||||
case '\n':
|
||||
pos.y += 16;
|
||||
pos.x = org_x;
|
||||
continue;
|
||||
|
||||
case '\x1b':
|
||||
tie(text, font_color) = parse_esc(text, font_color);
|
||||
continue;
|
||||
|
||||
case 'i':
|
||||
case '!':
|
||||
pos.x += 12;
|
||||
break;
|
||||
|
||||
default:
|
||||
pos.x += 16;
|
||||
}
|
||||
|
||||
const uint8_t char_id = cur_char - '!';
|
||||
(*Pool::text_ptr)->tex_offset = GPU::PageOffset::create(((char_id & 0xF) << 4), ((char_id >> 4) << 4));
|
||||
(*Pool::text_ptr)->color = font_color;
|
||||
|
||||
Pool::last_link = &Pool::last_link->concat(*Pool::text_ptr);
|
||||
Pool::text_ptr++;
|
||||
}
|
||||
|
||||
end:
|
||||
return pos;
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
#include "../assets.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma GCC warning "Remove this namespace and integrate to \"Objects\" folder?"
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
using Position = JabyEngine::GPU::PositionI16;
|
||||
|
||||
class FontWriter {
|
||||
private:
|
||||
class Pool {
|
||||
private:
|
||||
struct Buffer {
|
||||
static constexpr auto BufferSize = 1024;
|
||||
|
||||
GPU::TexPage::Linked page;
|
||||
GPU::SPRT_16::Linked text_buffer[BufferSize];
|
||||
|
||||
void setup();
|
||||
};
|
||||
|
||||
static Buffer buffer[2];
|
||||
static GPU::Link* last_link;
|
||||
static GPU::SPRT_16::Linked* text_ptr;
|
||||
|
||||
static void reset_links();
|
||||
|
||||
public:
|
||||
static void setup();
|
||||
static void render();
|
||||
|
||||
friend class FontWriter;
|
||||
};
|
||||
|
||||
public:
|
||||
static void setup() {
|
||||
Pool::setup();
|
||||
}
|
||||
|
||||
static void render() {
|
||||
Pool::render();
|
||||
}
|
||||
|
||||
Position write(Position pos, const char* text);
|
||||
};
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
#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->timer.reset();
|
||||
// This should only work on elements that are linkable - but it didn't
|
||||
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);
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace object {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Paco {
|
||||
public:
|
||||
static constexpr auto TIM = SimpleTIM(896, 0, 960, 510);
|
||||
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(GPU::TexPage::create(GPU::PositionU16::create(
|
||||
TIM.get_texture_x(), TIM.get_texture_y()),
|
||||
GPU::TexturePageColor::$4bit).linked()),
|
||||
sprite(GPU::SPRT::create(
|
||||
GPU::AreaI16::create(GPU::PositionI16::create(0, 100), GPU::SizeI16::create(120, 128)),
|
||||
GPU::OffsetPageWithClut(GPU::PageOffset::create(0, 0), GPU::PageClut::create(TIM.get_clut_x(), TIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked()),
|
||||
timer(),
|
||||
color_idx(0) {}
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
void render();
|
||||
};
|
||||
}
|
@@ -1,192 +0,0 @@
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(FONT, "ASSETS/FONT.BIN"),
|
||||
__jabyengine_request_lba_for(ICON, "ASSETS/ICON.BIN"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
|
||||
using namespace JabyEngine;
|
||||
|
||||
// Some default values for the objects
|
||||
static constexpr auto TriangleColor = GPU::Color24::from_rgb(0x0, 0xFF, 0xFF);
|
||||
static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Make::SizeI16(64, 64));
|
||||
static constexpr auto TriangleTPage = Make::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto TriangleClut = Make::PageClut(320, 511);
|
||||
|
||||
static constexpr auto RectangleColor = GPU::Color24::from_rgb(0x80, 0x80, 0xFF);
|
||||
static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80));
|
||||
static constexpr auto RectangleTPage = Make::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto RectangleClut = Make::PageClut(320, 510);
|
||||
|
||||
static constexpr auto LineColor = GPU::Color24::from_rgb(0xFF, 0x0, 0x0);
|
||||
|
||||
static constexpr const auto triangle1 = Make::POLY_F3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height),
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.size.height)
|
||||
}, TriangleColor
|
||||
);
|
||||
static constexpr const auto triangle2 = Make::POLY_FT3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height)
|
||||
},{
|
||||
// Texture
|
||||
Make::PageOffset(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.size.height)
|
||||
}, TriangleTPage, TriangleClut, GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto triangle3 = Make::POLY_G3({
|
||||
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
|
||||
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
|
||||
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
|
||||
);
|
||||
static constexpr const auto triangle4 = Make::POLY_GT3({
|
||||
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.tex_offset0, GPU::Color24::Red()},
|
||||
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.tex_offset1, GPU::Color24::Blue()},
|
||||
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.tex_offset2, GPU::Color24::Green()}},
|
||||
TriangleTPage,
|
||||
TriangleClut
|
||||
);
|
||||
|
||||
static constexpr const auto rectangle1 = Make::POLY_F4(RectangleArea, RectangleColor);
|
||||
static constexpr const auto rectangle2 = Make::POLY_FT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut,
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto rectangle3 = Make::POLY_G4(
|
||||
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()});
|
||||
static constexpr const auto rectangle4 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
);
|
||||
static constexpr const auto rectangle5 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
).set_semi_transparent(true);
|
||||
|
||||
static constexpr const auto line1 = Make::LINE_F(LineColor,
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(GPU::Display::Width, GPU::Display::Height)
|
||||
);
|
||||
static constexpr const auto line2 = Make::LINE_F(LineColor.invert(),
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(16, 0),
|
||||
Make::Vertex(16, 16),
|
||||
Make::Vertex(0, 0)
|
||||
);
|
||||
static constexpr const auto line3 = Make::LINE_G(
|
||||
GPU::ColorVertex{LineColor, Make::Vertex(GPU::Display::Width, 0)},
|
||||
GPU::ColorVertex{LineColor.invert(), Make::Vertex(0, GPU::Display::Height)}
|
||||
);
|
||||
static constexpr const auto line4 = Make::LINE_G(
|
||||
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
|
||||
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(16, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::White(), Make::Vertex(0, 0)}
|
||||
);
|
||||
|
||||
static constexpr const auto rect1 = Make::TILE(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green());
|
||||
static constexpr const auto rect2 = Make::TILE_16(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue());
|
||||
static constexpr const auto rect3 = Make::TILE_8(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect4 = Make::TILE_1(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red());
|
||||
|
||||
static constexpr const auto texpage = Make::TexPage(Make::PositionU16(320, 0), GPU::TexturePageColor::$4bit);
|
||||
static constexpr const auto rect5 = Make::SPRT(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PageOffset(0, 0), TriangleClut}, GPU::Color24::Green());
|
||||
static constexpr const auto rect6 = Make::SPRT_16(Make::Vertex(0, GPU::Display::Height - 16), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Blue());
|
||||
static constexpr const auto rect7 = Make::SPRT_8(Make::Vertex(0, GPU::Display::Height - 8), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect8 = Make::SPRT_1(Make::Vertex(0, GPU::Display::Height - 1), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Red());
|
||||
|
||||
static auto rect9 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
static auto rect10 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
|
||||
static void load_assets() {
|
||||
static const CDFile Assets[] = {
|
||||
CDFileBuilder::simple_tim(LBA::FONT, SimpleTIM(320, 0, 320, 511)),
|
||||
CDFileBuilder::simple_tim(LBA::ICON, SimpleTIM(320, 256, 320, 510)),
|
||||
};
|
||||
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, Assets, 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;
|
||||
}
|
||||
}
|
||||
printf("Done loading assets!\n");
|
||||
}
|
||||
|
||||
void test_gpu() {
|
||||
load_assets();
|
||||
|
||||
rect9.concat(rect10);
|
||||
|
||||
while(true) {
|
||||
GPU::render(triangle1);
|
||||
GPU::render(triangle2);
|
||||
GPU::render(triangle3);
|
||||
GPU::render(triangle4);
|
||||
|
||||
GPU::render(rectangle1);
|
||||
GPU::render(rectangle2);
|
||||
GPU::render(rectangle3);
|
||||
GPU::render(rectangle4);
|
||||
GPU::render(rectangle5);
|
||||
|
||||
GPU::render(rect1);
|
||||
GPU::render(rect2);
|
||||
GPU::render(rect3);
|
||||
GPU::render(rect4);
|
||||
GPU::render(texpage);
|
||||
GPU::render(rect5);
|
||||
GPU::render(rect6);
|
||||
GPU::render(rect7);
|
||||
GPU::render(rect8);
|
||||
|
||||
GPU::render(line1);
|
||||
GPU::render(line2);
|
||||
GPU::render(line3);
|
||||
GPU::render(line4);
|
||||
|
||||
GPU::render(rect9);
|
||||
|
||||
GPU::swap_buffers_vsync(2);
|
||||
}
|
||||
}
|
||||
__declare_lba_header(LBA);
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Overlay {
|
||||
namespace TimerTest {
|
||||
using TimeStamp = JabyEngine::HighResTime::TimeStamp;
|
||||
|
||||
void mesaure_busy_loop();
|
||||
|
||||
TimeStamp start_measuring();
|
||||
void end_measuring(const TimeStamp& start, size_t data_samples);
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
#include "../Overlay.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void busy_loop(int count);
|
||||
|
||||
namespace Overlay {
|
||||
namespace TimerTest {
|
||||
static size_t avg = 0;
|
||||
static size_t cur_rounds = 0;
|
||||
|
||||
void mesaure_busy_loop() {
|
||||
static constexpr auto Counts = 500;
|
||||
|
||||
JabyEngine::HighResTime::enable();
|
||||
const auto start = JabyEngine::HighResTime::get_time_stamp();
|
||||
busy_loop(Counts);
|
||||
const auto end = JabyEngine::HighResTime::get_time_stamp();
|
||||
JabyEngine::HighResTime::disable();
|
||||
|
||||
printf("Busy loop of %i took %ims %ins\n", Counts, start.milliseconds_to(end), start.microseconds_to(end));
|
||||
}
|
||||
|
||||
TimeStamp start_measuring() {
|
||||
return JabyEngine::HighResTime::get_time_stamp();
|
||||
}
|
||||
|
||||
void end_measuring(const TimeStamp& start, size_t data_samples) {
|
||||
const auto end = JabyEngine::HighResTime::get_time_stamp();
|
||||
|
||||
avg += start.microseconds_to(end);
|
||||
cur_rounds++;
|
||||
if(cur_rounds == data_samples) {
|
||||
printf("AVG Time: %ius\n", avg/cur_rounds);
|
||||
|
||||
avg = 0;
|
||||
cur_rounds = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
|
||||
namespace Assets {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto FontTIM = SimpleTIM(960, 0, 960, 511);
|
||||
void load_for_main();
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
#include "../include/font_writer.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/GPU/gpu_auto_load_font.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
#include <FontWriter/fonts.hpp>
|
||||
|
||||
using JabyEngine::Make::PositionI8;
|
||||
|
||||
static constexpr auto LibraryFontTIM = JabyEngine::SimpleTIM(320, 0, 320, JabyEngine::DefaultFont::Info.texture_size.height);
|
||||
|
||||
static JabyEngine::FontPrimitive font_buffer[2*256];
|
||||
static JabyEngine::Wiggle wiggle = {PositionI8(0, 0), PositionI8(1, -2), PositionI8(0, -4), PositionI8(-1, -2), PositionI8(0, 0), PositionI8(1, 2), PositionI8(0, 4), PositionI8(-1, 2)};
|
||||
static JabyEngine::FontWriter new_font_writer = JabyEngine::FontWriter::empty();
|
||||
static JabyEngine::FontWriter bios_font_writer = JabyEngine::FontWriter::empty();
|
||||
static JabyEngine::SimpleTimer<uint8_t> timer;
|
||||
static uint8_t wiggle_count = 0;
|
||||
|
||||
void font_writer_setup() {
|
||||
JabyEngine::DefaultFont::load(&__heap_start, LibraryFontTIM);
|
||||
JabyEngine::GlobalFontPrimitivePool::setup(font_buffer);
|
||||
|
||||
new_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info);
|
||||
bios_font_writer.setup(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info);
|
||||
timer.reset();
|
||||
}
|
||||
|
||||
void font_writer_update() {
|
||||
static const char*const Text[2] = {"Planschi", "Becken"};
|
||||
|
||||
auto& controller = JabyEngine::Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
auto cur_rumble = controller.get_large_rumble();
|
||||
|
||||
if(controller.button.is_down(JabyEngine::Periphery::GenericController::Button::R1) && cur_rumble < 0xFF) {
|
||||
cur_rumble += 1;
|
||||
}
|
||||
|
||||
if(controller.button.is_down(JabyEngine::Periphery::GenericController::Button::L1) && cur_rumble > 0x0) {
|
||||
cur_rumble -= 1;
|
||||
}
|
||||
controller.set_analog_rumble(cur_rumble, controller.button.is_down(JabyEngine::Periphery::GenericController::Button::Circle));
|
||||
|
||||
auto state = JabyEngine::State::create(JabyEngine::Make::PositionI16(8, 8), wiggle_count);
|
||||
new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl\n", JabyEngine::GPU::Color24::Blue(), &wiggle);
|
||||
new_font_writer.write(state, "%i (0x%p)\nWiggle (%s)\n", JabyEngine::GPU::Color24::Green(), &wiggle, wiggle_count, 0xAABBCCDD, Text[wiggle_count&0x1]);
|
||||
bios_font_writer.write(state, "!!PLANSCHBECKEN\n(%i)!!", controller.button.is_down(JabyEngine::Periphery::GenericController::Button::Square) ? JabyEngine::GPU::Color24::Blue() : JabyEngine::GPU::Color24::White(), static_cast<int>(cur_rumble));
|
||||
|
||||
if(timer.is_expired_for(50_ms)) {
|
||||
timer.reset();
|
||||
wiggle_count++;
|
||||
}
|
||||
}
|
||||
|
||||
void font_writer_render() {
|
||||
new_font_writer.render();
|
||||
bios_font_writer.render();
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
#include "../include/font_writer.hpp"
|
||||
#include "FontWriter/font_writer.hpp"
|
||||
#include "Objects/paco.hpp"
|
||||
#include "Overlay/Overlay.hpp"
|
||||
#include "assets.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace JabyEngine;
|
||||
using NewFontWriter = ::JabyEngine::FontWriter;
|
||||
|
||||
static object::Paco paco;
|
||||
|
||||
static void setup() {
|
||||
font_writer_setup();
|
||||
Assets::load_for_main();
|
||||
FontWriter::FontWriter::setup();
|
||||
|
||||
paco.setup();
|
||||
}
|
||||
|
||||
static void update() {
|
||||
Periphery::query_controller();
|
||||
FontWriter::FontWriter cursor;
|
||||
|
||||
const auto end_pos = cursor.write(FontWriter::Position::create(0, 32), "Cody is cute\n&\na \x1b[8;0;0mBAAAAABY!!!");
|
||||
cursor.write(end_pos, "\x1b[0;7;7mJaby was\nhere c:");
|
||||
|
||||
font_writer_update();
|
||||
paco.update();
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::swap_buffers_vsync(1);
|
||||
FontWriter::FontWriter::render();
|
||||
paco.render();
|
||||
font_writer_render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
Overlay::TimerTest::mesaure_busy_loop();
|
||||
JabyEngine::HighResTime::enable();
|
||||
|
||||
while(true) {
|
||||
const auto start = Overlay::TimerTest::start_measuring();
|
||||
update();
|
||||
render();
|
||||
Overlay::TimerTest::end_measuring(start, GPU::Display::frames_per_sec);
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
#include "assets.hpp"
|
||||
#include "Objects/paco.hpp"
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Assets {
|
||||
using namespace object;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(FONT, "ASSETS/MAIN/FONT.BIN"),
|
||||
__jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.BIN"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
void load_for_main() {
|
||||
static const CDFile Assets[] = {
|
||||
CDFileBuilder::simple_tim(LBA::FONT, FontTIM),
|
||||
CDFileBuilder::simple_tim(LBA::PACO, Paco::TIM),
|
||||
};
|
||||
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, Assets, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user