From d5565bad72ac05dd6d6fd8a260dada649e1fc1f8 Mon Sep 17 00:00:00 2001 From: rogerman Date: Sun, 29 Mar 2015 01:12:47 +0000 Subject: [PATCH] SoftRasterizer: - Do some code cleanup around GFX3D_TXTHack. Also make this check a little more robust. --- desmume/src/rasterize.cpp | 55 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index d03f62ee6..6c0faa664 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -416,7 +416,7 @@ public: bool enabled; int width, height; - int wmask, hmask; + s32 wmask, hmask; int wrap; int wshift; int texFormat; @@ -432,27 +432,27 @@ public: enabled = gfx3d.renderState.enableTexturing && (texFormat!=0); } - FORCEINLINE void clamp(int &val, const int size, const int sizemask){ + FORCEINLINE void clamp(s32 &val, const int size, const s32 sizemask){ if(val<0) val = 0; if(val>sizemask) val = sizemask; } - FORCEINLINE void hclamp(int &val) { clamp(val,width,wmask); } - FORCEINLINE void vclamp(int &val) { clamp(val,height,hmask); } + FORCEINLINE void hclamp(s32 &val) { clamp(val,width,wmask); } + FORCEINLINE void vclamp(s32 &val) { clamp(val,height,hmask); } - FORCEINLINE void repeat(int &val, const int size, const int sizemask) { + FORCEINLINE void repeat(s32 &val, const int size, const s32 sizemask) { val &= sizemask; } - FORCEINLINE void hrepeat(int &val) { repeat(val,width,wmask); } - FORCEINLINE void vrepeat(int &val) { repeat(val,height,hmask); } + FORCEINLINE void hrepeat(s32 &val) { repeat(val,width,wmask); } + FORCEINLINE void vrepeat(s32 &val) { repeat(val,height,hmask); } - FORCEINLINE void flip(int &val, const int size, const int sizemask) { + FORCEINLINE void flip(s32 &val, const int size, const s32 sizemask) { val &= ((size<<1)-1); if(val>=size) val = (size<<1)-val-1; } - FORCEINLINE void hflip(int &val) { flip(val,width,wmask); } - FORCEINLINE void vflip(int &val) { flip(val,height,hmask); } + FORCEINLINE void hflip(s32 &val) { flip(val,width,wmask); } + FORCEINLINE void vflip(s32 &val) { flip(val,height,hmask); } - FORCEINLINE void dowrap(int& iu, int& iv) + FORCEINLINE void dowrap(s32 &iu, s32 &iv) { switch(wrap) { //flip none @@ -486,25 +486,24 @@ public: //finally, we can use floor here. but, it is slower than we want. //the best solution is probably to wait until the pipeline is full of fixed point - - //add TXT Hack options - tkd3 - if(CommonSettings.GFX3D_TXTHack==false) + s32 iu = 0; + s32 iv = 0; + + if (!CommonSettings.GFX3D_TXTHack) { - s32 iu = s32floor(u); - s32 iv = s32floor(v); - sampler.dowrap(iu,iv); - FragmentColor color; - color.color = ((u32*)lastTexKey->decoded)[(iv<decoded)[(iv<decoded)[(iv<