From 400d7be8cf76b9722b0ee0c484989e9c77af867d Mon Sep 17 00:00:00 2001 From: foxcam <118768446+thefoxcam@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:40:54 -0500 Subject: [PATCH] some `mn` work (#1487) * mn work * match minor func --- config/GALE01/symbols.txt | 2 +- src/melee/gm/gm_1A36.c | 125 ++++++++- src/melee/gm/gm_1A36.h | 16 +- src/melee/gm/gm_1A36.static.h | 16 ++ src/melee/gr/grkongo.c | 7 +- src/melee/lb/lb_00CE.c | 221 ++++++++++++++++ src/melee/lb/lb_00CE.h | 8 +- src/melee/lb/lbaudio_ax.h | 14 +- src/melee/mn/inlines.h | 16 +- src/melee/mn/mn_2295.c | 147 +++++++++++ src/melee/mn/mn_2295.h | 19 +- src/melee/mn/mndeflicker.c | 47 ++-- src/melee/mn/mnhyaku.c | 27 +- src/melee/mn/mnsound.c | 8 +- src/melee/mn/mnsoundtest.c | 396 ++++++++++++++++++++++++++-- src/melee/mn/mnsoundtest.h | 41 +++ src/sysdolphin/baselib/controller.h | 1 + 17 files changed, 1011 insertions(+), 100 deletions(-) diff --git a/config/GALE01/symbols.txt b/config/GALE01/symbols.txt index 84733cbbad..556c90bc74 100644 --- a/config/GALE01/symbols.txt +++ b/config/GALE01/symbols.txt @@ -225,7 +225,7 @@ lb_8000CE30 = .text:0x8000CE30; // type:function size:0x10 scope:global lb_8000CE40 = .text:0x8000CE40; // type:function size:0x10 scope:global expf = .text:0x8000CE50; // type:function size:0x90 scope:global powf = .text:0x8000CEE0; // type:function size:0x94 scope:global -lb_8000CF74 = .text:0x8000CF74; // type:function size:0x94 scope:global +powi = .text:0x8000CF74; // type:function size:0x94 scope:global lb_8000D008 = .text:0x8000D008; // type:function size:0x140 scope:global lb_8000D148 = .text:0x8000D148; // type:function size:0x1A4 scope:global lbVector_Normalize = .text:0x8000D2EC; // type:function size:0xC4 scope:global diff --git a/src/melee/gm/gm_1A36.c b/src/melee/gm/gm_1A36.c index b95ac40cd3..a50513e00f 100644 --- a/src/melee/gm/gm_1A36.c +++ b/src/melee/gm/gm_1A36.c @@ -1,10 +1,11 @@ #include -#include "gm_1A36.static.h" +#include "gm/gm_1A36.static.h" #include "gmmain_lib.h" #include "db/db_2253.h" +#include "gm/types.h" #include "lb/lb_00B0.h" #include "lb/lbaudio_ax.h" #include "lb/lbcardgame.h" @@ -21,21 +22,123 @@ #include #include -/// #gm_801A3680 +u64 gm_801A3680(u8 idx) +{ + return gm_80479C30[(u8) idx].button; +} -/// #gm_801A36A0 +u64 gm_801A36A0(u8 idx) +{ + return gm_80479C30[(u8) idx].trigger; +} -/// #gm_801A36C0 +u64 gm_801A36C0(u8 idx) +{ + return gm_80479C30[(u8) idx].unk; +} -/// #gm_801A36E0 +void gm_801A36E0(s32 idx, s32 arg1) +{ + if (idx == 4) { + gm_80479C30[0].x28 = arg1; + gm_80479C30[1].x28 = arg1; + gm_80479C30[2].x28 = arg1; + gm_80479C30[3].x28 = arg1; + return; + } + gm_80479C30[idx].x28 = arg1; +} -/// #gm_801A3714 +void gm_801A3714(s32 idx, u64 arg1, u64 arg2) +{ + if (arg1 & gm_80479C30[idx].button) { + gm_80479C30[idx].button |= arg2; + } + if (arg1 & gm_80479C30[idx].repeat) { + gm_80479C30[idx].repeat |= arg2; + } + if (arg1 & gm_80479C30[idx].trigger) { + gm_80479C30[idx].trigger |= arg2; + } + if (arg1 & gm_80479C30[idx].release) { + gm_80479C30[idx].release |= arg2; + } +} -/// #gm_801A3820 +void gm_801A3820(s32 idx, u64 arg1, u64 arg2) +{ + u64 val; + if (arg1 == (arg1 & gm_80479C30[idx].button)) { + gm_80479C30[idx].button |= arg2; + } + if (arg1 == (arg1 & gm_80479C30[idx].repeat)) { + gm_80479C30[idx].repeat |= arg2; + } + if (arg1 == (arg1 & gm_80479C30[idx].button)) { + if (arg1 & gm_80479C30[idx].trigger) { + gm_80479C30[idx].trigger |= arg2; + } + } + if (arg1 == (arg1 & gm_80479C30[idx].button)) { + if (arg1 & gm_80479C30[idx].release) { + gm_80479C30[idx].release |= arg2; + } + } +} -/// #fn_801A396C +void fn_801A396C(s32 idx) +{ + if (gm_80479C30[idx].button || gm_80479C30[idx].release) { + gm_80479C30[idx].unk = gm_80479C30[idx].button; + gm_80479C30[idx].x28 = gm_80479D24; + gm_80479C30[idx].x2C = 0; + } + if (gm_80479C30[idx].x2C < gm_80479D24) { + gm_80479C30[idx].x2C++; + } + if (gm_80479C30[idx].x28 != 0) { + gm_80479C30[idx].x28--; + gm_80479C30[idx].unk = 0; + } +} -/// #gm_801A3A74 +#pragma push +#pragma dont_inline on +void gm_801A3A74(void) +{ + gm_controller_map* controller = gm_80479C30; + int i; + for (i = 0; i < 4; i++) { + controller->button = HSD_PadCopyStatus[i].button; + controller->trigger = HSD_PadCopyStatus[i].trigger; + controller->repeat = HSD_PadCopyStatus[i].repeat; + controller->release = HSD_PadCopyStatus[i].release; + gm_801A3714(i, 0x1100, ((u64) 1 << (32 + 0))); + gm_801A3714(i, 0x200, ((u64) 1 << (32 + 1))); + gm_801A3820(i, 0x1060, ((u64) 1 << (32 + 2))); + gm_801A3820(i, 0x1160, ((u64) 1 << (32 + 3))); + gm_801A3714(i, 0x10008, ((u64) 1 << (32 + 4))); + gm_801A3714(i, 0x20004, ((u64) 1 << (32 + 5))); + gm_801A3714(i, 0x40001, ((u64) 1 << (32 + 6))); + gm_801A3714(i, 0x80002, ((u64) 1 << (32 + 7))); + gm_80479D20(i); + controller++; + } + controller_union.button = 0; + controller_union.trigger = 0; + controller_union.repeat = 0; + controller_union.release = 0; + controller_union.unk = 0; + controller_union.x28 = 0; + controller_union.x2C = 0; + for (i = 0; i < 4; i++) { + controller_union.button |= gm_80479C30[i].button; + controller_union.trigger |= gm_80479C30[i].trigger; + controller_union.repeat |= gm_80479C30[i].repeat; + controller_union.release |= gm_80479C30[i].release; + } +} +#pragma pop /// #gm_801A3E88 @@ -363,9 +466,9 @@ s32 gm_801A4B90(void) extern void* gm_804D6720; -s32 gm_801A4B9C(void) +s8* gm_801A4B9C(void) { - return M2C_FIELD(gm_804D6720, s32*, 8); + return (s8*) M2C_FIELD(gm_804D6720, s32*, 8); } struct gm_80479D58_t* gm_801A4BA8(void) diff --git a/src/melee/gm/gm_1A36.h b/src/melee/gm/gm_1A36.h index 041e3d4c88..e7f7d7b111 100644 --- a/src/melee/gm/gm_1A36.h +++ b/src/melee/gm/gm_1A36.h @@ -4,12 +4,14 @@ #include #include -/* 1A3680 */ UNK_RET gm_801A3680(UNK_PARAMS); -/* 1A36A0 */ UNK_RET gm_801A36A0(UNK_PARAMS); -/* 1A36C0 */ UNK_RET gm_801A36C0(UNK_PARAMS); -/* 1A36E0 */ UNK_RET gm_801A36E0(UNK_PARAMS); -/* 1A3714 */ UNK_RET gm_801A3714(UNK_PARAMS); -/* 1A3820 */ UNK_RET gm_801A3820(UNK_PARAMS); +#include "gm/types.h" + +/* 1A3680 */ u64 gm_801A3680(u8); +/* 1A36A0 */ u64 gm_801A36A0(u8); +/* 1A36C0 */ u64 gm_801A36C0(u8); +/* 1A36E0 */ void gm_801A36E0(s32, s32); +/* 1A3714 */ void gm_801A3714(s32, u64, u64); +/* 1A3820 */ void gm_801A3820(s32, u64, u64); /* 1A396C */ UNK_RET fn_801A396C(UNK_PARAMS); /* 1A3A74 */ UNK_RET gm_801A3A74(UNK_PARAMS); /* 1A3E88 */ UNK_RET gm_801A3E88(UNK_PARAMS); @@ -34,7 +36,7 @@ /* 1A4B60 */ UNK_RET gm_801A4B60(UNK_PARAMS); /* 1A4B74 */ UNK_RET gm_801A4B74(UNK_PARAMS); /* 1A4B90 */ s32 gm_801A4B90(void); -/* 1A4B9C */ s32 gm_801A4B9C(void); +/* 1A4B9C */ s8* gm_801A4B9C(void); /* 1A4BA8 */ struct gm_80479D58_t* gm_801A4BA8(void); /* 1A4BC8 */ s32 gm_801A4BC8(void); /* 1A4BD0 */ UNK_RET fn_801A4BD0(UNK_PARAMS); diff --git a/src/melee/gm/gm_1A36.static.h b/src/melee/gm/gm_1A36.static.h index 0691daecab..940102d8c9 100644 --- a/src/melee/gm/gm_1A36.static.h +++ b/src/melee/gm/gm_1A36.static.h @@ -116,6 +116,17 @@ struct fn_801BA3B4_arg0_t { /* +C:7 */ u8 xC_b7 : 1; }; +typedef struct gm_controller_map gm_controller_map; +struct gm_controller_map { + u64 button; + u64 trigger; + u64 repeat; + u64 release; + u64 unk; + s32 x28; + s32 x2C; +}; + /* 1A3F48 */ static void gm_801A3F48(MinorScene*); /* 1A4014 */ static void gm_801A4014(MajorScene* scene); /* 1A4284 */ static UNK_T gm_801A4284(UNK_T); @@ -154,6 +165,11 @@ struct fn_801BA3B4_arg0_t { /* 1BF684 */ static void gm_801BF684(s16 arg0); /* 1BF694 */ static u8 gm_801BF694(void); /* 2A3EF4 */ static void gm_801A3EF4(void); +static u64 gm_803DA788; +static gm_controller_map gm_80479C30[4]; +static gm_controller_map controller_union; +void (*gm_80479D20)(s32); +s32 gm_80479D24; /* 3DA920 */ static MajorScene gm_803DA920; /* 3DACA4 */ static MajorScene gm_803DACA4; /* 3DD2C0 */ static int gm_803DD2C0[74]; diff --git a/src/melee/gr/grkongo.c b/src/melee/gr/grkongo.c index cc45fd1b11..ecd87d02ff 100644 --- a/src/melee/gr/grkongo.c +++ b/src/melee/gr/grkongo.c @@ -394,12 +394,13 @@ void grKongo_801D577C(HSD_GObj* arg0) lb_8000B1CC(temp_r30, NULL, &vec); Ground_801C4D70(arg0, &vec, temp_r31->gv.kongo3.xD8); switch (temp_r31->gv.kongo3.xC8) { - case 0: + case 0: { + s16 val = temp_r31->gv.kongo2.xCE; temp_r31->gv.kongo2.xCE -= 1; - if (temp_r31->gv.kongo2.xCE < 0) { + if (val < 0) { temp_r31->gv.kongo2.xC8 = 1; } - break; + } break; case 1: temp_r31->gv.kongo2.xE8 += grKg_804D6980->unk5C; if (temp_r31->gv.kongo2.xE8 > grKg_804D6980->unk60) { diff --git a/src/melee/lb/lb_00CE.c b/src/melee/lb/lb_00CE.c index 8b13789179..00dbe34b06 100644 --- a/src/melee/lb/lb_00CE.c +++ b/src/melee/lb/lb_00CE.c @@ -1 +1,222 @@ +#include +#include + +#include "lb/lb_00CE.h" + +#include "MSL/math_ppc.h" + +#include +#include + +f32 expf(f32 arg8) +{ + f32 temp_f5; + f32 var_f1; + f32 var_f3; + f32 var_f4; + f32 var_f6; + s32 temp_r3; + s32 var_r4; + s32 var_r5; + + var_f1 = arg8; + var_r5 = 2; + var_f6 = 1.0f; + if (var_f1 < 0.0f) { + var_f1 = -var_f1; + var_r4 = 1; + } else { + var_r4 = 0; + } + var_f4 = var_f1; + var_f3 = 1.0f + var_f1; + do { + temp_r3 = var_r5; + var_f4 *= var_f1; + temp_f5 = var_f3; + var_r5 += 1; + var_f6 *= (f32) temp_r3; + var_f3 += var_f4 / var_f6; + } while (var_f3 != temp_f5); + if (var_r4 != 0) { + var_f3 = 1.0f / var_f3; + } + return var_f3; +} + +f32 powf(f32 arg0, f32 arg1) +{ + f32 temp_f1; + f32 temp_f5; + f32 var_f4; + f32 var_f6; + s32 var_r4; + + if (arg0 == 0.0f) { + return 0.0f; + } + var_r4 = 1; + var_f6 = (arg0 - 1.0f) / (1.0f + arg0); + var_f4 = var_f6; + temp_f5 = var_f6 * var_f6; + do { + var_r4 += 2; + var_f6 *= temp_f5; + temp_f1 = var_f4; + var_f4 += var_f6 / (f32) var_r4; + } while (var_f4 != temp_f1); + return expf(arg1 * (2.0f * var_f4)); +} + +s32 powi(s32 arg0, s32 arg1) +{ + s32 temp_r5; + s32 var_ctr_2; + s32 var_r6; + s32 var_r7; + u32 var_ctr; + + if (arg0 == 0) { + return 0; + } + if (arg1 >= 0) { + var_r6 = 0; + var_r7 = 1; + if (arg1 > 0) { + temp_r5 = arg1 - 8; + if (arg1 > 8) { + var_ctr = (u32) (temp_r5 + 7) >> 3U; + if (temp_r5 > 0) { + do { + var_r7 = var_r7 * arg0 * arg0 * arg0 * arg0 * arg0 * + arg0 * arg0 * arg0; + var_r6 += 8; + var_ctr -= 1; + } while (var_ctr != 0); + } + } + var_ctr_2 = arg1 - var_r6; + if (var_r6 < arg1) { + do { + var_r7 *= arg0; + var_ctr_2 -= 1; + } while (var_ctr_2 != 0); + } + } + return var_r7; + } + return 0; +} + +f32 lb_8000D008(f32 point_y_in, f32 point_x) +{ + f32 var_f2; + s32 var_r0; + s32 var_r0_2; + s32 var_r0_3; + s32 var_r31; + + f32 point_y = point_y_in; + if ((point_x < 0.00001f) && (point_x > -0.00001f)) { + var_r0_2 = 1; + } else { + var_r0_2 = 0; + } + if (var_r0_2 != 0) { + if ((point_y < 0.00001f) && (point_y > -0.00001f)) { + var_r0_3 = 1; + } else { + var_r0_3 = 0; + } + if (var_r0_3 != 0) { + return 0.0f; + } + if (point_y < 0.0f) { + var_r0 = -1; + } else { + var_r0 = 1; + } + return (f32) ((M_PI / 2) * (f64) var_r0); + } + if (point_x > 0.0f) { + return atanf(point_y / point_x); + } + if (point_x < 0.0f) { + var_f2 = point_y / point_x; + if (var_f2 < 0.0f) { + var_f2 = -var_f2; + } + if (point_y < 0.0f) { + var_r31 = -1; + } else { + var_r31 = 1; + } + point_y = (f32) ((f64) var_r31 * (M_PI - atanf(var_f2))); + } + return point_y; +} + +s32 lb_8000D148(f32 point0_x, f32 point0_y, f32 point1_x, f32 point1_y, + f32 point2_x, f32 point2_y, f32 threshold) +{ + f32 dist_01; + f32 var_f0; + { + f32 diff_01_y = point0_y - point1_y; + f32 diff_01_x = point1_x - point0_x; + f32 dist_squared_01 = + (diff_01_x * diff_01_x) + (diff_01_y * diff_01_y); + if (dist_squared_01 < 0.00001f) { + return 0; + } + dist_01 = sqrtf(dist_squared_01); + + var_f0 = ((point0_x * point1_y) - (point0_y * point1_x)) + + ((diff_01_x * point2_x) + (diff_01_y * point2_y)); + if (var_f0 < 0.0f) { + var_f0 = -var_f0; + } + } + + if ((var_f0 / dist_01) <= threshold) { + f32 diff_02_x = point0_x - point2_x; + f32 diff_02_y = point0_y - point2_y; + f32 diff_12_x = point1_x - point2_x; + f32 diff_12_y = point1_y - point2_y; + f32 threshold_squared = threshold * threshold; + f32 dist_squared_02 = + (diff_02_x * diff_02_x) + (diff_02_y * diff_02_y); + f32 dist_squared_12 = + (diff_12_x * diff_12_x) + (diff_12_y * diff_12_y); + if (dist_squared_02 < threshold_squared) { + if (dist_squared_12 > threshold_squared) { + return 1; + } + if (dist_squared_12 < threshold_squared) { + return 0; + } + return 1; + } + if (dist_squared_02 > threshold_squared) { + if (dist_squared_12 > threshold_squared) { + // If an axis of point0 and point1 are on opposite sides of + // point2, return true. + if (((point0_x > point2_x) && (point1_x < point2_x)) || + ((point0_x < point2_x) && (point1_x > point2_x)) || + ((point0_y > point2_y) && (point1_y < point2_y)) || + ((point0_y < point2_y) && (point1_y > point2_y))) + { + return 1; + } + return 0; + } + if (dist_squared_12 < threshold_squared) { + return 1; + } + return 1; + } + return 1; + } + return 0; +} diff --git a/src/melee/lb/lb_00CE.h b/src/melee/lb/lb_00CE.h index 4dff35e405..3137859967 100644 --- a/src/melee/lb/lb_00CE.h +++ b/src/melee/lb/lb_00CE.h @@ -1,8 +1,14 @@ #ifndef GALE01_00CE50 #define GALE01_00CE50 +#include + +#include + +/* 00CE50 */ float expf(float); /* 00CEE0 */ float powf(float, float); +/* 00CF74 */ s32 powi(s32, s32); /* 00D008 */ float lb_8000D008(float, float); -/* 00D148 */ int lb_8000D148(float, float, float, float, float, float, float); +/* 00D148 */ s32 lb_8000D148(float, float, float, float, float, float, float); #endif diff --git a/src/melee/lb/lbaudio_ax.h b/src/melee/lb/lbaudio_ax.h index 07fd7da7d1..761d581d0e 100644 --- a/src/melee/lb/lbaudio_ax.h +++ b/src/melee/lb/lbaudio_ax.h @@ -17,18 +17,18 @@ /* 023220 */ s32 lbAudioAx_80023220(s32); /* 023254 */ UNK_RET fn_80023254(UNK_PARAMS); /* 0233EC */ s32 lbAudioAx_800233EC(s32); -/* 023694 */ UNK_RET lbAudioAx_80023694(UNK_PARAMS); +/* 023694 */ s32 lbAudioAx_80023694(void); /* 0236B8 */ void lbAudioAx_800236B8(s32); -/* 0236DC */ UNK_RET lbAudioAx_800236DC(UNK_PARAMS); +/* 0236DC */ void lbAudioAx_800236DC(HSD_GObj*); /* 023710 */ bool lbAudioAx_80023710(s32); /* 023730 */ UNK_RET lbAudioAx_80023730(UNK_PARAMS); /* 023750 */ UNK_RET fn_80023750(UNK_PARAMS); /* 0237A8 */ u32 lbAudioAx_800237A8(enum_t sfx_id, u8 sfx_vol, u8 sfx_pan); /* 023870 */ int lbAudioAx_80023870(int, int, int, int); /* 02392C */ UNK_RET lbAudioAx_8002392C(UNK_PARAMS); -/* 023968 */ UNK_RET lbAudioAx_80023968(UNK_PARAMS); -/* 023A44 */ UNK_RET lbAudioAx_80023A44(UNK_PARAMS); -/* 023B24 */ UNK_RET lbAudioAx_80023B24(UNK_PARAMS); +/* 023968 */ s32 lbAudioAx_80023968(s32); +/* 023A44 */ s32 lbAudioAx_80023A44(u8, u16); +/* 023B24 */ f32 lbAudioAx_80023B24(s32); /* 023ED4 */ UNK_RET fn_80023ED4(UNK_PARAMS); /* 023F28 */ void lbAudioAx_80023F28(s32); /* 024030 */ void lbAudioAx_80024030(s32); @@ -40,8 +40,8 @@ /* 0243F4 */ UNK_RET lbAudioAx_800243F4(UNK_PARAMS); /* 0244F4 */ UNK_RET fn_800244F4(UNK_PARAMS); /* 0245D4 */ UNK_RET lbAudioAx_800245D4(UNK_PARAMS); -/* 0245F4 */ UNK_RET lbAudioAx_800245F4(UNK_PARAMS); -/* 024614 */ UNK_RET lbAudioAx_80024614(UNK_PARAMS); +/* 0245F4 */ s32 lbAudioAx_800245F4(s32); +/* 024614 */ void lbAudioAx_80024614(s32); /* 024634 */ UNK_RET lbAudioAx_80024634(UNK_PARAMS); /* 024654 */ UNK_RET fn_80024654(UNK_PARAMS); /* 024B1C */ void lbAudioAx_80024B1C(s32, s32); diff --git a/src/melee/mn/inlines.h b/src/melee/mn/inlines.h index 9139d012c0..7d08686cdc 100644 --- a/src/melee/mn/inlines.h +++ b/src/melee/mn/inlines.h @@ -4,7 +4,9 @@ #include "mn/types.h" #include +#include #include +#include #include typedef enum _MenuEvent { @@ -12,8 +14,14 @@ typedef enum _MenuEvent { MenuEvent_Down = 1 << 1, MenuEvent_Left = 1 << 2, MenuEvent_Right = 1 << 3, - MenuEvent_Unk = 1 << 4, + MenuEvent_Forward = 1 << 4, MenuEvent_Back = 1 << 5, + MenuEvent_unk = 1 << 6, + MenuEvent_unk2 = 1 << 7, + MenuEvent_unk3 = 1 << 8, + MenuEvent_unk4 = 1 << 9, + MenuEvent_unk5 = 1 << 10, + MenuEvent_unk6 = 1 << 11, } MenuEvent; #define GET_MENU(gobj) ((Menu*) HSD_GObjGetUserData(gobj)) @@ -33,17 +41,17 @@ static inline u64 Menu_GetEvents(void) // @todo: The functions `fn_8017435C`, `fn_80174338`, and `fn_80174380` are // probably deduplicated clones of these. -static inline void Menu_SFX_Back(void) +static inline void sfxBack(void) { lbAudioAx_80024030(0); } -static inline void Menu_SFX_Forward(void) +static inline void sfxForward(void) { lbAudioAx_80024030(1); } -static inline void Menu_SFX_Move(void) +static inline void sfxMove(void) { lbAudioAx_80024030(2); } diff --git a/src/melee/mn/mn_2295.c b/src/melee/mn/mn_2295.c index 8b13789179..7d12a92018 100644 --- a/src/melee/mn/mn_2295.c +++ b/src/melee/mn/mn_2295.c @@ -1 +1,148 @@ +#include +#include + +#include "mn/mn_2295.h" + +#include "gm/gm_1A36.h" +#include "gm/gmmain_lib.h" +#include "lb/lb_00CE.h" +#include "mn/inlines.h" + +u8 mn_802295AC(void) +{ + s32 port_idx = 0; + while (port_idx < 4) { + u64 res = gm_801A36A0(port_idx); + if (res & 0x100000000) { + return port_idx; + } + port_idx += 1; + } + return 0; +} + +u32 mn_80229624(u32 arg0) +{ + u32 ret = 0; + u64 inputs_a; + u64 inputs_b; + inputs_a = gm_801A36C0(arg0); + inputs_b = gm_801A36A0(arg0); + if (mn_804D6BC8.x0 != 0) { + Menu_DecrementAnimTimer(); + return 0; + } + if (inputs_b & 0x100) { + ret |= MenuEvent_unk4; + } + if (inputs_b & 0x1000) { + ret |= MenuEvent_unk3; + } + if (inputs_b & 0x100000000) { + ret |= MenuEvent_Forward; + } + if (inputs_b & 0x200000000) { + ret |= MenuEvent_Back; + } + if (inputs_b & 0x40) { + ret |= MenuEvent_unk; + } + if (inputs_b & 0x20) { + ret |= MenuEvent_unk2; + } + if (inputs_b & 0x400) { + ret |= MenuEvent_unk5; + } + if (inputs_b & 0x800) { + ret |= MenuEvent_unk6; + } + if (inputs_a & 0x1000000000) { + ret |= MenuEvent_Up; + } + if (inputs_a & 0x2000000000) { + ret |= MenuEvent_Down; + } + if (inputs_a & 0x4000000000) { + ret |= MenuEvent_Left; + } + if (inputs_a & 0x8000000000) { + ret |= MenuEvent_Right; + } + return ret; +} + +void mn_80229860(s8 arg0) +{ + s8* val = gm_801A4B9C(); + *val = arg0; + gm_801A4B60(); +} + +s32 mn_80229938(s32 arg0, s32 arg1) +{ + if (arg0 == 6 && arg1 == 2) { + if (gmMainLib_8015EDD4()) { + return 1; + } + return 0; + } + if (arg0 == 5 && arg1 == 2) { + if (gmMainLib_8015EE90()) { + return 1; + } + return 0; + } + if (arg0 == 4 && arg1 == 3) { + return 0; + } + if (arg0 == 1 && arg1 == 2) { + return 0; + } + if (arg0 == 3) { + if (arg1 == 2) { + return 0; + } else { + return 1; + } + } + return 1; +} + +char null_terminator = '\0'; + +void mn_8022EA08(char* buf, u32 num) +{ + s32 buf_end = mn_8022EB78(num); + s32 buf_len = buf_end - 1; + s32 idx = 0; + while (idx < buf_end) { + buf[buf_len - idx] = mn_8022EB24(num, idx) + 0x30; + idx += 1; + } + buf[buf_end] = null_terminator; +} + +s32 mn_8022EB24(s32 arg0, s32 arg1) +{ + return (arg0 / powi(0xA, arg1)) % 10; +} + +s32 mn_8022EB78(s32 num) +{ + s32 count; + if (num == 0) { + return 1; + } + count = 0; + for (;;) { + if ((num / powi(0xA, count)) != 0) { + count += 1; + if (count < 0xB) { + continue; + } + } + break; + } + return count; +} diff --git a/src/melee/mn/mn_2295.h b/src/melee/mn/mn_2295.h index 038ed78602..6fcd90a6e2 100644 --- a/src/melee/mn/mn_2295.h +++ b/src/melee/mn/mn_2295.h @@ -7,13 +7,24 @@ #include +u8 mn_802295AC(void); //< Test for some sort of analogue movement and return + // the port that inputted it. +u32 mn_80229624(u32); //< Return a MenuEvent bitfield of controller input. +void mn_8022EA08(char*, + u32); //< Fill arg0 with the string representation of arg1. + +s32 mn_8022EB24(s32, s32); //< Shift arg0 left in base 10 by arg1 digits and + // return the ones digit> + 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? + +void mn_80229894(s32, s32, s32); + +s32 mn_8022EB78(s32); //< Return how many digits are in a number. + float mn_8022EC18(HSD_JObj*, float*, int); -void mn_802295AC(void); -void mn_80229860(s32); +void mn_80229860(s8); f32 mn_8022F298(HSD_JObj*); typedef struct _mn_unk1 { diff --git a/src/melee/mn/mndeflicker.c b/src/melee/mn/mndeflicker.c index 9bdd662d7a..1edb1b3315 100644 --- a/src/melee/mn/mndeflicker.c +++ b/src/melee/mn/mndeflicker.c @@ -45,36 +45,35 @@ Vec3 mnDeflicker_803EEFF0 = { 50.0F, 350.0F, 50.0F }; void mnDeflicker_8024A168(HSD_GObj* gobj) { - unsigned long long ty_permuter; + u64 events; HSD_JObj* asd[2]; int stack[5]; Menu* menu = GET_MENU(mnDeflicker_804D6C38); if (mn_804D6BC8.x0 != 0) { Menu_DecrementAnimTimer(); return; - } else { - ty_permuter = Menu_GetEvents(); - if ((ty_permuter & 0x20)) { - Menu_SFX_Back(); - gmMainLib_8015F4F4( - ((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; - 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( - ((Menu*) mnDeflicker_804D6C38->user_data)->cursor); // inline - } + } + events = Menu_GetEvents(); + if ((events & MenuEvent_Back)) { + sfxBack(); + gmMainLib_8015F4F4( + ((Menu*) mnDeflicker_804D6C38->user_data)->cursor); // inline + lb_8001CE00(); + mn_804A04F0.x11 = 0; + mn_80229894(4, 2, 3); + } else if (mnDeflicker_804D6C3C && (events & MenuEvent_unk4)) { + unsigned char x; + PAD_STACK(4); + sfxMove(); + 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( + ((Menu*) mnDeflicker_804D6C38->user_data)->cursor); // inline } } diff --git a/src/melee/mn/mnhyaku.c b/src/melee/mn/mnhyaku.c index 735c986e96..286884e7dc 100644 --- a/src/melee/mn/mnhyaku.c +++ b/src/melee/mn/mnhyaku.c @@ -46,27 +46,26 @@ static inline void mnHyaku_8024C68C_inline_2(HSD_GObj* gobj) void mnHyaku_8024C68C(HSD_GObj* arg0) { - u64 ret; + u64 events; Menu* menu = GET_MENU(mnHyaku_804D6C58); - PAD_STACK(16); + PAD_STACK(8); if (mn_804D6BC8.x0 != 0) { - mn_804D6BC8.x0--; - mn_804D6BC8.x2 = 0; - mn_804D6BC8.x4 = 0; + Menu_DecrementAnimTimer(); return; } - ret = mn_804A04F0.x8 = mn_80229624(4); - if ((ret & 0x20)) { - lbAudioAx_80024030(0); + events = Menu_GetEvents(); + if (events & MenuEvent_Back) { + sfxBack(); mn_804A04F0.x11 = 0; mn_80229894(9, 2, 3); return; } - if (ret & 0x10) { - lbAudioAx_80024030(1); + if (events & MenuEvent_Forward) { + sfxForward(); mn_802295AC(); gm_801677E8(); + // load the different multi-man melee modes switch (menu->cursor) { case 0: mn_80229860(0x21); @@ -88,8 +87,8 @@ void mnHyaku_8024C68C(HSD_GObj* arg0) return; } } else { - if (ret & 4) { - lbAudioAx_80024030(2); + if (events & MenuEvent_Left) { + sfxMove(); if (menu->cursor == 0) { menu->cursor = 5; } else { @@ -99,8 +98,8 @@ void mnHyaku_8024C68C(HSD_GObj* arg0) mnHyaku_8024C68C_inline_2(mnHyaku_804D6C58); return; } - if (ret & 8) { - lbAudioAx_80024030(2); + if (events & MenuEvent_Right) { + sfxMove(); if (menu->cursor == 5) { menu->cursor = 0; } else { diff --git a/src/melee/mn/mnsound.c b/src/melee/mn/mnsound.c index bef0e2830a..a0d851edb8 100644 --- a/src/melee/mn/mnsound.c +++ b/src/melee/mn/mnsound.c @@ -86,7 +86,7 @@ void mnSound_802492CC(HSD_GObj* gobj) } events = Menu_GetEvents(); if (events & MenuEvent_Back) { - Menu_SFX_Back(); + sfxBack(); mn_804A04F0.x11 = 0; gmMainLib_8015ED80(GET_MENU(mnSound_804D6C30)->unk3); lb_8001CE00(); @@ -95,7 +95,7 @@ void mnSound_802492CC(HSD_GObj* gobj) } if (events & (MenuEvent_Up | MenuEvent_Down)) { // switch between the two - Menu_SFX_Move(); + sfxMove(); if ((u8) menu->unk2 == 0) { menu->unk2 = 1; } else { @@ -115,7 +115,7 @@ void mnSound_802492CC(HSD_GObj* gobj) if (menu->unk2 == 0) { if (menu->unk1 == 1) { // switch from mono to stereo - Menu_SFX_Move(); + sfxMove(); menu->unk1 = 0; mnSound_ChannelAnim(GET_JOBJ(mnSound_804D6C30), menu->unk1); lbAudioAx_80024C08(menu->unk1); @@ -132,7 +132,7 @@ void mnSound_802492CC(HSD_GObj* gobj) if (menu->unk2 == 0) { if (menu->unk1 == 0) { // switch from stereo to mono - Menu_SFX_Move(); + sfxMove(); menu->unk1 = 1; mnSound_ChannelAnim(GET_JOBJ(mnSound_804D6C30), menu->unk1); lbAudioAx_80024C08(menu->unk1); diff --git a/src/melee/mn/mnsoundtest.c b/src/melee/mn/mnsoundtest.c index 3c08ea6b64..9fc2c60cc8 100644 --- a/src/melee/mn/mnsoundtest.c +++ b/src/melee/mn/mnsoundtest.c @@ -2,7 +2,12 @@ #include +#include "mnsoundtest.h" + +#include "lb/lb_00F9.h" #include "lb/lbarchive.h" +#include "mn/inlines.h" +#include "mn/types.h" #include "sc/types.h" #include @@ -20,31 +25,109 @@ 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 }; +HSD_GObj* mnSoundTest_804D6C40; +u8 mnSoundTest_804D6C44; +s32 mnSoundTest_804D6C4C; + +void fn_8024B2B0(HSD_GObj*); + +#if 0 +Vec3 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, } +}; +#else +Vec3 vec_0 = { + 0, + 19, + -0.1, +}; +Vec3 vec_1 = { + 20, + 39, + -0.1, +}; +Vec3 vec_2 = { + 0, + 20, + -0.1, +}; +Vec3 vec_3 = { + 0, + 0, + -0.1, +}; +Vec3 vec_4 = { + 0, + 200, + 0, +}; +Vec3 vec_5 = { + 0, + 10, + -0.1, +}; +Vec3 vec_6 = { -2, -6.6, 0 }; +Vec3 vec_7 = { -1.7, -4.7, 0 }; +#endif + +f32 floats_2[] = { -1.7, 2 }; + +typedef struct { + u16 text_id; + u32 idx; +} soundtest_data; + +u8 text_ids[] = { 0x2A, 0x02, 0x2D, 0x20, 0x15, 0x16, 0x2F, 0x34, 0x21, 0x33, + 0x32, 0x1F, 0x17, 0x04, 0x31, 0x2B, 0x2C, 0x24, 0x01, 0x28, + 0x13, 0x19, 0x1A, 0x1B, 0x1C, 0x18, 0x3A, 0x25, 0x27, 0x26, + 0x3C, 0x2E, 0x3B, 0x00, 0x37, 0x29, 0x3D, 0x3E, 0x0E, 0x07, + 0x0D, 0x11, 0x12, 0x0C, 0x09, 0x10, 0x0A, 0x0F, 0x08, 0x3F, + 0x0B, 0x38, 0x40, 0x41, 0x22, 0x35, 0x4F, 0x39, 0x43, 0x44, + 0x36, 0x45, 0x46, 0x23, 0x1D, 0x1E, 0x05, 0x06, 0x03, 0x14, + 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x30, 0x42 }; + +soundtest_data data_2[] = { + { 0x00E7, 0x01 }, { 0x00E8, 0x03 }, { 0x00E9, 0x04 }, { 0x00EA, 0x05 }, + { 0x00EB, 0x06 }, { 0x00ED, 0x0A }, { 0x00EE, 0x0B }, { 0x00EF, 0x0D }, + { 0x00F0, 0x0E }, { 0x00F1, 0x10 }, { 0x00F2, 0x11 }, { 0x00F3, 0x13 }, + { 0x00F4, 0x14 }, { 0x00F5, 0x15 }, { 0x00F6, 0x16 }, { 0x00F7, 0x17 }, + { 0x00F8, 0x18 }, { 0x00F9, 0x19 }, { 0x00FA, 0x1D }, { 0x00FB, 0x1F }, + { 0x00FC, 0x20 }, { 0x00FD, 0x32 }, { 0x00FE, 0x22 }, { 0x00FF, 0x23 }, + { 0x0100, 0x28 }, { 0x0101, 0x29 }, { 0x0102, 0x2A }, { 0x0103, 0x2B }, + { 0x0104, 0x2C }, { 0x0105, 0x2D }, { 0x0106, 0x2E }, { 0x0107, 0x31 }, + { 0x0108, 0x21 }, { 0x0109, 0x33 }, { 0x010A, 0x34 }, { 0x010B, 0x35 }, + { 0x010C, 0x38 }, { 0x010D, 0x39 }, { 0x010E, 0x3A }, { 0x010F, 0x3B }, + { 0x0110, 0x3C }, { 0x0111, 0x3D }, { 0x0112, 0x3E }, { 0x0113, 0x40 }, + { 0x0114, 0x41 }, { 0x0115, 0x42 }, { 0x0116, 0x4A }, { 0x0117, 0x4B }, + { 0x0118, 0x4C }, { 0x0119, 0x54 }, { 0x011A, 0x5F }, { 0x011B, 0x60 }, + { 0x011C, 0x61 }, { 0x011D, 0x36 }, { 0x011E, 0x00 }, { 0x011F, 0x37 }, + { 0x0120, 0x50 }, { 0x0121, 0x53 }, { 0x0122, 0x1E }, { 0x0123, 0x3F }, + { 0x0124, 0x4D }, { 0x0125, 0x07 }, { 0x0126, 0x02 }, { 0x0127, 0x0F }, + { 0x0128, 0x51 }, { 0x0129, 0x4E }, { 0x012A, 0x08 }, { 0x012B, 0x26 }, + { 0x012C, 0x27 }, { 0x012F, 0x5D }, { 0x0130, 0x5E }, { 0x0132, 0x46 }, + { 0x0133, 0x47 }, { 0x0134, 0x48 }, { 0x0135, 0x43 }, { 0x0136, 0x44 }, + { 0x0137, 0x45 }, { 0x0138, 0x2F }, { 0x0139, 0x30 }, { 0x013D, 0x25 } +}; + +u8 data_3[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }; + +u32 data_4[] = { 25, 8, 1, 6, 16, 17, 4, 2, 13, 0, 11, 5, 12, 14, 18, + 7, 15, 10, 9, 3, 21, 20, 24, 19, 23, 22, 29, 28, 26, 27, + 6, 8, 11, 18, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 13, + 25, 26, 28, 27, 10, 7, 9, 31, 23, 30, 4, 0, 39, 3, 32 }; 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; +s32 mnSoundTest_804D6C48; +s32 mnSoundTest_804D6C4C; void mnSoundTest_8024A790(HSD_GObj* arg0) { @@ -97,3 +180,276 @@ void mnSoundTest_8024A790(HSD_GObj* arg0) mnSoundTest_804D6C4C = temp_r3_2; } } + +void mnSoundTest_8024A958(Soundtest_GObj* arg0) +{ + char string[3]; + HSD_Text* temp_r3; + HSD_Text* temp_r3_2; + HSD_Text* temp_r3_3; + HSD_Text* temp_r3_4; + soundtest_user_data* temp_r30; + + temp_r30 = arg0->user_data; + if (temp_r30->unk14 != NULL) { + HSD_SisLib_803A5CC4(temp_r30->unk14); + } + if (temp_r30->unk18 != NULL) { + HSD_SisLib_803A5CC4(temp_r30->unk18); + } + temp_r3_3 = + HSD_SisLib_803A5ACC(0, 0, vec_6.x, vec_6.y, 18.0f, 350.0f, 10.0f); + temp_r30->unk14 = temp_r3_3; + temp_r3_3->x24.x = 0.035f; + temp_r3_3->x24.y = 0.035f; + temp_r3_3->x4A = 2; + HSD_SisLib_803A6368(temp_r3_3, data_2[text_ids[temp_r30->unk1]].text_id); + temp_r3_4 = HSD_SisLib_803A6754(0, 0); + temp_r30->unk18 = temp_r3_4; + temp_r3_4->x0 = 0.0f; // mnSoundTest_803EF0A8[0xB]; + temp_r3_4->x4 = 0.0f; // mnSoundTest_803EF0A8[0xB]; + temp_r3_4->x8 = 18.0f; + temp_r3_4->x24.x = 0.04f; + temp_r3_4->x24.y = 0.04f; + mn_8022EA08((char*) &string, temp_r30->unk1); + temp_r3_4->x4A = 1; + HSD_SisLib_803A6B98(temp_r3_4, &string, 0.0f, 0.0f); +} + +f32 mn_8022F298(HSD_JObj*); + +void mnSoundTest_8024AA70(HSD_GObj* arg0, u8 arg1) +{ + HSD_JObj* sp38; + HSD_JObj* sp34; + char string[3]; + HSD_JObj* temp_r31; + HSD_Text* temp_r3; + HSD_Text* temp_r3_2; + HSD_Text* temp_r3_4; + f32 temp_f1; + void* temp_r30; + void* temp_r30_2; + Vec3* temp_r3_3; + + HSD_JObj* jobj = GET_JOBJ(arg0); + soundtest_user_data* user_data = arg0->user_data; + lb_80011E24(jobj, &sp38, 0x13, -1); + lb_80011E24(jobj, &sp34, 0x14, -1); + if (arg1 == 2) { + soundtest_user_data* temp_r30_2 = arg0->user_data; + temp_r3 = temp_r30_2->unk1C; + if (temp_r3 != NULL) { + HSD_SisLib_803A5CC4(temp_r3); + } + temp_r3_2 = HSD_SisLib_803A6754(0, 0); + temp_r3_3 = &vec_7; + temp_r30_2->unk1C = temp_r3_2; + temp_f1 = temp_r3_3->y; + temp_r3_2->x0 = temp_r3_3->x; + temp_r3_2->x4 = temp_f1; + temp_r3_2->x8 = 18.0f; + temp_r3_2->x24.x = 0.04f; + temp_r3_2->x24.y = 0.04f; + mn_8022EA08((char*) &string, temp_r30_2->unk4); + temp_r3_2->x4A = 1; + HSD_SisLib_803A6B98(temp_r3_2, &string, 0.0f, 0.0f); + HSD_JObjClearFlagsAll(sp38, 0x10U); + } else { + temp_r3_4 = user_data->unk1C; + if (temp_r3_4 != NULL) { + HSD_SisLib_803A5CC4(temp_r3_4); + user_data->unk1C = NULL; + } + HSD_JObjSetFlagsAll(sp38, 0x10U); + } + HSD_JObjReqAnimAll(sp34, (f32) (arg1 == 1)); + mn_8022F3D8(sp34, 0xFFU, 0x420); + HSD_JObjAnimAll(sp34); +} + +void mnSoundTest_8024ABF8(HSD_GObj* arg0, u8 arg1) +{ + HSD_JObj* sp1C; + HSD_JObj* sp18; + HSD_JObj* sp14; + HSD_JObj* temp_r31; + f32 temp_f30; + f32 temp_f31; + + temp_r31 = GET_JOBJ(arg0); + lb_80011E24(temp_r31, &sp18, 2, -1); + lb_80011E24(temp_r31, &sp1C, 5, -1); + lb_80011E24(temp_r31, &sp14, 4, -1); + temp_f31 = mn_8022F298(sp18); + temp_f30 = mn_8022F298(sp14); + HSD_JObjReqAnimAll(sp18, (f32) arg1); + mn_8022F3D8(sp18, 0xFFU, 0x420); + HSD_JObjAnimAll(sp18); + HSD_JObjReqAnim(sp18, temp_f31); + HSD_JObjAnim(sp18); + HSD_JObjReqAnimAll(sp14, temp_f30); + mn_8022F3D8(sp14, 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(sp14); + if (arg1 != 0) { + HSD_JObjReqAnimAll(sp1C, vec_2.x); + } else { + HSD_JObjReqAnimAll(sp1C, vec_3.y); + } + mn_8022F3D8(sp1C, 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(sp1C); +} + +void mnSoundTest_8024AD58(HSD_GObj* arg0, s8 arg1) +{ + HSD_JObj* sp1C; + HSD_JObj* sp18; + HSD_JObj* sp14; + HSD_JObj* temp_r30; + f32 temp_f31; + u8 temp_r0; + + temp_r30 = GET_JOBJ(arg0); + lb_80011E24(temp_r30, &sp18, 0xB, -1); + lb_80011E24(temp_r30, &sp1C, 0xE, -1); + lb_80011E24(temp_r30, &sp14, 0xD, -1); + temp_r0 = !!arg1; + temp_f31 = mn_8022F298(sp18); + HSD_JObjReqAnimAll(sp18, (f32) temp_r0); + mn_8022F3D8(sp18, 0xFFU, 0x420); + HSD_JObjAnimAll(sp18); + HSD_JObjReqAnimAll(sp18, temp_f31); + HSD_JObjAnim(sp18); + HSD_JObjReqAnimAll(sp14, vec_5.y); + mn_8022F3D8(sp14, 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(sp14); + if (temp_r0 != 0) { + HSD_JObjReqAnimAll(sp1C, vec_2.x); + } else { + HSD_JObjReqAnimAll(sp1C, vec_3.y); + } + mn_8022F3D8(sp1C, 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(sp1C); + mnSoundTest_8024AA70(arg0, arg1); +} + +static inline void fn_8024AED0_inline(HSD_GObj* arg0) +{ + char string[3]; + HSD_Text* temp_r3_6; + soundtest_user_data* temp_r28_4 = mnSoundTest_804D6C40->user_data; + HSD_Text* temp_r3_5 = temp_r28_4->unk1C; + if (temp_r3_5 != NULL) { + HSD_SisLib_803A5CC4(temp_r3_5); + } + temp_r3_6 = HSD_SisLib_803A6754(0, 0); + temp_r28_4->unk1C = temp_r3_6; + temp_r3_6->x0 = vec_6.x; + temp_r3_6->x4 = vec_6.y; + temp_r3_6->x8 = 18.0f; + temp_r3_6->x24.x = 0.04f; + temp_r3_6->x24.y = 0.04f; + mn_8022EA08((char*) &string, temp_r28_4->unk4); + temp_r3_6->x4A = 1; + HSD_SisLib_803A6B98(temp_r3_6, &string, 0.0f, 0.0f); +} + +void fn_8024AED0(HSD_GObj* arg0) +{ + HSD_JObj* sp7C; + void* sp50; + HSD_GObjProc* temp_r3_2; + HSD_Text* temp_r3_7; + HSD_Text* temp_r3_8; + f32 temp_f1; + f32 temp_f1_2; + s32 temp_r28_3; + s32 temp_r31; + s32 temp_r3_3; + s32 temp_r5; + u16 temp_r30; + u16 temp_r4; + u8 temp_r28_2; + soundtest_user_data* temp_r26; + soundtest_user_data* temp_r27; + soundtest_user_data* temp_r28_5; + HSD_JObj* temp_r27_2; + soundtest_user_data* temp_r3_4; + u64 events; + + soundtest_user_data* user_data = arg0->user_data; + if ((u16) mn_804D6BC8.x0 != 0) { + Menu_DecrementAnimTimer(); + return; + } + events = Menu_GetEvents(); + if (events & MenuEvent_Back) { + lbAudioAx_80023694(); + user_data->unk0 = 1U; + mnSoundTest_8024AA70(mnSoundTest_804D6C40, user_data->unk0); + HSD_GObjProc_8038FE24(HSD_GObj_804D7838); + temp_r3_2 = HSD_GObjProc_8038FD54(arg0, fn_8024B2B0, 0U); + temp_r3_2->flags_1 = HSD_GObj_804D783C; + return; + } + temp_r26 = mnSoundTest_804D6C40->user_data; + temp_f1 = temp_r26->unk8; + if (temp_f1 < 1.0f) { + temp_r26->unk8 = (f32) (temp_f1 - 0.02f); + M2C_ERROR(/* unknown instruction: cror eq, lt, eq */); + if (temp_r26->unk8 == 0.0f) { + temp_r26->unk8 = 1.0f; + temp_r27 = mnSoundTest_804D6C40->user_data; + lbAudioAx_800236DC(mnSoundTest_804D6C40); + temp_r27->unk2 = 0x50; + } + } + temp_f1_2 = temp_r26->unkC; + if (temp_f1_2 < 1.0f) { + temp_r26->unkC = (f32) (temp_f1_2 - 0.02f); + M2C_ERROR(/* unknown instruction: cror eq, lt, eq */); + if (temp_r26->unkC == 0.0f) { + temp_r26->unkC = 1.0f; + lbAudioAx_80023694(); + } + } + if ((u8) mnSoundTest_804D6C44 == 0) { + temp_r3_3 = lbAudioAx_80023968(data_3[user_data->unk3]); + temp_r5 = 0 & 0; + if (events & MenuEvent_unk2) { + temp_r30 = user_data->unk4; + temp_r28_2 = data_3[user_data->unk3]; + temp_r3_4 = mnSoundTest_804D6C40->user_data; + temp_r27_2 = mnSoundTest_804D6C40->hsd_obj; + temp_r3_4->unkC = 1.0f; + gmMainLib_8015ED74(); + mnSoundTest_804D6C4C = lbAudioAx_800245F4(gm_80160244()); + temp_r28_3 = lbAudioAx_80023A44(temp_r28_2, temp_r30); + lbAudioAx_80023694(); + lbAudioAx_80023B24(temp_r28_3); + lb_80011E24(temp_r27_2, &sp7C, 0xD, -1); + HSD_JObjReqAnimAll(sp7C, vec_4.x); + mn_8022F3D8(sp7C, 0xFFU, MOBJ_MASK); + HSD_JObjAnimAll(sp7C); + } else if (events & MenuEvent_unk) { + if (user_data->unkC == 1.0f) { + user_data->unkC = 0.98f; + } + } else if (events & MenuEvent_Left) { + temp_r4 = user_data->unk4; + if (temp_r4 != 0) { + user_data->unk4 = (u16) (temp_r4 - 1); + } else { + user_data->unk4 = (u16) (temp_r3_3 - 1); + } + fn_8024AED0_inline(arg0); + } else if (events & MenuEvent_Right) { + user_data->unk4 += 1; + if (user_data->unk4 >= temp_r3_3) { + user_data->unk4 = 0; + } + fn_8024AED0_inline(arg0); + } + mnSoundTest_8024A790(mnSoundTest_804D6C40); + } +} diff --git a/src/melee/mn/mnsoundtest.h b/src/melee/mn/mnsoundtest.h index b29f1ae049..58b2c545af 100644 --- a/src/melee/mn/mnsoundtest.h +++ b/src/melee/mn/mnsoundtest.h @@ -1,4 +1,45 @@ #include +#include extern HSD_PadStatus HSD_PadCopyStatus[4]; +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u16 unk4; + f32 unk8; + f32 unkC; + UNK_T unk10; + HSD_Text* unk14; + HSD_Text* unk18; + HSD_Text* unk1C; +} soundtest_user_data; + +typedef struct { + /* +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 */ HSD_GObj* next; + /* +C */ HSD_GObj* prev; + /* +10 */ HSD_GObj* next_gx; + /* +14 */ HSD_GObj* prev_gx; + /* +18 */ HSD_GObjProc* proc; + /* +1C */ GObj_RenderFunc render_cb; + /* +20 */ u64 gxlink_prios; + /* +28 */ void* hsd_obj; + /* +2C */ soundtest_user_data* user_data; + /* +30 */ void (*user_data_remove_func)(void* data); + /* +34 */ void* x34_unk; +} Soundtest_GObj; + void mnSoundTest_8024A790(HSD_GObj*); +void mnSoundTest_8024A958(Soundtest_GObj*); +void mnSoundTest_8024AA70(HSD_GObj* arg0, u8 arg1); +void mnSoundTest_8024ABF8(HSD_GObj* arg0, u8 arg1); +void mnSoundTest_8024AD58(HSD_GObj* arg0, s8 arg1); +void fn_8024AED0(HSD_GObj* arg0); diff --git a/src/sysdolphin/baselib/controller.h b/src/sysdolphin/baselib/controller.h index 95a82883df..3061ed9298 100644 --- a/src/sysdolphin/baselib/controller.h +++ b/src/sysdolphin/baselib/controller.h @@ -84,6 +84,7 @@ struct PadLibData { extern HSD_PadStatus HSD_PadMasterStatus[4]; extern HSD_PadStatus HSD_PadGameStatus[4]; +extern HSD_PadStatus HSD_PadCopyStatus[4]; void HSD_PadFlushQueue(HSD_FlushType); u8 HSD_PadGetRawQueueCount(void);