From f67ac19513f6f6b96a00315f1dcd266e0564c684 Mon Sep 17 00:00:00 2001 From: Jaby Date: Tue, 30 Jul 2024 16:13:32 -0500 Subject: [PATCH] Support configuratable screen offset and remove resolved TODOs --- config/Readme.md | 9 +++++++-- include/PSX/System/IOPorts/cd_io.hpp | 1 - include/PSX/jabyengine_config.hpp | 2 ++ src/Library/src/BootLoader/cd_boot.cpp | 13 ------------- src/Library/src/BootLoader/dma_boot.cpp | 1 - src/Library/src/GPU/gpu.cpp | 17 +++++++++++------ src/Library/src/System/string.cpp | 1 - src/Tools/psxcdgen_ex/src/encoder/builder.rs | 2 -- 8 files changed, 20 insertions(+), 26 deletions(-) diff --git a/config/Readme.md b/config/Readme.md index 8533585a..fd91bf39 100644 --- a/config/Readme.md +++ b/config/Readme.md @@ -27,6 +27,9 @@ struct DefaultConfiguration { static constexpr GPU::PositionU16 CLUT_load_pos(); }; + // Offsets the default origin of the screen by the specified value + static constexpr auto DisplayDefaultOffset; + struct Periphery { // Turns on the second controller port and enables multi tap support static constexpr bool include_portB(); @@ -36,6 +39,8 @@ struct DefaultConfiguration { ``` ### `CustomConfiguration` macros ```c++ -#define __USE_DEBUG_COLOR__ // Turns on colored rectangles during boot (off by default) -#define __SUPPORT_PS3__ // Turns on PS3 support (on by default) +// Turns on colored rectangles during boot (off by default) +#define __USE_DEBUG_COLOR__ +// Turns on PS3 support (on by default) +#define __SUPPORT_PS3__ ``` \ No newline at end of file diff --git a/include/PSX/System/IOPorts/cd_io.hpp b/include/PSX/System/IOPorts/cd_io.hpp index 214b963b..868ee822 100644 --- a/include/PSX/System/IOPorts/cd_io.hpp +++ b/include/PSX/System/IOPorts/cd_io.hpp @@ -164,7 +164,6 @@ namespace JabyEngine { Interrupt::Type complete_irq; }; - // TODO: Seems they all need to be ACK? Can we remove this? static constexpr Desc GetStat{0x01, Interrupt::Type::Acknowledge}; static constexpr Desc SetLoc{0x02, Interrupt::Type::Acknowledge}; static constexpr Desc Play{0x03, Interrupt::Type::Acknowledge}; diff --git a/include/PSX/jabyengine_config.hpp b/include/PSX/jabyengine_config.hpp index 33570402..3a92f80d 100644 --- a/include/PSX/jabyengine_config.hpp +++ b/include/PSX/jabyengine_config.hpp @@ -13,6 +13,8 @@ namespace JabyEngine { } }; + static constexpr auto DisplayDefaultOffset = GPU::PositionI16::create(0, 0); + struct Periphery { static constexpr bool include_portB() { return false; diff --git a/src/Library/src/BootLoader/cd_boot.cpp b/src/Library/src/BootLoader/cd_boot.cpp index 59aa61e6..9d01bda3 100644 --- a/src/Library/src/BootLoader/cd_boot.cpp +++ b/src/Library/src/BootLoader/cd_boot.cpp @@ -36,19 +36,6 @@ namespace JabyEngine { Interrupt::enable_irq(Interrupt::CDROM); Interrupt::ack_irq(Interrupt::CDROM); SysCall::ExitCriticalSection(); - - // TODO: Do we need this at all?! - /*__debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale); - CD_IO::PortIndex0::change_to(); - - __debug_boot_color_at(::JabyEngine::GPU::Color24::Green(), DebugX, DebugY, DebugScale); - Command::send(CD_IO::Command::GetStat); - __debug_boot_color_at(::JabyEngine::GPU::Color24::Blue(), DebugX, DebugY, DebugScale); - Command::send(CD_IO::Command::GetStat); - __debug_boot_color_at(::JabyEngine::GPU::Color24::Yellow(), DebugX, DebugY, DebugScale); - Command::send(CD_IO::Command::Init);*/ - - //Command::send(CD_IO::Command::Demute); } } } diff --git a/src/Library/src/BootLoader/dma_boot.cpp b/src/Library/src/BootLoader/dma_boot.cpp index f5ccd6df..400b721f 100644 --- a/src/Library/src/BootLoader/dma_boot.cpp +++ b/src/Library/src/BootLoader/dma_boot.cpp @@ -5,7 +5,6 @@ namespace JabyEngine { namespace boot { namespace DMA { - // TODO: Do we want all of this? So far it didn't help void setup() { static constexpr auto EnableDMA = DMA_IO::DPCR::from(DMA_IO::DPCR::SPU.turn_on(3), DMA_IO::DPCR::GPU.turn_on(3), DMA_IO::DPCR::CDROM.turn_on(3)); diff --git a/src/Library/src/GPU/gpu.cpp b/src/Library/src/GPU/gpu.cpp index fbf3342e..f4215500 100644 --- a/src/Library/src/GPU/gpu.cpp +++ b/src/Library/src/GPU/gpu.cpp @@ -84,12 +84,17 @@ namespace JabyEngine { } void Display :: set_offset(int16_t x, int16_t y) { - // TODO: Apply these in a better way or never? - static constexpr auto PS3_CorrectionX = 0; // 2 - static constexpr auto PS3_CorrectionY = 0; // 1 - - x += internal::Display::DisplayRange.x; - y += internal::Display::DisplayRange.y; + // Does not matter really - The original offset is good enough + #ifdef __ADJUST_PS3_SCREEN_OFFSET__ + static constexpr auto PS3_CorrectionX = 2; + static constexpr auto PS3_CorrectionY = 1; + #else + static constexpr auto PS3_CorrectionX = 0; + static constexpr auto PS3_CorrectionY = 0; + #endif // __ADJUST_PS3_SCREEN_OFFSET__ + + x += (internal::Display::DisplayRange.x + Configuration::DisplayDefaultOffset.x); + y += (internal::Display::DisplayRange.y + Configuration::DisplayDefaultOffset.y); GPU_IO::GP1.write(GPU_IO::Command::HorizontalDisplayRange((x << 3), (x + Display::Width + PS3_CorrectionX) << 3)); GPU_IO::GP1.write(GPU_IO::Command::VerticalDisplayRange(y, y + Display::Height + PS3_CorrectionY)); diff --git a/src/Library/src/System/string.cpp b/src/Library/src/System/string.cpp index 593aecd5..fa264af1 100644 --- a/src/Library/src/System/string.cpp +++ b/src/Library/src/System/string.cpp @@ -57,7 +57,6 @@ static void* cplx_memset(void* dst, int val, size_t len) { } extern "C" { - // TODO: Speed measure void* memset(void* dest, int val, size_t len) { return simple_memset(dest, val, len); } diff --git a/src/Tools/psxcdgen_ex/src/encoder/builder.rs b/src/Tools/psxcdgen_ex/src/encoder/builder.rs index fa088c01..5b47dc6b 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/builder.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/builder.rs @@ -30,8 +30,6 @@ pub fn create_audio_for_vec(audio_samples: &Vec) -> Vec