From 37fb50eebe6c24108e5b63a7ed85a7219491fc0d Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 18 Sep 2022 20:57:20 +0200 Subject: [PATCH] Fix displaying the config menu on games which run in native 1080p --- source/utils/ConfigUtils.cpp | 7 +++++++ source/utils/DrawUtils.cpp | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source/utils/ConfigUtils.cpp b/source/utils/ConfigUtils.cpp index a4237e6..d7f72a6 100644 --- a/source/utils/ConfigUtils.cpp +++ b/source/utils/ConfigUtils.cpp @@ -537,6 +537,8 @@ void ConfigUtils::displayMenu() { } } +#define __SetDCPitchReg ((void (*)(uint32_t, uint32_t))(0x101C400 + 0x1e714)) + void ConfigUtils::openConfigMenu() { bool wasHomeButtonMenuEnabled = OSIsHomeButtonMenuEnabled(); @@ -547,6 +549,11 @@ void ConfigUtils::openConfigMenu() { void *screenbuffer0 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size, 0x100); void *screenbuffer1 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf1_size, 0x100); + // Fix the TV buffer pitch if a 1080p buffer is used. + if (screen_buf0_size == 0x00FD2000) { + __SetDCPitchReg(SCREEN_TV, 1920); + } + bool skipScreen0Free = false; bool skipScreen1Free = false; diff --git a/source/utils/DrawUtils.cpp b/source/utils/DrawUtils.cpp index 89bbe07..aab8517 100644 --- a/source/utils/DrawUtils.cpp +++ b/source/utils/DrawUtils.cpp @@ -78,10 +78,17 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t } } + uint32_t USED_TV_WIDTH = TV_WIDTH; + float scale = 1.5f; + if (DrawUtils::tvSize == 0x00FD2000) { + USED_TV_WIDTH = 1920; + scale = 2.25f; + } + // scale and put pixel in the tv buffer - for (uint32_t yy = (y * 1.5); yy < ((y * 1.5) + 1); yy++) { - for (uint32_t xx = (x * 1.5); xx < ((x * 1.5) + 1); xx++) { - uint32_t i = (xx + yy * TV_WIDTH) * 4; + for (uint32_t yy = (y * scale); yy < ((y * scale) + (uint32_t) scale); yy++) { + for (uint32_t xx = (x * scale); xx < ((x * scale) + (uint32_t) scale); xx++) { + uint32_t i = (xx + yy * USED_TV_WIDTH) * 4; if (i + 3 < tvSize / 2) { if (isBackBuffer) { i += tvSize / 2;