From 3a6a689d77fa70e5e8917298bfdc3b47142cf181 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 20 Aug 2020 20:36:06 +1000 Subject: [PATCH] Decompile mpStartMatch --- src/game/game_01bea0.c | 4 +- src/game/game_179060.c | 2 +- src/game/mplayer.c | 99 ++++++++++++---------------------- src/include/constants.h | 33 ++++++------ src/include/game/game_179060.h | 4 +- src/include/game/mplayer.h | 2 +- 6 files changed, 58 insertions(+), 86 deletions(-) diff --git a/src/game/game_01bea0.c b/src/game/game_01bea0.c index 582df8cd8..861d8c7c7 100644 --- a/src/game/game_01bea0.c +++ b/src/game/game_01bea0.c @@ -1090,7 +1090,7 @@ glabel var7f1a863c /* f01ccd0: 2401fffb */ addiu $at,$zero,-5 /* f01ccd4: 54a10011 */ bnel $a1,$at,.L0f01cd1c /* f01ccd8: 2401fffa */ addiu $at,$zero,-6 -/* f01ccdc: 0fc61e19 */ jal func0f187864 +/* f01ccdc: 0fc61e19 */ jal mpStartMatch /* f01cce0: afa40158 */ sw $a0,0x158($sp) /* f01cce4: 0fc06fa8 */ jal func0f01bea0 /* f01cce8: 00000000 */ nop @@ -2325,7 +2325,7 @@ glabel var7f1a863c // // ccc8 // if (g_MenuData.unk008 != -1) { // if (g_MenuData.unk008 == -5) { -// func0f187864(); +// mpStartMatch(); // func0f01bea0(); // // if (g_Vars.unk000458 & 0x00000002) { diff --git a/src/game/game_179060.c b/src/game/game_179060.c index 3fc27ce26..9c973f28d 100644 --- a/src/game/game_179060.c +++ b/src/game/game_179060.c @@ -126,7 +126,7 @@ u32 func0f1790fc(void) } GLOBAL_ASM( -glabel func0f179104 +glabel mpChooseRandomStage /* f179104: 27bdffd8 */ addiu $sp,$sp,-40 /* f179108: afb1001c */ sw $s1,0x1c($sp) /* f17910c: afb00018 */ sw $s0,0x18($sp) diff --git a/src/game/mplayer.c b/src/game/mplayer.c index d49653624..90d1de59b 100644 --- a/src/game/mplayer.c +++ b/src/game/mplayer.c @@ -85,70 +85,41 @@ glabel func0f187838 /* f187860: a4800040 */ sh $zero,0x40($a0) ); -GLOBAL_ASM( -glabel func0f187864 -/* f187864: 27bdffd0 */ addiu $sp,$sp,-48 -/* f187868: afbf001c */ sw $ra,0x1c($sp) -/* f18786c: afb00018 */ sw $s0,0x18($sp) -/* f187870: 0fc5fc98 */ jal func0f17f260 -/* f187874: 00008025 */ or $s0,$zero,$zero -/* f187878: 0fc67244 */ jal mpIsChallengeComplete -/* f18787c: 2404001e */ addiu $a0,$zero,0x1e -/* f187880: 14400006 */ bnez $v0,.L0f18789c -/* f187884: 3c05800b */ lui $a1,%hi(g_MpSetup) -/* f187888: 24a5cb88 */ addiu $a1,$a1,%lo(g_MpSetup) -/* f18788c: 8cae000c */ lw $t6,0xc($a1) -/* f187890: 2401fffe */ addiu $at,$zero,-2 -/* f187894: 01c17824 */ and $t7,$t6,$at -/* f187898: acaf000c */ sw $t7,0xc($a1) -.L0f18789c: -/* f18789c: 0fc67244 */ jal mpIsChallengeComplete -/* f1878a0: 2404001d */ addiu $a0,$zero,0x1d -/* f1878a4: 3c05800b */ lui $a1,%hi(g_MpSetup) -/* f1878a8: 14400005 */ bnez $v0,.L0f1878c0 -/* f1878ac: 24a5cb88 */ addiu $a1,$a1,%lo(g_MpSetup) -/* f1878b0: 8cb8000c */ lw $t8,0xc($a1) -/* f1878b4: 2401ff3f */ addiu $at,$zero,-193 -/* f1878b8: 0301c824 */ and $t9,$t8,$at -/* f1878bc: acb9000c */ sw $t9,0xc($a1) -.L0f1878c0: -/* f1878c0: 00001025 */ or $v0,$zero,$zero -/* f1878c4: 94a30016 */ lhu $v1,0x16($a1) -/* f1878c8: 24040004 */ addiu $a0,$zero,0x4 -/* f1878cc: 24080001 */ addiu $t0,$zero,0x1 -.L0f1878d0: -/* f1878d0: 00484804 */ sllv $t1,$t0,$v0 -/* f1878d4: 00695024 */ and $t2,$v1,$t1 -/* f1878d8: 11400002 */ beqz $t2,.L0f1878e4 -/* f1878dc: 24420001 */ addiu $v0,$v0,0x1 -/* f1878e0: 26100001 */ addiu $s0,$s0,0x1 -.L0f1878e4: -/* f1878e4: 5444fffa */ bnel $v0,$a0,.L0f1878d0 -/* f1878e8: 24080001 */ addiu $t0,$zero,0x1 -/* f1878ec: 90a40011 */ lbu $a0,0x11($a1) -/* f1878f0: 24010001 */ addiu $at,$zero,0x1 -/* f1878f4: 14810004 */ bne $a0,$at,.L0f187908 -/* f1878f8: 00000000 */ nop -/* f1878fc: 0fc5e441 */ jal func0f179104 -/* f187900: 00000000 */ nop -/* f187904: 00402025 */ or $a0,$v0,$zero -.L0f187908: -/* f187908: 0fc06c55 */ jal titleSetNextStage -/* f18790c: afa40024 */ sw $a0,0x24($sp) -/* f187910: 0c003a57 */ jal func0000e95c -/* f187914: 8fa40024 */ lw $a0,0x24($sp) -/* f187918: 0fc068d5 */ jal setNumPlayers -/* f18791c: 02002025 */ or $a0,$s0,$zero -/* f187920: 0fc069f9 */ jal titleSetNextMode -/* f187924: 24040005 */ addiu $a0,$zero,0x5 -/* f187928: 8fbf001c */ lw $ra,0x1c($sp) -/* f18792c: 240b0001 */ addiu $t3,$zero,0x1 -/* f187930: 3c01800a */ lui $at,%hi(g_Vars+0x470) -/* f187934: 8fb00018 */ lw $s0,0x18($sp) -/* f187938: ac2ba430 */ sw $t3,%lo(g_Vars+0x470)($at) -/* f18793c: 03e00008 */ jr $ra -/* f187940: 27bd0030 */ addiu $sp,$sp,0x30 -); +void mpStartMatch(void) +{ + s32 i; + s32 numplayers = 0; + s32 stagenum; + + func0f17f260(); + + if (!mpIsChallengeComplete(30)) { + g_MpSetup.options &= ~MPOPTION_ONEHITKILLS; + } + + if (!mpIsChallengeComplete(29)) { + g_MpSetup.options &= ~(MPOPTION_SLOWMOTION_ON | MPOPTION_SLOWMOTION_SMART); + } + + for (i = 0; i < 4; i++) { + if (g_MpSetup.chrslots & (1 << i)) { + numplayers++; + } + } + + stagenum = g_MpSetup.stagenum; + + if (g_MpSetup.stagenum == STAGE_MP_RANDOM) { + stagenum = mpChooseRandomStage(); + } + + titleSetNextStage(stagenum); + func0000e95c(stagenum); + setNumPlayers(numplayers); + titleSetNextMode(TITLEMODE_SKIP); + + g_Vars.perfectbuddynum = 1; +} GLOBAL_ASM( glabel func0f187944 diff --git a/src/include/constants.h b/src/include/constants.h index 836ade9a6..f332d09e1 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1745,27 +1745,27 @@ #define MPLOCKTYPE_PLAYER 4 #define MPLOCKTYPE_CHALLENGE 5 -#define MPOPTION_ONEHITKILLS 0x00000001 -#define MPOPTION_TEAMSENABLED 0x00000002 -#define MPOPTION_NORADAR 0x00000004 -#define MPOPTION_NOAUTOAIM 0x00000008 -#define MPOPTION_NOPLAYERHIGHLIGHT 0x00000010 -#define MPOPTION_NOPICKUPHIGHLIGHT 0x00000020 -#define MPOPTION_SLOWMOTION_ON 0x00000040 -#define MPOPTION_SLOWMOTION_SMART 0x00000080 -#define MPOPTION_FASTMOVEMENT 0x00000100 -#define MPOPTION_DISPLAYTEAM 0x00000200 -#define MPOPTION_KILLSSCORE 0x00000400 +#define MPOPTION_ONEHITKILLS 0x00000001 +#define MPOPTION_TEAMSENABLED 0x00000002 +#define MPOPTION_NORADAR 0x00000004 +#define MPOPTION_NOAUTOAIM 0x00000008 +#define MPOPTION_NOPLAYERHIGHLIGHT 0x00000010 +#define MPOPTION_NOPICKUPHIGHLIGHT 0x00000020 +#define MPOPTION_SLOWMOTION_ON 0x00000040 +#define MPOPTION_SLOWMOTION_SMART 0x00000080 +#define MPOPTION_FASTMOVEMENT 0x00000100 +#define MPOPTION_DISPLAYTEAM 0x00000200 +#define MPOPTION_KILLSSCORE 0x00000400 #define MPOPTION_HTB_HIGHLIGHTBRIEFCASE 0x00000800 -#define MPOPTION_HTB_SHOWONRADAR 0x00001000 -#define MPOPTION_CTC_SHOWONRADAR 0x00002000 +#define MPOPTION_HTB_SHOWONRADAR 0x00001000 +#define MPOPTION_CTC_SHOWONRADAR 0x00002000 #define MPOPTION_KOH_HILLONRADAR 0x00004000 #define MPOPTION_KOH_MOBILEHILL 0x00008000 -#define MPOPTION_00010000 0x00010000 +#define MPOPTION_00010000 0x00010000 #define MPOPTION_HTM_HIGHLIGHTTERMINAL 0x00020000 -#define MPOPTION_HTM_SHOWONRADAR 0x00040000 +#define MPOPTION_HTM_SHOWONRADAR 0x00040000 #define MPOPTION_PAC_HIGHLIGHTTARGET 0x00080000 -#define MPOPTION_PAC_SHOWONRADAR 0x00100000 +#define MPOPTION_PAC_SHOWONRADAR 0x00100000 #define MPPLAYERTITLE_BEGINNER 0 #define MPPLAYERTITLE_TRAINEE 1 @@ -2586,6 +2586,7 @@ #define SQUADRON_0E 0x0e #define SQUADRON_0F 0x0f +#define STAGE_MP_RANDOM 0x01 #define STAGE_MAIANSOS 0x09 #define STAGE_TEST_SILO 0x14 #define STAGE_WAR 0x16 diff --git a/src/include/game/game_179060.h b/src/include/game/game_179060.h index 0c34a1f7e..1d55d6c7e 100644 --- a/src/include/game/game_179060.h +++ b/src/include/game/game_179060.h @@ -4,7 +4,7 @@ #include "types.h" char *mpGetCurrentPlayerName(struct menuitem *item); -u32 func0f179104(void); +u32 mpChooseRandomStage(void); s32 menuhandler001791c8(u32, u32, u32 *); char *mpMenuTextWeaponNameForSlot(struct menuitem *item); char *mpMenuTextSetupName(struct menuitem *item); @@ -63,7 +63,7 @@ char *mpMenuTextSavePlayerOrCopy(struct menuitem *item); char *mpMenuTextArenaName(struct menuitem *item); char *mpMenuTextWeaponSetName(struct menuitem *item); u32 func0f17f100(void); -u32 func0f17f260(void); +void func0f17f260(void); u32 func0f17f428(void); s32 menuhandlerPlayerTeam(u32 operation, struct menuitem *item, s32 *value); u32 menuhandlerMpNumberOfSimulants(u32 operation, struct menuitem *item, s32 *value); diff --git a/src/include/game/mplayer.h b/src/include/game/mplayer.h index 2745aad1d..975c3cace 100644 --- a/src/include/game/mplayer.h +++ b/src/include/game/mplayer.h @@ -5,7 +5,7 @@ f32 func0f187770(u8 value); u32 func0f187838(void); -void func0f187864(void); +void mpStartMatch(void); u32 func0f187944(void); void func0f187e70(void); void func0f187fbc(s32 playernum);