1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +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)
{
u32 tmp;
u32 p0, idx0, idx1;
while (numQWords--) {
tmp = src[srcIdx & srcMask];
src[srcIdx & srcMask] = src[(srcIdx + 1) & srcMask];
++srcIdx;
src[srcIdx & srcMask] = tmp;
++srcIdx;
idx0 = srcIdx++ & srcMask;
idx1 = srcIdx++ & srcMask;
p0 = src[idx0];
src[idx0] = src[idx1];
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!
else {
u32 tmemAddr = gDP.loadTile->tmem;
if (dxt > 0) {
const u32 widthInQWords = (bytes >> 3);
u32 height = (widthInQWords * dxt) / 2048;
if ((widthInQWords * dxt) % 2048 >= 1024)
++height;
u32 line = widthInQWords / height;
if (widthInQWords % height > height/2)
++line;
const u32 bpl = line << 3;
for (u32 y = 0; y < height; ++y) {
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bpl);
if (y & 1)
DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line);
address += bpl;
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bytes);
if (dxt != 0) {
u32 dxtCounter = 0;
u32 qwords = (bytes >> 3);
u32 line = 0;
while (true) {
do {
++tmemAddr;
--qwords;
if (qwords == 0)
goto end_dxt_test;
dxtCounter += dxt;
} while ((dxtCounter & 0x800) == 0);
do {
++line;
--qwords;
if (qwords == 0)
goto end_dxt_test;
dxtCounter += dxt;
} while ((dxtCounter & 0x800) != 0);
DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line);
tmemAddr += line;
line = 0;
}
} else
UnswapCopyWrap(RDRAM, address, (u8*)TMEM, tmemAddr << 3, 0xFFF, bytes);
end_dxt_test:
DWordInterleaveWrap((u32*)TMEM, tmemAddr << 1, 0x3FF, line);
}
}
#ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadBlock( %i, %i, %i, %i, %i );\n",