From 4015411ad66f9a599307a7a19cc4b47a87de9682 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 3 Aug 2009 21:41:07 +0000 Subject: [PATCH] gpu: fix bug with 16color bg overdrawing line buffer by one pixel when scrolled to an odd offset. move assert x<256 lower in callstack to help spot these bugs more aggressively. --- desmume/src/GPU.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index f8f8f5f60..977500066 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -784,11 +784,10 @@ FORCEINLINE void GPU::__setFinalColorBck(u16 color, const u32 x, const int opaqu template FORCEINLINE void GPU::___setFinalColorBck(u16 color, const u32 x, const int opaque) { - //I commented out this line to make a point. //under ordinary circumstances, nobody should pass in something >=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. - //assert(x<256); + assert(debug || x<256); int x_int; @@ -960,9 +959,12 @@ template INLINE void renderline_textBG(GPU * gpu, u16 XBG, u16 YBG, x++; xoff++; } - color = T1ReadWord(pal, ((currLine&0xF) + tilePalette) << 1); - gpu->__setFinalColorBck(color,x,currLine&0xF); - x++; xoff++; + if(x__setFinalColorBck(color,x,currLine&0xF); + x++; xoff++; + } } } else { line += ((xoff&7)>>1); @@ -977,9 +979,12 @@ template INLINE void renderline_textBG(GPU * gpu, u16 XBG, u16 YBG, x++; xoff++; } - color = T1ReadWord(pal, ((currLine>>4) + tilePalette) << 1); - gpu->__setFinalColorBck(color,x,currLine>>4); - x++; xoff++; + if(x>4) + tilePalette) << 1); + gpu->__setFinalColorBck(color,x,currLine>>4); + x++; xoff++; + } } } }