1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Correct _calculateCRC:

tile tmem address can be set to a value greater than 512, that is above TMEM size.
It should be used with proper mask for tileTmemInBytes calculation.

Fixed #2360 Castlevania 64 Crash
This commit is contained in:
Sergey Lipskiy 2020-11-10 15:41:35 +07:00
parent a11a0208c9
commit e81022ad71

View File

@ -1330,9 +1330,10 @@ u64 _calculateCRC(u32 _t, const TextureParams & _params, u32 _bytes)
if (rgba32)
_bytes >>= 1;
const u32 tMemMask = (gDP.otherMode.textureLUT == G_TT_NONE && !rgba32) ? 0x1FF : 0xFF;
const u64 *src = (u64*)&TMEM[gSP.textureTile[_t]->tmem & tMemMask];
const u32 tMem = gSP.textureTile[_t]->tmem & tMemMask;
const u64 *src = (u64*)&TMEM[tMem];
const u32 maxBytes = (tMemMask + 1) << 3;
const u32 tileTmemInBytes = gSP.textureTile[_t]->tmem << 3;
const u32 tileTmemInBytes = tMem << 3;
if (!rgba32 && (tileTmemInBytes + _bytes > maxBytes))
_bytes = maxBytes - tileTmemInBytes;
u64 crc = UINT64_MAX;