From f6be5fd39fdcc9fd992087303138f9b2cff7dfe0 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 17 Mar 2016 09:29:57 +0600 Subject: [PATCH] Fix bug with line calculation in gDPLoadBlock. Fixed South Park Rally (All) - Gfx Issue #391 and probably other similar issues. --- src/gDP.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gDP.cpp b/src/gDP.cpp index 660797ab..4959cadb 100644 --- a/src/gDP.cpp +++ b/src/gDP.cpp @@ -625,9 +625,10 @@ void gDPLoadBlock(u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt) u32 tmemAddr = gDP.loadTile->tmem; if (dxt > 0) { - u32 line = (2047 + dxt) / dxt; - u32 bpl = line << 3; - u32 height = bytes / bpl; + const u32 widthInQWords = (bytes >> 3); + const u32 height = (widthInQWords * dxt) / 2048; + const u32 line = widthInQWords / height; + const u32 bpl = line << 3; for (u32 y = 0; y < height; ++y) { UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bpl);