From 43e740c6615e57aa2fd30b4ef1b9fbed42964dfa Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 17 Oct 2017 18:49:05 -0700 Subject: [PATCH] GPU: Fix the clear color on big-endian systems when running RGB666 and RGB888. - Also endian swap the BGnX and BGnY values on big-endian systems. This is a non-functional change, and is only meant to show that the endian swaps are indeed the correct choice for big-endian. --- desmume/src/GPU.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index d568a5268..31f262c07 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -1617,11 +1617,11 @@ void GPUEngineBase::_RenderLine_Clear(GPUEngineCompositorInfo &compInfo) break; case NDSColorFormat_BGR666_Rev: - memset_u32_fast(*compInfo.target.lineColor, COLOR555TO666(dstClearColor16)); + memset_u32_fast(*compInfo.target.lineColor, COLOR555TO666(LOCAL_TO_LE_16(dstClearColor16))); break; case NDSColorFormat_BGR888_Rev: - memset_u32_fast(*compInfo.target.lineColor, COLOR555TO888(dstClearColor16)); + memset_u32_fast(*compInfo.target.lineColor, COLOR555TO888(LOCAL_TO_LE_16(dstClearColor16))); break; } @@ -2927,17 +2927,21 @@ void GPUEngineBase::_RenderPixelIterate_Final(GPUEngineCompositorInfo &compInfo, const s32 wmask = wh - 1; const s32 hmask = ht - 1; - IOREG_BGnX x = param.BGnX; - IOREG_BGnY y = param.BGnY; + IOREG_BGnX x; + IOREG_BGnY y; + x.value = LOCAL_TO_LE_32(param.BGnX.value); + y.value = LOCAL_TO_LE_32(param.BGnY.value); #ifdef MSB_FIRST - // This only seems to work in the unrotated/unscaled case. I'm not too sure - // about how these bits should really be arranged on big-endian, but at - // least this arrangement fixes a bunch of games that use affine or extended - // layers, just as long as they don't perform any rotation/scaling. - // - rogerman, 2016-07-05 - x.value = ((x.value & 0x00FFFFFF) << 8) | ((x.value & 0xFF000000) >> 24); - y.value = ((y.value & 0x00FFFFFF) << 8) | ((y.value & 0xFF000000) >> 24); + // This only seems to work in the unrotated/unscaled case. + // + // All the working values should be correct on big-endian, but there is something else wrong going + // on somewhere else, but that remains a mystery at this time. In the meantime, this hack will have + // to remain in order to fix a bunch of games that use affine or extended layers, just as long as + // they don't perform any rotation/scaling. + // - rogerman, 2017-10-17 + x.value = ((x.value & 0xFF000000) >> 16) | (x.value & 0x00FF00FF) | ((x.value & 0x0000FF00) << 16); + y.value = ((y.value & 0xFF000000) >> 16) | (y.value & 0x00FF00FF) | ((y.value & 0x0000FF00) << 16); #endif u8 index;