Skip to content

Commit

Permalink
Correct C++ implementation of RiceCRC32.
Browse files Browse the repository at this point in the history
Fixed incorrect checksum calculation for textures with small width or height,
see Super Smash Bros. buggy dumps #2317
  • Loading branch information
gonetz committed Mar 2, 2024
1 parent c3ee03d commit 2f59b2a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/GLideNHQ/TxUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,22 @@ TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStri
}
#else
int y = height - 1;
while (y >= 0)
{
do {
uint32 esi = 0;
int x = bytesPerLine - 4;
while (x >= 0)
{
do {
esi = *(uint32*)(src + x);
esi ^= x;

crc32Ret = (crc32Ret << 4) + ((crc32Ret >> 28) & 15);
crc32Ret += esi;
x -= 4;
}
} while (x >= 0);
esi ^= y;
crc32Ret += esi;
src += rowStride;
--y;
}
} while (y >= 0);
#endif
} catch(...) {
DBG_INFO(80, wst("Error: RiceCRC32 exception!\n"));
Expand Down

0 comments on commit 2f59b2a

Please sign in to comment.