fork/training-mode-ce

git clone https://git.julia.blue/fork/training-mode-ce

AitchAdd warnings and fix them (#297)4f5d26e

nix
7.5 KiB247 linesraw
1#ifndef MEX_H_EFFECTS
2#define MEX_H_EFFECTS
3
4#include "structs.h"
5#include "datatypes.h"
6#include "obj.h"
7
8#define PTCL_LINKMAX 16
9
10/*** Structs ***/
11
12struct EffectModelDesc
13{
14    float frame_num;
15    JOBJSet jobjset;
16};
17
18struct PtclDesc
19{
20    u16 x0;
21    u16 x2;
22    int effect_idx_start;
23    int gen_num;
24    struct
25    {
26        int x0;
27        int x4;
28        int flags; // 0x8
29    } *gen[];
30};
31
32struct TexGDesc
33{
34    int num;
35    struct
36    {
37        int img_num;
38        GXTexFmt img_fmt;
39        int x8;
40        int width;
41        int height;
42        int x14;
43        void *img_ptr[];
44    } *data[];
45};
46
47struct EffectDataTable // exists in the dat
48{
49    PtclDesc *particle;
50    TexGDesc *texg;
51    EffectModelDesc model_desc[];
52};
53
54struct Effect
55{
56    GOBJ *child;
57    GOBJ *gobj;
58    GOBJ *parent;
59    int xc;
60    void *callback;
61    int x14;
62    int x18;
63    int x1c;
64    float x20;
65    short lifetime;
66    char x26;
67    char x27;
68    char x28; // if this is == 2, the effect is not updated
69    char x29;
70};
71
72struct ptclGenCallback
73{
74    void (*cbSpawnParticle)(Particle *);   // x00
75    void (*cbDestroyParticle)(Particle *); // x04
76};
77
78struct ptclGen // allocated at 8039d9c8
79{
80    struct ptclGen *next;       // 0x0
81    int kind;                   // x4
82    float random;               // x8
83    float num_to_spawn;         // xc
84    JOBJ *joint;                // x10
85    u16 genlife;                // x14
86    u16 type;                   // x16
87    u8 ef_file;                 // x18
88    u8 link_no;                 // x19, r3 for 8039f05c
89    u8 tex_group;               // x1a
90    u8 x1b;                     // x1b
91    u16 instance;               // x1c, is equal to idnum value in the particles it creates
92    u16 life;                   // x1e
93    void *cmdList;              // x20, pointer to track data
94    Vec3 pos;                   // x24
95    Vec3 vel;                   // x30
96    float gravity;              // x3c
97    float friction;             // x40
98    float size;                 // x44
99    float radius;               // x48
100    float angle;                // x4c
101    int particle_num;           // x50
102    GeneratorAppSRT *appsrt;    // x54, points to an SRT mtx used for transforming the generator while attached to a joint
103    ptclGenCallback *callbacks; // x58
104    void *x5C;                  // x5C
105    Vec3 x60;                   // x60
106    Vec3 x6c;                   // x6C
107    Vec3 x78;                   // x78
108    Vec3 x84;                   // x84
109    short rect_flags;           // x90
110};
111
112struct GeneratorAppSRT // allocated at 803a42b0
113{
114    int x0;     // x0
115    int x4;     // x4
116    Vec3 pos;   // x8
117    Vec4 rot;   // x14
118    Vec3 scale; // x24
119    int x30;    // x30
120    int x34;    // x34
121    int x38;    // x38
122    int x3c;    // x3c
123    int x40;    // x40
124    int x44;    // x44
125    int x48;    // x48
126    int x4c;    // x4c
127    int x50;    // x50
128    int x54;    // x54
129    int x58;    // x58
130    int x5c;    // x5c
131    int x60;    // x60
132    int x64;    // x64
133    int x68;    // x68
134    int x6c;    // x6c
135    int x70;    // x70
136    int x74;    // x74
137    int x78;    // x78
138    int x7c;    // x7c
139    int x80;    // x80
140    int x84;    // x84
141    int x88;    // x88
142    int x8c;    // x8c
143    int x90;    // x90
144    int x94;    // x94
145    int x98;    // x98
146    int x9c;    // x9c
147    int xa0;    // xa0
148    u16 xa2;
149};
150
151// courtesy of psilupan: https://pastebin.com/raw/yQdjypW0
152struct Particle // created at 80398c90. dont feel like labelling this, offsets are @ 80398de4
153{
154    struct Particle *next; // 0x0
155    u32 kind;              // 0x4, actually are flags. 0x800 pauses it
156    u8 bank;               // 0x8
157    u8 texGroup;           // 0x9
158    u8 poseNum;            // 0xa
159    u8 palNum;             // 0xb
160    u16 sizeCount;         // 0xc
161    u16 primColCount;      // 0xe
162    u16 envColCount;       // 0x10
163    u8 primCol[4];         // 0x12
164    u8 envCol[4];          // 0x16
165    u16 cmdWait;           // 0x1a
166    u8 loopCount;          // 0x1c
167    u8 linkNo;             // 0x1d
168    u16 idnum;             // 0x1e
169    void *cmdList;         // 0x20
170    u16 cmdPtr;            // 0x24
171    u16 cmdMarkPtr;        // 0x26
172    u16 cmdLoopPtr;        // 0x28
173    u16 life;              // 0x2a
174    Vec3 v;                // 0x2C
175    float grav;            // 0x38
176    float fric;            // 0x3C
177    Vec3 pos;              // 0x40
178    float size;            // 0x4C
179    float rotate;          // 0x50
180    u16 aCmpCount;         // 0x54
181    u8 aCmpMode;           // 0x56
182    u8 aCmpParam1;         // 0x57
183    u8 aCmpParam2;         // 0x58
184    u8 pJObjOfs;           // 0x59
185    u16 matColCount;       // 0x5A
186    u16 ambColCount;       // 0x5C
187    u16 rotateCount;       // 0x5E
188    float sizeTarget;      // 0x60
189    float rotateTarget;    // 0x64
190    float rotateAcc;       // 0x68
191    u16 primColRemain;     // 0x6C
192    u16 envColRemain;      // 0x6E
193    GXColor primColTarget; // 0x70
194    GXColor envColTarget;  // 0x74
195    u16 matColRemain;      // 0x78
196    u16 ambColRemain;      // 0x7A
197    u16 aCmpRemain;        // 0x7C
198    u8 aCmpParam1Target;   // 0x7D
199    u8 aCmpParam2Target;   // 0x7E
200    u8 matRGB;             // 0x7F
201    u8 matA;               // 0x80
202    u8 ambRGB;             // 0x81
203    u8 ambA;               // 0x82
204    // u8 matRGBTarget;         // 0x83
205    // u8 matATarget;           // 0x84
206    // u8 ambRGBTarget;         // 0x85
207    // u8 ambATarget;           // 0x86
208    float trail;             // 0x84
209    ptclGen *gen;            // 0x88
210    GeneratorAppSRT *appsrt; // 0x8C
211    void *userdata;          // 0x90
212    void *callback;          // 0x94
213};
214
215/*** Functions ***/
216
217void Effect_LoadFile(int eff_file_idx);
218Effect *Effect_SpawnSync(int gfx_id, ...);
219void Effect_SpawnAsync(GOBJ *fighter, Effect *ptr, int type, int gfx_id, ...);
220void Effect_SpawnAsyncLookup(GOBJ *gobj, int gfx_id, int bone, int unk, int destroy_on_leave, Vec3 *offset, Vec3 *range);
221void Effect_SpawnItEffectLookup(GOBJ *gobj, int gfx_id, int bone, Vec3 *offset, Vec3 *scatter, int unk3);
222void Effect_SpawnItEffect(GOBJ *gobj, int gfx_id);
223void Effect_DestroyAll(GOBJ *fighter);
224void Particle_DestroyAll(JOBJ *jobj);
225void Effect_PauseAll(GOBJ *fighter);
226void Effect_ResumeAll(GOBJ *fighter);
227void Effect_CheckQueue(GOBJ *g, Effect **gfx);
228void Particle_InitFile(void *ptcl, void *texg, int r5);
229ptclGen *psCreateGeneratorID(int linkno, int bank_no, int ptcl_index);                 // 8039f05c
230ptclGen *psCreateGeneratorIDJObj(int linkno, int bank_no, int ptcl_index, JOBJ *jobj); // 8039efac
231void psInterpretParticles(u32 blacklist_link_nos);                                     // input is a bitfield, shifted left by 16 bits!
232void psExecGenerator(u32 blacklist_link_nos);                                          // input is a bitfield, shifted left by 16 bits!
233void psDispParticles(u32 whitelist_link_nos, int pass);                                // input is a bitfield
234GeneratorAppSRT *psAddGeneratorAppSRT(ptclGen *ptcl_gen, int unk);
235int psRemoveParticleAppSRT(Particle *ptcl);
236void psDeletePntJObjwithParticle(Particle *ptcl);
237ptclGen *psKillGenerator(ptclGen *gen, ptclGen *unk);
238ptclGen *psKillGeneratorEZ(ptclGen *gen);
239void psInitDataBanks(int bank_no, void *ptcl, void *texg, int r6, int r7);
240
241static u16 *stc_ptclnum = R13_OFFSET(-0x3DBE);      // number of pctls alive
242static Particle **stc_ptcl = (void *)0x804d0908;        // last created ptcl
243static ptclGen **stc_ptclgen = R13_OFFSET(-0x3DA4); // last created gen
244static ptclGen **stc_ptclgencurr = R13_OFFSET(-0x3DA8);
245static u16 *stc_ptclgennum = R13_OFFSET(-0x3DC0);
246
247#endif