From 5e050f3ffdffeff289c348e9f00939a1dd4cbb0e Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 3 Jan 2024 20:38:43 -0600 Subject: [PATCH] Add ControllerTest Overlay and support not loading new state if previous loaded --- examples/PoolBox/application/Overlays.json | 4 +- .../PoolBox/application/include/asset_mgr.hpp | 1 + .../ControllerTest/controller_test.cpp | 7 ++++ .../src/Overlay/GPUTest/gpu_test.cpp | 3 +- .../application/src/Overlay/Overlays.hpp | 5 +++ .../PoolBox/application/src/application.cpp | 39 ++++++++++++------- .../PoolBox/application/src/asset_mgr.cpp | 18 +++++++-- examples/PoolBox/iso/Config.xml | 1 + 8 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp diff --git a/examples/PoolBox/application/Overlays.json b/examples/PoolBox/application/Overlays.json index 00a14b6c..f18211a9 100644 --- a/examples/PoolBox/application/Overlays.json +++ b/examples/PoolBox/application/Overlays.json @@ -1,7 +1,7 @@ { "slot_0": { - "!timer_tests": { - "pattern": "bin/*/src/Overlay/TimerTests/*.o" + "controller_tests": { + "pattern": "bin/*/src/Overlay/ControllerTest/*.o" }, "gpu_tests": { "pattern": "bin/*/src/Overlay/GPUTest/*.o" diff --git a/examples/PoolBox/application/include/asset_mgr.hpp b/examples/PoolBox/application/include/asset_mgr.hpp index fab276b2..640d6e47 100644 --- a/examples/PoolBox/application/include/asset_mgr.hpp +++ b/examples/PoolBox/application/include/asset_mgr.hpp @@ -11,6 +11,7 @@ namespace Assets { } namespace Overlay { + void load_controller_test(); void load_gpu_test(); } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp new file mode 100644 index 00000000..6e63e838 --- /dev/null +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp @@ -0,0 +1,7 @@ +#include + +namespace ControllerTest { + void main() { + printf("CONT: BlubbBlubbBlubb!!\n"); + } +} \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp index 821a3e06..d4b979e2 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp @@ -2,7 +2,6 @@ namespace GPUTest { void main() { - printf("BlubbBlubbBlubb!!\n"); - while(true); + printf("GPU: BlubbBlubbBlubb!!\n"); } } \ 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 e61b02db..18e8e475 100644 --- a/examples/PoolBox/application/src/Overlay/Overlays.hpp +++ b/examples/PoolBox/application/src/Overlay/Overlays.hpp @@ -1,4 +1,9 @@ #pragma once + +namespace ControllerTest { + void main(); +} + namespace GPUTest { void main(); } \ No newline at end of file diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index cbedb764..cff18f75 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -26,11 +26,13 @@ struct StateChange { bool contains_state() const { return this->main; } + + auto operator<=>(const StateChange&) const = default; }; static const Menu::SimpleMenu::Entry MenuEntries[] = { - {"Menu 1"}, - {"Menu 2"}, + {"Controller Test"}, + {"GPU Test"}, {"Menu 3"}, {"Menu 4"}, {"Menu 5"} @@ -41,14 +43,24 @@ static const Menu::SimpleMenu::Entry MenuEntries[] = { static object::Paco paco; static Menu::SimpleMenu menu; static StateChange state_changer; +static StateChange old_state_changer; static void setup() { Assets::Main::load(); FontWriter::setup(); paco.setup(); menu.setup([](uint32_t selection) { - state_changer.asset_load = Assets::Overlay::load_gpu_test; - state_changer.main = GPUTest::main; + switch(selection) { + case 0: + state_changer.asset_load = Assets::Overlay::load_controller_test; + state_changer.main = ControllerTest::main; + break; + + case 1: + state_changer.asset_load = Assets::Overlay::load_gpu_test; + state_changer.main = GPUTest::main; + break; + } },MenuEntries); } @@ -92,18 +104,19 @@ namespace LoadingScene { } static void run() { - update(); - GPU::swap_buffers_vsync(1); - render(); - GPU::swap_buffers_vsync(1); + if(old_state_changer != state_changer) { + printf("Loading new state...\n"); + + update(); + GPU::swap_buffers_vsync(1); + render(); + GPU::swap_buffers_vsync(1); + + old_state_changer = state_changer; + } - printf("End of execution!\n"); state_changer.asset_load(); state_changer.main(); - printf("Done in state!\n"); - - while(true); - state_changer.clear(); } } diff --git a/examples/PoolBox/application/src/asset_mgr.cpp b/examples/PoolBox/application/src/asset_mgr.cpp index ce78bc3f..fee40896 100644 --- a/examples/PoolBox/application/src/asset_mgr.cpp +++ b/examples/PoolBox/application/src/asset_mgr.cpp @@ -4,13 +4,15 @@ #include #include +extern "C" uint32_t __controller_tests_start; extern "C" uint32_t __gpu_tests_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(PACO, "ASSETS/MAIN/PACO.BIN"), + __jabyengine_request_lba_for(GPU_TEST_OVL, "GTO.BIN"), + __jabyengine_request_lba_for(CONT_TEST_OVL, "CTO.BIN"), __jabyengine_end_lba_request }; __declare_lba_header(LBA); @@ -54,12 +56,20 @@ namespace Assets { } namespace Overlay { - static const CDFile Files[] = { + static const CDFile GPUFiles[] = { CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start) }; + static const CDFile ControllerFiles[] = { + CDFileBuilder::overlay(LBA::CONT_TEST_OVL, &__controller_tests_start) + }; + + void load_controller_test() { + ::Assets::load(ControllerFiles); + } + void load_gpu_test() { - ::Assets::load(Files); + ::Assets::load(GPUFiles); // Load Overlay assets?! } } diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 24ad2615..ad5e536c 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -6,6 +6,7 @@ System.cnf
../application/bin/PSX-release/PoolBox.psexe
+ ../application/bin/PSX-release/Overlay.controller_tests ../application/bin/PSX-release/Overlay.gpu_tests