From 6a1c5e704aac5913c664f8ecdc53a27cb65d9a05 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sat, 5 Oct 2024 16:25:08 +0200 Subject: [PATCH] Improve load screen a lot --- .../PoolBox/application/include/asset_mgr.hpp | 8 ++- .../PoolBox/application/src/application.cpp | 51 +++++++++++-------- .../PoolBox/application/src/asset_mgr.cpp | 10 ++-- examples/PoolBox/assets/JabyTails.png | 3 ++ examples/PoolBox/assets/Makefile | 3 ++ examples/PoolBox/iso/Config.xml | 1 + 6 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 examples/PoolBox/assets/JabyTails.png diff --git a/examples/PoolBox/application/include/asset_mgr.hpp b/examples/PoolBox/application/include/asset_mgr.hpp index c1128b13..ff6c4f55 100644 --- a/examples/PoolBox/application/include/asset_mgr.hpp +++ b/examples/PoolBox/application/include/asset_mgr.hpp @@ -12,9 +12,15 @@ namespace Assets { static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510); static constexpr auto DoenerFishInfo = ImageInfo{ - .tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510), + .tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510), .size = GPU::SizeI16::create(128, 64) }; + + namespace JabyLoader { + static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510); + static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44); + static constexpr auto FontFrame = GPU::AreaI16::create(0, 45, 186, 32); + }; void load(); } diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index bfe86b07..2221a76c 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -236,36 +236,43 @@ namespace NormalScene { } namespace LoadingScene { + static SimpleTimer jaby_timer; + static uint8_t jaby_frame_offset; + static void update() { - static const char Title[] = "Loading..."; - static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.get_font_size().width; - - auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, (GPU::Display::Height-16)/2)); - FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Blue(0xD0)); + jaby_timer.reset(); + jaby_frame_offset = 0; } - static void render() { - FontWriter::new_font_writer.render(); - } + static void vsync_render() { + static constexpr auto StartPosition = Make::PositionI16(24, 64); + const auto load_font = Make::SPRT( + Make::AreaI16(StartPosition.move(Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0), Assets::Main::JabyLoader::FontFrame.size), + Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4().move(Assets::Main::JabyLoader::FontFrame.position.x, Assets::Main::JabyLoader::FontFrame.position.y), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())), + GPU::Color24::Grey() + ); + auto jaby_sprt = Make::SPRT( + Make::AreaI16(StartPosition, Assets::Main::JabyLoader::JabyFrame.size), + Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4(), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())), + GPU::Color24::Grey() + ); - // TODO: No good name - static void test() { - const auto triangle1 = Make::POLY_F3({ - Make::Vertex(0, 0), - Make::Vertex(128, 128), - Make::Vertex(0, 128)}, - GPU::Color24::Blue()); + if(jaby_timer.is_expired_for(500_ms)) { + jaby_frame_offset = jaby_frame_offset ? 0 : 32; + jaby_timer.reset(); + } + jaby_sprt.tex_offset.add(jaby_frame_offset, 0); - GPU::swap_buffers(false); - GPU::render(triangle1); + GPU::swap_buffers(); + GPU::render(jaby_sprt); + GPU::render(load_font); + jaby_sprt.position.move(Assets::Main::JabyLoader::FontFrame.size.width + Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0); + GPU::render(jaby_sprt); } static void run() { - if(Shared::load_test || old_state_changer != state_changer) { - update(); - render(); - - GPU::set_vsync_callback(test); + if(Shared::load_test || old_state_changer != state_changer) { + GPU::set_vsync_callback(vsync_render); cd_player.push(); state_changer.asset_load(); diff --git a/examples/PoolBox/application/src/asset_mgr.cpp b/examples/PoolBox/application/src/asset_mgr.cpp index ae0da29b..87a789e2 100644 --- a/examples/PoolBox/application/src/asset_mgr.cpp +++ b/examples/PoolBox/application/src/asset_mgr.cpp @@ -17,6 +17,7 @@ namespace Assets { __jabyengine_start_lba_request __jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.IMG"), __jabyengine_request_lba_for(DFISH, "ASSETS/MAIN/DFISH.IMG"), + __jabyengine_request_lba_for(JABY_LOAD, "ASSETS/MAIN/LOAD.IMG"), __jabyengine_request_lba_for(APPLE_SFX, "SFX/APPLE.VAG"), __jabyengine_request_lba_for(BLUBB_SFX, "SFX/BLUBB.VAG"), __jabyengine_request_lba_for(MIX_XA, "XAAUDIO/MIX.XA"), @@ -63,10 +64,11 @@ namespace Assets { using SPU::operator""_vol; static const CDFile Files[] = { - CDFileBuilder::simple_tim(LBA::PACO, PacoTIM), - CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim), - CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)), - CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)), + CDFileBuilder::simple_tim(LBA::PACO, PacoTIM), + CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim), + CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction), + CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)), + CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)), CustomCDFileBuilder::jingle(32), }; diff --git a/examples/PoolBox/assets/JabyTails.png b/examples/PoolBox/assets/JabyTails.png new file mode 100644 index 00000000..1199a1fb --- /dev/null +++ b/examples/PoolBox/assets/JabyTails.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50c3fd85a0327a6cff4a75d47349c1e329a129498c7fee46d57a8c1aabfe6b1d +size 1676 diff --git a/examples/PoolBox/assets/Makefile b/examples/PoolBox/assets/Makefile index 3456f708..08b582e3 100644 --- a/examples/PoolBox/assets/Makefile +++ b/examples/PoolBox/assets/Makefile @@ -34,6 +34,9 @@ doener_fish_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) INPUT += $(OUTPUT_DIR)/JabyStar.img JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) +INPUT += $(OUTPUT_DIR)/JabyTails.img +JabyTails_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) + $(OUTPUT_DIR)/fox.xa: audio/temp/fox.wav @mkdir -p $(OUTPUT_DIR) jaby_engine_fconv $< -o $@ xa diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 8ef1e4d2..e6abd5fd 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -28,6 +28,7 @@ ../assets/bin/Paco.img ../assets/bin/doener_fish.img + ../assets/bin/JabyTails.img