Integrate all the progress into master #6
|
@ -48,7 +48,7 @@ namespace FontWriter {
|
|||
return {text, color};
|
||||
}
|
||||
|
||||
return {text + 7, GPU::Color24(char_to_color(text[1]), char_to_color(text[3]), char_to_color(text[5]))};
|
||||
return {text + 7, GPU::Color24::from_rgb(char_to_color(text[1]), char_to_color(text[3]), char_to_color(text[5]))};
|
||||
};
|
||||
const auto* cur_text_end = &Pool::buffer[GPU::Display::current_id].text_buffer[Pool::Buffer::BufferSize];
|
||||
const auto org_x = pos.x;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace JabyEngine {
|
|||
|
||||
// The following two values can be easily changed
|
||||
static constexpr auto TextureLoadPos = PositionU16::create(0, 0);
|
||||
static constexpr auto CLUTLoadPos = PositionU16::create(0, 0);
|
||||
static constexpr auto CLUTLoadPos = PositionU16::create(0, 96);
|
||||
|
||||
static constexpr TexPage get_tex_page() {
|
||||
return TexPage::create(BIOS_Font::TextureLoadPos, GPU::TexturePageColor::$4bit);
|
||||
|
|
|
@ -53,6 +53,37 @@ namespace JabyEngine {
|
|||
return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).move(dx, dy);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PredefinedColors {
|
||||
static constexpr T Black() {
|
||||
return T::from_rgb(0, 0, 0);
|
||||
}
|
||||
|
||||
static constexpr T Grey() {
|
||||
return T::from_rgb(0x80, 0x80, 0x80);
|
||||
}
|
||||
|
||||
static constexpr T White() {
|
||||
return T::from_rgb(0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
static constexpr T Red(uint8_t base = 0xFF) {
|
||||
return T::from_rgb(base, 0x0, 0x0);
|
||||
}
|
||||
|
||||
static constexpr T Green(uint8_t base = 0xFF) {
|
||||
return T::from_rgb(0x0, base, 0x0);
|
||||
}
|
||||
|
||||
static constexpr T Blue(uint8_t base = 0xFF) {
|
||||
return T::from_rgb(0x0, 0x0, base);
|
||||
}
|
||||
|
||||
static constexpr T Yellow(uint8_t base = 0xFF) {
|
||||
return T::from_rgb(base, base, 0x0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
enum struct SemiTransparency {
|
||||
|
@ -68,62 +99,32 @@ namespace JabyEngine {
|
|||
$15bit = 2,
|
||||
};
|
||||
|
||||
struct Color24 {
|
||||
struct Color24 : public internal::PredefinedColors<Color24> {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
|
||||
static constexpr Color24 from_rgb(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return Color24{r, g, b};
|
||||
return Color24{.red = r, .green = g, .blue = b};
|
||||
}
|
||||
|
||||
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 Grey() {
|
||||
return Color24(0x80, 0x80, 0x80);
|
||||
}
|
||||
|
||||
static constexpr Color24 White() {
|
||||
return Color24(0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
static constexpr Color24 Red(uint8_t base = 0xFF) {
|
||||
return Color24(base, 0x0, 0x0);
|
||||
}
|
||||
|
||||
static constexpr Color24 Green(uint8_t base = 0xFF) {
|
||||
return Color24(0x0, base, 0x0);
|
||||
}
|
||||
|
||||
static constexpr Color24 Blue(uint8_t base = 0xFF) {
|
||||
return Color24(0x0, 0x0, base);
|
||||
}
|
||||
|
||||
static constexpr Color24 Yellow(uint8_t base = 0xFF) {
|
||||
return Color24(base, base, 0x0);
|
||||
}
|
||||
|
||||
constexpr Color24 invert() const {
|
||||
return Color24(0xFF - this->red, 0xFF - this->green, 0xFF - this->blue);
|
||||
return Color24::from_rgb(this->red^0xFF, this->green^0xFF, this->blue^0xFF);
|
||||
}
|
||||
};
|
||||
|
||||
class Color {
|
||||
private:
|
||||
struct Color : public internal::PredefinedColors<Color> {
|
||||
static constexpr auto RedRange = BitRange::from_to(0, 4);
|
||||
static constexpr auto GreenRange = BitRange::from_to(5, 9);
|
||||
static constexpr auto BlueRange = BitRange::from_to(10, 14);
|
||||
static constexpr auto SemiTransperancyBit = Bit(15);
|
||||
|
||||
uint16_t value;
|
||||
uint16_t raw;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -132,18 +133,22 @@ namespace JabyEngine {
|
|||
return Color::from_rgb(color.red, color.green, color.blue);
|
||||
}
|
||||
|
||||
constexpr Color invert() const {
|
||||
return Color{.raw = static_cast<uint16_t>(this->raw^0xFFFF)};
|
||||
}
|
||||
|
||||
constexpr Color& set_red(uint8_t red) {
|
||||
this->value = bit::value::set_normalized(this->value, RedRange.with(red));
|
||||
this->raw = bit::value::set_normalized(this->raw, RedRange.with(red));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Color& set_green(uint8_t green) {
|
||||
this->value = bit::value::set_normalized(this->value, GreenRange.with(green));
|
||||
this->raw = bit::value::set_normalized(this->raw, GreenRange.with(green));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Color& set_blue(uint8_t blue) {
|
||||
this->value = bit::value::set_normalized(this->value, BlueRange.with(blue));
|
||||
this->raw = bit::value::set_normalized(this->raw, BlueRange.with(blue));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,6 +22,26 @@ namespace JabyEngine {
|
|||
namespace internal {
|
||||
extern SysCall::InterrupCallback callback;
|
||||
}
|
||||
|
||||
namespace SJIS {
|
||||
void load_clut(const PositionU16& dst_cord) {
|
||||
struct CLUT {
|
||||
CPU2VRAM cmd;
|
||||
Color data[16];
|
||||
};
|
||||
const CLUT clut {
|
||||
.cmd = CPU2VRAM::create(AreaU16::create(dst_cord, GPU::SizeU16::create(16, 1))),
|
||||
.data = {
|
||||
Color::Blue(), Color::White(),
|
||||
Color::Blue(), Color::White(), Color::Blue(), Color::White(), Color::Blue(), Color::White(),
|
||||
Color::Blue(), Color::White(),
|
||||
Color::Blue(), Color::White(), Color::Blue(), Color::White(), Color::Blue(), Color::White(),
|
||||
}
|
||||
};
|
||||
|
||||
GPU::internal::render(reinterpret_cast<const uint32_t*>(&clut), sizeof(CLUT)/sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
|
@ -64,6 +84,7 @@ namespace JabyEngine {
|
|||
|
||||
// Now load the BIOS font to the specified location
|
||||
SJIS::load(BIOS_Font::TextureLoadPos);
|
||||
SJIS::load_clut(BIOS_Font::CLUTLoadPos);
|
||||
|
||||
// Duplicate DisplayBuffer content
|
||||
::JabyEngine::GPU::internal::copy_vram_to_vram({PositionU16::create(0, Display::Height), SizeU16::create(Display::Width, Display::Height)}, PositionU16::create(0, 0));
|
||||
|
|
Loading…
Reference in New Issue