From e6bc02330179db649ad49b370945f5812b85c1b4 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 29 Oct 2009 05:20:49 +0000 Subject: [PATCH] fix warnings and more gcc pedantic errors --- desmume/src/OGLRender.cpp | 2 +- desmume/src/metaspu/SndOut.h | 484 +++++++++++++++++------------------ desmume/src/rasterize.cpp | 13 +- desmume/src/texcache.h | 2 +- 4 files changed, 250 insertions(+), 251 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 87d6d173c..df0a2d43c 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -562,7 +562,7 @@ static void setTexture(unsigned int format, unsigned int texpal) { currTexture->deleteCallback = texDeleteCallback; if(freeTextureIds.empty()) expandFreeTextures(); - currTexture->texid = (u32)freeTextureIds.front(); + currTexture->texid = (u64)freeTextureIds.front(); freeTextureIds.pop(); glBindTexture(GL_TEXTURE_2D,(GLuint)currTexture->texid); diff --git a/desmume/src/metaspu/SndOut.h b/desmume/src/metaspu/SndOut.h index a24c699dd..65252cbe0 100644 --- a/desmume/src/metaspu/SndOut.h +++ b/desmume/src/metaspu/SndOut.h @@ -147,248 +147,248 @@ struct StereoOutFloat } }; -struct Stereo21Out16 -{ - s16 Left; - s16 Right; - s16 LFE; - - void ResampleFrom( const StereoOut32& src ) - { - Left = src.Left >> SndOutVolumeShift; - Right = src.Right >> SndOutVolumeShift; - LFE = (src.Left + src.Right) >> (SndOutVolumeShift + 1); - } -}; - -struct StereoQuadOut16 -{ - s16 Left; - s16 Right; - s16 LeftBack; - s16 RightBack; - - void ResampleFrom( const StereoOut32& src ) - { - Left = src.Left >> SndOutVolumeShift; - Right = src.Right >> SndOutVolumeShift; - LeftBack = src.Left >> SndOutVolumeShift; - RightBack = src.Right >> SndOutVolumeShift; - } -}; - -struct Stereo41Out16 -{ - s16 Left; - s16 Right; - s16 LFE; - s16 LeftBack; - s16 RightBack; - - void ResampleFrom( const StereoOut32& src ) - { - Left = src.Left >> SndOutVolumeShift; - Right = src.Right >> SndOutVolumeShift; - LFE = (src.Left + src.Right) >> (SndOutVolumeShift + 1); - LeftBack = src.Left >> SndOutVolumeShift; - RightBack = src.Right >> SndOutVolumeShift; - } -}; - -struct Stereo51Out16 -{ - s16 Left; - s16 Right; - s16 Center; - s16 LFE; - s16 LeftBack; - s16 RightBack; - - // Implementation Note: Center and Subwoofer/LFE --> - // This method is simple and sounds nice. It relies on the speaker/soundcard - // systems do to their own low pass / crossover. Manual lowpass is wasted effort - // and can't match solid state results anyway. - - void ResampleFrom( const StereoOut32& src ) - { - Left = src.Left >> SndOutVolumeShift; - Right = src.Right >> SndOutVolumeShift; - Center = (src.Left + src.Right) >> (SndOutVolumeShift + 1); - LFE = Center; - LeftBack = src.Left >> SndOutVolumeShift; - RightBack = src.Right >> SndOutVolumeShift; - } -}; - -struct Stereo51Out16DplII -{ - s16 Left; - s16 Right; - s16 Center; - s16 LFE; - s16 LeftBack; - s16 RightBack; - - void ResampleFrom( const StereoOut32& src ) - { - static const u8 sLogTable[256] = { - 0x00,0x3C,0x60,0x78,0x8C,0x9C,0xA8,0xB4,0xBE,0xC8,0xD0,0xD8,0xDE,0xE4,0xEA,0xF0, - 0xF6,0xFA,0xFE,0x04,0x08,0x0C,0x10,0x14,0x16,0x1A,0x1E,0x20,0x24,0x26,0x2A,0x2C, - 0x2E,0x32,0x34,0x36,0x38,0x3A,0x3E,0x40,0x42,0x44,0x46,0x48,0x4A,0x4C,0x4E,0x50, - 0x50,0x52,0x54,0x56,0x58,0x5A,0x5A,0x5C,0x5E,0x60,0x60,0x62,0x64,0x66,0x66,0x68, - 0x6A,0x6A,0x6C,0x6E,0x6E,0x70,0x70,0x72,0x74,0x74,0x76,0x76,0x78,0x7A,0x7A,0x7C, - 0x7C,0x7E,0x7E,0x80,0x80,0x82,0x82,0x84,0x84,0x86,0x86,0x88,0x88,0x8A,0x8A,0x8C, - 0x8C,0x8C,0x8E,0x8E,0x90,0x90,0x92,0x92,0x92,0x94,0x94,0x96,0x96,0x96,0x98,0x98, - 0x9A,0x9A,0x9A,0x9C,0x9C,0x9C,0x9E,0x9E,0xA0,0xA0,0xA0,0xA2,0xA2,0xA2,0xA4,0xA4, - 0xA4,0xA6,0xA6,0xA6,0xA8,0xA8,0xA8,0xAA,0xAA,0xAA,0xAC,0xAC,0xAC,0xAC,0xAE,0xAE, - 0xAE,0xB0,0xB0,0xB0,0xB2,0xB2,0xB2,0xB2,0xB4,0xB4,0xB4,0xB6,0xB6,0xB6,0xB6,0xB8, - 0xB8,0xB8,0xB8,0xBA,0xBA,0xBA,0xBC,0xBC,0xBC,0xBC,0xBE,0xBE,0xBE,0xBE,0xC0,0xC0, - 0xC0,0xC0,0xC2,0xC2,0xC2,0xC2,0xC2,0xC4,0xC4,0xC4,0xC4,0xC6,0xC6,0xC6,0xC6,0xC8, - 0xC8,0xC8,0xC8,0xC8,0xCA,0xCA,0xCA,0xCA,0xCC,0xCC,0xCC,0xCC,0xCC,0xCE,0xCE,0xCE, - 0xCE,0xCE,0xD0,0xD0,0xD0,0xD0,0xD0,0xD2,0xD2,0xD2,0xD2,0xD2,0xD4,0xD4,0xD4,0xD4, - 0xD4,0xD6,0xD6,0xD6,0xD6,0xD6,0xD8,0xD8,0xD8,0xD8,0xD8,0xD8,0xDA,0xDA,0xDA,0xDA, - 0xDA,0xDC,0xDC,0xDC,0xDC,0xDC,0xDC,0xDE,0xDE,0xDE,0xDE,0xDE,0xDE,0xE0,0xE0,0xE0, - }; - - static s32 Gfl=0,Gfr=0; - static s32 LMax=0,RMax=0; - - static s32 LAccum; - static s32 RAccum; - static s32 ANum; - - s32 ValL = src.Left >> (SndOutVolumeShift-8); - s32 ValR = src.Right >> (SndOutVolumeShift-8); - - s32 XL = abs(ValL>>8); - s32 XR = abs(ValR>>8); - - if(XL>LMax) LMax = XL; - if(XR>RMax) RMax = XR; - - ANum++; - if(ANum>=128) - { - ANum=0; - LAccum = 1+((LAccum * 224 + LMax * 31)>>8); - RAccum = 1+((RAccum * 224 + RMax * 31)>>8); - - LMax = 0; - RMax = 0; - - s32 Tfl=(RAccum)*255/(LAccum); - s32 Tfr=(LAccum)*255/(RAccum); - - int gMax = std::max(Tfl,Tfr); - Tfl = Tfl*255/gMax; - Tfr = Tfr*255/gMax; - - if(Tfl>255) Tfl=255; - if(Tfr>255) Tfr=255; - if(Tfl<1) Tfl=1; - if(Tfr<1) Tfr=1; - - Gfl = (Gfl * 200 + Tfl * 56)>>8; - Gfr = (Gfr * 200 + Tfr * 56)>>8; - - } - - s32 L,R,C,SUB,SL,SR; - - C=(ValL+ValR)>>1; //16.8 - - ValL-=C;//16.8 - ValR-=C;//16.8 - - L=ValL>>8; //16.0 - R=ValR>>8; //16.0 - C=C>>8; //16.0 - SUB = C; - - { - s32 Cfl = 1+sLogTable[Gfl]; - s32 Cfr = 1+sLogTable[Gfr]; - - s32 VL=(ValL>>4) * Cfl; //16.12 - s32 VR=(ValR>>4) * Cfr; - - //s32 SC = (VL-VR)>>15; - - SL = (((VR/148 - VL/209)>>4)*Cfr)>>8; - SR = (((VR/209 - VL/148)>>4)*Cfl)>>8; - - } - - // Random-ish values to get it to compile - int GainL = 200; - int GainR = 200; - int GainC = 180; - int GainSL = 230; - int GainSR = 230; - int GainLFE = 200; - int AddCLR = 55; - - int AddCX = (C * AddCLR)>>8; - - Left = (((L * GainL ))>>8) + AddCX; - Right = (((R * GainR ))>>8) + AddCX; - Center = (((C * GainC ))>>8); - LFE = (((SUB * GainLFE))>>8); - LeftBack = (((SL * GainSL ))>>8); - RightBack = (((SR * GainSR ))>>8); - } -}; - -struct Stereo71Out16 -{ - s16 Left; - s16 Right; - s16 Center; - s16 LFE; - s16 LeftBack; - s16 RightBack; - s16 LeftSide; - s16 RightSide; - - void ResampleFrom( const StereoOut32& src ) - { - Left = src.Left >> SndOutVolumeShift; - Right = src.Right >> SndOutVolumeShift; - Center = (src.Left + src.Right) >> (SndOutVolumeShift + 1); - LFE = Center; - LeftBack = src.Left >> SndOutVolumeShift; - RightBack = src.Right >> SndOutVolumeShift; - - LeftSide = src.Left >> (SndOutVolumeShift+1); - RightSide = src.Right >> (SndOutVolumeShift+1); - } -}; - -struct Stereo21Out32 -{ - s32 Left; - s32 Right; - s32 LFE; -}; - -struct Stereo41Out32 -{ - s32 Left; - s32 Right; - s32 LFE; - s32 LeftBack; - s32 RightBack; -}; - -struct Stereo51Out32 -{ - s32 Left; - s32 Right; - s32 Center; - s32 LFE; - s32 LeftBack; - s32 RightBack; -}; +//struct Stereo21Out16 +//{ +// s16 Left; +// s16 Right; +// s16 LFE; +// +// void ResampleFrom( const StereoOut32& src ) +// { +// Left = src.Left >> SndOutVolumeShift; +// Right = src.Right >> SndOutVolumeShift; +// LFE = (src.Left + src.Right) >> (SndOutVolumeShift + 1); +// } +//}; +// +//struct StereoQuadOut16 +//{ +// s16 Left; +// s16 Right; +// s16 LeftBack; +// s16 RightBack; +// +// void ResampleFrom( const StereoOut32& src ) +// { +// Left = src.Left >> SndOutVolumeShift; +// Right = src.Right >> SndOutVolumeShift; +// LeftBack = src.Left >> SndOutVolumeShift; +// RightBack = src.Right >> SndOutVolumeShift; +// } +//}; +// +//struct Stereo41Out16 +//{ +// s16 Left; +// s16 Right; +// s16 LFE; +// s16 LeftBack; +// s16 RightBack; +// +// void ResampleFrom( const StereoOut32& src ) +// { +// Left = src.Left >> SndOutVolumeShift; +// Right = src.Right >> SndOutVolumeShift; +// LFE = (src.Left + src.Right) >> (SndOutVolumeShift + 1); +// LeftBack = src.Left >> SndOutVolumeShift; +// RightBack = src.Right >> SndOutVolumeShift; +// } +//}; +// +//struct Stereo51Out16 +//{ +// s16 Left; +// s16 Right; +// s16 Center; +// s16 LFE; +// s16 LeftBack; +// s16 RightBack; +// +// // Implementation Note: Center and Subwoofer/LFE --> +// // This method is simple and sounds nice. It relies on the speaker/soundcard +// // systems do to their own low pass / crossover. Manual lowpass is wasted effort +// // and can't match solid state results anyway. +// +// void ResampleFrom( const StereoOut32& src ) +// { +// Left = src.Left >> SndOutVolumeShift; +// Right = src.Right >> SndOutVolumeShift; +// Center = (src.Left + src.Right) >> (SndOutVolumeShift + 1); +// LFE = Center; +// LeftBack = src.Left >> SndOutVolumeShift; +// RightBack = src.Right >> SndOutVolumeShift; +// } +//}; +// +//struct Stereo51Out16DplII +//{ +// s16 Left; +// s16 Right; +// s16 Center; +// s16 LFE; +// s16 LeftBack; +// s16 RightBack; +// +// void ResampleFrom( const StereoOut32& src ) +// { +// static const u8 sLogTable[256] = { +// 0x00,0x3C,0x60,0x78,0x8C,0x9C,0xA8,0xB4,0xBE,0xC8,0xD0,0xD8,0xDE,0xE4,0xEA,0xF0, +// 0xF6,0xFA,0xFE,0x04,0x08,0x0C,0x10,0x14,0x16,0x1A,0x1E,0x20,0x24,0x26,0x2A,0x2C, +// 0x2E,0x32,0x34,0x36,0x38,0x3A,0x3E,0x40,0x42,0x44,0x46,0x48,0x4A,0x4C,0x4E,0x50, +// 0x50,0x52,0x54,0x56,0x58,0x5A,0x5A,0x5C,0x5E,0x60,0x60,0x62,0x64,0x66,0x66,0x68, +// 0x6A,0x6A,0x6C,0x6E,0x6E,0x70,0x70,0x72,0x74,0x74,0x76,0x76,0x78,0x7A,0x7A,0x7C, +// 0x7C,0x7E,0x7E,0x80,0x80,0x82,0x82,0x84,0x84,0x86,0x86,0x88,0x88,0x8A,0x8A,0x8C, +// 0x8C,0x8C,0x8E,0x8E,0x90,0x90,0x92,0x92,0x92,0x94,0x94,0x96,0x96,0x96,0x98,0x98, +// 0x9A,0x9A,0x9A,0x9C,0x9C,0x9C,0x9E,0x9E,0xA0,0xA0,0xA0,0xA2,0xA2,0xA2,0xA4,0xA4, +// 0xA4,0xA6,0xA6,0xA6,0xA8,0xA8,0xA8,0xAA,0xAA,0xAA,0xAC,0xAC,0xAC,0xAC,0xAE,0xAE, +// 0xAE,0xB0,0xB0,0xB0,0xB2,0xB2,0xB2,0xB2,0xB4,0xB4,0xB4,0xB6,0xB6,0xB6,0xB6,0xB8, +// 0xB8,0xB8,0xB8,0xBA,0xBA,0xBA,0xBC,0xBC,0xBC,0xBC,0xBE,0xBE,0xBE,0xBE,0xC0,0xC0, +// 0xC0,0xC0,0xC2,0xC2,0xC2,0xC2,0xC2,0xC4,0xC4,0xC4,0xC4,0xC6,0xC6,0xC6,0xC6,0xC8, +// 0xC8,0xC8,0xC8,0xC8,0xCA,0xCA,0xCA,0xCA,0xCC,0xCC,0xCC,0xCC,0xCC,0xCE,0xCE,0xCE, +// 0xCE,0xCE,0xD0,0xD0,0xD0,0xD0,0xD0,0xD2,0xD2,0xD2,0xD2,0xD2,0xD4,0xD4,0xD4,0xD4, +// 0xD4,0xD6,0xD6,0xD6,0xD6,0xD6,0xD8,0xD8,0xD8,0xD8,0xD8,0xD8,0xDA,0xDA,0xDA,0xDA, +// 0xDA,0xDC,0xDC,0xDC,0xDC,0xDC,0xDC,0xDE,0xDE,0xDE,0xDE,0xDE,0xDE,0xE0,0xE0,0xE0, +// }; +// +// static s32 Gfl=0,Gfr=0; +// static s32 LMax=0,RMax=0; +// +// static s32 LAccum; +// static s32 RAccum; +// static s32 ANum; +// +// s32 ValL = src.Left >> (SndOutVolumeShift-8); +// s32 ValR = src.Right >> (SndOutVolumeShift-8); +// +// s32 XL = abs(ValL>>8); +// s32 XR = abs(ValR>>8); +// +// if(XL>LMax) LMax = XL; +// if(XR>RMax) RMax = XR; +// +// ANum++; +// if(ANum>=128) +// { +// ANum=0; +// LAccum = 1+((LAccum * 224 + LMax * 31)>>8); +// RAccum = 1+((RAccum * 224 + RMax * 31)>>8); +// +// LMax = 0; +// RMax = 0; +// +// s32 Tfl=(RAccum)*255/(LAccum); +// s32 Tfr=(LAccum)*255/(RAccum); +// +// int gMax = std::max(Tfl,Tfr); +// Tfl = Tfl*255/gMax; +// Tfr = Tfr*255/gMax; +// +// if(Tfl>255) Tfl=255; +// if(Tfr>255) Tfr=255; +// if(Tfl<1) Tfl=1; +// if(Tfr<1) Tfr=1; +// +// Gfl = (Gfl * 200 + Tfl * 56)>>8; +// Gfr = (Gfr * 200 + Tfr * 56)>>8; +// +// } +// +// s32 L,R,C,SUB,SL,SR; +// +// C=(ValL+ValR)>>1; //16.8 +// +// ValL-=C;//16.8 +// ValR-=C;//16.8 +// +// L=ValL>>8; //16.0 +// R=ValR>>8; //16.0 +// C=C>>8; //16.0 +// SUB = C; +// +// { +// s32 Cfl = 1+sLogTable[Gfl]; +// s32 Cfr = 1+sLogTable[Gfr]; +// +// s32 VL=(ValL>>4) * Cfl; //16.12 +// s32 VR=(ValR>>4) * Cfr; +// +// //s32 SC = (VL-VR)>>15; +// +// SL = (((VR/148 - VL/209)>>4)*Cfr)>>8; +// SR = (((VR/209 - VL/148)>>4)*Cfl)>>8; +// +// } +// +// // Random-ish values to get it to compile +// int GainL = 200; +// int GainR = 200; +// int GainC = 180; +// int GainSL = 230; +// int GainSR = 230; +// int GainLFE = 200; +// int AddCLR = 55; +// +// int AddCX = (C * AddCLR)>>8; +// +// Left = (((L * GainL ))>>8) + AddCX; +// Right = (((R * GainR ))>>8) + AddCX; +// Center = (((C * GainC ))>>8); +// LFE = (((SUB * GainLFE))>>8); +// LeftBack = (((SL * GainSL ))>>8); +// RightBack = (((SR * GainSR ))>>8); +// } +//}; +// +//struct Stereo71Out16 +//{ +// s16 Left; +// s16 Right; +// s16 Center; +// s16 LFE; +// s16 LeftBack; +// s16 RightBack; +// s16 LeftSide; +// s16 RightSide; +// +// void ResampleFrom( const StereoOut32& src ) +// { +// Left = src.Left >> SndOutVolumeShift; +// Right = src.Right >> SndOutVolumeShift; +// Center = (src.Left + src.Right) >> (SndOutVolumeShift + 1); +// LFE = Center; +// LeftBack = src.Left >> SndOutVolumeShift; +// RightBack = src.Right >> SndOutVolumeShift; +// +// LeftSide = src.Left >> (SndOutVolumeShift+1); +// RightSide = src.Right >> (SndOutVolumeShift+1); +// } +//}; +// +//struct Stereo21Out32 +//{ +// s32 Left; +// s32 Right; +// s32 LFE; +//}; +// +//struct Stereo41Out32 +//{ +// s32 Left; +// s32 Right; +// s32 LFE; +// s32 LeftBack; +// s32 RightBack; +//}; +// +//struct Stereo51Out32 +//{ +// s32 Left; +// s32 Right; +// s32 Center; +// s32 LFE; +// s32 LeftBack; +// s32 RightBack; +//}; // Developer Note: This is a static class only (all static members). class SndBuffer diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 4918ca689..94643d7a5 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -341,9 +341,10 @@ public: int SLI_MASK, SLI_VALUE; RasterizerUnit() - : sampler(*this) + : sampler() , shader(sampler) { + sampler.unit = this; } ADPCMCacheItem* lastTexKey; @@ -397,11 +398,9 @@ public: struct Sampler { - Sampler(RasterizerUnit& _unit) - : unit(_unit) - {} + Sampler() {} - RasterizerUnit& unit; + RasterizerUnit* unit; int width, height; int wmask, hmask; @@ -474,7 +473,7 @@ public: dowrap(iu,iv); FragmentColor color; - color.color = ((u32*)unit.lastTexKey->decoded)[(iv<lastTexKey->decoded)[(iv<(); return 0; } diff --git a/desmume/src/texcache.h b/desmume/src/texcache.h index f55933be1..d8dd8f6ac 100644 --- a/desmume/src/texcache.h +++ b/desmume/src/texcache.h @@ -44,7 +44,7 @@ public: u32 sizeX, sizeY; float invSizeX, invSizeY; - u32 texid; //used by ogl renderer for the texid + u64 texid; //used by ogl renderer for the texid void (*deleteCallback)(ADPCMCacheItem*); TexCache_TexFormat cacheFormat;