diff --git a/include/PSX/GPU/gpu_primitives.hpp b/include/PSX/GPU/gpu_primitives.hpp index 5bd49e69..c61f229b 100644 --- a/include/PSX/GPU/gpu_primitives.hpp +++ b/include/PSX/GPU/gpu_primitives.hpp @@ -13,8 +13,8 @@ namespace JabyEngine { static constexpr auto CmdID = BitRange::from_to(29 - BitCorrection, 31 - BitCorrection); static constexpr auto GouraudShading = Bit(28 - BitCorrection); static constexpr auto FlatShading = !GouraudShading; - static constexpr auto QuardVertics = Bit(27 - BitCorrection); - static constexpr auto TriVertics = !QuardVertics; + static constexpr auto QuadVertics = Bit(27 - BitCorrection); + static constexpr auto TriVertics = !QuadVertics; static constexpr auto Textured = Bit(26 - BitCorrection); static constexpr auto Untextured = !Textured; static constexpr auto SemiTransparent = Bit(25 - BitCorrection); @@ -117,7 +117,11 @@ namespace JabyEngine { Vertex vertex2; // d constexpr POLY_F3() = default; - constexpr POLY_F3(const Vertex (&verticies)[3], Color24 color) : color(color), code(IdentityCode), vertex0(verticies[0]), vertex1(verticies[1]), vertex2(verticies[2]) { + constexpr POLY_F3(const Vertex (&verticies)[3], Color24 color) : + color(color), code(IdentityCode), + vertex0(verticies[0]), + vertex1(verticies[1]), + vertex2(verticies[2]) { } }; @@ -216,15 +220,44 @@ namespace JabyEngine { color2(verticies_ex[2].color), vertex2(verticies_ex[2].position), page2(verticies_ex[2].page) {} }; + struct POLY_F4 : public internal::IsPrimitive, public internal::CodeInterface { + static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics); + + Color24 color; // a + Code code = IdentityCode; // a + Vertex vertex0; // b + Vertex vertex1; // c + Vertex vertex2; // d + Vertex vertex3; // e + + constexpr POLY_F4() = default; + constexpr POLY_F4(const Vertex (&verticies)[4], Color24 color) : + color(color), code(IdentityCode), + vertex0(verticies[0]), + vertex1(verticies[1]), + vertex2(verticies[2]), + vertex3(verticies[3]) {} + constexpr POLY_F4(const AreaI16& area, Color24 color) : POLY_F4({ + area.position, + area.position.move(area.size.width, 0), + area.position.move(0, area.size.height), + area.position.move(area.size.width, area.size.height)}, + color) {} + }; + typedef POLY_F3 FlatTriangle; typedef POLY_FT3 FlatTexturedTriangle; typedef POLY_G3 GouraudTriangle; typedef POLY_GT3 GouraudTexturedTriangle; + typedef POLY_F4 FlatRectangle; + static_assert(sizeof(POLY_F3) == 16); static_assert(sizeof(POLY_FT3) == 28); static_assert(sizeof(POLY_G3) == 24); static_assert(sizeof(POLY_GT3) == 36); + + static_assert(sizeof(POLY_F4) == 20); } } diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index f2318882..2219b1cc 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -81,6 +81,17 @@ namespace JabyEngine { constexpr Position() = default; constexpr Position(T x, T y) : x(x), y(y) { } + + constexpr Position& move(T dx, T dy) { + this->x += dx; + this->y += dy; + + return *this; + } + + constexpr Position move(T dx, T dy) const { + return Position(this->x, this->y).move(dx, dy); + } }; template