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

Fix load hires textures.

Fixed 2 zelda oot problems #1521
This commit is contained in:
Sergey Lipskiy 2017-11-02 22:59:18 +07:00
parent b4ad1832c4
commit d1bf2e3979

View File

@ -901,21 +901,36 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
gDPLoadTileInfo & info = gDP.loadInfo[_pTexture->tMem];
int bpl;
int width, height;
u8 * addr = (u8*)(RDRAM + info.texAddress);
int tile_width = _pTexture->width;
int tile_height = _pTexture->height;
if (info.loadType == LOADTYPE_TILE) {
bpl = info.texWidth << info.size >> 1;
addr += (info.ult * bpl) + (((info.uls << info.size) + 1) >> 1);
tile_width = min(info.width, info.texWidth);
width = min(info.width, info.texWidth);
if (info.size > _pTexture->size)
tile_width <<= info.size - _pTexture->size;
width <<= info.size - _pTexture->size;
tile_height = info.height;
if ((config.generalEmulation.hacks & hack_MK64) != 0 && (tile_height % 2) != 0)
tile_height--;
height = info.height;
if ((config.generalEmulation.hacks & hack_MK64) != 0 && (height % 2) != 0)
height--;
} else {
int tile_width = gDP.tiles[_tile].lrs - gDP.tiles[_tile].uls + 1;
int tile_height = gDP.tiles[_tile].lrt - gDP.tiles[_tile].ult + 1;
int mask_width = (gDP.tiles[_tile].masks == 0) ? (tile_width) : (1 << gDP.tiles[_tile].masks);
int mask_height = (gDP.tiles[_tile].maskt == 0) ? (tile_height) : (1 << gDP.tiles[_tile].maskt);
if ((gDP.tiles[_tile].clamps && tile_width <= 256))
width = min(mask_width, tile_width);
else
width = mask_width;
if ((gDP.tiles[_tile].clampt && tile_height <= 256) || (mask_height > 256))
height = min(mask_height, tile_height);
else
height = mask_height;
if (gSP.textureTile[_tile]->size == G_IM_SIZ_32b)
bpl = gSP.textureTile[_tile]->line << 4;
else if (info.dxt == 0)
@ -941,7 +956,7 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
// palette = (rdp.pal_8 + (gSP.textureTile[_t]->palette << 4));
}
_ricecrc = txfilter_checksum(addr, tile_width, tile_height, (unsigned short)(_pTexture->format << 8 | _pTexture->size), bpl, paladdr);
_ricecrc = txfilter_checksum(addr, width, height, (unsigned short)(_pTexture->format << 8 | _pTexture->size), bpl, paladdr);
GHQTexInfo ghqTexInfo;
// TODO: fix problem with zero texture dimensions on GLideNHQ side.
if (txfilter_hirestex(_pTexture->crc, _ricecrc, palette, &ghqTexInfo) &&
@ -959,7 +974,7 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
params.data = ghqTexInfo.data;
gfxContext.init2DTexture(params);
assert(!gfxContext.isError());
_updateCachedTexture(ghqTexInfo, _pTexture, ghqTexInfo.width / tile_width);
_updateCachedTexture(ghqTexInfo, _pTexture, ghqTexInfo.width / width);
return true;
}