From d66fd4ab85af926d05b75fec5ec0f2c66f1d5e31 Mon Sep 17 00:00:00 2001 From: luigi__ Date: Sun, 1 Feb 2009 00:24:03 +0000 Subject: [PATCH] Rewritten the incorrectly implemented setFinalBGColorSpecialIncreaseWnd and setFinalBGColorSpecialDecreaseWnd functions. This fixes the part 1 of the glitch #2488334 (SPP puzzle glitch). --- desmume/src/GPU.cpp | 68 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index dfb796741..b3a429744 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -431,9 +431,9 @@ u16 GPU::blend(u16 colA, u16 colB) void GPU_setMasterBrightness (GPU *gpu, u16 val) { - if(!nds.isInVblank()) { + if(!nds.isInVblank()) { PROGINFO("Changing master brightness outside of vblank\n"); - } + } gpu->MasterBrightFactor = (val & 0x1F); gpu->MasterBrightMode = (val>>14); } @@ -777,20 +777,21 @@ static void setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u8 *dst, u16 color, u8 gpu->renderline_checkWindows(x, windowDraw, windowEffect); - if (((gpu->BLDCNT >> gpu->currBgNum)&1) && windowEffect) // the bg to draw has a special color effect + if(windowDraw) { - if (gpu->BLDY_EVY != 0x0) - { // dont slow down if there is nothing to do - } - - T2WriteWord(dst, 0, color) ; - gpu->bgPixels[x] = gpu->currBgNum; - } - else - { - if ((windowEffect && (gpu->BLDCNT & (0x100 << gpu->currBgNum))) || windowDraw) + if((gpu->BLDCNT & (1 << gpu->currBgNum)) && windowEffect) { - T2WriteWord(dst, 0, color); + if (gpu->BLDY_EVY != 0x0) + { + color = fadeInColors[gpu->BLDY_EVY][color&0x7FFF]; + } + + T2WriteWord(dst, 0, (color | 0x8000)); + gpu->bgPixels[x] = gpu->currBgNum; + } + else + { + T2WriteWord(dst, 0, (color | 0x8000)); gpu->bgPixels[x] = gpu->currBgNum; } } @@ -802,20 +803,21 @@ static void setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u8 *dst, u16 color, u8 gpu->renderline_checkWindows(x, windowDraw, windowEffect); - if (((gpu->BLDCNT >> gpu->currBgNum)&1) && windowEffect) // the bg to draw has a special color effect + if(windowDraw) { - if (gpu->BLDY_EVY != 0x0) - { // dont slow down if there is nothing to do - color = (fadeOutColors[gpu->BLDY_EVY][color&0x7FFF] | 0x8000); - } - T2WriteWord(dst, 0, color) ; - gpu->bgPixels[x] = gpu->currBgNum; - } - else - { - if ((windowEffect && (gpu->BLDCNT & (0x100 << gpu->currBgNum))) || windowDraw) + if((gpu->BLDCNT & (1 << gpu->currBgNum)) && windowEffect) { - T2WriteWord(dst, 0, color); + if (gpu->BLDY_EVY != 0x0) + { + color = fadeOutColors[gpu->BLDY_EVY][color&0x7FFF]; + } + + T2WriteWord(dst, 0, (color | 0x8000)); + gpu->bgPixels[x] = gpu->currBgNum; + } + else + { + T2WriteWord(dst, 0, (color | 0x8000)); gpu->bgPixels[x] = gpu->currBgNum; } } @@ -1423,15 +1425,15 @@ static void setFinal3DColorSpecialDecreaseWnd(GPU *gpu, u32 passing, u8 *dst, u1 //overhead was ridiculous and terrible FORCEINLINE void GPU::__setFinalColorBck(u8 *dst, u16 color, u8 x, bool opaque) { - //I commented out this line to make a point. - //indeed, since x is a u8 we cannot pass in anything >=256 - //but in fact, someone is going to try. specifically, that is the map viewer debug tools - //which try to render the enter BG. in cases where that is large, it could be up to 1024 wide. - //I think it survives this truncation to 8bits. + //I commented out this line to make a point. + //indeed, since x is a u8 we cannot pass in anything >=256 + //but in fact, someone is going to try. specifically, that is the map viewer debug tools + //which try to render the enter BG. in cases where that is large, it could be up to 1024 wide. + //I think it survives this truncation to 8bits. //assert(x<256); - int x_int; - + int x_int; + //due to this early out, we will get incorrect behavior in cases where //we enable mosaic in the middle of a frame. this is deemed unlikely. if(!curr_mosaic_enabled) {