From 51f99194b2a27e65169fa8fecf48a1fb2dc850e0 Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 8 Sep 2022 20:36:36 +0200 Subject: [PATCH] Prepare GPU setup --- include/PSX/System/IOPorts/GPU_IO.hpp | 30 ++++++++++++++++++++++++- src/Library/src/BootLoader/gpu_boot.cpp | 5 +++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/PSX/System/IOPorts/GPU_IO.hpp b/include/PSX/System/IOPorts/GPU_IO.hpp index 439c8e36..bb16f06b 100644 --- a/include/PSX/System/IOPorts/GPU_IO.hpp +++ b/include/PSX/System/IOPorts/GPU_IO.hpp @@ -36,9 +36,33 @@ namespace GPU { GPU2CPU = 3, }; - struct __no_align Command : public ComplexBitMap { + enum struct DisplayState { + On = 0, + Off = 1 }; + 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); + }; + + struct __no_align GP1 : public ComplexBitMap { + __io_port_inherit_complex_bit_map(GP1); + + static constexpr GP1 Reset() { + return {0}; + } + + static constexpr GP1 SetDisplayState(DisplayState state) { + return {construct_cmd(0x03, static_cast(state))}; + } + }; + } + struct __no_align GPUStatusRegister : public ComplexBitMap { static constexpr auto DrawingOddLinesInterlaced = Bit(31); static constexpr auto DMADirectionValue = BitRange::from_to(29, 30); @@ -68,6 +92,10 @@ namespace GPU { static constexpr auto TexturePageY256 = Bit(4); }; + __declare_io_port_global(Command::GP0, GP0, 0x1F801810); + __declare_io_port_global(Command::GP1, GP1, 0x1F801814); + + __declare_io_port_global_const(uint32_t, GPUREAD, 0x1F801810); __declare_io_port_global_const(GPUStatusRegister, GPUSTAT, 0x1F801814); } } diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 575d6fd3..2660b219 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -1,7 +1,8 @@ -#include +#include namespace GPU { void setup() { - + Port::GP1.write(Port::Command::GP1::Reset()); + Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On)); } } \ No newline at end of file