From a8f0bddc89a5f225eb852fd31b51607c4601aab0 Mon Sep 17 00:00:00 2001 From: jaby Date: Sun, 11 Sep 2022 10:10:51 +0200 Subject: [PATCH] Introduce internal and normal GPU functions --- include/PSX/GPU/GPU.h | 17 ++++++++++++ include/PSX/GPU/GPU_Types.hpp | 26 +++++++++++++++++++ include/PSX/System/IOPorts/GPU_IO.hpp | 2 +- .../include/BootLoader/boot_loader.hpp | 1 + src/Library/include/GPU/GPU.h | 14 ++++++++++ src/Library/src/BootLoader/gpu_boot.cpp | 18 +++++++------ src/Library/src/BootLoader/start_boot.cpp | 7 ++--- 7 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 include/PSX/GPU/GPU.h create mode 100644 src/Library/include/GPU/GPU.h diff --git a/include/PSX/GPU/GPU.h b/include/PSX/GPU/GPU.h new file mode 100644 index 00000000..b27b9b57 --- /dev/null +++ b/include/PSX/GPU/GPU.h @@ -0,0 +1,17 @@ +#ifndef __JABYENGINE_GPU_H__ +#define __JABYENGINE_GPU_H__ +#include "../System/IOPorts/GPU_IO.hpp" + +namespace GPU { + namespace Display { + static void enable() { + Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On)); + } + + static void disable() { + Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::Off)); + } + } +} + +#endif //!__JABYENGINE_GPU_H__ \ No newline at end of file diff --git a/include/PSX/GPU/GPU_Types.hpp b/include/PSX/GPU/GPU_Types.hpp index 8a640c9b..c5e55128 100644 --- a/include/PSX/GPU/GPU_Types.hpp +++ b/include/PSX/GPU/GPU_Types.hpp @@ -16,6 +16,32 @@ namespace GPU { return ((this->blue << 16) | (this->green << 8) | this->red); } }; + + template + struct Position { + T x = 0; + T y = 0; + + constexpr Position() = default; + constexpr Position(T x, T y) : x(x), y(y) { + } + }; + + template + struct Size { + T width = 0; + T height = 0; + + constexpr Size() = default; + constexpr Size(T w, T h) : width(w), height(h) { + } + }; + + typedef Position PositionI16; + typedef Position PositionU16; + + typedef Size SizeI16; + typedef Size SizeU16; } #endif //!__JABYENGINE_GPU_TYPES_HPP__ \ No newline at end of file diff --git a/include/PSX/System/IOPorts/GPU_IO.hpp b/include/PSX/System/IOPorts/GPU_IO.hpp index e9828688..79daa8ca 100644 --- a/include/PSX/System/IOPorts/GPU_IO.hpp +++ b/include/PSX/System/IOPorts/GPU_IO.hpp @@ -55,7 +55,7 @@ namespace GPU { } static constexpr GP0 WidthHeight(uint16_t w, uint16_t h) { - return {(h << 16) | h}; + return {(h << 16) | w}; } }; diff --git a/src/Library/include/BootLoader/boot_loader.hpp b/src/Library/include/BootLoader/boot_loader.hpp index 8e161c0e..7ee8bede 100644 --- a/src/Library/include/BootLoader/boot_loader.hpp +++ b/src/Library/include/BootLoader/boot_loader.hpp @@ -2,6 +2,7 @@ #define BOOT_LOADER_HPP namespace GPU { + void display_logo(); void setup(); } diff --git a/src/Library/include/GPU/GPU.h b/src/Library/include/GPU/GPU.h new file mode 100644 index 00000000..c6f4f2ab --- /dev/null +++ b/src/Library/include/GPU/GPU.h @@ -0,0 +1,14 @@ +#ifndef __JABYENGINE_INTERNAL_GPU_HPP__ +#define __JABYENGINE_INTERNAL_GPU_HPP__ +#include +#include + +namespace GPU { + static void quick_fill_fast(const Color& color, const PositionU16& pos, const SizeU16& size) { + Port::GP0.write(Port::Command::GP0::QuickFill(color)); + Port::GP0.write(Port::Command::GP0::TopLeftPosition(pos.x, pos.y)); + Port::GP0.write(Port::Command::GP0::WidthHeight(size.width, size.height)); + } +} + +#endif //!__JABYENGINE_INTERNAL_GPU_HPP__ \ No newline at end of file diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 072d7338..3ec2479d 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -1,14 +1,16 @@ -#include +#include "../../include/GPU/GPU.h" +#include namespace GPU { + void display_logo() { + Display::disable(); + quick_fill_fast(Color(0x0, 0x80, 0x80), PositionU16(0, 0), SizeU16(640, 480)); + Display::enable(); + } + void setup() { - //Port::GP1.write(Port::Command::GP1::Reset()); + 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)); + quick_fill_fast(Color(0x0, 0x0, 0x0), PositionU16(0, 0), SizeU16(640, 480)); } } \ No newline at end of file diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index a62cd893..272d4ed1 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -4,14 +4,15 @@ namespace JabyEngine { void start() { printf("Hello Planschbecken\n"); - //We key off the voices + SPU::stop_voices(); + GPU::display_logo(); //Load picture here //Pause?? - //Do the real setup - GPU::setup(); + //Do not setup GPU for now + //GPU::setup(); SPU::setup(); printf("Setup done!\n"); }