From cc180fa2044c52b992a829e32c8df881d8e90baa Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Sun, 21 Jul 2013 18:44:04 -0700 Subject: [PATCH] Add type safe getter for texture and clut format fields. --- GPU/GLES/TextureCache.cpp | 8 ++++---- GPU/GPUState.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 695dff455f..3933b92c19 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -206,9 +206,9 @@ static u32 GetClutAddr() { } static u32 GetClutIndex(u32 index) { - const u32 clutBase = (gstate.clutformat & 0x1f0000) >> 12; - const u32 clutMask = (gstate.clutformat >> 8) & 0xff; - const u8 clutShift = (gstate.clutformat >> 2) & 0x1f; + const u32 clutBase = gstate.getClutIndexStartPos(); + const u32 clutMask = gstate.getClutIndexMask(); + const u8 clutShift = gstate.getClutIndexShift(); return ((index >> clutShift) & clutMask) | clutBase; } @@ -831,7 +831,7 @@ void TextureCache::LoadClut() { } void TextureCache::UpdateCurrentClut() { - const GEPaletteFormat clutFormat = (GEPaletteFormat)(gstate.clutformat & 3); + const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat(); const u32 clutBase = (gstate.clutformat & 0x1f0000) >> 12; const u32 clutBaseBytes = clutBase * (clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16)); // Technically, these extra bytes weren't loaded, but hopefully it was loaded earlier. diff --git a/GPU/GPUState.h b/GPU/GPUState.h index c8d9ecc982..30347bce7e 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -217,11 +217,13 @@ struct GPUgstate bool isTextureMapEnabled() const { return textureMapEnable & 1; } int getTextureFunction() const { return texfunc & 0x7; } bool isColorDoublingEnabled() const { return (texfunc & 0x10000) != 0; } + GETextureFormat getTextureFormat() const { return static_cast(texformat & 0xF); } int getTextureEnvColR() const { return texenvcolor&0xFF; } int getTextureEnvColG() const { return (texenvcolor>>8)&0xFF; } int getTextureEnvColB() const { return (texenvcolor>>16)&0xFF; } + GEPaletteFormat getClutPaletteFormat() { return static_cast(clutformat & 3); } int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; } int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; } int getClutIndexStartPos() const { return ((clutformat >> 16) & 0x1F) << 4; }