From c41c548d7349d74d53fc3e12747822cd9c7bc8fc Mon Sep 17 00:00:00 2001 From: foxcam <118768446+thefoxcam@users.noreply.github.com> Date: Thu, 15 Aug 2024 02:09:23 +0000 Subject: [PATCH] various mn work (#1431) --- config/GALE01/symbols.txt | 24 +-- src/melee/lb/lb_00F9.c | 5 + src/melee/lb/lb_00F9.h | 1 + src/melee/lb/lbaudio_ax.h | 2 +- src/melee/mn/inlines.h | 79 +++++++++ src/melee/mn/mn_2295.h | 33 +++- src/melee/mn/mndeflicker.c | 160 +++++------------ src/melee/mn/mnhyaku.c | 97 ++++------- src/melee/mn/mnsound.c | 292 ++++++++++++++++++++++++++++++++ src/melee/mn/mnsound.h | 1 - src/melee/mn/mnsoundtest.c | 97 +++++++++++ src/melee/mn/mnsoundtest.h | 3 + src/melee/mn/types.h | 36 ++++ src/sysdolphin/baselib/sislib.c | 95 +++++------ src/sysdolphin/baselib/sislib.h | 48 +++--- 15 files changed, 704 insertions(+), 269 deletions(-) create mode 100644 src/melee/mn/inlines.h diff --git a/config/GALE01/symbols.txt b/config/GALE01/symbols.txt index c9c930a770..24a6f60560 100644 --- a/config/GALE01/symbols.txt +++ b/config/GALE01/symbols.txt @@ -22984,9 +22984,14 @@ mnVibration_803EECE0 = .data:0x803EECE0; // type:object size:0xC scope:global mnVibration_803EECEC = .data:0x803EECEC; // type:object size:0xC scope:global mnVibration_803EECF8 = .data:0x803EECF8; // type:object size:0xC scope:global data:float mnVibration_803EED04 = .data:0x803EED04; // type:object size:0x1D4 scope:global -mnSound_803EEED8 = .data:0x803EEED8; // type:object size:0x3C scope:global -mnSound_803EEF14 = .data:0x803EEF14; // type:object size:0xC scope:global data:4byte -mnSound_803EEF20 = .data:0x803EEF20; // type:object size:0xB8 scope:global data:4byte +mnSound_803EEED8 = .data:0x803EEED8; // type:object size:0x54 scope:global data:float +mnSound_803EEF2C = .data:0x803EEF2C; // type:object size:0x16 scope:global data:string +mnSound_803EEF44 = .data:0x803EEF44; // type:object size:0x9 scope:global data:string +mnSound_803EEF50 = .data:0x803EEF50; // type:object size:0xA scope:global data:string +mnSound_803EEF5C = .data:0x803EEF5C; // type:object size:0x17 scope:global data:string +mnSound_803EEF74 = .data:0x803EEF74; // type:object size:0x1B scope:global data:string +mnSound_803EEF90 = .data:0x803EEF90; // type:object size:0x1E scope:global data:string +mnSound_803EEFB0 = .data:0x803EEFB0; // type:object size:0x20 scope:global data:string mnDeflicker_803EEFD8 = .data:0x803EEFD8; // type:object size:0xC scope:global ...data.0 = .data:0x803EEFD8; // type:label scope:local mnDeflicker_803EEFE4 = .data:0x803EEFE4; // type:object size:0xC scope:global @@ -22998,10 +23003,8 @@ mnDeflicker_803EEFF0 = .data:0x803EEFF0; // type:object size:0xC scope:global @234 = .data:0x803EF048; // type:object size:0x1B scope:local data:string @235 = .data:0x803EF064; // type:object size:0x1F scope:local data:string @236 = .data:0x803EF084; // type:object size:0x21 scope:local data:string -mnSoundTest_803EF0A8 = .data:0x803EF0A8; // type:object size:0x18 scope:global -mnSoundTest_803EF0C0 = .data:0x803EF0C0; // type:object size:0xC scope:global data:float -mnSoundTest_803EF0CC = .data:0x803EF0CC; // type:object size:0x3C scope:global -mnSoundTest_803EF108 = .data:0x803EF108; // type:object size:0x498 scope:global data:float +mnSoundTest_803EF0A8 = .data:0x803EF0A8; // type:object size:0x6C scope:global data:float +mnSoundTest_803EF114 = .data:0x803EF114; // type:object size:0x48C scope:global mnLanguage_803EF5A0 = .data:0x803EF5A0; // type:object size:0xC scope:global mnLanguage_803EF5AC = .data:0x803EF5AC; // type:object size:0xBC scope:global mnHyaku_803EF668 = .data:0x803EF668; // type:object size:0xC scope:global @@ -25013,7 +25016,8 @@ mnVibration_804A0868 = .bss:0x804A0868; // type:object size:0x10 scope:global da mnVibration_804A0878 = .bss:0x804A0878; // type:object size:0x10 scope:global data:4byte mnVibration_804A0888 = .bss:0x804A0888; // type:object size:0x10 scope:global data:4byte mnVibration_804A0898 = .bss:0x804A0898; // type:object size:0x10 scope:global data:4byte -mnSound_804A08A8 = .bss:0x804A08A8; // type:object size:0x10 scope:global data:4byte +mnSound_804A08A8 = .bss:0x804A08A8; // type:object size:0x4 scope:global data:4byte +mnSound_804A08AC = .bss:0x804A08AC; // type:object size:0xC scope:global data:4byte mnDeflicker_804A08B8 = .bss:0x804A08B8; // type:object size:0x10 scope:global data:4byte ...bss.0 = .bss:0x804A08B8; // type:label scope:local mnSoundTest_804A08C8 = .bss:0x804A08C8; // type:object size:0x10 scope:global data:4byte @@ -26221,8 +26225,8 @@ mnVibration_804D4FE8 = .sdata:0x804D4FE8; // type:object size:0x8 scope:global d mnVibration_804D4FF0 = .sdata:0x804D4FF0; // type:object size:0x4 scope:global mnVibration_804D4FF4 = .sdata:0x804D4FF4; // type:object size:0x8 scope:global mnVibration_804D4FFC = .sdata:0x804D4FFC; // type:object size:0xC scope:global -mnSound_804D5008 = .sdata:0x804D5008; // type:object size:0x8 scope:global -mnSound_804D5010 = .sdata:0x804D5010; // type:object size:0x8 scope:global +mnSound_804D5008 = .sdata:0x804D5008; // type:object size:0x8 scope:global data:string +mnSound_804D5010 = .sdata:0x804D5010; // type:object size:0x8 scope:global data:string mnLanguage_804D5018 = .sdata:0x804D5018; // type:object size:0x8 scope:global mnHyaku_804D5020 = .sdata:0x804D5020; // type:object size:0x8 scope:global mnEvent_804D5028 = .sdata:0x804D5028; // type:object size:0x4 scope:global data:4byte diff --git a/src/melee/lb/lb_00F9.c b/src/melee/lb/lb_00F9.c index bb7f8a18fc..e68566bec0 100644 --- a/src/melee/lb/lb_00F9.c +++ b/src/melee/lb/lb_00F9.c @@ -18,3 +18,8 @@ void lb_8000F9F8(HSD_JObj* jobj) lb_80011B74(HSD_JObjGetDObj(jobj), JOBJ_UNK_B26); } } + +/* +@note: The number of HSD_JObjs that get passed into arg1 is the number of +variable arguments passed until -1 is passed. lb_80011E24 +*/ diff --git a/src/melee/lb/lb_00F9.h b/src/melee/lb/lb_00F9.h index 53697d3882..87f54924f3 100644 --- a/src/melee/lb/lb_00F9.h +++ b/src/melee/lb/lb_00F9.h @@ -22,6 +22,7 @@ /* 011ABC */ UNK_RET lb_80011ABC(UNK_PARAMS); /* 011AC4 */ HSD_LObj* lb_80011AC4(UNK_T); /* 011C18 */ void lb_80011C18(HSD_JObj* jobj, u32 flags); +/* 011E24 */ int lb_80011E24(HSD_JObj*, HSD_JObj**, ...); /* 0122C8 */ void lb_800122C8(HSD_ImageDesc*, int, int, int); /* 0122FC */ void lb_800121FC(HSD_ImageDesc*, int, int, int, int); /* 013B14 */ HSD_CObj* lb_80013B14(HSD_CameraDescPerspective*); diff --git a/src/melee/lb/lbaudio_ax.h b/src/melee/lb/lbaudio_ax.h index 8888e7a896..c6f25f8dea 100644 --- a/src/melee/lb/lbaudio_ax.h +++ b/src/melee/lb/lbaudio_ax.h @@ -19,7 +19,7 @@ /* 0237A8 */ u32 lbAudioAx_800237A8(enum_t sfx_id, u8 sfx_vol, u8 sfx_pan); /* 023870 */ int lbAudioAx_80023870(int, int, int, int); /* 023F28 */ void lbAudioAx_80023F28(s32); -/* 024030 */ void lbAudioAx_80024030(s32); +/* 024030 */ void lbAudioAx_80024030(s32); // plays menu SFX /* 024184 */ int lbAudioAx_80024184(int, int, int, int); /* 02438C */ void lbAudioAx_8002438C(s32); /* 024B1C */ void lbAudioAx_80024B1C(s32, s32); diff --git a/src/melee/mn/inlines.h b/src/melee/mn/inlines.h new file mode 100644 index 0000000000..9139d012c0 --- /dev/null +++ b/src/melee/mn/inlines.h @@ -0,0 +1,79 @@ +#include "lb/lb_00F9.h" +#include "lb/lbaudio_ax.h" +#include "mn/mn_2295.h" +#include "mn/types.h" + +#include +#include +#include + +typedef enum _MenuEvent { + MenuEvent_Up = 1 << 0, + MenuEvent_Down = 1 << 1, + MenuEvent_Left = 1 << 2, + MenuEvent_Right = 1 << 3, + MenuEvent_Unk = 1 << 4, + MenuEvent_Back = 1 << 5, +} MenuEvent; + +#define GET_MENU(gobj) ((Menu*) HSD_GObjGetUserData(gobj)) + +static inline void Menu_DecrementAnimTimer(void) +{ + mn_804D6BC8.x0--; + mn_804D6BC8.x2 = 0; + mn_804D6BC8.x4 = 0; +} + +static inline u64 Menu_GetEvents(void) +{ + return mn_804A04F0.x8 = mn_80229624(4); +} + +// @todo: The functions `fn_8017435C`, `fn_80174338`, and `fn_80174380` are +// probably deduplicated clones of these. + +static inline void Menu_SFX_Back(void) +{ + lbAudioAx_80024030(0); +} + +static inline void Menu_SFX_Forward(void) +{ + lbAudioAx_80024030(1); +} + +static inline void Menu_SFX_Move(void) +{ + lbAudioAx_80024030(2); +} + +static inline void Menu_InitCenterText(Menu* menu, u8 val) +{ + HSD_Text* text = + HSD_SisLib_803A5ACC(0, 1, -9.5F, 9.1F, 17.0F, 364.68332F, 38.38772F); + menu->text = text; + text->x24.x = 0.0521F; + text->x24.y = 0.0521F; + HSD_SisLib_803A6368(text, val); +} + +// @todo: One of these inlines is probably correct + +static inline void inline_test_3(HSD_JObj* jobj, f32 val, u8 loops, + HSD_TypeMask type) +{ + HSD_JObjReqAnimAll(jobj, val); + mn_8022F3D8(jobj, loops, type); + HSD_JObjAnimAll(jobj); +} + +static inline void inline_test_4(HSD_GObj* gobj, f32 val, u8 loops, + HSD_TypeMask type) +{ + HSD_JObj* jobj; + lb_80011E24(GET_JOBJ(gobj), &jobj, 5, -1); + HSD_JObjReqAnimAll(jobj, val); + mn_8022F3D8(jobj, loops, type); + HSD_JObjAnimAll(jobj); +} diff --git a/src/melee/mn/mn_2295.h b/src/melee/mn/mn_2295.h index 85b7ea2b4f..038ed78602 100644 --- a/src/melee/mn/mn_2295.h +++ b/src/melee/mn/mn_2295.h @@ -3,6 +3,37 @@ #include -/* 22F3D8 */ void mn_8022F3D8(void); +#include "dolphin/mtx/types.h" + +#include + +void mn_8022F3D8(void*, u8, HSD_TypeMask); +void mn_8022ED6C(HSD_JObj*, Vec3*); +u32 mn_80229624(u32); // returns a bitfield of controller inputs +void mn_80229894(s32, s32, s32); // go to a specific part of the menu? +float mn_8022EC18(HSD_JObj*, float*, int); +void mn_802295AC(void); +void mn_80229860(s32); +f32 mn_8022F298(HSD_JObj*); + +typedef struct _mn_unk1 { + u8 x0; + u8 x1; + s16 x2; + s32 x4; + u64 x8; + u8 x10; + u8 x11; +} mn_unk1; + +typedef struct _mn_unk2 { + u16 x0; + u16 x2; + s32 x4; +} mn_unk2; + +extern HSD_Archive* mn_804D6BB8; +extern mn_unk1 mn_804A04F0; +extern mn_unk2 mn_804D6BC8; #endif diff --git a/src/melee/mn/mndeflicker.c b/src/melee/mn/mndeflicker.c index 0feab5e4ea..0d514b1e6e 100644 --- a/src/melee/mn/mndeflicker.c +++ b/src/melee/mn/mndeflicker.c @@ -1,10 +1,15 @@ #include #include +#include "lb/lb_00F9.h" #include "lb/lbarchive.h" +#include "mn/inlines.h" +#include "mn/mn_2295.h" +#include "mn/types.h" #include "sc/types.h" #include +#include #include #include #include @@ -14,38 +19,9 @@ #include #include #include +#include #include -//@todo: float order hack -static f32 force_float_order_0(u32 x) -{ - return (f32) x; -} -static f32 force_float_order_1(void) -{ - return -9.5F; -} -static f32 force_float_order_2(void) -{ - return 9.1F; -} -static f32 force_float_order_3(void) -{ - return 17.0F; -} -static f32 force_float_order_4(void) -{ - return 364.68332F; -} -static f32 force_float_order_5(void) -{ - return 38.38772F; -} -static f32 force_float_order_6(void) -{ - return 0.0521F; -} - void mnDeflicker_8024A168(HSD_GObj* gobj); void mnDeflicker_8024A2E8(HSD_GObj* gobj); void mnDeflicker_8024A344(HSD_GObj* gobj); @@ -53,89 +29,50 @@ void mnDeflicker_8024A3E8(HSD_GObj* gobj); void mnDeflicker_8024A4BC(HSD_GObj* arg0); void mnDeflicker_8024A6C4(HSD_GObj* arg0); -typedef struct { - unsigned char x0; - void* x4; -} gobj_user_data; - -extern struct { - unsigned char x0; - char x1; - short x2; - int x4; - unsigned long long x8; - char x10; - char x11; -} mn_804A04F0; - -extern struct { - unsigned short x0; - short x2; - int x4; -} mn_804D6BC8; - -struct ThreeFloats { - float x0; - float x4; - float x8; -}; - -unsigned int mn_80229624(int); -void mn_80229894(int, int, int); -void mn_8022F3D8(void*, int, int); -void mn_8022ED6C(HSD_JObj*, struct ThreeFloats*); -float mn_8022EC18(HSD_JObj*, float*, int); void gmMainLib_8015F4F4(u8); void gmMainLib_8015F588(u8); -void lbAudioAx_80024030(int); -int lb_80011E24(HSD_JObj*, HSD_JObj**, ...); -void lb_8001CE00(void); -void lb_8001CE00(void); u8 gmMainLib_8015F4E8(void); +void lb_8001CE00(void); -extern void* mn_804D6BB8; unsigned char mnDeflicker_804D6C3C; HSD_GObj* mnDeflicker_804D6C38; StaticModelDesc mnDeflicker_804A08B8; -struct ThreeFloats mnDeflicker_803EEFD8 = { 0.0F, 19.0F, -0.1F }; -struct ThreeFloats mnDeflicker_803EEFE4 = { 20.0F, 30.0F, -0.1F }; -struct ThreeFloats mnDeflicker_803EEFF0 = { 50.0F, 350.0F, 50.0F }; +Vec3 mnDeflicker_803EEFD8 = { 0.0F, 19.0F, -0.1F }; +Vec3 mnDeflicker_803EEFE4 = { 20.0F, 30.0F, -0.1F }; +Vec3 mnDeflicker_803EEFF0 = { 50.0F, 350.0F, 50.0F }; void mnDeflicker_8024A168(HSD_GObj* gobj) { unsigned long long ty_permuter; - HSD_JObj* asd[3]; - int stack[9]; - gobj_user_data* unk = mnDeflicker_804D6C38->user_data; + HSD_JObj* asd[2]; + int stack[5]; + Menu* menu = GET_MENU(mnDeflicker_804D6C38); if (mn_804D6BC8.x0 != 0) { - mn_804D6BC8.x0--; - mn_804D6BC8.x2 = 0; - mn_804D6BC8.x4 = 0; + Menu_DecrementAnimTimer(); return; } else { - ty_permuter = (mn_804A04F0.x8 = mn_80229624(4)); + ty_permuter = Menu_GetEvents(); if ((ty_permuter & 0x20)) { - lbAudioAx_80024030(0); + Menu_SFX_Back(); gmMainLib_8015F4F4( - ((gobj_user_data*) mnDeflicker_804D6C38->user_data) - ->x0); // inline + ((Menu*) mnDeflicker_804D6C38->user_data)->cursor); // inline lb_8001CE00(); mn_804A04F0.x11 = 0; mn_80229894(4, 2, 3); } else if (mnDeflicker_804D6C3C && (ty_permuter & 0x200)) { unsigned char x; - lbAudioAx_80024030(2); - unk->x0 = (unk->x0 == 0); - x = unk->x0; // inline arg? + PAD_STACK(4); + Menu_SFX_Move(); + menu->cursor = (menu->cursor == 0); + x = menu->cursor; // inline arg? lb_80011E24(mnDeflicker_804D6C38->hsd_obj, asd, 5, -1); HSD_JObjReqAnimAll(asd[0], (f32) x); mn_8022F3D8(asd[0], 0xFF, 0x20); HSD_JObjAnimAll(asd[0]); gmMainLib_8015F588(x); gmMainLib_8015F4F4( - ((gobj_user_data*) mnDeflicker_804D6C38->user_data) - ->x0); // inline + ((Menu*) mnDeflicker_804D6C38->user_data)->cursor); // inline } } } @@ -143,25 +80,24 @@ void mnDeflicker_8024A168(HSD_GObj* gobj) void mnDeflicker_8024A2E8(HSD_GObj* gobj) { int x[2]; - float f = mn_8022EC18(GET_JOBJ(gobj), &mnDeflicker_803EEFE4.x0, 0x400); - if (f == mnDeflicker_803EEFE4.x4) { + float f = mn_8022EC18(GET_JOBJ(gobj), &mnDeflicker_803EEFE4.x, 0x400); + if (f == mnDeflicker_803EEFE4.y) { HSD_GObjPLink_80390228(gobj); } } void mnDeflicker_8024A344(HSD_GObj* gobj) { - gobj_user_data* data = gobj->user_data; + Menu* menu = GET_MENU(gobj); HSD_JObj* jobj = GET_JOBJ(gobj); if (mn_804A04F0.x0 != 0x15) { HSD_GObjProc* p; HSD_GObjProc_8038FE24(HSD_GObj_804D7838); p = HSD_GObjProc_8038FD54(gobj, &mnDeflicker_8024A2E8, 0); p->flags_3 = HSD_GObj_804D783C; - HSD_SisLib_803A5CC4(data->x4); + HSD_SisLib_803A5CC4(menu->text); } else { HSD_JObj* asd; - int stack; lb_80011E24(jobj, &asd, 6, -1); mn_8022ED6C(asd, &mnDeflicker_803EEFF0); } @@ -169,18 +105,17 @@ void mnDeflicker_8024A344(HSD_GObj* gobj) void mnDeflicker_8024A3E8(HSD_GObj* gobj) { - int stack[2]; - gobj_user_data* data = gobj->user_data; + Menu* menu = GET_MENU(gobj); HSD_JObj* jobj = GET_JOBJ(gobj); HSD_GObjProc* p; if (mn_804A04F0.x0 != 0x15) { HSD_GObjProc_8038FE24(HSD_GObj_804D7838); p = HSD_GObjProc_8038FD54(gobj, &mnDeflicker_8024A2E8, 0); p->flags_3 = HSD_GObj_804D783C; - HSD_SisLib_803A5CC4(data->x4); + HSD_SisLib_803A5CC4(menu->text); } else { - float f = mn_8022EC18(jobj, &mnDeflicker_803EEFD8.x0, 0x400); - if (f == mnDeflicker_803EEFD8.x4) { + float f = mn_8022EC18(jobj, &mnDeflicker_803EEFD8.x, 0x400); + if (f == mnDeflicker_803EEFD8.y) { HSD_GObjProc_8038FE24(HSD_GObj_804D7838); p = HSD_GObjProc_8038FD54(gobj, &mnDeflicker_8024A344, 0); p->flags_3 = HSD_GObj_804D783C; @@ -189,33 +124,24 @@ void mnDeflicker_8024A3E8(HSD_GObj* gobj) } } -// this feels off -#define GET_GOBJ_USER_DATA(gobj) ((gobj_user_data*) HSD_GObjGetUserData(gobj)) -static inline void inline_test(void) +static void mnDeflicker_8024A4BC_inline(void) { - sislib_UnkAllocReturn* temp_r3_6; - gobj_user_data* user_data = GET_GOBJ_USER_DATA(mnDeflicker_804D6C38); - if (user_data->x4) { - HSD_SisLib_803A5CC4(user_data->x4); + Menu* menu = GET_MENU(mnDeflicker_804D6C38); + if (menu->text) { + HSD_SisLib_803A5CC4(menu->text); } - temp_r3_6 = - HSD_SisLib_803A5ACC(0, 1, -9.5F, 9.1F, 17.0F, 364.68332F, 38.38772F); - user_data->x4 = temp_r3_6; - temp_r3_6->x24.x = 0.0521F; - temp_r3_6->x24.y = 0.0521F; - HSD_SisLib_803A6368(temp_r3_6, 0xBD); + Menu_InitCenterText(menu, 0xBD); } void mnDeflicker_8024A4BC(HSD_GObj* arg0) { int fake1[3]; HSD_JObj* sp1C; - int fake2[1]; HSD_GObj* gobj; HSD_GObjProc* proc; HSD_JObj* jobj; u8 temp_r29; - gobj_user_data* user_data; + Menu* menu; PAD_STACK(4); gobj = GObj_Create(HSD_GOBJ_CLASS_ITEM, 7U, 0x80); @@ -229,17 +155,17 @@ void mnDeflicker_8024A4BC(HSD_GObj* arg0) mnDeflicker_804A08B8.shapeanim_joint); HSD_JObjReqAnimAll(jobj, 0.0F); HSD_JObjAnimAll(jobj); - user_data = HSD_MemAlloc(8); - if (user_data == NULL) { + menu = HSD_MemAlloc(8); + if (menu == NULL) { OSReport("Can't get user_data.\n"); __assert("mndeflicker.c", 344, "user_data"); } - user_data->x0 = gmMainLib_8015F4E8(); - user_data->x4 = 0; - GObj_InitUserData(gobj, 0, HSD_Free, user_data); + menu->cursor = gmMainLib_8015F4E8(); + menu->text = NULL; + GObj_InitUserData(gobj, 0, HSD_Free, menu); proc = HSD_GObjProc_8038FD54(gobj, mnDeflicker_8024A3E8, 0U); proc->flags_3 = HSD_GObj_804D783C; - temp_r29 = user_data->x0; + temp_r29 = menu->cursor; lb_80011E24(GET_JOBJ(gobj), &sp1C, 5, -1); HSD_JObjReqAnimAll(sp1C, (f32) temp_r29); mn_8022F3D8(sp1C, 0xFF, 0x20); @@ -248,7 +174,7 @@ void mnDeflicker_8024A4BC(HSD_GObj* arg0) HSD_JObjReqAnimAll(jobj, 0.0F); mn_8022F3D8(jobj, 0xFF, 0x400); HSD_JObjAnimAll(jobj); - inline_test(); + mnDeflicker_8024A4BC_inline(); } void mnDeflicker_8024A6C4(HSD_GObj* arg0) diff --git a/src/melee/mn/mnhyaku.c b/src/melee/mn/mnhyaku.c index c2c8cd4368..1fcffb4297 100644 --- a/src/melee/mn/mnhyaku.c +++ b/src/melee/mn/mnhyaku.c @@ -2,8 +2,12 @@ #include "sc/forward.h" #include +#include "lb/lb_00F9.h" #include "lb/lbarchive.h" #include "lb/lbaudio_ax.h" +#include "mn/inlines.h" +#include "mn/mn_2295.h" +#include "mn/types.h" #include "sc/types.h" #include @@ -18,22 +22,16 @@ #include void mnHyaku_8024C68C(HSD_GObj*); +void mnHyaku_8024CB94(u8); +void mnHyaku_8024CD64(u8); + void fn_8024C9F0(HSD_GObj*); void fn_8024CA50(HSD_GObj*); void fn_8024CAC8(HSD_GObj*); -void mnHyaku_8024CB94(u8); -void mnHyaku_8024CD64(u8); extern HSD_GObj* mnHyaku_804D6C58; -s32 mn_80229624(s32); -s32 mn_80229894(s32, s32, s32); -float mn_8022EC18(HSD_JObj*, float*, int); -void mn_802295AC(void); void gm_801677E8(void); -void mn_80229860(s32); -f32 mn_8022F298(HSD_JObj*); -void mn_8022F3D8(HSD_JObj*, s32, s32); void lbAudioAx_8002702C(s32, s32, s32); void lbAudioAx_80027168(void); @@ -48,30 +46,6 @@ static f32 mnHyaku_803EF680[6] = { StaticModelDesc mnHyaku_804A08E8; -extern HSD_Archive* mn_804D6BB8; - -typedef struct { - unsigned char x0; - void* x4; -} gobj_user_data; - -// @todo move and add proper types -extern struct { - unsigned short x0; - short x2; - int x4; -} mn_804D6BC8; - -extern struct { - unsigned char x0; - char x1; - short x2; - int x4; - unsigned long long x8; - char x10; - char x11; -} mn_804A04F0; - static inline void mnHyaku_8024C68C_inline(HSD_JObj* jobj, s32 val) { f32 temp_f31 = mn_8022F298(jobj); @@ -82,31 +56,22 @@ static inline void mnHyaku_8024C68C_inline(HSD_JObj* jobj, s32 val) HSD_JObjAnimAll(jobj); } +// these are most likely ids to text static u8 vals[] = { 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0x00, 0x00 }; -// @todo: this is a common inline in mn -#define GET_GOBJ_USER_DATA(gobj) ((gobj_user_data*) HSD_GObjGetUserData(gobj)) static inline void mnHyaku_8024C68C_inline_2(HSD_GObj* gobj) { - gobj_user_data* user_data = GET_GOBJ_USER_DATA(gobj); - if (user_data->x4) { - HSD_SisLib_803A5CC4(user_data->x4); - } - { - u8 val = vals[user_data->x0]; - sislib_UnkAllocReturn* temp_r3_6 = HSD_SisLib_803A5ACC( - 0, 1, -9.5F, 9.1F, 17.0F, 364.68332F, 38.38772F); - user_data->x4 = temp_r3_6; - temp_r3_6->x24.x = 0.0521F; - temp_r3_6->x24.y = 0.0521F; - HSD_SisLib_803A6368(temp_r3_6, val); + Menu* menu = GET_MENU(gobj); + if (menu->text) { + HSD_SisLib_803A5CC4(menu->text); } + Menu_InitCenterText(menu, vals[menu->cursor]); } void mnHyaku_8024C68C(HSD_GObj* arg0) { u64 ret; - gobj_user_data* unk = mnHyaku_804D6C58->user_data; + Menu* menu = GET_MENU(mnHyaku_804D6C58); if (mn_804D6BC8.x0 != 0) { mn_804D6BC8.x0--; mn_804D6BC8.x2 = 0; @@ -124,7 +89,7 @@ void mnHyaku_8024C68C(HSD_GObj* arg0) lbAudioAx_80024030(1); mn_802295AC(); gm_801677E8(); - switch (unk->x0) { + switch (menu->cursor) { case 0: mn_80229860(0x21); return; @@ -147,15 +112,15 @@ void mnHyaku_8024C68C(HSD_GObj* arg0) } else { if (ret & 4) { lbAudioAx_80024030(2); - unk->x0 = (unk->x0 == 0) ? 5 : (unk->x0 - 1); - mnHyaku_8024C68C_inline(mnHyaku_804D6C58->hsd_obj, unk->x0); + menu->cursor = (menu->cursor == 0) ? 5 : (menu->cursor - 1); + mnHyaku_8024C68C_inline(mnHyaku_804D6C58->hsd_obj, menu->cursor); mnHyaku_8024C68C_inline_2(mnHyaku_804D6C58); return; } if (ret & 8) { lbAudioAx_80024030(2); - unk->x0 = (unk->x0 == 5) ? 0 : (unk->x0 + 1); - mnHyaku_8024C68C_inline(mnHyaku_804D6C58->hsd_obj, unk->x0); + menu->cursor = (menu->cursor == 5) ? 0 : (menu->cursor + 1); + mnHyaku_8024C68C_inline(mnHyaku_804D6C58->hsd_obj, menu->cursor); mnHyaku_8024C68C_inline_2(mnHyaku_804D6C58); } } @@ -172,12 +137,12 @@ void fn_8024C9F0(HSD_GObj* gobj) void fn_8024CA50(HSD_GObj* gobj) { HSD_GObjProc* gobj_proc; - gobj_user_data* user_data = gobj->user_data; + Menu* menu = GET_MENU(gobj); if (mn_804A04F0.x0 != 0x21) { HSD_GObjProc_8038FE24(HSD_GObj_804D7838); gobj_proc = HSD_GObjProc_8038FD54(gobj, fn_8024C9F0, 0U); gobj_proc->flags_3 = HSD_GObj_804D783C; - HSD_SisLib_803A5CC4(user_data->x4); + HSD_SisLib_803A5CC4(menu->text); } } @@ -185,12 +150,12 @@ void fn_8024CAC8(HSD_GObj* gobj) { { HSD_GObjProc* gobj_proc; - gobj_user_data* user_data = gobj->user_data; + Menu* menu = GET_MENU(gobj); if (mn_804A04F0.x0 != 0x21) { HSD_GObjProc_8038FE24(HSD_GObj_804D7838); gobj_proc = HSD_GObjProc_8038FD54(gobj, fn_8024C9F0, 0U); gobj_proc->flags_3 = HSD_GObj_804D783C; - HSD_SisLib_803A5CC4(user_data->x4); + HSD_SisLib_803A5CC4(menu->text); return; } } @@ -210,7 +175,7 @@ void mnHyaku_8024CB94(u8 arg0) HSD_GObjProc* proc; HSD_JObj* jobj; u8 temp_r29; - gobj_user_data* user_data; + Menu* menu; HSD_GObjProc* temp_r3_4; gobj = GObj_Create(HSD_GOBJ_CLASS_ITEM, 7U, 0x80); @@ -224,16 +189,16 @@ void mnHyaku_8024CB94(u8 arg0) mnHyaku_804A08E8.shapeanim_joint); HSD_JObjReqAnimAll(jobj, 0.0F); HSD_JObjAnimAll(jobj); - user_data = HSD_MemAlloc(8); - if (user_data == NULL) { - OSReport("Can't get user_data.\n"); - __assert("mnhyaku.c", 344, "user_data"); + menu = HSD_MemAlloc(8); + if (menu == NULL) { + OSReport("Can't get menu.\n"); + __assert("mnhyaku.c", 344, "menu"); } - user_data->x0 = arg0; - user_data->x4 = 0; - GObj_InitUserData(gobj, 0, HSD_Free, user_data); + menu->cursor = arg0; + menu->text = 0; + GObj_InitUserData(gobj, 0, HSD_Free, menu); - mnHyaku_8024C68C_inline(jobj, user_data->x0); + mnHyaku_8024C68C_inline(jobj, menu->cursor); temp_r3_4 = HSD_GObjProc_8038FD54(gobj, fn_8024CAC8, 0U); temp_r3_4->flags_3 = HSD_GObj_804D783C; mnHyaku_8024C68C_inline_2(gobj); diff --git a/src/melee/mn/mnsound.c b/src/melee/mn/mnsound.c index 8b13789179..fbe695354a 100644 --- a/src/melee/mn/mnsound.c +++ b/src/melee/mn/mnsound.c @@ -1 +1,293 @@ +#include "gm/gmmain_lib.h" +#include "lb/lbarchive.h" +#include "mn/inlines.h" +#include "mn/mn_2295.h" +#include "mn/types.h" +#include "sc/types.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void mnSound_802492CC(HSD_GObj*); + +Vec3 mnSound_803EEED8[] = { { 0.0f, 199.0f, 0.0f }, { 0.0f, 29.0f, 0.0f }, + { 30.0f, 59.0f, 30.0f }, { 10.0f, 15.0f, -0.1f }, + { 0.0f, 5.0f, -0.1f }, { 0.0f, 3.0f, -0.1f }, + { 4.0f, 7.0f, -0.1f } }; + +void gmMainLib_8015ED80(u8); /* extern */ +void gm_801602C0(u8); /* extern */ +void lbAudioAx_80024C08(u8); /* extern */ +void lb_8001CE00(void); /* extern */ + +StaticModelDesc mnSound_desc; +HSD_GObj* mnSound_804D6C30; + +static void mnSound_VolumeAnim(HSD_JObj* jobj, s32 sound_music_mix, + s32 anim_id) +{ + Vec3 pos_0; + Vec3 pos_1; + HSD_JObj* jobj_anim_2; + HSD_JObj* jobj_anim_1; + HSD_JObj* jobj_anim_0; + lb_80011E24(jobj, &jobj_anim_0, 6, -1); + lb_80011E24(jobj, &jobj_anim_1, 3, -1); + lb_80011E24(jobj, &jobj_anim_2, 4, -1); + HSD_JObjGetTranslation(jobj_anim_1, &pos_0); + HSD_JObjGetTranslation(jobj_anim_2, &pos_1); + HSD_JObjSetTranslateX( + jobj_anim_0, + (((f32) ((s8) sound_music_mix + 100) / 200.0f) * (pos_1.x - pos_0.x)) + + pos_0.x); + if (anim_id != -1) { + HSD_JObjReqAnimAll(jobj_anim_0, mnSound_803EEED8[anim_id].x); + } +} + +static void mnSound_ChannelAnim(HSD_JObj* jobj, s32 channel) +{ + HSD_JObj* jobj_anim[3]; + f32 temp_f31, temp_f30; + lb_80011E24(jobj, &jobj_anim[0], 8, -1); + lb_80011E24(jobj, &jobj_anim[1], 10, -1); + lb_80011E24(jobj, &jobj_anim[2], 9, -1); + temp_f31 = mn_8022F298(jobj_anim[1]); + temp_f30 = mn_8022F298(jobj_anim[2]); + + HSD_JObjReqAnimAll(jobj_anim[0], channel); + HSD_JObjAnimAll(jobj_anim[0]); + + HSD_JObjReqAnimAll(jobj_anim[1], temp_f31); + mn_8022F3D8(jobj_anim[1], 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(jobj_anim[1]); + + HSD_JObjReqAnimAll(jobj_anim[2], temp_f30); + mn_8022F3D8(jobj_anim[2], 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(jobj_anim[2]); +} + +void mnSound_802492CC(HSD_GObj* gobj) +{ + Menu* menu = GET_MENU(mnSound_804D6C30); + u64 events; + if (mn_804D6BC8.x0 != 0) { + Menu_DecrementAnimTimer(); + return; + } + events = Menu_GetEvents(); + if (events & MenuEvent_Back) { + Menu_SFX_Back(); + mn_804A04F0.x11 = 0; + gmMainLib_8015ED80(GET_MENU(mnSound_804D6C30)->unk3); + lb_8001CE00(); + mn_80229894(4, 1, 3); + return; + } + if (events & (MenuEvent_Up | MenuEvent_Down)) { + // switch between the two + Menu_SFX_Move(); + if ((u8) menu->unk2 == 0) { + menu->unk2 = 1; + } else { + menu->unk2 = 0; + } + { + Menu* menu = GET_MENU(mnSound_804D6C30); + HSD_Text* text = menu->text; + if (text != NULL) { + HSD_SisLib_803A5CC4(text); + } + Menu_InitCenterText(menu, (menu->unk2 == 0) ? 0xBB : 0xBC); + } + return; + } + if (events & MenuEvent_Left) { + if (menu->unk2 == 0) { + if (menu->unk1 == 1) { + // switch from mono to stereo + Menu_SFX_Move(); + menu->unk1 = 0; + mnSound_ChannelAnim(GET_JOBJ(mnSound_804D6C30), menu->unk1); + lbAudioAx_80024C08(menu->unk1); + } + } else if ((s8) menu->unk3 > -100) { + // move towards sounds + lbAudioAx_80024030(2); + menu->unk3 -= 5; + mnSound_VolumeAnim(GET_JOBJ(mnSound_804D6C30), menu->unk3, 15); + gm_801602C0(menu->unk3); + gmMainLib_8015ED80(menu->unk3); + } + } else if (events & MenuEvent_Right) { + if (menu->unk2 == 0) { + if (menu->unk1 == 0) { + // switch from stereo to mono + Menu_SFX_Move(); + menu->unk1 = 1; + mnSound_ChannelAnim(GET_JOBJ(mnSound_804D6C30), menu->unk1); + lbAudioAx_80024C08(menu->unk1); + } + } else if ((s8) menu->unk3 < 100) { + // move towards music + lbAudioAx_80024030(2); + menu->unk3 += 5; + mnSound_VolumeAnim(GET_JOBJ(mnSound_804D6C30), menu->unk3, 18); + gm_801602C0(menu->unk3); + gmMainLib_8015ED80(menu->unk3); + } + } +} + +void fn_80249A1C(HSD_GObj* arg0) +{ + HSD_JObj* sp40; + HSD_JObj* sp3C; + HSD_JObj* sp34; + Vec3 sp28; + HSD_JObj* sp20; + HSD_JObj* temp_r3; + f32 temp_f1; + f32 var_f1; + u8 temp_r4; + f32 arg8 = 0.0F; // this should be uninitialized + + HSD_JObj* jobj = arg0->hsd_obj; + Menu* menu = GET_MENU(arg0); + if ((u8) mn_804A04F0.x0 != 0x14) { + HSD_GObjPLink_80390228(arg0); + HSD_SisLib_803A5CC4(menu->text); + return; + } + temp_r4 = menu->cursor; + if (temp_r4 != 0) { + menu->cursor = (u8) (temp_r4 - 1); + if ((u8) menu->cursor != 0) { + HSD_JObjSetFlagsAll(jobj, 0x10U); + return; + } + HSD_JObjClearFlagsAll(jobj, 0x10U); + return; + } + if ((u8) menu->unk2 == 0) { + if ((u8) menu->unk1 == 0) { + lb_80011E24(jobj, &sp34, 0xA, -1); + } else { + lb_80011E24(jobj, &sp34, 9, -1); + } + arg8 = mn_8022EC18(sp34, (f32*) mnSound_803EEED8, 0x80); + } + lb_80011E24((HSD_JObj*) arg0->hsd_obj, &sp20, 6, -1, arg8); + temp_f1 = mn_8022F298(sp20); + if ((mnSound_803EEED8[5].x <= temp_f1) && + ((temp_f1 <= mnSound_803EEED8[5].y) != 0)) + { + sp28 = mnSound_803EEED8[5]; + } else { + sp28 = mnSound_803EEED8[6]; + } + mn_8022ED6C(sp20, &sp28); + lb_80011E24(jobj, &sp40, 0xE, -1); + mn_8022ED6C(sp40, &mnSound_803EEED8[menu->unk2 + 1]); + lb_80011E24(jobj, &sp3C, 0xB, -1); + mn_8022ED6C(sp3C, &mnSound_803EEED8[menu->unk1 + 4]); +} + +u8 gmMainLib_8015ED74(void); /* extern */ +u8 lbAudioAx_80024BD0(void); /* extern */ +StaticModelDesc mnSound_804A08A8; + +void mnSound_80249C08(void) +{ + HSD_GObj* gobj = GObj_Create(6U, 7U, 0x80U); + HSD_JObj* jobj; + Menu* menu; + HSD_GObjProc* proc; + mnSound_804D6C30 = gobj; + jobj = HSD_JObjLoadJoint(mnSound_804A08A8.joint); + HSD_GObjObject_80390A70((HSD_GObj*) gobj, (u8) HSD_GObj_804D7849, jobj); + GObj_SetupGXLink((HSD_GObj*) gobj, HSD_GObj_80391070, 4U, 0x80); + HSD_JObjAddAnimAll(jobj, mnSound_804A08A8.animjoint, + mnSound_804A08A8.matanim_joint, + mnSound_804A08A8.shapeanim_joint); + HSD_JObjReqAnimAll(jobj, 0.0F); + menu = HSD_MemAlloc(8); + if (menu == NULL) { + OSReport("Can't get user_data.\n"); + __assert("mnsound.c", 0x22CU, "user_data"); + } + gmMainLib_8015CC34(); + menu->cursor = 0x14; + menu->unk1 = lbAudioAx_80024BD0(); + menu->unk2 = 0U; + menu->unk3 = gmMainLib_8015ED74(); + menu->text = NULL; + GObj_InitUserData(gobj, 0U, HSD_Free, menu); + proc = HSD_GObjProc_8038FD54(gobj, fn_80249A1C, 0U); + proc->flags_3 = HSD_GObj_804D783C; + + { + Menu* menu = GET_MENU(mnSound_804D6C30); + HSD_Text* text = menu->text; + if (text != NULL) { + HSD_SisLib_803A5CC4(text); + } + Menu_InitCenterText(menu, (menu->unk2 == 0) ? 0xBB : 0xBC); + } + + mnSound_ChannelAnim(GET_JOBJ(gobj), menu->unk1); + + { + HSD_JObj* sp5C; + lb_80011E24(jobj, &sp5C, 6, -1); + HSD_JObjReqAnimAll(sp5C, mnSound_803EEED8[1].x); + HSD_JObjAnimAll(sp5C); + } + + mnSound_VolumeAnim(GET_JOBJ(gobj), menu->unk3, -1); + + { + HSD_JObj* sp64; + HSD_JObj* sp60; + gm_801602C0(menu->unk3); + lb_80011E24(jobj, &sp64, 0xE, -1); + mn_8022ED6C(sp64, &mnSound_803EEED8[menu->unk2 + 1]); + lb_80011E24(jobj, &sp60, 0xB, -1); + HSD_JObjReqAnimAll(sp60, mnSound_803EEED8[menu->unk1 + 4].x); + HSD_JObjAnimAll(sp60); + HSD_JObjSetFlagsAll(jobj, 0x10U); + } +} + +void mnSound_8024A09C(s32 arg0) +{ + s32 spC; + HSD_GObjProc* temp_r3; + HSD_Archive* archive; + + mn_804D6BC8.x0 = 5; + mn_804A04F0.x1 = mn_804A04F0.x0; + mn_804A04F0.x0 = 0x14; // @note: could this be an enum?? + mn_804A04F0.x2 = 0; + archive = mn_804D6BB8; + lbArchive_LoadSections( + archive, (void**) &mnSound_desc.joint, "MenMainConSo_Top_joint", + &mnSound_desc.animjoint, "MenMainConSo_Top_animjoint", + &mnSound_desc.matanim_joint, "MenMainConSo_Top_matanim_joint", + &mnSound_desc.shapeanim_joint, "MenMainConSo_Top_shapeanim_joint", 0); + mnSound_80249C08(); + temp_r3 = + HSD_GObjProc_8038FD54(GObj_Create(0, 1, 0x80), mnSound_802492CC, 0); + temp_r3->flags_3 = HSD_GObj_804D783C; +} diff --git a/src/melee/mn/mnsound.h b/src/melee/mn/mnsound.h index 8b13789179..e69de29bb2 100644 --- a/src/melee/mn/mnsound.h +++ b/src/melee/mn/mnsound.h @@ -1 +0,0 @@ - diff --git a/src/melee/mn/mnsoundtest.c b/src/melee/mn/mnsoundtest.c index 8b13789179..9b893aea5b 100644 --- a/src/melee/mn/mnsoundtest.c +++ b/src/melee/mn/mnsoundtest.c @@ -1 +1,98 @@ +#include +#include +#include "lb/lbarchive.h" +#include "sc/types.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern HSD_PadStatus HSD_PadCopyStatus[4]; + +f32 mnSoundTest_803EF0A8[] = { 0, 19, -0.1, 20, 39, -0.1, 0, + 20, -0.1, 0, 0, -0.1, 0, 200, + 0, 0, 10, -0.1, -2, -6.6, 0, + -1.7, -4.7, 0, -1.7, 2 }; + +void gmMainLib_8015ED74(void); /* extern */ +s32 gm_801601C4(void); /* extern */ +s32 gm_80160244(void); /* extern */ +void lbAudioAx_800245F4(s32); /* extern */ +void lbAudioAx_80024614(s32); /* extern */ +extern s32 mnSoundTest_804D6C48; +extern s32 mnSoundTest_804D6C4C; + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + f32 unk4; + f32 unk8; + f32 unkC; + UNK_T unk10; + HSD_Text* unk14; + HSD_Text* unk18; +} soundtest_user_data; + +void mnSoundTest_8024A790(HSD_GObj* arg0) +{ + f32 temp_f1; + f32 temp_f1_2; + f32 temp_f30; + f32 temp_f31; + s32 temp_r30; + s32 temp_r30_2; + s32 temp_r3; + s32 temp_r3_2; + + soundtest_user_data* temp_r31 = (soundtest_user_data*) arg0->user_data; + // control the volume by holding down L trigger + temp_f31 = 1.0f * (1.0f - HSD_PadCopyStatus->nml_analogL) * + (1.0f - HSD_PadCopyStatus[1].nml_analogL) * + (1.0f - HSD_PadCopyStatus[2].nml_analogL) * + (1.0f - HSD_PadCopyStatus[3].nml_analogL); + // R trigger doesn't seem to do anything + temp_f30 = 1.0f * (1.0f - HSD_PadCopyStatus->nml_analogR) * + (1.0f - HSD_PadCopyStatus[1].nml_analogR) * + (1.0f - HSD_PadCopyStatus[2].nml_analogR) * + (1.0f - HSD_PadCopyStatus[3].nml_analogR); + if ((temp_f31 < 0.9f) || (temp_r31->unk8 < 1.0f)) { + gmMainLib_8015ED74(); + temp_f1 = temp_f31 * (f32) gm_801601C4(); + temp_r30 = (s32) (temp_r31->unk8 * temp_f1); + lbAudioAx_80024614(temp_r30); + mnSoundTest_804D6C48 = temp_r30; + } else { + gmMainLib_8015ED74(); + temp_r3 = gm_801601C4(); + if (temp_r3 != (s32) mnSoundTest_804D6C48) { + lbAudioAx_80024614(temp_r3); + mnSoundTest_804D6C48 = temp_r3; + } + } + if ((temp_f30 < 0.9f) || (temp_r31->unkC < 1.0f)) { + gmMainLib_8015ED74(); + temp_f1_2 = temp_f30 * (f32) gm_80160244(); + temp_r30_2 = (s32) (temp_r31->unkC * temp_f1_2); + lbAudioAx_800245F4(temp_r30_2); + mnSoundTest_804D6C4C = temp_r30_2; + return; + } + gmMainLib_8015ED74(); + temp_r3_2 = gm_80160244(); + if (temp_r3_2 != (s32) mnSoundTest_804D6C4C) { + lbAudioAx_800245F4(temp_r3_2); + mnSoundTest_804D6C4C = temp_r3_2; + } +} diff --git a/src/melee/mn/mnsoundtest.h b/src/melee/mn/mnsoundtest.h index 8b13789179..b29f1ae049 100644 --- a/src/melee/mn/mnsoundtest.h +++ b/src/melee/mn/mnsoundtest.h @@ -1 +1,4 @@ +#include +extern HSD_PadStatus HSD_PadCopyStatus[4]; +void mnSoundTest_8024A790(HSD_GObj*); diff --git a/src/melee/mn/types.h b/src/melee/mn/types.h index aa47045339..894e66303a 100644 --- a/src/melee/mn/types.h +++ b/src/melee/mn/types.h @@ -6,6 +6,42 @@ #include #include +typedef struct { + u8 cursor; // @todo are these arbitrary variables the menus can use in any + // way? + u8 unk1; + u8 unk2; + u8 unk3; + HSD_Text* text; +} Menu; +// size 0x8 + +#ifdef M2CTX +typedef struct Menu_GObj Menu_GObj; +struct Menu_GObj { + /* +0 */ u16 classifier; + /* +2 */ u8 p_link; + /* +3 */ u8 gx_link; + /* +4 */ u8 p_priority; + /* +5 */ u8 render_priority; + /* +6 */ u8 obj_kind; + /* +7 */ u8 user_data_kind; + /* +8 */ Menu_GObj* next; + /* +C */ Menu_GObj* prev; + /* +10 */ Menu_GObj* next_gx; + /* +14 */ Menu_GObj* prev_gx; + /* +18 */ HSD_GObjProc* proc; + /* +1C */ void (*rendered)(Menu_GObj* gobj, s32 code); + /* +20 */ u64 gxlink_prios; + /* +28 */ HSD_JObj* hsd_obj; + /* +2C */ Menu* user_data; + /* +30 */ void (*user_data_remove_func)(Fighter* data); + /* +34 */ void* x34_unk; +}; +#else +typedef struct HSD_GObj Menu_GObj; +#endif + struct PlayerInitData { /*0x00*/ u8 character_kind; /*0x01*/ u8 slot_type; diff --git a/src/sysdolphin/baselib/sislib.c b/src/sysdolphin/baselib/sislib.c index ab7ba5b341..6e78101d6c 100644 --- a/src/sysdolphin/baselib/sislib.c +++ b/src/sysdolphin/baselib/sislib.c @@ -27,7 +27,7 @@ HSD_CObjDesc HSD_SisLib_8040C4B8; sislib_UnkAllocData* HSD_SisLib_804D7970; sislib_UnkAllocData* HSD_SisLib_804D7974; -sislib_UnkAllocReturn* HSD_SisLib_804D7978; +HSD_Text* HSD_SisLib_804D7978; sislib_UnkAlloc3* HSD_SisLib_804D797C; // extern ? *HSD_SisLib_804D796C; @@ -110,8 +110,7 @@ void* HSD_SisLib_803A5798(s32 size) HSD_SisLib_804D7970 = (sislib_UnkAllocData*) (temp_r26 + size); HSD_SisLib_804D7970->data_0 = temp_r25; - HSD_SisLib_804D7970->data_1 = - (sislib_UnkAllocReturn*) (HSD_SisLib_804D7970 + 1); + HSD_SisLib_804D7970->data_1 = (HSD_Text*) (HSD_SisLib_804D7970 + 1); HSD_SisLib_804D7970->size = temp_r27; var_r31->size = size; } else { @@ -159,7 +158,7 @@ void HSD_SisLib_803A594C(void* arg0) arg0 = var_r7; HSD_SisLib_804D7970->data_0 = var_r4->data_0; HSD_SisLib_804D7970->data_1 = - (sislib_UnkAllocReturn*) (HSD_SisLib_804D7970 + 1); + (HSD_Text*) (HSD_SisLib_804D7970 + 1); HSD_SisLib_804D7970->size = new_size; return; } @@ -179,14 +178,14 @@ void HSD_SisLib_803A594C(void* arg0) } } -void HSD_SisLib_803A5A2C(sislib_UnkAllocReturn* arg0) +void HSD_SisLib_803A5A2C(HSD_Text* arg0) { HSD_GObj* temp_r0; sislib_UnkAllocData* temp_r3; - sislib_UnkAllocReturn* temp_r3_2; - sislib_UnkAllocReturn* temp_r3_3; - sislib_UnkAllocReturn* var_r31; - sislib_UnkAllocReturn* var_r4; + HSD_Text* temp_r3_2; + HSD_Text* temp_r3_3; + HSD_Text* var_r31; + HSD_Text* var_r4; var_r4 = NULL; var_r31 = HSD_SisLib_804D7978; @@ -196,7 +195,7 @@ void HSD_SisLib_803A5A2C(sislib_UnkAllocReturn* arg0) if (var_r4 != NULL) { var_r4->x54 = temp_r0; } else { - HSD_SisLib_804D7978 = (sislib_UnkAllocReturn*) temp_r0; + HSD_SisLib_804D7978 = (HSD_Text*) temp_r0; } temp_r3 = var_r31->x64; if (temp_r3 != NULL) { @@ -214,14 +213,14 @@ void HSD_SisLib_803A5A2C(sislib_UnkAllocReturn* arg0) return; } var_r4 = var_r31; - var_r31 = (sislib_UnkAllocReturn*) temp_r0; + var_r31 = (HSD_Text*) temp_r0; } } -void HSD_SisLib_803A5CC4(sislib_UnkAllocReturn* arg0) +void HSD_SisLib_803A5CC4(HSD_Text* arg0) { HSD_GObj* temp_r3; - sislib_UnkAllocReturn* var_r31; + HSD_Text* var_r31; var_r31 = HSD_SisLib_804D7978; while (var_r31 != NULL) { @@ -235,15 +234,15 @@ void HSD_SisLib_803A5CC4(sislib_UnkAllocReturn* arg0) HSD_SisLib_803A5A2C(var_r31); return; } - var_r31 = (sislib_UnkAllocReturn*) var_r31->x54; + var_r31 = (HSD_Text*) var_r31->x54; } } void HSD_SisLib_803A5D30(void) { HSD_GObj* temp_r3; - sislib_UnkAllocReturn* temp_r29; - sislib_UnkAllocReturn* var_r30; + HSD_Text* temp_r29; + HSD_Text* var_r30; var_r30 = HSD_SisLib_804D7978; while (var_r30 != NULL) { @@ -266,8 +265,8 @@ void HSD_SisLib_803A5DA0(s32 arg0) sislib_UnkAlloc3* temp_r30_2; sislib_UnkAlloc3* var_r28; sislib_UnkAlloc3* var_r29_2; - sislib_UnkAllocReturn* temp_r30; - sislib_UnkAllocReturn* var_r29; + HSD_Text* temp_r30; + HSD_Text* var_r29; var_r28 = NULL; var_r29 = HSD_SisLib_804D7978; @@ -303,17 +302,16 @@ void HSD_SisLib_803A5DA0(s32 arg0) } } -sislib_UnkAllocReturn* HSD_SisLib_803A5ACC(s8 arg0, s32 arg1, f32 arg2, - f32 arg3, f32 arg4, f32 arg5, - f32 arg6) +HSD_Text* HSD_SisLib_803A5ACC(s8 arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4, + f32 arg5, f32 arg6) { HSD_GObj* temp_r3; HSD_GObj* var_r27; s32 var_r4; - sislib_UnkAllocReturn* temp_r30; + HSD_Text* temp_r30; sislib_UnkAlloc3* var_r28; - sislib_UnkAllocReturn* var_r29; - sislib_UnkAllocReturn* var_r30; + HSD_Text* var_r29; + HSD_Text* var_r30; var_r4 = arg1; var_r29 = NULL; @@ -341,7 +339,7 @@ sislib_UnkAllocReturn* HSD_SisLib_803A5ACC(s8 arg0, s32 arg1, f32 arg2, var_r30 = var_r30->x50; } temp_r30 = HSD_SisLib_803A5798(0xA0); - if ((sislib_UnkAllocReturn*) HSD_SisLib_804D7978 == NULL) { + if ((HSD_Text*) HSD_SisLib_804D7978 == NULL) { HSD_SisLib_804D7978 = temp_r30; } if (var_r29 != NULL) { @@ -402,8 +400,8 @@ void HSD_SisLib_803A5E70(void) s32 temp_r3_2; sislib_UnkAlloc3* temp_r30_2; sislib_UnkAlloc3* var_r29_2; - sislib_UnkAllocReturn* temp_r30; - sislib_UnkAllocReturn* var_r29; + HSD_Text* temp_r30; + HSD_Text* var_r29; var_r29 = HSD_SisLib_804D7978; while (var_r29 != NULL) { @@ -431,8 +429,7 @@ void HSD_SisLib_803A5E70(void) HSD_SisLib_804D7970 = HSD_SisLib_804D796C; HSD_SisLib_804D7974 = NULL; HSD_SisLib_804D7970->data_0 = NULL; - HSD_SisLib_804D7970->data_1 = - (sislib_UnkAllocReturn*) (HSD_SisLib_804D7970 + 0xC); + HSD_SisLib_804D7970->data_1 = (HSD_Text*) (HSD_SisLib_804D7970 + 0xC); HSD_SisLib_804D7970->size = HSD_SisLib_804D7968 - 0xC; } @@ -482,7 +479,7 @@ void HSD_SisLib_803A6048(u32 arg0) HSD_SisLib_804D796C = temp_r3; HSD_SisLib_804D7970->data_0 = NULL; HSD_SisLib_804D7970->data_1 = - (sislib_UnkAllocReturn*) ((u8*) HSD_SisLib_804D7970 + 0xC); + (HSD_Text*) ((u8*) HSD_SisLib_804D7970 + 0xC); HSD_SisLib_804D7970->size = HSD_SisLib_804D7968 - 0xC; HSD_SisLib_804D7978 = NULL; HSD_SisLib_804D797C = NULL; @@ -595,7 +592,7 @@ void HSD_SisLib_803A62A0(s32 arg0, HSD_Archive* arg1, char* arg2) } } -void HSD_SisLib_803A6368(sislib_UnkAllocReturn* arg0, s32 arg1) +void HSD_SisLib_803A6368(HSD_Text* arg0, s32 arg1) { SIS** temp_r3; s32 var_r5; @@ -745,11 +742,11 @@ void HSD_SisLib_803A660C(s32 arg0, s32 arg1, s32 arg2) HSD_SisLib_803A6478_inline(var_r3, var_r4); } -sislib_UnkAllocReturn* HSD_SisLib_803A6754(s8 arg0, s32 arg1) +HSD_Text* HSD_SisLib_803A6754(s8 arg0, s32 arg1) { sislib_UnkAllocData* temp_r3; - sislib_UnkAllocReturn* temp_r30; - sislib_UnkAllocReturn* temp_r3_2; + HSD_Text* temp_r30; + HSD_Text* temp_r3_2; temp_r30 = HSD_SisLib_803A5ACC(arg0, arg1, 0.0f, 0.0f, 0.0f, 640.0f, 480.0f); @@ -965,10 +962,10 @@ s32 HSD_SisLib_803A67EC(u8* data, u8* string) return var_r9; } -void HSD_SisLib_803A6B98(sislib_UnkAllocReturn* arg0, void* arg1, ...) +void HSD_SisLib_803A6B98(HSD_Text* arg0, void* arg1, ...) { s8 sp10C; - sislib_UnkAllocReturn** sp88; + HSD_Text** sp88; f64* sp84; s32 sp80; f64 sp60; @@ -986,7 +983,7 @@ void HSD_SisLib_803A6B98(sislib_UnkAllocReturn* arg0, void* arg1, ...) s32 sp14; s32 sp10; void* spC; - sislib_UnkAllocReturn* sp8; + HSD_Text* sp8; s16 temp_r0_3; s16 temp_r7; s32 temp_r3_16; @@ -1020,7 +1017,7 @@ void HSD_SisLib_803A6B98(sislib_UnkAllocReturn* arg0, void* arg1, ...) sislib_UnkAllocData* temp_r5_6; sislib_UnkAllocData* temp_r5_7; sislib_UnkAllocData* temp_r5_8; - sislib_UnkAllocReturn* temp_r31; + HSD_Text* temp_r31; u8* temp_r3; u8* var_r4; u8* var_r5; @@ -1078,7 +1075,7 @@ void HSD_SisLib_803A6B98(sislib_UnkAllocReturn* arg0, void* arg1, ...) var_r4 += 1; } } - temp_r30->data_1 = (sislib_UnkAllocReturn*) temp_r3; + temp_r30->data_1 = (HSD_Text*) temp_r3; arg0->x5C = (SIS*) temp_r3; temp_r30->data_0 = (sislib_UnkAllocData*) (temp_r3 + @@ -1207,8 +1204,7 @@ u8* fn_803A6FEC(u8* arg0, s32 arg1, s32* arg2) return arg0; } -void HSD_SisLib_803A746C(sislib_UnkAllocReturn* arg0, s32 arg1, f32 arg2, - f32 arg3) +void HSD_SisLib_803A746C(HSD_Text* arg0, s32 arg1, f32 arg2, f32 arg3) { s16 temp_r0; s16 temp_r0_2; @@ -1227,7 +1223,7 @@ void HSD_SisLib_803A746C(sislib_UnkAllocReturn* arg0, s32 arg1, f32 arg2, } } -void HSD_SisLib_803A74F0(sislib_UnkAllocReturn* arg0, s32 arg1, u8* arg2) +void HSD_SisLib_803A74F0(HSD_Text* arg0, s32 arg1, u8* arg2) { u8* temp_r3; u8* temp_r3_2; @@ -1242,8 +1238,7 @@ void HSD_SisLib_803A74F0(sislib_UnkAllocReturn* arg0, s32 arg1, u8* arg2) } } -void HSD_SisLib_803A8134(void* arg0, sislib_UnkAllocReturn* arg1, f32* arg2, - f32* arg3) +void HSD_SisLib_803A8134(void* arg0, HSD_Text* arg1, f32* arg2, f32* arg3) { SIS* temp_r4; TextGlyphTexture* var_r29; @@ -1381,9 +1376,9 @@ void HSD_SisLib_803A8134(void* arg0, sislib_UnkAllocReturn* arg1, f32* arg2, } } -void static inline HSD_SisLib_803A7F0C_inline(sislib_UnkAllocReturn* arg0, - s32 arg1, s32* var_r4, - u32* var_r5, s32* var_r0) +void static inline HSD_SisLib_803A7F0C_inline(HSD_Text* arg0, s32 arg1, + s32* var_r4, u32* var_r5, + s32* var_r0) { s32* temp_r8; u8 temp_r7; @@ -1463,7 +1458,7 @@ void static inline HSD_SisLib_803A7F0C_inline(sislib_UnkAllocReturn* arg0, } } -s32 HSD_SisLib_803A7F0C(sislib_UnkAllocReturn* arg0, s32 arg1) +s32 HSD_SisLib_803A7F0C(HSD_Text* arg0, s32 arg1) { s32 temp_r7_2; s32 var_r0; @@ -1490,10 +1485,10 @@ s32 HSD_SisLib_803A7F0C(sislib_UnkAllocReturn* arg0, s32 arg1) return var_r0; } -void HSD_SisLib_803A84BC(HSD_GObj* gobj, sislib_UnkAllocReturn* arg1) +void HSD_SisLib_803A84BC(HSD_GObj* gobj, HSD_Text* arg1) { // clang-format off - sislib_UnkAllocReturn *var_r31; + HSD_Text *var_r31; Mtx m; TextGlyphTexture *textures = NULL; TextKerning *kerning = NULL; diff --git a/src/sysdolphin/baselib/sislib.h b/src/sysdolphin/baselib/sislib.h index 83926af707..26150f30f0 100644 --- a/src/sysdolphin/baselib/sislib.h +++ b/src/sysdolphin/baselib/sislib.h @@ -11,7 +11,7 @@ #include typedef struct sislib_UnkAllocData sislib_UnkAllocData; -typedef struct sislib_UnkAllocReturn sislib_UnkAllocReturn; +typedef struct HSD_Text HSD_Text; typedef struct sislib_UnkAlloc3 sislib_UnkAlloc3; typedef struct { @@ -39,19 +39,21 @@ typedef struct SIS { // @todo: give actual names? struct sislib_UnkAllocData { sislib_UnkAllocData* data_0; - sislib_UnkAllocReturn* data_1; + HSD_Text* data_1; u32 size; }; -// @todo: this is probably what gets put in gobj user_data -struct sislib_UnkAllocReturn { - f32 x0; - f32 x4; - f32 x8; - f32 xC; - f32 x10; +struct HSD_Text { + // these get passed to the text initializer HSD_SisLib_803A5ACC + f32 x0; // global x position, 0,0 at center + f32 x4; // global y position + f32 x8; // scale that happens from the origin after the translation of x0, + // x4 + f32 xC; // scale that happens on the X axis from the left side of the text + f32 x10; // unknown, no effect observed so far + Vec4 x14; - Vec2 x24; + Vec2 x24; // font size, 1.0 being 100% of the screen? U8Vec4 x2C; U8Vec4 x30; Vec2 x34; @@ -66,7 +68,7 @@ struct sislib_UnkAllocReturn { u8 x4D; u8 x4E; u8 x4F; // which font to select from the array HSD_SisLib_804D1124 - sislib_UnkAllocReturn* x50; + HSD_Text* x50; HSD_GObj* x54; void (*x58)(void*); // callback in the text renderer (HSD_SisLib_803A84BC) SIS* x5C; // could just be a byte pointer? @@ -113,7 +115,7 @@ extern u32 HSD_SisLib_804D7968; extern sislib_UnkAllocData* HSD_SisLib_804D796C; extern sislib_UnkAllocData* HSD_SisLib_804D7970; extern sislib_UnkAllocData* HSD_SisLib_804D7974; -extern sislib_UnkAllocReturn* HSD_SisLib_804D7978; +extern HSD_Text* HSD_SisLib_804D7978; extern sislib_UnkAlloc3* HSD_SisLib_804D797C; extern sislib_UnknownType001 HSD_SisLib_8040C4A4; @@ -124,32 +126,32 @@ UNK_T func_804A70A0(UNK_T, s32, u32, s32, s32, s32, s32, s32, f64, f64, f64, f64, f64, f64, f64, f64); void HSD_SisLib_803A947C(HSD_Archive*); void HSD_SisLib_803A945C(void); -void HSD_SisLib_803A84BC(HSD_GObj*, sislib_UnkAllocReturn*); -s32 HSD_SisLib_803A7F0C(sislib_UnkAllocReturn*, s32); -void HSD_SisLib_803A8134(void*, sislib_UnkAllocReturn*, f32*, f32*); +void HSD_SisLib_803A84BC(HSD_GObj*, HSD_Text*); +s32 HSD_SisLib_803A7F0C(HSD_Text*, s32); +void HSD_SisLib_803A8134(void*, HSD_Text*, f32*, f32*); void HSD_SisLib_803A7684(UNK_T, u8, u8); void HSD_SisLib_803A7664(UNK_T); void HSD_SisLib_803A75E0(UNK_T, s32); void HSD_SisLib_803A7548(UNK_T, f32, f32); -void HSD_SisLib_803A74F0(sislib_UnkAllocReturn*, s32 arg1, u8* arg2); -void HSD_SisLib_803A746C(sislib_UnkAllocReturn*, s32, f32, f32); +void HSD_SisLib_803A74F0(HSD_Text*, s32 arg1, u8* arg2); +void HSD_SisLib_803A746C(HSD_Text*, s32, f32, f32); s32 HSD_SisLib_803A70A0(s32, UNK_T, UNK_T); u32 lbl_803A6FEC(s32, s32, bool); -void HSD_SisLib_803A6B98(sislib_UnkAllocReturn* arg0, void* arg1, ...); +void HSD_SisLib_803A6B98(HSD_Text* arg0, void* arg1, ...); s32 HSD_SisLib_803A67EC(u8*, u8*); -sislib_UnkAllocReturn* HSD_SisLib_803A6754(s8 arg0, s32 arg1); +HSD_Text* HSD_SisLib_803A6754(s8 arg0, s32 arg1); void HSD_SisLib_803A660C(s32, s32, s32); void HSD_SisLib_803A6530(s32, s32, s32); void HSD_SisLib_803A6478(u8*, u8*); -void HSD_SisLib_803A6368(sislib_UnkAllocReturn*, s32); +void HSD_SisLib_803A6368(HSD_Text*, s32); void HSD_SisLib_803A62A0(s32, HSD_Archive*, char*); s32 HSD_SisLib_803A611C(u16, u32, u16, u8, u8, u8, u8, u32); void lbl_803A60EC(void); -sislib_UnkAllocReturn* HSD_SisLib_803A5ACC(s8, s32, f32, f32, f32, f32, f32); +HSD_Text* HSD_SisLib_803A5ACC(s8, s32, f32, f32, f32, f32, f32); void* HSD_SisLib_803A5798(s32); void HSD_SisLib_803A594C(void*); -void HSD_SisLib_803A5CC4(sislib_UnkAllocReturn*); -void HSD_SisLib_803A5A2C(sislib_UnkAllocReturn*); +void HSD_SisLib_803A5CC4(HSD_Text*); +void HSD_SisLib_803A5A2C(HSD_Text*); void HSD_SisLib_803A5D30(void); void HSD_SisLib_803A5DA0(s32); void HSD_SisLib_803A5E70(void);