diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index ba81e9290..96b5f699c 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -2987,9 +2987,10 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE)); - u32 *textureSrc = (u32 *)currTexture->decoded; - size_t texWidth = currTexture->sizeX; - size_t texHeight = currTexture->sizeY; + const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat(); + const u32 *textureSrc = (u32 *)this->currTexture->decoded; + size_t texWidth = this->currTexture->sizeX; + size_t texHeight = this->currTexture->sizeY; if (this->_textureDeposterizeBuffer != NULL) { @@ -3010,10 +3011,10 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } @@ -3022,15 +3023,15 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2); - this->TextureUpscale<4>(textureSrc, texWidth, texHeight); + this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - texWidth = currTexture->sizeX; - texHeight = currTexture->sizeY; - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + texWidth = this->currTexture->sizeX; + texHeight = this->currTexture->sizeY; + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } @@ -4637,9 +4638,10 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE)); - u32 *textureSrc = (u32 *)currTexture->decoded; - size_t texWidth = currTexture->sizeX; - size_t texHeight = currTexture->sizeY; + const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat(); + const u32 *textureSrc = (u32 *)this->currTexture->decoded; + size_t texWidth = this->currTexture->sizeX; + size_t texHeight = this->currTexture->sizeY; if (this->_textureDeposterizeBuffer != NULL) { @@ -4660,10 +4662,10 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } @@ -4672,15 +4674,15 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2); - this->TextureUpscale<4>(textureSrc, texWidth, texHeight); + this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - texWidth = currTexture->sizeX; - texHeight = currTexture->sizeY; - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + texWidth = this->currTexture->sizeX; + texHeight = this->currTexture->sizeY; + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index 163a7cf04..7c48721b9 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -1716,9 +1716,10 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE)); - u32 *textureSrc = (u32 *)currTexture->decoded; - size_t texWidth = currTexture->sizeX; - size_t texHeight = currTexture->sizeY; + const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat(); + const u32 *textureSrc = (u32 *)this->currTexture->decoded; + size_t texWidth = this->currTexture->sizeX; + size_t texHeight = this->currTexture->sizeY; if (this->_textureDeposterizeBuffer != NULL) { @@ -1739,10 +1740,10 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } @@ -1751,15 +1752,15 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2); - this->TextureUpscale<4>(textureSrc, texWidth, texHeight); + this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - texWidth = currTexture->sizeX; - texHeight = currTexture->sizeY; - this->TextureUpscale<2>(textureSrc, texWidth, texHeight); + texWidth = this->currTexture->sizeX; + texHeight = this->currTexture->sizeY; + this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight); glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer); - glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); + glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc); break; } diff --git a/desmume/src/filter/xbrz.cpp b/desmume/src/filter/xbrz.cpp index b434ac1ca..16dd3923d 100644 --- a/desmume/src/filter/xbrz.cpp +++ b/desmume/src/filter/xbrz.cpp @@ -43,8 +43,6 @@ #define COLOR_MASK_G 0x0000FF00 #define COLOR_MASK_B 0x000000FF -#define USE_DESMUME_TEXTURE_UPSCALE_ALPHA_BLEND - namespace { template inline @@ -80,7 +78,6 @@ uint32_t gradientRGB(uint32_t pixFront, uint32_t pixBack) //blend front color wi gradientRGB_calcColor(getBlue (pixFront), getBlue (pixBack))); } - template inline uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!) { @@ -90,25 +87,10 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c const unsigned int weightBack = getAlpha(pixBack) * (N - M); const unsigned int weightSum = weightFront + weightBack; -#ifdef USE_DESMUME_TEXTURE_UPSCALE_ALPHA_BLEND - if (weightSum == 0) - { - return (pixFront & 0x00FFFFFF); - } - else if (weightFront == 0) - { - return pixBack; - } - else if (weightBack == 0) - { - return pixFront; - } -#else if (weightSum == 0) { return 0; } -#endif /* auto calcColor = [=](unsigned char colFront, unsigned char colBack) @@ -122,6 +104,39 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c gradientARGB_calcColor(getBlue (pixFront), getBlue (pixBack), weightFront, weightBack, weightSum)); } +template inline +uint32_t gradientARGB_1bitAlpha(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!) +{ + //static_assert(0 < M && M < N && N <= 1000, ""); + + const unsigned int weightFront = getAlpha(pixFront) * M; + const unsigned int weightBack = getAlpha(pixBack) * (N - M); + const unsigned int weightSum = weightFront + weightBack; + + if (weightSum == 0) + { + return (pixFront & 0x00FFFFFF); + } + else if (weightFront == 0) + { + return pixBack; + } + else if (weightBack == 0) + { + return pixFront; + } + + /* + auto calcColor = [=](unsigned char colFront, unsigned char colBack) + { + return static_cast((colFront * weightFront + colBack * weightBack) / weightSum); + }; + */ + return makePixel(static_cast(weightSum / N), + gradientARGB_calcColor(getRed (pixFront), getRed (pixBack), weightFront, weightBack, weightSum), + gradientARGB_calcColor(getGreen(pixFront), getGreen(pixBack), weightFront, weightBack, weightSum), + gradientARGB_calcColor(getBlue (pixFront), getBlue (pixBack), weightFront, weightBack, weightSum)); +} //inline //double fastSqrt(double n) @@ -1184,6 +1199,15 @@ struct ColorGradientARGB pixBack = gradientARGB(pixFront, pixBack); } }; + +struct ColorGradientARGB_1bitAlpha +{ + template + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) + { + pixBack = gradientARGB_1bitAlpha(pixFront, pixBack); + } +}; } template @@ -1191,6 +1215,22 @@ void xbrz::scale(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight { switch (FORMAT) { + case ColorFormatARGB_1bitAlpha: + switch (SCALEFACTOR) + { + case 2: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + break; + case ColorFormatARGB: switch (SCALEFACTOR) { @@ -1340,3 +1380,5 @@ void Render6xBRZ(SSurface Src, SSurface Dst) template void xbrz::scale<2, xbrz::ColorFormatARGB>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast); template void xbrz::scale<4, xbrz::ColorFormatARGB>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast); +template void xbrz::scale<2, xbrz::ColorFormatARGB_1bitAlpha>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast); +template void xbrz::scale<4, xbrz::ColorFormatARGB_1bitAlpha>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast); diff --git a/desmume/src/filter/xbrz.h b/desmume/src/filter/xbrz.h index 97338e70f..c48102ce2 100644 --- a/desmume/src/filter/xbrz.h +++ b/desmume/src/filter/xbrz.h @@ -54,6 +54,7 @@ enum ColorFormat //from high bits -> low bits, 8 bit per channel { ColorFormatRGB, //8 bit for each red, green, blue, upper 8 bits unused ColorFormatARGB, //including alpha channel, BGRA byte order on little-endian machines + ColorFormatARGB_1bitAlpha // special alpha blending mode for NDS 1-bit alpha textures }; /* diff --git a/desmume/src/gfx3d.h b/desmume/src/gfx3d.h index 1ea92219f..0a4da3273 100644 --- a/desmume/src/gfx3d.h +++ b/desmume/src/gfx3d.h @@ -185,7 +185,7 @@ enum }; // TEXTURE PARAMETERS - FORMAT ID -enum +enum NDSTextureFormat { TEXMODE_NONE = 0, TEXMODE_A3I5 = 1, diff --git a/desmume/src/render3D.cpp b/desmume/src/render3D.cpp index 0b6e23c07..3f1f5128d 100644 --- a/desmume/src/render3D.cpp +++ b/desmume/src/render3D.cpp @@ -546,14 +546,21 @@ Render3DError Render3D::TextureDeposterize(const u32 *src, const size_t srcTexWi } template -Render3DError Render3D::TextureUpscale(const u32 *src, size_t &outTexWidth, size_t &outTexHeight) +Render3DError Render3D::TextureUpscale(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight) { if ( (SCALEFACTOR != 2) && (SCALEFACTOR != 4) ) { return RENDER3DERROR_NOERR; } - xbrz::scale(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight); + if (texFormat == TEXMODE_A3I5 || texFormat == TEXMODE_A5I3) + { + xbrz::scale(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight); + } + else + { + xbrz::scale(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight); + } outTexWidth *= SCALEFACTOR; outTexHeight *= SCALEFACTOR; @@ -984,5 +991,5 @@ Render3DError Render3D_SSE2::ClearFramebuffer(const GFX3D_State &renderState) #endif // ENABLE_SSE2 -template Render3DError Render3D::TextureUpscale<2>(const u32 *src, size_t &outTexWidth, size_t &outTexHeight); -template Render3DError Render3D::TextureUpscale<4>(const u32 *src, size_t &outTexWidth, size_t &outTexHeight); +template Render3DError Render3D::TextureUpscale<2>(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight); +template Render3DError Render3D::TextureUpscale<4>(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight); diff --git a/desmume/src/render3D.h b/desmume/src/render3D.h index 372c4f741..dd64ff99a 100644 --- a/desmume/src/render3D.h +++ b/desmume/src/render3D.h @@ -139,7 +139,7 @@ protected: CACHE_ALIGN u8 clearImagePolyIDBuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; Render3DError TextureDeposterize(const u32 *src, const size_t srcTexWidth, const size_t srcTexHeight); - template Render3DError TextureUpscale(const u32 *src, size_t &outTexWidth, size_t &outTexHeight); + template Render3DError TextureUpscale(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight); virtual Render3DError BeginRender(const GFX3D &engine); virtual Render3DError RenderGeometry(const GFX3D_State &renderState, const POLYLIST *polyList, const INDEXLIST *indexList); diff --git a/desmume/src/texcache.cpp b/desmume/src/texcache.cpp index c05352a39..a936a5c1e 100644 --- a/desmume/src/texcache.cpp +++ b/desmume/src/texcache.cpp @@ -245,7 +245,7 @@ public: //used to hold a copy of the palette specified for this texture CACHE_ALIGN u16 pal[256]; - u32 textureMode = (unsigned short)((format>>26)&0x07); + NDSTextureFormat textureMode = (NDSTextureFormat)((format>>26)&0x07); u32 sizeX=(8 << ((format>>20)&0x07)); u32 sizeY=(8 << ((format>>23)&0x07)); u32 imageSize = sizeX*sizeY; @@ -256,18 +256,19 @@ public: switch (textureMode) { - case TEXMODE_I2: - paletteAddress = texpal<<3; - break; - case TEXMODE_A3I5: //a3i5 - case TEXMODE_I4: //i4 - case TEXMODE_I8: //i8 - case TEXMODE_A5I3: //a5i3 - case TEXMODE_16BPP: //16bpp - case TEXMODE_4X4: //4x4 - default: - paletteAddress = texpal<<4; - break; + case TEXMODE_I2: + paletteAddress = texpal<<3; + break; + + case TEXMODE_A3I5: + case TEXMODE_I4: + case TEXMODE_I8: + case TEXMODE_A5I3: + case TEXMODE_16BPP: + case TEXMODE_4X4: + default: + paletteAddress = texpal<<4; + break; } //analyze the texture memory mapping and the specifications of this texture @@ -373,7 +374,7 @@ public: newitem->invSizeX=1.0f/((float)(sizeX)); newitem->invSizeY=1.0f/((float)(sizeY)); newitem->decode_len = sizeX*sizeY*4; - newitem->mode = textureMode; + newitem->format = textureMode; newitem->decoded = (u8 *)malloc_alignedCacheLine(newitem->decode_len); list_push_front(newitem); //printf("allocating: up to %d with %d items\n",cache_size,index.size()); @@ -405,7 +406,7 @@ public: const bool isPalZeroTransparent = ( ((format >> 29) & 1) != 0 ); - switch (newitem->mode) + switch (newitem->format) { case TEXMODE_A3I5: { @@ -934,6 +935,9 @@ public: } break; } + + default: + break; } //switch(texture format) #ifdef DO_DEBUG_DUMP_TEXTURE @@ -953,19 +957,19 @@ public: //but this will work for now MemSpan mspal = MemSpan_TexPalette(0,PALETTE_DUMP_SIZE,true); bool paletteDirty = mspal.memcmp(paletteDump); - if(paletteDirty) + if (paletteDirty) { mspal.dump(paletteDump); } - for(TTexCacheItemMultimap::iterator it(index.begin()); it != index.end(); ++it) + for (TTexCacheItemMultimap::iterator it(index.begin()); it != index.end(); ++it) { it->second->suspectedInvalid = true; //when the palette changes, we assume all 4x4 textures are dirty. //this is because each 4x4 item doesnt carry along with it a copy of the entire palette, for verification //instead, we just use the one paletteDump for verifying of all 4x4 textures; and if paletteDirty is set, verification has failed - if(it->second->getTextureMode() == TEXMODE_4X4 && paletteDirty) + if( (it->second->GetTextureFormat() == TEXMODE_4X4) && paletteDirty ) { it->second->assumedInvalid = true; } diff --git a/desmume/src/texcache.h b/desmume/src/texcache.h index 3afa37c43..02b88df19 100644 --- a/desmume/src/texcache.h +++ b/desmume/src/texcache.h @@ -24,6 +24,7 @@ #include "types.h" #include "common.h" +#include "gfx3d.h" enum TexCache_TexFormat { @@ -62,13 +63,13 @@ public: if (this->_deleteCallback != NULL) this->_deleteCallback(this, this->_deleteCallbackParam1, this->_deleteCallbackParam2); } u32 decode_len; - u32 mode; + NDSTextureFormat format; u8* decoded; //decoded texture data bool suspectedInvalid; bool assumedInvalid; TTexCacheItemMultimap::iterator iterator; - int getTextureMode() const { return (int)((texformat>>26)&0x07); } + NDSTextureFormat GetTextureFormat() const { return this->format; } u32 texformat, texpal; u32 sizeX, sizeY;