diff --git a/examples/PoolBox/application/Overlays.json b/examples/PoolBox/application/Overlays.json index d00b4f08..5ce89e47 100644 --- a/examples/PoolBox/application/Overlays.json +++ b/examples/PoolBox/application/Overlays.json @@ -6,6 +6,9 @@ "gpu_tests": { "pattern": "bin/*/src/Overlay/GPUTest/*.o" }, + "font_cycler": { + "pattern": "bin/*/src/Overlay/FontCycler/*.o" + }, "screen_center": { "pattern": "bin/*/src/Overlay/ScreenCenter/*.o" } diff --git a/examples/PoolBox/application/include/asset_mgr.hpp b/examples/PoolBox/application/include/asset_mgr.hpp index 527453b8..89d9dd07 100644 --- a/examples/PoolBox/application/include/asset_mgr.hpp +++ b/examples/PoolBox/application/include/asset_mgr.hpp @@ -13,6 +13,7 @@ namespace Assets { namespace Overlay { void load_controller_test(); void load_gpu_test(); + void load_font_cycler(); void load_screen_center(); } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp b/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp new file mode 100644 index 00000000..91a9c28b --- /dev/null +++ b/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp @@ -0,0 +1,79 @@ +#include "../../../include/shared.hpp" +#include +#include +#include + +namespace FontCycler { + using namespace JabyEngine; + + static const char*const ASCII = "!\"#$%&'()*+,-./0\n123456789:;<=>?@\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ[\\]^_`\nabcdefghijklmnop\nqrstuvwxyz{|}~\n"; + + static JabyEngine::FontWriter*const FontWriters[] = { + &FontWriter::bios_font_writer, + &FontWriter::new_font_writer, + }; + static constexpr auto MaxFontSelector = (sizeof(FontWriters)/sizeof(FontWriters[0])) - 1; + static uint8_t font_selector = 0; + + static void increment_font_selector() { + if(font_selector == MaxFontSelector) { + font_selector = 0; + } + + else { + font_selector++; + } + } + + static void decrement_font_selector() { + if(font_selector == 0) { + font_selector = MaxFontSelector; + } + + else { + font_selector--; + } + } + + static void setup() { + Shared::back_menu.reset(); + font_selector = 0; + } + + static bool update_or_exit() { + Periphery::query_controller(); + if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) { + return true; + } + + const auto& controller = Periphery::get_primary_controller_as(); + if(controller.button.went_up(Periphery::GenericController::Button::L1)) { + decrement_font_selector(); + } + if(controller.button.went_up(Periphery::GenericController::Button::R1)) { + increment_font_selector(); + } + + auto cursor = FontWriter::update(Make::PositionI16(8, 8)); + FontWriters[font_selector]->write(cursor, ASCII); + FontWriters[font_selector]->write(cursor, "\nPress L1 or R1 to cycle\nthrough fonts"); + return false; + } + + static void render() { + FontWriters[font_selector]->render(); + Shared::back_menu.render(); + } + + void main() { + setup(); + + while(true) { + if(update_or_exit()) { + break; + } + GPU::swap_buffers_vsync(1); + render(); + } + } +} \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/Overlays.hpp b/examples/PoolBox/application/src/Overlay/Overlays.hpp index a46a5de3..537b9c82 100644 --- a/examples/PoolBox/application/src/Overlay/Overlays.hpp +++ b/examples/PoolBox/application/src/Overlay/Overlays.hpp @@ -15,6 +15,10 @@ namespace GPUTest { void main(); } +namespace FontCycler { + void main(); +} + namespace ScreenCenter { void main(); } \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp index e430bf4e..3d2e7044 100644 --- a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp @@ -6,38 +6,8 @@ namespace ScreenCenter { using namespace JabyEngine; - static const char*const ASCII = "!\"#$%&'()*+,-./0\n123456789:;<=>?@\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ[\\]^_`\nabcdefghijklmnop\nqrstuvwxyz{|}~\n"; - - static JabyEngine::FontWriter*const FontWriters[] = { - &FontWriter::bios_font_writer, - &FontWriter::new_font_writer, - }; - static constexpr auto MaxFontSelector = (sizeof(FontWriters)/sizeof(FontWriters[0])) - 1; - static uint8_t font_selector = 0; - - static void increment_font_selector() { - if(font_selector == MaxFontSelector) { - font_selector = 0; - } - - else { - font_selector++; - } - } - - static void decrement_font_selector() { - if(font_selector == 0) { - font_selector = MaxFontSelector; - } - - else { - font_selector--; - } - } - static void setup() { Shared::back_menu.reset(); - font_selector = 0; } static bool update_or_exit() { @@ -46,26 +16,17 @@ namespace ScreenCenter { return true; } - const auto& controller = Periphery::get_primary_controller_as(); - if(controller.button.went_up(Periphery::GenericController::Button::L1)) { - decrement_font_selector(); - } - if(controller.button.went_up(Periphery::GenericController::Button::R1)) { - increment_font_selector(); - } - auto cursor = FontWriter::update(Make::PositionI16(8, 8)); - FontWriters[font_selector]->write(cursor, ASCII); - FontWriters[font_selector]->write(cursor, "\nPress L1 or R1 to cycle\nthrough fonts"); + FontWriter::bios_font_writer.write(cursor, "NOTHING HERE TO SEE", GPU::Color24::Red()); return false; } static void render() { - FontWriters[font_selector]->render(); Shared::back_menu.render(); } void main() { + printf("BlubbBlubbBlubbBlubb\n"); setup(); while(true) { diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index df6232b9..6b0a74c0 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -33,8 +33,8 @@ struct StateChange { static const Menu::SimpleMenu::Entry MenuEntries[] = { {"Controller Test"}, {"GPU Test"}, + {"Font Cycler"}, {"Screen Center"}, - {"Menu 4"}, {"Menu 5"} }; @@ -72,8 +72,14 @@ static void setup() { break; case 2: + state_changer.asset_load = Assets::Overlay::load_font_cycler; + state_changer.main = FontCycler::main; + break; + + case 3: state_changer.asset_load = Assets::Overlay::load_screen_center; state_changer.main = ScreenCenter::main; + break; } },MenuEntries); } diff --git a/examples/PoolBox/application/src/asset_mgr.cpp b/examples/PoolBox/application/src/asset_mgr.cpp index 914ce7d2..c599278d 100644 --- a/examples/PoolBox/application/src/asset_mgr.cpp +++ b/examples/PoolBox/application/src/asset_mgr.cpp @@ -12,10 +12,11 @@ extern "C" uint32_t __screen_center_start; namespace Assets { enum LBA { __jabyengine_start_lba_request - __jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.BIN"), - __jabyengine_request_lba_for(GPU_TEST_OVL, "GTO.BIN"), - __jabyengine_request_lba_for(CONT_TEST_OVL, "CTO.BIN"), - __jabyengine_request_lba_for(SC_OVL, "SCO.BIN"), + __jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.BIN"), + __jabyengine_request_lba_for(GPU_TEST_OVL, "GTO.BIN"), + __jabyengine_request_lba_for(CONT_TEST_OVL, "CTO.BIN"), + __jabyengine_request_lba_for(FONT_CYC_OVL, "FCO.BIN"), + __jabyengine_request_lba_for(SCREEN_CENT_OVL, "SCO.BIN"), __jabyengine_end_lba_request }; __declare_lba_header(LBA); @@ -78,9 +79,17 @@ namespace Assets { ::Assets::load(GPUTest::lba, GPUTest::Assets); } + void load_font_cycler() { + const CDFile Files[] = { + CDFileBuilder::overlay(LBA::FONT_CYC_OVL, &__screen_center_start) + }; + + ::Assets::load(lba, Files); + } + void load_screen_center() { const CDFile Files[] = { - CDFileBuilder::overlay(LBA::SC_OVL, &__screen_center_start) + CDFileBuilder::overlay(LBA::SCREEN_CENT_OVL, &__screen_center_start) }; ::Assets::load(lba, Files); diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index e5561dcd..f8333c41 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -8,6 +8,7 @@
../application/bin/PSX-release/PoolBox.psexe
../application/bin/PSX-release/Overlay.controller_tests ../application/bin/PSX-release/Overlay.gpu_tests + ../application/bin/PSX-release/Overlay.font_cycler ../application/bin/PSX-release/Overlay.screen_center