From 594b1316a6e693dea69a7ebd90207639cdbd80d3 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 26 Apr 2009 02:48:49 +0000 Subject: [PATCH] fix master brightness logic for parameters which are outside of the reasonable range. Fixes insane color warping during fades. --- desmume/src/GPU.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 6446f1149..292533b52 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -2906,11 +2906,12 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) u8 * dst = GPU_tempScreen + (screen->offset + l) * 512; u16 i16; - if (!gpu->MasterBrightFactor) return; + //isn't it odd that we can set uselessly high factors here? + //factors above 16 change nothing. curious. + int factor = gpu->MasterBrightFactor; + if(factor==0) return; + if(factor>16) factor=16; -#ifdef BRIGHT_TABLES - calc_bright_colors(); -#endif // Apply final brightness adjust (MASTER_BRIGHT) // Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS) @@ -2928,7 +2929,7 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) { for(i16 = 0; i16 < 256; ++i16) { - ((u16*)dst)[i16] = fadeInColors[gpu->MasterBrightFactor][((u16*)dst)[i16]&0x7FFF]; + ((u16*)dst)[i16] = fadeInColors[factor][((u16*)dst)[i16]&0x7FFF]; } break; } @@ -2938,7 +2939,7 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) { for(i16 = 0; i16 < 256; ++i16) { - ((u16*)dst)[i16] = fadeOutColors[gpu->MasterBrightFactor][((u16*)dst)[i16]&0x7FFF]; + ((u16*)dst)[i16] = fadeOutColors[factor][((u16*)dst)[i16]&0x7FFF]; } break; }