From 2c4583c8d7efc062d437f9d1e2a4f54e2fb9bfc7 Mon Sep 17 00:00:00 2001 From: Jaby Blubb Date: Tue, 3 Oct 2023 09:52:04 +0200 Subject: [PATCH] Remove primitive support types constructor --- .../src/FontWriter/font_writer.cpp | 2 +- .../PoolBox/application/src/Objects/paco.hpp | 2 +- .../src/Overlay/GPUTests/gpu_tests.cpp | 8 ++++---- .../GPU/Primitives/primitive_line_types.hpp | 2 +- .../GPU/Primitives/primitive_poly_types.hpp | 2 +- .../Primitives/primitive_rectangle_types.hpp | 2 +- .../Primitives/primitive_support_types.hpp | 20 ++++++++++--------- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/examples/PoolBox/application/src/FontWriter/font_writer.cpp b/examples/PoolBox/application/src/FontWriter/font_writer.cpp index 6a8f47ac..af8a8db9 100644 --- a/examples/PoolBox/application/src/FontWriter/font_writer.cpp +++ b/examples/PoolBox/application/src/FontWriter/font_writer.cpp @@ -24,7 +24,7 @@ namespace FontWriter { for(auto& single_char : this->text_buffer) { single_char.set_link_identitiy(); single_char->set_identitiy(); - single_char->clut = GPU::PageClut(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y()); + single_char->clut = GPU::PageClut::create(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y()); } } diff --git a/examples/PoolBox/application/src/Objects/paco.hpp b/examples/PoolBox/application/src/Objects/paco.hpp index f46a7977..03ff3442 100644 --- a/examples/PoolBox/application/src/Objects/paco.hpp +++ b/examples/PoolBox/application/src/Objects/paco.hpp @@ -26,7 +26,7 @@ namespace object { sprite(GPU::SPRT::create( #pragma GCC warning "This pic used to be 122px (file size) and every tool would except it - however the display would be corrupt" GPU::AreaI16({0, 100}, {120, 128}), - GPU::PagePositionClut({0, 0}, GPU::PageClut(TIM.get_clut_x(), TIM.get_clut_y())), + GPU::PagePositionClut({0, 0}, GPU::PageClut::create(TIM.get_clut_x(), TIM.get_clut_y())), GPU::Color24::Blue()).linked()), timer(), color_idx(0) {} diff --git a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp index 7b3307de..f154e79b 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp @@ -16,13 +16,13 @@ using namespace JabyEngine; // Some default values for the objects static constexpr auto TriangleColor = GPU::Color24(0x0, 0xFF, 0xFF); static constexpr auto TriangleArea = GPU::AreaI16({0, 0}, {64, 64}); -static constexpr auto TriangleTPage = GPU::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); -static constexpr auto TriangleClut = GPU::PageClut(320, 511); +static constexpr auto TriangleTPage = GPU::TPage::create(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); +static constexpr auto TriangleClut = GPU::PageClut::create(320, 511); static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF); static constexpr auto RectangleArea = GPU::AreaI16({0, TriangleArea.size.height}, {80, 80}); -static constexpr auto RectangleTPage = GPU::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); -static constexpr auto RectangleClut = GPU::PageClut(320, 510); +static constexpr auto RectangleTPage = GPU::TPage::create(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); +static constexpr auto RectangleClut = GPU::PageClut::create(320, 510); static constexpr auto LineColor = GPU::Color24(0xFF, 0x0, 0x0); diff --git a/include/PSX/GPU/Primitives/primitive_line_types.hpp b/include/PSX/GPU/Primitives/primitive_line_types.hpp index c950b155..2abacef5 100644 --- a/include/PSX/GPU/Primitives/primitive_line_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_line_types.hpp @@ -15,7 +15,7 @@ namespace JabyEngine { static constexpr auto SingleLine = !PolyLine; static constexpr LineCode create() { - return LineCode(CmdValue); + return CodeBase::create(CmdValue); } }; diff --git a/include/PSX/GPU/Primitives/primitive_poly_types.hpp b/include/PSX/GPU/Primitives/primitive_poly_types.hpp index 892f9b27..3ffdfba6 100644 --- a/include/PSX/GPU/Primitives/primitive_poly_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_poly_types.hpp @@ -15,7 +15,7 @@ namespace JabyEngine { static constexpr auto TriVertics = !QuadVertics; static constexpr PolyCode create() { - return PolyCode(CmdValue); + return CodeBase::create(CmdValue); } }; diff --git a/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp b/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp index d4c0a7b0..42bb9e54 100644 --- a/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp @@ -23,7 +23,7 @@ namespace JabyEngine { static constexpr auto Size = BitRange::from_to(27 - BitCorrection, 28 - BitCorrection); static constexpr RectCode create() { - return RectCode(CmdValue); + return CodeBase::create(CmdValue); } }; diff --git a/include/PSX/GPU/Primitives/primitive_support_types.hpp b/include/PSX/GPU/Primitives/primitive_support_types.hpp index 85a05381..96e139e9 100644 --- a/include/PSX/GPU/Primitives/primitive_support_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_support_types.hpp @@ -23,10 +23,12 @@ namespace JabyEngine { static constexpr auto NoBlendTexture = Bit(24 - BitCorrection); static constexpr auto BlendTexture = !NoBlendTexture; - constexpr CodeBase() = default; - constexpr CodeBase(uint8_t value) : value(bit::value::set_normalized(0u, CmdID.with(value))) { + static constexpr T create(uint8_t value) { + return T{bit::value::set_normalized(0u, CmdID.with(value))}; } - constexpr CodeBase(const T& code) : value(code.value) { + + static constexpr T create(const T& code) { + return CodeBase::create(code.value); } constexpr T& set(Bit bit) { @@ -67,10 +69,10 @@ namespace JabyEngine { } struct PageClut { - uint16_t value = 0; + uint16_t value; - constexpr PageClut() = default; - constexpr PageClut(uint16_t x, uint16_t y) : value((y << 6) | ((x >> 4) & 0x3f)) { + static constexpr PageClut create(uint16_t x, uint16_t y) { + return PageClut{static_cast((y << 6) | ((x >> 4) & 0x3f))}; } }; @@ -80,10 +82,10 @@ namespace JabyEngine { static constexpr auto SemiTransparency = BitRange::from_to(5, 6); static constexpr auto TextureClut = BitRange::from_to(7, 8); - uint16_t value = 0; + uint16_t value; - constexpr TPage() = default; - constexpr TPage(uint16_t x, uint16_t y, ::JabyEngine::GPU::SemiTransparency transparency, TexturePageColor clut_color) : value(TexturePageX.as_value(x >> 6) | TexturePageY.as_value(y >> 8) | SemiTransparency.as_value(static_cast(transparency)) | TextureClut.as_value(static_cast(clut_color))) { + static constexpr TPage create(uint16_t x, uint16_t y, ::JabyEngine::GPU::SemiTransparency transparency, TexturePageColor clut_color) { + return TPage{static_cast(TexturePageX.as_value(x >> 6) | TexturePageY.as_value(y >> 8) | SemiTransparency.as_value(static_cast(transparency)) | TextureClut.as_value(static_cast(clut_color)))}; } }; }