Introduce the JabyEngine namespace to all files

This commit is contained in:
2022-12-23 21:18:25 +01:00
parent 791fe85ab8
commit def6c6d3b9
27 changed files with 1320 additions and 1282 deletions

View File

@@ -10,32 +10,33 @@
#endif
#endif
namespace GPU {
namespace Display {
#ifdef JABYENGINE_PAL
static constexpr size_t Width = 320;
static constexpr size_t Height = 256;
#else
static constexpr size_t Width = 320;
static constexpr size_t Height = 240;
#endif
namespace JabyEngine {
namespace GPU {
namespace Display {
#ifdef JABYENGINE_PAL
static constexpr size_t Width = 320;
static constexpr size_t Height = 256;
#else
static constexpr size_t Width = 320;
static constexpr size_t Height = 240;
#endif
static void enable() {
GP1.write(Command::GP1::SetDisplayState(DisplayState::On));
static void enable() {
GP1.write(Command::GP1::SetDisplayState(DisplayState::On));
}
static void disable() {
GP1.write(Command::GP1::SetDisplayState(DisplayState::Off));
}
}
static void disable() {
GP1.write(Command::GP1::SetDisplayState(DisplayState::Off));
}
}
namespace Screen {
extern uint8_t CurrentDisplayAreaID;
namespace Screen {
extern uint8_t CurrentDisplayAreaID;
namespace Range {
void set_offset(uint16_t x, uint16_t y);
namespace Range {
void set_offset(uint16_t x, uint16_t y);
}
}
}
}
#endif //!__JABYENGINE_GPU_HPP__

View File

@@ -3,100 +3,101 @@
#include "../jabyengine_defines.h"
#include "../Auxiliary/complex_bitmap.hpp"
namespace GPU {
struct Color24 {
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
namespace JabyEngine {
namespace GPU {
struct Color24 {
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
constexpr Color24() = default;
constexpr Color24(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
}
constexpr Color24() = default;
constexpr Color24(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
}
constexpr uint32_t raw() const {
return ((this->blue << 16) | (this->green << 8) | this->red);
}
constexpr uint32_t raw() const {
return ((this->blue << 16) | (this->green << 8) | this->red);
}
static constexpr Color24 Black() {
return Color24(0, 0, 0);
}
static constexpr Color24 Black() {
return Color24(0, 0, 0);
}
static constexpr Color24 White() {
return Color24(0xFF, 0xFF, 0xFF);
}
static constexpr Color24 White() {
return Color24(0xFF, 0xFF, 0xFF);
}
static constexpr Color24 Red() {
return Color24(0xFF, 0x0, 0x0);
}
static constexpr Color24 Red() {
return Color24(0xFF, 0x0, 0x0);
}
static constexpr Color24 Green() {
return Color24(0x0, 0xFF, 0x0);
}
static constexpr Color24 Green() {
return Color24(0x0, 0xFF, 0x0);
}
static constexpr Color24 Blue() {
return Color24(0x0, 0x0, 0xFF);
}
};
static constexpr Color24 Blue() {
return Color24(0x0, 0x0, 0xFF);
}
};
class Color {
private:
static constexpr auto RedRange = BitRange<uint16_t>::from_to(0, 4);
static constexpr auto GreenRange = BitRange<uint16_t>::from_to(5, 9);
static constexpr auto BlueRange = BitRange<uint16_t>::from_to(10, 14);
static constexpr auto SemiTransperancyBit = Bit<uint16_t>(15);
class Color {
private:
static constexpr auto RedRange = BitRange<uint16_t>::from_to(0, 4);
static constexpr auto GreenRange = BitRange<uint16_t>::from_to(5, 9);
static constexpr auto BlueRange = BitRange<uint16_t>::from_to(10, 14);
static constexpr auto SemiTransperancyBit = Bit<uint16_t>(15);
ComplexBitMap<uint16_t> value = {0};
ComplexBitMap<uint16_t> value = {0};
public:
static constexpr Color from_rgb(uint8_t r, uint8_t g, uint8_t b) {
return Color().set_red(r).set_green(g).set_blue(b);
}
public:
static constexpr Color from_rgb(uint8_t r, uint8_t g, uint8_t b) {
return Color().set_red(r).set_green(g).set_blue(b);
}
static constexpr Color from(const Color24& color) {
return Color::from_rgb(color.red, color.green, color.blue);
}
static constexpr Color from(const Color24& color) {
return Color::from_rgb(color.red, color.green, color.blue);
}
constexpr Color& set_red(uint8_t red) {
this->value.set_value(static_cast<uint16_t>(red), RedRange);
return *this;
}
constexpr Color& set_red(uint8_t red) {
this->value.set_value(static_cast<uint16_t>(red), RedRange);
return *this;
}
constexpr Color& set_green(uint8_t green) {
this->value.set_value(static_cast<uint16_t>(green), GreenRange);
return *this;
}
constexpr Color& set_green(uint8_t green) {
this->value.set_value(static_cast<uint16_t>(green), GreenRange);
return *this;
}
constexpr Color& set_blue(uint8_t blue) {
this->value.set_value(static_cast<uint16_t>(blue), BlueRange);
return *this;
}
};
constexpr Color& set_blue(uint8_t blue) {
this->value.set_value(static_cast<uint16_t>(blue), BlueRange);
return *this;
}
};
template<typename T>
struct Position {
T x = 0;
T y = 0;
template<typename T>
struct Position {
T x = 0;
T y = 0;
constexpr Position() = default;
constexpr Position(T x, T y) : x(x), y(y) {
}
};
constexpr Position() = default;
constexpr Position(T x, T y) : x(x), y(y) {
}
};
template<typename T>
struct Size {
T width = 0;
T height = 0;
template<typename T>
struct Size {
T width = 0;
T height = 0;
constexpr Size() = default;
constexpr Size(T w, T h) : width(w), height(h) {
}
};
constexpr Size() = default;
constexpr Size(T w, T h) : width(w), height(h) {
}
};
typedef Position<int16_t> PositionI16;
typedef Position<uint16_t> PositionU16;
typedef Position<int16_t> PositionI16;
typedef Position<uint16_t> PositionU16;
typedef Size<int16_t> SizeI16;
typedef Size<uint16_t> SizeU16;
typedef Size<int16_t> SizeI16;
typedef Size<uint16_t> SizeU16;
}
}
#endif //!__JABYENGINE_GPU_TYPES_HPP__