From c3cc5eb87891c06b636409342fd86e4d8893c549 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sun, 27 Apr 2008 01:45:21 -0700 Subject: [PATCH] Made sin/cos tables const. Made the sin/cos/arcsin/arccos tables const and removed the redundant externs that were scattered about. --- src/avp/avpview.c | 2 -- src/avp/bh_ais.c | 2 -- src/avp/bh_far.c | 2 -- src/avp/bh_fhug.c | 1 - src/avp/bh_near.c | 1 - src/avp/decal.c | 2 -- src/avp/hmodel.c | 2 -- src/avp/hud.c | 3 --- src/avp/paintball.c | 1 - src/avp/particle.c | 1 - src/avp/pmove.c | 1 - src/avp/stratdef.c | 4 ---- src/avp/track.c | 4 ---- src/avp/weapons.c | 1 - src/avp/win95/d3d_hud.cpp | 1 - src/avp/win95/ddplat.cpp | 1 - src/avp/win95/objsetup.cpp | 1 - src/avp/win95/pldghost.c | 1 - src/avp/win95/projload.cpp | 3 +-- src/include/prototyp.h | 9 ++------- src/kshape.c | 8 -------- src/maths.c | 10 +++++----- src/opengl.c | 2 -- src/tables.c | 16 +++++----------- src/vdb.c | 5 ----- src/win95/io.c | 12 ------------ src/win95/platform.h | 3 --- 27 files changed, 13 insertions(+), 86 deletions(-) diff --git a/src/avp/avpview.c b/src/avp/avpview.c index c566b4c..c2c72cd 100644 --- a/src/avp/avpview.c +++ b/src/avp/avpview.c @@ -92,8 +92,6 @@ int AlienBiteAttackInProgress; /* phase for cloaked objects */ int CloakingPhase; extern int NormalFrameTime; -extern int cosine[]; -extern int sine[]; int LeanScale; EULER deathTargetOrientation={0,0,0}; diff --git a/src/avp/bh_ais.c b/src/avp/bh_ais.c index 3c789f2..76361f6 100644 --- a/src/avp/bh_ais.c +++ b/src/avp/bh_ais.c @@ -891,8 +891,6 @@ int NPCSetVelocity(STRATEGYBLOCK *sbPtr, VECTORCH* targetDirn, int in_speed) -----------------------------------------------------------------------*/ int NPCOrientateToVector(STRATEGYBLOCK *sbPtr, VECTORCH *zAxisVector,int turnspeed, VECTORCH *offset) { - extern int cosine[], sine[]; - int maxTurnThisFrame; int turnThisFrame; VECTORCH localZAxisVector; diff --git a/src/avp/bh_far.c b/src/avp/bh_far.c index 93bab27..a1cb0e4 100644 --- a/src/avp/bh_far.c +++ b/src/avp/bh_far.c @@ -1065,8 +1065,6 @@ AIMODULE *FarNPC_GetTargetAIModuleForHunt(STRATEGYBLOCK *sbPtr, int alien) /* Patrick 2/7/96: this function returns a module for wandering to */ AIMODULE *FarNPC_GetTargetAIModuleForWander(STRATEGYBLOCK *sbPtr, AIMODULE *exception, int alien) { - extern int cosine[], sine[]; - AIMODULE **AdjModuleRefPtr; DYNAMICSBLOCK *dynPtr; AIMODULE* targetModule = (AIMODULE *)0; diff --git a/src/avp/bh_fhug.c b/src/avp/bh_fhug.c index b371b61..e5cf5f4 100644 --- a/src/avp/bh_fhug.c +++ b/src/avp/bh_fhug.c @@ -33,7 +33,6 @@ extern int ModuleArraySize; extern char *ModuleCurrVisArray; extern int NormalFrameTime; -extern int cosine[], sine[]; extern ACTIVESOUNDSAMPLE ActiveSounds[]; diff --git a/src/avp/bh_near.c b/src/avp/bh_near.c index 0bc2d17..6f358e8 100644 --- a/src/avp/bh_near.c +++ b/src/avp/bh_near.c @@ -32,7 +32,6 @@ #include "particle.h" #include "scream.h" -extern int cosine[], sine[]; extern int NormalFrameTime; extern int ShowHiveState; extern ACTIVESOUNDSAMPLE ActiveSounds[]; diff --git a/src/avp/decal.c b/src/avp/decal.c index ce91072..b8a3fac 100644 --- a/src/avp/decal.c +++ b/src/avp/decal.c @@ -619,7 +619,6 @@ void AddDecal(enum DECAL_ID decalID, VECTORCH *normalPtr, VECTORCH *positionPtr, DECAL *decalPtr; MATRIXCH orientation; int decalSize; - extern int sine[],cosine[]; int theta = FastRandom()&4095; int sin = GetSin(theta); int cos = GetCos(theta); @@ -958,7 +957,6 @@ void AddDecalToHModel(VECTORCH *normalPtr, VECTORCH *positionPtr, SECTION_DATA * VECTORCH v; int decalSize; - extern int sine[],cosine[]; int theta,sin,cos; if (!LocalDetailLevels.DrawHierarchicalDecals) return; diff --git a/src/avp/hmodel.c b/src/avp/hmodel.c index e7f37fc..a1d96d5 100644 --- a/src/avp/hmodel.c +++ b/src/avp/hmodel.c @@ -59,8 +59,6 @@ void Budge_HModel(HMODELCONTROLLER *controller,VECTORCH *offset); /* external globals */ extern int NormalFrameTime; -extern int sine[]; -extern int cosine[]; extern int GlobalFrameCounter; extern VIEWDESCRIPTORBLOCK *Global_VDB_Ptr; diff --git a/src/avp/hud.c b/src/avp/hud.c index 952717a..1cda299 100644 --- a/src/avp/hud.c +++ b/src/avp/hud.c @@ -66,8 +66,6 @@ extern int ScanDrawMode; extern DISPLAYBLOCK* Player; -extern int sine[], cosine[]; /* these externs should be with the GetCos GetSin macros!! */ - extern int NumActiveBlocks; extern DISPLAYBLOCK *ActiveBlockList[]; extern int NumOnScreenBlocks; @@ -1947,7 +1945,6 @@ void DrawWristDisplay(void) } void RotateVertex(VECTOR2D *vertexPtr, int theta) { - extern int sine[],cosine[]; int vx,vy; int sin = GetSin(theta); int cos = GetCos(theta); diff --git a/src/avp/paintball.c b/src/avp/paintball.c index e5dc2f8..537cfbd 100644 --- a/src/avp/paintball.c +++ b/src/avp/paintball.c @@ -35,7 +35,6 @@ extern void PaintBallMode_DrawCurrentDecalAtTarget(void) extern DECAL_DESC DecalDescription[]; DECAL_DESC *decalDescPtr = &DecalDescription[PaintBallMode.CurrentDecalID]; extern void MakeMatrixFromDirection(VECTORCH *directionPtr, MATRIXCH *matrixPtr); - extern int sine[],cosine[]; extern MODULE *playerPherModule; MATRIXCH orientation; diff --git a/src/avp/particle.c b/src/avp/particle.c index 800e420..9072d8d 100644 --- a/src/avp/particle.c +++ b/src/avp/particle.c @@ -3799,7 +3799,6 @@ void HandleRipples(void) int EffectOfRipples(VECTORCH *point) { - extern int sine[]; int offset; int i; offset = GetSin((point->vx+point->vz+CloakingPhase)&4095)>>11; diff --git a/src/avp/pmove.c b/src/avp/pmove.c index d6092d0..096e79f 100644 --- a/src/avp/pmove.c +++ b/src/avp/pmove.c @@ -93,7 +93,6 @@ int executeDemo; /* Global Externs */ extern DISPLAYBLOCK* Player; extern int NormalFrameTime; -extern int cosine[], sine[]; extern int predHUDSoundHandle; extern int predOVision_SoundHandle; extern int TauntSoundPlayed; diff --git a/src/avp/stratdef.c b/src/avp/stratdef.c index e021abb..1e670d6 100644 --- a/src/avp/stratdef.c +++ b/src/avp/stratdef.c @@ -38,10 +38,6 @@ static STRATEGYBLOCK **ActiveStBlockListPtr = &ActiveStBlockList[0]; unsigned int IncrementalSBname; -/**** improted globals ************/ - -extern int cosine[], sine[]; - /* Support functions for Strategy Blocks diff --git a/src/avp/track.c b/src/avp/track.c index e088e06..fa33d73 100644 --- a/src/avp/track.c +++ b/src/avp/track.c @@ -22,13 +22,9 @@ static void LnQuat(QUAT *q); static void ExpPurelyImaginaryQuat(QUAT *q); extern void MulQuat(QUAT *q1, QUAT *q2, QUAT *output); - - extern int NormalFrameTime; extern void QNormalise(QUAT*); extern int QDot(QUAT *, QUAT *); -extern int sine[]; -extern int cosine[]; static void TrackSlerp(TRACK_SECTION_DATA* tsd,int lerp,MATRIXCH* output_mat) { diff --git a/src/avp/weapons.c b/src/avp/weapons.c index b8f3fa3..6663dc3 100644 --- a/src/avp/weapons.c +++ b/src/avp/weapons.c @@ -3011,7 +3011,6 @@ void PositionPlayersWeaponMuzzleFlash(void) /* rotate flash around in random multiples of 60 degrees */ { MATRIXCH mat; - extern int cosine[], sine[]; int angle = (FastRandom()%6)*683; int cos = GetCos(angle); int sin = GetSin(angle); diff --git a/src/avp/win95/d3d_hud.cpp b/src/avp/win95/d3d_hud.cpp index a7b0d41..553a3b3 100644 --- a/src/avp/win95/d3d_hud.cpp +++ b/src/avp/win95/d3d_hud.cpp @@ -70,7 +70,6 @@ extern void YClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v extern void XClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2); /* HUD globals */ extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; -extern int sine[],cosine[]; extern enum HUD_RES_ID HUDResolution; diff --git a/src/avp/win95/ddplat.cpp b/src/avp/win95/ddplat.cpp index e606183..1a12b91 100644 --- a/src/avp/win95/ddplat.cpp +++ b/src/avp/win95/ddplat.cpp @@ -44,7 +44,6 @@ extern "C++" extern int ScanDrawMode; extern int ZBufferMode; -extern int sine[],cosine[]; extern IMAGEHEADER ImageHeaderArray[]; int BackdropImage; //#define UseLocalAssert Yes diff --git a/src/avp/win95/objsetup.cpp b/src/avp/win95/objsetup.cpp index 4ccdb9d..422916b 100644 --- a/src/avp/win95/objsetup.cpp +++ b/src/avp/win95/objsetup.cpp @@ -61,7 +61,6 @@ extern "C" { #include "3dc.h" -extern int cosine[]; extern MAPSETVDB chnk_playcam_vdb; extern int GlobalAmbience; extern VIEWDESCRIPTORBLOCK *ActiveVDBList[]; diff --git a/src/avp/win95/pldghost.c b/src/avp/win95/pldghost.c index 7d75a1e..0ad3c81 100644 --- a/src/avp/win95/pldghost.c +++ b/src/avp/win95/pldghost.c @@ -40,7 +40,6 @@ ----------------------------------------------------------------------*/ extern int NormalFrameTime; extern int GlobalFrameCounter; -extern int cosine[], sine[]; extern ACTIVESOUNDSAMPLE ActiveSounds[]; extern DEATH_DATA Alien_Deaths[]; extern HITLOCATIONTABLE *GetThisHitLocationTable(char *id); diff --git a/src/avp/win95/projload.cpp b/src/avp/win95/projload.cpp index 39005a5..b045cdf 100644 --- a/src/avp/win95/projload.cpp +++ b/src/avp/win95/projload.cpp @@ -59,9 +59,8 @@ extern int ScanDrawMode; extern int ZBufferMode; extern unsigned char *PaletteRemapTable; extern unsigned char **PaletteShadingTableArray; -extern int cosine[]; extern int HWAccel; -#define remap_table_size (1 << (remap_table_rgb_bits * 3)) + extern VECTORCH PlayerStartLocation; extern MATRIXCH PlayerStartMat; diff --git a/src/include/prototyp.h b/src/include/prototyp.h index f982f77..265960b 100644 --- a/src/include/prototyp.h +++ b/src/include/prototyp.h @@ -29,13 +29,8 @@ */ - - -/* Grrr!! That's the last time these will be missing! */ -/* Oh, CDF 18/12/97 */ - -extern int sine[]; -extern int cosine[]; +extern const int sine[4096]; +extern const int cosine[4096]; typedef struct vectorch { diff --git a/src/kshape.c b/src/kshape.c index 2202c17..dd20815 100644 --- a/src/kshape.c +++ b/src/kshape.c @@ -133,14 +133,6 @@ void FindZFromXYIntersection(VECTORCH *startPtr, VECTORCH *directionPtr, VECTORC void AddToTranslucentPolyList(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr); void DrawWaterFallPoly(VECTORCH *v); -#if platform_pc -extern int sine[]; -extern int cosine[]; -#endif - - -//extern int ItemCount; - /*KJL************************************************************************************ * N.B. All the following global variables have their first elements initialised so that * diff --git a/src/maths.c b/src/maths.c index 6cdbc54..dc43618 100644 --- a/src/maths.c +++ b/src/maths.c @@ -10,12 +10,12 @@ */ -extern int sine[]; -extern int cosine[]; +extern const int sine[4096]; +extern const int cosine[4096]; -extern short ArcCosTable[]; -extern short ArcSineTable[]; -extern short ArcTanTable[]; +extern const short ArcCosTable[4096]; +extern const short ArcSineTable[4096]; +extern const short ArcTanTable[256]; extern LONGLONGCH ll_zero; diff --git a/src/opengl.c b/src/opengl.c index 327500a..e015133 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -2536,8 +2536,6 @@ void BltImage(RECT *dest, DDSurface *image, RECT *src) /* Hacked in special effects */ -extern int sine[]; -extern int cosine[]; extern int NormalFrameTime; void UpdateForceField(void); diff --git a/src/tables.c b/src/tables.c index f3f1efd..e83f114 100644 --- a/src/tables.c +++ b/src/tables.c @@ -10,13 +10,9 @@ */ -#if PSX - int sine[]={}; - int cosine[]={}; -#else int oneoversin[4096]; -int sine[]={ +const int sine[4096]={ 0, 100, @@ -4117,7 +4113,7 @@ int sine[]={ }; -int cosine[]={ +const int cosine[4096]={ 65536, 65535, @@ -8218,9 +8214,7 @@ int cosine[]={ }; -#endif - -short ArcCosTable[]={ +const short ArcCosTable[4096]={ 2047, 2027, @@ -12321,7 +12315,7 @@ short ArcCosTable[]={ }; -short ArcSineTable[]={ +const short ArcSineTable[4096]={ -1023, -1004, @@ -16422,7 +16416,7 @@ short ArcSineTable[]={ }; -short ArcTanTable[]={ +const short ArcTanTable[256]={ 0,2,5,7,10,12,15,17, 20,22,25,27,30,33,35,38, diff --git a/src/vdb.c b/src/vdb.c index 983497f..7244ebd 100644 --- a/src/vdb.c +++ b/src/vdb.c @@ -10,11 +10,6 @@ */ - #if platform_pc - extern int sine[]; - extern int cosine[]; - #endif - #if SupportWindows95 extern int ScanDrawMode; #endif diff --git a/src/win95/io.c b/src/win95/io.c index 67a3bfc..44986d2 100644 --- a/src/win95/io.c +++ b/src/win95/io.c @@ -61,9 +61,6 @@ extern SHAPEHEADER **mainshapelist; extern SHAPEHEADER *testpaletteshapelist[]; extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; -extern int sine[]; -extern int cosine[]; -extern int AdaptiveHazingFlag; extern int *Global_ShapeNormals; extern int *Global_ShapePoints; extern int *ItemPointers[]; @@ -391,15 +388,6 @@ int CompareFilenameCH(char *string1, char *string2) */ - -#define remap_table_size (1 << (remap_table_rgb_bits * 3)) - - -#define cprt_info No -#define cprt_cnt No - - - int NearestColour(int rs, int gs, int bs, unsigned char *palette) { diff --git a/src/win95/platform.h b/src/win95/platform.h index f8f6331..d93366a 100644 --- a/src/win95/platform.h +++ b/src/win95/platform.h @@ -37,9 +37,6 @@ typedef struct LONGLONGCH { */ -extern int sine[]; -extern int cosine[]; - #define GetSin(a) sine[a] #define GetCos(a) cosine[a]