Skip to content

Commit c9ee6fd

Browse files
authored
xLaserBolt: Fixes to Headers and Initial Matches (#644)
* Add -sym on c_flags to xLaserBolt.cpp in configure.py * iParMgr: Properly expose gRenderBuffer global var * xLaserBolt: Header updates using objdiff tooling * xLaserBolt: Initial pass of function matches
1 parent be0faf0 commit c9ee6fd

File tree

4 files changed

+78
-38
lines changed

4 files changed

+78
-38
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def MatchingFor(*versions):
571571
Object(Matching, "SB/Game/zCameraFly.cpp"),
572572
Object(Matching, "SB/Core/x/xCurveAsset.cpp"),
573573
Object(NonMatching, "SB/Core/x/xDecal.cpp", extra_cflags=["-sym on"]),
574-
Object(NonMatching, "SB/Core/x/xLaserBolt.cpp"),
574+
Object(NonMatching, "SB/Core/x/xLaserBolt.cpp", extra_cflags=["-sym on"]),
575575
Object(NonMatching, "SB/Game/zCameraTweak.cpp"),
576576
Object(NonMatching, "SB/Core/x/xPtankPool.cpp"),
577577
Object(Equivalent, "SB/Core/gc/iTRC.cpp"),

src/SB/Core/gc/iParMgr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
struct tagiRenderArrays
1010
{
1111
// total size: 0x5280
12-
public:
12+
public:
1313
U16 m_index[960]; // offset 0x0, size 0x780
1414
RxObjSpace3DVertex m_vertex[480]; // offset 0x780, size 0x4380
1515
F32 m_vertexTZ[480]; // offset 0x4B00, size 0x780
@@ -18,7 +18,7 @@ struct tagiRenderArrays
1818
struct tagiRenderInput
1919
{
2020
// total size: 0x80
21-
public:
21+
public:
2222
U16* m_index; // offset 0x0, size 0x4
2323
RxObjSpace3DVertex* m_vertex; // offset 0x4, size 0x4
2424
F32* m_vertexTZ; // offset 0x8, size 0x4
@@ -32,6 +32,8 @@ struct tagiRenderInput
3232
xVec4 m_camViewU; // offset 0x70, size 0x10
3333
};
3434

35+
extern tagiRenderInput gRenderBuffer;
36+
3537
void iParMgrInit();
3638
void iParMgrUpdate(F32 elapsedTime);
3739
void iParMgrRender();

src/SB/Core/x/xLaserBolt.cpp

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22
#include "xString.h"
33
#include "xstransvc.h"
44
#include "iParMgr.h"
5+
#include "zEvent.h"
6+
#include "zBase.h"
7+
#include "zNPCTypeCommon.h"
8+
#include "zEntDestructObj.h"
59

610
#include <types.h>
711

8-
extern tagiRenderInput gRenderBuffer;
9-
extern F32 lbl_803CF7A4; // 0.0f
10-
extern F32 lbl_803CF7A8; // 255f
12+
void xLaserBoltEmitter::init(u32 max_bolts, const char* texture_name)
13+
{
14+
this->bolt_raster = NULL;
15+
memset(fxsize, 0, sizeof(fxsize));
16+
this->bolts.init(max_bolts);
17+
debug_init(texture_name);
18+
}
19+
1120

12-
void xLaserBoltEmitter::set_texture(char* name)
21+
void xLaserBoltEmitter::set_texture(const char* name)
1322
{
1423
set_texture(xStrHash(name));
1524
}
@@ -36,23 +45,30 @@ void xLaserBoltEmitter::set_texture(RwRaster* raster)
3645
this->bolt_raster = raster;
3746
}
3847

48+
void xLaserBoltEmitter::reset()
49+
{
50+
}
51+
3952
void xLaserBoltEmitter::refresh_config()
4053
{
4154
F32 alpha;
4255
if (this->cfg.kill_dist <= this->cfg.fade_dist)
4356
{
44-
alpha = lbl_803CF7A4;
57+
alpha = 0.0f;
4558
}
4659
else
4760
{
48-
alpha = lbl_803CF7A8 / (this->cfg.kill_dist - this->cfg.fade_dist);
61+
alpha = 255.0f / (this->cfg.kill_dist - this->cfg.fade_dist);
4962
}
5063
this->ialpha = alpha;
5164
}
5265

5366
void xLaserBoltEmitter::attach_effects(fx_when_enum when, effect_data* fx, size_t fxsize)
5467
{
55-
// TODO!!!
68+
this->fx[when] = fx;
69+
this->fxsize[when] = fxsize;
70+
reset_fx(when);
71+
debug_refresh_effects(when);
5672
}
5773

5874
RxObjSpace3DVertex* xLaserBoltEmitter::get_vert_buffer(S32& dat)
@@ -61,9 +77,31 @@ RxObjSpace3DVertex* xLaserBoltEmitter::get_vert_buffer(S32& dat)
6177
return gRenderBuffer.m_vertex;
6278
}
6379

80+
void xLaserBoltEmitter::apply_damage(xLaserBoltEmitter::bolt& b)
81+
{
82+
if (b.hit_ent->baseType == eBaseTypeNPC)
83+
{
84+
zNPCCommon* npc = (zNPCCommon*)b.hit_ent;
85+
npc->Damage(DMGTYP_PROJECTILE, NULL, &b.dir);
86+
}
87+
else if (b.hit_ent->baseType == eBaseTypeDestructObj)
88+
{
89+
zEntDestructObj_Hit((zEntDestructObj*)b.hit_ent, 0x40000);
90+
}
91+
else
92+
{
93+
zEntEvent(b.hit_ent, eEventHit, cfg.damage, 0.0f, 0.0f, 0.0f);
94+
}
95+
}
96+
6497
// WIP.
6598
void xLaserBoltEmitter::reset_fx(fx_when_enum when)
6699
{
67-
U32* sizePtr = &this->fxsize[when];
68-
effect_data** effect = &this->fx[when];
100+
for (U32 i = 0; i < sizeof(fx); i++)
101+
{
102+
U32* sizePtr = &this->fxsize[when];
103+
effect_data** effect = &this->fx[when];
104+
105+
106+
}
69107
}

src/SB/Core/x/xLaserBolt.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111
#include <rwcore.h>
1212
#include <types.h>
1313

14-
enum fx_when_enum
15-
{
16-
FX_WHEN_LAUNCH,
17-
FX_WHEN_IMPACT,
18-
FX_WHEN_BIRTH,
19-
FX_WHEN_DEATH,
20-
FX_WHEN_HEAD,
21-
FX_WHEN_TAIL,
22-
FX_WHEN_KILL,
23-
MAX_FX_WHEN
24-
};
25-
2614
enum fx_type_enum
2715
{
2816
FX_TYPE_PARTICLE,
@@ -44,6 +32,18 @@ enum fx_orient_enum
4432

4533
struct xLaserBoltEmitter
4634
{
35+
enum fx_when_enum
36+
{
37+
FX_WHEN_LAUNCH,
38+
FX_WHEN_IMPACT,
39+
FX_WHEN_BIRTH,
40+
FX_WHEN_DEATH,
41+
FX_WHEN_HEAD,
42+
FX_WHEN_TAIL,
43+
FX_WHEN_KILL,
44+
MAX_FX_WHEN
45+
};
46+
4747
struct config
4848
{
4949
F32 radius;
@@ -61,16 +61,6 @@ struct xLaserBoltEmitter
6161
};
6262

6363
struct bolt;
64-
65-
struct static_queue
66-
{
67-
U32 _first;
68-
U32 _size;
69-
U32 _max_size;
70-
U32 _max_size_mask;
71-
bolt* _buffer;
72-
};
73-
7464
struct effect_data
7565
{
7666
struct effect_callback
@@ -107,15 +97,15 @@ struct xLaserBoltEmitter
10797
};
10898

10999
config cfg;
110-
static_queue bolts;
100+
static_queue<bolt> bolts;
111101
F32 ialpha;
112102
RwRaster* bolt_raster;
113103
S32 start_collide;
114104
effect_data* fx[7];
115105
U32 fxsize[7];
116106

117-
void init(U32 max_bolts, const char*);
118-
void set_texture(char* name);
107+
void init(u32 max_bolts, const char* texture_name);
108+
void set_texture(const char* name);
119109
void set_texture(U32 aid);
120110
void set_texture(RwTexture* tex);
121111
void set_texture(RwRaster* raster);
@@ -129,10 +119,20 @@ struct xLaserBoltEmitter
129119
void collide_update(bolt& b);
130120
RxObjSpace3DVertex* render(bolt& b, RxObjSpace3DVertex* vert);
131121
RxObjSpace3DVertex* get_vert_buffer(S32& dat);
132-
void applyDamage(bolt& b);
122+
void apply_damage(bolt& b);
133123
void reset_fx(fx_when_enum when);
134124

135125
U32 visible() const;
126+
127+
void debug_init(const char* texture_name)
128+
{
129+
130+
}
131+
132+
void debug_refresh_effects(fx_when_enum when)
133+
{
134+
135+
}
136136
};
137137

138138
#endif

0 commit comments

Comments
 (0)