Remove last constructor and remove GLOBAL SUB with it

This commit is contained in:
2023-10-03 13:16:46 +02:00
parent af5855804f
commit baa9e8c5de
11 changed files with 86 additions and 89 deletions

View File

@@ -31,7 +31,7 @@ namespace JabyEngine {
}
constexpr GPU::PositionU16 get_texture_position() const {
return {SimpleTIM::get_texture_x(), SimpleTIM::get_texture_y()};
return GPU::PositionU16::create(SimpleTIM::get_texture_x(), SimpleTIM::get_texture_y());
}
constexpr uint16_t get_clut_x() const {
@@ -43,7 +43,7 @@ namespace JabyEngine {
}
constexpr GPU::PositionU16 get_clut_position() const {
return {SimpleTIM::get_clut_x(), SimpleTIM::get_clut_y()};
return GPU::PositionU16::create(SimpleTIM::get_clut_x(), SimpleTIM::get_clut_y());
}
};

View File

@@ -53,7 +53,7 @@ namespace JabyEngine {
Vertex value;
static constexpr Termination create() {
return {.value = {static_cast<short>(0x5000), static_cast<short>(0x5000)}};
return {.value = Vertex::create(static_cast<short>(0x5000), static_cast<short>(0x5000))};
}
};

View File

@@ -27,7 +27,7 @@ namespace JabyEngine {
}
constexpr T sub(S dx, S dy) const {
return T(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).sub(dx, dy);
return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).sub(dx, dy);
}
constexpr T& move(S dx, S dy) {
@@ -35,7 +35,7 @@ namespace JabyEngine {
}
constexpr T move(S dx, S dy) const {
return T(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).move(dx, dy);
return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).move(dx, dy);
}
};
}
@@ -54,12 +54,12 @@ namespace JabyEngine {
};
struct Color24 {
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
uint8_t red;
uint8_t green;
uint8_t blue;
constexpr Color24() = default;
constexpr Color24(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
static constexpr Color24 from_rgb(uint8_t r, uint8_t g, uint8_t b) {
return Color24{r, g, b};
}
constexpr uint32_t raw() const {
@@ -106,7 +106,7 @@ namespace JabyEngine {
static constexpr auto BlueRange = BitRange::from_to(10, 14);
static constexpr auto SemiTransperancyBit = Bit(15);
uint16_t value = 0;
uint16_t value;
public:
static constexpr Color from_rgb(uint8_t r, uint8_t g, uint8_t b) {
@@ -135,21 +135,21 @@ namespace JabyEngine {
template<typename T>
struct Position : public internal::XYMovement<Position<T>, T> {
T x = 0;
T y = 0;
T x;
T y;
constexpr Position() = default;
constexpr Position(T x, T y) : x(x), y(y) {
static constexpr Position create(T x, T y) {
return Position{.x = x, .y = y};
}
};
template<typename T>
struct Size {
T width = 0;
T height = 0;
T width;
T height;
constexpr Size() = default;
constexpr Size(T w, T h) : width(w), height(h) {
static constexpr Size create(T w, T h) {
return Size{w, h};
}
};
@@ -158,10 +158,12 @@ namespace JabyEngine {
Position<T> position;
Size<T> size;
constexpr Area() = default;
constexpr Area(Position<T> position, Size<T> size) : position(position), size(size) {
static constexpr Area create(Position<T> position, Size<T> size) {
return Area{position, size};
}
constexpr Area(T position_x, T position_y, T size_width, T size_height) : position{position_x, position_y}, size{size_width, size_height} {
static constexpr Area create(T position_x, T position_y, T size_width, T size_height) {
return Area{Position<T>::create(position_x, position_y), Size<T>::create(size_width, size_height)};
}
constexpr Area centered() const {
@@ -176,17 +178,17 @@ namespace JabyEngine {
// Type used for primitives
struct PagePosition : public internal::XYMovement<PagePosition, uint8_t> {
union {
uint8_t x = 0;
uint8_t x;
uint8_t u;
};
union {
uint8_t y = 0;
uint8_t y;
uint8_t v;
};
constexpr PagePosition() = default;
constexpr PagePosition(uint8_t u, uint8_t v) : x(u), y(v) { //< Activate x and y to use XYMovement during constexpr
static constexpr PagePosition create(uint8_t u, uint8_t v) {
return PagePosition{.x = u, .y = v}; //< Activate x and y to use XYMovement during constexpr
}
};