From 991bacfa9c090e618b90d23696399cbab6c79614 Mon Sep 17 00:00:00 2001 From: Jaby Blubb Date: Tue, 3 Oct 2023 17:10:10 +0200 Subject: [PATCH] Support TILE and SPRT for make functions --- .../src/Overlay/GPUTests/gpu_tests.cpp | 26 +++--- include/PSX/GPU/gpu_primitives.hpp | 83 +++++++++++++++++++ 2 files changed, 96 insertions(+), 13 deletions(-) diff --git a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp index 1099fafe..f7603b45 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp @@ -19,12 +19,12 @@ static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Mak static constexpr auto TriangleTPage = Make::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); static constexpr auto TriangleClut = Make::PageClut(320, 511); -static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF); +static constexpr auto RectangleColor = GPU::Color24::from_rgb(0x80, 0x80, 0xFF); static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80)); static constexpr auto RectangleTPage = Make::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); static constexpr auto RectangleClut = Make::PageClut(320, 510); -static constexpr auto LineColor = GPU::Color24(0xFF, 0x0, 0x0); +static constexpr auto LineColor = GPU::Color24::from_rgb(0xFF, 0x0, 0x0); static constexpr const auto triangle1 = GPU::POLY_F3::create({ Make::Vertex(TriangleArea.position.x, TriangleArea.position.y), @@ -109,19 +109,19 @@ static constexpr const auto line4 = GPU::LINE_G::create( GPU::ColorVertex{GPU::Color24::White(), Make::Vertex(0, 0)} ); -static constexpr const auto rect1 = GPU::TILE::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green()); -static constexpr const auto rect2 = GPU::TILE_16::create(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue()); -static constexpr const auto rect3 = GPU::TILE_8::create(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow()); -static constexpr const auto rect4 = GPU::TILE_1::create(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red()); +static constexpr const auto rect1 = Make::TILE(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green()); +static constexpr const auto rect2 = Make::TILE_16(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue()); +static constexpr const auto rect3 = Make::TILE_8(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow()); +static constexpr const auto rect4 = Make::TILE_1(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red()); -static constexpr const auto texpage = GPU::TexPage::create(Make::PositionU16(320, 0), GPU::TexturePageColor::$4bit); -static constexpr const auto rect5 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PagePosition(0, 0), TriangleClut}, GPU::Color24::Green()); -static constexpr const auto rect6 = GPU::SPRT_16::create(Make::Vertex(0, GPU::Display::Height - 16), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Blue()); -static constexpr const auto rect7 = GPU::SPRT_8::create(Make::Vertex(0, GPU::Display::Height - 8), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Yellow()); -static constexpr const auto rect8 = GPU::SPRT_1::create(Make::Vertex(0, GPU::Display::Height - 1), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Red()); +static constexpr const auto texpage = Make::TexPage(Make::PositionU16(320, 0), GPU::TexturePageColor::$4bit); +static constexpr const auto rect5 = Make::SPRT(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PagePosition(0, 0), TriangleClut}, GPU::Color24::Green()); +static constexpr const auto rect6 = Make::SPRT_16(Make::Vertex(0, GPU::Display::Height - 16), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Blue()); +static constexpr const auto rect7 = Make::SPRT_8(Make::Vertex(0, GPU::Display::Height - 8), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Yellow()); +static constexpr const auto rect8 = Make::SPRT_1(Make::Vertex(0, GPU::Display::Height - 1), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Red()); -static auto rect9 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked(); -static auto rect10 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked(); +static auto rect9 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked(); +static auto rect10 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked(); static void load_assets() { static const CDFile Assets[] = { diff --git a/include/PSX/GPU/gpu_primitives.hpp b/include/PSX/GPU/gpu_primitives.hpp index 2c3cc38f..bd585985 100644 --- a/include/PSX/GPU/gpu_primitives.hpp +++ b/include/PSX/GPU/gpu_primitives.hpp @@ -68,6 +68,10 @@ namespace JabyEngine { // ################################################################### + static constexpr GPU::AreaI16 AreaI16() { + return creator_template(0, 0, 0, 0); + } + static constexpr GPU::AreaI16 AreaI16(int16_t x, int16_t y, int16_t w, int16_t h) { return creator_template(x, y, w, h); } @@ -78,6 +82,10 @@ namespace JabyEngine { // ################################################################### + static constexpr GPU::AreaU16 AreaU16() { + return creator_template(0, 0, 0, 0); + } + static constexpr GPU::AreaU16 AreaU16(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { return creator_template(x, y, w, h); } @@ -116,6 +124,16 @@ namespace JabyEngine { return creator_template(x, y, transparency, clut_color); } + // ################################################################### + + static constexpr GPU::TexPage TexPage() { + return creator_template(PositionU16(), GPU::TexturePageColor::$4bit, GPU::SemiTransparency::B_Half_add_F_Half, false); + } + + static constexpr GPU::TexPage TexPage(const GPU::PositionU16& tex_pos, GPU::TexturePageColor tex_color, GPU::SemiTransparency transparency = GPU::SemiTransparency::B_Half_add_F_Half, bool dither = false) { + return creator_template(tex_pos, tex_color, transparency, dither); + } + // ################################################################### static constexpr GPU::PagePositionClut PagePositionClut() { @@ -151,7 +169,72 @@ namespace JabyEngine { // ################################################################### // ################################################################### // ################################################################### + + static constexpr GPU::TILE_1 TILE_1() { + return creator_template(Vertex(), GPU::Color24::Black()); + } + + static constexpr GPU::TILE_1 TILE_1(const GPU::Vertex& position, const GPU::Color24& color) { + return creator_template(position, color); + } + + static constexpr GPU::TILE_8 TILE_8() { + return creator_template(Vertex(), GPU::Color24::Black()); + } + + static constexpr GPU::TILE_8 TILE_8(const GPU::Vertex& position, const GPU::Color24& color) { + return creator_template(position, color); + } + + static constexpr GPU::TILE_16 TILE_16() { + return creator_template(Vertex(), GPU::Color24::Black()); + } + + static constexpr GPU::TILE_16 TILE_16(const GPU::Vertex& position, const GPU::Color24& color) { + return creator_template(position, color); + } + + static constexpr GPU::TILE TILE() { + return creator_template(AreaI16(), GPU::Color24::Black()); + } + + static constexpr GPU::TILE TILE(const GPU::AreaI16& area, const GPU::Color24& color) { + return creator_template(area, color); + } + // ################################################################### + + static constexpr GPU::SPRT_1 SPRT_1() { + return creator_template(Vertex(), PagePositionClut(), GPU::Color24::Black()); + } + + static constexpr GPU::SPRT_1 SPRT_1(const GPU::Vertex& position, const GPU::PagePositionClut& page, const GPU::Color24& color = GPU::Color24::Grey()) { + return creator_template(position, page, color); + } + + static constexpr GPU::SPRT_8 SPRT_8() { + return creator_template(Vertex(), PagePositionClut(), GPU::Color24::Black()); + } + + static constexpr GPU::SPRT_8 SPRT_8(const GPU::Vertex& position, const GPU::PagePositionClut& page, const GPU::Color24& color = GPU::Color24::Grey()) { + return creator_template(position, page, color); + } + + static constexpr GPU::SPRT_16 SPRT_16() { + return creator_template(Vertex(), PagePositionClut(), GPU::Color24::Black()); + } + + static constexpr GPU::SPRT_16 SPRT_16(const GPU::Vertex& position, const GPU::PagePositionClut& page, const GPU::Color24& color = GPU::Color24::Grey()) { + return creator_template(position, page, color); + } + + static constexpr GPU::SPRT SPRT() { + return creator_template(AreaI16(), PagePositionClut(), GPU::Color24::Black()); + } + + static constexpr GPU::SPRT SPRT(const GPU::AreaI16& area, const GPU::PagePositionClut& page, const GPU::Color24& color = GPU::Color24::Grey()) { + return creator_template(area, page, color); + } } }