From 60c7b619d9f1aee848d8ab82ccd37ab2d77906ab Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 31 Dec 2020 20:50:53 +1000 Subject: [PATCH] Decompile mpSetDefaultSetup --- src/game/game_0f09f0.c | 4 +- src/game/game_107fb0.c | 2 +- src/game/game_17f930.c | 2 +- src/game/mplayer.c | 167 +++++++++++++-------------------- src/gvars/gvars.c | 1 - src/include/game/game_0f09f0.h | 2 +- src/include/game/mplayer.h | 2 +- src/include/types.h | 2 + src/lib/main.c | 4 +- 9 files changed, 76 insertions(+), 110 deletions(-) diff --git a/src/game/game_0f09f0.c b/src/game/game_0f09f0.c index 0cf711d93..d5334834e 100644 --- a/src/game/game_0f09f0.c +++ b/src/game/game_0f09f0.c @@ -14009,9 +14009,9 @@ glabel menuIsDialogOpen /* f0fd64c: 27bd0008 */ addiu $sp,$sp,0x8 ); -bool currentPlayerGetUnk1c04(void) +struct chrdata *currentPlayerGetCommandingAibot(void) { - return g_Vars.currentplayer->unk1c04; + return g_Vars.currentplayer->commandingaibot; } struct menuitem menuitems_damagedcontrollerpak[] = { diff --git a/src/game/game_107fb0.c b/src/game/game_107fb0.c index 8c4690913..c3ae3c8cb 100644 --- a/src/game/game_107fb0.c +++ b/src/game/game_107fb0.c @@ -2195,7 +2195,7 @@ s32 filemgrMainMenuDialog(u32 operation, struct menudialog *dialog, union handle g_Menus[g_MpPlayerNum].data.filemgr.filetypeplusone = 0; func0f110c5c(0, FILETYPE_SOLO); - func0f188210(); + mpSetDefaultSetup(); // Set MP player names to "Player 1" through 4 if blank for (i = 0; i < 4; i++) { diff --git a/src/game/game_17f930.c b/src/game/game_17f930.c index 6321b09d4..5d544f8e8 100644 --- a/src/game/game_17f930.c +++ b/src/game/game_17f930.c @@ -6118,7 +6118,7 @@ glabel var7f1b89b8 /* f185f90: afa0001c */ sw $zero,0x1c($sp) /* f185f94: afa50034 */ sw $a1,0x34($sp) /* f185f98: afa00028 */ sw $zero,0x28($sp) -/* f185f9c: 0fc3f594 */ jal currentPlayerGetUnk1c04 +/* f185f9c: 0fc3f594 */ jal currentPlayerGetCommandingAibot /* f185fa0: afa00020 */ sw $zero,0x20($sp) /* f185fa4: 3c07800b */ lui $a3,%hi(g_MpSetup) /* f185fa8: 24e7cb88 */ addiu $a3,$a3,%lo(g_MpSetup) diff --git a/src/game/mplayer.c b/src/game/mplayer.c index 8e891b2eb..562957010 100644 --- a/src/game/mplayer.c +++ b/src/game/mplayer.c @@ -36,9 +36,6 @@ const char var7f1b8a00[] = "||||||||||||| Starting game... players %d\n"; const char var7f1b8a2c[] = "%s %d\n"; -const char var7f1b8a34[] = ""; -const char var7f1b8a38[] = "-mpwpnset"; -const char var7f1b8a44[] = "-mpwpnset"; /** * Converts the given value into a float on a curved scale from 0.1 to 10. @@ -427,8 +424,8 @@ glabel var7f1b8d94 /* f187d6c: ae790000 */ sw $t9,0x0($s3) .L0f187d70: /* f187d70: 2408ffff */ addiu $t0,$zero,-1 -/* f187d74: 3c01800b */ lui $at,%hi(var800acc24) -/* f187d78: ac28cc24 */ sw $t0,%lo(var800acc24)($at) +/* f187d74: 3c01800b */ lui $at,%hi(g_MpLockInfo+0x4) +/* f187d78: ac28cc24 */ sw $t0,%lo(g_MpLockInfo+0x4)($at) .L0f187d7c: /* f187d7c: 3c02800b */ lui $v0,%hi(g_ActiveMenuMpBotCommands) /* f187d80: 3c03800b */ lui $v1,%hi(g_ActiveMenuMpBotCommands+0x9) @@ -745,102 +742,70 @@ void func0f1881d4(s32 index) g_MpSimulants[index].difficulty = SIMDIFF_DISABLED; } -GLOBAL_ASM( -glabel func0f188210 -/* f188210: 3c02800b */ lui $v0,%hi(g_MpSetup) -/* f188214: 2442cb88 */ addiu $v0,$v0,%lo(g_MpSetup) -/* f188218: 3c0f001f */ lui $t7,0x1f -/* f18821c: 27bdffe0 */ addiu $sp,$sp,-32 -/* f188220: 240e0032 */ addiu $t6,$zero,0x32 -/* f188224: 35effe00 */ ori $t7,$t7,0xfe00 -/* f188228: afbf001c */ sw $ra,0x1c($sp) -/* f18822c: a0400010 */ sb $zero,0x10($v0) -/* f188230: a04e0011 */ sb $t6,0x11($v0) -/* f188234: ac4f000c */ sw $t7,0xc($v0) -/* f188238: 2418000a */ addiu $t8,$zero,0xa -/* f18823c: 3c01800a */ lui $at,%hi(g_Vars+0x484) -/* f188240: afb00018 */ sw $s0,0x18($sp) -/* f188244: 0fc61ffb */ jal func0f187fec -/* f188248: ac38a444 */ sw $t8,%lo(g_Vars+0x484)($at) -/* f18824c: 3c04800b */ lui $a0,%hi(g_MpSetup) -/* f188250: 2484cb88 */ addiu $a0,$a0,%lo(g_MpSetup) -/* f188254: 3c057f1c */ lui $a1,%hi(var7f1b8a34) -/* f188258: ac800020 */ sw $zero,0x20($a0) -/* f18825c: a4800024 */ sh $zero,0x24($a0) -/* f188260: 0c004c4c */ jal strcpy -/* f188264: 24a58a34 */ addiu $a1,$a1,%lo(var7f1b8a34) -/* f188268: 00008025 */ or $s0,$zero,$zero -/* f18826c: 02002025 */ or $a0,$s0,$zero -.L0f188270: -/* f188270: 0fc62003 */ jal func0f18800c -/* f188274: 00002825 */ or $a1,$zero,$zero -/* f188278: 26100001 */ addiu $s0,$s0,0x1 -/* f18827c: 2a010006 */ slti $at,$s0,0x6 -/* f188280: 5420fffb */ bnezl $at,.L0f188270 -/* f188284: 02002025 */ or $a0,$s0,$zero -/* f188288: 00008025 */ or $s0,$zero,$zero -.L0f18828c: -/* f18828c: 0fc62075 */ jal func0f1881d4 -/* f188290: 02002025 */ or $a0,$s0,$zero -/* f188294: 26100001 */ addiu $s0,$s0,0x1 -/* f188298: 2a010008 */ slti $at,$s0,0x8 -/* f18829c: 1420fffb */ bnez $at,.L0f18828c -/* f1882a0: 00000000 */ nop -/* f1882a4: 3c057f1c */ lui $a1,%hi(var7f1b8a38) -/* f1882a8: 24a58a38 */ addiu $a1,$a1,%lo(var7f1b8a38) -/* f1882ac: 0c004c04 */ jal func00013010 -/* f1882b0: 24040001 */ addiu $a0,$zero,0x1 -/* f1882b4: 10400009 */ beqz $v0,.L0f1882dc -/* f1882b8: 24040001 */ addiu $a0,$zero,0x1 -/* f1882bc: 3c057f1c */ lui $a1,%hi(var7f1b8a44) -/* f1882c0: 0c004c04 */ jal func00013010 -/* f1882c4: 24a58a44 */ addiu $a1,$a1,%lo(var7f1b8a44) -/* f1882c8: 90440000 */ lbu $a0,0x0($v0) -/* f1882cc: 0fc6256f */ jal mpSetWeaponSet -/* f1882d0: 2484ffd0 */ addiu $a0,$a0,-48 -/* f1882d4: 10000003 */ b .L0f1882e4 -/* f1882d8: 00000000 */ nop -.L0f1882dc: -/* f1882dc: 0fc6256f */ jal mpSetWeaponSet -/* f1882e0: 00002025 */ or $a0,$zero,$zero -.L0f1882e4: -/* f1882e4: 3c02800b */ lui $v0,%hi(g_MpLockInfo) -/* f1882e8: 2442cc20 */ addiu $v0,$v0,%lo(g_MpLockInfo) -/* f1882ec: 2403ffff */ addiu $v1,$zero,-1 -/* f1882f0: 3c04800a */ lui $a0,%hi(g_Vars) -/* f1882f4: 24849fc0 */ addiu $a0,$a0,%lo(g_Vars) -/* f1882f8: ac800314 */ sw $zero,0x314($a0) -/* f1882fc: ac800318 */ sw $zero,0x318($a0) -/* f188300: ac80031c */ sw $zero,0x31c($a0) -/* f188304: a0400000 */ sb $zero,0x0($v0) -/* f188308: a0430001 */ sb $v1,0x1($v0) -/* f18830c: a0430002 */ sb $v1,0x2($v0) -/* f188310: a0430003 */ sb $v1,0x3($v0) -/* f188314: 0fc66fe8 */ jal mpForceUnlockSimulantFeatures -/* f188318: ac430004 */ sw $v1,0x4($v0) -/* f18831c: 3c05800b */ lui $a1,%hi(g_MpPlayers) -/* f188320: 3c06800b */ lui $a2,%hi(g_ActiveMenuMpBotCommands) -/* f188324: 24c6cb78 */ addiu $a2,$a2,%lo(g_ActiveMenuMpBotCommands) -/* f188328: 24a5c7b8 */ addiu $a1,$a1,%lo(g_MpPlayers) -/* f18832c: 24040006 */ addiu $a0,$zero,0x6 -/* f188330: 00001025 */ or $v0,$zero,$zero -.L0f188334: -/* f188334: 00a01825 */ or $v1,$a1,$zero -.L0f188338: -/* f188338: 24420001 */ addiu $v0,$v0,0x1 -/* f18833c: 24630001 */ addiu $v1,$v1,0x1 -/* f188340: 1444fffd */ bne $v0,$a0,.L0f188338 -/* f188344: a0600096 */ sb $zero,0x96($v1) -/* f188348: 24a500a0 */ addiu $a1,$a1,0xa0 -/* f18834c: 54a6fff9 */ bnel $a1,$a2,.L0f188334 -/* f188350: 00001025 */ or $v0,$zero,$zero -/* f188354: 8fbf001c */ lw $ra,0x1c($sp) -/* f188358: 3c01800b */ lui $at,%hi(g_MpSetup+0x16) -/* f18835c: 8fb00018 */ lw $s0,0x18($sp) -/* f188360: a420cb9e */ sh $zero,%lo(g_MpSetup+0x16)($at) -/* f188364: 03e00008 */ jr $ra -/* f188368: 27bd0020 */ addiu $sp,$sp,0x20 -); +void mpSetDefaultSetup(void) +{ + s32 i; + s32 j; + + g_MpSetup.scenario = MPSCENARIO_COMBAT; + g_MpSetup.stagenum = STAGE_MP_SKEDAR; + g_MpSetup.options = MPOPTION_DISPLAYTEAM + | MPOPTION_KILLSSCORE + | MPOPTION_HTB_HIGHLIGHTBRIEFCASE + | MPOPTION_HTB_SHOWONRADAR + | MPOPTION_CTC_SHOWONRADAR + | MPOPTION_KOH_HILLONRADAR + | MPOPTION_KOH_MOBILEHILL + | MPOPTION_00010000 + | MPOPTION_HTM_HIGHLIGHTTERMINAL + | MPOPTION_HTM_SHOWONRADAR + | MPOPTION_PAC_HIGHLIGHTTARGET + | MPOPTION_PAC_SHOWONRADAR; + + g_Vars.mphilltime = 10; + + func0f187fec(); + + g_MpSetup.unk20.unk00 = 0; + g_MpSetup.unk20.unk04 = 0; + + strcpy(g_MpSetup.name, ""); + + for (i = 0; i < 6; i++) { + func0f18800c(i, false); + } + + for (i = 0; i < 8; i++) { + func0f1881d4(i); + } + + if (func00013010(1, "-mpwpnset")) { + char *value = func00013010(1, "-mpwpnset"); + mpSetWeaponSet(*value - 0x30); + } else { + mpSetWeaponSet(0); + } + + g_Vars.mplayerisrunning = false; + g_Vars.normmplayerisrunning = false; + g_Vars.lvmpbotlevel = 0; + + g_MpLockInfo.lockedplayernum = 0; + g_MpLockInfo.lastwinner = -1; + g_MpLockInfo.lastloser = -1; + g_MpLockInfo.unk03 = -1; + g_MpLockInfo.unk04 = -1; + + mpForceUnlockSimulantFeatures(); + + for (i = 0; i < ARRAYCOUNT(g_MpPlayers); i++) { + for (j = 0; j < 6; j++) { + g_MpPlayers[i].gunfuncs[j] = 0; + } + } + + g_MpSetup.chrslots = 0; +} void mpSetDefaultNamesIfEmpty(void) { diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index e03c58646..4827a18ad 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -17131,7 +17131,6 @@ struct mpsetup g_MpSetup = {0}; struct savefile_setup g_MpSetupSaveFile = {0}; u32 var800acc1c = 0; struct mplockinfo g_MpLockInfo = {0}; -u32 var800acc24 = 0; u32 var800acc28[18] = {0}; u32 var800acc70 = 0; u32 var800acc74 = 0; diff --git a/src/include/game/game_0f09f0.h b/src/include/game/game_0f09f0.h index da46edb84..b986646d2 100644 --- a/src/include/game/game_0f09f0.h +++ b/src/include/game/game_0f09f0.h @@ -82,7 +82,7 @@ u32 func0f0fd320(void); void func0f0fd494(struct coord *pos); void func0f0fd548(s32 arg0); bool menuIsDialogOpen(struct menudialog *dialog); -bool currentPlayerGetUnk1c04(void); +struct chrdata *currentPlayerGetCommandingAibot(void); extern const char var7f1b2658[]; extern const char var7f1b265c[]; diff --git a/src/include/game/mplayer.h b/src/include/game/mplayer.h index c9839a211..37cc89b86 100644 --- a/src/include/game/mplayer.h +++ b/src/include/game/mplayer.h @@ -12,7 +12,7 @@ void func0f187fbc(s32 playernum); void func0f187fec(void); void func0f18800c(s32 playernum, bool arg1); void func0f1881d4(s32 index); -void func0f188210(void); +void mpSetDefaultSetup(void); void mpSetDefaultNamesIfEmpty(void); u32 func0f18844c(void); void func0f188530(void); diff --git a/src/include/types.h b/src/include/types.h index 21790e681..31cfaecc9 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -6079,6 +6079,8 @@ struct mplockinfo { s8 lockedplayernum; s8 lastwinner; s8 lastloser; + s8 unk03; + s32 unk04; // might not be part of struct }; struct var8009da60 { diff --git a/src/lib/main.c b/src/lib/main.c index d846867d1..2a55e4bcc 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -561,7 +561,7 @@ glabel mainInit /* da64: 00000000 */ nop /* da68: 0fc00210 */ jal func0f000840 /* da6c: 00000000 */ nop -/* da70: 0fc62084 */ jal func0f188210 +/* da70: 0fc62084 */ jal mpSetDefaultSetup /* da74: 00000000 */ nop /* da78: 0fc528ca */ jal func0f14a328 /* da7c: 00000000 */ nop @@ -789,7 +789,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // func0f00b180(); // func0f000910(); // func0f000840(); -// func0f188210(); +// mpSetDefaultSetup(); // func0f14a328(); // func0f1189d8(); // func0f14a3bc();