From 25c00617e69f0dcedf2fa1ea3eb5bc37e4f79ad1 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Sun, 30 Aug 2026 22:46:17 -0700 Subject: [PATCH] Split gmregclear at its original translation-unit boundaries The retail .sdata2 pool for this range holds four copies of the signed int-to-float magic, three of the unsigned one, and duplicate 100.0f, 0.5f, 1.0f and 2.0f. A single MWCC unit pools each constant once, so the range was several units. Two of the boundaries are recoverable exactly: - gm_GetAdventureData at 0x8017E424 opens a unit owning the adventure stage table (.data 0x803D7AC0) and UnkAdventureData (.bss 0x80472C30); - gm_GetAllStarData at 0x8017EB30 opens one owning the allstar stage table (.data 0x803D85F0) and its state (.bss 0x80472CB0); - 0x8017F008 opens gmregclear proper, whose .data starts at lbl_803D8B88 -- the string-pool base that fn_8017F2A4, fn_801803FC and fn_80180630 anchor on. Every section divides along those lines without a remainder: .rodata, .bss, .sdata, .sbss and .sdata2 each partition by which unit's functions reference them, and the 4- and 2-byte holes before lbl_803D85F0 and lbl_803D8B88 fall out as linker alignment rather than needing padding members. gm_17E4 and gm_17EB match completely, functions and data, and are marked Matching. gm_17C0 and gmregclear are byte-exact in every data section they own except gmregclear's .sdata2, which still merges the two units remaining in its tail. fn_80180630 improves from 97.53% to 98.28% now that it anchors on the right base. --- config/GALE01/splits.txt | 29 +- config/GALE01/symbols.txt | 8 +- configure.py | 3 + src/melee/gm/gm_1736.c | 3 +- src/melee/gm/gm_17C0.c | 1288 ++++++++++++++++++++++ src/melee/gm/gm_17C0.h | 52 + src/melee/gm/gm_17E4.c | 404 +++++++ src/melee/gm/gm_17E4.h | 30 + src/melee/gm/gm_17EB.c | 233 ++++ src/melee/gm/gm_17EB.h | 24 + src/melee/gm/gm_1A9B.c | 2 +- src/melee/gm/gm_unsplit.h | 3 + src/melee/gm/gmregclear.c | 2094 +++--------------------------------- src/melee/gm/gmregclear.h | 72 -- src/melee/gr/grcorneria.c | 2 +- src/melee/gr/grfigureget.c | 2 +- 16 files changed, 2199 insertions(+), 2050 deletions(-) create mode 100644 src/melee/gm/gm_17C0.c create mode 100644 src/melee/gm/gm_17C0.h create mode 100644 src/melee/gm/gm_17E4.c create mode 100644 src/melee/gm/gm_17E4.h create mode 100644 src/melee/gm/gm_17EB.c create mode 100644 src/melee/gm/gm_17EB.h diff --git a/config/GALE01/splits.txt b/config/GALE01/splits.txt index 58d8d0b4a2..5ae90758b4 100644 --- a/config/GALE01/splits.txt +++ b/config/GALE01/splits.txt @@ -2329,14 +2329,33 @@ melee/gm/gmregcommon.c: .data start:0x803D79F0 end:0x803D7A50 .sdata start:0x804D4050 end:0x804D4058 +melee/gm/gm_17C0.c: + .text start:0x8017C0C8 end:0x8017E424 + .rodata start:0x803B7C08 end:0x803B7C18 + .data start:0x803D7A50 end:0x803D7AC0 + .bss start:0x804706C0 end:0x80472C30 + .sdata2 start:0x804DA428 end:0x804DA448 + +melee/gm/gm_17E4.c: + .text start:0x8017E424 end:0x8017EB30 + .data start:0x803D7AC0 end:0x803D85F0 + .bss start:0x80472C30 end:0x80472CB0 + .sdata2 start:0x804DA448 end:0x804DA458 + +melee/gm/gm_17EB.c: + .text start:0x8017EB30 end:0x8017F008 + .data start:0x803D85F0 end:0x803D8B88 + .bss start:0x80472CB0 end:0x80472D28 + .sdata2 start:0x804DA458 end:0x804DA468 + melee/gm/gmregclear.c: - .text start:0x8017C0C8 end:0x8018325C - .rodata start:0x803B7C08 end:0x803B7C28 - .data start:0x803D7A50 end:0x803D9248 - .bss start:0x804706C0 end:0x804735A8 + .text start:0x8017F008 end:0x8018325C + .rodata start:0x803B7C18 end:0x803B7C28 + .data start:0x803D8B88 end:0x803D9248 + .bss start:0x80472D28 end:0x804735A8 .sdata start:0x804D4058 end:0x804D408D .sbss start:0x804D65B8 end:0x804D65F0 - .sdata2 start:0x804DA428 end:0x804DA538 + .sdata2 start:0x804DA468 end:0x804DA538 melee/gm/gm_1832.c: .text start:0x8018325C end:0x80188454 diff --git a/config/GALE01/symbols.txt b/config/GALE01/symbols.txt index 6a2895d252..eed53727b7 100644 --- a/config/GALE01/symbols.txt +++ b/config/GALE01/symbols.txt @@ -31538,10 +31538,10 @@ lbl_804DA430 = .sdata2:0x804DA430; // type:object size:0x8 align:8 data:double lbl_804DA438 = .sdata2:0x804DA438; // type:object size:0x4 align:4 data:float lbl_804DA43C = .sdata2:0x804DA43C; // type:object size:0x4 align:4 data:float lbl_804DA440 = .sdata2:0x804DA440; // type:object size:0x4 align:4 data:float -lbl_804DA448 = .sdata2:0x804DA448; // type:object size:0x4 align:4 data:float -lbl_804DA450 = .sdata2:0x804DA450; // type:object size:0x8 align:8 data:double -lbl_804DA458 = .sdata2:0x804DA458; // type:object size:0x4 align:4 data:float -lbl_804DA460 = .sdata2:0x804DA460; // type:object size:0x8 align:8 data:double +@217 = .sdata2:0x804DA448; // type:object size:0x4 scope:local align:4 data:float +@219 = .sdata2:0x804DA450; // type:object size:0x8 scope:local align:8 data:double +@197 = .sdata2:0x804DA458; // type:object size:0x4 scope:local align:4 data:float +@199 = .sdata2:0x804DA460; // type:object size:0x8 scope:local align:8 data:double lbl_804DA468 = .sdata2:0x804DA468; // type:object size:0x4 align:4 data:float lbl_804DA46C = .sdata2:0x804DA46C; // type:object size:0x4 align:4 data:float lbl_804DA470 = .sdata2:0x804DA470; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index 7214ceb7e8..61ad28dc36 100755 --- a/configure.py +++ b/configure.py @@ -1152,6 +1152,9 @@ def MatchingFor(*versions): Object(Matching, "melee/gm/gm_17AD.c"), Object(Matching, "melee/gm/gm_17BA.c"), Object(Matching, "melee/gm/gmregcommon.c"), + Object(Linkable, "melee/gm/gm_17C0.c"), + Object(Matching, "melee/gm/gm_17E4.c"), + Object(Matching, "melee/gm/gm_17EB.c"), Object(Linkable, "melee/gm/gmregclear.c"), Object(Linkable, "melee/gm/gm_1832.c"), Object(Linkable, "melee/gm/gm_1884.c"), diff --git a/src/melee/gm/gm_1736.c b/src/melee/gm/gm_1736.c index f2bab210c7..920fac58b9 100644 --- a/src/melee/gm/gm_1736.c +++ b/src/melee/gm/gm_1736.c @@ -1,9 +1,10 @@ #include "gm_1601.h" #include "gm_16F1.h" +#include "gm_17C0.h" +#include "gm_17E4.h" #include "gm_1A3F.h" #include "gmevent.h" #include "gmmain_lib.h" -#include "gmregclear.h" #include "types.h" #include "ft/forward.h" diff --git a/src/melee/gm/gm_17C0.c b/src/melee/gm/gm_17C0.c new file mode 100644 index 0000000000..62a18141f5 --- /dev/null +++ b/src/melee/gm/gm_17C0.c @@ -0,0 +1,1288 @@ +#include "gm_17C0.h" + +#include "gm_17E4.h" +#include "gm_17EB.h" +#include "platform.h" + +#include "baselib/forward.h" + +#include "dolphin/pad.h" + +#include "gm/forward.h" + +#include "mn/inlines.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct lbl_804706D8_t { + s16 x0; + u8 x2; + u8 x3; +} lbl_804706D8_t; + +lbl_804706D8_t lbl_804706D8[12]; + +/// @todo Sizes are inferred from the split; contents are runtime-filled. +CSSData gmClassic_80470708; +DebugGameOverData gmClassic_80470850; +MatchExitInfo gmClassic_8047086C; +StartMeleeData gmClassic_80472AF8; + +typedef struct RegClearCharEntry { + /* 0x00 */ u8 x0; + /* 0x01 */ u8 x1; + /* 0x02 */ u8 x2; + /* 0x03 */ u8 x3; + /* 0x04 */ f32 x4; + /* 0x08 */ f32 x8; +} RegClearCharEntry; + +static struct lbl_804706C0_t { + int x0; + int x4; + int x8; + int xC; // HP (stamina) + int x10; + int x14; +} lbl_804706C0; + +void fn_8017C0C8(void) +{ + PlayerInitData sp8; + gm_8016795C(&sp8); + sp8.slot_type = Gm_PKind_Cpu; + sp8.stocks = 1; + sp8.xE = 4; + sp8.cpu_level = Player_GetCpuLevel(2); + sp8.xE = Player_GetCpuType(2); + sp8.x18 = Player_GetAttackRatio(2); + sp8.x1C = Player_GetUnk50(2); + sp8.color = 0; + sp8.ckind = CKIND_CREZYH; + sp8.team = 4; + sp8.xC_b7 = true; + sp8.hp = lbl_804706C0.xC; + sp8.xD_b2 = true; + sp8.xD_b0 = true; + sp8.xD_b2 = true; + sp8.spawn_dir = 1; + gm_8016EDDC(1, &sp8); +} + +void fn_8017C1A4(HSD_GObj* unused) +{ + struct lbl_804706C0_t* tmp = &lbl_804706C0; + int temp_r29; + int temp_r29_2; + int temp_r28; + int temp_r27; + int temp_r27_2; + int temp_r31; + int temp_r3; + int temp_r3_3; + lbl_8046B6A0_t* temp_r3_2; + lbl_8046B6A0_t* temp_r3_4; + PAD_STACK(8); + + temp_r31 = ftBossLib_8015C74C(); + temp_r29 = ftBossLib_8015C7EC(); + temp_r27 = ftBossLib_8015C88C(); + temp_r3 = ftBossLib_8015C9CC(); + switch (tmp->x0) { + case 0: + if (tmp->x8 == 0) { + temp_r3_2 = gm_16AE_GetUnkData_0(); + temp_r3_2->x24C8.disable_pausing = false; + temp_r3_2->hud_enabled = 0; + lbAudioAx_800237A8(0x81650, 0x7F, 0x40); + ftLib_80086824(); + tmp->x8 = 1; + } else if (ftBossLib_8015C270() == 0) { + tmp->x0 = 2; + } + break; + case 1: + if (tmp->x8 == 0) { + gm_16AE_GetUnkData_0(); + lbAudioAx_800236DC(); + ftBossLib_8015CA6C(0x1D9); + Player_SetMoreFlagsBit4(0, 1); + Player_SetMoreFlagsBit3(0, 1); + tmp->x10 = ft_80087C58(Player_GetEntity(0)); + ft_80087C64(Player_GetEntity(0), 2); + tmp->x14 = ft_80087C58(Player_GetEntity(2)); + ft_80087C64(Player_GetEntity(2), 2); + tmp->x8 = 1; + } else if (tmp->x8 == 1) { + lbAudioAx_800237A8(0x81651, 0x7F, 0x40); + fn_8017C0C8(); + tmp->x8 = 2; + } else if (ftBossLib_8015C2A8() == 0) { + gm_16AE_GetUnkData_0(); + Stage_80225074(0); + ftBossLib_8015CB7C(); + Player_SetMoreFlagsBit4(0, 0); + Player_SetMoreFlagsBit3(0, 0); + ft_80087C64(Player_GetEntity(0), tmp->x10); + ft_80087C64(Player_GetEntity(2), tmp->x14); + ftBossLib_8015CC14(); + tmp->x0 = 4U; + } + break; + case 2: + temp_r3_4 = gm_16AE_GetUnkData_0(); + temp_r3_4->hud_enabled = 1; + Stage_80225074(0); + ftLib_800868A4(); + ftBossLib_8015CC14(); + tmp->x0 = 3; + break; + case 3: + if (Player_GetRemainingHP(2) <= 0) { + tmp->x0 = 7; + tmp->x8 = 0; + } else if (Player_GetRemainingHP(2) <= 0.5F * tmp->xC && fn_8017EDDC()) + { + tmp->x0 = 1; + tmp->x8 = 0; + } + break; + case 4: + if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { + tmp->x0 = 7; + tmp->x8 = 0; + } else if (Player_GetRemainingHP(2) <= 0 || + Player_GetRemainingHP(1) <= 0) + { + tmp->x0 = 6; + tmp->x8 = 0; + } + break; + case 5: + if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { + tmp->x0 = 7; + tmp->x8 = 0; + } + break; + case 6: + if (Player_GetRemainingHP(2) <= 0) { + tmp->x4 = 2; + } else { + tmp->x4 = 1; + } + temp_r27_2 = temp_r31 + temp_r29; + if (tmp->x8 == 0) { + ftBossLib_8015CB9C(tmp->x4); + gm_801A4634(6); + } else if (tmp->x8 == temp_r31) { + lbAudioAx_8002438C(0x4E200); + ftBossLib_8015CC14(); + gm_801A4674(6); + gm_SetGameSpeed(0.5f); + } else if (tmp->x8 >= temp_r27_2) { + gm_SetGameSpeed(1.0f); + tmp->x0 = 5; + } + if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { + tmp->x0 = 7; + tmp->x8 = 0; + } else if (tmp->x8 <= temp_r27_2) { + tmp->x8++; + } + break; + case 7: + temp_r28 = temp_r31 + temp_r27; + temp_r29_2 = temp_r3 + temp_r28; + if (tmp->x8 == 0) { + temp_r3_4 = gm_16AE_GetUnkData_0(); + temp_r3_4->hud_enabled = 0; + if (tmp->x4 == 2) { + tmp->x4 = 1; + } else { + tmp->x4 = 2; + } + ftBossLib_8015CB9C(tmp->x4); + gm_801A4634(6); + Player_80031790(0); + Player_80036844(0, 1); + temp_r3_4 = gm_16AE_GetUnkData_0(); + temp_r3_4->x24C8.x0_6 = false; + } else if (tmp->x8 == temp_r31) { + lbAudioAx_8002438C(0x4E200); + ftBossLib_8015CC14(); + gm_801A4674(6); + gm_SetGameSpeed(0.5f); + lbBgFlash_80020688(temp_r27); + } else if (tmp->x8 == temp_r28) { + lbBgFlash_800205F0(temp_r3); + } else if (tmp->x8 >= temp_r29_2) { + lbAudioAx_80028B90(); + gm_SetGameSpeed(1.0f); + gm_8016B33C(8); + gm_8016B328(); + break; + } + if (tmp->x8 >= temp_r31) { + lbAudioAx_80028B6C(); + } + if (tmp->x8 <= temp_r28 && tmp->x8 % 30 == 0) { + gm_80167858(Player_GetPlayerId(0), Player_GetNametagSlotID(0), 2, + 0x1E); + Camera_80030E44(3, NULL); + } + if (tmp->x8 <= temp_r29_2) { + tmp->x8++; + } + break; + } +} + +void fn_8017C71C(void) +{ + struct lbl_804706C0_t* tmp = &lbl_804706C0; + HSD_GObj_SetupProc(GObj_Create(0xF, 0x11, 0), fn_8017C1A4, 0x15); + tmp->x0 = 0; + tmp->x4 = 1; + tmp->x8 = 0; + tmp->xC = ftBossLib_8015C530(gm_8017E068()); + Player_SetOtherStamina(2, tmp->xC); + ftLib_80087508(FTKIND_CREZYH, 0); +} + +void fn_8017C7A0(void) +{ + lbBgFlash_8002063C(0x30); + if (Ground_801C1DAC()) { + gm_8016B350(0x7C85E); + return; + } + gm_8016B350(0x9C48); +} + +void fn_8017C7EC(void) +{ + lbl_8046B6A0_t* temp_r31; + Unk1PData* temp_r30; + + temp_r30 = fn_8017DF28(); + temp_r31 = gm_16AE_GetUnkData_1(); + temp_r31->timer_seconds = grPushOn_80219230(temp_r30->ckind); +} + +void gm_8017C838(void) +{ + s8 sp10[3]; + + lbl_8046B6A0_t* temp_r3; + int i; + s8 var_r3; + s8* var_r31; + UnkAdventureData* temp_r30; + + PAD_STACK(8); + + temp_r30 = gm_GetAdventureData(); + temp_r3 = gm_16AE_GetUnkData_0(); + var_r31 = sp10; + sp10[0] = FTKIND_NONE; + sp10[1] = FTKIND_NONE; + sp10[2] = FTKIND_NONE; + switch (temp_r3->x24C8.stkind) { + case 0x3B: + sp10[0] = FTKIND_YOSHI; + break; + case 0x3F: + sp10[0] = FTKIND_LINK; + break; + case 0x44: + sp10[0] = FTKIND_KIRBY; + if (temp_r30->x0.ckind == CKIND_KIRBY && temp_r30->x0.color == 0) { + var_r3 = 1; + } else { + var_r3 = 0; + } + ftLib_80087610(var_r3); + break; + case 0x48: + sp10[0] = 0xC; + if (gm_IsCKindUnlocked(CKIND_PICHU) != 0) { + sp10[1] = FTKIND_PICHU; + } + if (gm_IsCKindUnlocked(CKIND_PURIN) != 0) { + sp10[2] = FTKIND_PURIN; + } + break; + case 0x4C: + sp10[0] = FTKIND_POPO; + sp10[1] = FTKIND_NANA; + break; + case 0x4E: + sp10[0] = FTKIND_BOY; + sp10[1] = FTKIND_GIRL; + break; + } + + for (i = 0; i < 3; i++) { + if (*var_r31 != FTKIND_MAX) { + ftLib_80087574(*var_r31); + } + var_r31++; + } + Camera_80030E34(0.2f); +} + +void gm_8017C984(UNK_T arg0) +{ + memzero(arg0, 0x74); +} + +static const u8 lbl_803B7C08[3][5] = { + { 1, 2, 3, 5, 10 }, + { 1, 2, 3, 5, 10 }, + { 10, 10, 10, 10, 10 }, +}; + +void gm_8017C9A8(DebugGameOverData* arg0, Unk1PData* arg1, u8 arg2) +{ + PAD_STACK(8); + arg0->x0 = arg1->xC.x18; + arg0->x8 = arg2; + arg0->ckind = arg1->ckind; + arg0->slot = arg1->slot; + arg0->x15 = arg1->x4; + arg0->x18 = gm_801623D8(); + arg0->x16 = lbl_803B7C08[arg2][arg1->cpu_level]; +} + +void gm_8017CA38(DebugGameOverData* arg0, Unk1PData* arg1, gmm_x0_528_t* arg2, + u8 arg3) +{ + u8 temp_r31; + + arg1->xC.x14 = arg0->x18; + gm_801623FC(arg1->xC.x14); + if (arg0->xC == 0) { + temp_r31 = gm_80173224(arg3, 0); + switch (gm_GetCurrentGameMode()) { + case GM_CLASSIC: + fn_80162BFC(arg1->ckind, arg0->x4); + break; + case GM_ADVENTURE: + fn_80162DF8(arg1->ckind, arg0->x4); + break; + case GM_ALLSTAR: + fn_80162FF4(arg1->ckind, arg0->x4); + break; + } + Ground_801C5A60(); + gm_8017390C(fn_8017DF90(), 0); + gm_80173EEC(); + gm_80172898(0x40); + if (temp_r31 == CHKIND_NONE) { + if (gm_80173754(1, arg1->slot) == 0) { + gm_ChangeGameModeAfterCurrentScene(GM_MENU); + } + } else { + gm_801736E8(arg1->ckind, arg1->color, arg1->slot, arg1->x4, + temp_r31, 1U); + gm_ChangeGameModeAfterCurrentScene(GM_CHALLENGER_APPROACH); + } + } else { + arg1->xC.x18 = lbTime_8000AEC8((u32) arg0->x4, 1U); + arg1->stocks = arg2->stocks; + arg1->xC.xD = lbTime_8000AF74((u32) arg1->xC.xD, 1); + gm_SetNextGameModeStateId(arg1->x7); + } +} + +void gm_8017CBAC(UnkAdventureData* arg0, gmm_x0_528_t* arg1, u8 arg2) +{ + s32 temp_r3_2; + u8 temp_r31; + u8* temp_r3; + + temp_r31 = gm_CKindToSelKind(arg0->x0.ckind); + Ground_801C5A60(); + switch (arg2) { + case 21: + gmMainLib_8015D134(temp_r31); + fn_80162BFC(arg0->x0.ckind, arg0->x0.xC.x18); + temp_r3 = gmMainLib_8015D194(temp_r31); + if (*temp_r3 < arg0->x0.cpu_level) { + *temp_r3 = arg0->x0.cpu_level; + } + temp_r3_2 = gmMainLib_8015D1AC(temp_r31); + if ((arg0->x0.cpu_level == 4) && + ((temp_r3_2 == 0) || (arg1->stocks < temp_r3_2))) + { + gmMainLib_8015D1C8(temp_r31, arg1->stocks); + } + break; + case 22: + gmMainLib_8015D25C(temp_r31); + fn_80162DF8(arg0->x0.ckind, arg0->x0.xC.x18); + temp_r3 = gmMainLib_8015D2BC(temp_r31); + if (*temp_r3 < arg0->x0.cpu_level) { + *temp_r3 = arg0->x0.cpu_level; + } + temp_r3_2 = gmMainLib_8015D2D4(temp_r31); + if ((arg0->x0.cpu_level == 4) && + ((temp_r3_2 == 0) || (arg1->stocks < temp_r3_2))) + { + gmMainLib_8015D2F0(temp_r31, arg1->stocks); + } + break; + case 23: + gmMainLib_8015D384(temp_r31); + fn_80162FF4(arg0->x0.ckind, arg0->x0.xC.x18); + if (!gm_80164430(0x1F)) { + gm_80164504(0x1F); + } + temp_r3 = gmMainLib_8015D3E4(temp_r31); + if (*temp_r3 < arg0->x0.cpu_level) { + *temp_r3 = arg0->x0.cpu_level; + } + temp_r3_2 = gmMainLib_8015D3FC(temp_r31); + if ((arg0->x0.cpu_level == 4) && + (temp_r3_2 == 0 || arg1->stocks < temp_r3_2)) + { + gmMainLib_8015D418(temp_r31, arg1->stocks); + } + break; + } + lb_8001C550(); + lb_8001D164(0); + lb_8001CE00(); + gm_SetPendingGameMode(arg2); + gm_SetNewGameModePending(); +} + +u8 gm_8017CD94(UnkAdventureData* arg0, int arg1, int arg2, int arg3) +{ + u8 num_colors; + u8 result; + + num_colors = gm_80169238(arg1); + if (arg0->x54 != NULL) { + result = arg0->x54(arg2, arg0->x0.cpu_level, arg3); + if (num_colors != 0) { + return result % num_colors; + } + return 0; + } + return 0; +} + +static inline s32 gm_8017CE34_CountEnemies(const s8* arg0) +{ + s32 count = 0; + s32 i; + + for (i = 0; i < 3; i++) { + if ((s32) arg0[i] != CHKIND_NONE) { + count++; + } + } + return count; +} + +static inline void gm_8017CE34_SetupColors(UnkAdventureData* arg1, s32 count, + s8* arg2, u8* colors) +{ + u8* out_color = colors; + s32 color_idx; + s8* kind_iter = arg2; + + for (color_idx = 0; color_idx < 3; color_idx++) { + *out_color = gm_8017CD94(arg1, (u8) *kind_iter, count, color_idx); + out_color++; + kind_iter++; + } +} + +static inline u8 gm_8017CE34_ResolvePlayerCKind(UnkAdventureData* arg1, + u8 player_ckind) +{ + if (((s32) player_ckind == CKIND_ZELDA) && (arg1->x0.xC.x12 != 0)) { + player_ckind = CKIND_SEAK; + } else if (((arg1->x0.x8 & 0x80) != 0) && (arg1->x0.x9 == 1) && + ((s8) player_ckind == CKIND_POPONANA)) + { + player_ckind = CHKIND_POPO; + } + return player_ckind; +} + +static inline u8 gm_8017CE34_GetCpuLevel(UnkAdventureData* arg1) +{ + return arg1->x0.cpu_level; +} + +void gm_8017CE34(StartMeleeData* arg0, UnkAdventureData* arg1, s8* arg2, + u8 arg3, u8 arg4, u8 arg5, s32 arg6, StKind arg7, s32 count, + s32 arg9) +{ + u8 colors[16]; + u8 enemy_level; + s32 boss_count; + u8 enemy_cpu_type; + s32 player_idx; + f32 attack_ratio; + u8 player_stocks; + u8 player_ckind; + u8 flags; + s8* enemy_kind; + f32 defense_ratio; + u8 enemy_ckind; + s32 enemy_count; + s32 enemy_idx; + u8* color_iter; + + boss_count = 0; + enemy_level = 0; + enemy_cpu_type = 0; + arg1->x0.xC.xC = 1; + fn_8017E21C(); + fn_8016F030(arg0); + arg0->rules.x30 = 1.0f; + arg0->rules.x4_4 = 1; + + switch (arg9) { + case 0: + arg0->rules.xA = 0; + break; + case 1: + arg0->rules.xA = 3; + break; + case 2: + arg0->rules.xA = 2; + break; + } + + arg0->rules.x1_1 = 1; + arg0->rules.x4_2 = 1; + arg0->rules.x4_3 = 1; + arg0->rules.x2_5 = 0; + arg0->rules.x0_3 = arg1->x0.xB; + + if (arg6 != 0) { + arg0->rules.time_limit = (u32) arg6; + arg0->rules.x0_6 = 1; + } else { + arg0->rules.x0_6 = 0; + } + + arg0->rules.x18 = (u32) arg1->x0.xC.x18; + arg0->rules.stkind = (u16) arg7; + arg0->rules.xB = arg1->x48((u8) count, arg1->x0.cpu_level); + + arg0->rules.x20 = (u64) -1; + + enemy_count = gm_8017CE34_CountEnemies(arg2); + if (enemy_count == 0) { + arg0->rules.x5_1 = 1; + } + if (arg1->x0.x8 & 1) { + arg0->rules.x2_7 = 1; + } + if (arg1->x0.x8 & 0x20) { + arg0->rules.x4_5 = 1; + } + if (arg1->x0.x8 & 0x80) { + arg1->x0.xC.xC = 5; + switch ((s32) arg1->x0.x9) { + case 1: + arg0->rules.on_pause_override = gm_80165290; + arg0->rules.x9 = 1; + arg0->rules.x3_1 = 0; + arg0->players[0].xC_b1 = 0; + break; + case 2: + arg0->rules.x9 = 3; + arg0->rules.x44 = fn_8017C7EC; + break; + case 3: + arg0->rules.x9 = 2; + arg0->rules.x7 = 9; + arg0->rules.x4_4 = 0; + arg0->rules.x50 = (void (*)(u8)) fn_8017C7A0; + arg0->rules.xD = 0x30; + break; + } + } + + if ((arg1->x0.x8 & 0x80) != 0) { + player_stocks = 1; + } else { + player_stocks = arg1->x0.stocks; + } + + player_ckind = (u8) arg1->x0.ckind; + player_ckind = gm_8017CE34_ResolvePlayerCKind(arg1, player_ckind); + + gm_801B0620(arg0->players, player_ckind, arg1->x0.color, player_stocks, + arg1->x0.slot); + arg0->players[0].nametag = arg1->x0.x4; + arg0->players[0].spawn_dir = (s8) arg1->x0.xA; + + { + u8 team_color; + if (arg1->x58 != NULL) { + team_color = + arg1->x58((u8) count, gm_8017CE34_GetCpuLevel(arg1), 0); + } else { + team_color = 0; + } + + { + player_idx = + fn_8017DD7C(arg0->players, arg1->x0.xC.x24, team_color) + 1; + arg0->rules.is_teams = 1; + } + } + + attack_ratio = arg1->x64((u8) count, arg1->x0.cpu_level); + defense_ratio = arg1->x68((u8) count, arg1->x0.cpu_level); + + color_iter = colors; + gm_8017CE34_SetupColors(arg1, count, arg2, color_iter); + + { + s32 temp_r3_4 = arg1->x0.x8 & 8; + if ((temp_r3_4 != 0) && (arg1->x0.xC.x11 == 0)) { + s32 event_enemy_count; + s32 special_stage; + s32 special_enemy_mode; + u8 sp8; + u8 first_enemy; + u32 stage_flags; + + event_enemy_count = gm_8017CE34_CountEnemies(arg2); + arg1->x0.xC.xC = 3; + special_stage = 0; + special_enemy_mode = 0; + sp8 = 0; + if (arg1->x4C != NULL) { + enemy_level = arg1->x4C((u8) count, arg1->x0.cpu_level, 0U); + } + + first_enemy = (u8) arg2[0]; + if ((s8) first_enemy != 4) { + if ((u8) (first_enemy - 0x1B) <= 1U) { + arg0->rules.x0_3 = 6; + event_enemy_count = 5; + colors[0] = 0; + special_stage = 1; + special_enemy_mode = 1; + } else if (((s8) first_enemy == 0xD) && + (((s32) arg2[1] != 0xD) || ((s32) arg2[2] != 0xD))) + { + special_enemy_mode = 2; + } + } + + stage_flags = Ground_801C5AD0(Stage_8022519C(arg7)); + + gm_8016A22C((s8) (u8) arg2[0], arg2[1], arg2[2], colors[0], + colors[1], (s32) colors[2], special_stage, + special_enemy_mode, sp8, (u8) arg1->x0.ckind, + arg1->x0.color, (s32) enemy_level, (s32) arg3, + event_enemy_count, (s32) stage_flags, (s32) arg5, + (s32) arg4, attack_ratio, defense_ratio); + gm_8016A21C(&arg0->rules); + arg1->x0.xC.x11 = 0; + if (arg1->x0.x8 & 4) { + fn_8016A450(); + } + if ((u8) special_enemy_mode == 1) { + fn_8016A46C(); + arg0->players[0].xC_b5 = 1; + } + } else if (temp_r3_4 != 0) { + gm_8016A21C(&arg0->rules); + arg1->x0.xC.x11 = 0; + } + } + + gmRegSetupEnemyColorTable((s8) (u8) arg1->x0.ckind, arg1->x0.color, arg2, + colors); + + enemy_idx = 0; + for (;;) { + enemy_kind = &arg2[enemy_idx]; + if ((s32) (u8) enemy_kind[0] != 0x21) { + if (arg1->x0.x8 & 8) { + if (arg1->x4C != NULL) { + enemy_level = + arg1->x4C((u8) count, arg1->x0.cpu_level, 0U); + } + if (arg1->x50 != NULL) { + enemy_cpu_type = + arg1->x50((u8) count, arg1->x0.cpu_level, 0U); + } + } else { + if (arg1->x4C != NULL) { + u8 selected_enemy_level = + arg1->x4C((u8) count, arg1->x0.cpu_level, enemy_idx); + enemy_level = selected_enemy_level; + } + if (arg1->x50 != NULL) { + enemy_cpu_type = + arg1->x50((u8) count, arg1->x0.cpu_level, enemy_idx); + } + } + gm_8016795C(&arg0->players[player_idx]); + arg0->players[player_idx].slot_type = 1; + arg0->players[player_idx].ckind = (s8) (u8) enemy_kind[0]; + arg0->players[player_idx].stocks = 1; + arg0->players[player_idx].cpu_level = enemy_level; + arg0->players[player_idx].xE = enemy_cpu_type; + arg0->players[player_idx].x18 = attack_ratio; + arg0->players[player_idx].x1C = defense_ratio; + arg0->players[player_idx].color = *color_iter; + if (arg1->x0.x8 & 2) { + arg0->players[player_idx].x20 = 2.0f; + arg0->players[player_idx].xB = 2; + } else { + arg0->players[player_idx].x20 = 1.0f; + arg0->players[player_idx].xB = 0; + } + if (arg1->x0.x8 & 4) { + arg0->players[player_idx].xC_b2 = 1; + arg0->players[player_idx].xE = 0x1B; + } + if ((s32) arg0->players[player_idx].ckind == CKIND_GKOOPS) { + arg0->players[player_idx].xC_b1 = 0; + } + enemy_ckind = (u8) arg0->players[player_idx].ckind; + if (((s8) enemy_ckind == CKIND_MASTERH) || + ((s8) enemy_ckind == CKIND_CREZYH)) + { + arg0->players[player_idx].xC_b7 = 1; + arg0->players[player_idx].hp = 0x12C; + arg0->players[player_idx].xD_b2 = 1; + arg0->players[player_idx].xD_b0 = 1; + arg0->players[player_idx].xD_b2 = 1; + arg0->players[player_idx].spawn_dir = -1; + if ((s32) arg0->players[player_idx].ckind == CKIND_CREZYH) { + arg0->players[player_idx].slot_type = 3; + } + boss_count += 1; + } + if (arg0->rules.is_teams == 1) { + arg0->players[player_idx].team = 4; + } + player_idx += 1; + if (player_idx >= 6) { + break; + } + } else { + if ((enemy_idx == 0) && ((s32) enemy_kind[1] == 0x1A)) { + arg0->players[player_idx].slot_type = 3; + player_idx += 1; + } + } + enemy_idx += 1; + color_iter += 1; + if (enemy_idx >= 3) { + break; + } + } + + { + s32 i; + for (i = player_idx; i < 6; i++) { + arg0->players[i].slot_type = 3; + } + } + + flags = arg1->x0.x8; + if (flags & 0x40) { + arg1->x0.xC.xC = 7; + } else if (flags & 1) { + if ((flags & 8) && (arg3 > 1U)) { + arg1->x0.xC.xC = 4; + } else { + arg1->x0.xC.xC = 2; + } + } + if (boss_count != 0) { + arg0->rules.x1_2 = 1; + arg0->rules.x1_3 = 1; + arg0->rules.x1_4 = 1; + arg0->rules.x0_3 = 3; + arg0->rules.disable_pausing = 1; + arg0->rules.x7 = 0; + arg0->rules.x44 = (void (*)(void)) fn_8017C71C; + arg1->x0.xC.xC = 6; + } + if (arg7 == 0x49) { + arg1->x0.xC.xC = 8; + } +} + +bool gm_8017D7AC(MatchExitInfo* arg0, Unk1PData* arg1, u8 arg2) +{ + u8 temp_r0; + + arg1->xC.x14 = + lbTime_8000AEC8(arg1->xC.x14, arg0->match_end.player_standings[0].xE); + gm_8016247C(arg0->match_end.player_standings[0].xE); + arg1->xC.x1C = + lbTime_8000AEC8(arg1->xC.x1C, arg0->match_end.player_standings[0].x44); + gm_80162968(arg0->match_end.frame_count / 60); + if (!(arg1->x8 & 0x80)) { + arg1->xC.x20 = + lbTime_8000AEC8(arg1->xC.x20, arg0->match_end.frame_count); + } + if (arg0->match_end.player_standings[0].ftkind == 7) { + arg1->xC.x12 = 1; + } else { + arg1->xC.x12 = 0; + } + if (fn_8016B510() != 0) { + arg1->xC.xF = 1; + } + if (fn_8016B4BC() != 0) { + arg1->xC.xE = 1; + } + temp_r0 = arg0->match_end.result; + if ((temp_r0 == OUTCOME_NO_CONTEST || temp_r0 == OUTCOME_RETRY) && + DbLevel <= DbLKind_DebugDevelop) + { + switch (gm_GetCurrentGameMode()) { + case GM_CLASSIC: + fn_80162BFC(arg1->ckind, arg1->xC.x18); + break; + case GM_ADVENTURE: + fn_80162DF8(arg1->ckind, arg1->xC.x18); + break; + case GM_ALLSTAR: + fn_80162FF4(arg1->ckind, arg1->xC.x18); + break; + } + gm_ChangeGameModeAfterCurrentScene(GM_MENU); + return 0; + } + fn_8017E3C8(); + if (!(arg1->x8 & 0x80)) { + arg1->stocks = arg0->match_end.player_standings[0].stocks; + if (arg1->stocks != 0) { + if (arg0->match_end.result == OUTCOME_TIMEOUT) { + arg1->stocks--; + if (arg1->stocks == 0) { + gm_SetNextGameModeStateId(arg2); + return 0; + } + if (!(arg1->x8 & 0x40)) { + arg1->xC.x10++; + gm_SetNextGameModeStateId(gm_GetCurrentSceneIndex()); + return 0; + } + } + } else { + arg1->xC.x10 = 0; + gm_SetNextGameModeStateId(arg2); + return 0; + } + } + arg1->xC.x18 = arg0->x0; + arg1->xC.x10 = 0; + return 1; +} + +#ifdef MUST_MATCH +#pragma opt_propagation off +#endif +static inline s32 pick_random_ckind(u8* arr, const u8* used_ckinds, + const u8* preset_ckinds) +{ + struct { + s32 count; + u8* cursor; + } scan; + u8 temp; + s32 j; + s32 i; + s32 swap_idx; + u8 ckind; + s32 used_idx; + s32 preset_idx; + u8* base; + u8* w; + u8* w2; + + base = arr; + scan.cursor = base; + scan.count = 0; + while ((s32) *scan.cursor != CHKIND_NONE) { + scan.cursor++; + scan.count++; + } + + w = base; + for (j = 0; j < scan.count; j++) { + temp = *w; + swap_idx = HSD_Randi(scan.count); + *w++ = base[swap_idx]; + base[swap_idx] = temp; + } + + w2 = base; + for (i = 0; i < scan.count; i++) { + if (gm_IsCKindUnlocked(*w2) != 0) { + ckind = *w2; + for (used_idx = 0; used_idx < 4; used_idx++) { + if ((s8) ckind == (s8) used_ckinds[used_idx]) { + used_idx = -1; + break; + } + } + if (used_idx != -1) { + for (preset_idx = 0; preset_idx < 3; preset_idx++) { + if ((s8) ckind == (s8) preset_ckinds[preset_idx]) { + preset_idx = -1; + break; + } + } + if (preset_idx != -1) { + return base[i]; + } + } + } + w2++; + } + + return CHKIND_NONE; +} + +s32 fn_8017D9C0(const u8* used_ckinds, const u8* preset_ckinds) +{ + return pick_random_ckind(lbl_803D79F0, used_ckinds, preset_ckinds); +} +#ifdef MUST_MATCH +#pragma opt_propagation reset +#pragma dont_inline on +#endif + +void gm_8017DB58(struct Unk1PData_x24* arg0) +{ + int i; + for (i = 0; i < 3; i++) { + arg0[i].ckind = CHKIND_NONE; + } +} + +u8 gm_8017DB6C(gm_8017DB6C_arg0_t* arg0, int index) +{ + return arg0[index].x0; +} + +u8 gm_8017DB78(gm_8017DB6C_arg0_t* arg0, int index) +{ + return arg0[index].x1; +} + +s32 gm_8017DB88(void* arg0, u8 arg1, s32 arg2, s32 arg3, u8* arg4, u8 arg5, + u8 (*arg6)(s32, s32, u8), u8 (*arg7)(s32, s32, u8), + u8 (*arg8)(s32, s32, u8), f32 (*arg9)(s32, s32), + f32 (*arg10)(s32, s32)) +{ + u8 chars[4]; + s32 val; + f32 fval; + + { + u8* p; + RegClearCharEntry* out; + s32 i; + s32 count; + + count = fn_8017DE54(arg1, arg4); + chars[1] = 0x21; + out = arg0; + chars[2] = 0x21; + p = chars; + i = 0; + chars[3] = 0x21; + chars[0] = arg5; + for (; i < count; i++) { + p[1] = fn_8017D9C0(chars, arg4); + out->x0 = p[1]; + if (arg8 != NULL) { + val = arg8(arg3, arg2, (u8) i); + } else { + val = 0; + } + out->x1 = val; + if (arg6 != NULL) { + val = arg6(arg3, arg2, (u8) i); + } else { + val = 0; + } + out->x2 = val; + if (arg7 != NULL) { + val = arg7(arg3, arg2, (u8) i); + } else { + val = 0; + } + out->x3 = val; + if (arg9 != NULL) { + fval = arg9(arg3, arg2); + } else { + fval = 0.0f; + } + out->x4 = fval; + if (arg10 != NULL) { + fval = arg10(arg3, arg2); + } else { + fval = 0.0f; + } + out->x8 = fval; + p++; + out++; + } + for (; i < 3; i++) { + ((RegClearCharEntry*) arg0)[i].x0 = 0x21; + } + return count; + } +} +#ifdef MUST_MATCH +#pragma dont_inline off +#endif + +s32 fn_8017DD7C(PlayerInitData* arg0, Unk1PData_x24* arg1, u8 arg2) +{ + s32 index = 1; + int i; + for (i = 0; i < 3; i++) { + if (arg1[i].ckind != CHKIND_NONE) { + gm_8016795C(&arg0[index]); + arg0[index].ckind = arg1[i].ckind; + arg0[index].slot_type = 1; + arg0[index].stocks = 1; + arg0[index].team = arg0->team; + arg0[index].color = arg1[i].x1; + arg0[index].xE = arg1[i].x3; + arg0[index].cpu_level = arg1[i].x2; + arg0[index].x18 = arg1[i].x4; + arg0[index].x1C = arg1[i].x8; + arg0[index].xD_b1 = 1; + if (arg0[index].ckind == CKIND_GKOOPS) { + arg0[index].xC_b1 = 0; + } + index++; + } + } + return index - 1; +} + +s32 fn_8017DE54(u8 arg0, u8* arg1) +{ + u8* p; + s32 count; + + if (arg0 & 0x20) { + return 0; + } + if (arg0 & 0x10) { + count = 0; + if ((s32) arg1[0] != 0x21) { + count = 1; + } + p = &arg1[1]; + if ((s32) *p != 0x21) { + count += 1; + } + if ((s32) p[1] != 0x21) { + count += 1; + } + return 3 - count; + } + if (arg0 & 2) { + return 2; + } + return 0; +} + +Unk1PData* fn_8017DEC8(int arg0) +{ + switch (arg0) { + case 0: + return &gm_GetAdventureData()->x0; + case 1: + return &gm_GetAllStarData()->x0; + case 2: + return &gm_80473A18.x0; + default: + return NULL; + } +} + +Unk1PData* fn_8017DF28(void) +{ + switch (gm_GetCurrentGameMode()) { + case GM_CLASSIC: + return &gm_GetAllStarData()->x0; + case GM_ADVENTURE: + return &gm_GetAdventureData()->x0; + case GM_ALLSTAR: + return &gm_80473A18.x0; + default: + return NULL; + } +} + +u8 fn_8017DF90(void) +{ + switch (gm_GetCurrentGameMode()) { + case GM_CLASSIC: + return 1; + case GM_ADVENTURE: + return 0; + case GM_ALLSTAR: + return 2; + default: + return 3; + } +} + +int gm_8017DFF4(int arg0) +{ + Unk1PData* var_r3 = fn_8017DEC8(arg0); + if (var_r3 != NULL) { + return var_r3->cpu_level; + } + return -1; +} + +int gm_8017E068(void) +{ + Unk1PData* var_r3 = fn_8017DF28(); + if (var_r3 != NULL) { + return var_r3->cpu_level; + } + return -1; +} + +int fn_8017E0E4(void) +{ + Unk1PData* var_r3 = fn_8017DF28(); + if (var_r3 != NULL) { + return var_r3->xC.xC; + } + return -1; +} + +bool fn_8017E160(void) +{ + Unk1PData* var_r3 = fn_8017DF28(); + struct Unk1PData_xC* temp_r3_2; + + if (var_r3 != NULL) { + int i; + for (i = 0; i < 3; i++) { + if (var_r3->xC.x24[i].ckind != CHKIND_NONE) { + return true; + } + } + return false; + } + return false; +} + +void fn_8017E21C(void) +{ + int i; + for (i = 0; i < 12; i++) { + lbl_804706D8[i].x0 = -1; + } +} + +s8 gm_8017E280(u16 arg0, u32 arg1) +{ + lbl_804706D8_t* var_r7 = lbl_804706D8; + s32 index; + index = 0; + for (index = 0; index < 12; index++) { + if (arg0 == var_r7[index].x0) { + var_r7[index].x2 += arg1; + return var_r7[index].x2; + } + } + index = 0; + for (index = 0; index < 12; index++) { + if (var_r7[index].x0 == -1) { + var_r7[index].x0 = arg0; + var_r7[index].x2 = arg1; + return (u8) arg1; + } + } + return -1; +} + +int fn_8017E318(void) +{ + int i; + int sum = 0; + for (i = 0; i < 12; i++) { + if (lbl_804706D8[i].x0 != -1) { + sum += lbl_804706D8[i].x2; + } + } + return sum; +} + +void fn_8017E3C8(void) +{ + int i = 0; + PAD_STACK(8); + for (i = 0; i < 12; i++) { + if (lbl_804706D8[i].x0 != -1) { + Toy_SetUnlockState(lbl_804706D8[i].x0, lbl_804706D8[i].x2); + } + } +} diff --git a/src/melee/gm/gm_17C0.h b/src/melee/gm/gm_17C0.h new file mode 100644 index 0000000000..eb2a62cb54 --- /dev/null +++ b/src/melee/gm/gm_17C0.h @@ -0,0 +1,52 @@ +#ifndef MELEE_GM_17C0_H +#define MELEE_GM_17C0_H + +#include +#include + +#include "ft/forward.h" +#include +#include +#include +#include + +/* 17C0C8 */ void fn_8017C0C8(void); +/* 17C1A4 */ void fn_8017C1A4(HSD_GObj*); +/* 17C71C */ void fn_8017C71C(void); +/* 17C7A0 */ void fn_8017C7A0(void); +/* 17C7EC */ void fn_8017C7EC(void); +/* 17C838 */ void gm_8017C838(void); +/* 17C984 */ void gm_8017C984(UNK_T); +/* 17C9A8 */ void gm_8017C9A8(DebugGameOverData*, Unk1PData*, u8); +/* 17CA38 */ UNK_RET gm_8017CA38(DebugGameOverData*, Unk1PData*, + struct gmm_x0_528_t*, u8); +/* 17CBAC */ UNK_RET gm_8017CBAC(UnkAdventureData*, struct gmm_x0_528_t*, u8); +/* 17CD94 */ u8 gm_8017CD94(UnkAdventureData*, int, int, int); +/* 17CE34 */ void gm_8017CE34(StartMeleeData*, UnkAdventureData*, s8*, u8, u8, + u8, s32, StKind, s32 count, s32); +/* 17D7AC */ bool gm_8017D7AC(MatchExitInfo*, Unk1PData*, u8); +/* 17D9C0 */ s32 fn_8017D9C0(const u8* used_ckinds, const u8* preset_ckinds); +/* 17DB58 */ void gm_8017DB58(struct Unk1PData_x24* arg0); +/* 17DB6C */ u8 gm_8017DB6C(gm_8017DB6C_arg0_t* arg0, int index); +/* 17DB78 */ u8 gm_8017DB78(gm_8017DB6C_arg0_t* arg0, int index); +/* 17DB88 */ s32 gm_8017DB88(void* arg0, u8 arg1, s32 arg2, s32 arg3, u8* arg4, + u8 arg5, u8 (*arg6)(s32, s32, u8), + u8 (*arg7)(s32, s32, u8), + u8 (*arg8)(s32, s32, u8), f32 (*arg9)(s32, s32), + f32 (*arg10)(s32, s32)); +/* 17DD7C */ s32 fn_8017DD7C(PlayerInitData* arg0, Unk1PData_x24* arg1, + u8 arg2); +/* 17DE54 */ s32 fn_8017DE54(u8, u8*); +/* 17DEC8 */ Unk1PData* fn_8017DEC8(int); +/* 17DF28 */ Unk1PData* fn_8017DF28(void); +/* 17DF90 */ u8 fn_8017DF90(void); +/* 17DFF4 */ int gm_8017DFF4(int); +/* 17E068 */ int gm_8017E068(void); +/* 17E0E4 */ int fn_8017E0E4(void); +/* 17E160 */ bool fn_8017E160(void); +/* 17E21C */ void fn_8017E21C(void); +/* 17E280 */ s8 gm_8017E280(u16, u32); +/* 17E318 */ int fn_8017E318(void); +/* 17E3C8 */ void fn_8017E3C8(void); + +#endif diff --git a/src/melee/gm/gm_17E4.c b/src/melee/gm/gm_17E4.c new file mode 100644 index 0000000000..4e27df260d --- /dev/null +++ b/src/melee/gm/gm_17E4.c @@ -0,0 +1,404 @@ +#include "gm_17E4.h" + +#include "gm_1601.h" +#include "gm_16AE.h" +#include "gm_17C0.h" +#include "gm_1A3F.h" + +#include +#include +#include +#include +#include +#include + +/// Adventure mode stage data table entry (size 0x1A) +/// Table has 110 entries: 22 stages × 5 difficulty levels +/// Indexed as: difficulty * 5 + stage_slot +typedef struct AdventureStageEntry { + /* 0x00 */ u8 stage_kind; + /* 0x01 */ u8 pad_1; + /* 0x02 */ u16 scale0_pct; ///< Divided by 100 to get ratio + /* 0x04 */ u16 scale1_pct; ///< Divided by 100 to get ratio + /* 0x06 */ u8 pad_6[0x14]; +} AdventureStageEntry; +ASSERT_SIZE(AdventureStageEntry, 0x1A); + +static UnkAdventureData lbl_80472C30; + +AdventureStageEntry lbl_803D7AC0[110] = { + { 4, 0, 0x28, 0x1c2, { 1 } }, + { 3, 0, 0x32, 0x190, { 2 } }, + { 3, 0, 0x3c, 0x140, { 4 } }, + { 2, 0, 0x46, 0xf0, { 5 } }, + { 1, 0, 0x50, 0xaa, { 6 } }, + { 4, 0, 0x50, 0x8c, { 0, 0, 0x10, 0, 0, 4 } }, + { 3, 0, 0x5e, 0x70, { 3, 0, 0x10, 3, 0, 4 } }, + { 3, 0, 0x64, 0x6b, { 5, 0, 0x10, 4, 0, 4 } }, + { 3, 0, 0x6e, 0x69, { 7, 0, 0x10, 7, 0, 4 } }, + { 2, 0, 0x78, 0x5f, { 8, 0, 0x10, 8, 0, 4 } }, + { 4, 0, 0x50, 0x8c, { 1, 0, 4, 1, 1, 8 } }, + { 4, 0, 0x64, 0x5a, { 2, 0, 4, 2, 1, 8 } }, + { 3, 0, 0x6e, 0x46, { 4, 0, 4, 3, 1, 8 } }, + { 2, 0, 0x78, 0x32, { 7, 0, 4, 6, 1, 8 } }, + { 1, 0, 0x82, 0x28, { 9, 0, 4, 9, 1, 8 } }, + { 4, 0, 0x3c, 0x17c, { 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, + { 4, 0, 0x50, 0xfa, { 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, + { 3, 0, 0x5a, 0xc8, { 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, + { 2, 0, 0x5f, 0xa0, { 7, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, + { 1, 0, 0x6e, 0x78, { 8, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, + { 3, 0, 0x46, 0xa0, { 1 } }, + { 2, 0, 0x50, 0x8c, { 3 } }, + { 2, 0, 0x5a, 0x78, { 5 } }, + { 1, 0, 0x64, 0x69, { 7 } }, + { 1, 0, 0x6c, 0x5f, { 9 } }, + { 4, 0, 0x50, 0x7d, { 2, 0, 4 } }, + { 4, 0, 0x5a, 0x6e, { 6, 0, 4 } }, + { 3, 0, 0x64, 0x64, { 8, 0, 4 } }, + { 3, 0, 0x76, 0x5f, { 9, 0, 4 } }, + { 2, 0, 0x82, 0x5a, { 9, 0, 4 } }, + { 3, 0, 0x50, 0x82, { 2, 0, 4 } }, + { 3, 0, 0x5a, 0x6e, { 5, 0, 4 } }, + { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, + { 2, 0, 0x73, 0x58, { 8, 0, 4 } }, + { 1, 0, 0x82, 0x4a, { 9, 0, 4 } }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 3, 0, 0x50, 0xaa, { 2, 0, 4 } }, + { 2, 0, 0x64, 0x82, { 4, 0, 4 } }, + { 2, 0, 0x78, 0x6e, { 6, 0, 4 } }, + { 1, 0, 0x82, 0x64, { 8, 0, 4 } }, + { 0xff, 0, 0x8c, 0x5a, { 9, 0, 4 } }, + { 3, 0, 0x3c, 0x1f4, { 1 } }, + { 2, 0, 0x46, 0x190, { 3 } }, + { 2, 0, 0x50, 0x12c, { 4 } }, + { 1, 0, 0x5a, 0xc8, { 6 } }, + { 0xff, 0, 0x64, 0xaf, { 7 } }, + { 3, 0, 0x46, 0xf0, { 2, 0, 0x1b } }, + { 2, 0, 0x4b, 0xb4, { 4, 0, 0x1b } }, + { 2, 0, 0x50, 0x82, { 6, 0, 0x1b } }, + { 1, 0, 0x64, 0x64, { 7, 0, 4 } }, + { 1, 0, 0x78, 0x5a, { 9, 0, 4 } }, + { 2, 0, 0x50, 0xb4, { 2, 0, 0x1b } }, + { 2, 0, 0x5a, 0x96, { 4, 0, 4 } }, + { 2, 0, 0x64, 0x82, { 5, 0, 0x12 } }, + { 2, 0, 0x76, 0x6e, { 6, 0, 0x12 } }, + { 2, 0, 0x82, 0x64, { 7, 0, 0x12 } }, + { 2, 0, 0x3c, 0xd2, { 2, 1, 8 } }, + { 2, 0, 0x46, 0xb4, { 4, 1, 8 } }, + { 2, 0, 0x5a, 0x8c, { 6, 1, 8 } }, + { 2, 0, 0x69, 0x78, { 8, 1, 8 } }, + { 2, 0, 0x75, 0x64, { 9, 1, 8 } }, + { 4, 0, 0x3c, 0x1a4, { 1 } }, + { 4, 0, 0x4e, 0x140, { 4 } }, + { 4, 0, 0x58, 0xc8, { 5 } }, + { 3, 0, 0x62, 0xaa, { 7 } }, + { 2, 0, 0x6d, 0x96, { 8 } }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 2, 0, 0x50, 0x96, { 3, 0, 4 } }, + { 2, 0, 0x64, 0x6e, { 6, 0, 4 } }, + { 2, 0, 0x6e, 0x64, { 8, 0, 4 } }, + { 2, 0, 0x78, 0x5a, { 9, 0, 4 } }, + { 2, 0, 0x82, 0x46, { 9, 2, 4 } }, + { 4, + 0, + 0x46, + 0xbe, + { 1, 0, 0x1d, 1, 2, 0x1d, 1, 1, 0x1b, 0, 0, 0x64, 0, 0x64 } }, + { 4, + 0, + 0x50, + 0x96, + { 3, 0, 0x1d, 3, 2, 0x1d, 2, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, + { 4, + 0, + 0x5a, + 0x82, + { 5, 0, 0x1d, 4, 2, 0x1d, 4, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, + { 4, + 0, + 0x64, + 0x6e, + { 7, 0, 0x1d, 6, 2, 0x1d, 5, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, + { 4, + 0, + 0x82, + 0x64, + { 8, 0, 0x1d, 8, 2, 0x1d, 8, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, + { 2, 0, 0x50, 0xbe, { 1 } }, + { 2, 0, 0x55, 0x8c, { 3 } }, + { 2, 0, 0x5a, 0x82, { 4 } }, + { 2, 0, 0x5f, 0x78, { 6 } }, + { 2, 0, 0x64, 0x64, { 9 } }, + { 2, 0, 0x32, 0x1a4, { 1 } }, + { 2, 0, 0x3c, 0x172, { 3 } }, + { 2, 0, 0x46, 0x118, { 5 } }, + { 2, 0, 0x50, 0xc8, { 6 } }, + { 2, 0, 0x5a, 0x96, { 8 } }, + { 2, 0, 0x46, 0xbe, { 1, 0, 0x1b, 1, 0, 0x1b } }, + { 2, 0, 0x5a, 0x96, { 3, 0, 0x1b, 2, 0, 0x1b } }, + { 2, 0, 0x64, 0x82, { 5, 0, 0x1b, 3, 0, 0x1b } }, + { 2, 0, 0x6e, 0x6e, { 6, 0, 0x1b, 5, 0, 0x1b } }, + { 2, 0, 0x78, 0x5a, { 8, 0, 0x1b, 7, 0, 0x1b } }, + { 3, 0, 0x46, 0x82, { 2, 0, 4 } }, + { 2, 0, 0x5d, 0x73, { 4, 0, 4 } }, + { 2, 0, 0x64, 0x69, { 6, 3, 4 } }, + { 1, 0, 0x6e, 0x58, { 8, 3, 4 } }, + { 0xff, 0, 0x78, 0x4b, { 9, 3, 4 } }, + { 2, 0, 1, 1, { 0, 0, 4 } }, + { 2, 0, 1, 1, { 0, 0, 4 } }, + { 1, 0, 0x87, 0x3a, { 7, 0, 4 } }, + { 1, 0, 0x94, 0x32, { 8, 0, 4 } }, + { 0xff, 0, 0xa0, 0x26, { 9, 0, 4 } }, +}; + +UnkAdventureData* gm_GetAdventureData(void) +{ + return &lbl_80472C30; +} + +u8 gm_8017E430(void) +{ + return gm_GetAdventureData()->x0.slot; +} + +u8 gm_8017E440(void) +{ + UnkAdventureData* r31 = gm_GetAdventureData(); + if (gm_RumbleEnabledForPlayer(r31->x0.slot, r31->x0.x4) == false) { + return 4; + } + return r31->x0.slot; +} + +u8 gm_8017E48C(GameModeState* scene) +{ + u8 count = 0; + int i; + for (i = 0; scene->id != gm_Mode_Adventure_States[i].id; i++) { + if (gm_Mode_Adventure_States[i].info.scene_kind == GS_VS) { + count++; + } + } + return count; +} + +struct gm_803DE650_t* gm_8017E4C4(u8 arg0) +{ + struct gm_803DE650_t* ptr; + for (ptr = gm_803DE650; ptr->x0 != 0xFF; ptr++) { + if (ptr->x0 == arg0) { + return ptr; + } + } + return NULL; +} + +/// Get adventure stage kind for given difficulty and stage slot. +/// The (u8) cast on difficulty is required - these functions are called +/// via function pointers typed as f32(*)(int, u8) in UnkAdventureData. +u8 gm_8017E500(u8 difficulty, u8 stage_slot) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].stage_kind; +} + +f32 gm_8017E528(u8 difficulty, u8 stage_slot) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].scale0_pct / 100.0F; +} + +f32 gm_8017E578(u8 difficulty, u8 stage_slot) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].scale1_pct / 100.0F; +} + +u8 gm_8017E5C8(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[arg2 * 3]; +} + +u8 gm_8017E5FC(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[1 + arg2 * 3]; +} + +u8 gm_8017E630(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 2]; +} + +f32 gm_8017E664(u8 difficulty, u8 stage_slot) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].scale0_pct / 100.0F; +} + +f32 gm_8017E6B4(u8 difficulty, u8 stage_slot) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].scale1_pct / 100.0F; +} + +u8 gm_8017E704(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0x0E + arg2 * 3]; +} + +u8 gm_8017E738(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0xF + arg2 * 3]; +} + +u8 gm_8017E76C(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0x10 + (arg2 * 3)]; +} + +void gm_8017E7A0(u8 matchResult) +{ + if (matchResult == OUTCOME_TIMEOUT) { + Player_LoseStock(0); + ifStatus_802F6948(0); + ifStatus_802F6E3C(0); + } +} + +bool gm_8017E7E0(void) +{ + return gm_GetAdventureData()->x7C == 0x14; +} + +void gm_8017E7FC(u8 matchResult) +{ + UnkAdventureData* r31 = gm_GetAdventureData(); + bool cond; + + if (gm_GetCurrentGameMode() == GM_ADVENTURE && r31->x0.cpu_level >= 2 && + r31->x0.xC.x20 + gm_8016AEDC() < 0xFD20U) + { + cond = true; + } else { + cond = false; + } + + if (!cond) { + struct StartMeleeRules* rules = gm_GetRules(); + rules->x4_5 = 1; + r31->x77 = 0; + gm_SetNextGameModeStateId(0x5A); + } else { + r31->x77 = 1; + gm_SetNextGameModeStateId(0x5A); + } +} + +typedef struct { + u8 b7 : 1, b6 : 1, b5 : 1, b4 : 1, b3 : 1, b2 : 1, b1 : 1, b0 : 1; +} u8_bits; + +#ifdef MUST_MATCH +#pragma push +#pragma dont_inline on +#endif +void fn_8017E8A4(int arg0_int) +{ + MatchEnd* arg0 = (MatchEnd*) arg0_int; + lbl_8046B6A0_t* gm = gm_16AE_GetUnkData_0(); + struct gm_803DE650_t* stage = gm_8017E4C4(gm_GetCurrentSceneIndex()); + UnkAdventureData* adv = &lbl_80472C30; + u8* flags = arg0->_x448; + gmm_x0_528_t* main_data; + u32 total_time; + int i; + + if (fn_8017E318() > 0) { + ((u8_bits*) &flags[2])->b3 = 1; + } + + if (gm->x24C8.x4_5) { + main_data = gmMainLib_8015CDD4(); + total_time = adv->x0.xC.x20 + gm_8016AEDC(); + ((u8_bits*) &flags[0])->b6 = 1; + + if (adv->x0.cpu_level == 4) { + ((u8_bits*) &flags[0])->b3 = 1; + } + + if (total_time < 0xC4E0U) { + ((u8_bits*) &flags[2])->b6 = 1; + } else if (total_time < 0x13560U) { + ((u8_bits*) &flags[2])->b7 = 1; + } + + if ((u32) adv->x0.xC.x1C == 0U && arg0->player_standings[0].x44 == 0U) + { + ((u8_bits*) &flags[1])->b1 = 1; + } + + if (adv->x0.xC.xE != 0) { + ((u8_bits*) &flags[2])->b5 = 1; + } + + if (adv->x0.xC.xF != 0) { + ((u8_bits*) &flags[2])->b4 = 1; + } + + if (adv->x0.xC.xD != 0) { + ((u8_bits*) &flags[1])->b0 = 1; + } else if (arg0->player_standings[0].stocks == (s32) main_data->stocks) + { + ((u8_bits*) &arg0->_x448[1])->b2 = 1; + } + } + + if (stage->x0 == 3) { + for (i = 0; i < 6; i++) { + if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && + Player_GetPlayerCharacter(i) == CKIND_LUIGI) + { + ((u8_bits*) &flags[1])->b7 = 1; + return; + } + } + } + + if (stage->x0 == 0x11) { + if (gm->unk_C >= 5) { + ((u8_bits*) &flags[1])->b6 = 1; + return; + } + } + + if (stage->x0 == 0x25) { + ((u8_bits*) &flags[1])->b5 = 1; + return; + } else if (stage->x0 == 0x53) { + for (i = 0; i < 6; i++) { + if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && + Player_GetPlayerCharacter(i) == CKIND_LUIGI) + { + ((u8_bits*) &flags[1])->b4 = 1; + return; + } + } + } + + if (stage->x0 == 0x5C) { + ((u8_bits*) &flags[1])->b3 = 1; + } + + PAD_STACK(8); +} +#ifdef MUST_MATCH +#pragma pop +#endif diff --git a/src/melee/gm/gm_17E4.h b/src/melee/gm/gm_17E4.h new file mode 100644 index 0000000000..01a1b7d054 --- /dev/null +++ b/src/melee/gm/gm_17E4.h @@ -0,0 +1,30 @@ +#ifndef MELEE_GM_17E4_H +#define MELEE_GM_17E4_H + +#include +#include + +#include + +/* 17E424 */ UnkAdventureData* gm_GetAdventureData(void); +/* 17E430 */ u8 gm_8017E430(void); ///< returns a player slot +/* 17E440 */ u8 gm_8017E440(void); +/* 17E48C */ u8 gm_8017E48C(GameModeState*); +/* 17E4C4 */ struct gm_803DE650_t* gm_8017E4C4(u8); +/* 17E500 */ u8 gm_8017E500(u8, u8); +/* 17E528 */ f32 gm_8017E528(u8, u8); +/* 17E578 */ f32 gm_8017E578(u8, u8); +/* 17E5C8 */ u8 gm_8017E5C8(u8, u8, u8); +/* 17E5FC */ u8 gm_8017E5FC(u8, u8, u8); +/* 17E630 */ u8 gm_8017E630(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17E664 */ f32 gm_8017E664(u8, u8); +/* 17E6B4 */ f32 gm_8017E6B4(u8, u8); +/* 17E704 */ u8 gm_8017E704(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17E738 */ u8 gm_8017E738(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17E76C */ u8 gm_8017E76C(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17E7A0 */ void gm_8017E7A0(u8); +/* 17E7E0 */ bool gm_8017E7E0(void); +/* 17E7FC */ void gm_8017E7FC(u8); +/* 17E8A4 */ void fn_8017E8A4(int); + +#endif diff --git a/src/melee/gm/gm_17EB.c b/src/melee/gm/gm_17EB.c new file mode 100644 index 0000000000..cfc0e37052 --- /dev/null +++ b/src/melee/gm/gm_17EB.c @@ -0,0 +1,233 @@ +#include "gm_17EB.h" + +#include "gm_16AE.h" +#include "gm_17C0.h" +#include "gm_1A3F.h" + +#include +#include +#include +#include + +/// Allstar mode stage data table entry (size 0x1A) +/// Table has 55 entries: 11 stages × 5 difficulty levels +typedef struct AllstarStageEntry { + /* 0x00 */ u8 stage_kind; + /* 0x01 */ u8 pad_1; + /* 0x02 */ u16 scale0_pct; ///< Divided by 100 to get ratio + /* 0x04 */ u16 scale1_pct; ///< Divided by 100 to get ratio + /* 0x06 */ u8 pad_6[0xA]; + /* 0x10 */ u16 scale2_pct; ///< Divided by 100 to get ratio + /* 0x12 */ u16 scale3_pct; ///< Divided by 100 to get ratio + /* 0x14 */ u8 pad_14[0x6]; +} AllstarStageEntry; +ASSERT_SIZE(AllstarStageEntry, 0x1A); + +/// @todo The split gives this object 0x78 bytes, but UnkAllstarData is 0xA0. +static u8 lbl_80472CB0[0x78]; + +AllstarStageEntry lbl_803D85F0[55] = { + { 4, 0, 0x3c, 0xaf, { 0, 0, 9 } }, + { 3, 0, 0x55, 0x78, { 2, 0, 4 } }, + { 3, 0, 0x64, 0x64, { 4, 0, 4 } }, + { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, + { 1, 0, 0x78, 0x5a, { 9, 3, 8 } }, + { 4, 0, 0x46, 0xa0, { 1, 0, 4, 2, 0, 9 }, 0x50, 0x5a, { 8, 1, 4 } }, + { 4, 0, 0x55, 0x78, { 3, 0, 4, 3, 0, 4 }, 0x50, 0x64, { 7, 1, 4 } }, + { 3, 0, 0x64, 0x64, { 5, 0, 4, 4, 0, 4 }, 0x50, 0x73, { 6, 1, 4 } }, + { 3, 0, 0x64, 0x5a, { 6, 0, 4, 6, 0, 8 }, 0x50, 0x82, { 4, 1, 4 } }, + { 1, 0, 0x73, 0x50, { 8, 3, 4, 8, 0, 8 }, 0x50, 0x96, { 3, 1, 4 } }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 4, 0, 0x4b, 0x8c, { 2, 0, 4 } }, + { 4, 0, 0x5a, 0x6e, { 5, 0, 4 } }, + { 4, 0, 0x64, 0x64, { 8, 0, 4 } }, + { 4, 0, 0x73, 0x55, { 9, 0, 4 } }, + { 4, 0, 0x86, 0x46, { 9, 0, 4 } }, + { 3, 0, 0x46, 0x168, { 2, 0, 0x1b }, 0x64, 0x64, { 6, 2, 4, 6, 1, 4 } }, + { 3, 0, 0x50, 0xf0, { 3, 0, 0x1b }, 0x64, 0x5a, { 5, 2, 4, 5, 1, 4 } }, + { 2, 0, 0x5a, 0xb4, { 5, 0, 0x1b }, 0x64, 0x50, { 2, 2, 4, 2, 1, 9 } }, + { 2, 0, 0x64, 0x8c, { 7, 0, 4 }, 0x64, 0x50, { 1, 2, 4, 1, 1, 9 } }, + { 1, 0, 0x78, 0x64, { 8, 0, 4 }, 0x64, 0x50, { 0, 2, 4, 0, 1, 9 } }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 0xff }, + { 2, 0, 0x55, 0x82, { 3, 0, 4 } }, + { 2, 0, 0x64, 0x6e, { 6, 0, 4 } }, + { 2, 0, 0x5a, 0x82, { 5, 0, 4 } }, + { 2, 0, 0x64, 0x6e, { 6, 0, 0x12 } }, + { 1, 0, 0x6e, 0x5a, { 8, 0, 0x12 } }, + { 3, 0, 0x3c, 0x190, { 1, 0, 0x19 } }, + { 3, 0, 0x46, 0x104, { 3, 0, 0x17 } }, + { 2, 0, 0x50, 0xc8, { 4, 0, 0x17 } }, + { 2, 0, 0x5a, 0x9b, { 5, 0, 0x17 } }, + { 1, 0, 0x6e, 0x78, { 7, 0, 0x17 } }, + { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, + { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, + { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, + { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, + { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, + { 2, 0, 0x50, 0xb4, { 1, 0, 0x1b } }, + { 2, 0, 0x5a, 0x82, { 3, 0, 0x1b } }, + { 2, 0, 0x64, 0x64, { 5, 0, 0x1b } }, + { 1, 0, 0x6e, 0x55, { 8, 0, 0x1b } }, + { 0xff, 0, 0x7d, 0x44, { 9, 0, 0x1b } }, + { 2, 0, 0x32, 0x64, { 5, 0, 4 } }, + { 2, 0, 0x4b, 0x64, { 6, 0, 4 } }, + { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, + { 2, 0, 0x96, 0x64, { 8, 0, 4 } }, + { 0xff, 0, 0xc8, 0x64, { 9, 0, 4 } }, +}; + +UnkAllstarData* gm_GetAllStarData(void) +{ + return (UnkAllstarData*) lbl_80472CB0; +} + +u8 gm_8017EB3C(u8 difficulty, u8 stage_slot) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].stage_kind; +} + +u8 gm_8017EB64(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3]; +} + +u8 gm_8017EB98(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 1]; +} + +u8 gm_8017EBCC(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 2]; +} + +f32 gm_8017EC00(u8 difficulty, u8 stage_slot) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].scale2_pct / 100.0F; +} + +f32 gm_8017EC50(u8 difficulty, u8 stage_slot) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].scale3_pct / 100.0F; +} + +u8 gm_8017ECA0(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].pad_14[arg2 * 3]; +} + +u8 gm_8017ECD4(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + (difficulty * 5)].pad_14[arg2 * 3 + 1]; +} + +u8 gm_8017ED08(u8 difficulty, u8 stage_slot, u8 arg2) +{ + return lbl_803D85F0[stage_slot + (difficulty * 5)].pad_14[arg2 * 3 + 2]; +} + +f32 gm_8017ED3C(u8 difficulty, u8 stage_slot) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].scale0_pct / 100.0F; +} + +f32 gm_8017ED8C(u8 difficulty, u8 stage_slot) +{ + return lbl_803D85F0[stage_slot + difficulty * 5].scale1_pct / 100.0F; +} + +typedef struct { + u8 b7 : 1, b6 : 1, b5 : 1, b4 : 1, b3 : 1, b2 : 1, b1 : 1, b0 : 1; +} u8_bits; + +bool fn_8017EDDC(void) +{ + UnkAllstarData* p; + + if (gm_GetCurrentGameMode() == GM_CLASSIC) { + p = gm_GetAllStarData(); + if (p->x0.xC.xD == 0 && p->x0.cpu_level >= 2 && p->x0.xC.x20 < 0x5208) + { + return true; + } + } + return false; +} + +#ifdef MUST_MATCH +#pragma push +#pragma dont_inline on +#endif +void fn_8017EE40(int arg0_int) +{ + MatchEnd* arg0 = (MatchEnd*) arg0_int; + struct StartMeleeRules* rules; + UnkAllstarData* allstar; + gmm_x0_528_t* main_data; + u32 total_time; + int i; + + rules = gm_GetRules(); + allstar = (UnkAllstarData*) lbl_80472CB0; + + if (fn_8017E318() > 0) { + ((u8_bits*) &arg0->_x448[2])->b3 = 1; + } + + if (rules->x4_5) { + main_data = gmMainLib_8015CDC8(); + total_time = allstar->x0.xC.x20 + gm_8016AEDC(); + ((u8_bits*) &arg0->_x448[0])->b7 = 1; + + if (allstar->x0.cpu_level == 4) { + ((u8_bits*) &arg0->_x448[0])->b4 = 1; + } + + if (total_time < 0x3840U) { + ((u8_bits*) &arg0->_x448[2])->b6 = 1; + } else if (total_time < 0x5460U) { + ((u8_bits*) &arg0->_x448[2])->b7 = 1; + } + + if ((u32) allstar->x0.xC.x1C == 0U && + arg0->player_standings[0].x44 == 0U) + { + ((u8_bits*) &arg0->_x448[1])->b1 = 1; + } + + if (allstar->x0.xC.xE != 0) { + ((u8_bits*) &arg0->_x448[2])->b5 = 1; + } + + if (allstar->x0.xC.xF != 0) { + ((u8_bits*) &arg0->_x448[2])->b4 = 1; + } + + if (allstar->x0.xC.xD != 0) { + ((u8_bits*) &arg0->_x448[1])->b0 = 1; + } else if (arg0->player_standings[0].stocks == (s32) main_data->stocks) + { + ((u8_bits*) &arg0->_x448[1])->b2 = 1; + } + } + + for (i = 0; i < 6; i++) { + if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && + Player_GetPlayerCharacter(i) == CKIND_CREZYH) + { + ((u8_bits*) &arg0->_x448[0])->b0 = 1; + return; + } + } +} +#ifdef MUST_MATCH +#pragma pop +#endif diff --git a/src/melee/gm/gm_17EB.h b/src/melee/gm/gm_17EB.h new file mode 100644 index 0000000000..a7d205b514 --- /dev/null +++ b/src/melee/gm/gm_17EB.h @@ -0,0 +1,24 @@ +#ifndef MELEE_GM_17EB_H +#define MELEE_GM_17EB_H + +#include +#include + +#include + +/* 17EB30 */ UnkAllstarData* gm_GetAllStarData(void); +/* 17EB3C */ u8 gm_8017EB3C(u8, u8); +/* 17EB64 */ u8 gm_8017EB64(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17EB98 */ u8 gm_8017EB98(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17EBCC */ u8 gm_8017EBCC(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17EC00 */ f32 gm_8017EC00(u8, u8); +/* 17EC50 */ f32 gm_8017EC50(u8, u8); +/* 17ECA0 */ u8 gm_8017ECA0(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17ECD4 */ u8 gm_8017ECD4(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17ED08 */ u8 gm_8017ED08(u8 difficulty, u8 stage_slot, u8 arg2); +/* 17ED3C */ f32 gm_8017ED3C(u8, u8); +/* 17ED8C */ f32 gm_8017ED8C(u8, u8); +/* 17EDDC */ bool fn_8017EDDC(void); +/* 17EE40 */ void fn_8017EE40(int); + +#endif diff --git a/src/melee/gm/gm_1A9B.c b/src/melee/gm/gm_1A9B.c index cd391955a8..4d342987df 100644 --- a/src/melee/gm/gm_1A9B.c +++ b/src/melee/gm/gm_1A9B.c @@ -16,10 +16,10 @@ #include "gm/forward.h" +#include "gm/gm_17C0.h" #include "gm/gm_1A36.h" #include "gm/gm_1A3F.h" #include "gm/gmevent.h" -#include "gm/gmregclear.h" #include "gm/gmregtyfall.h" #include "lb/lbaudio_ax.h" #include "lb/lbbgflash.h" diff --git a/src/melee/gm/gm_unsplit.h b/src/melee/gm/gm_unsplit.h index 8855ebc5d1..9947dc4ddf 100644 --- a/src/melee/gm/gm_unsplit.h +++ b/src/melee/gm/gm_unsplit.h @@ -17,6 +17,9 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/src/melee/gm/gmregclear.c b/src/melee/gm/gmregclear.c index dda9b83280..0896c563f1 100644 --- a/src/melee/gm/gmregclear.c +++ b/src/melee/gm/gmregclear.c @@ -1,5 +1,8 @@ #include "gmregclear.h" +#include "gm_17C0.h" +#include "gm_17E4.h" +#include "gm_17EB.h" #include "platform.h" #include "baselib/forward.h" @@ -57,1791 +60,148 @@ /// @todo Split-derived data; types are inferred. u8 lbl_804D65B8[0x8]; -typedef struct lbl_804706D8_t { - s16 x0; - u8 x2; - u8 x3; -} lbl_804706D8_t; - -lbl_804706D8_t lbl_804706D8[12]; - -/// @todo Sizes are inferred from the split; contents are runtime-filled. -CSSData gmClassic_80470708; -DebugGameOverData gmClassic_80470850; -MatchExitInfo gmClassic_8047086C; -StartMeleeData gmClassic_80472AF8; - -struct lbl_80472D28_t { - /* +0 */ char pad_0[0x20]; - /* +20 */ HSD_JObj* x20; - /* +24 */ HSD_JObj* x24; - /* +28 */ char pad_28[4]; - /* +2C */ HSD_GObj* x2C; - /* +30 */ HSD_ImageDesc x30; - /* +48 */ HSD_Archive* x48; - /* +4C */ DynamicModelDesc x4C; - /* +5C */ void* x5C; - /* +60 */ void* x60; - /* +64 */ char pad_64[0x20]; - /* +84 */ HSD_Text* x84; - /* +88 */ char pad_88[0x38]; - /* +C0 */ u16 xC0; - /* +C2 */ u16 pad_C2; - /* +C4 */ u32 xC4; - /* +C8 */ u8 xC8; - /* +C9 */ u8 pad_C9[3]; - /* +CC */ s32 xCC; - /* +D0 */ s32 xD0; - /* +D4 */ s32 xD4; - /* +D8 */ s32 xD8; - /* +DC */ s32 xDC; - /* +E0 */ s32 xE0; - /* +E4 */ s32 xE4; - /* +E8 */ s32 xE8; - /* +EC */ s32 xEC; - /* +F0 */ s32 xF0; - /* +F4 */ s32 xF4; - /* +F8 */ s32 xF8; - /* +FC */ s32 xFC; - /* +100 */ s32 x100; - /* +104 */ int x104; - /* +108 */ s16 x108; - /* +10A */ s16 x10A; - /* +10C */ f32 x10C; - /* +110 */ u32 x110; - /* +114 */ u8 x114; - /* +115 */ u8 x115; - /* +116 */ u8 x116; - /* +117 */ u8 x117; - /* +118 */ u8 x118; - /* +119 */ u8 x119; - /* +11A */ u8 x11A; - /* +11B */ u8 x11B; - /* +11C */ u8 x11C; - /* +11D */ u8 x11D; - /* +11E */ u8 x11E; - /* +11F */ u8 x11F; -}; - -struct lbl_80472E48_t { - /* 0x00 */ u8 b76 : 2, b54 : 2, b32 : 2, b10 : 2; - /* 0x01 */ char pad_1[3]; - /* 0x04 */ s32 unk_4; /* inferred */ - /* 0x08 */ s32 unk_8; /* inferred */ - /* 0x0C */ u32 xC; - /* 0x10 */ u8 x10; - /* 0x11 */ char pad_11[3]; - /* 0x14 */ s32 x14[0x1B]; -}; /* size = 0x80 */ -ASSERT_SIZE(struct lbl_80472E48_t, 0x80); - -/// Adventure mode stage data table entry (size 0x1A) -/// Table has 110 entries: 22 stages × 5 difficulty levels -/// Indexed as: difficulty * 5 + stage_slot -typedef struct AdventureStageEntry { - /* 0x00 */ u8 stage_kind; - /* 0x01 */ u8 pad_1; - /* 0x02 */ u16 scale0_pct; ///< Divided by 100 to get ratio - /* 0x04 */ u16 scale1_pct; ///< Divided by 100 to get ratio - /* 0x06 */ u8 pad_6[0x14]; -} AdventureStageEntry; -ASSERT_SIZE(AdventureStageEntry, 0x1A); - -/// Allstar mode stage data table entry (size 0x1A) -/// Table has 55 entries: 11 stages × 5 difficulty levels -typedef struct AllstarStageEntry { - /* 0x00 */ u8 stage_kind; - /* 0x01 */ u8 pad_1; - /* 0x02 */ u16 scale0_pct; ///< Divided by 100 to get ratio - /* 0x04 */ u16 scale1_pct; ///< Divided by 100 to get ratio - /* 0x06 */ u8 pad_6[0xA]; - /* 0x10 */ u16 scale2_pct; ///< Divided by 100 to get ratio - /* 0x12 */ u16 scale3_pct; ///< Divided by 100 to get ratio - /* 0x14 */ u8 pad_14[0x6]; -} AllstarStageEntry; -ASSERT_SIZE(AllstarStageEntry, 0x1A); - -typedef struct RegClearEv { - /* 0x00 */ char pad_0[0x1C]; - /* 0x1C */ HSD_ImageDesc* x1C; - /* 0x20 */ f32 x20; -} RegClearEv; - -static struct lbl_804706C0_t { - int x0; - int x4; - int x8; - int xC; // HP (stamina) - int x10; - int x14; -} lbl_804706C0; - -extern AdventureStageEntry lbl_803D7AC0[110]; -extern AllstarStageEntry lbl_803D85F0[55]; - -u16 lbl_803D8B88[] = { 0x18, 0x16, 0x12, 0x3, 0x5, 0x4, 0x6, 0x1a, 0x19, 0x7 }; - -/// @todo .data order hack -#ifdef MUST_MATCH -static void order_data(void) -{ - (void) "GmRegClr"; - (void) "ScGamRegClear_scene_data"; - (void) "Error : Cannot open archive file (File Name : %s)."; - (void) "SdDec.usd"; - (void) "SIS_DecisionData"; - (void) "SdDec.dat"; - (void) " "; - (void) " "; - (void) "Error : gobj don\'t get (gmRegClearAddModel)\n"; - (void) "gmregclear.c"; - (void) "Error : jobj don\'t get (gmRegClearAddModel)\n"; -} -#endif - -static UnkAdventureData lbl_80472C30; -/// @todo The split gives this object 0x78 bytes, but UnkAllstarData is 0xA0. -static u8 lbl_80472CB0[0x78]; -static struct lbl_80472D28_t lbl_80472D28; -static struct lbl_80472E48_t lbl_80472E48; -static int lbl_80472EC8[4]; -typedef struct RegClearSpawnEntry { - /* 0x00 */ s32 x0; - /* 0x04 */ u8 x4; - /* 0x05 */ u8 x5; - /* 0x06 */ u8 x6; - /* 0x07 */ u8 x7; - /* 0x08 */ f32 x8; - /* 0x0C */ f32 xC; -} RegClearSpawnEntry; - -typedef struct RegClearCharEntry { - /* 0x00 */ u8 x0; - /* 0x01 */ u8 x1; - /* 0x02 */ u8 x2; - /* 0x03 */ u8 x3; - /* 0x04 */ f32 x4; - /* 0x08 */ f32 x8; -} RegClearCharEntry; - -typedef struct RegClearRecordState { - /* 0x00 */ u8 x0; - /* 0x01 */ u8 pad_1; - /* 0x02 */ u16 x2; - /* 0x04 */ int x4; - /* 0x08 */ int x8; - /* 0x0C */ int xC; - /* 0x10 */ s8 x10; - /* 0x11 */ u8 x11; - /* 0x12 */ u8 pad_12[2]; -} RegClearRecordState; -ASSERT_SIZE(RegClearRecordState, 0x14); - -typedef struct RegClearRecordOverlay { - u8 pad_0[0x6BC]; - RegClearRecordState record; -} RegClearRecordOverlay; - -typedef struct lbl_80472ED8_t { - /* 0x000 */ s32 x0; - /* 0x004 */ s32 x4; - /* 0x008 */ s32 x8; - /* 0x00C */ PlayerInitData xC; - /* 0x030 */ u8 pad_30[0x24]; - /* 0x054 */ RegClearSpawnEntry x54[101]; - /* 0x6A4 */ RegClearSpawnEntry* x6A4; - /* 0x6A8 */ RegClearSpawnEntry* x6A8; - /* 0x6AC */ RegClearSpawnEntry* x6AC; - /* 0x6B0 */ RegClearSpawnEntry* x6B0; - /* 0x6B4 */ RegClearSpawnEntry* x6B4; - /* 0x6B8 */ RegClearSpawnEntry* x6B8; - /* 0x6BC */ RegClearRecordState record[0]; -} lbl_80472ED8_t; -ASSERT_SIZE(lbl_80472ED8_t, 0x6BC); - -lbl_80472ED8_t lbl_80472ED8; - -void fn_8017C0C8(void) -{ - PlayerInitData sp8; - gm_8016795C(&sp8); - sp8.slot_type = Gm_PKind_Cpu; - sp8.stocks = 1; - sp8.xE = 4; - sp8.cpu_level = Player_GetCpuLevel(2); - sp8.xE = Player_GetCpuType(2); - sp8.x18 = Player_GetAttackRatio(2); - sp8.x1C = Player_GetUnk50(2); - sp8.color = 0; - sp8.ckind = CKIND_CREZYH; - sp8.team = 4; - sp8.xC_b7 = true; - sp8.hp = lbl_804706C0.xC; - sp8.xD_b2 = true; - sp8.xD_b0 = true; - sp8.xD_b2 = true; - sp8.spawn_dir = 1; - gm_8016EDDC(1, &sp8); -} - -void fn_8017C1A4(HSD_GObj* unused) -{ - struct lbl_804706C0_t* tmp = &lbl_804706C0; - int temp_r29; - int temp_r29_2; - int temp_r28; - int temp_r27; - int temp_r27_2; - int temp_r31; - int temp_r3; - int temp_r3_3; - lbl_8046B6A0_t* temp_r3_2; - lbl_8046B6A0_t* temp_r3_4; - PAD_STACK(8); - - temp_r31 = ftBossLib_8015C74C(); - temp_r29 = ftBossLib_8015C7EC(); - temp_r27 = ftBossLib_8015C88C(); - temp_r3 = ftBossLib_8015C9CC(); - switch (tmp->x0) { - case 0: - if (tmp->x8 == 0) { - temp_r3_2 = gm_16AE_GetUnkData_0(); - temp_r3_2->x24C8.disable_pausing = false; - temp_r3_2->hud_enabled = 0; - lbAudioAx_800237A8(0x81650, 0x7F, 0x40); - ftLib_80086824(); - tmp->x8 = 1; - } else if (ftBossLib_8015C270() == 0) { - tmp->x0 = 2; - } - break; - case 1: - if (tmp->x8 == 0) { - gm_16AE_GetUnkData_0(); - lbAudioAx_800236DC(); - ftBossLib_8015CA6C(0x1D9); - Player_SetMoreFlagsBit4(0, 1); - Player_SetMoreFlagsBit3(0, 1); - tmp->x10 = ft_80087C58(Player_GetEntity(0)); - ft_80087C64(Player_GetEntity(0), 2); - tmp->x14 = ft_80087C58(Player_GetEntity(2)); - ft_80087C64(Player_GetEntity(2), 2); - tmp->x8 = 1; - } else if (tmp->x8 == 1) { - lbAudioAx_800237A8(0x81651, 0x7F, 0x40); - fn_8017C0C8(); - tmp->x8 = 2; - } else if (ftBossLib_8015C2A8() == 0) { - gm_16AE_GetUnkData_0(); - Stage_80225074(0); - ftBossLib_8015CB7C(); - Player_SetMoreFlagsBit4(0, 0); - Player_SetMoreFlagsBit3(0, 0); - ft_80087C64(Player_GetEntity(0), tmp->x10); - ft_80087C64(Player_GetEntity(2), tmp->x14); - ftBossLib_8015CC14(); - tmp->x0 = 4U; - } - break; - case 2: - temp_r3_4 = gm_16AE_GetUnkData_0(); - temp_r3_4->hud_enabled = 1; - Stage_80225074(0); - ftLib_800868A4(); - ftBossLib_8015CC14(); - tmp->x0 = 3; - break; - case 3: - if (Player_GetRemainingHP(2) <= 0) { - tmp->x0 = 7; - tmp->x8 = 0; - } else if (Player_GetRemainingHP(2) <= 0.5F * tmp->xC && fn_8017EDDC()) - { - tmp->x0 = 1; - tmp->x8 = 0; - } - break; - case 4: - if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { - tmp->x0 = 7; - tmp->x8 = 0; - } else if (Player_GetRemainingHP(2) <= 0 || - Player_GetRemainingHP(1) <= 0) - { - tmp->x0 = 6; - tmp->x8 = 0; - } - break; - case 5: - if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { - tmp->x0 = 7; - tmp->x8 = 0; - } - break; - case 6: - if (Player_GetRemainingHP(2) <= 0) { - tmp->x4 = 2; - } else { - tmp->x4 = 1; - } - temp_r27_2 = temp_r31 + temp_r29; - if (tmp->x8 == 0) { - ftBossLib_8015CB9C(tmp->x4); - gm_801A4634(6); - } else if (tmp->x8 == temp_r31) { - lbAudioAx_8002438C(0x4E200); - ftBossLib_8015CC14(); - gm_801A4674(6); - gm_SetGameSpeed(0.5f); - } else if (tmp->x8 >= temp_r27_2) { - gm_SetGameSpeed(1.0f); - tmp->x0 = 5; - } - if (Player_GetRemainingHP(2) <= 0 && Player_GetRemainingHP(1) <= 0) { - tmp->x0 = 7; - tmp->x8 = 0; - } else if (tmp->x8 <= temp_r27_2) { - tmp->x8++; - } - break; - case 7: - temp_r28 = temp_r31 + temp_r27; - temp_r29_2 = temp_r3 + temp_r28; - if (tmp->x8 == 0) { - temp_r3_4 = gm_16AE_GetUnkData_0(); - temp_r3_4->hud_enabled = 0; - if (tmp->x4 == 2) { - tmp->x4 = 1; - } else { - tmp->x4 = 2; - } - ftBossLib_8015CB9C(tmp->x4); - gm_801A4634(6); - Player_80031790(0); - Player_80036844(0, 1); - temp_r3_4 = gm_16AE_GetUnkData_0(); - temp_r3_4->x24C8.x0_6 = false; - } else if (tmp->x8 == temp_r31) { - lbAudioAx_8002438C(0x4E200); - ftBossLib_8015CC14(); - gm_801A4674(6); - gm_SetGameSpeed(0.5f); - lbBgFlash_80020688(temp_r27); - } else if (tmp->x8 == temp_r28) { - lbBgFlash_800205F0(temp_r3); - } else if (tmp->x8 >= temp_r29_2) { - lbAudioAx_80028B90(); - gm_SetGameSpeed(1.0f); - gm_8016B33C(8); - gm_8016B328(); - break; - } - if (tmp->x8 >= temp_r31) { - lbAudioAx_80028B6C(); - } - if (tmp->x8 <= temp_r28 && tmp->x8 % 30 == 0) { - gm_80167858(Player_GetPlayerId(0), Player_GetNametagSlotID(0), 2, - 0x1E); - Camera_80030E44(3, NULL); - } - if (tmp->x8 <= temp_r29_2) { - tmp->x8++; - } - break; - } -} - -void fn_8017C71C(void) -{ - struct lbl_804706C0_t* tmp = &lbl_804706C0; - HSD_GObj_SetupProc(GObj_Create(0xF, 0x11, 0), fn_8017C1A4, 0x15); - tmp->x0 = 0; - tmp->x4 = 1; - tmp->x8 = 0; - tmp->xC = ftBossLib_8015C530(gm_8017E068()); - Player_SetOtherStamina(2, tmp->xC); - ftLib_80087508(FTKIND_CREZYH, 0); -} - -void fn_8017C7A0(void) -{ - lbBgFlash_8002063C(0x30); - if (Ground_801C1DAC()) { - gm_8016B350(0x7C85E); - return; - } - gm_8016B350(0x9C48); -} - -void fn_8017C7EC(void) -{ - lbl_8046B6A0_t* temp_r31; - Unk1PData* temp_r30; - - temp_r30 = fn_8017DF28(); - temp_r31 = gm_16AE_GetUnkData_1(); - temp_r31->timer_seconds = grPushOn_80219230(temp_r30->ckind); -} - -void gm_8017C838(void) -{ - s8 sp10[3]; - - lbl_8046B6A0_t* temp_r3; - int i; - s8 var_r3; - s8* var_r31; - UnkAdventureData* temp_r30; - - PAD_STACK(8); - - temp_r30 = gm_GetAdventureData(); - temp_r3 = gm_16AE_GetUnkData_0(); - var_r31 = sp10; - sp10[0] = FTKIND_NONE; - sp10[1] = FTKIND_NONE; - sp10[2] = FTKIND_NONE; - switch (temp_r3->x24C8.stkind) { - case 0x3B: - sp10[0] = FTKIND_YOSHI; - break; - case 0x3F: - sp10[0] = FTKIND_LINK; - break; - case 0x44: - sp10[0] = FTKIND_KIRBY; - if (temp_r30->x0.ckind == CKIND_KIRBY && temp_r30->x0.color == 0) { - var_r3 = 1; - } else { - var_r3 = 0; - } - ftLib_80087610(var_r3); - break; - case 0x48: - sp10[0] = 0xC; - if (gm_IsCKindUnlocked(CKIND_PICHU) != 0) { - sp10[1] = FTKIND_PICHU; - } - if (gm_IsCKindUnlocked(CKIND_PURIN) != 0) { - sp10[2] = FTKIND_PURIN; - } - break; - case 0x4C: - sp10[0] = FTKIND_POPO; - sp10[1] = FTKIND_NANA; - break; - case 0x4E: - sp10[0] = FTKIND_BOY; - sp10[1] = FTKIND_GIRL; - break; - } - - for (i = 0; i < 3; i++) { - if (*var_r31 != FTKIND_MAX) { - ftLib_80087574(*var_r31); - } - var_r31++; - } - Camera_80030E34(0.2f); -} - -void gm_8017C984(UNK_T arg0) -{ - memzero(arg0, 0x74); -} - -static const u8 lbl_803B7C08[3][5] = { - { 1, 2, 3, 5, 10 }, - { 1, 2, 3, 5, 10 }, - { 10, 10, 10, 10, 10 }, -}; - -void gm_8017C9A8(DebugGameOverData* arg0, Unk1PData* arg1, u8 arg2) -{ - PAD_STACK(8); - arg0->x0 = arg1->xC.x18; - arg0->x8 = arg2; - arg0->ckind = arg1->ckind; - arg0->slot = arg1->slot; - arg0->x15 = arg1->x4; - arg0->x18 = gm_801623D8(); - arg0->x16 = lbl_803B7C08[arg2][arg1->cpu_level]; -} - -void gm_8017CA38(DebugGameOverData* arg0, Unk1PData* arg1, gmm_x0_528_t* arg2, - u8 arg3) -{ - u8 temp_r31; - - arg1->xC.x14 = arg0->x18; - gm_801623FC(arg1->xC.x14); - if (arg0->xC == 0) { - temp_r31 = gm_80173224(arg3, 0); - switch (gm_GetCurrentGameMode()) { - case GM_CLASSIC: - fn_80162BFC(arg1->ckind, arg0->x4); - break; - case GM_ADVENTURE: - fn_80162DF8(arg1->ckind, arg0->x4); - break; - case GM_ALLSTAR: - fn_80162FF4(arg1->ckind, arg0->x4); - break; - } - Ground_801C5A60(); - gm_8017390C(fn_8017DF90(), 0); - gm_80173EEC(); - gm_80172898(0x40); - if (temp_r31 == CHKIND_NONE) { - if (gm_80173754(1, arg1->slot) == 0) { - gm_ChangeGameModeAfterCurrentScene(GM_MENU); - } - } else { - gm_801736E8(arg1->ckind, arg1->color, arg1->slot, arg1->x4, - temp_r31, 1U); - gm_ChangeGameModeAfterCurrentScene(GM_CHALLENGER_APPROACH); - } - } else { - arg1->xC.x18 = lbTime_8000AEC8((u32) arg0->x4, 1U); - arg1->stocks = arg2->stocks; - arg1->xC.xD = lbTime_8000AF74((u32) arg1->xC.xD, 1); - gm_SetNextGameModeStateId(arg1->x7); - } -} - -void gm_8017CBAC(UnkAdventureData* arg0, gmm_x0_528_t* arg1, u8 arg2) -{ - s32 temp_r3_2; - u8 temp_r31; - u8* temp_r3; - - temp_r31 = gm_CKindToSelKind(arg0->x0.ckind); - Ground_801C5A60(); - switch (arg2) { - case 21: - gmMainLib_8015D134(temp_r31); - fn_80162BFC(arg0->x0.ckind, arg0->x0.xC.x18); - temp_r3 = gmMainLib_8015D194(temp_r31); - if (*temp_r3 < arg0->x0.cpu_level) { - *temp_r3 = arg0->x0.cpu_level; - } - temp_r3_2 = gmMainLib_8015D1AC(temp_r31); - if ((arg0->x0.cpu_level == 4) && - ((temp_r3_2 == 0) || (arg1->stocks < temp_r3_2))) - { - gmMainLib_8015D1C8(temp_r31, arg1->stocks); - } - break; - case 22: - gmMainLib_8015D25C(temp_r31); - fn_80162DF8(arg0->x0.ckind, arg0->x0.xC.x18); - temp_r3 = gmMainLib_8015D2BC(temp_r31); - if (*temp_r3 < arg0->x0.cpu_level) { - *temp_r3 = arg0->x0.cpu_level; - } - temp_r3_2 = gmMainLib_8015D2D4(temp_r31); - if ((arg0->x0.cpu_level == 4) && - ((temp_r3_2 == 0) || (arg1->stocks < temp_r3_2))) - { - gmMainLib_8015D2F0(temp_r31, arg1->stocks); - } - break; - case 23: - gmMainLib_8015D384(temp_r31); - fn_80162FF4(arg0->x0.ckind, arg0->x0.xC.x18); - if (!gm_80164430(0x1F)) { - gm_80164504(0x1F); - } - temp_r3 = gmMainLib_8015D3E4(temp_r31); - if (*temp_r3 < arg0->x0.cpu_level) { - *temp_r3 = arg0->x0.cpu_level; - } - temp_r3_2 = gmMainLib_8015D3FC(temp_r31); - if ((arg0->x0.cpu_level == 4) && - (temp_r3_2 == 0 || arg1->stocks < temp_r3_2)) - { - gmMainLib_8015D418(temp_r31, arg1->stocks); - } - break; - } - lb_8001C550(); - lb_8001D164(0); - lb_8001CE00(); - gm_SetPendingGameMode(arg2); - gm_SetNewGameModePending(); -} - -u8 gm_8017CD94(UnkAdventureData* arg0, int arg1, int arg2, int arg3) -{ - u8 num_colors; - u8 result; - - num_colors = gm_80169238(arg1); - if (arg0->x54 != NULL) { - result = arg0->x54(arg2, arg0->x0.cpu_level, arg3); - if (num_colors != 0) { - return result % num_colors; - } - return 0; - } - return 0; -} - -static inline s32 gm_8017CE34_CountEnemies(const s8* arg0) -{ - s32 count = 0; - s32 i; - - for (i = 0; i < 3; i++) { - if ((s32) arg0[i] != CHKIND_NONE) { - count++; - } - } - return count; -} - -static inline void gm_8017CE34_SetupColors(UnkAdventureData* arg1, s32 count, - s8* arg2, u8* colors) -{ - u8* out_color = colors; - s32 color_idx; - s8* kind_iter = arg2; - - for (color_idx = 0; color_idx < 3; color_idx++) { - *out_color = gm_8017CD94(arg1, (u8) *kind_iter, count, color_idx); - out_color++; - kind_iter++; - } -} - -static inline u8 gm_8017CE34_ResolvePlayerCKind(UnkAdventureData* arg1, - u8 player_ckind) -{ - if (((s32) player_ckind == CKIND_ZELDA) && (arg1->x0.xC.x12 != 0)) { - player_ckind = CKIND_SEAK; - } else if (((arg1->x0.x8 & 0x80) != 0) && (arg1->x0.x9 == 1) && - ((s8) player_ckind == CKIND_POPONANA)) - { - player_ckind = CHKIND_POPO; - } - return player_ckind; -} - -static inline u8 gm_8017CE34_GetCpuLevel(UnkAdventureData* arg1) -{ - return arg1->x0.cpu_level; -} - -void gm_8017CE34(StartMeleeData* arg0, UnkAdventureData* arg1, s8* arg2, - u8 arg3, u8 arg4, u8 arg5, s32 arg6, StKind arg7, s32 count, - s32 arg9) -{ - u8 colors[16]; - u8 enemy_level; - s32 boss_count; - u8 enemy_cpu_type; - s32 player_idx; - f32 attack_ratio; - u8 player_stocks; - u8 player_ckind; - u8 flags; - s8* enemy_kind; - f32 defense_ratio; - u8 enemy_ckind; - s32 enemy_count; - s32 enemy_idx; - u8* color_iter; - - boss_count = 0; - enemy_level = 0; - enemy_cpu_type = 0; - arg1->x0.xC.xC = 1; - fn_8017E21C(); - fn_8016F030(arg0); - arg0->rules.x30 = 1.0f; - arg0->rules.x4_4 = 1; - - switch (arg9) { - case 0: - arg0->rules.xA = 0; - break; - case 1: - arg0->rules.xA = 3; - break; - case 2: - arg0->rules.xA = 2; - break; - } - - arg0->rules.x1_1 = 1; - arg0->rules.x4_2 = 1; - arg0->rules.x4_3 = 1; - arg0->rules.x2_5 = 0; - arg0->rules.x0_3 = arg1->x0.xB; - - if (arg6 != 0) { - arg0->rules.time_limit = (u32) arg6; - arg0->rules.x0_6 = 1; - } else { - arg0->rules.x0_6 = 0; - } - - arg0->rules.x18 = (u32) arg1->x0.xC.x18; - arg0->rules.stkind = (u16) arg7; - arg0->rules.xB = arg1->x48((u8) count, arg1->x0.cpu_level); - - arg0->rules.x20 = (u64) -1; - - enemy_count = gm_8017CE34_CountEnemies(arg2); - if (enemy_count == 0) { - arg0->rules.x5_1 = 1; - } - if (arg1->x0.x8 & 1) { - arg0->rules.x2_7 = 1; - } - if (arg1->x0.x8 & 0x20) { - arg0->rules.x4_5 = 1; - } - if (arg1->x0.x8 & 0x80) { - arg1->x0.xC.xC = 5; - switch ((s32) arg1->x0.x9) { - case 1: - arg0->rules.on_pause_override = gm_80165290; - arg0->rules.x9 = 1; - arg0->rules.x3_1 = 0; - arg0->players[0].xC_b1 = 0; - break; - case 2: - arg0->rules.x9 = 3; - arg0->rules.x44 = fn_8017C7EC; - break; - case 3: - arg0->rules.x9 = 2; - arg0->rules.x7 = 9; - arg0->rules.x4_4 = 0; - arg0->rules.x50 = (void (*)(u8)) fn_8017C7A0; - arg0->rules.xD = 0x30; - break; - } - } - - if ((arg1->x0.x8 & 0x80) != 0) { - player_stocks = 1; - } else { - player_stocks = arg1->x0.stocks; - } - - player_ckind = (u8) arg1->x0.ckind; - player_ckind = gm_8017CE34_ResolvePlayerCKind(arg1, player_ckind); - - gm_801B0620(arg0->players, player_ckind, arg1->x0.color, player_stocks, - arg1->x0.slot); - arg0->players[0].nametag = arg1->x0.x4; - arg0->players[0].spawn_dir = (s8) arg1->x0.xA; - - { - u8 team_color; - if (arg1->x58 != NULL) { - team_color = - arg1->x58((u8) count, gm_8017CE34_GetCpuLevel(arg1), 0); - } else { - team_color = 0; - } - - { - player_idx = - fn_8017DD7C(arg0->players, arg1->x0.xC.x24, team_color) + 1; - arg0->rules.is_teams = 1; - } - } - - attack_ratio = arg1->x64((u8) count, arg1->x0.cpu_level); - defense_ratio = arg1->x68((u8) count, arg1->x0.cpu_level); - - color_iter = colors; - gm_8017CE34_SetupColors(arg1, count, arg2, color_iter); - - { - s32 temp_r3_4 = arg1->x0.x8 & 8; - if ((temp_r3_4 != 0) && (arg1->x0.xC.x11 == 0)) { - s32 event_enemy_count; - s32 special_stage; - s32 special_enemy_mode; - u8 sp8; - u8 first_enemy; - u32 stage_flags; - - event_enemy_count = gm_8017CE34_CountEnemies(arg2); - arg1->x0.xC.xC = 3; - special_stage = 0; - special_enemy_mode = 0; - sp8 = 0; - if (arg1->x4C != NULL) { - enemy_level = arg1->x4C((u8) count, arg1->x0.cpu_level, 0U); - } - - first_enemy = (u8) arg2[0]; - if ((s8) first_enemy != 4) { - if ((u8) (first_enemy - 0x1B) <= 1U) { - arg0->rules.x0_3 = 6; - event_enemy_count = 5; - colors[0] = 0; - special_stage = 1; - special_enemy_mode = 1; - } else if (((s8) first_enemy == 0xD) && - (((s32) arg2[1] != 0xD) || ((s32) arg2[2] != 0xD))) - { - special_enemy_mode = 2; - } - } - - stage_flags = Ground_801C5AD0(Stage_8022519C(arg7)); - - gm_8016A22C((s8) (u8) arg2[0], arg2[1], arg2[2], colors[0], - colors[1], (s32) colors[2], special_stage, - special_enemy_mode, sp8, (u8) arg1->x0.ckind, - arg1->x0.color, (s32) enemy_level, (s32) arg3, - event_enemy_count, (s32) stage_flags, (s32) arg5, - (s32) arg4, attack_ratio, defense_ratio); - gm_8016A21C(&arg0->rules); - arg1->x0.xC.x11 = 0; - if (arg1->x0.x8 & 4) { - fn_8016A450(); - } - if ((u8) special_enemy_mode == 1) { - fn_8016A46C(); - arg0->players[0].xC_b5 = 1; - } - } else if (temp_r3_4 != 0) { - gm_8016A21C(&arg0->rules); - arg1->x0.xC.x11 = 0; - } - } - - gmRegSetupEnemyColorTable((s8) (u8) arg1->x0.ckind, arg1->x0.color, arg2, - colors); - - enemy_idx = 0; - for (;;) { - enemy_kind = &arg2[enemy_idx]; - if ((s32) (u8) enemy_kind[0] != 0x21) { - if (arg1->x0.x8 & 8) { - if (arg1->x4C != NULL) { - enemy_level = - arg1->x4C((u8) count, arg1->x0.cpu_level, 0U); - } - if (arg1->x50 != NULL) { - enemy_cpu_type = - arg1->x50((u8) count, arg1->x0.cpu_level, 0U); - } - } else { - if (arg1->x4C != NULL) { - u8 selected_enemy_level = - arg1->x4C((u8) count, arg1->x0.cpu_level, enemy_idx); - enemy_level = selected_enemy_level; - } - if (arg1->x50 != NULL) { - enemy_cpu_type = - arg1->x50((u8) count, arg1->x0.cpu_level, enemy_idx); - } - } - gm_8016795C(&arg0->players[player_idx]); - arg0->players[player_idx].slot_type = 1; - arg0->players[player_idx].ckind = (s8) (u8) enemy_kind[0]; - arg0->players[player_idx].stocks = 1; - arg0->players[player_idx].cpu_level = enemy_level; - arg0->players[player_idx].xE = enemy_cpu_type; - arg0->players[player_idx].x18 = attack_ratio; - arg0->players[player_idx].x1C = defense_ratio; - arg0->players[player_idx].color = *color_iter; - if (arg1->x0.x8 & 2) { - arg0->players[player_idx].x20 = 2.0f; - arg0->players[player_idx].xB = 2; - } else { - arg0->players[player_idx].x20 = 1.0f; - arg0->players[player_idx].xB = 0; - } - if (arg1->x0.x8 & 4) { - arg0->players[player_idx].xC_b2 = 1; - arg0->players[player_idx].xE = 0x1B; - } - if ((s32) arg0->players[player_idx].ckind == CKIND_GKOOPS) { - arg0->players[player_idx].xC_b1 = 0; - } - enemy_ckind = (u8) arg0->players[player_idx].ckind; - if (((s8) enemy_ckind == CKIND_MASTERH) || - ((s8) enemy_ckind == CKIND_CREZYH)) - { - arg0->players[player_idx].xC_b7 = 1; - arg0->players[player_idx].hp = 0x12C; - arg0->players[player_idx].xD_b2 = 1; - arg0->players[player_idx].xD_b0 = 1; - arg0->players[player_idx].xD_b2 = 1; - arg0->players[player_idx].spawn_dir = -1; - if ((s32) arg0->players[player_idx].ckind == CKIND_CREZYH) { - arg0->players[player_idx].slot_type = 3; - } - boss_count += 1; - } - if (arg0->rules.is_teams == 1) { - arg0->players[player_idx].team = 4; - } - player_idx += 1; - if (player_idx >= 6) { - break; - } - } else { - if ((enemy_idx == 0) && ((s32) enemy_kind[1] == 0x1A)) { - arg0->players[player_idx].slot_type = 3; - player_idx += 1; - } - } - enemy_idx += 1; - color_iter += 1; - if (enemy_idx >= 3) { - break; - } - } - - { - s32 i; - for (i = player_idx; i < 6; i++) { - arg0->players[i].slot_type = 3; - } - } - - flags = arg1->x0.x8; - if (flags & 0x40) { - arg1->x0.xC.xC = 7; - } else if (flags & 1) { - if ((flags & 8) && (arg3 > 1U)) { - arg1->x0.xC.xC = 4; - } else { - arg1->x0.xC.xC = 2; - } - } - if (boss_count != 0) { - arg0->rules.x1_2 = 1; - arg0->rules.x1_3 = 1; - arg0->rules.x1_4 = 1; - arg0->rules.x0_3 = 3; - arg0->rules.disable_pausing = 1; - arg0->rules.x7 = 0; - arg0->rules.x44 = (void (*)(void)) fn_8017C71C; - arg1->x0.xC.xC = 6; - } - if (arg7 == 0x49) { - arg1->x0.xC.xC = 8; - } -} - -bool gm_8017D7AC(MatchExitInfo* arg0, Unk1PData* arg1, u8 arg2) -{ - u8 temp_r0; - - arg1->xC.x14 = - lbTime_8000AEC8(arg1->xC.x14, arg0->match_end.player_standings[0].xE); - gm_8016247C(arg0->match_end.player_standings[0].xE); - arg1->xC.x1C = - lbTime_8000AEC8(arg1->xC.x1C, arg0->match_end.player_standings[0].x44); - gm_80162968(arg0->match_end.frame_count / 60); - if (!(arg1->x8 & 0x80)) { - arg1->xC.x20 = - lbTime_8000AEC8(arg1->xC.x20, arg0->match_end.frame_count); - } - if (arg0->match_end.player_standings[0].ftkind == 7) { - arg1->xC.x12 = 1; - } else { - arg1->xC.x12 = 0; - } - if (fn_8016B510() != 0) { - arg1->xC.xF = 1; - } - if (fn_8016B4BC() != 0) { - arg1->xC.xE = 1; - } - temp_r0 = arg0->match_end.result; - if ((temp_r0 == OUTCOME_NO_CONTEST || temp_r0 == OUTCOME_RETRY) && - DbLevel <= DbLKind_DebugDevelop) - { - switch (gm_GetCurrentGameMode()) { - case GM_CLASSIC: - fn_80162BFC(arg1->ckind, arg1->xC.x18); - break; - case GM_ADVENTURE: - fn_80162DF8(arg1->ckind, arg1->xC.x18); - break; - case GM_ALLSTAR: - fn_80162FF4(arg1->ckind, arg1->xC.x18); - break; - } - gm_ChangeGameModeAfterCurrentScene(GM_MENU); - return 0; - } - fn_8017E3C8(); - if (!(arg1->x8 & 0x80)) { - arg1->stocks = arg0->match_end.player_standings[0].stocks; - if (arg1->stocks != 0) { - if (arg0->match_end.result == OUTCOME_TIMEOUT) { - arg1->stocks--; - if (arg1->stocks == 0) { - gm_SetNextGameModeStateId(arg2); - return 0; - } - if (!(arg1->x8 & 0x40)) { - arg1->xC.x10++; - gm_SetNextGameModeStateId(gm_GetCurrentSceneIndex()); - return 0; - } - } - } else { - arg1->xC.x10 = 0; - gm_SetNextGameModeStateId(arg2); - return 0; - } - } - arg1->xC.x18 = arg0->x0; - arg1->xC.x10 = 0; - return 1; -} - -#ifdef MUST_MATCH -#pragma opt_propagation off -#endif -static inline s32 pick_random_ckind(u8* arr, const u8* used_ckinds, - const u8* preset_ckinds) -{ - struct { - s32 count; - u8* cursor; - } scan; - u8 temp; - s32 j; - s32 i; - s32 swap_idx; - u8 ckind; - s32 used_idx; - s32 preset_idx; - u8* base; - u8* w; - u8* w2; - - base = arr; - scan.cursor = base; - scan.count = 0; - while ((s32) *scan.cursor != CHKIND_NONE) { - scan.cursor++; - scan.count++; - } - - w = base; - for (j = 0; j < scan.count; j++) { - temp = *w; - swap_idx = HSD_Randi(scan.count); - *w++ = base[swap_idx]; - base[swap_idx] = temp; - } - - w2 = base; - for (i = 0; i < scan.count; i++) { - if (gm_IsCKindUnlocked(*w2) != 0) { - ckind = *w2; - for (used_idx = 0; used_idx < 4; used_idx++) { - if ((s8) ckind == (s8) used_ckinds[used_idx]) { - used_idx = -1; - break; - } - } - if (used_idx != -1) { - for (preset_idx = 0; preset_idx < 3; preset_idx++) { - if ((s8) ckind == (s8) preset_ckinds[preset_idx]) { - preset_idx = -1; - break; - } - } - if (preset_idx != -1) { - return base[i]; - } - } - } - w2++; - } - - return CHKIND_NONE; -} - -s32 fn_8017D9C0(const u8* used_ckinds, const u8* preset_ckinds) -{ - return pick_random_ckind(lbl_803D79F0, used_ckinds, preset_ckinds); -} -#ifdef MUST_MATCH -#pragma opt_propagation reset -#pragma dont_inline on -#endif - -void gm_8017DB58(struct Unk1PData_x24* arg0) -{ - int i; - for (i = 0; i < 3; i++) { - arg0[i].ckind = CHKIND_NONE; - } -} - -u8 gm_8017DB6C(gm_8017DB6C_arg0_t* arg0, int index) -{ - return arg0[index].x0; -} - -u8 gm_8017DB78(gm_8017DB6C_arg0_t* arg0, int index) -{ - return arg0[index].x1; -} - -s32 gm_8017DB88(void* arg0, u8 arg1, s32 arg2, s32 arg3, u8* arg4, u8 arg5, - u8 (*arg6)(s32, s32, u8), u8 (*arg7)(s32, s32, u8), - u8 (*arg8)(s32, s32, u8), f32 (*arg9)(s32, s32), - f32 (*arg10)(s32, s32)) -{ - u8 chars[4]; - s32 val; - f32 fval; - - { - u8* p; - RegClearCharEntry* out; - s32 i; - s32 count; - - count = fn_8017DE54(arg1, arg4); - chars[1] = 0x21; - out = arg0; - chars[2] = 0x21; - p = chars; - i = 0; - chars[3] = 0x21; - chars[0] = arg5; - for (; i < count; i++) { - p[1] = fn_8017D9C0(chars, arg4); - out->x0 = p[1]; - if (arg8 != NULL) { - val = arg8(arg3, arg2, (u8) i); - } else { - val = 0; - } - out->x1 = val; - if (arg6 != NULL) { - val = arg6(arg3, arg2, (u8) i); - } else { - val = 0; - } - out->x2 = val; - if (arg7 != NULL) { - val = arg7(arg3, arg2, (u8) i); - } else { - val = 0; - } - out->x3 = val; - if (arg9 != NULL) { - fval = arg9(arg3, arg2); - } else { - fval = 0.0f; - } - out->x4 = fval; - if (arg10 != NULL) { - fval = arg10(arg3, arg2); - } else { - fval = 0.0f; - } - out->x8 = fval; - p++; - out++; - } - for (; i < 3; i++) { - ((RegClearCharEntry*) arg0)[i].x0 = 0x21; - } - return count; - } -} -#ifdef MUST_MATCH -#pragma dont_inline off -#endif - -s32 fn_8017DD7C(PlayerInitData* arg0, Unk1PData_x24* arg1, u8 arg2) -{ - s32 index = 1; - int i; - for (i = 0; i < 3; i++) { - if (arg1[i].ckind != CHKIND_NONE) { - gm_8016795C(&arg0[index]); - arg0[index].ckind = arg1[i].ckind; - arg0[index].slot_type = 1; - arg0[index].stocks = 1; - arg0[index].team = arg0->team; - arg0[index].color = arg1[i].x1; - arg0[index].xE = arg1[i].x3; - arg0[index].cpu_level = arg1[i].x2; - arg0[index].x18 = arg1[i].x4; - arg0[index].x1C = arg1[i].x8; - arg0[index].xD_b1 = 1; - if (arg0[index].ckind == CKIND_GKOOPS) { - arg0[index].xC_b1 = 0; - } - index++; - } - } - return index - 1; -} - -s32 fn_8017DE54(u8 arg0, u8* arg1) -{ - u8* p; - s32 count; - - if (arg0 & 0x20) { - return 0; - } - if (arg0 & 0x10) { - count = 0; - if ((s32) arg1[0] != 0x21) { - count = 1; - } - p = &arg1[1]; - if ((s32) *p != 0x21) { - count += 1; - } - if ((s32) p[1] != 0x21) { - count += 1; - } - return 3 - count; - } - if (arg0 & 2) { - return 2; - } - return 0; -} - -Unk1PData* fn_8017DEC8(int arg0) -{ - switch (arg0) { - case 0: - return &gm_GetAdventureData()->x0; - case 1: - return &gm_GetAllStarData()->x0; - case 2: - return &gm_80473A18.x0; - default: - return NULL; - } -} - -Unk1PData* fn_8017DF28(void) -{ - switch (gm_GetCurrentGameMode()) { - case GM_CLASSIC: - return &gm_GetAllStarData()->x0; - case GM_ADVENTURE: - return &gm_GetAdventureData()->x0; - case GM_ALLSTAR: - return &gm_80473A18.x0; - default: - return NULL; - } -} - -u8 fn_8017DF90(void) -{ - switch (gm_GetCurrentGameMode()) { - case GM_CLASSIC: - return 1; - case GM_ADVENTURE: - return 0; - case GM_ALLSTAR: - return 2; - default: - return 3; - } -} - -int gm_8017DFF4(int arg0) -{ - Unk1PData* var_r3 = fn_8017DEC8(arg0); - if (var_r3 != NULL) { - return var_r3->cpu_level; - } - return -1; -} - -int gm_8017E068(void) -{ - Unk1PData* var_r3 = fn_8017DF28(); - if (var_r3 != NULL) { - return var_r3->cpu_level; - } - return -1; -} - -int fn_8017E0E4(void) -{ - Unk1PData* var_r3 = fn_8017DF28(); - if (var_r3 != NULL) { - return var_r3->xC.xC; - } - return -1; -} - -bool fn_8017E160(void) -{ - Unk1PData* var_r3 = fn_8017DF28(); - struct Unk1PData_xC* temp_r3_2; - - if (var_r3 != NULL) { - int i; - for (i = 0; i < 3; i++) { - if (var_r3->xC.x24[i].ckind != CHKIND_NONE) { - return true; - } - } - return false; - } - return false; -} - -void fn_8017E21C(void) -{ - int i; - for (i = 0; i < 12; i++) { - lbl_804706D8[i].x0 = -1; - } -} - -s8 gm_8017E280(u16 arg0, u32 arg1) -{ - lbl_804706D8_t* var_r7 = lbl_804706D8; - s32 index; - index = 0; - for (index = 0; index < 12; index++) { - if (arg0 == var_r7[index].x0) { - var_r7[index].x2 += arg1; - return var_r7[index].x2; - } - } - index = 0; - for (index = 0; index < 12; index++) { - if (var_r7[index].x0 == -1) { - var_r7[index].x0 = arg0; - var_r7[index].x2 = arg1; - return (u8) arg1; - } - } - return -1; -} - -int fn_8017E318(void) -{ - int i; - int sum = 0; - for (i = 0; i < 12; i++) { - if (lbl_804706D8[i].x0 != -1) { - sum += lbl_804706D8[i].x2; - } - } - return sum; -} - -void fn_8017E3C8(void) -{ - int i = 0; - PAD_STACK(8); - for (i = 0; i < 12; i++) { - if (lbl_804706D8[i].x0 != -1) { - Toy_SetUnlockState(lbl_804706D8[i].x0, lbl_804706D8[i].x2); - } - } -} - -UnkAdventureData* gm_GetAdventureData(void) -{ - return &lbl_80472C30; -} - -u8 gm_8017E430(void) -{ - return gm_GetAdventureData()->x0.slot; -} - -u8 gm_8017E440(void) -{ - UnkAdventureData* r31 = gm_GetAdventureData(); - if (gm_RumbleEnabledForPlayer(r31->x0.slot, r31->x0.x4) == false) { - return 4; - } - return r31->x0.slot; -} - -u8 gm_8017E48C(GameModeState* scene) -{ - u8 count = 0; - int i; - for (i = 0; scene->id != gm_Mode_Adventure_States[i].id; i++) { - if (gm_Mode_Adventure_States[i].info.scene_kind == GS_VS) { - count++; - } - } - return count; -} - -struct gm_803DE650_t* gm_8017E4C4(u8 arg0) -{ - struct gm_803DE650_t* ptr; - for (ptr = gm_803DE650; ptr->x0 != 0xFF; ptr++) { - if (ptr->x0 == arg0) { - return ptr; - } - } - return NULL; -} - -/// Get adventure stage kind for given difficulty and stage slot. -/// The (u8) cast on difficulty is required - these functions are called -/// via function pointers typed as f32(*)(int, u8) in UnkAdventureData. -u8 gm_8017E500(u8 difficulty, u8 stage_slot) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].stage_kind; -} - -f32 gm_8017E528(u8 difficulty, u8 stage_slot) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].scale0_pct / 100.0F; -} - -f32 gm_8017E578(u8 difficulty, u8 stage_slot) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].scale1_pct / 100.0F; -} - -u8 gm_8017E5C8(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[arg2 * 3]; -} - -u8 gm_8017E5FC(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[1 + arg2 * 3]; -} - -u8 gm_8017E630(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 2]; -} - -f32 gm_8017E664(u8 difficulty, u8 stage_slot) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].scale0_pct / 100.0F; -} - -f32 gm_8017E6B4(u8 difficulty, u8 stage_slot) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].scale1_pct / 100.0F; -} - -u8 gm_8017E704(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0x0E + arg2 * 3]; -} - -u8 gm_8017E738(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0xF + arg2 * 3]; -} - -u8 gm_8017E76C(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D7AC0[stage_slot + difficulty * 5].pad_6[0x10 + (arg2 * 3)]; -} - -void gm_8017E7A0(u8 matchResult) -{ - if (matchResult == OUTCOME_TIMEOUT) { - Player_LoseStock(0); - ifStatus_802F6948(0); - ifStatus_802F6E3C(0); - } -} - -bool gm_8017E7E0(void) -{ - return gm_GetAdventureData()->x7C == 0x14; -} - -void gm_8017E7FC(u8 matchResult) -{ - UnkAdventureData* r31 = gm_GetAdventureData(); - bool cond; - - if (gm_GetCurrentGameMode() == GM_ADVENTURE && r31->x0.cpu_level >= 2 && - r31->x0.xC.x20 + gm_8016AEDC() < 0xFD20U) - { - cond = true; - } else { - cond = false; - } - - if (!cond) { - struct StartMeleeRules* rules = gm_GetRules(); - rules->x4_5 = 1; - r31->x77 = 0; - gm_SetNextGameModeStateId(0x5A); - } else { - r31->x77 = 1; - gm_SetNextGameModeStateId(0x5A); - } -} - -typedef struct { - u8 b7 : 1, b6 : 1, b5 : 1, b4 : 1, b3 : 1, b2 : 1, b1 : 1, b0 : 1; -} u8_bits; - -#ifdef MUST_MATCH -#pragma push -#pragma dont_inline on -#endif -void fn_8017E8A4(int arg0_int) -{ - MatchEnd* arg0 = (MatchEnd*) arg0_int; - lbl_8046B6A0_t* gm = gm_16AE_GetUnkData_0(); - struct gm_803DE650_t* stage = gm_8017E4C4(gm_GetCurrentSceneIndex()); - UnkAdventureData* adv = &lbl_80472C30; - u8* flags = arg0->_x448; - gmm_x0_528_t* main_data; - u32 total_time; - int i; - - if (fn_8017E318() > 0) { - ((u8_bits*) &flags[2])->b3 = 1; - } - - if (gm->x24C8.x4_5) { - main_data = gmMainLib_8015CDD4(); - total_time = adv->x0.xC.x20 + gm_8016AEDC(); - ((u8_bits*) &flags[0])->b6 = 1; - - if (adv->x0.cpu_level == 4) { - ((u8_bits*) &flags[0])->b3 = 1; - } - - if (total_time < 0xC4E0U) { - ((u8_bits*) &flags[2])->b6 = 1; - } else if (total_time < 0x13560U) { - ((u8_bits*) &flags[2])->b7 = 1; - } - - if ((u32) adv->x0.xC.x1C == 0U && arg0->player_standings[0].x44 == 0U) - { - ((u8_bits*) &flags[1])->b1 = 1; - } - - if (adv->x0.xC.xE != 0) { - ((u8_bits*) &flags[2])->b5 = 1; - } - - if (adv->x0.xC.xF != 0) { - ((u8_bits*) &flags[2])->b4 = 1; - } - - if (adv->x0.xC.xD != 0) { - ((u8_bits*) &flags[1])->b0 = 1; - } else if (arg0->player_standings[0].stocks == (s32) main_data->stocks) - { - ((u8_bits*) &arg0->_x448[1])->b2 = 1; - } - } - - if (stage->x0 == 3) { - for (i = 0; i < 6; i++) { - if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && - Player_GetPlayerCharacter(i) == CKIND_LUIGI) - { - ((u8_bits*) &flags[1])->b7 = 1; - return; - } - } - } +struct lbl_80472D28_t { + /* +0 */ char pad_0[0x20]; + /* +20 */ HSD_JObj* x20; + /* +24 */ HSD_JObj* x24; + /* +28 */ char pad_28[4]; + /* +2C */ HSD_GObj* x2C; + /* +30 */ HSD_ImageDesc x30; + /* +48 */ HSD_Archive* x48; + /* +4C */ DynamicModelDesc x4C; + /* +5C */ void* x5C; + /* +60 */ void* x60; + /* +64 */ char pad_64[0x20]; + /* +84 */ HSD_Text* x84; + /* +88 */ char pad_88[0x38]; + /* +C0 */ u16 xC0; + /* +C2 */ u16 pad_C2; + /* +C4 */ u32 xC4; + /* +C8 */ u8 xC8; + /* +C9 */ u8 pad_C9[3]; + /* +CC */ s32 xCC; + /* +D0 */ s32 xD0; + /* +D4 */ s32 xD4; + /* +D8 */ s32 xD8; + /* +DC */ s32 xDC; + /* +E0 */ s32 xE0; + /* +E4 */ s32 xE4; + /* +E8 */ s32 xE8; + /* +EC */ s32 xEC; + /* +F0 */ s32 xF0; + /* +F4 */ s32 xF4; + /* +F8 */ s32 xF8; + /* +FC */ s32 xFC; + /* +100 */ s32 x100; + /* +104 */ int x104; + /* +108 */ s16 x108; + /* +10A */ s16 x10A; + /* +10C */ f32 x10C; + /* +110 */ u32 x110; + /* +114 */ u8 x114; + /* +115 */ u8 x115; + /* +116 */ u8 x116; + /* +117 */ u8 x117; + /* +118 */ u8 x118; + /* +119 */ u8 x119; + /* +11A */ u8 x11A; + /* +11B */ u8 x11B; + /* +11C */ u8 x11C; + /* +11D */ u8 x11D; + /* +11E */ u8 x11E; + /* +11F */ u8 x11F; +}; - if (stage->x0 == 0x11) { - if (gm->unk_C >= 5) { - ((u8_bits*) &flags[1])->b6 = 1; - return; - } - } +struct lbl_80472E48_t { + /* 0x00 */ u8 b76 : 2, b54 : 2, b32 : 2, b10 : 2; + /* 0x01 */ char pad_1[3]; + /* 0x04 */ s32 unk_4; /* inferred */ + /* 0x08 */ s32 unk_8; /* inferred */ + /* 0x0C */ u32 xC; + /* 0x10 */ u8 x10; + /* 0x11 */ char pad_11[3]; + /* 0x14 */ s32 x14[0x1B]; +}; /* size = 0x80 */ +ASSERT_SIZE(struct lbl_80472E48_t, 0x80); - if (stage->x0 == 0x25) { - ((u8_bits*) &flags[1])->b5 = 1; - return; - } else if (stage->x0 == 0x53) { - for (i = 0; i < 6; i++) { - if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && - Player_GetPlayerCharacter(i) == CKIND_LUIGI) - { - ((u8_bits*) &flags[1])->b4 = 1; - return; - } - } - } +typedef struct RegClearEv { + /* 0x00 */ char pad_0[0x1C]; + /* 0x1C */ HSD_ImageDesc* x1C; + /* 0x20 */ f32 x20; +} RegClearEv; - if (stage->x0 == 0x5C) { - ((u8_bits*) &flags[1])->b3 = 1; - } +u16 lbl_803D8B88[] = { 0x18, 0x16, 0x12, 0x3, 0x5, 0x4, 0x6, 0x1a, 0x19, 0x7 }; - PAD_STACK(8); -} +/// @todo .data order hack #ifdef MUST_MATCH -#pragma pop -#endif - -UnkAllstarData* gm_GetAllStarData(void) -{ - return (UnkAllstarData*) lbl_80472CB0; -} - -u8 gm_8017EB3C(u8 difficulty, u8 stage_slot) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].stage_kind; -} - -u8 gm_8017EB64(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3]; -} - -u8 gm_8017EB98(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 1]; -} - -u8 gm_8017EBCC(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].pad_6[arg2 * 3 + 2]; -} - -f32 gm_8017EC00(u8 difficulty, u8 stage_slot) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].scale2_pct / 100.0F; -} - -f32 gm_8017EC50(u8 difficulty, u8 stage_slot) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].scale3_pct / 100.0F; -} - -u8 gm_8017ECA0(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].pad_14[arg2 * 3]; -} - -u8 gm_8017ECD4(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + (difficulty * 5)].pad_14[arg2 * 3 + 1]; -} - -u8 gm_8017ED08(u8 difficulty, u8 stage_slot, u8 arg2) -{ - return lbl_803D85F0[stage_slot + (difficulty * 5)].pad_14[arg2 * 3 + 2]; -} - -f32 gm_8017ED3C(u8 difficulty, u8 stage_slot) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].scale0_pct / 100.0F; -} - -f32 gm_8017ED8C(u8 difficulty, u8 stage_slot) -{ - return lbl_803D85F0[stage_slot + difficulty * 5].scale1_pct / 100.0F; -} - -bool fn_8017EDDC(void) +static void order_data(void) { - UnkAllstarData* p; - - if (gm_GetCurrentGameMode() == GM_CLASSIC) { - p = gm_GetAllStarData(); - if (p->x0.xC.xD == 0 && p->x0.cpu_level >= 2 && p->x0.xC.x20 < 0x5208) - { - return true; - } - } - return false; + (void) "GmRegClr"; + (void) "ScGamRegClear_scene_data"; + (void) "Error : Cannot open archive file (File Name : %s)."; + (void) "SdDec.usd"; + (void) "SIS_DecisionData"; + (void) "SdDec.dat"; + (void) " "; + (void) " "; + (void) "Error : gobj don\'t get (gmRegClearAddModel)\n"; + (void) "gmregclear.c"; + (void) "Error : jobj don\'t get (gmRegClearAddModel)\n"; } - -#ifdef MUST_MATCH -#pragma push -#pragma dont_inline on #endif -void fn_8017EE40(int arg0_int) -{ - MatchEnd* arg0 = (MatchEnd*) arg0_int; - struct StartMeleeRules* rules; - UnkAllstarData* allstar; - gmm_x0_528_t* main_data; - u32 total_time; - int i; - - rules = gm_GetRules(); - allstar = (UnkAllstarData*) lbl_80472CB0; - - if (fn_8017E318() > 0) { - ((u8_bits*) &arg0->_x448[2])->b3 = 1; - } - if (rules->x4_5) { - main_data = gmMainLib_8015CDC8(); - total_time = allstar->x0.xC.x20 + gm_8016AEDC(); - ((u8_bits*) &arg0->_x448[0])->b7 = 1; +static struct lbl_80472D28_t lbl_80472D28; - if (allstar->x0.cpu_level == 4) { - ((u8_bits*) &arg0->_x448[0])->b4 = 1; - } +static struct lbl_80472E48_t lbl_80472E48; - if (total_time < 0x3840U) { - ((u8_bits*) &arg0->_x448[2])->b6 = 1; - } else if (total_time < 0x5460U) { - ((u8_bits*) &arg0->_x448[2])->b7 = 1; - } +static int lbl_80472EC8[4]; - if ((u32) allstar->x0.xC.x1C == 0U && - arg0->player_standings[0].x44 == 0U) - { - ((u8_bits*) &arg0->_x448[1])->b1 = 1; - } +typedef struct RegClearSpawnEntry { + /* 0x00 */ s32 x0; + /* 0x04 */ u8 x4; + /* 0x05 */ u8 x5; + /* 0x06 */ u8 x6; + /* 0x07 */ u8 x7; + /* 0x08 */ f32 x8; + /* 0x0C */ f32 xC; +} RegClearSpawnEntry; - if (allstar->x0.xC.xE != 0) { - ((u8_bits*) &arg0->_x448[2])->b5 = 1; - } +typedef struct RegClearRecordState { + /* 0x00 */ u8 x0; + /* 0x01 */ u8 pad_1; + /* 0x02 */ u16 x2; + /* 0x04 */ int x4; + /* 0x08 */ int x8; + /* 0x0C */ int xC; + /* 0x10 */ s8 x10; + /* 0x11 */ u8 x11; + /* 0x12 */ u8 pad_12[2]; +} RegClearRecordState; +ASSERT_SIZE(RegClearRecordState, 0x14); - if (allstar->x0.xC.xF != 0) { - ((u8_bits*) &arg0->_x448[2])->b4 = 1; - } +typedef struct RegClearRecordOverlay { + u8 pad_0[0x6BC]; + RegClearRecordState record; +} RegClearRecordOverlay; - if (allstar->x0.xC.xD != 0) { - ((u8_bits*) &arg0->_x448[1])->b0 = 1; - } else if (arg0->player_standings[0].stocks == (s32) main_data->stocks) - { - ((u8_bits*) &arg0->_x448[1])->b2 = 1; - } - } +typedef struct lbl_80472ED8_t { + /* 0x000 */ s32 x0; + /* 0x004 */ s32 x4; + /* 0x008 */ s32 x8; + /* 0x00C */ PlayerInitData xC; + /* 0x030 */ u8 pad_30[0x24]; + /* 0x054 */ RegClearSpawnEntry x54[101]; + /* 0x6A4 */ RegClearSpawnEntry* x6A4; + /* 0x6A8 */ RegClearSpawnEntry* x6A8; + /* 0x6AC */ RegClearSpawnEntry* x6AC; + /* 0x6B0 */ RegClearSpawnEntry* x6B0; + /* 0x6B4 */ RegClearSpawnEntry* x6B4; + /* 0x6B8 */ RegClearSpawnEntry* x6B8; + /* 0x6BC */ RegClearRecordState record[0]; +} lbl_80472ED8_t; +ASSERT_SIZE(lbl_80472ED8_t, 0x6BC); - for (i = 0; i < 6; i++) { - if (Player_GetPlayerSlotType(i) == Gm_PKind_Cpu && - Player_GetPlayerCharacter(i) == CKIND_CREZYH) - { - ((u8_bits*) &arg0->_x448[0])->b0 = 1; - return; - } - } -} -#ifdef MUST_MATCH -#pragma pop -#endif +lbl_80472ED8_t lbl_80472ED8; int fn_8017F008(void) { @@ -4145,199 +2505,3 @@ void gm_80183218(void) lbl_804D65E8 = 0; HSD_GObj_SetupProc(GObj_Create(0xF, 0x11, 0), fn_80182F40, 0x15); } - -AdventureStageEntry lbl_803D7AC0[110] = { - { 4, 0, 0x28, 0x1c2, { 1 } }, - { 3, 0, 0x32, 0x190, { 2 } }, - { 3, 0, 0x3c, 0x140, { 4 } }, - { 2, 0, 0x46, 0xf0, { 5 } }, - { 1, 0, 0x50, 0xaa, { 6 } }, - { 4, 0, 0x50, 0x8c, { 0, 0, 0x10, 0, 0, 4 } }, - { 3, 0, 0x5e, 0x70, { 3, 0, 0x10, 3, 0, 4 } }, - { 3, 0, 0x64, 0x6b, { 5, 0, 0x10, 4, 0, 4 } }, - { 3, 0, 0x6e, 0x69, { 7, 0, 0x10, 7, 0, 4 } }, - { 2, 0, 0x78, 0x5f, { 8, 0, 0x10, 8, 0, 4 } }, - { 4, 0, 0x50, 0x8c, { 1, 0, 4, 1, 1, 8 } }, - { 4, 0, 0x64, 0x5a, { 2, 0, 4, 2, 1, 8 } }, - { 3, 0, 0x6e, 0x46, { 4, 0, 4, 3, 1, 8 } }, - { 2, 0, 0x78, 0x32, { 7, 0, 4, 6, 1, 8 } }, - { 1, 0, 0x82, 0x28, { 9, 0, 4, 9, 1, 8 } }, - { 4, 0, 0x3c, 0x17c, { 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, - { 4, 0, 0x50, 0xfa, { 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, - { 3, 0, 0x5a, 0xc8, { 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, - { 2, 0, 0x5f, 0xa0, { 7, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, - { 1, 0, 0x6e, 0x78, { 8, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0x64, 0, 0x64, 0, 0, 4, 0, 0, 4 } }, - { 3, 0, 0x46, 0xa0, { 1 } }, - { 2, 0, 0x50, 0x8c, { 3 } }, - { 2, 0, 0x5a, 0x78, { 5 } }, - { 1, 0, 0x64, 0x69, { 7 } }, - { 1, 0, 0x6c, 0x5f, { 9 } }, - { 4, 0, 0x50, 0x7d, { 2, 0, 4 } }, - { 4, 0, 0x5a, 0x6e, { 6, 0, 4 } }, - { 3, 0, 0x64, 0x64, { 8, 0, 4 } }, - { 3, 0, 0x76, 0x5f, { 9, 0, 4 } }, - { 2, 0, 0x82, 0x5a, { 9, 0, 4 } }, - { 3, 0, 0x50, 0x82, { 2, 0, 4 } }, - { 3, 0, 0x5a, 0x6e, { 5, 0, 4 } }, - { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, - { 2, 0, 0x73, 0x58, { 8, 0, 4 } }, - { 1, 0, 0x82, 0x4a, { 9, 0, 4 } }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 3, 0, 0x50, 0xaa, { 2, 0, 4 } }, - { 2, 0, 0x64, 0x82, { 4, 0, 4 } }, - { 2, 0, 0x78, 0x6e, { 6, 0, 4 } }, - { 1, 0, 0x82, 0x64, { 8, 0, 4 } }, - { 0xff, 0, 0x8c, 0x5a, { 9, 0, 4 } }, - { 3, 0, 0x3c, 0x1f4, { 1 } }, - { 2, 0, 0x46, 0x190, { 3 } }, - { 2, 0, 0x50, 0x12c, { 4 } }, - { 1, 0, 0x5a, 0xc8, { 6 } }, - { 0xff, 0, 0x64, 0xaf, { 7 } }, - { 3, 0, 0x46, 0xf0, { 2, 0, 0x1b } }, - { 2, 0, 0x4b, 0xb4, { 4, 0, 0x1b } }, - { 2, 0, 0x50, 0x82, { 6, 0, 0x1b } }, - { 1, 0, 0x64, 0x64, { 7, 0, 4 } }, - { 1, 0, 0x78, 0x5a, { 9, 0, 4 } }, - { 2, 0, 0x50, 0xb4, { 2, 0, 0x1b } }, - { 2, 0, 0x5a, 0x96, { 4, 0, 4 } }, - { 2, 0, 0x64, 0x82, { 5, 0, 0x12 } }, - { 2, 0, 0x76, 0x6e, { 6, 0, 0x12 } }, - { 2, 0, 0x82, 0x64, { 7, 0, 0x12 } }, - { 2, 0, 0x3c, 0xd2, { 2, 1, 8 } }, - { 2, 0, 0x46, 0xb4, { 4, 1, 8 } }, - { 2, 0, 0x5a, 0x8c, { 6, 1, 8 } }, - { 2, 0, 0x69, 0x78, { 8, 1, 8 } }, - { 2, 0, 0x75, 0x64, { 9, 1, 8 } }, - { 4, 0, 0x3c, 0x1a4, { 1 } }, - { 4, 0, 0x4e, 0x140, { 4 } }, - { 4, 0, 0x58, 0xc8, { 5 } }, - { 3, 0, 0x62, 0xaa, { 7 } }, - { 2, 0, 0x6d, 0x96, { 8 } }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 2, 0, 0x50, 0x96, { 3, 0, 4 } }, - { 2, 0, 0x64, 0x6e, { 6, 0, 4 } }, - { 2, 0, 0x6e, 0x64, { 8, 0, 4 } }, - { 2, 0, 0x78, 0x5a, { 9, 0, 4 } }, - { 2, 0, 0x82, 0x46, { 9, 2, 4 } }, - { 4, - 0, - 0x46, - 0xbe, - { 1, 0, 0x1d, 1, 2, 0x1d, 1, 1, 0x1b, 0, 0, 0x64, 0, 0x64 } }, - { 4, - 0, - 0x50, - 0x96, - { 3, 0, 0x1d, 3, 2, 0x1d, 2, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, - { 4, - 0, - 0x5a, - 0x82, - { 5, 0, 0x1d, 4, 2, 0x1d, 4, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, - { 4, - 0, - 0x64, - 0x6e, - { 7, 0, 0x1d, 6, 2, 0x1d, 5, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, - { 4, - 0, - 0x82, - 0x64, - { 8, 0, 0x1d, 8, 2, 0x1d, 8, 1, 0x1d, 0, 0, 0x64, 0, 0x64 } }, - { 2, 0, 0x50, 0xbe, { 1 } }, - { 2, 0, 0x55, 0x8c, { 3 } }, - { 2, 0, 0x5a, 0x82, { 4 } }, - { 2, 0, 0x5f, 0x78, { 6 } }, - { 2, 0, 0x64, 0x64, { 9 } }, - { 2, 0, 0x32, 0x1a4, { 1 } }, - { 2, 0, 0x3c, 0x172, { 3 } }, - { 2, 0, 0x46, 0x118, { 5 } }, - { 2, 0, 0x50, 0xc8, { 6 } }, - { 2, 0, 0x5a, 0x96, { 8 } }, - { 2, 0, 0x46, 0xbe, { 1, 0, 0x1b, 1, 0, 0x1b } }, - { 2, 0, 0x5a, 0x96, { 3, 0, 0x1b, 2, 0, 0x1b } }, - { 2, 0, 0x64, 0x82, { 5, 0, 0x1b, 3, 0, 0x1b } }, - { 2, 0, 0x6e, 0x6e, { 6, 0, 0x1b, 5, 0, 0x1b } }, - { 2, 0, 0x78, 0x5a, { 8, 0, 0x1b, 7, 0, 0x1b } }, - { 3, 0, 0x46, 0x82, { 2, 0, 4 } }, - { 2, 0, 0x5d, 0x73, { 4, 0, 4 } }, - { 2, 0, 0x64, 0x69, { 6, 3, 4 } }, - { 1, 0, 0x6e, 0x58, { 8, 3, 4 } }, - { 0xff, 0, 0x78, 0x4b, { 9, 3, 4 } }, - { 2, 0, 1, 1, { 0, 0, 4 } }, - { 2, 0, 1, 1, { 0, 0, 4 } }, - { 1, 0, 0x87, 0x3a, { 7, 0, 4 } }, - { 1, 0, 0x94, 0x32, { 8, 0, 4 } }, - { 0xff, 0, 0xa0, 0x26, { 9, 0, 4 } }, -}; - -AllstarStageEntry lbl_803D85F0[55] = { - { 4, 0, 0x3c, 0xaf, { 0, 0, 9 } }, - { 3, 0, 0x55, 0x78, { 2, 0, 4 } }, - { 3, 0, 0x64, 0x64, { 4, 0, 4 } }, - { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, - { 1, 0, 0x78, 0x5a, { 9, 3, 8 } }, - { 4, 0, 0x46, 0xa0, { 1, 0, 4, 2, 0, 9 }, 0x50, 0x5a, { 8, 1, 4 } }, - { 4, 0, 0x55, 0x78, { 3, 0, 4, 3, 0, 4 }, 0x50, 0x64, { 7, 1, 4 } }, - { 3, 0, 0x64, 0x64, { 5, 0, 4, 4, 0, 4 }, 0x50, 0x73, { 6, 1, 4 } }, - { 3, 0, 0x64, 0x5a, { 6, 0, 4, 6, 0, 8 }, 0x50, 0x82, { 4, 1, 4 } }, - { 1, 0, 0x73, 0x50, { 8, 3, 4, 8, 0, 8 }, 0x50, 0x96, { 3, 1, 4 } }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 4, 0, 0x4b, 0x8c, { 2, 0, 4 } }, - { 4, 0, 0x5a, 0x6e, { 5, 0, 4 } }, - { 4, 0, 0x64, 0x64, { 8, 0, 4 } }, - { 4, 0, 0x73, 0x55, { 9, 0, 4 } }, - { 4, 0, 0x86, 0x46, { 9, 0, 4 } }, - { 3, 0, 0x46, 0x168, { 2, 0, 0x1b }, 0x64, 0x64, { 6, 2, 4, 6, 1, 4 } }, - { 3, 0, 0x50, 0xf0, { 3, 0, 0x1b }, 0x64, 0x5a, { 5, 2, 4, 5, 1, 4 } }, - { 2, 0, 0x5a, 0xb4, { 5, 0, 0x1b }, 0x64, 0x50, { 2, 2, 4, 2, 1, 9 } }, - { 2, 0, 0x64, 0x8c, { 7, 0, 4 }, 0x64, 0x50, { 1, 2, 4, 1, 1, 9 } }, - { 1, 0, 0x78, 0x64, { 8, 0, 4 }, 0x64, 0x50, { 0, 2, 4, 0, 1, 9 } }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 0xff }, - { 2, 0, 0x55, 0x82, { 3, 0, 4 } }, - { 2, 0, 0x64, 0x6e, { 6, 0, 4 } }, - { 2, 0, 0x5a, 0x82, { 5, 0, 4 } }, - { 2, 0, 0x64, 0x6e, { 6, 0, 0x12 } }, - { 1, 0, 0x6e, 0x5a, { 8, 0, 0x12 } }, - { 3, 0, 0x3c, 0x190, { 1, 0, 0x19 } }, - { 3, 0, 0x46, 0x104, { 3, 0, 0x17 } }, - { 2, 0, 0x50, 0xc8, { 4, 0, 0x17 } }, - { 2, 0, 0x5a, 0x9b, { 5, 0, 0x17 } }, - { 1, 0, 0x6e, 0x78, { 7, 0, 0x17 } }, - { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, - { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, - { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, - { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, - { 2, 0, 0x64, 0x64, { 1, 0, 4, 0, 0, 4, 0, 0, 4 }, 0x64, 0x64 }, - { 2, 0, 0x50, 0xb4, { 1, 0, 0x1b } }, - { 2, 0, 0x5a, 0x82, { 3, 0, 0x1b } }, - { 2, 0, 0x64, 0x64, { 5, 0, 0x1b } }, - { 1, 0, 0x6e, 0x55, { 8, 0, 0x1b } }, - { 0xff, 0, 0x7d, 0x44, { 9, 0, 0x1b } }, - { 2, 0, 0x32, 0x64, { 5, 0, 4 } }, - { 2, 0, 0x4b, 0x64, { 6, 0, 4 } }, - { 2, 0, 0x64, 0x64, { 7, 0, 4 } }, - { 2, 0, 0x96, 0x64, { 8, 0, 4 } }, - { 0xff, 0, 0xc8, 0x64, { 9, 0, 4 } }, -}; diff --git a/src/melee/gm/gmregclear.h b/src/melee/gm/gmregclear.h index 2ee3c16cb8..2075e953fb 100644 --- a/src/melee/gm/gmregclear.h +++ b/src/melee/gm/gmregclear.h @@ -10,78 +10,6 @@ #include #include -/* 17C0C8 */ void fn_8017C0C8(void); -/* 17C1A4 */ void fn_8017C1A4(HSD_GObj*); -/* 17C71C */ void fn_8017C71C(void); -/* 17C7A0 */ void fn_8017C7A0(void); -/* 17C7EC */ void fn_8017C7EC(void); -/* 17C838 */ void gm_8017C838(void); -/* 17C984 */ void gm_8017C984(UNK_T); -/* 17C9A8 */ void gm_8017C9A8(DebugGameOverData*, Unk1PData*, u8); -/* 17CA38 */ UNK_RET gm_8017CA38(DebugGameOverData*, Unk1PData*, - struct gmm_x0_528_t*, u8); -/* 17CBAC */ UNK_RET gm_8017CBAC(UnkAdventureData*, struct gmm_x0_528_t*, u8); -/* 17CD94 */ u8 gm_8017CD94(UnkAdventureData*, int, int, int); -/* 17CE34 */ void gm_8017CE34(StartMeleeData*, UnkAdventureData*, s8*, u8, u8, - u8, s32, StKind, s32 count, s32); -/* 17D7AC */ bool gm_8017D7AC(MatchExitInfo*, Unk1PData*, u8); -/* 17D9C0 */ s32 fn_8017D9C0(const u8* used_ckinds, const u8* preset_ckinds); -/* 17DB58 */ void gm_8017DB58(struct Unk1PData_x24* arg0); -/* 17DB6C */ u8 gm_8017DB6C(gm_8017DB6C_arg0_t* arg0, int index); -/* 17DB78 */ u8 gm_8017DB78(gm_8017DB6C_arg0_t* arg0, int index); -/* 17DB88 */ s32 gm_8017DB88(void* arg0, u8 arg1, s32 arg2, s32 arg3, u8* arg4, - u8 arg5, u8 (*arg6)(s32, s32, u8), - u8 (*arg7)(s32, s32, u8), - u8 (*arg8)(s32, s32, u8), f32 (*arg9)(s32, s32), - f32 (*arg10)(s32, s32)); -/* 17DD7C */ s32 fn_8017DD7C(PlayerInitData* arg0, Unk1PData_x24* arg1, - u8 arg2); -/* 17DE54 */ s32 fn_8017DE54(u8, u8*); -/* 17DEC8 */ Unk1PData* fn_8017DEC8(int); -/* 17DF28 */ Unk1PData* fn_8017DF28(void); -/* 17DF90 */ u8 fn_8017DF90(void); -/* 17DFF4 */ int gm_8017DFF4(int); -/* 17E068 */ int gm_8017E068(void); -/* 17E0E4 */ int fn_8017E0E4(void); -/* 17E160 */ bool fn_8017E160(void); -/* 17E21C */ void fn_8017E21C(void); -/* 17E280 */ s8 gm_8017E280(u16, u32); -/* 17E318 */ int fn_8017E318(void); -/* 17E3C8 */ void fn_8017E3C8(void); -/* 17E424 */ UnkAdventureData* gm_GetAdventureData(void); -/* 17E430 */ u8 gm_8017E430(void); ///< returns a player slot -/* 17E440 */ u8 gm_8017E440(void); -/* 17E48C */ u8 gm_8017E48C(GameModeState*); -/* 17E4C4 */ struct gm_803DE650_t* gm_8017E4C4(u8); -/* 17E500 */ u8 gm_8017E500(u8, u8); -/* 17E528 */ f32 gm_8017E528(u8, u8); -/* 17E578 */ f32 gm_8017E578(u8, u8); -/* 17E5C8 */ u8 gm_8017E5C8(u8, u8, u8); -/* 17E5FC */ u8 gm_8017E5FC(u8, u8, u8); -/* 17E630 */ u8 gm_8017E630(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17E664 */ f32 gm_8017E664(u8, u8); -/* 17E6B4 */ f32 gm_8017E6B4(u8, u8); -/* 17E704 */ u8 gm_8017E704(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17E738 */ u8 gm_8017E738(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17E76C */ u8 gm_8017E76C(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17E7A0 */ void gm_8017E7A0(u8); -/* 17E7E0 */ bool gm_8017E7E0(void); -/* 17E7FC */ void gm_8017E7FC(u8); -/* 17E8A4 */ void fn_8017E8A4(int); -/* 17EB30 */ UnkAllstarData* gm_GetAllStarData(void); -/* 17EB3C */ u8 gm_8017EB3C(u8, u8); -/* 17EB64 */ u8 gm_8017EB64(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17EB98 */ u8 gm_8017EB98(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17EBCC */ u8 gm_8017EBCC(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17EC00 */ f32 gm_8017EC00(u8, u8); -/* 17EC50 */ f32 gm_8017EC50(u8, u8); -/* 17ECA0 */ u8 gm_8017ECA0(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17ECD4 */ u8 gm_8017ECD4(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17ED08 */ u8 gm_8017ED08(u8 difficulty, u8 stage_slot, u8 arg2); -/* 17ED3C */ f32 gm_8017ED3C(u8, u8); -/* 17ED8C */ f32 gm_8017ED8C(u8, u8); -/* 17EDDC */ bool fn_8017EDDC(void); -/* 17EE40 */ void fn_8017EE40(int); /* 17F008 */ int fn_8017F008(void); /* 17F09C */ s32 fn_8017F09C(void); /* 17F14C */ s32 fn_8017F14C(void* arg0); diff --git a/src/melee/gr/grcorneria.c b/src/melee/gr/grcorneria.c index 01d4bfc8bc..d4a60d1f0f 100644 --- a/src/melee/gr/grcorneria.c +++ b/src/melee/gr/grcorneria.c @@ -16,9 +16,9 @@ #include "cm/camera.h" #include "ft/ftlib.h" +#include "gm/gm_17E4.h" #include "gm/gm_1832.h" #include "gm/gm_1A45.h" -#include "gm/gmregclear.h" #include "if/ifcoget.h" #include "if/ifstatus.h" #include "it/item.h" diff --git a/src/melee/gr/grfigureget.c b/src/melee/gr/grfigureget.c index 42e6607a30..61923a2bc0 100644 --- a/src/melee/gr/grfigureget.c +++ b/src/melee/gr/grfigureget.c @@ -12,7 +12,7 @@ #include "baselib/forward.h" #include "ft/ftlib.h" -#include "gm/gmregclear.h" +#include "gm/gm_17C0.h" #include "it/forward.h"