From 60049cc9e5e685488f398a1216e5e693948813a6 Mon Sep 17 00:00:00 2001 From: Jaby Blubb Date: Sun, 30 Apr 2023 14:18:11 +0200 Subject: [PATCH] Add BootImage to second DisplayBuffer during boot --- include/PSX/GPU/gpu_types.hpp | 15 +++++++++++++++ include/PSX/System/IOPorts/gpu_io.hpp | 4 ++++ src/Library/internal-include/GPU/gpu_internal.hpp | 13 ++++++++++--- src/Library/src/BootLoader/gpu_boot.cpp | 5 ++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index 48bfc0ca..187b9f9f 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -92,11 +92,26 @@ namespace JabyEngine { } }; + template + struct Area { + Position position; + Size size; + + constexpr Area() = default; + constexpr Area(Position position, Size size) : position(position), size(size) { + } + constexpr Area(T position_x, T position_y, T size_width, T size_height) : position{position_x, position_y}, size{size_width, size_height} { + } + }; + typedef Position PositionI16; typedef Position PositionU16; typedef Size SizeI16; typedef Size SizeU16; + + typedef Area AreaI16; + typedef Area AreaU16; } } #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 37307d49..b26059c3 100644 --- a/include/PSX/System/IOPorts/gpu_io.hpp +++ b/include/PSX/System/IOPorts/gpu_io.hpp @@ -106,6 +106,10 @@ namespace JabyEngine { return {(0x02 << 24) | color.raw()}; } + static constexpr GP0_t VRAM2VRAM_Blitting() { + return {(0b100u << 29)}; + } + static constexpr GP0_t CPU2VRAM_Blitting() { return {(0b101u << 29)}; } diff --git a/src/Library/internal-include/GPU/gpu_internal.hpp b/src/Library/internal-include/GPU/gpu_internal.hpp index 68c1d03d..74b57864 100644 --- a/src/Library/internal-include/GPU/gpu_internal.hpp +++ b/src/Library/internal-include/GPU/gpu_internal.hpp @@ -31,10 +31,17 @@ namespace JabyEngine { GPU_IO::GP0 = GPU_IO::Command::DrawAreaBottomRight((x + Display::Width), (y + Display::Height)); } - static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) { + static void copy_vram_to_vram(const AreaU16& dst, const PositionU16& src) { + GPU_IO::GP0 = GPU_IO::Command::VRAM2VRAM_Blitting(); + GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(src.x, src.y); + GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(dst.position.x, dst.position.y); + GPU_IO::GP0 = GPU_IO::Command::WidthHeight(dst.size.width, dst.size.height); + } + + static void quick_fill_fast(const Color24& color, const AreaU16& area) { GPU_IO::GP0 = GPU_IO::Command::QuickFill(color); - GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(pos.x, pos.y); - GPU_IO::GP0 = GPU_IO::Command::WidthHeight(size.width, size.height); + GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(area.position.x, area.position.y); + GPU_IO::GP0 = GPU_IO::Command::WidthHeight(area.size.width, area.size.height); } static void reset_cmd_buffer() { diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 22390d12..3c1f3fde 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -58,6 +58,9 @@ namespace JabyEngine { auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0)); state.process(bytes_ready); + // Duplicate DisplayBuffer content + internal::copy_vram_to_vram({PositionU16(0, Display::Height), SizeU16(Display::Width, Display::Height)}, PositionU16(0, 0)); + Display::enable(); } @@ -67,7 +70,7 @@ namespace JabyEngine { internal::Display::exchange_buffer_and_display(); GPU::internal::wait_ready_for_CMD(); - GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height)); + GPU::internal::quick_fill_fast(Color24::Black(), {PositionU16(32, 0), SizeU16(Display::Width, Display::Height)}); __syscall_EnterCriticalSection(); __syscall_SysEnqIntRP(VblankIrq, &::JabyEngine::GPU::internal::callback);