From 91571bff472d2190265d8d42ef585cdd84f88e92 Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 13 Mar 2024 23:59:15 -0500 Subject: [PATCH] Prepare DMA support for PS3 --- src/Library/internal-include/GPU/gpu_internal.hpp | 15 ++++++++++++++- src/Library/src/BootLoader/start_boot.cpp | 1 - src/Library/src/GPU/gpu.cpp | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Library/internal-include/GPU/gpu_internal.hpp b/src/Library/internal-include/GPU/gpu_internal.hpp index 01e1e914..85e5d1f2 100644 --- a/src/Library/internal-include/GPU/gpu_internal.hpp +++ b/src/Library/internal-include/GPU/gpu_internal.hpp @@ -66,6 +66,11 @@ namespace JabyEngine { } namespace DMA { + #ifdef SUPPORT_PS3 + // The PS3 doesn't autoincrement the GPU MADR register so we have to do it + extern uintptr_t MADR; + #endif // SUPPORT_PS3 + static void wait() { ::JabyEngine::DMA_IO::GPU.wait(); } @@ -81,7 +86,11 @@ namespace JabyEngine { } static void set_src(uintptr_t adr) { - DMA_IO::GPU.set_adr(adr); + #ifdef SUPPORT_PS3 + MADR = adr; + #else + DMA_IO::GPU.set_adr(adr); + #endif // SUPPORT_PS3 } static void set_dst(const PositionU16& position, const SizeU16& size) { @@ -94,6 +103,10 @@ namespace JabyEngine { static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) { typedef DMA_IO::BCR::SyncMode1 SyncMode1; + #ifdef SUPPORT_PS3 + DMA_IO::GPU.set_adr(MADR); + MADR += (blockCount * wordsPerBlock) << 2; + #endif // SUPPORT_PS3 DMA_IO::GPU.block_ctrl.write(DMA_IO::BCR::from(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount))); DMA_IO::GPU.channel_ctrl.write(DMA_IO::CHCHR::StartGPUReceive()); } diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index ac878bdc..18ea2aa4 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -116,7 +116,6 @@ namespace JabyEngine { __debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale); SPU::stop_voices(); - // TODO: v Might be the PS3 crash __debug_boot_color_at(::JabyEngine::GPU::Color24::Green(), DebugX, DebugY, DebugScale); CD::setup(); __debug_boot_color_at(::JabyEngine::GPU::Color24::Blue(), DebugX, DebugY, DebugScale); diff --git a/src/Library/src/GPU/gpu.cpp b/src/Library/src/GPU/gpu.cpp index 85a84d1e..012e84f8 100644 --- a/src/Library/src/GPU/gpu.cpp +++ b/src/Library/src/GPU/gpu.cpp @@ -8,6 +8,12 @@ namespace JabyEngine { uint8_t Display :: current_id = 1; //< Setup will call exchange and set it to 0 namespace internal { + namespace DMA { + #ifdef SUPPORT_PS3 + uintptr_t MADR = 0; + #endif // SUPPORT_PS3 + } + static SysCall::InterruptVerifierResult interrupt_verifier(); static uint32_t interrupt_handler(uint32_t);