Introduce QuickFill

This commit is contained in:
jaby 2022-09-08 21:36:12 +02:00
parent b5533733c3
commit 679899279d
3 changed files with 33 additions and 22 deletions

View File

@ -3,25 +3,17 @@
#include "../jabyengine_defines.h"
namespace GPU {
struct __no_align Color3 {
uint8_t blue;
uint8_t green;
uint8_t red;
struct Color {
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
static constexpr Color3 black() {
return {0x0, 0x0, 0x0};
constexpr Color() = default;
constexpr Color(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
}
static constexpr Color3 rgb(uint8_t r, uint8_t g, uint8_t b) {
return {b, g, r};
}
};
struct __no_align Color {
uint8_t reserved;
Color3 color_data;
constexpr Color(Color3 color) : reserved(0), color_data(color) {
constexpr uint32_t raw() const {
return ((this->blue << 16) | (this->green << 8) | this->red);
}
};
}

View File

@ -1,6 +1,7 @@
#ifndef __JABYENGINE_GPU_IO_HPP__
#define __JABYENGINE_GPU_IO_HPP__
#include "IOPort.hpp"
#include "../../GPU/GPU_Types.hpp"
namespace GPU {
namespace Port {
@ -42,17 +43,29 @@ namespace GPU {
};
namespace Command {
static constexpr uint32_t construct_cmd(uint8_t cmd, uint32_t value) {
return ((cmd << 24) | value);
}
struct __no_align GP0 : public ComplexBitMap<uint32_t> {
__io_port_inherit_complex_bit_map(GP0);
static constexpr GP0 QuickFill(Color color) {
return {(0x02 << 24) | color.raw()};
}
static constexpr GP0 TopLeftPosition(uint16_t x, uint16_t y) {
return {(y << 16) | x};
}
static constexpr GP0 WidthHeight(uint16_t w, uint16_t h) {
return {(h << 16) | h};
}
};
struct __no_align GP1 : public ComplexBitMap<uint32_t> {
__io_port_inherit_complex_bit_map(GP1);
static constexpr uint32_t construct_cmd(uint8_t cmd, uint32_t value) {
return ((cmd << 24) | value);
}
static constexpr GP1 Reset() {
return {0};
}

View File

@ -2,7 +2,13 @@
namespace GPU {
void setup() {
Port::GP1.write(Port::Command::GP1::Reset());
Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On));
//Port::GP1.write(Port::Command::GP1::Reset());
//Quickfill
Port::GP0.write(Port::Command::GP0::QuickFill(Color(0xFF, 0x0, 0x0)));
Port::GP0.write(Port::Command::GP0::TopLeftPosition(8, 8));
Port::GP0.write(Port::Command::GP0::WidthHeight(32, 32));
//Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On));
}
}