From ee754e7edf0b9955bfa73e9e53171c453348f794 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 31 Mar 2016 13:04:57 -0400 Subject: [PATCH] Made static variables that inline asm needs to touch non-static. I dislike having to do this, but Clang sees them as unused and removes them from the object file, causing linking to fail. The real solution here is to remove all the assembly code because it's 2016 and this game doesn't have to run on 133MHz Pentium now. :) --- Sources/Engine/Graphics/Graphics.cpp | 60 +++++++++------------- Sources/Engine/Graphics/TextureEffects.cpp | 51 +++++++++--------- Sources/Engine/Light/LayerMixer.cpp | 50 +++++++++--------- 3 files changed, 75 insertions(+), 86 deletions(-) diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index 73cf443..b3efc05 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -626,19 +626,19 @@ static ULONG ulDither2[4][4] = { }; -static __int64 mmErrDiffMask=0; +__int64 mmErrDiffMask=0; #if (defined __GNUC__) -static __int64 mmW3 = 0x0003000300030003ll; -static __int64 mmW5 = 0x0005000500050005ll; -static __int64 mmW7 = 0x0007000700070007ll; +__int64 mmW3 = 0x0003000300030003ll; +__int64 mmW5 = 0x0005000500050005ll; +__int64 mmW7 = 0x0007000700070007ll; #else -static __int64 mmW3 = 0x0003000300030003; -static __int64 mmW5 = 0x0005000500050005; -static __int64 mmW7 = 0x0007000700070007; +__int64 mmW3 = 0x0003000300030003; +__int64 mmW5 = 0x0005000500050005; +__int64 mmW7 = 0x0007000700070007; #endif -static __int64 mmShift = 0; -static __int64 mmMask = 0; -static ULONG *pulDitherTable; +__int64 mmShift = 0; +__int64 mmMask = 0; +ULONG *pulDitherTable; // performs dithering of a 32-bit bipmap (can be in-place) void DitherBitmap( INDEX iDitherType, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PIX pixHeight, @@ -1132,35 +1132,23 @@ static INDEX aiFilters[6][3] = { { 1, 1, 1 }}; // // temp for middle pixels, vertical/horizontal edges, and corners -static __int64 mmMc, mmMe, mmMm; // corner, edge, middle -static __int64 mmEch, mmEm; // corner-high, middle +__int64 mmMc, mmMe, mmMm; // corner, edge, middle +__int64 mmEch, mmEm; // corner-high, middle #define mmEcl mmMc // corner-low #define mmEe mmMe // edge -static __int64 mmCm; // middle +__int64 mmCm; // middle #define mmCc mmMc // corner #define mmCe mmEch // edge -static __int64 mmInvDiv; +__int64 mmInvDiv; #if (defined __GNUC__) -static __int64 mmAdd = 0x0007000700070007ll; +__int64 mmAdd = 0x0007000700070007ll; #else -static __int64 mmAdd = 0x0007000700070007; +__int64 mmAdd = 0x0007000700070007; #endif // temp rows for in-place filtering support -extern "C" { static ULONG aulRows[2048]; } - -static void *force_syms_to_exist = NULL; -void asm_force_mmAdd() { force_syms_to_exist = &mmAdd; } -void asm_force_aulRows() { force_syms_to_exist = &aulRows; } -void asm_force_mmMc() { force_syms_to_exist = &mmMc; } -void asm_force_mmMe() { force_syms_to_exist = &mmMe; } -void asm_force_mmMm() { force_syms_to_exist = &mmMm; } -void asm_force_mmEch() { force_syms_to_exist = &mmEch; } -void asm_force_mmEm() { force_syms_to_exist = &mmEm; } -void asm_force_mmW3() { force_syms_to_exist = &mmW3; } -void asm_force_mmW5() { force_syms_to_exist = &mmW5; } -void asm_force_mmW7() { force_syms_to_exist = &mmW7; } +extern "C" { ULONG aulRows[2048]; } // FilterBitmap() INTERNAL: generates convolution filter matrix if needed static INDEX iLastFilter; @@ -1199,13 +1187,13 @@ static void GenerateConvolutionMatrix( INDEX iFilter) extern "C" { - static ULONG *FB_pulSrc = NULL; - static ULONG *FB_pulDst = NULL; - static PIX FB_pixWidth = 0; - static PIX FB_pixHeight = 0; - static PIX FB_pixCanvasWidth = 0; - static SLONG FB_slModulo1 = 0; - static SLONG FB_slCanvasWidth = 0; + ULONG *FB_pulSrc = NULL; + ULONG *FB_pulDst = NULL; + PIX FB_pixWidth = 0; + PIX FB_pixHeight = 0; + PIX FB_pixCanvasWidth = 0; + SLONG FB_slModulo1 = 0; + SLONG FB_slCanvasWidth = 0; } diff --git a/Sources/Engine/Graphics/TextureEffects.cpp b/Sources/Engine/Graphics/TextureEffects.cpp index a4543fe..61cc1ef 100644 --- a/Sources/Engine/Graphics/TextureEffects.cpp +++ b/Sources/Engine/Graphics/TextureEffects.cpp @@ -29,12 +29,12 @@ #define ASMOPT 0 #endif -static __int64 mmBaseWidthShift=0; -static __int64 mmBaseWidth=0; -static __int64 mmBaseWidthMask=0; -static __int64 mmBaseHeightMask=0; -static __int64 mmBaseMasks=0; -static __int64 mmShift=0; +__int64 mmBaseWidthShift=0; +__int64 mmBaseWidth=0; +__int64 mmBaseWidthMask=0; +__int64 mmBaseHeightMask=0; +__int64 mmBaseMasks=0; +__int64 mmShift=0; #if (defined __GNUC__) /* @@ -42,12 +42,12 @@ static __int64 mmShift=0; * builds with optimization, which means the linker can't resolve the * references to them in the inline ASM. That's obnoxious. */ -static __int64 mm1LO = 0x0000000000000001ll; -static __int64 mm1HI = 0x0000000100000000ll; -static __int64 mm1HILO = 0x0000000100000001ll; -static __int64 mm0001 = 0x0000000000000001ll; -static __int64 mm0010 = 0x0000000000010000ll; -static __int64 mm00M0 = 0x00000000FFFF0000ll; +__int64 mm1LO = 0x0000000000000001ll; +__int64 mm1HI = 0x0000000100000000ll; +__int64 mm1HILO = 0x0000000100000001ll; +__int64 mm0001 = 0x0000000000000001ll; +__int64 mm0010 = 0x0000000000010000ll; +__int64 mm00M0 = 0x00000000FFFF0000ll; static void *force_syms_to_exist = NULL; void asm_force_mm1LO() { force_syms_to_exist = &mm1LO; } @@ -64,30 +64,31 @@ void asm_force_mmBaseMasks() { force_syms_to_exist = &mmBaseMasks; } void asm_force_mmShift() { force_syms_to_exist = &mmShift; } #else -static const __int64 mm1LO = 0x0000000000000001; -static const __int64 mm1HI = 0x0000000100000000; -static const __int64 mm1HILO = 0x0000000100000001; -static const __int64 mm0001 = 0x0000000000000001; -static const __int64 mm0010 = 0x0000000000010000; -static const __int64 mm00M0 = 0x00000000FFFF0000; +const __int64 mm1LO = 0x0000000000000001; +const __int64 mm1HI = 0x0000000100000000; +const __int64 mm1HILO = 0x0000000100000001; +const __int64 mm0001 = 0x0000000000000001; +const __int64 mm0010 = 0x0000000000010000; +const __int64 mm00M0 = 0x00000000FFFF0000; #endif // speed table -static SBYTE asbMod3Sub1Table[256]; +SBYTE asbMod3Sub1Table[256]; static BOOL bTableSet = FALSE; static CTextureData *_ptdEffect, *_ptdBase; -static PIX _pixTexWidth, _pixTexHeight; -static PIX _pixBufferWidth, _pixBufferHeight; static ULONG _ulBufferMask; static INDEX _iWantedMipLevel; static UBYTE *_pubDrawBuffer; static SWORD *_pswDrawBuffer; +PIX _pixTexWidth, _pixTexHeight; +PIX _pixBufferWidth, _pixBufferHeight; + // randomizer -static ULONG ulRNDSeed; +ULONG ulRNDSeed; inline void Randomize( ULONG ulSeed) { @@ -1240,8 +1241,8 @@ static void AnimateWater( SLONG slDensity) #define PIXEL(u,v) pulTextureBase[ ((u)&(SLONG&)mmBaseWidthMask) + ((v)&(SLONG&)mmBaseHeightMask) *pixBaseWidth] -static ULONG _slHeightMapStep_renderWater = 0; -static PIX _pixBaseWidth_renderWater = 0; +ULONG _slHeightMapStep_renderWater = 0; +PIX _pixBaseWidth_renderWater = 0; #pragma warning(disable: 4731) static void RenderWater(void) @@ -3039,7 +3040,7 @@ pixDone: //////////////////////////// displace texture -static UBYTE *_pubHeat_RenderPlasmaFire = NULL; +UBYTE *_pubHeat_RenderPlasmaFire = NULL; static void RenderPlasmaFire(void) { diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index e776ce5..bfbbec2 100644 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -241,25 +241,25 @@ void CLayerMixer::FindLayerMipmap( CBrushShadowLayer *pbsl, UBYTE *&pub, UBYTE & #define FTOX 0x10000000 #define SHIFTX (28-SQRTTABLESIZELOG2) -// static variables for easier transfers -static const FLOAT3D *_vLight; -static FLOAT _fMinLightDistance; -static FLOAT _f1oFallOff; -static INDEX _iPixCt; -static INDEX _iRowCt; -static SLONG _slModulo; -static ULONG _ulLightFlags; -static ULONG _ulPolyFlags; -static SLONG _slL2Row; -static SLONG _slDDL2oDU; -static SLONG _slDDL2oDV; -static SLONG _slDDL2oDUoDV; -static SLONG _slDL2oDURow; -static SLONG _slDL2oDV; -static SLONG _slLightMax; -static SLONG _slHotSpot; -static SLONG _slLightStep; -static ULONG *_pulLayer; +// variables for easier transfers +const FLOAT3D *_vLight; +FLOAT _fMinLightDistance; +FLOAT _f1oFallOff; +INDEX _iPixCt; +INDEX _iRowCt; +SLONG _slModulo; +ULONG _ulLightFlags; +ULONG _ulPolyFlags; +SLONG _slL2Row; +SLONG _slDDL2oDU; +SLONG _slDDL2oDV; +SLONG _slDDL2oDUoDV; +SLONG _slDL2oDURow; +SLONG _slDL2oDV; +SLONG _slLightMax; +SLONG _slHotSpot; +SLONG _slLightStep; +ULONG *_pulLayer; // !!! FIXME : rcg01072001 These statics are a pain in the ass. @@ -472,8 +472,8 @@ skipPixel: extern "C" { - static __int64 mmDDL2oDU_addAmbientMaskPoint; - static __int64 mmDDL2oDV_addAmbientMaskPoint; + __int64 mmDDL2oDU_addAmbientMaskPoint; + __int64 mmDDL2oDV_addAmbientMaskPoint; } // add one layer point light without diffusion and with mask @@ -694,8 +694,8 @@ skipPixel: } extern "C" { - static __int64 mmDDL2oDU_AddDiffusionPoint; - static __int64 mmDDL2oDV_AddDiffusionPoint; + __int64 mmDDL2oDU_AddDiffusionPoint; + __int64 mmDDL2oDV_AddDiffusionPoint; } // add one layer point light with diffusion and without mask @@ -878,8 +878,8 @@ skipPixel: } extern "C" { - static __int64 mmDDL2oDU_AddDiffusionMaskPoint; - static __int64 mmDDL2oDV_AddDiffusionMaskPoint; + __int64 mmDDL2oDU_AddDiffusionMaskPoint; + __int64 mmDDL2oDV_AddDiffusionMaskPoint; } // add one layer point light with diffusion and mask