Fix MP1 & MP2 texture font issue. Not very robust but the general idea is there :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1401 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
42e485ba0b
commit
83e4bd2e5f
|
@ -62,10 +62,12 @@ int TexDecoder_GetTextureSizeInBytes(int width, int height, int format)
|
||||||
return (width * height * TexDecoder_GetTexelSizeInNibbles(format)) / 2;
|
return (width * height * TexDecoder_GetTexelSizeInNibbles(format)) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat)
|
u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat, u32 seed)
|
||||||
{
|
{
|
||||||
int sz = TexDecoder_GetTextureSizeInBytes(width, height, texformat);
|
int sz = TexDecoder_GetTextureSizeInBytes(width, height, texformat);
|
||||||
u32 hash = 0x1337c0de;
|
|
||||||
|
u32 hash = seed ? seed : 0x1337c0de;
|
||||||
|
|
||||||
if (sz < 2048) {
|
if (sz < 2048) {
|
||||||
for (int i = 0; i < sz / 4; i += 13) {
|
for (int i = 0; i < sz / 4; i += 13) {
|
||||||
hash = _rotl(hash, 17) ^ ((u32 *)src)[i];
|
hash = _rotl(hash, 17) ^ ((u32 *)src)[i];
|
||||||
|
|
|
@ -77,7 +77,8 @@ enum PC_TexFormat
|
||||||
|
|
||||||
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt);
|
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt);
|
||||||
|
|
||||||
u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat);
|
//u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat);
|
||||||
|
u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texformat, u32 seed=0);
|
||||||
|
|
||||||
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
||||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
|
|
||||||
|
// not very robust but this is a fast fix for MPs font issue.
|
||||||
|
// GX_TF_C4, GX_TF_C8, GX_TF_C14X2 use tlutaddr.
|
||||||
|
// So the other cases could be needed later.
|
||||||
|
u32 hashseed = format!=GX_TF_C4 ? 0 : *(u32*)(u16*)(texMem + tlutaddr);
|
||||||
|
|
||||||
int palSize = TexDecoder_GetPaletteSize(format);
|
int palSize = TexDecoder_GetPaletteSize(format);
|
||||||
u32 palhash = 0xc0debabe;
|
u32 palhash = 0xc0debabe;
|
||||||
|
|
||||||
|
@ -227,7 +232,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
|
|
||||||
u32 hash_value;
|
u32 hash_value;
|
||||||
if (g_Config.bSafeTextureCache)
|
if (g_Config.bSafeTextureCache)
|
||||||
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, format);
|
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, format, hashseed);
|
||||||
else
|
else
|
||||||
hash_value = ((u32 *)ptr)[entry.hashoffset];
|
hash_value = ((u32 *)ptr)[entry.hashoffset];
|
||||||
|
|
||||||
|
@ -271,7 +276,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
entry.paletteHash = palhash;
|
entry.paletteHash = palhash;
|
||||||
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
|
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
|
||||||
if (g_Config.bSafeTextureCache) {
|
if (g_Config.bSafeTextureCache) {
|
||||||
entry.hash = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, format);
|
entry.hash = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, format, hashseed);
|
||||||
} else {
|
} else {
|
||||||
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
|
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
|
||||||
((u32 *)ptr)[entry.hashoffset] = entry.hash;
|
((u32 *)ptr)[entry.hashoffset] = entry.hash;
|
||||||
|
|
Loading…
Reference in New Issue