diff --git a/include/PSX/GTE/gte_types.hpp b/include/PSX/GTE/gte_types.hpp index fbdcee35..76924a6c 100644 --- a/include/PSX/GTE/gte_types.hpp +++ b/include/PSX/GTE/gte_types.hpp @@ -20,6 +20,10 @@ namespace JabyEngine { return VECTOR{.x = x, .y = y, .z = z, .pad = 0}; } + static constexpr VECTOR create(gte_float x, gte_float y, gte_float z) { + return VECTOR{.x = static_cast(x), .y = static_cast(y), .z = static_cast(z)}; + } + template static constexpr VECTOR from(const GPU::Position& pos) { return VECTOR::create(static_cast(pos.x), static_cast(pos.y), 0); @@ -39,9 +43,9 @@ namespace JabyEngine { static constexpr ROTMATRIX identity() { return ROTMATRIX{.matrix = { - {4096, 0, 0}, - {0, 4096, 0}, - {0, 0, 4096} + {static_cast(gte_float::one()), 0, 0}, + {0, static_cast(gte_float::one()), 0}, + {0, 0, static_cast(gte_float::one())} } }; } diff --git a/include/math.hpp b/include/math.hpp index 9efee370..5d187cc4 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -50,6 +50,30 @@ static constexpr deg_t operator""_deg(long double degree) { return deg_t::from_tenth_degree((degree*10.0)); } +struct gte_float : public math::raw_math { + int32_t raw; + + static constexpr gte_float from_double(double value) { + return gte_float{.raw = static_cast(4096.0*value)}; + } + + static constexpr gte_float one() { + return gte_float::from_double(1.0); + } + + constexpr explicit operator int32_t() const { + return this->raw; + } + + constexpr explicit operator int16_t() const { + return static_cast(this->raw); + } +}; + +static constexpr gte_float operator""_gf(long double value) { + return gte_float::from_double(value); +} + using sin_t = int32_t; using cos_t = int32_t; diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index 5749b443..fc15190a 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -16,7 +16,7 @@ namespace JabyEngine { static void test_gte_scale() { auto matrix = GTE::ROTMATRIX::identity(); - GTE::scale_matrix(matrix, GTE::VECTOR::create(4096*2, 4096*2, 4096*2)); + GTE::scale_matrix(matrix, GTE::VECTOR::create(1.5_gf, 2.0_gf, 1.0_gf)); printf("|%i|%i|%i|\n", matrix.matrix[0][0], matrix.matrix[0][1], matrix.matrix[0][2]); printf("|%i|%i|%i|\n", matrix.matrix[1][0], matrix.matrix[1][1], matrix.matrix[1][2]); printf("|%i|%i|%i|\n", matrix.matrix[2][0], matrix.matrix[2][1], matrix.matrix[2][2]);