From 4d93ddac4fbe6e8c6c65519854f30c24d58bfa56 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Mon, 1 Sep 2014 23:19:20 +0700 Subject: [PATCH] Use std min and max --- RSP.cpp | 5 ++++- Textures.cpp | 7 +++++-- gDP.cpp | 17 ++++++++++------- gSP.cpp | 3 +++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/RSP.cpp b/RSP.cpp index 9ef7518e..e42d0992 100644 --- a/RSP.cpp +++ b/RSP.cpp @@ -1,3 +1,4 @@ +#include #include "Debug.h" #include "RSP.h" #include "RDP.h" @@ -10,6 +11,8 @@ #include "GBI.h" #include "Config.h" +using namespace std; + RSPInfo RSP; void RSP_LoadMatrix( f32 mtx[4][4], u32 address ) @@ -130,7 +133,7 @@ void RSP_ProcessDList() RSP.halt = FALSE; RSP.busy = TRUE; - gSP.matrix.stackSize = min( 32, *(u32*)&DMEM[0x0FE4] >> 6 ); + gSP.matrix.stackSize = min( 32U, *(u32*)&DMEM[0x0FE4] >> 6 ); gSP.matrix.modelViewi = 0; gSP.changed &= ~CHANGED_CPU_FB_WRITE; gSP.changed |= CHANGED_MATRIX; diff --git a/Textures.cpp b/Textures.cpp index bafb6660..3f0b97f3 100644 --- a/Textures.cpp +++ b/Textures.cpp @@ -1,4 +1,5 @@ #include +#include #include "OpenGL.h" #include "Textures.h" #include "GBI.h" @@ -13,6 +14,8 @@ #include "Config.h" #include +using namespace std; + TextureCache cache; typedef u32 (*GetTexelFunc)( u64 *src, u16 x, u16 i, u8 palette ); @@ -497,13 +500,13 @@ void TextureCache_LoadBackground( CachedTexture *texInfo ) j = 0; for (y = 0; y < texInfo->realHeight; y++) { - ty = min(y, clampTClamp); + ty = min(y, (u32)clampTClamp); src = &swapped[bpl * ty]; for (x = 0; x < texInfo->realWidth; x++) { - tx = min(x, clampSClamp); + tx = min(x, (u32)clampSClamp); if (glInternalFormat == GL_RGBA) ((u32*)dest)[j++] = GetTexel( (u64*)src, tx, 0, texInfo->palette ); diff --git a/gDP.cpp b/gDP.cpp index fc9062b1..c33d0810 100644 --- a/gDP.cpp +++ b/gDP.cpp @@ -1,4 +1,5 @@ #include +#include #include "GLideN64.h" #include "N64.h" #include "GBI.h" @@ -17,6 +18,8 @@ #define DEPTH_CLEAR_COLOR 0xfffcfffc // The value usually used to clear depth buffer +using namespace std; + gDPInfo gDP; void gDPSetOtherMode( u32 mode0, u32 mode1 ) @@ -261,9 +264,9 @@ void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address ) u32 height = 1; if (width == VI.width) { if (width == gSP.viewport.width) - height = max(VI.height, gSP.viewport.height); + height = max((float)VI.height, gSP.viewport.height); else - height = max(VI.height, gDP.scissor.lry); + height = max((float)VI.height, gDP.scissor.lry); } else if (width == gDP.scissor.lrx && width == gSP.viewport.width) height = max(gDP.scissor.lry, gSP.viewport.height); else if (width == gDP.scissor.lrx) @@ -753,10 +756,10 @@ void gDPFillRDRAM(u32 address, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 width, u3 frameBuffer.top->cleared = true; frameBuffer.top->fillcolor = color; } - ulx = min(max(ulx, gDP.scissor.ulx), gDP.scissor.lrx); - lrx = min(max(lrx, gDP.scissor.ulx), gDP.scissor.lrx); - uly = min(max(uly, gDP.scissor.uly), gDP.scissor.lry); - lry = min(max(lry, gDP.scissor.uly), gDP.scissor.lry); + ulx = min(max((float)ulx, gDP.scissor.ulx), gDP.scissor.lrx); + lrx = min(max((float)lrx, gDP.scissor.ulx), gDP.scissor.lrx); + uly = min(max((float)uly, gDP.scissor.uly), gDP.scissor.lry); + lry = min(max((float)lry, gDP.scissor.uly), gDP.scissor.lry); u32 ci_width_in_dwords = width >> (3 - size); ulx >>= (3 - size); lrx >>= (3 - size); @@ -903,7 +906,7 @@ void gDPTextureRectangle( f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f gDP.colorImage.changed = TRUE; if (gDP.colorImage.width < 64) - gDP.colorImage.height = (u32)max( (s32)gDP.colorImage.height, lry ); + gDP.colorImage.height = (u32)max( (f32)gDP.colorImage.height, lry ); else gDP.colorImage.height = max( gDP.colorImage.height, (u32)gDP.scissor.lry ); diff --git a/gSP.cpp b/gSP.cpp index 32b6d495..45c47706 100644 --- a/gSP.cpp +++ b/gSP.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "N64.h" #include "GLideN64.h" #include "Debug.h" @@ -20,6 +21,8 @@ #include "Config.h" #include "Log.h" +using namespace std; + #ifdef DEBUG extern u32 uc_crc, uc_dcrc; extern char uc_str[256];