From d65cd9115bc0ebaa05fffaa45a9f393c95f67762 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 10 Jan 2022 18:52:45 +1000 Subject: [PATCH] Decompile mpApplyWeaponSet --- src/game/mplayer/mplayer.c | 479 ++++------------------------- src/include/constants.h | 4 + src/include/game/mplayer/mplayer.h | 2 +- 3 files changed, 70 insertions(+), 415 deletions(-) diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 6807cc0d9..24600d9f2 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -45,7 +45,7 @@ struct modelfiledata *var800acc28[18]; // Forward declaractions struct mpweaponset g_MpWeaponSets[12]; -s32 var800874c8; +s32 g_MpWeaponSetNum; #if VERSION >= VERSION_NTSC_1_0 const char var7f1b8a00[] = "||||||||||||| Starting game... players %d\n"; @@ -1079,438 +1079,89 @@ void func0f18913c(void) if (ok) { done = true; - var800874c8 = i; + g_MpWeaponSetNum = i; } } } if (!done) { - var800874c8 = 14; + g_MpWeaponSetNum = WEAPONSET_CUSTOM; } } -#if VERSION >= VERSION_NTSC_1_0 -GLOBAL_ASM( -glabel func0f1892dc -/* f1892dc: 27bdffb0 */ addiu $sp,$sp,-80 -/* f1892e0: afb00018 */ sw $s0,0x18($sp) -/* f1892e4: 3c108008 */ lui $s0,%hi(var800874c8) -/* f1892e8: 261074c8 */ addiu $s0,$s0,%lo(var800874c8) -/* f1892ec: 8e020000 */ lw $v0,0x0($s0) -/* f1892f0: afbf001c */ sw $ra,0x1c($sp) -/* f1892f4: 04400077 */ bltz $v0,.L0f1894d4 -/* f1892f8: 2841000c */ slti $at,$v0,0xc -/* f1892fc: 10200075 */ beqz $at,.L0f1894d4 -/* f189300: 000270c0 */ sll $t6,$v0,0x3 -/* f189304: 01c27021 */ addu $t6,$t6,$v0 -/* f189308: 000e7040 */ sll $t6,$t6,0x1 -/* f18930c: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0x8) -/* f189310: 008e2021 */ addu $a0,$a0,$t6 -/* f189314: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189318: 908473f8 */ lbu $a0,%lo(g_MpWeaponSets+0x8)($a0) -/* f18931c: 50400029 */ beqzl $v0,.L0f1893c4 -/* f189320: 8e0d0000 */ lw $t5,0x0($s0) -/* f189324: 8e0f0000 */ lw $t7,0x0($s0) -/* f189328: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0x9) -/* f18932c: 000fc0c0 */ sll $t8,$t7,0x3 -/* f189330: 030fc021 */ addu $t8,$t8,$t7 -/* f189334: 0018c040 */ sll $t8,$t8,0x1 -/* f189338: 00982021 */ addu $a0,$a0,$t8 -/* f18933c: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189340: 908473f9 */ lbu $a0,%lo(g_MpWeaponSets+0x9)($a0) -/* f189344: 5040001f */ beqzl $v0,.L0f1893c4 -/* f189348: 8e0d0000 */ lw $t5,0x0($s0) -/* f18934c: 8e190000 */ lw $t9,0x0($s0) -/* f189350: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0xa) -/* f189354: 001960c0 */ sll $t4,$t9,0x3 -/* f189358: 01996021 */ addu $t4,$t4,$t9 -/* f18935c: 000c6040 */ sll $t4,$t4,0x1 -/* f189360: 008c2021 */ addu $a0,$a0,$t4 -/* f189364: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189368: 908473fa */ lbu $a0,%lo(g_MpWeaponSets+0xa)($a0) -/* f18936c: 50400015 */ beqzl $v0,.L0f1893c4 -/* f189370: 8e0d0000 */ lw $t5,0x0($s0) -/* f189374: 8e0d0000 */ lw $t5,0x0($s0) -/* f189378: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0xb) -/* f18937c: 000d70c0 */ sll $t6,$t5,0x3 -/* f189380: 01cd7021 */ addu $t6,$t6,$t5 -/* f189384: 000e7040 */ sll $t6,$t6,0x1 -/* f189388: 008e2021 */ addu $a0,$a0,$t6 -/* f18938c: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189390: 908473fb */ lbu $a0,%lo(g_MpWeaponSets+0xb)($a0) -/* f189394: 5040000b */ beqzl $v0,.L0f1893c4 -/* f189398: 8e0d0000 */ lw $t5,0x0($s0) -/* f18939c: 8e0f0000 */ lw $t7,0x0($s0) -/* f1893a0: 3c0c8008 */ lui $t4,%hi(g_MpWeaponSets) -/* f1893a4: 258c73f0 */ addiu $t4,$t4,%lo(g_MpWeaponSets) -/* f1893a8: 000fc0c0 */ sll $t8,$t7,0x3 -/* f1893ac: 030fc021 */ addu $t8,$t8,$t7 -/* f1893b0: 0018c040 */ sll $t8,$t8,0x1 -/* f1893b4: 27190002 */ addiu $t9,$t8,0x2 -/* f1893b8: 1000000f */ b .L0f1893f8 -/* f1893bc: 032c1021 */ addu $v0,$t9,$t4 -/* f1893c0: 8e0d0000 */ lw $t5,0x0($s0) -.L0f1893c4: -/* f1893c4: 3c0f8008 */ lui $t7,%hi(g_MpWeaponSets) -/* f1893c8: 25ef73f0 */ addiu $t7,$t7,%lo(g_MpWeaponSets) -/* f1893cc: 000d70c0 */ sll $t6,$t5,0x3 -/* f1893d0: 01cd7021 */ addu $t6,$t6,$t5 -/* f1893d4: 000e7040 */ sll $t6,$t6,0x1 -/* f1893d8: 01cf1821 */ addu $v1,$t6,$t7 -/* f1893dc: 9078000c */ lbu $t8,0xc($v1) -/* f1893e0: 2401005c */ addiu $at,$zero,0x5c -/* f1893e4: 53010004 */ beql $t8,$at,.L0f1893f8 -/* f1893e8: 00001025 */ or $v0,$zero,$zero -/* f1893ec: 10000002 */ b .L0f1893f8 -/* f1893f0: 2462000c */ addiu $v0,$v1,0xc -/* f1893f4: 00001025 */ or $v0,$zero,$zero -.L0f1893f8: -/* f1893f8: 1040006b */ beqz $v0,.L0f1895a8 -/* f1893fc: 00405825 */ or $t3,$v0,$zero -/* f189400: 3c0a800b */ lui $t2,%hi(g_MpSetup) -/* f189404: 3c088008 */ lui $t0,%hi(g_MpWeapons) -/* f189408: 25087268 */ addiu $t0,$t0,%lo(g_MpWeapons) -/* f18940c: 254acb88 */ addiu $t2,$t2,%lo(g_MpSetup) -/* f189410: 2410005b */ addiu $s0,$zero,0x5b -/* f189414: 2409000a */ addiu $t1,$zero,0xa -.L0f189418: -/* f189418: 91660000 */ lbu $a2,0x0($t3) -/* f18941c: 00002825 */ or $a1,$zero,$zero -/* f189420: 00003825 */ or $a3,$zero,$zero -/* f189424: 14d00014 */ bne $a2,$s0,.L0f189478 -/* f189428: 00001825 */ or $v1,$zero,$zero -/* f18942c: 24040016 */ addiu $a0,$zero,0x16 -/* f189430: afa00044 */ sw $zero,0x44($sp) -/* f189434: afa00040 */ sw $zero,0x40($sp) -/* f189438: afa60038 */ sw $a2,0x38($sp) -/* f18943c: afa0003c */ sw $zero,0x3c($sp) -/* f189440: afaa0024 */ sw $t2,0x24($sp) -/* f189444: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189448: afab0028 */ sw $t3,0x28($sp) -/* f18944c: 3c088008 */ lui $t0,%hi(g_MpWeapons) -/* f189450: 25087268 */ addiu $t0,$t0,%lo(g_MpWeapons) -/* f189454: 8fa30044 */ lw $v1,0x44($sp) -/* f189458: 8fa50040 */ lw $a1,0x40($sp) -/* f18945c: 8fa60038 */ lw $a2,0x38($sp) -/* f189460: 8fa7003c */ lw $a3,0x3c($sp) -/* f189464: 2409000a */ addiu $t1,$zero,0xa -/* f189468: 8faa0024 */ lw $t2,0x24($sp) -/* f18946c: 14400002 */ bnez $v0,.L0f189478 -/* f189470: 8fab0028 */ lw $t3,0x28($sp) -/* f189474: 00003025 */ or $a2,$zero,$zero -.L0f189478: -/* f189478: 2c610027 */ sltiu $at,$v1,0x27 -/* f18947c: 14200003 */ bnez $at,.L0f18948c -/* f189480: 00000000 */ nop -/* f189484: 10000009 */ b .L0f1894ac -/* f189488: 24050001 */ addiu $a1,$zero,0x1 -.L0f18948c: -/* f18948c: 00690019 */ multu $v1,$t1 -/* f189490: 0000c812 */ mflo $t9 -/* f189494: 01196021 */ addu $t4,$t0,$t9 -/* f189498: 918d0000 */ lbu $t5,0x0($t4) -/* f18949c: 14cd0003 */ bne $a2,$t5,.L0f1894ac -/* f1894a0: 00000000 */ nop -/* f1894a4: 00603825 */ or $a3,$v1,$zero -/* f1894a8: 24050001 */ addiu $a1,$zero,0x1 -.L0f1894ac: -/* f1894ac: 10a0fff2 */ beqz $a1,.L0f189478 -/* f1894b0: 24630001 */ addiu $v1,$v1,0x1 -/* f1894b4: 3c0e800b */ lui $t6,%hi(g_MpSetup+0x6) -/* f1894b8: 25cecb8e */ addiu $t6,$t6,%lo(g_MpSetup+0x6) -/* f1894bc: 254a0001 */ addiu $t2,$t2,0x1 -/* f1894c0: 256b0001 */ addiu $t3,$t3,0x1 -/* f1894c4: 154effd4 */ bne $t2,$t6,.L0f189418 -/* f1894c8: a1470017 */ sb $a3,0x17($t2) -/* f1894cc: 10000037 */ b .L0f1895ac -/* f1894d0: 8fbf001c */ lw $ra,0x1c($sp) -.L0f1894d4: -/* f1894d4: 2401000d */ addiu $at,$zero,0xd -/* f1894d8: 54410017 */ bnel $v0,$at,.L0f189538 -/* f1894dc: 2401000c */ addiu $at,$zero,0xc -/* f1894e0: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f1894e4: 00000000 */ nop -/* f1894e8: afa20034 */ sw $v0,0x34($sp) -/* f1894ec: 00008025 */ or $s0,$zero,$zero -.L0f1894f0: -/* f1894f0: 0c004b70 */ jal random -/* f1894f4: 00000000 */ nop -/* f1894f8: 8faf0034 */ lw $t7,0x34($sp) -/* f1894fc: 02002025 */ or $a0,$s0,$zero -/* f189500: 004f001b */ divu $zero,$v0,$t7 -/* f189504: 00002810 */ mfhi $a1 -/* f189508: 15e00002 */ bnez $t7,.L0f189514 -/* f18950c: 00000000 */ nop -/* f189510: 0007000d */ break 0x7 -.L0f189514: -/* f189514: 0fc62346 */ jal mpSetWeaponSlot -/* f189518: 00000000 */ nop -/* f18951c: 26100001 */ addiu $s0,$s0,0x1 -/* f189520: 24010006 */ addiu $at,$zero,0x6 -/* f189524: 1601fff2 */ bne $s0,$at,.L0f1894f0 -/* f189528: 00000000 */ nop -/* f18952c: 1000001f */ b .L0f1895ac -/* f189530: 8fbf001c */ lw $ra,0x1c($sp) -/* f189534: 2401000c */ addiu $at,$zero,0xc -.L0f189538: -/* f189538: 5441001c */ bnel $v0,$at,.L0f1895ac -/* f18953c: 8fbf001c */ lw $ra,0x1c($sp) -/* f189540: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f189544: 00000000 */ nop -/* f189548: 2458fffe */ addiu $t8,$v0,-2 -/* f18954c: afb80030 */ sw $t8,0x30($sp) -/* f189550: 00008025 */ or $s0,$zero,$zero -.L0f189554: -/* f189554: 0c004b70 */ jal random -/* f189558: 00000000 */ nop -/* f18955c: 8fb90030 */ lw $t9,0x30($sp) -/* f189560: 02002025 */ or $a0,$s0,$zero -/* f189564: 0059001b */ divu $zero,$v0,$t9 -/* f189568: 00002810 */ mfhi $a1 -/* f18956c: 24a50001 */ addiu $a1,$a1,0x1 -/* f189570: 17200002 */ bnez $t9,.L0f18957c -/* f189574: 00000000 */ nop -/* f189578: 0007000d */ break 0x7 -.L0f18957c: -/* f18957c: 0fc62346 */ jal mpSetWeaponSlot -/* f189580: 00000000 */ nop -/* f189584: 26100001 */ addiu $s0,$s0,0x1 -/* f189588: 24010005 */ addiu $at,$zero,0x5 -/* f18958c: 1601fff1 */ bne $s0,$at,.L0f189554 -/* f189590: 00000000 */ nop -/* f189594: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f189598: 00000000 */ nop -/* f18959c: 02002025 */ or $a0,$s0,$zero -/* f1895a0: 0fc62346 */ jal mpSetWeaponSlot -/* f1895a4: 2445ffff */ addiu $a1,$v0,-1 -.L0f1895a8: -/* f1895a8: 8fbf001c */ lw $ra,0x1c($sp) -.L0f1895ac: -/* f1895ac: 8fb00018 */ lw $s0,0x18($sp) -/* f1895b0: 27bd0050 */ addiu $sp,$sp,0x50 -/* f1895b4: 03e00008 */ jr $ra -/* f1895b8: 00000000 */ nop -); -#else -GLOBAL_ASM( -glabel func0f1892dc -/* f1892dc: 27bdffb0 */ addiu $sp,$sp,-80 -/* f1892e0: afb00018 */ sw $s0,0x18($sp) -/* f1892e4: 3c108008 */ lui $s0,%hi(var800874c8) -/* f1892e8: 261074c8 */ addiu $s0,$s0,%lo(var800874c8) -/* f1892ec: 8e020000 */ lw $v0,0x0($s0) -/* f1892f0: afbf001c */ sw $ra,0x1c($sp) -/* f1892f4: 04400077 */ bltz $v0,.L0f1894d4 -/* f1892f8: 2841000c */ slti $at,$v0,0xc -/* f1892fc: 10200075 */ beqz $at,.L0f1894d4 -/* f189300: 000270c0 */ sll $t6,$v0,0x3 -/* f189304: 01c27021 */ addu $t6,$t6,$v0 -/* f189308: 000e7040 */ sll $t6,$t6,0x1 -/* f18930c: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0x8) -/* f189310: 008e2021 */ addu $a0,$a0,$t6 -/* f189314: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189318: 908473f8 */ lbu $a0,%lo(g_MpWeaponSets+0x8)($a0) -/* f18931c: 50400029 */ beqzl $v0,.L0f1893c4 -/* f189320: 8e0d0000 */ lw $t5,0x0($s0) -/* f189324: 8e0f0000 */ lw $t7,0x0($s0) -/* f189328: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0x9) -/* f18932c: 000fc0c0 */ sll $t8,$t7,0x3 -/* f189330: 030fc021 */ addu $t8,$t8,$t7 -/* f189334: 0018c040 */ sll $t8,$t8,0x1 -/* f189338: 00982021 */ addu $a0,$a0,$t8 -/* f18933c: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189340: 908473f9 */ lbu $a0,%lo(g_MpWeaponSets+0x9)($a0) -/* f189344: 5040001f */ beqzl $v0,.L0f1893c4 -/* f189348: 8e0d0000 */ lw $t5,0x0($s0) -/* f18934c: 8e190000 */ lw $t9,0x0($s0) -/* f189350: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0xa) -/* f189354: 001960c0 */ sll $t4,$t9,0x3 -/* f189358: 01996021 */ addu $t4,$t4,$t9 -/* f18935c: 000c6040 */ sll $t4,$t4,0x1 -/* f189360: 008c2021 */ addu $a0,$a0,$t4 -/* f189364: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189368: 908473fa */ lbu $a0,%lo(g_MpWeaponSets+0xa)($a0) -/* f18936c: 50400015 */ beqzl $v0,.L0f1893c4 -/* f189370: 8e0d0000 */ lw $t5,0x0($s0) -/* f189374: 8e0d0000 */ lw $t5,0x0($s0) -/* f189378: 3c048008 */ lui $a0,%hi(g_MpWeaponSets+0xb) -/* f18937c: 000d70c0 */ sll $t6,$t5,0x3 -/* f189380: 01cd7021 */ addu $t6,$t6,$t5 -/* f189384: 000e7040 */ sll $t6,$t6,0x1 -/* f189388: 008e2021 */ addu $a0,$a0,$t6 -/* f18938c: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189390: 908473fb */ lbu $a0,%lo(g_MpWeaponSets+0xb)($a0) -/* f189394: 5040000b */ beqzl $v0,.L0f1893c4 -/* f189398: 8e0d0000 */ lw $t5,0x0($s0) -/* f18939c: 8e0f0000 */ lw $t7,0x0($s0) -/* f1893a0: 3c0c8008 */ lui $t4,%hi(g_MpWeaponSets) -/* f1893a4: 258c73f0 */ addiu $t4,$t4,%lo(g_MpWeaponSets) -/* f1893a8: 000fc0c0 */ sll $t8,$t7,0x3 -/* f1893ac: 030fc021 */ addu $t8,$t8,$t7 -/* f1893b0: 0018c040 */ sll $t8,$t8,0x1 -/* f1893b4: 27190002 */ addiu $t9,$t8,0x2 -/* f1893b8: 1000000f */ b .L0f1893f8 -/* f1893bc: 032c1021 */ addu $v0,$t9,$t4 -/* f1893c0: 8e0d0000 */ lw $t5,0x0($s0) -.L0f1893c4: -/* f1893c4: 3c0f8008 */ lui $t7,%hi(g_MpWeaponSets) -/* f1893c8: 25ef73f0 */ addiu $t7,$t7,%lo(g_MpWeaponSets) -/* f1893cc: 000d70c0 */ sll $t6,$t5,0x3 -/* f1893d0: 01cd7021 */ addu $t6,$t6,$t5 -/* f1893d4: 000e7040 */ sll $t6,$t6,0x1 -/* f1893d8: 01cf1821 */ addu $v1,$t6,$t7 -/* f1893dc: 9078000c */ lbu $t8,0xc($v1) -/* f1893e0: 2401005c */ addiu $at,$zero,0x5b -/* f1893e4: 53010004 */ beql $t8,$at,.L0f1893f8 -/* f1893e8: 00001025 */ or $v0,$zero,$zero -/* f1893ec: 10000002 */ b .L0f1893f8 -/* f1893f0: 2462000c */ addiu $v0,$v1,0xc -/* f1893f4: 00001025 */ or $v0,$zero,$zero -.L0f1893f8: -/* f1893f8: 1040006b */ beqz $v0,.L0f1895a8 -/* f1893fc: 00405825 */ or $t3,$v0,$zero -/* f189400: 3c0a800b */ lui $t2,%hi(g_MpSetup) -/* f189404: 3c088008 */ lui $t0,%hi(g_MpWeapons) -/* f189408: 25087268 */ addiu $t0,$t0,%lo(g_MpWeapons) -/* f18940c: 254acb88 */ addiu $t2,$t2,%lo(g_MpSetup) -/* f189410: 2410005b */ addiu $s0,$zero,0x5a -/* f189414: 2409000a */ addiu $t1,$zero,0xa -.L0f189418: -/* f189418: 91660000 */ lbu $a2,0x0($t3) -/* f18941c: 00002825 */ or $a1,$zero,$zero -/* f189420: 00003825 */ or $a3,$zero,$zero -/* f189424: 14d00014 */ bne $a2,$s0,.L0f189478 -/* f189428: 00001825 */ or $v1,$zero,$zero -/* f18942c: 24040016 */ addiu $a0,$zero,0x16 -/* f189430: afa00044 */ sw $zero,0x44($sp) -/* f189434: afa00040 */ sw $zero,0x40($sp) -/* f189438: afa60038 */ sw $a2,0x38($sp) -/* f18943c: afa0003c */ sw $zero,0x3c($sp) -/* f189440: afaa0024 */ sw $t2,0x24($sp) -/* f189444: 0fc67244 */ jal mpIsFeatureUnlocked -/* f189448: afab0028 */ sw $t3,0x28($sp) -/* f18944c: 3c088008 */ lui $t0,%hi(g_MpWeapons) -/* f189450: 25087268 */ addiu $t0,$t0,%lo(g_MpWeapons) -/* f189454: 8fa30044 */ lw $v1,0x44($sp) -/* f189458: 8fa50040 */ lw $a1,0x40($sp) -/* f18945c: 8fa60038 */ lw $a2,0x38($sp) -/* f189460: 8fa7003c */ lw $a3,0x3c($sp) -/* f189464: 2409000a */ addiu $t1,$zero,0xa -/* f189468: 8faa0024 */ lw $t2,0x24($sp) -/* f18946c: 14400002 */ bnez $v0,.L0f189478 -/* f189470: 8fab0028 */ lw $t3,0x28($sp) -/* f189474: 00003025 */ or $a2,$zero,$zero -.L0f189478: -/* f189478: 2c610027 */ sltiu $at,$v1,0x27 -/* f18947c: 14200003 */ bnez $at,.L0f18948c -/* f189480: 00000000 */ nop -/* f189484: 10000009 */ b .L0f1894ac -/* f189488: 24050001 */ addiu $a1,$zero,0x1 -.L0f18948c: -/* f18948c: 00690019 */ multu $v1,$t1 -/* f189490: 0000c812 */ mflo $t9 -/* f189494: 01196021 */ addu $t4,$t0,$t9 -/* f189498: 918d0000 */ lbu $t5,0x0($t4) -/* f18949c: 14cd0003 */ bne $a2,$t5,.L0f1894ac -/* f1894a0: 00000000 */ nop -/* f1894a4: 00603825 */ or $a3,$v1,$zero -/* f1894a8: 24050001 */ addiu $a1,$zero,0x1 -.L0f1894ac: -/* f1894ac: 10a0fff2 */ beqz $a1,.L0f189478 -/* f1894b0: 24630001 */ addiu $v1,$v1,0x1 -/* f1894b4: 3c0e800b */ lui $t6,%hi(g_MpSetup+0x6) -/* f1894b8: 25cecb8e */ addiu $t6,$t6,%lo(g_MpSetup+0x6) -/* f1894bc: 254a0001 */ addiu $t2,$t2,0x1 -/* f1894c0: 256b0001 */ addiu $t3,$t3,0x1 -/* f1894c4: 154effd4 */ bne $t2,$t6,.L0f189418 -/* f1894c8: a1470017 */ sb $a3,0x17($t2) -/* f1894cc: 10000037 */ b .L0f1895ac -/* f1894d0: 8fbf001c */ lw $ra,0x1c($sp) -.L0f1894d4: -/* f1894d4: 2401000d */ addiu $at,$zero,0xd -/* f1894d8: 54410017 */ bnel $v0,$at,.L0f189538 -/* f1894dc: 2401000c */ addiu $at,$zero,0xc -/* f1894e0: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f1894e4: 00000000 */ nop -/* f1894e8: afa20034 */ sw $v0,0x34($sp) -/* f1894ec: 00008025 */ or $s0,$zero,$zero -.L0f1894f0: -/* f1894f0: 0c004b70 */ jal random -/* f1894f4: 00000000 */ nop -/* f1894f8: 8faf0034 */ lw $t7,0x34($sp) -/* f1894fc: 02002025 */ or $a0,$s0,$zero -/* f189500: 004f001b */ divu $zero,$v0,$t7 -/* f189504: 00002810 */ mfhi $a1 -/* f189508: 15e00002 */ bnez $t7,.L0f189514 -/* f18950c: 00000000 */ nop -/* f189510: 0007000d */ break 0x7 -.L0f189514: -/* f189514: 0fc62346 */ jal mpSetWeaponSlot -/* f189518: 00000000 */ nop -/* f18951c: 26100001 */ addiu $s0,$s0,0x1 -/* f189520: 24010006 */ addiu $at,$zero,0x6 -/* f189524: 1601fff2 */ bne $s0,$at,.L0f1894f0 -/* f189528: 00000000 */ nop -/* f18952c: 1000001f */ b .L0f1895ac -/* f189530: 8fbf001c */ lw $ra,0x1c($sp) -/* f189534: 2401000c */ addiu $at,$zero,0xc -.L0f189538: -/* f189538: 5441001c */ bnel $v0,$at,.L0f1895ac -/* f18953c: 8fbf001c */ lw $ra,0x1c($sp) -/* f189540: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f189544: 00000000 */ nop -/* f189548: 2458fffe */ addiu $t8,$v0,-2 -/* f18954c: afb80030 */ sw $t8,0x30($sp) -/* f189550: 00008025 */ or $s0,$zero,$zero -.L0f189554: -/* f189554: 0c004b70 */ jal random -/* f189558: 00000000 */ nop -/* f18955c: 8fb90030 */ lw $t9,0x30($sp) -/* f189560: 02002025 */ or $a0,$s0,$zero -/* f189564: 0059001b */ divu $zero,$v0,$t9 -/* f189568: 00002810 */ mfhi $a1 -/* f18956c: 24a50001 */ addiu $a1,$a1,0x1 -/* f189570: 17200002 */ bnez $t9,.L0f18957c -/* f189574: 00000000 */ nop -/* f189578: 0007000d */ break 0x7 -.L0f18957c: -/* f18957c: 0fc62346 */ jal mpSetWeaponSlot -/* f189580: 00000000 */ nop -/* f189584: 26100001 */ addiu $s0,$s0,0x1 -/* f189588: 24010005 */ addiu $at,$zero,0x5 -/* f18958c: 1601fff1 */ bne $s0,$at,.L0f189554 -/* f189590: 00000000 */ nop -/* f189594: 0fc622f5 */ jal mpGetNumWeaponOptions -/* f189598: 00000000 */ nop -/* f18959c: 02002025 */ or $a0,$s0,$zero -/* f1895a0: 0fc62346 */ jal mpSetWeaponSlot -/* f1895a4: 2445ffff */ addiu $a1,$v0,-1 -.L0f1895a8: -/* f1895a8: 8fbf001c */ lw $ra,0x1c($sp) -.L0f1895ac: -/* f1895ac: 8fb00018 */ lw $s0,0x18($sp) -/* f1895b0: 27bd0050 */ addiu $sp,$sp,0x50 -/* f1895b4: 03e00008 */ jr $ra -/* f1895b8: 00000000 */ nop -); -#endif +void mpApplyWeaponSet(void) +{ + s32 i; + u8 *ptr; + + if (g_MpWeaponSetNum >= 0 && g_MpWeaponSetNum < 12) { + if (mpIsFeatureUnlocked(g_MpWeaponSets[g_MpWeaponSetNum].requirefeatures[0]) + && mpIsFeatureUnlocked(g_MpWeaponSets[g_MpWeaponSetNum].requirefeatures[1]) + && mpIsFeatureUnlocked(g_MpWeaponSets[g_MpWeaponSetNum].requirefeatures[2]) + && mpIsFeatureUnlocked(g_MpWeaponSets[g_MpWeaponSetNum].requirefeatures[3])) { + ptr = &g_MpWeaponSets[g_MpWeaponSetNum].slots[0]; + } else if (g_MpWeaponSets[g_MpWeaponSetNum].unk0c != WEAPON_DISABLED) { + ptr = &g_MpWeaponSets[g_MpWeaponSetNum].unk0c; + } else { + ptr = NULL; + } + + if (ptr != NULL) { + for (i = 0; i < 6; i++) { + u32 j; + bool done = false; + s32 mpweaponnum = MPWEAPON_NONE; + s32 weaponnum = ptr[i]; + + if (weaponnum == WEAPON_MPSHIELD && !mpIsFeatureUnlocked(MPFEATURE_WEAPON_SHIELD)) { + weaponnum = 0; + } + + for (j = 0; !done; j++) { + if (j > MPWEAPON_DISABLED) { + done = true; + } else if (weaponnum == g_MpWeapons[j].weaponnum) { + mpweaponnum = j; + done = true; + } + } + + g_MpSetup.weapons[i] = mpweaponnum; + } + } + } else if (g_MpWeaponSetNum == WEAPONSET_RANDOM) { + s32 numoptions = mpGetNumWeaponOptions(); + + for (i = 0; i < 6; i++) { + mpSetWeaponSlot(i, random() % numoptions); + } + } else if (g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { + s32 numoptions = mpGetNumWeaponOptions() - 2; + + for (i = 0; i < 5; i++) { + mpSetWeaponSlot(i, random() % numoptions + 1); + } + + mpSetWeaponSlot(i, mpGetNumWeaponOptions() - 1); + } +} void mpSetWeaponSet(s32 weaponsetnum) { - var800874c8 = func0f188f9c(weaponsetnum); - func0f1892dc(); + g_MpWeaponSetNum = func0f188f9c(weaponsetnum); + mpApplyWeaponSet(); } void func0f1895e8(void) { - if (var800874c8 < 12) { - func0f1892dc(); + if (g_MpWeaponSetNum < 12) { + mpApplyWeaponSet(); } } s32 mpGetWeaponSet(void) { - return mpCountWeaponSetThing(var800874c8); + return mpCountWeaponSetThing(g_MpWeaponSetNum); } bool mpIsPaused(void) @@ -1775,7 +1426,7 @@ struct mpweaponset g_MpWeaponSets[12] = { { /*0x0b*/ L_MPWEAPONS_044, { WEAPON_COMBATKNIFE, WEAPON_COMBATKNIFE, WEAPON_TIMEDMINE, WEAPON_CROSSBOW, WEAPON_MPSHIELD, WEAPON_DISABLED }, { MPFEATURE_WEAPON_CROSSBOW, 0, 0, 0 }, WEAPON_COMBATKNIFE, WEAPON_COMBATKNIFE, WEAPON_TIMEDMINE, WEAPON_TIMEDMINE, WEAPON_MPSHIELD, WEAPON_DISABLED }, // Close Combat }; -s32 var800874c8 = 0x00000000; +s32 g_MpWeaponSetNum = 0x00000000; u16 g_AwardNames[] = { L_MPMENU_000, // "Most Suicidal" diff --git a/src/include/constants.h b/src/include/constants.h index fe5b6b26e..2e317bcce 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -4105,6 +4105,10 @@ enum weaponnum { #define WEAPONFLAG_AIMTRACK 0x40000000 // Allow drawing red box around targets in aim mode #define WEAPONFLAG_FIRETOACTIVATE 0x80000000 // For devices/gadgets +#define WEAPONSET_RANDOMFIVE 0x0c +#define WEAPONSET_RANDOM 0x0d +#define WEAPONSET_CUSTOM 0x0e + #define WEATHERTYPE_RAIN 0 #define WEATHERTYPE_SNOW 1 diff --git a/src/include/game/mplayer/mplayer.h b/src/include/game/mplayer/mplayer.h index 8a40e65cd..d8c2b3024 100644 --- a/src/include/game/mplayer/mplayer.h +++ b/src/include/game/mplayer/mplayer.h @@ -32,7 +32,7 @@ s32 func0f189058(s32 arg0); s32 func0f189088(void); char *mpGetWeaponSetName(s32 arg0); void func0f18913c(void); -void func0f1892dc(void); +void mpApplyWeaponSet(void); void mpSetWeaponSet(s32 weaponsetnum); void func0f1895e8(void); s32 mpGetWeaponSet(void);