Add type safe getter for texture and clut format fields.

This commit is contained in:
Florent Castelli 2013-07-21 18:44:04 -07:00 committed by Unknown W. Brackets
parent a70220a1d5
commit cc180fa204
2 changed files with 6 additions and 4 deletions

View File

@ -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.

View File

@ -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<GETextureFormat>(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<GEPaletteFormat>(clutformat & 3); }
int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; }
int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; }
int getClutIndexStartPos() const { return ((clutformat >> 16) & 0x1F) << 4; }