Skip to content

Commit de49fba

Browse files
authored
Multiple file cleanup (bfbbdecomp#719)
* Multiple file cleanup * More cleanup * Filled data out
1 parent b269e03 commit de49fba

File tree

12 files changed

+238
-367
lines changed

12 files changed

+238
-367
lines changed

src/SB/Core/x/iCamera.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,11 @@
99

1010
#include <string.h>
1111

12-
extern F32 sCameraNearClip;
13-
extern F32 sCameraFarClip;
14-
extern RwCamera* sMainGameCamera;
15-
16-
extern F32 _640_0;
17-
extern F32 _706_0;
18-
extern F32 _707_1;
19-
extern F32 _708_3;
20-
extern F32 _709_1;
21-
extern F32 _741_3;
22-
extern F32 _742_1;
23-
extern F32 _743_1;
24-
extern F64 _769_1;
25-
extern F64 _826_0;
12+
RwCamera* globalCamera;
13+
static RwCamera* sMainGameCamera;
14+
15+
F32 sCameraNearClip = 0.05f;
16+
F32 sCameraFarClip = 400.0f;
2617

2718
RwCamera* iCameraCreate(S32 width, S32 height, S32 mainGameCamera)
2819
{
@@ -37,8 +28,8 @@ RwCamera* iCameraCreate(S32 width, S32 height, S32 mainGameCamera)
3728
RwCameraSetFarClipPlane(camera, sCameraFarClip);
3829
RwCameraSetNearClipPlane(camera, sCameraNearClip);
3930

40-
vw.x = _640_0;
41-
vw.y = _640_0;
31+
vw.x = 1.0f;
32+
vw.y = 1.0f;
4233

4334
RwCameraSetViewWindow(camera, &vw);
4435

@@ -231,10 +222,10 @@ void iCameraSetFOV(RwCamera* cam, F32 fov)
231222
{
232223
RwV2d vw;
233224

234-
vw.x = itan(_706_0 * (_707_1 * fov) / _708_3);
225+
vw.x = itan(PI * (0.5f * fov) / 180.0f);
235226

236227
// non-matching: frsp instruction is here for some reason
237-
vw.y = _709_1 * vw.x;
228+
vw.y = 0.75f * vw.x;
238229

239230
RwCameraSetViewWindow(cam, &vw);
240231
}
@@ -271,18 +262,16 @@ void iCamGetViewMatrix(RwCamera* camera, xMat4x3* view_matrix)
271262

272263
void iCameraSetNearFarClip(F32 nearPlane, F32 farPlane)
273264
{
274-
if (nearPlane <= *(const F32*)&_742_1)
265+
if (nearPlane <= 0.0f)
275266
{
276-
nearPlane = _741_3;
267+
nearPlane = 0.05f;
277268
}
278269

279270
sCameraNearClip = nearPlane;
280271

281-
// non-matching: _742_1 is loaded too early
282-
283-
if (farPlane <= *(const F32*)&_742_1)
272+
if (farPlane <= 0.0f)
284273
{
285-
farPlane = _743_1;
274+
farPlane = 400.0f;
286275
}
287276

288277
sCameraFarClip = farPlane;
@@ -295,7 +284,7 @@ void iCameraSetFogParams(iFogParams* fp, F32 time)
295284
xglobals->fog.type = rwFOGTYPENAFOGTYPE;
296285
xglobals->fogA.type = rwFOGTYPENAFOGTYPE;
297286
}
298-
else if (_742_1 == time || fp->type != xglobals->fogA.type)
287+
else if (0.0f == time || fp->type != xglobals->fogA.type)
299288
{
300289
xglobals->fog = *fp;
301290
xglobals->fogA = *fp;
@@ -306,7 +295,8 @@ void iCameraSetFogParams(iFogParams* fp, F32 time)
306295
xglobals->fogA = xglobals->fog;
307296
xglobals->fogB = *fp;
308297

309-
// todo
298+
xglobals->fog_t0 = iTimeGet();
299+
xglobals->fog_t1 = xglobals->fog_t0 + (iTime)(time * 1000.0f);
310300
}
311301
}
312302

src/SB/Core/x/xFX.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#define ID_gloss_edge 0xB8C2351E
2626
#define ID_rainbowfilm_smooth32 0x741B0566
2727

28-
extern const char _stringBase0_7[];
29-
3028
/* Global variables from .comm segment */
3129
xFXRing ringlist[RING_COUNT];
3230
xFXStreak sStreakList[10];
@@ -596,30 +594,6 @@ static _xFXAuraAngle sAuraAngle[2];
596594
static RwTexture* gAuraTex = NULL;
597595
static _xFXAura sAura[AURA_COUNT];
598596

599-
__declspec(section ".rodata") static const char _stringBase0_7[] = "bubble buddy\0"
600-
"bubble missile\0"
601-
"bubble helmet\0"
602-
"bubble bowling ball\0"
603-
"bubble shoeL\0"
604-
"bubble shoeR\0"
605-
"spec3\0"
606-
"default_env_map.RW3\0"
607-
"gloss_edge\0"
608-
"update frame\n\0"
609-
"fx_streak1\0"
610-
"BLENDZERO\0"
611-
"BLENDONE\0"
612-
"BLENDSRCCOLOR\0"
613-
"BLENDINVSRCCOLOR\0"
614-
"BLENDSRCALPHA\0"
615-
"BLENDINVSRCALPHA\0"
616-
"BLENDDESTALPHA\0"
617-
"BLENDINVDESTALPHA\0"
618-
"BLENDDESTCOLOR\0"
619-
"BLENDINVDESTCOLOR\0"
620-
"BLENDSRCALPHASAT\0"
621-
"FX|Ribbon";
622-
623597
void xFXStartup()
624598
{
625599
}

src/SB/Core/x/xNPCBasic.cpp

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,7 @@
1717
#include "xColor.h"
1818
#include "iCollide.h"
1919

20-
extern float xNPCBasic_float_0;
21-
extern float xNPCBasic_float_1;
22-
extern float xNPCBasic_float_onehalf;
23-
extern float xNPCBasic_float_onequarter;
24-
extern float xNPCBasic_float_15;
25-
extern float xNCPBasic_float_0p10000000;
26-
extern float xNPCBasic_float_0p75;
27-
extern float xNPCBasic_float_1eminus5;
28-
extern float xNPCBasic_float_0p2;
29-
extern float xNPCBasic_float_thirty;
30-
extern float xNPCBasic_float_0p04;
31-
extern float xNPCBasic_float_0p025;
32-
33-
extern xEntCollis g_colrec;
34-
extern xVec3 lbl_8026A3F8;
20+
static xEntCollis g_colrec = { 0 };
3521

3622
void NPC_alwaysUseSphere(xEnt*, xVec3*);
3723
void NPC_entwrap_setup(xEnt*);
@@ -45,17 +31,17 @@ void NPC_entwrap_render(xEnt*);
4531
// The order of the function pointer assignment instructions at the end of the
4632
void xNPCBasic::Init(xEntAsset* asset)
4733
{
48-
if (xNPCBasic_float_0 == asset->scale.x)
34+
if (0.0f == asset->scale.x)
4935
{
50-
asset->scale.x = xNPCBasic_float_1;
36+
asset->scale.x = 1.0f;
5137
}
52-
if (xNPCBasic_float_0 == asset->scale.y)
38+
if (0.0f == asset->scale.y)
5339
{
54-
asset->scale.y = xNPCBasic_float_1;
40+
asset->scale.y = 1.0f;
5541
}
56-
if (xNPCBasic_float_0 == asset->scale.z)
42+
if (0.0f == asset->scale.z)
5743
{
58-
asset->scale.z = xNPCBasic_float_1;
44+
asset->scale.z = 1.0f;
5945
}
6046

6147
xEnt* thisEnt = this;
@@ -125,14 +111,15 @@ void xNPCBasic::Reset()
125111
void NPC_alwaysUseSphere(xEnt* ent, xVec3* value)
126112
{
127113
xNPCBasic* npc = (xNPCBasic*)ent;
128-
xVec3 bndcent = lbl_8026A3F8;
114+
const xVec3 vec = { 0, 0, 0 };
115+
xVec3 bndcent = vec;
129116

130117
xVec3Copy(&bndcent, xEntGetPos(npc));
131-
bndcent.y += xNPCBasic_float_0p75;
118+
bndcent.y += 0.75f;
132119

133120
npc->bound.type = XBOUND_TYPE_SPHERE;
134121
xVec3Copy(&npc->bound.sph.center, &bndcent);
135-
npc->bound.sph.r = xNPCBasic_float_0p75;
122+
npc->bound.sph.r = 0.75f;
136123
if (npc->bound.type != XBOUND_TYPE_NA)
137124
{
138125
xQuickCullForBound(&npc->bound.qcd, &npc->bound);
@@ -148,12 +135,12 @@ void NPC_alwaysUseSphere(xEnt* ent, xVec3* value)
148135

149136
void NPC_spdBasedColFreq(xNPCBasic* npc, F32 dt)
150137
{
151-
if (dt < xNPCBasic_float_1eminus5)
138+
if (dt < 1e-5f)
152139
{
153140
return;
154141
}
155142
F32 d = xVec3Length(&npc->frame->vel);
156-
if (d < xNPCBasic_float_0p2)
143+
if (d < 0.2f)
157144
{
158145
return;
159146
}
@@ -169,7 +156,7 @@ void NPC_spdBasedColFreq(xNPCBasic* npc, F32 dt)
169156
npc->bound.box.box.upper.z - npc->bound.box.box.lower.z);
170157
}
171158

172-
S32 nf = xNPCBasic_float_thirty * (radius / d);
159+
S32 nf = 30.0f * (radius / d);
173160
npc->colFreq = MIN(npc->colFreq, nf);
174161
}
175162

@@ -215,10 +202,10 @@ void xNPCBasic::Process(xScene* xscn, F32 dt)
215202

216203
if (frame != NULL && (flags1.flg_upward & 0x2))
217204
{
218-
frame->dpos.y = MAX(xNPCBasic_float_0, frame->dpos.y);
219-
frame->dvel.y = MAX(xNPCBasic_float_0, frame->dvel.y);
220-
frame->vel.y = MAX(xNPCBasic_float_0, frame->vel.y);
221-
frame->oldvel.y = MAX(xNPCBasic_float_0, frame->oldvel.y);
205+
frame->dpos.y = MAX(0.0f, frame->dpos.y);
206+
frame->dvel.y = MAX(0.0f, frame->dvel.y);
207+
frame->vel.y = MAX(0.0f, frame->vel.y);
208+
frame->oldvel.y = MAX(0.0f, frame->oldvel.y);
222209
model->Mat->pos.y = MAX(model->Mat->pos.y, frame->oldmat.pos.y);
223210
}
224211

@@ -254,7 +241,7 @@ void xNPCBasic::Process(xScene* xscn, F32 dt)
254241
DBG_PStatOn(eNPCPerfEnable);
255242
}
256243

257-
if ((pflags & (0x2 | 0x1)) != 0 && xVec3Length2(&frame->vel) > xNCPBasic_float_0p10000000)
244+
if ((pflags & (0x2 | 0x1)) != 0 && xVec3Length2(&frame->vel) > 0.1f)
258245
{
259246
NPC_spdBasedColFreq(this, dt);
260247
}
@@ -302,9 +289,9 @@ void NPC_entwrap_reset(xEnt* ent)
302289
void NPC_entwrap_update(xEnt* ent, xScene* scn, F32 dt_caller)
303290
{
304291
F32 dt = dt_caller;
305-
if (dt > xNPCBasic_float_0p04)
292+
if (dt > 0.04f)
306293
{
307-
dt = xNPCBasic_float_0p025;
294+
dt = 0.025000002f;
308295
}
309296

310297
xNPCBasic* npc = (xNPCBasic*)ent;

src/SB/Core/x/xNPCBasic.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ struct xNPCBasic : xEnt, xFactoryInst
128128
{
129129
return 0;
130130
}
131-
132-
virtual void Destroy();
133131
};
134132

135133
void NPC_spdBasedColFreq(xNPCBasic* npc, F32 dt);

0 commit comments

Comments
 (0)