From b1293926832f62a287e3c0de6245998bb6b3b8ed Mon Sep 17 00:00:00 2001 From: rogerman Date: Mon, 4 Jul 2016 00:13:36 +0000 Subject: [PATCH] Render3D: - Fix some coloring issues on big-endian systems brought about by the recent changes to the colorspace conversion code. (Regression from r5455.) --- desmume/src/cocoa/cocoa_rom.mm | 16 ++++++++-------- desmume/src/rasterize.cpp | 3 +-- desmume/src/render3D.cpp | 7 ++++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/desmume/src/cocoa/cocoa_rom.mm b/desmume/src/cocoa/cocoa_rom.mm index a987e61c7..d671da76c 100644 --- a/desmume/src/cocoa/cocoa_rom.mm +++ b/desmume/src/cocoa/cocoa_rom.mm @@ -719,28 +719,28 @@ void RomIconToRGBA8888(uint32_t *bitmapData) // Set the RGBA8888 bitmap pixels using our CLUT from earlier. #ifdef __BIG_ENDIAN__ - *bitmapPixPtr = clut[(pixRowColors & 0x0F000000) >> 24]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x0F000000) >> 24]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0xF0000000) >> 28]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0xF0000000) >> 28]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x000F0000) >> 16]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x000F0000) >> 16]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x00F00000) >> 20]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x00F00000) >> 20]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x00000F00) >> 8]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x00000F00) >> 8]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x0000F000) >> 12]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x0000F000) >> 12]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x0000000F)]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x0000000F)]); bitmapPixPtr++; - *bitmapPixPtr = clut[(pixRowColors & 0x000000F0) >> 4]; + *bitmapPixPtr = LOCAL_TO_LE_32(clut[(pixRowColors & 0x000000F0) >> 4]); #else diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 38e27fa1d..49646a848 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -1839,8 +1839,7 @@ Render3DError SoftRasterizerRenderer::UpdateToonTable(const u16 *toonTableBuffer //convert the toon colors for (size_t i = 0; i < 32; i++) { - this->toonColor32LUT[i].color = ( COLOR555TO888(toonTableBuffer[i] & 0x7FFF) >> 2 ) & 0x003F3F3F; - //printf("%d %d %d %d\n", this->toonColor32LUT[i].r, this->toonColor32LUT[i].g, this->toonColor32LUT[i].b, this->toonColor32LUT[i].a); + this->toonColor32LUT[i].color = COLOR555TO666(toonTableBuffer[i] & 0x7FFF); } return RENDER3DERROR_NOERR; diff --git a/desmume/src/render3D.cpp b/desmume/src/render3D.cpp index 4a460ed1e..0b6e23c07 100644 --- a/desmume/src/render3D.cpp +++ b/desmume/src/render3D.cpp @@ -635,11 +635,12 @@ Render3DError Render3D::ClearFramebuffer(const GFX3D_State &renderState) { Render3DError error = RENDER3DERROR_NOERR; + const u32 clearColorSwapped = LE_TO_LOCAL_32(renderState.clearColor); FragmentColor clearColor6665; - clearColor6665.color = COLOR555TO6665(renderState.clearColor & 0x7FFF, (renderState.clearColor >> 16) & 0x1F); + clearColor6665.color = COLOR555TO6665(clearColorSwapped & 0x7FFF, (clearColorSwapped >> 16) & 0x1F); FragmentAttributes clearFragment; - clearFragment.opaquePolyID = (renderState.clearColor >> 24) & 0x3F; + clearFragment.opaquePolyID = (clearColorSwapped >> 24) & 0x3F; //special value for uninitialized translucent polyid. without this, fires in spiderman2 dont display //I am not sure whether it is right, though. previously this was cleared to 0, as a guess, //but in spiderman2 some fires with polyid 0 try to render on top of the background @@ -647,7 +648,7 @@ Render3DError Render3D::ClearFramebuffer(const GFX3D_State &renderState) clearFragment.depth = renderState.clearDepth; clearFragment.stencil = 0; clearFragment.isTranslucentPoly = 0; - clearFragment.isFogged = BIT15(renderState.clearColor); + clearFragment.isFogged = BIT15(clearColorSwapped); if (renderState.enableClearImage) {