diff --git a/examples/PoolBox/application/include/old/font_writer.hpp b/examples/PoolBox/application/include/old/font_writer.hpp deleted file mode 100644 index 79829223..00000000 --- a/examples/PoolBox/application/include/old/font_writer.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include - -void font_writer_setup(); -void font_writer_update(); -void font_writer_render(); \ No newline at end of file diff --git a/examples/PoolBox/application/old/FontWriter/font_writer.cpp b/examples/PoolBox/application/old/FontWriter/font_writer.cpp deleted file mode 100644 index f7e5cf34..00000000 --- a/examples/PoolBox/application/old/FontWriter/font_writer.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "../assets.hpp" -#include "font_writer.hpp" -#include -#include - -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 { - 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; - } -} diff --git a/examples/PoolBox/application/old/FontWriter/font_writer.hpp b/examples/PoolBox/application/old/FontWriter/font_writer.hpp deleted file mode 100644 index ef2d1e15..00000000 --- a/examples/PoolBox/application/old/FontWriter/font_writer.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "../assets.hpp" -#include -#include - -#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); - }; -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/Overlay/Overlay.hpp b/examples/PoolBox/application/old/Overlay/Overlay.hpp deleted file mode 100644 index 5f78e8f6..00000000 --- a/examples/PoolBox/application/old/Overlay/Overlay.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include - -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); - } -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/Overlay/TimerTests/timer_tests.cpp b/examples/PoolBox/application/old/Overlay/TimerTests/timer_tests.cpp deleted file mode 100644 index 72510819..00000000 --- a/examples/PoolBox/application/old/Overlay/TimerTests/timer_tests.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "../Overlay.hpp" -#include - -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; - } - } - } -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/assets.hpp b/examples/PoolBox/application/old/assets.hpp deleted file mode 100644 index b950d069..00000000 --- a/examples/PoolBox/application/old/assets.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include - -namespace Assets { - using namespace JabyEngine; - - static constexpr auto FontTIM = SimpleTIM(960, 0, 960, 511); - void load_for_main(); -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/font_writer.cpp b/examples/PoolBox/application/old/font_writer.cpp deleted file mode 100644 index de8507a8..00000000 --- a/examples/PoolBox/application/old/font_writer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "../include/font_writer.hpp" -#include -#include -#include -#include -#include -#include - -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 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(); - 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(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(); -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/main.cpp b/examples/PoolBox/application/old/main.cpp deleted file mode 100644 index 9bfbac9d..00000000 --- a/examples/PoolBox/application/old/main.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include - -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); - } -} \ No newline at end of file diff --git a/examples/PoolBox/application/old/main_assets.cpp b/examples/PoolBox/application/old/main_assets.cpp deleted file mode 100644 index 405f4564..00000000 --- a/examples/PoolBox/application/old/main_assets.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "assets.hpp" -#include "Objects/paco.hpp" -#include -#include - -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; - } - } - } -} \ No newline at end of file