1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Rewrite LoadBlock.

This commit is contained in:
Sergey Lipskiy 2016-03-26 21:14:42 +06:00
parent f3677db0a7
commit 06c99ad30f
2 changed files with 31 additions and 24 deletions

View File

@ -145,13 +145,13 @@ static inline void UnswapCopyWrap(const u8 *src, u32 srcIdx, u8 *dest, u32 destI
static inline void DWordInterleaveWrap(u32 *src, u32 srcIdx, u32 srcMask, u32 numQWords) static inline void DWordInterleaveWrap(u32 *src, u32 srcIdx, u32 srcMask, u32 numQWords)
{ {
u32 tmp; u32 p0, idx0, idx1;
while (numQWords--) { while (numQWords--) {
tmp = src[srcIdx & srcMask]; idx0 = srcIdx++ & srcMask;
src[srcIdx & srcMask] = src[(srcIdx + 1) & srcMask]; idx1 = srcIdx++ & srcMask;
++srcIdx; p0 = src[idx0];
src[srcIdx & srcMask] = tmp; src[idx0] = src[idx1];
++srcIdx; src[idx1] = p0;
} }
} }

View File

@ -623,26 +623,33 @@ void gDPLoadBlock(u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt)
memcpy(TMEM, &RDRAM[address], bytes); // HACK! memcpy(TMEM, &RDRAM[address], bytes); // HACK!
else { else {
u32 tmemAddr = gDP.loadTile->tmem; u32 tmemAddr = gDP.loadTile->tmem;
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bytes);
if (dxt > 0) { if (dxt != 0) {
const u32 widthInQWords = (bytes >> 3); u32 dxtCounter = 0;
u32 height = (widthInQWords * dxt) / 2048; u32 qwords = (bytes >> 3);
if ((widthInQWords * dxt) % 2048 >= 1024) u32 line = 0;
++height; while (true) {
u32 line = widthInQWords / height; do {
if (widthInQWords % height > height/2) ++tmemAddr;
++line; --qwords;
const u32 bpl = line << 3; if (qwords == 0)
goto end_dxt_test;
for (u32 y = 0; y < height; ++y) { dxtCounter += dxt;
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bpl); } while ((dxtCounter & 0x800) == 0);
if (y & 1) do {
DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line); ++line;
address += bpl; --qwords;
if (qwords == 0)
goto end_dxt_test;
dxtCounter += dxt;
} while ((dxtCounter & 0x800) != 0);
DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line);
tmemAddr += line; tmemAddr += line;
line = 0;
} }
} else end_dxt_test:
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bytes); DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line);
}
} }
#ifdef DEBUG #ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadBlock( %i, %i, %i, %i, %i );\n", DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadBlock( %i, %i, %i, %i, %i );\n",