From 48af4d190f8ce6dd1b4d66fd2d8bdc1e2ffcee21 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 10 Jan 2020 21:19:11 +1000 Subject: [PATCH] Decompile scenarioHtbKill --- src/game/game_176d70.c | 127 +++++++++++---------------------- src/game/game_187770.c | 4 +- src/game/pdoptions.c | 8 +-- src/gvars/gvars.c | 20 +----- src/include/game/game_176d70.h | 10 +-- src/include/gvars/gvars.h | 4 +- src/include/types.h | 58 +++------------ src/setup/setup_020df0.c | 10 +-- 8 files changed, 71 insertions(+), 170 deletions(-) diff --git a/src/game/game_176d70.c b/src/game/game_176d70.c index 8354d3e2c..b1c953152 100644 --- a/src/game/game_176d70.c +++ b/src/game/game_176d70.c @@ -3516,15 +3516,15 @@ s32 menuhandlerMpDisplayOptionCheckbox(u32 operation, struct menu_item *item, s3 { switch (operation) { case MENUOP_GET: - if ((g_MpPlayers[g_MpPlayerNum].displayoptions & item->param3) == 0) { + if ((g_MpPlayers[g_MpPlayerNum].base.displayoptions & item->param3) == 0) { return false; } return true; case MENUOP_SET: - g_MpPlayers[g_MpPlayerNum].displayoptions &= ~(u8)item->param3; + g_MpPlayers[g_MpPlayerNum].base.displayoptions &= ~(u8)item->param3; if (*value) { - g_MpPlayers[g_MpPlayerNum].displayoptions |= (u8)item->param3; + g_MpPlayers[g_MpPlayerNum].base.displayoptions |= (u8)item->param3; } break; } @@ -10594,83 +10594,38 @@ glabel scenarioHtbCallback18 /* f18095c: 27bd00a8 */ addiu $sp,$sp,0xa8 ); -GLOBAL_ASM( -glabel scenarioHtbCallback1c -/* f180960: afa7000c */ sw $a3,0xc($sp) -/* f180964: acc00000 */ sw $zero,0x0($a2) -/* f180968: 848e003e */ lh $t6,0x3e($a0) -/* f18096c: 3c08800b */ lui $t0,%hi(g_MpSetup) -/* f180970: 2508cb88 */ addiu $t0,$t0,%lo(g_MpSetup) -/* f180974: acce0000 */ sw $t6,0x0($a2) -/* f180978: 8d0f000c */ lw $t7,0xc($t0) -/* f18097c: 00001025 */ or $v0,$zero,$zero -/* f180980: 00801825 */ or $v1,$a0,$zero -/* f180984: 31f80400 */ andi $t8,$t7,0x400 -/* f180988: 13000033 */ beqz $t8,.L0f180a58 -/* f18098c: 240d004c */ addiu $t5,$zero,0x4c -/* f180990: 3c0c800b */ lui $t4,%hi(g_MpSimulants) -/* f180994: 3c0a800b */ lui $t2,%hi(g_MpPlayers) -/* f180998: 254ac7b8 */ addiu $t2,$t2,%lo(g_MpPlayers) -/* f18099c: 258cc538 */ addiu $t4,$t4,%lo(g_MpSimulants) -/* f1809a0: 240b00a0 */ addiu $t3,$zero,0xa0 -/* f1809a4: 2409000c */ addiu $t1,$zero,0xc -.L0f1809a8: -/* f1809a8: 54450007 */ bnel $v0,$a1,.L0f1809c8 -/* f1809ac: 8d18000c */ lw $t8,0xc($t0) -/* f1809b0: 8cd90000 */ lw $t9,0x0($a2) -/* f1809b4: 846e0024 */ lh $t6,0x24($v1) -/* f1809b8: 032e7823 */ subu $t7,$t9,$t6 -/* f1809bc: 10000023 */ beqz $zero,.L0f180a4c -/* f1809c0: accf0000 */ sw $t7,0x0($a2) -/* f1809c4: 8d18000c */ lw $t8,0xc($t0) -.L0f1809c8: -/* f1809c8: 28410004 */ slti $at,$v0,0x4 -/* f1809cc: 33190002 */ andi $t9,$t8,0x2 -/* f1809d0: 5320001b */ beqzl $t9,.L0f180a40 -/* f1809d4: 8cd80000 */ lw $t8,0x0($a2) -/* f1809d8: 10200006 */ beqz $at,.L0f1809f4 -/* f1809dc: 00000000 */ sll $zero,$zero,0x0 -/* f1809e0: 004b0019 */ multu $v0,$t3 -/* f1809e4: 00007012 */ mflo $t6 -/* f1809e8: 014e3821 */ addu $a3,$t2,$t6 -/* f1809ec: 10000006 */ beqz $zero,.L0f180a08 -/* f1809f0: 90980011 */ lbu $t8,0x11($a0) -.L0f1809f4: -/* f1809f4: 004d0019 */ multu $v0,$t5 -/* f1809f8: 00007812 */ mflo $t7 -/* f1809fc: 018f3821 */ addu $a3,$t4,$t7 -/* f180a00: 24e7fed0 */ addiu $a3,$a3,-304 -/* f180a04: 90980011 */ lbu $t8,0x11($a0) -.L0f180a08: -/* f180a08: 90f90011 */ lbu $t9,0x11($a3) -/* f180a0c: 57190007 */ bnel $t8,$t9,.L0f180a2c -/* f180a10: 8cd90000 */ lw $t9,0x0($a2) -/* f180a14: 8cce0000 */ lw $t6,0x0($a2) -/* f180a18: 846f0024 */ lh $t7,0x24($v1) -/* f180a1c: 01cfc023 */ subu $t8,$t6,$t7 -/* f180a20: 1000000a */ beqz $zero,.L0f180a4c -/* f180a24: acd80000 */ sw $t8,0x0($a2) -/* f180a28: 8cd90000 */ lw $t9,0x0($a2) -.L0f180a2c: -/* f180a2c: 846e0024 */ lh $t6,0x24($v1) -/* f180a30: 032e7821 */ addu $t7,$t9,$t6 -/* f180a34: 10000005 */ beqz $zero,.L0f180a4c -/* f180a38: accf0000 */ sw $t7,0x0($a2) -/* f180a3c: 8cd80000 */ lw $t8,0x0($a2) -.L0f180a40: -/* f180a40: 84790024 */ lh $t9,0x24($v1) -/* f180a44: 03197021 */ addu $t6,$t8,$t9 -/* f180a48: acce0000 */ sw $t6,0x0($a2) -.L0f180a4c: -/* f180a4c: 24420001 */ addiu $v0,$v0,0x1 -/* f180a50: 1449ffd5 */ bne $v0,$t1,.L0f1809a8 -/* f180a54: 24630002 */ addiu $v1,$v1,0x2 -.L0f180a58: -/* f180a58: 848f003c */ lh $t7,0x3c($a0) -/* f180a5c: 8fb8000c */ lw $t8,0xc($sp) -/* f180a60: 03e00008 */ jr $ra -/* f180a64: af0f0000 */ sw $t7,0x0($t8) -); +void scenarioHtbKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3) +{ + struct mpchr *loopmpchr; + s32 i; + + *score = 0; + *score = mpchr->unk3e; + + if (g_MpSetup.options & MPOPTION_KILLSSCORE) { + for (i = 0; i != 12; i++) { + if (i == arg1) { + *score -= mpchr->unk24[i]; + } else if (g_MpSetup.options & MPOPTION_TEAMSENABLED) { + if (i < 4) { + loopmpchr = &g_MpPlayers[i].base; + } else { + loopmpchr = &g_MpSimulants[i - 4].base; + } + + if (loopmpchr->team == mpchr->team) { + *score -= mpchr->unk24[i]; + } else { + *score += mpchr->unk24[i]; + } + } else { + *score += mpchr->unk24[i]; + } + } + } + + *arg3 = mpchr->unk3c; +} GLOBAL_ASM( glabel scenarioHtbCallback20 @@ -10861,8 +10816,8 @@ void scenarioCtcInit(void) basedata = &g_MpSimulants[k - 4].base; } - while (scenarioCallback30() <= basedata->unk11) { - basedata->unk11 -= scenarioCallback30(); + while (scenarioCallback30() <= basedata->team) { + basedata->team -= scenarioCallback30(); } } } @@ -11278,7 +11233,7 @@ glabel scenarioCtcReset ); GLOBAL_ASM( -glabel scenarioCtcCallback1c +glabel scenarioCtcKill /* f1813d8: afa7000c */ sw $a3,0xc($sp) /* f1813dc: acc00000 */ sw $zero,0x0($a2) /* f1813e0: 848e003e */ lh $t6,0x3e($a0) @@ -12721,7 +12676,7 @@ glabel scenarioKohCallback18 ); GLOBAL_ASM( -glabel scenarioKohCallback1c +glabel scenarioKohKill /* f182908: afa7000c */ sw $a3,0xc($sp) /* f18290c: acc00000 */ sw $zero,0x0($a2) /* f182910: 848e003e */ lh $t6,0x3e($a0) @@ -13910,7 +13865,7 @@ glabel scenarioHtmCallback18 ); GLOBAL_ASM( -glabel scenarioHtmCallback1c +glabel scenarioHtmKill /* f183bb4: 27bdffe0 */ addiu $sp,$sp,-32 /* f183bb8: afb10018 */ sw $s1,0x18($sp) /* f183bbc: afbf001c */ sw $ra,0x1c($sp) @@ -15145,7 +15100,7 @@ glabel scenarioPacCallback18 ); GLOBAL_ASM( -glabel scenarioPacCallback1c +glabel scenarioPacKill /* f184c18: 27bdffe0 */ addiu $sp,$sp,-32 /* f184c1c: afb10018 */ sw $s1,0x18($sp) /* f184c20: afbf001c */ sw $ra,0x1c($sp) diff --git a/src/game/game_187770.c b/src/game/game_187770.c index 96a34efe1..32be8c422 100644 --- a/src/game/game_187770.c +++ b/src/game/game_187770.c @@ -15145,8 +15145,8 @@ s32 func0f194724(struct chrdata *self, s32 arg1, bool includeself) s32 func0f194834(struct chrdata *chr) { - struct var800ac500 *thing = var800ac500[mpPlayerGetIndex(chr)]; - struct prop *prop = g_ScenarioData.htm.props[thing->propindex]; + struct mpchr *mpchr = var800ac500[mpPlayerGetIndex(chr)]; + struct prop *prop = g_ScenarioData.htm.props[mpchr->team]; return prop && (prop->type == PROPTYPE_CHR || prop->type == PROPTYPE_PLAYER); } diff --git a/src/game/pdoptions.c b/src/game/pdoptions.c index d20ded090..39bc0e05a 100644 --- a/src/game/pdoptions.c +++ b/src/game/pdoptions.c @@ -9,22 +9,22 @@ s32 optionsGetControlMode(s32 mpchrnum) { - return g_MpPlayers[mpchrnum].controlmode; + return g_MpPlayers[mpchrnum].base.controlmode; } void optionsSetControlMode(s32 mpchrnum, s32 mode) { - g_MpPlayers[mpchrnum].controlmode = mode; + g_MpPlayers[mpchrnum].base.controlmode = mode; } s32 optionsGetUnk45(s32 mpchrnum) { - return g_MpPlayers[mpchrnum].unk45; + return g_MpPlayers[mpchrnum].base.unk45; } s32 optionsGetUnk46(s32 mpchrnum) { - return g_MpPlayers[mpchrnum].unk46; + return g_MpPlayers[mpchrnum].base.unk46; } s32 optionsGetForwardPitch(s32 mpchrnum) diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index 59125532f..9f4eca6c7 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -30531,24 +30531,8 @@ u32 var800ac4c0 = 0; u32 var800ac4c4 = 0; u32 var800ac4c8 = 0; u32 var800ac4cc = 0; -struct chrdata *g_MpPlayerChrs[] = {NULL, NULL, NULL, NULL}; -u32 var800ac4e0 = 0; -u32 var800ac4e4 = 0; -u32 var800ac4e8 = 0; -u32 var800ac4ec = 0; -u32 var800ac4f0 = 0; -u32 var800ac4f4 = 0; -u32 var800ac4f8 = 0; -u32 var800ac4fc = 0; -struct var800ac500 *var800ac500[] = {NULL, NULL, NULL, NULL}; -u32 var800ac510 = 0; -u32 var800ac514 = 0; -u32 var800ac518 = 0; -u32 var800ac51c = 0; -u32 var800ac520 = 0; -u32 var800ac524 = 0; -u32 var800ac528 = 0; -u32 var800ac52c = 0; +struct chrdata *g_MpPlayerChrs[12] = {NULL}; +struct mpchr *var800ac500[12] = {NULL}; s32 g_MpNumPlayers = 0; u32 var800ac534 = 0; struct mpsim g_MpSimulants[8] = {0}; diff --git a/src/include/game/game_176d70.h b/src/include/game/game_176d70.h index 344f6c8ee..f0f374139 100644 --- a/src/include/game/game_176d70.h +++ b/src/include/game/game_176d70.h @@ -89,7 +89,7 @@ void scenarioHtbReset(void); void scenarioHtbCallback10(void); void scenarioHtbCallback14(struct chrdata *chr); u32 scenarioHtbCallback18(void); -u32 scenarioHtbCallback1c(void); +void scenarioHtbKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 scenarioHtbCallback20(s32 value); bool scenarioHtbCallback24(void *arg0, struct prop *prop); u32 scenarioHtbCallback28(void); @@ -98,7 +98,7 @@ s32 scenarioCtcCallback08(void); void scenarioCtcCallback10(void); void scenarioCtcCallback14(); void scenarioCtcReset(void); -u32 scenarioCtcCallback1c(void); +void scenarioCtcKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 scenarioCtcCallback20(s32 value); bool scenarioCtcCallback24(void *arg0, struct prop *prop); u32 scenarioCtcCallback28(void); @@ -113,7 +113,7 @@ void scenarioKohInit(void); void scenarioKohReset(void); void scenarioKohCallback10(void); u32 scenarioKohCallback18(void); -u32 scenarioKohCallback1c(void); +void scenarioKohKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 scenarioKohCallback20(s32 value); u32 func0f182aac(void); bool scenarioKohCallback34(s16 arg0); @@ -127,7 +127,7 @@ void scenarioHtmReset(void); void scenarioHtmCallback10(void); void scenarioHtmCallback14(struct chrdata *chr); u32 scenarioHtmCallback18(void); -u32 scenarioHtmCallback1c(void); +void scenarioHtmKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 scenarioHtmCallback20(s32 value); bool scenarioHtmCallback24(void *arg0, struct prop *prop); u32 scenarioHtmCallback28(void); @@ -139,7 +139,7 @@ void func0f1845bc(void); u32 func0f1847b8(void); void scenarioPacCallback10(void); u32 scenarioPacCallback18(void); -u32 scenarioPacCallback1c(void); +void scenarioPacKill(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 scenarioPacCallback20(s32 value); bool scenarioPacCallback24(void *arg0, struct prop *prop); u32 func0f184fb0(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 724197c5b..e66dfe114 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -832,8 +832,8 @@ extern u32 var800ac390; extern u32 var800ac3f8; extern u32 var800ac460; extern u32 var800ac4cc; -extern struct chrdata *g_MpPlayerChrs[4]; -extern struct var800ac500 *var800ac500[4]; +extern struct chrdata *g_MpPlayerChrs[12]; +extern struct mpchr *var800ac500[12]; extern s32 g_MpNumPlayers; extern struct mpsim g_MpSimulants[8]; extern u32 var800ac798[8]; diff --git a/src/include/types.h b/src/include/types.h index d1a4573cd..2363b2f22 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4015,27 +4015,23 @@ struct mpchr { /*0x0e*/ u8 unk0e; /*0x0f*/ u8 headnum; /*0x10*/ u8 bodynum; - /*0x11*/ u8 unk11; -}; - -struct mpplayer { - /*0x00*/ struct mpchr base; + /*0x11*/ u8 team; /*0x14*/ u32 displayoptions; /*0x18*/ u32 unk18; /*0x1c*/ u32 unk1c; /*0x20*/ u32 unk20; - /*0x24*/ u32 unk24; - /*0x28*/ u32 unk28; - /*0x2c*/ u32 unk2c; - /*0x30*/ u32 unk30; - /*0x34*/ u32 unk34; - /*0x38*/ u32 unk38; - /*0x3c*/ u32 unk3c; + /*0x24*/ s16 unk24[12]; + /*0x3c*/ s16 unk3c; + /*0x3c*/ s16 unk3e; /*0x40*/ u32 unk40; /*0x44*/ u8 controlmode; /*0x45*/ s8 unk45; /*0x46*/ s8 unk46; /*0x47*/ u8 unk47; +}; + +struct mpplayer { + /*0x00*/ struct mpchr base; /*0x48*/ u16 options; /*0x4c*/ u32 unk4c; /*0x50*/ u32 unk50; @@ -4063,19 +4059,6 @@ struct mpplayer { struct mpsim { /*0x00*/ struct mpchr base; - /*0x14*/ u32 unk14; - /*0x18*/ u32 unk18; - /*0x1c*/ u32 unk1c; - /*0x20*/ u32 unk20; - /*0x24*/ u32 unk24; - /*0x28*/ u32 unk28; - /*0x2c*/ u32 unk2c; - /*0x30*/ u32 unk30; - /*0x34*/ u32 unk34; - /*0x38*/ u32 unk38; - /*0x3c*/ u32 unk3c; - /*0x40*/ u32 unk40; - /*0x44*/ u32 unk44; /*0x48*/ u8 unk48; }; @@ -4131,7 +4114,7 @@ struct mpscenario { void (*unk10)(void); void (*unk14)(struct chrdata *chr); void *unk18; - void *unk1c; + void (*killfunc)(struct mpchr *mpchr, s32 arg1, s32 *score, s32 *arg3); s32 (*unk20)(s32 value); bool (*unk24)(void *arg0, struct prop *prop); void *unk28; @@ -4354,27 +4337,6 @@ struct challenge { /*0x18*/ u16 unk18; }; -struct var800ac500 { - u32 unk00; - u32 unk04; - u32 unk08; - u32 unk0c; - u8 unk10; - u8 propindex; - u32 unk14; - u32 unk18; - u32 unk1c; - u32 unk20; - u32 unk24; - u32 unk28; - u32 unk2c; - u32 unk30; - u32 unk34; - u32 unk38; - u16 unk3c; - s16 unk3e; -}; - struct scenariodata_cbt { u32 unk00; u32 unk04; @@ -4412,7 +4374,7 @@ struct scenariodata_htm { /*0x800ac15c*/ u32 unk04c; /*0x800ac160*/ u32 unk050; /*0x800ac164*/ u32 unk054; - /*0x800ac168*/ struct prop *props[4]; + /*0x800ac168*/ struct prop *props[4]; // probably a team list, not props /*0x800ac178*/ u32 unk068; /*0x800ac17c*/ u32 unk06c; /*0x800ac180*/ u32 unk070; diff --git a/src/setup/setup_020df0.c b/src/setup/setup_020df0.c index 03031333d..556f0e042 100644 --- a/src/setup/setup_020df0.c +++ b/src/setup/setup_020df0.c @@ -11548,11 +11548,11 @@ struct menu_dialog menudialog_mppopacapoptions = { // 2cfb8 struct mpscenario g_MpScenarios[] = { { &menudialog_mpcombatoptions, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { &menudialog_mpbriefcaseoptions, scenarioHtbInit, scenarioHtbCallback08, scenarioHtbReset, scenarioHtbCallback10, scenarioHtbCallback14, scenarioHtbCallback18, scenarioHtbCallback1c, scenarioHtbCallback20, scenarioHtbCallback24, scenarioHtbCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { &menudialog_mphackeroptions, scenarioHtmInit, scenarioHtmCallback08, scenarioHtmReset, scenarioHtmCallback10, scenarioHtmCallback14, scenarioHtmCallback18, scenarioHtmCallback1c, scenarioHtmCallback20, scenarioHtmCallback24, scenarioHtmCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { &menudialog_mppopacapoptions, scenarioPacInit, NULL, scenarioPacReset, scenarioPacCallback10, NULL, scenarioPacCallback18, scenarioPacCallback1c, scenarioPacCallback20, scenarioPacCallback24, scenarioPacCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { &menudialog_mphilloptions, scenarioKohInit, NULL, scenarioKohReset, scenarioKohCallback10, NULL, scenarioKohCallback18, scenarioKohCallback1c, scenarioKohCallback20, NULL, NULL, NULL, NULL, scenarioKohCallback34, scenarioKohCallback38, NULL, scenarioKohCallback40, scenarioKohCallback44 }, - { &menudialog_mpcaptureoptions, scenarioCtcInit, scenarioCtcCallback08, scenarioCtcReset, scenarioCtcCallback10, scenarioCtcCallback14, NULL, scenarioCtcCallback1c, scenarioCtcCallback20, scenarioCtcCallback24, scenarioCtcCallback28, scenarioCtcCallback2c, scenarioCtcCallback30, scenarioCtcCallback34, scenarioCtcCallback38, NULL, NULL, NULL }, + { &menudialog_mpbriefcaseoptions, scenarioHtbInit, scenarioHtbCallback08, scenarioHtbReset, scenarioHtbCallback10, scenarioHtbCallback14, scenarioHtbCallback18, scenarioHtbKill, scenarioHtbCallback20, scenarioHtbCallback24, scenarioHtbCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { &menudialog_mphackeroptions, scenarioHtmInit, scenarioHtmCallback08, scenarioHtmReset, scenarioHtmCallback10, scenarioHtmCallback14, scenarioHtmCallback18, scenarioHtmKill, scenarioHtmCallback20, scenarioHtmCallback24, scenarioHtmCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { &menudialog_mppopacapoptions, scenarioPacInit, NULL, scenarioPacReset, scenarioPacCallback10, NULL, scenarioPacCallback18, scenarioPacKill, scenarioPacCallback20, scenarioPacCallback24, scenarioPacCallback28, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { &menudialog_mphilloptions, scenarioKohInit, NULL, scenarioKohReset, scenarioKohCallback10, NULL, scenarioKohCallback18, scenarioKohKill, scenarioKohCallback20, NULL, NULL, NULL, NULL, scenarioKohCallback34, scenarioKohCallback38, NULL, scenarioKohCallback40, scenarioKohCallback44 }, + { &menudialog_mpcaptureoptions, scenarioCtcInit, scenarioCtcCallback08, scenarioCtcReset, scenarioCtcCallback10, scenarioCtcCallback14, NULL, scenarioCtcKill, scenarioCtcCallback20, scenarioCtcCallback24, scenarioCtcCallback28, scenarioCtcCallback2c, scenarioCtcCallback30, scenarioCtcCallback34, scenarioCtcCallback38, NULL, NULL, NULL }, }; // 2d168