From 2e821de16eab49eaef2c0ee0899eed6f4ad073e4 Mon Sep 17 00:00:00 2001 From: Fexty12573 Date: Tue, 30 Jul 2024 17:06:17 +0200 Subject: [PATCH] Organize SPL headers and source files --- include/struct_defs/struct_020147B8.h | 4 +- lib/spl/include/spl.h | 473 +------------------------- lib/spl/include/spl_behavior.h | 14 +- lib/spl/include/spl_emitter.h | 76 +++++ lib/spl/include/spl_internal.h | 47 +++ lib/spl/include/spl_manager.h | 54 +++ lib/spl/include/spl_particle.h | 40 +++ lib/spl/include/spl_resource.h | 228 +++++++++++++ lib/spl/include/spl_texture.h | 42 +++ lib/spl/src/spl_behavior.c | 2 +- lib/spl/src/unk_0209C400.c | 19 +- lib/spl/src/unk_0209CF00.c | 37 +- lib/spl/src/unk_0209DD54.c | 28 +- lib/spl/src/unk_020A05BC.c | 15 +- lib/spl/src/unk_020A19F0.c | 3 +- src/unk_02014000.c | 2 +- 16 files changed, 581 insertions(+), 503 deletions(-) create mode 100644 lib/spl/include/spl_emitter.h create mode 100644 lib/spl/include/spl_internal.h create mode 100644 lib/spl/include/spl_manager.h create mode 100644 lib/spl/include/spl_particle.h create mode 100644 lib/spl/include/spl_resource.h create mode 100644 lib/spl/include/spl_texture.h diff --git a/include/struct_defs/struct_020147B8.h b/include/struct_defs/struct_020147B8.h index 8fd2d6c596..2f8f8cc788 100644 --- a/include/struct_defs/struct_020147B8.h +++ b/include/struct_defs/struct_020147B8.h @@ -4,10 +4,10 @@ #include typedef struct SPLParticle_t SPLParticle; -struct SPLEmitter_t; +struct SPLEmitter; typedef struct { - void (*unk_00)(const void *, SPLParticle *, VecFx32 *, struct SPLEmitter_t *); + void (*unk_00)(const void *, SPLParticle *, VecFx32 *, struct SPLEmitter *); const void *unk_04; } UnkStruct_020147B8; diff --git a/lib/spl/include/spl.h b/lib/spl/include/spl.h index 8ce802e28e..d0055f3e41 100644 --- a/lib/spl/include/spl.h +++ b/lib/spl/include/spl.h @@ -1,479 +1,8 @@ #ifndef POKEPLATINUM_SPL_H #define POKEPLATINUM_SPL_H -#include "nitro/types.h" -#include +#include "spl_manager.h" -#include "struct_defs/struct_020147B8.h" - -#include "spl_list.h" -#include "spl_random.h" -#include "spl_behavior.h" - -#define GX_RGB_R(RGB) (((RGB) >> GX_RGB_R_SHIFT) & 31) -#define GX_RGB_G(RGB) (((RGB) >> GX_RGB_G_SHIFT) & 31) -#define GX_RGB_B(RGB) (((RGB) >> GX_RGB_B_SHIFT) & 31) - -#define GX_RGB_R_(rgb) (rgb & GX_RGB_R_MASK) -#define GX_RGB_G_(rgb) (rgb & GX_RGB_G_MASK) -#define GX_RGB_B_(rgb) (rgb & GX_RGB_B_MASK) - -typedef void * (* UnkFuncPtr_0209CD00)(u32); - -typedef union { - u32 unk_00; - struct { - u32 unk_04_0 : 4; - u32 unk_04_4 : 2; - u32 unk_04_6 : 2; - u32 unk_05_0 : 1; - u32 unk_05_1 : 1; - u32 unk_05_2 : 1; - u32 unk_05_3 : 1; - u32 unk_05_4 : 1; - u32 unk_05_5 : 1; - u32 unk_05_6 : 1; - u32 unk_05_7 : 1; - u32 unk_06_0 : 1; - u32 unk_06_1 : 2; - u32 unk_06_3 : 1; - u32 unk_06_4 : 1; - u32 unk_06_5 : 1; - u32 unk_06_6 : 1; - u32 unk_06_7 : 1; - u32 unk_07_0 : 1; - u32 unk_07_1 : 1; - u32 unk_07_2 : 1; - u32 unk_07_3 : 1; - u32 unk_07_4 : 1; - u32 unk_07_5 : 1; - u32 unk_07_6 : 1; - u32 unk_07_7 : 1; - }; -} UnkSPLUnion1; // size=0x4 - -typedef union { - u16 unk_00; - struct { - u16 unk_02_0 : 1; - u16 unk_02_1 : 1; - u16 unk_02_2 : 1; - u16 unk_02_3 : 2; - u16 unk_02_5 : 1; - u16 unk_02_6 : 1; - u16 unk_02_7 : 2; - u16 unk_03_1 : 2; - u16 unk_03_3 : 1; - u16 reserved_03_4 : 4; - }; -} UnkSPLUnion2; // size=0x2 - -typedef union { - u16 val1; - struct { - u16 val2_00 : 8; - u16 val2_01 : 8; - }; -} UnkSPLUnion3; // size=0x2 - -typedef union { - u32 unk_00; - struct { - u32 unk_04_0 : 8; - u32 unk_05_0 : 8; - u32 unk_06_0 : 8; - u32 unk_07_0 : 8; - }; -} UnkSPLUnion4; // size=0x4 - -typedef union { - u32 val1; - struct { - u32 val2_00_0 : 4; - u32 val2_00_4 : 4; - u32 val2_01_0 : 4; - u32 val2_01_4 : 2; - u32 val2_01_6 : 2; - u32 val2_02_0 : 1; - u32 val2_02_1 : 1; - u32 val2_02_2 : 8; - u32 val2_03_2 : 6; - }; -} UnkSPLUnion5; - -typedef struct SPLParticle_t { - struct SPLParticle_t * unk_00; - struct SPLParticle_t * unk_04; - VecFx32 unk_08; - VecFx32 unk_14; - u16 unk_20; - s16 unk_22; - u16 unk_24; - u16 unk_26; - u16 unk_28; - u16 unk_2A; - struct { - u16 unk_00 : 8; - u16 unk_01 : 8; - } unk_2C; - struct { - u16 unk_00_0 : 5; - u16 unk_00_5 : 5; - u16 unk_01_2 : 6; - } unk_2E; - fx32 unk_30; - fx16 unk_34; - GXRgb unk_36; - VecFx32 unk_38; -} SPLParticle; // size=0x44 - -typedef struct UnkSPLStruct3_t { - SPLParticle * unk_00; - int unk_04; - SPLParticle * unk_08; -} UnkSPLStruct3; // size=0xc - -typedef struct { - union - { - u32 all; - u8 padding_00[4]; - struct - { - u32 terminate:1; - u32 stop_generate:1; - u32 stop_calc:1; - u32 stop_draw:1; - u32 started: 1 ; - u32 reserved0:27; - }; - }; -} UnkSPLStruct7; - -typedef struct UnkSPLStruct9_t { - UnkSPLUnion1 unk_00; - VecFx32 unk_04; - fx32 unk_10; - fx32 unk_14; - fx32 unk_18; - VecFx16 unk_1C; - GXRgb unk_22; - fx32 unk_24; - fx32 unk_28; - fx32 unk_2C; - fx16 unk_30; - u16 unk_32; - s16 unk_34; - s16 unk_36; - u16 unk_38; - u16 reserved_3A; - u16 unk_3C; - u16 unk_40; - struct { - u32 unk_00_0 : 8; - u32 unk_01_0 : 8; - u32 unk_02_0 : 8; - u32 reserved_03_0 : 8; - } unk_44; - - struct { - u32 unk_00_0 : 8; - u32 unk_01_0 : 8; - u32 unk_02_0 : 8; - u32 unk_03_0 : 8; - u32 unk_04_0 : 8; - u32 unk_05_0 : 16; - u32 unk_07_0 : 2; - u32 unk_07_2 : 2; - u32 unk_07_4 : 3; - u32 unk_07_7 : 1; - u32 unk_08_0 : 1; - u32 unk_08_1 : 1; - u32 unk_08_2 : 3; - u32 unk_08_5 : 27; - } unk_48; - fx16 unk_54; - fx16 unk_56; - struct { - u32 unk_00_0 : 8; - u32 reserved_01_0 : 24; - } unk_58; -} UnkSPLStruct9; // size=0x5C - -typedef struct UnkSPLStruct10_t { - fx16 unk_00; - fx16 unk_02; - fx16 unk_04; - UnkSPLUnion3 unk_06; - struct { - u16 unk_00_0 : 1; - u16 reserved_00_1 : 15; - } unk_08; - u16 reserved_0A; -} UnkSPLStruct10; // size=0xc - -typedef struct UnkSPLStruct11_t { - GXRgb unk_00; - GXRgb unk_02; - UnkSPLUnion4 unk_04; - struct { - u16 unk_00_0 : 1; - u16 unk_00_1 : 1; - u16 unk_00_2 : 1; - u16 unk_00_3 : 13; - } unk_08; - u16 reserved_0A; -} UnkSPLStruct11; - -typedef struct UnkSPLStruct12_t { - union { - u16 val1; - struct { - u16 val2_00_0 : 5; - u16 val2_00_5 : 5; - u16 val2_01_2 : 5; - u16 val2_reserved_01_7 : 1; - }; - } unk_00; - struct { - u16 unk_00_0 : 8; - u16 unk_01_0 : 1; - u16 unk_01_1 : 7; - } unk_02; - UnkSPLUnion3 unk_04; - u16 reserved_06; -} UnkSPLStruct12; // size=0x8 - -typedef struct UnkSPLStruct13_t { - u8 unk_00[8]; - struct { - u32 unk_00_0 : 8; - u32 unk_01_0 : 8; - u32 unk_02_0 : 1; - u32 unk_02_1 : 1; - u32 reserved_02_2 : 14; - } unk_08; -} UnkSPLStruct13; - -typedef struct UnkSPLStruct14_t { - UnkSPLUnion2 unk_00; - fx16 unk_02; - fx16 unk_04; - u16 unk_06; - struct { - u16 unk_00_0 : 8; - u16 unk_01_0 : 8; - } unk_08; - GXRgb unk_0A; - struct { - u32 unk_00_0 : 8; - u32 unk_01_0 : 8; - u32 unk_02_0 : 8; - u32 unk_03_0 : 8; - u32 unk_04_0 : 2; - u32 unk_04_2 : 2; - u32 unk_04_4 : 1; - u32 unk_04_5 : 1; - u32 unk_04_6 : 1; - u32 reserved_04_7 : 25; - } unk_0C; -} UnkSPLStruct14; - -typedef struct UnkSPLStruct15_t { - u32 unk_00; - UnkSPLUnion5 unk_04; - u32 unk_08; - u32 unk_0C; - u32 unk_10; - u32 unk_14; - u32 unk_18; - u32 unk_1C; -} UnkSPLStruct15; - -typedef struct UnkSPLStruct4_t { - UnkSPLStruct9 * unk_00; - UnkSPLStruct10 * unk_04; - UnkSPLStruct11 * unk_08; - UnkSPLStruct12 * unk_0C; - UnkSPLStruct13 * unk_10; - UnkSPLStruct14 * unk_14; - UnkStruct_020147B8 * unk_18; - u16 unk_1C; - u16 reserved_1E; -} UnkSPLStruct4; - -typedef struct UnkSPLStruct5_t { - const void * unk_00; - u32 unk_04; - u32 unk_08; - UnkSPLUnion5 unk_0C; - u16 unk_10; - u16 unk_12; -} UnkSPLStruct5; - -typedef struct SPLEmitter_t { - struct SPLEmitter_t * unk_00; - struct SPLEmitter_t * unk_04; - UnkSPLStruct3 unk_08; - UnkSPLStruct3 unk_4C; - UnkSPLStruct4 * p_res; - UnkSPLStruct7 unk_94; - VecFx32 unk_98; - VecFx32 unk_A4; - VecFx32 unk_B0; - u16 unk_BC; - fx16 unk_BE; - VecFx16 unk_C0; - u16 unk_C6; - fx32 unk_C8; - fx32 unk_CC; - fx32 unk_D0; - fx32 unk_D4; - fx32 unk_D8; - fx32 unk_DC; - u16 unk_E0; - GXRgb unk_E2; - fx32 unk_E4; - fx16 unk_E8; - fx16 unk_EA; - fx16 unk_EC; - fx16 unk_EE; - struct { - u32 unk_00_0 : 8; - u32 unk_01_0 : 8; - u32 unk_02_0 : 3; - u32 unk_02_3 : 13; - } unk_F0; - VecFx16 unk_F4; - VecFx16 unk_FA; - void (* unk_100)(struct SPLEmitter_t *, unsigned int); - void * unk_104; - union { - u32 unk_108_val1; - u16 unk_108_val2[2]; - u8 unk_108_val3[4]; - } unk_108; -} SPLEmitter; - -typedef struct UnkSPLStruct2_t { - SPLEmitter * unk_00; - int unk_04; - SPLEmitter * unk_08; -} UnkSPLStruct2; // size=0xc - -typedef struct SPLManager_t { - UnkFuncPtr_0209CD00 unk_00; - UnkSPLStruct2 unk_04; - UnkSPLStruct2 unk_10; - UnkSPLStruct3 unk_1C; - UnkSPLStruct4 * unk_28; - UnkSPLStruct5 * unk_2C; - u16 unk_30; - u16 unk_32; - u16 unk_34; - u16 unk_36; - struct { - u32 unk_00_0 : 6; - u32 unk_00_6 : 6; - u32 unk_01_4 : 6; - u32 unk_02_2 : 6; - u32 unk_03_0 : 1; - u32 unk_03_7 : 7; - } unk_38; - s32 unk_3C; - struct { - SPLEmitter * unk_00; - const MtxFx43 * unk_04; - } unk_40; - u16 unk_48; - u16 unk_4A; -} SPLManager; // size=0x4c - -typedef struct FieldFunc { - void (*func)(SPLParticle *, UnkSPLStruct4 *, int); - BOOL loop; -} FieldFunc; - -typedef struct FieldFunc8 { - void (*func)(SPLParticle *, UnkSPLStruct4 *, u8); - BOOL loop; -} FieldFunc8; - -typedef struct SPLArcHdr { - u32 id; - u32 ver; - u16 res_num; - u16 tex_num; - u32 reserved0; - u32 res_size; - u32 tex_size; - u32 tex_offset; - u32 reserved1; -} SPLArcHdr; - -typedef void (*UnkSPLFuncPtr0)(SPLEmitter *, void *); - -void SPL_0209C400(SPLManager * param0); -void SPL_0209C444(SPLManager * param0, SPLEmitter * param1); -SPLEmitter * SPL_0209C4D8(SPLManager * param0, int param1, void (* param2)(struct SPLEmitter_t *)); -void SPL_0209C5E0(SPLManager * param0, const MtxFx43 * param1); -SPLEmitter * SPL_0209C56C(SPLManager * param0, int param1, const VecFx32 * param2); -void SPL_0209C6A8(SPLManager * param0); -BOOL SPL_0209C7E0(SPLManager * param0); -BOOL SPL_0209C7F4(SPLManager * param0); -BOOL SPL_0209C808(SPLManager * param0, u32 (* param1)(u32, BOOL)); -BOOL SPL_0209C8BC(SPLManager * param0, u32 (* param1)(u32, BOOL)); -void SPL_0209C988(SPLManager * param0, const void * param1); -SPLManager * SPL_0209CD00(UnkFuncPtr_0209CD00 param0, u16 param1, u16 param2, u16 param3, u16 param4, u16 param5); - - - -void sub_020A1DA0(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_scl_in_out -void sub_020A1BD4(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_clr_in_out -void sub_020A1AF8(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_alp_in_out -void sub_020A1A94(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_tex_ptn_anm -void sub_020A1A48(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_chld_scl_out -void sub_020A19F0(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_chld_alp_out - -void sub_020A08DC(SPLEmitter *emtr, SPLList *list); -void sub_020A05BC(SPLParticle *ptcl, SPLEmitter *emtr, SPLList *list); - -void sub_020A1768(SPLEmitter *emtr); -void sub_020A1608(VecFx32 *ptclPos, VecFx32 *pos, SPLEmitter *emtr); - -void sub_0209D998(SPLEmitter *emtr, UnkSPLStruct4 *res, const VecFx32 *param2); -void sub_0209CF00(SPLManager *mgr); -void sub_0209D150(SPLManager *mgr, SPLEmitter *emtr); - -u32 sub_0209CE90(u32 param0, BOOL param1); -u32 sub_0209CEC8(u32 param0, BOOL param1); - -void sub_0209D064(SPLManager *mgr); -void sub_0209CF7C(SPLManager *mgr); - -typedef void(*DrawFunc)(SPLManager *mgr, SPLParticle *ptcl); -typedef void(*SetTexFunc)(UnkSPLStruct5 *tex); - -void sub_0209FAB8(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_bb -void sub_0209ECF0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_dbb -void sub_0209E650(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_pol -void sub_0209DD54(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_dpl - -void sub_0209FF0C(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_bb -void sub_0209F3D0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_dbb -void sub_0209E9A0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_pol -void sub_0209E1D4(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_dpl - -void sub_0209DC68(UnkSPLStruct5 *tex); // spl_set_tex -void sub_0209DC64(UnkSPLStruct5 *tex); // spl_set_tex_dummy - -void sub_020A0358(fx32 sin, fx32 cos, MtxFx43 *mat); -void sub_020A0398(fx32 sin, fx32 cos, MtxFx43 *mat); - -void sub_020A0444(fx16 s, fx16 t, fx16 offsetX, fx16 offsetZ); -void sub_020A0500(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY); - -void spl_generate(SPLEmitter *emtr, SPLList *list); static inline void SPL_UnkInline1 (SPLEmitter * param0, const VecFx32 * param1) { diff --git a/lib/spl/include/spl_behavior.h b/lib/spl/include/spl_behavior.h index 0b504af61d..2fa3408bb0 100644 --- a/lib/spl/include/spl_behavior.h +++ b/lib/spl/include/spl_behavior.h @@ -3,7 +3,7 @@ #include -#include "spl.h" +#include "spl_emitter.h" typedef struct SPLGravityBehavior { VecFx16 mag; @@ -44,11 +44,11 @@ typedef struct SPLConvergenceBehavior { } SPLConvergenceBehavior; -void SPL_020A2204(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); -void SPL_020A213C(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); -void SPL_020A20B8(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); -void SPL_020A1FE0(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); -void SPL_020A1EC4(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); -void SPL_020A1E30(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter_t *param3); +void SPL_020A2204(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); +void SPL_020A213C(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); +void SPL_020A20B8(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); +void SPL_020A1FE0(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); +void SPL_020A1EC4(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); +void SPL_020A1E30(const void *param0, SPLParticle *param1, VecFx32 *param2, struct SPLEmitter *param3); #endif // SPL_BEHAVIOR_H diff --git a/lib/spl/include/spl_emitter.h b/lib/spl/include/spl_emitter.h new file mode 100644 index 0000000000..8391d660fb --- /dev/null +++ b/lib/spl/include/spl_emitter.h @@ -0,0 +1,76 @@ +#ifndef SPL_EMITTER_H +#define SPL_EMITTER_H + +#include + +#include "spl_particle.h" +#include "spl_resource.h" + +typedef struct UnkSPLStruct7 { + union + { + u32 all; + u8 padding_00[4]; + struct + { + u32 terminate:1; + u32 stop_generate:1; + u32 stop_calc:1; + u32 stop_draw:1; + u32 started: 1 ; + u32 reserved0:27; + }; + }; +} UnkSPLStruct7; + +typedef struct SPLEmitter { + struct SPLEmitter * unk_00; + struct SPLEmitter * unk_04; + UnkSPLStruct3 unk_08; + UnkSPLStruct3 unk_4C; + UnkSPLStruct4 * p_res; + UnkSPLStruct7 unk_94; + VecFx32 unk_98; + VecFx32 unk_A4; + VecFx32 unk_B0; + u16 unk_BC; + fx16 unk_BE; + VecFx16 unk_C0; + u16 unk_C6; + fx32 unk_C8; + fx32 unk_CC; + fx32 unk_D0; + fx32 unk_D4; + fx32 unk_D8; + fx32 unk_DC; + u16 unk_E0; + GXRgb unk_E2; + fx32 unk_E4; + fx16 unk_E8; + fx16 unk_EA; + fx16 unk_EC; + fx16 unk_EE; + struct { + u32 unk_00_0 : 8; + u32 unk_01_0 : 8; + u32 unk_02_0 : 3; + u32 unk_02_3 : 13; + } unk_F0; + VecFx16 unk_F4; + VecFx16 unk_FA; + void (* unk_100)(struct SPLEmitter *, unsigned int); + void * unk_104; + union { + u32 unk_108_val1; + u16 unk_108_val2[2]; + u8 unk_108_val3[4]; + } unk_108; +} SPLEmitter; + +typedef struct UnkSPLStruct2_t { + SPLEmitter * unk_00; + int unk_04; + SPLEmitter * unk_08; +} UnkSPLStruct2; // size=0xc + +#endif // SPL_EMITTER_H diff --git a/lib/spl/include/spl_internal.h b/lib/spl/include/spl_internal.h new file mode 100644 index 0000000000..78e6de596c --- /dev/null +++ b/lib/spl/include/spl_internal.h @@ -0,0 +1,47 @@ +#ifndef SPL_INTERNAL_H +#define SPL_INTERNAL_H + +#include +#include + +#include "spl_manager.h" +#include "spl_particle.h" +#include "spl_emitter.h" +#include "spl_resource.h" +#include "spl_list.h" + + +#define GX_RGB_R(RGB) (((RGB) >> GX_RGB_R_SHIFT) & 31) +#define GX_RGB_G(RGB) (((RGB) >> GX_RGB_G_SHIFT) & 31) +#define GX_RGB_B(RGB) (((RGB) >> GX_RGB_B_SHIFT) & 31) + +#define GX_RGB_R_(rgb) (rgb & GX_RGB_R_MASK) +#define GX_RGB_G_(rgb) (rgb & GX_RGB_G_MASK) +#define GX_RGB_B_(rgb) (rgb & GX_RGB_B_MASK) + + +void sub_0209FAB8(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209ECF0(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209E650(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209DD54(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209FF0C(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209F3D0(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209E9A0(SPLManager *mgr, SPLParticle *ptcl); +void sub_0209E1D4(SPLManager *mgr, SPLParticle *ptcl); + +void sub_020A1DA0(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_scl_in_out +void sub_020A1BD4(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_clr_in_out +void sub_020A1AF8(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_alp_in_out +void sub_020A1A94(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_tex_ptn_anm +void sub_020A1A48(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_chld_scl_out +void sub_020A19F0(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate); // spl_chld_alp_out + +void sub_020A08DC(SPLEmitter *emtr, SPLList *list); +void sub_020A05BC(SPLParticle *ptcl, SPLEmitter *emtr, SPLList *list); + +void sub_0209D150(SPLManager *mgr, SPLEmitter *emtr); +void sub_0209CF00(SPLManager *mgr); +void sub_0209D998(SPLEmitter *emtr, UnkSPLStruct4 *res, const VecFx32 *pos); +void spl_generate(SPLEmitter *emtr, SPLList *list); + +#endif // SPL_INTERNAL_H diff --git a/lib/spl/include/spl_manager.h b/lib/spl/include/spl_manager.h new file mode 100644 index 0000000000..433af74bba --- /dev/null +++ b/lib/spl/include/spl_manager.h @@ -0,0 +1,54 @@ +#ifndef SPL_MANAGER_H +#define SPL_MANAGER_H + +#include + +#include "spl_particle.h" +#include "spl_emitter.h" +#include "spl_texture.h" + +typedef void *(* UnkFuncPtr_0209CD00)(u32); + +typedef struct SPLManager_t { + UnkFuncPtr_0209CD00 unk_00; + UnkSPLStruct2 unk_04; + UnkSPLStruct2 unk_10; + UnkSPLStruct3 unk_1C; + UnkSPLStruct4 * unk_28; + UnkSPLStruct5 * unk_2C; + u16 unk_30; + u16 unk_32; + u16 unk_34; + u16 unk_36; + struct { + u32 unk_00_0 : 6; + u32 unk_00_6 : 6; + u32 unk_01_4 : 6; + u32 unk_02_2 : 6; + u32 unk_03_0 : 1; + u32 unk_03_7 : 7; + } unk_38; + s32 unk_3C; + struct { + SPLEmitter * unk_00; + const MtxFx43 * unk_04; + } unk_40; + u16 unk_48; + u16 unk_4A; +} SPLManager; // size=0x4c + + +void SPL_0209C400(SPLManager * param0); +void SPL_0209C444(SPLManager * param0, SPLEmitter * param1); +SPLEmitter * SPL_0209C4D8(SPLManager * param0, int param1, void (* param2)(struct SPLEmitter *)); +void SPL_0209C5E0(SPLManager * param0, const MtxFx43 * param1); +SPLEmitter * SPL_0209C56C(SPLManager * param0, int param1, const VecFx32 * param2); +void SPL_0209C6A8(SPLManager * param0); +BOOL SPL_0209C7E0(SPLManager * param0); +BOOL SPL_0209C7F4(SPLManager * param0); +BOOL SPL_0209C808(SPLManager * param0, u32 (* param1)(u32, BOOL)); +BOOL SPL_0209C8BC(SPLManager * param0, u32 (* param1)(u32, BOOL)); +void SPL_0209C988(SPLManager * param0, const void * param1); +SPLManager * SPL_0209CD00(UnkFuncPtr_0209CD00 param0, u16 param1, u16 param2, u16 param3, u16 param4, u16 param5); + +#endif // SPL_MANAGER_H diff --git a/lib/spl/include/spl_particle.h b/lib/spl/include/spl_particle.h new file mode 100644 index 0000000000..dba1ae3a75 --- /dev/null +++ b/lib/spl/include/spl_particle.h @@ -0,0 +1,40 @@ +#ifndef SPL_PARTICLE_H +#define SPL_PARTICLE_H + +#include +#include + + +typedef struct SPLParticle_t { + struct SPLParticle_t *unk_00; + struct SPLParticle_t *unk_04; + VecFx32 unk_08; + VecFx32 unk_14; + u16 unk_20; + s16 unk_22; + u16 unk_24; + u16 unk_26; + u16 unk_28; + u16 unk_2A; + struct { + u16 unk_00 : 8; + u16 unk_01 : 8; + } unk_2C; + struct { + u16 unk_00_0 : 5; + u16 unk_00_5 : 5; + u16 unk_01_2 : 6; + } unk_2E; + fx32 unk_30; + fx16 unk_34; + GXRgb unk_36; + VecFx32 unk_38; +} SPLParticle; // size=0x44 + +typedef struct UnkSPLStruct3_t { + SPLParticle *unk_00; + int unk_04; + SPLParticle *unk_08; +} UnkSPLStruct3; // size=0xc + +#endif // SPL_PARTICLE_H \ No newline at end of file diff --git a/lib/spl/include/spl_resource.h b/lib/spl/include/spl_resource.h new file mode 100644 index 0000000000..d44b96be8b --- /dev/null +++ b/lib/spl/include/spl_resource.h @@ -0,0 +1,228 @@ +#ifndef SPL_RESOURCE_H +#define SPL_RESOURCE_H + +#include + +#include "struct_defs/struct_020147B8.h" + + +typedef struct SPLArcHdr { + u32 id; + u32 ver; + u16 res_num; + u16 tex_num; + u32 reserved0; + u32 res_size; + u32 tex_size; + u32 tex_offset; + u32 reserved1; +} SPLArcHdr; + +typedef union { + u32 unk_00; + struct { + u32 unk_04_0 : 4; + u32 unk_04_4 : 2; + u32 unk_04_6 : 2; + u32 unk_05_0 : 1; + u32 unk_05_1 : 1; + u32 unk_05_2 : 1; + u32 unk_05_3 : 1; + u32 unk_05_4 : 1; + u32 unk_05_5 : 1; + u32 unk_05_6 : 1; + u32 unk_05_7 : 1; + u32 unk_06_0 : 1; + u32 unk_06_1 : 2; + u32 unk_06_3 : 1; + u32 unk_06_4 : 1; + u32 unk_06_5 : 1; + u32 unk_06_6 : 1; + u32 unk_06_7 : 1; + u32 unk_07_0 : 1; + u32 unk_07_1 : 1; + u32 unk_07_2 : 1; + u32 unk_07_3 : 1; + u32 unk_07_4 : 1; + u32 unk_07_5 : 1; + u32 unk_07_6 : 1; + u32 unk_07_7 : 1; + }; +} UnkSPLUnion1; // size=0x4 + +typedef union { + u16 unk_00; + struct { + u16 unk_02_0 : 1; + u16 unk_02_1 : 1; + u16 unk_02_2 : 1; + u16 unk_02_3 : 2; + u16 unk_02_5 : 1; + u16 unk_02_6 : 1; + u16 unk_02_7 : 2; + u16 unk_03_1 : 2; + u16 unk_03_3 : 1; + u16 reserved_03_4 : 4; + }; +} UnkSPLUnion2; // size=0x2 + +typedef union { + u16 val1; + struct { + u16 val2_00 : 8; + u16 val2_01 : 8; + }; +} UnkSPLUnion3; // size=0x2 + +typedef union { + u32 unk_00; + struct { + u32 unk_04_0 : 8; + u32 unk_05_0 : 8; + u32 unk_06_0 : 8; + u32 unk_07_0 : 8; + }; +} UnkSPLUnion4; // size=0x4 + +typedef struct UnkSPLStruct9_t { + UnkSPLUnion1 unk_00; + VecFx32 unk_04; + fx32 unk_10; + fx32 unk_14; + fx32 unk_18; + VecFx16 unk_1C; + GXRgb unk_22; + fx32 unk_24; + fx32 unk_28; + fx32 unk_2C; + fx16 unk_30; + u16 unk_32; + s16 unk_34; + s16 unk_36; + u16 unk_38; + u16 reserved_3A; + u16 unk_3C; + u16 unk_40; + struct { + u32 unk_00_0 : 8; + u32 unk_01_0 : 8; + u32 unk_02_0 : 8; + u32 reserved_03_0 : 8; + } unk_44; + + struct { + u32 unk_00_0 : 8; + u32 unk_01_0 : 8; + u32 unk_02_0 : 8; + u32 unk_03_0 : 8; + u32 unk_04_0 : 8; + u32 unk_05_0 : 16; + u32 unk_07_0 : 2; + u32 unk_07_2 : 2; + u32 unk_07_4 : 3; + u32 unk_07_7 : 1; + u32 unk_08_0 : 1; + u32 unk_08_1 : 1; + u32 unk_08_2 : 3; + u32 unk_08_5 : 27; + } unk_48; + fx16 unk_54; + fx16 unk_56; + struct { + u32 unk_00_0 : 8; + u32 reserved_01_0 : 24; + } unk_58; +} UnkSPLStruct9; // size=0x5C + +typedef struct UnkSPLStruct10_t { + fx16 unk_00; + fx16 unk_02; + fx16 unk_04; + UnkSPLUnion3 unk_06; + struct { + u16 unk_00_0 : 1; + u16 reserved_00_1 : 15; + } unk_08; + u16 reserved_0A; +} UnkSPLStruct10; // size=0xc + +typedef struct UnkSPLStruct11_t { + GXRgb unk_00; + GXRgb unk_02; + UnkSPLUnion4 unk_04; + struct { + u16 unk_00_0 : 1; + u16 unk_00_1 : 1; + u16 unk_00_2 : 1; + u16 unk_00_3 : 13; + } unk_08; + u16 reserved_0A; +} UnkSPLStruct11; + +typedef struct UnkSPLStruct12_t { + union { + u16 val1; + struct { + u16 val2_00_0 : 5; + u16 val2_00_5 : 5; + u16 val2_01_2 : 5; + u16 val2_reserved_01_7 : 1; + }; + } unk_00; + struct { + u16 unk_00_0 : 8; + u16 unk_01_0 : 1; + u16 unk_01_1 : 7; + } unk_02; + UnkSPLUnion3 unk_04; + u16 reserved_06; +} UnkSPLStruct12; // size=0x8 + +typedef struct UnkSPLStruct13_t { + u8 unk_00[8]; + struct { + u32 unk_00_0 : 8; + u32 unk_01_0 : 8; + u32 unk_02_0 : 1; + u32 unk_02_1 : 1; + u32 reserved_02_2 : 14; + } unk_08; +} UnkSPLStruct13; + +typedef struct UnkSPLStruct14_t { + UnkSPLUnion2 unk_00; + fx16 unk_02; + fx16 unk_04; + u16 unk_06; + struct { + u16 unk_00_0 : 8; + u16 unk_01_0 : 8; + } unk_08; + GXRgb unk_0A; + struct { + u32 unk_00_0 : 8; + u32 unk_01_0 : 8; + u32 unk_02_0 : 8; + u32 unk_03_0 : 8; + u32 unk_04_0 : 2; + u32 unk_04_2 : 2; + u32 unk_04_4 : 1; + u32 unk_04_5 : 1; + u32 unk_04_6 : 1; + u32 reserved_04_7 : 25; + } unk_0C; +} UnkSPLStruct14; + +typedef struct UnkSPLStruct4_t { + UnkSPLStruct9 * unk_00; + UnkSPLStruct10 * unk_04; + UnkSPLStruct11 * unk_08; + UnkSPLStruct12 * unk_0C; + UnkSPLStruct13 * unk_10; + UnkSPLStruct14 * unk_14; + UnkStruct_020147B8 * unk_18; + u16 unk_1C; + u16 reserved_1E; +} UnkSPLStruct4; + +#endif // SPL_RESOURCE_H diff --git a/lib/spl/include/spl_texture.h b/lib/spl/include/spl_texture.h new file mode 100644 index 0000000000..8fedfa5bd1 --- /dev/null +++ b/lib/spl/include/spl_texture.h @@ -0,0 +1,42 @@ +#ifndef SPL_TEXTURE_H +#define SPL_TEXTURE_H + +#include + + +typedef union { + u32 val1; + struct { + u32 val2_00_0 : 4; + u32 val2_00_4 : 4; + u32 val2_01_0 : 4; + u32 val2_01_4 : 2; + u32 val2_01_6 : 2; + u32 val2_02_0 : 1; + u32 val2_02_1 : 1; + u32 val2_02_2 : 8; + u32 val2_03_2 : 6; + }; +} UnkSPLUnion5; + +typedef struct UnkSPLStruct15_t { + u32 unk_00; + UnkSPLUnion5 unk_04; + u32 unk_08; + u32 unk_0C; + u32 unk_10; + u32 unk_14; + u32 unk_18; + u32 unk_1C; +} UnkSPLStruct15; + +typedef struct UnkSPLStruct5_t { + const void * unk_00; + u32 unk_04; + u32 unk_08; + UnkSPLUnion5 unk_0C; + u16 unk_10; + u16 unk_12; +} UnkSPLStruct5; + +#endif // SPL_TEXTURE_H diff --git a/lib/spl/src/spl_behavior.c b/lib/spl/src/spl_behavior.c index fc51cfb03e..a3a8832e9a 100644 --- a/lib/spl/src/spl_behavior.c +++ b/lib/spl/src/spl_behavior.c @@ -2,10 +2,10 @@ #include #include -#include "spl.h" #include "spl_behavior.h" #include "spl_random.h" + void SPL_020A2204(const void *obj, SPLParticle *ptcl, VecFx32 *pos, SPLEmitter *emtr) { SPLGravityBehavior *gravity = (SPLGravityBehavior *)obj; diff --git a/lib/spl/src/unk_0209C400.c b/lib/spl/src/unk_0209C400.c index fd056122cb..89ce33c67a 100644 --- a/lib/spl/src/unk_0209C400.c +++ b/lib/spl/src/unk_0209C400.c @@ -1,18 +1,27 @@ -#include "spl.h" -#include "spl_behavior.h" - #include #include #include +#include "spl_list.h" +#include "spl_manager.h" +#include "spl_behavior.h" +#include "spl_internal.h" + #define DECODE_WH(X) ((u16)(1 << ((X) + 3))) -u32 sub_0209CEC8(u32 size, BOOL is4x4) +typedef void (*UnkSPLFuncPtr0)(SPLEmitter *, void *); + + +static u32 sub_0209CE90(u32 param0, BOOL param1); +static u32 sub_0209CEC8(u32 param0, BOOL param1); + + +static u32 sub_0209CEC8(u32 size, BOOL is4x4) { return (NNS_GfdAllocTexVram(size, is4x4, 0) & 0xFFFF) * 8; } -u32 sub_0209CE90(u32 size, BOOL is4Pltt) +static u32 sub_0209CE90(u32 size, BOOL is4Pltt) { return (NNS_GfdAllocPlttVram(size, is4Pltt, 0) & 0xFFFF) * 8; } diff --git a/lib/spl/src/unk_0209CF00.c b/lib/spl/src/unk_0209CF00.c index 7cfda896cd..ad55b5b519 100644 --- a/lib/spl/src/unk_0209CF00.c +++ b/lib/spl/src/unk_0209CF00.c @@ -3,9 +3,36 @@ #include #include -#include "spl.h" +#include "spl_emitter.h" +#include "spl_texture.h" +#include "spl_manager.h" +#include "spl_particle.h" +#include "spl_internal.h" +#include "spl_list.h" -void sub_0209DC68(UnkSPLStruct5 *tex) + +typedef void(*DrawFunc)(SPLManager *mgr, SPLParticle *ptcl); +typedef void(*SetTexFunc)(UnkSPLStruct5 *tex); + +typedef struct FieldFunc { + void (*func)(SPLParticle *, UnkSPLStruct4 *, int); + BOOL loop; +} FieldFunc; + +typedef struct FieldFunc8 { + void (*func)(SPLParticle *, UnkSPLStruct4 *, u8); + BOOL loop; +} FieldFunc8; + +static void sub_0209DC68(UnkSPLStruct5 *tex); // spl_set_tex +static void sub_0209DC64(UnkSPLStruct5 *tex); // spl_set_tex_dummy +static void sub_0209D064(SPLManager *mgr); +static void sub_0209CF7C(SPLManager *mgr); +void sub_0209D998(SPLEmitter *emtr, UnkSPLStruct4 *res, const VecFx32 *param2); +void sub_0209CF00(SPLManager *mgr); +void sub_0209D150(SPLManager *mgr, SPLEmitter *emtr); + +static void sub_0209DC68(UnkSPLStruct5 *tex) { UnkSPLUnion5 param = tex->unk_0C; @@ -26,7 +53,7 @@ void sub_0209DC68(UnkSPLStruct5 *tex) G3_MtxMode(GX_MTXMODE_POSITION); } -void sub_0209DC64(UnkSPLStruct5 *tex) +static void sub_0209DC64(UnkSPLStruct5 *tex) { } @@ -289,7 +316,7 @@ void sub_0209D150(SPLManager *mgr, SPLEmitter *emtr) } } -void sub_0209D064(SPLManager *mgr) +static void sub_0209D064(SPLManager *mgr) { SPLEmitter *emtr; UnkSPLStruct9 *resBase; @@ -331,7 +358,7 @@ void sub_0209D064(SPLManager *mgr) } } -void sub_0209CF7C(SPLManager *mgr) +static void sub_0209CF7C(SPLManager *mgr) { SPLEmitter *emtr; UnkSPLStruct4 *res; diff --git a/lib/spl/src/unk_0209DD54.c b/lib/spl/src/unk_0209DD54.c index da1ef7399b..2773189049 100644 --- a/lib/spl/src/unk_0209DD54.c +++ b/lib/spl/src/unk_0209DD54.c @@ -6,11 +6,29 @@ #include #include -#include "spl.h" +#include "spl_particle.h" +#include "spl_manager.h" +#include "spl_internal.h" typedef void (*RotFunc)(fx32 sin, fx32 cos, MtxFx43 *rot); typedef void (*DrawPlaneFunc)(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY); +void sub_0209FAB8(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_bb +void sub_0209ECF0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_dbb +void sub_0209E650(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_pol +void sub_0209DD54(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_chld_dpl + +void sub_0209FF0C(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_bb +void sub_0209F3D0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_dbb +void sub_0209E9A0(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_pol +void sub_0209E1D4(SPLManager *mgr, SPLParticle *ptcl); // spl_draw_dpl + +static void sub_020A0500(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY); +static void sub_020A0444(fx16 s, fx16 t, fx16 offsetX, fx16 offsetZ); + +static void sub_020A0398(fx32 sin, fx32 cos, MtxFx43 *mat); +static void sub_020A0358(fx32 sin, fx32 cos, MtxFx43 *mat); + static DrawPlaneFunc Unk_02100DA0[2] = { sub_020A0500, sub_020A0444, @@ -21,7 +39,7 @@ static RotFunc Unk_02100DA8[2] = { sub_020A0398, }; -void sub_020A0500(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY) +static void sub_020A0500(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY) { G3_Begin(GX_BEGIN_QUADS); @@ -40,7 +58,7 @@ void sub_020A0500(fx16 s, fx16 t, fx16 offsetX, fx16 offsetY) G3_End(); } -void sub_020A0444(fx16 s, fx16 t, fx16 offsetX, fx16 offsetZ) +static void sub_020A0444(fx16 s, fx16 t, fx16 offsetX, fx16 offsetZ) { G3_Begin(GX_BEGIN_QUADS); @@ -59,7 +77,7 @@ void sub_020A0444(fx16 s, fx16 t, fx16 offsetX, fx16 offsetZ) G3_End(); } -void sub_020A0398(fx32 sin, fx32 cos, MtxFx43 *mat) +static void sub_020A0398(fx32 sin, fx32 cos, MtxFx43 *mat) { fx32 C, Sm, Sp; @@ -82,7 +100,7 @@ void sub_020A0398(fx32 sin, fx32 cos, MtxFx43 *mat) mat->m[3][2] = 0; } -void sub_020A0358(fx32 sin, fx32 cos, MtxFx43 *mat) +static void sub_020A0358(fx32 sin, fx32 cos, MtxFx43 *mat) { mat->m[0][0] = cos; mat->m[1][0] = 0; diff --git a/lib/spl/src/unk_020A05BC.c b/lib/spl/src/unk_020A05BC.c index 97eb9cfc41..3a9d8f501c 100644 --- a/lib/spl/src/unk_020A05BC.c +++ b/lib/spl/src/unk_020A05BC.c @@ -2,14 +2,21 @@ #include #include -#include "spl.h" +#include "spl_emitter.h" +#include "spl_list.h" #include "spl_random.h" -VecFx16 Unk_02100DB0 = { 0, FX16_ONE, 0 }; #define IS_IN_RANGE(x, min, max) (((x) - (min)) <= ((max) - (min))) -void sub_020A1768(SPLEmitter *emtr) + +static void sub_020A1768(SPLEmitter *emtr); +static void sub_020A1608(VecFx32 *ptclPos, VecFx32 *pos, SPLEmitter *emtr); + +VecFx16 Unk_02100DB0 = { 0, FX16_ONE, 0 }; + + +static void sub_020A1768(SPLEmitter *emtr) { VecFx16 vec, axis; @@ -55,7 +62,7 @@ void sub_020A1768(SPLEmitter *emtr) VEC_Fx16Normalize(&emtr->unk_FA, &emtr->unk_FA); } -void sub_020A1608(VecFx32 *ptclPos, VecFx32 *pos, SPLEmitter *emtr) +static void sub_020A1608(VecFx32 *ptclPos, VecFx32 *pos, SPLEmitter *emtr) { VecFx16 vec; VEC_Fx16CrossProduct(&emtr->unk_F4, &emtr->unk_FA, &vec); diff --git a/lib/spl/src/unk_020A19F0.c b/lib/spl/src/unk_020A19F0.c index 9985d5408f..1edde39d6b 100644 --- a/lib/spl/src/unk_020A19F0.c +++ b/lib/spl/src/unk_020A19F0.c @@ -1,8 +1,9 @@ #include #include -#include "spl.h" #include "spl_random.h" +#include "spl_internal.h" + void sub_020A1DA0(SPLParticle *ptcl, UnkSPLStruct4 *res, int lifeRate) { diff --git a/src/unk_02014000.c b/src/unk_02014000.c index ce8411c541..3989d0b0c0 100644 --- a/src/unk_02014000.c +++ b/src/unk_02014000.c @@ -16,7 +16,7 @@ #include "camera.h" #include "heap.h" #include "narc.h" -#include "spl.h" +#include "spl_behavior.h" #include "sys_task.h" #include "sys_task_manager.h"