diff --git a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp index 1847fa6b..c9a68f82 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp @@ -8,11 +8,29 @@ namespace GTETest { using namespace JabyEngine; using namespace GTETest; - static auto jaby_star_base = Make::SPRT( - // TODO: improve magic numbers - Make::AreaI16(GPU::Display::Width - 64, GPU::Display::Height - 64, 64, 64), - Make::OffsetPageWithClut(JabySTARTim.get_page_offset_clut4(), Make::PageClut(JabySTARTim.get_clut_position())) - ); + namespace Jaby { + static constexpr auto Position = Make::PositionI16(GPU::Display::Width - 64, GPU::Display::Height - 64); + + static constexpr GPU::POLY_FT4::Linked make_star_eye(GPU::PositionI16 pos) { + return Make::POLY_FT4( + Make::AreaI16(pos, GPU::SizeI16(8, 8)), + JabySTARTim.get_page_offset_clut4().add(0, 64), + Make::TPage(JabySTARTim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4), + Make::PageClut(JabySTARTim.get_clut_position()), + GPU::Color24::Grey() + ).linked(); + } + + static auto star_base = Make::SPRT( + // TODO: improve magic numbers + Make::AreaI16(Position, Make::SizeI16(64, 64)), + Make::OffsetPageWithClut(JabySTARTim.get_page_offset_clut4(), Make::PageClut(JabySTARTim.get_clut_position())) + ).linked(); + + static GPU::POLY_FT4::Linked star_eyes[2] = { + make_star_eye(Position.add(12, 31)), + make_star_eye(Position.add(33, 33))}; + } static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4( Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size), @@ -25,6 +43,7 @@ namespace GTETest { static auto gbl_rotation = 0.0_deg; static void setup() { + Jaby::star_base.concat(Jaby::star_eyes[0].concat(Jaby::star_eyes[1])); doener_fish.area.position = GPU::PositionI16::create(100, 100); Shared::back_menu.reset(); @@ -47,8 +66,9 @@ namespace GTETest { static void render() { doener_fish.render(); - GPU::render(jaby_star_base); + GPU::render(Jaby::star_base); Shared::back_menu.render(); + GPU::wait_for_render(); //< Because we are single buffer } void main() { diff --git a/include/PSX/GPU/gpu.hpp b/include/PSX/GPU/gpu.hpp index 0afa19e0..8c899074 100644 --- a/include/PSX/GPU/gpu.hpp +++ b/include/PSX/GPU/gpu.hpp @@ -71,6 +71,10 @@ namespace JabyEngine { internal::render(reinterpret_cast(&primitives), (sizeof(T)/sizeof(uint32_t))*N); } + static void wait_for_render() { + while(!GPU_IO::GPUSTAT.read().is_set(GPU_IO::GPUSTAT::GP0ReadyForCMD)); + } + uint8_t swap_buffers_vsync(uint8_t syncs, bool clear_screen = true); } } \ No newline at end of file diff --git a/src/Library/internal-include/GPU/gpu_internal.hpp b/src/Library/internal-include/GPU/gpu_internal.hpp index 88eb27b7..dfdbcfcd 100644 --- a/src/Library/internal-include/GPU/gpu_internal.hpp +++ b/src/Library/internal-include/GPU/gpu_internal.hpp @@ -28,7 +28,7 @@ namespace JabyEngine { void wait_vsync(uint8_t syncs); static void wait_ready_for_CMD() { - while(!GPU_IO::GPUSTAT.read().is_set(GPU_IO::GPUSTAT::GP0ReadyForCMD)); + GPU::wait_for_render(); } static void set_draw_area(const PositionU16& pos) {