diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 04ce97464..9152ed1b7 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -1103,32 +1103,29 @@ FORCEINLINE void rot_scale_op(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s const s32 dx = (s32)PA; const s32 dy = (s32)PC; - //not safe for 128 wide nonwrapping BG - //and probably not safe for other size nonwrapping BG which are scrolled near their edge - - //// as an optimization, specially handle the fairly common case of - //// "unrotated + unscaled + no boundary checking required" - //if(dx==0x100 && dy==0) - //{ - // s32 auxX = x.bits.Integer; - // if(WRAP || auxX + LG < wh) - // { - // s32 auxY = y.bits.Integer; - // if(WRAP) - // { - // auxY = auxY & (ht-1); - // auxX = auxX & (wh-1); - // } - // for(int i = 0; i < LG; ++i) - // { - // fun(gpu, auxX, auxY, wh, map, tile, pal, i); - // auxX++; - // if(WRAP) - // auxX = auxX & (wh-1); - // } - // return; - // } - //} + // as an optimization, specially handle the fairly common case of + // "unrotated + unscaled + no boundary checking required" + if(dx==0x100 && dy==0) + { + s32 auxX = x.bits.Integer; + s32 auxY = y.bits.Integer; + if(WRAP || (auxX + LG < wh && auxX >= 0 && auxY < ht && auxY >= 0)) + { + if(WRAP) + { + auxY = auxY & (ht-1); + auxX = auxX & (wh-1); + } + for(int i = 0; i < LG; ++i) + { + fun(gpu, auxX, auxY, wh, map, tile, pal, i); + auxX++; + if(WRAP) + auxX = auxX & (wh-1); + } + return; + } + } for(int i = 0; i < LG; ++i) {