From b523c2c73fbb0c265049680588dea9b11e13a09b Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 8 Sep 2022 21:36:12 +0200 Subject: [PATCH] Introduce QuickFill --- include/PSX/GPU/GPU_Types.hpp | 24 ++++++++---------------- include/PSX/System/IOPorts/GPU_IO.hpp | 21 +++++++++++++++++---- src/Library/src/BootLoader/gpu_boot.cpp | 10 ++++++++-- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/include/PSX/GPU/GPU_Types.hpp b/include/PSX/GPU/GPU_Types.hpp index fc62f09d..8a640c9b 100644 --- a/include/PSX/GPU/GPU_Types.hpp +++ b/include/PSX/GPU/GPU_Types.hpp @@ -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); } }; } diff --git a/include/PSX/System/IOPorts/GPU_IO.hpp b/include/PSX/System/IOPorts/GPU_IO.hpp index bb16f06b..e9828688 100644 --- a/include/PSX/System/IOPorts/GPU_IO.hpp +++ b/include/PSX/System/IOPorts/GPU_IO.hpp @@ -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 { __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 { __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}; } diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 2660b219..072d7338 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -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)); } } \ No newline at end of file