mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Fix tile load via gDPLoadBlock when amount of tile data is over TMEM size.
Fixed Tom & Jerry / PPG CHEMICAL X: texture issues #183
This commit is contained in:
parent
dae9796fff
commit
3fd958431a
2
N64.cpp
2
N64.cpp
|
@ -3,7 +3,7 @@
|
|||
u8 *HEADER;
|
||||
u8 *DMEM;
|
||||
u8 *IMEM;
|
||||
u64 TMEM[512];
|
||||
u64 TMEM[TMEM_SIZE];
|
||||
u8 *RDRAM;
|
||||
|
||||
u32 RDRAMSize;
|
||||
|
|
8
N64.h
8
N64.h
|
@ -5,6 +5,12 @@
|
|||
|
||||
#define MI_INTR_DP 0x20 // Bit 5: DP intr
|
||||
|
||||
// Actual TMEM size is 512 QWORDS. However, some load operations load more data that TMEM can take.
|
||||
// We can either cut the surplus data, or increase the buffer and load everything.
|
||||
// The second option is more simple and safe. Actual texture load will use correct TMEM size.
|
||||
#define TMEM_SIZE 1024
|
||||
#define TMEM_SIZE_BYTES 8192
|
||||
|
||||
struct N64Regs
|
||||
{
|
||||
u32 *MI_INTR;
|
||||
|
@ -39,7 +45,7 @@ extern u8 *HEADER;
|
|||
extern u8 *DMEM;
|
||||
extern u8 *IMEM;
|
||||
extern u8 *RDRAM;
|
||||
extern u64 TMEM[512];
|
||||
extern u64 TMEM[TMEM_SIZE];
|
||||
extern u32 RDRAMSize;
|
||||
|
||||
#endif
|
||||
|
|
12
gDP.cpp
12
gDP.cpp
|
@ -511,14 +511,14 @@ void gDPLoadTile(u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt)
|
|||
return;
|
||||
|
||||
const u32 bpl = gDP.loadTile->line << 3;
|
||||
if (((gDP.loadTile->tmem << 3) + height * bpl) > 4096) // Stay within TMEM
|
||||
if (((gDP.loadTile->tmem << 3) + height * bpl) > TMEM_SIZE_BYTES) // Stay within TMEM
|
||||
{
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_ERROR | DEBUG_TEXTURE, "// Attempting to load texture tile out of range\n" );
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadTile( %i, %i, %i, %i, %i );\n",
|
||||
tile, gDP.loadTile->uls, gDP.loadTile->ult, gDP.loadTile->lrs, gDP.loadTile->lrt );
|
||||
#endif
|
||||
height = (4096 - (gDP.loadTile->tmem << 3)) / bpl;
|
||||
height = (TMEM_SIZE_BYTES - (gDP.loadTile->tmem << 3)) / bpl;
|
||||
}
|
||||
|
||||
u32 bpl2 = bpl;
|
||||
|
@ -626,20 +626,18 @@ void gDPLoadBlock(u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt)
|
|||
info.loadType = LOADTYPE_BLOCK;
|
||||
|
||||
u32 bytes = (lrs - uls + 1) << gDP.loadTile->size >> 1;
|
||||
if (((gDP.loadTile->tmem << 3) + bytes) > TMEM_SIZE_BYTES) // Stay within TMEM
|
||||
bytes = TMEM_SIZE_BYTES - (gDP.loadTile->tmem << 3);
|
||||
if ((bytes & 7) != 0)
|
||||
bytes = (bytes & (~7)) + 8;
|
||||
u32 address = gDP.textureImage.address + ult * gDP.textureImage.bpl + (uls << gDP.textureImage.size >> 1);
|
||||
|
||||
if ((bytes == 0) ||
|
||||
((address + bytes) > RDRAMSize) ||
|
||||
(((gDP.loadTile->tmem << 3) + bytes) > 4096))
|
||||
{
|
||||
if (bytes == 0 || (address + bytes) > RDRAMSize) {
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_ERROR | DEBUG_TEXTURE, "// Attempting to load texture block out of range\n" );
|
||||
DebugMsg(DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadBlock( %i, %i, %i, %i, %i );\n",
|
||||
tile, uls, ult, lrs, dxt );
|
||||
#endif
|
||||
// bytes = min( bytes, min( RDRAMSize - gDP.textureImage.address, 4096 - (gDP.loadTile->tmem << 3) ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user