From 3c710f33dd05b874de8c41456cd582a6a2b929cc Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 18 Feb 2016 20:38:48 +0000 Subject: [PATCH] Render3D: - In the OpenGL renderer, fix framebuffer color conversions on big-endian systems. - In SoftRasterizer, fix toon table coloring on big-endian systems. --- desmume/src/OGLRender.cpp | 20 ++++++++++---------- desmume/src/gfx3d.h | 4 ++-- desmume/src/rasterize.cpp | 8 -------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index da8d56232..53c1a0ff6 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -517,22 +517,22 @@ static const char *FramebufferOutputFragShader_100 = {"\ FORCEINLINE u32 BGRA8888_32_To_RGBA6665_32(const u32 srcPix) { - const u32 dstPix = (srcPix >> 2) & 0x3F3F3F3F; + const u32 dstPix = (srcPix >> 2); - return (dstPix & 0x0000FF00) << 16 | // R - (dstPix & 0x00FF0000) | // G - (dstPix & 0xFF000000) >> 16 | // B - ((dstPix >> 1) & 0x000000FF); // A + return (dstPix & 0x00003F00) << 16 | // R + (dstPix & 0x003F0000) | // G + (dstPix & 0x3F000000) >> 16 | // B + ((dstPix >> 1) & 0x0000001F); // A } FORCEINLINE u32 BGRA8888_32Rev_To_RGBA6665_32Rev(const u32 srcPix) { - const u32 dstPix = (srcPix >> 2) & 0x3F3F3F3F; + const u32 dstPix = (srcPix >> 2); - return (dstPix & 0x00FF0000) >> 16 | // R - (dstPix & 0x0000FF00) | // G - (dstPix & 0x000000FF) << 16 | // B - ((dstPix >> 1) & 0xFF000000); // A + return (dstPix & 0x003F0000) >> 16 | // R + (dstPix & 0x00003F00) | // G + (dstPix & 0x0000003F) << 16 | // B + ((dstPix >> 1) & 0x1F000000); // A } bool IsVersionSupported(unsigned int checkVersionMajor, unsigned int checkVersionMinor, unsigned int checkVersionRevision) diff --git a/desmume/src/gfx3d.h b/desmume/src/gfx3d.h index d047c6d8a..a1af4b724 100644 --- a/desmume/src/gfx3d.h +++ b/desmume/src/gfx3d.h @@ -520,7 +520,7 @@ struct POLY { #define POLYLIST_SIZE 20000 struct POLYLIST { POLY list[POLYLIST_SIZE]; - int count; + size_t count; }; //just a vert with a 4 float position @@ -588,7 +588,7 @@ struct VERT { #define VERTLIST_SIZE (POLYLIST_SIZE * 4) struct VERTLIST { VERT list[VERTLIST_SIZE]; - int count; + size_t count; }; #define INDEXLIST_SIZE (POLYLIST_SIZE * 4) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index eb296f244..3df312318 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -551,7 +551,6 @@ public: dst.b = modulate_table[mainTexColor.b][toonColor.b]; dst.a = modulate_table[GFX3D_5TO6(mainTexColor.a)][GFX3D_5TO6(src.a)] >> 1; } - } break; @@ -1845,14 +1844,7 @@ Render3DError SoftRasterizerRenderer::UpdateToonTable(const u16 *toonTableBuffer //convert the toon colors for (size_t i = 0; i < 32; i++) { -#ifdef WORDS_BIGENDIAN - u32 u32temp = RGB15TO32_NOALPHA(toonTableBuffer[i]); - this->toonColor32LUT[i].r = (u32temp >> 2) & 0x3F; - this->toonColor32LUT[i].g = (u32temp >> 10) & 0x3F; - this->toonColor32LUT[i].b = (u32temp >> 18) & 0x3F; -#else this->toonColor32LUT[i].color = (RGB15TO32_NOALPHA(toonTableBuffer[i])>>2)&0x3F3F3F3F; -#endif //printf("%d %d %d %d\n", this->toonColor32LUT[i].r, this->toonColor32LUT[i].g, this->toonColor32LUT[i].b, this->toonColor32LUT[i].a); }