From 7a79cebf6412354e6164931acf1df34ef50311bd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 5 Feb 2020 08:22:02 +1000 Subject: [PATCH] Decompile currentPlayerGiveWeaponWithArgument --- src/game/game_011110.c | 4 +- src/game/game_0b28d0.c | 4 +- src/game/game_111600.c | 73 ++++++++++++++-------------------- src/include/game/game_111600.h | 2 +- src/include/types.h | 19 +++++++-- 5 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/game/game_011110.c b/src/game/game_011110.c index 629f288f9..15c355cf9 100644 --- a/src/game/game_011110.c +++ b/src/game/game_011110.c @@ -599,7 +599,7 @@ glabel currentPlayerInit /* f011ac0: 0fc04558 */ jal func0f011560 /* f011ac4: 00000000 */ sll $zero,$zero,0x0 /* f011ac8: 8e040004 */ lw $a0,0x4($s0) -/* f011acc: 0fc4478a */ jal func0f111e28 +/* f011acc: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f011ad0: 8e050008 */ lw $a1,0x8($s0) /* f011ad4: 10000004 */ beqz $zero,.L0f011ae8 /* f011ad8: 8fb80080 */ lw $t8,0x80($sp) @@ -1332,7 +1332,7 @@ glabel currentPlayerInit // // if (cmd[2] >= 0) { // func0f011560(cmd[2]); -// func0f111e28(cmd[1], cmd[2]); +// currentPlayerGiveWeaponWithArgument(cmd[1], cmd[2]); // } else { // currentPlayerGiveWeapon(cmd[1]); // } diff --git a/src/game/game_0b28d0.c b/src/game/game_0b28d0.c index b1be51c66..cb92fce10 100644 --- a/src/game/game_0b28d0.c +++ b/src/game/game_0b28d0.c @@ -5859,7 +5859,7 @@ glabel func0f0b72dc /* f0b7674: 8e250008 */ lw $a1,0x8($s1) /* f0b7678: 04a00005 */ bltz $a1,.L0f0b7690 /* f0b767c: 00000000 */ sll $zero,$zero,0x0 -/* f0b7680: 0fc4478a */ jal func0f111e28 +/* f0b7680: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f0b7684: 8e240004 */ lw $a0,0x4($s1) /* f0b7688: 10000016 */ beqz $zero,.L0f0b76e4 /* f0b768c: 26310010 */ addiu $s1,$s1,0x10 @@ -6307,7 +6307,7 @@ glabel func0f0b7c60 /* f0b7d0c: afa30034 */ sw $v1,0x34($sp) /* f0b7d10: 8fad0034 */ lw $t5,0x34($sp) /* f0b7d14: 91a4005c */ lbu $a0,0x5c($t5) -/* f0b7d18: 0fc4478a */ jal func0f111e28 +/* f0b7d18: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f0b7d1c: 00802825 */ or $a1,$a0,$zero /* f0b7d20: 8fae0034 */ lw $t6,0x34($sp) /* f0b7d24: 00002025 */ or $a0,$zero,$zero diff --git a/src/game/game_111600.c b/src/game/game_111600.c index 879e87f0b..e777ff4ca 100644 --- a/src/game/game_111600.c +++ b/src/game/game_111600.c @@ -558,9 +558,9 @@ bool currentPlayerGiveWeapon(s32 weaponnum) item = func0f111928(); if (item) { - item->unk00 = 1; - item->weapon04 = weaponnum; - item->weapon06 = -1; + item->type = 1; + item->type1.weapon1 = weaponnum; + item->type1.weapon2 = -1; func0f11179c(item); } @@ -570,44 +570,29 @@ bool currentPlayerGiveWeapon(s32 weaponnum) return false; } -GLOBAL_ASM( -glabel func0f111e28 -/* f111e28: 27bdffe8 */ addiu $sp,$sp,-24 -/* f111e2c: afbf0014 */ sw $ra,0x14($sp) -/* f111e30: afa40018 */ sw $a0,0x18($sp) -/* f111e34: 0fc446ac */ jal func0f111ab0 -/* f111e38: afa5001c */ sw $a1,0x1c($sp) -/* f111e3c: 14400014 */ bnez $v0,.L0f111e90 -/* f111e40: 8fa40018 */ lw $a0,0x18($sp) -/* f111e44: 0fc2c5f0 */ jal weaponHasFlag -/* f111e48: 24051000 */ addiu $a1,$zero,0x1000 -/* f111e4c: 1040000e */ beqz $v0,.L0f111e88 -/* f111e50: 00000000 */ sll $zero,$zero,0x0 -/* f111e54: 0fc4464a */ jal func0f111928 -/* f111e58: 00000000 */ sll $zero,$zero,0x0 -/* f111e5c: 10400008 */ beqz $v0,.L0f111e80 -/* f111e60: 00402025 */ or $a0,$v0,$zero -/* f111e64: 240e0003 */ addiu $t6,$zero,0x3 -/* f111e68: ac4e0000 */ sw $t6,0x0($v0) -/* f111e6c: 8faf0018 */ lw $t7,0x18($sp) -/* f111e70: ac4f0004 */ sw $t7,0x4($v0) -/* f111e74: 8fb8001c */ lw $t8,0x1c($sp) -/* f111e78: 0fc445e7 */ jal func0f11179c -/* f111e7c: ac580008 */ sw $t8,0x8($v0) -.L0f111e80: -/* f111e80: 10000004 */ beqz $zero,.L0f111e94 -/* f111e84: 24020001 */ addiu $v0,$zero,0x1 -.L0f111e88: -/* f111e88: 10000002 */ beqz $zero,.L0f111e94 -/* f111e8c: 00001025 */ or $v0,$zero,$zero -.L0f111e90: -/* f111e90: 00001025 */ or $v0,$zero,$zero -.L0f111e94: -/* f111e94: 8fbf0014 */ lw $ra,0x14($sp) -/* f111e98: 27bd0018 */ addiu $sp,$sp,0x18 -/* f111e9c: 03e00008 */ jr $ra -/* f111ea0: 00000000 */ sll $zero,$zero,0x0 -); +bool currentPlayerGiveWeaponWithArgument(s32 weapon1, s32 weapon2) +{ + if (func0f111ab0(weapon1, weapon2) == 0) { + if (weaponHasFlag(weapon1, WEAPONFLAG_00001000)) { + struct invitem *item = func0f111928(); + + if (item) { + item->type = 3; + item->type3.weapon1 = weapon1; + item->type3.weapon2 = weapon2; + func0f11179c(item); + } + + return true; + } else { + return false; + } + } else { + return false; + } + + return false; +} GLOBAL_ASM( glabel func0f111ea4 @@ -856,7 +841,7 @@ glabel func0f1120f0 /* f1121f4: 8fa30024 */ lw $v1,0x24($sp) /* f1121f8: 10640007 */ beq $v1,$a0,.L0f112218 /* f1121fc: 02002825 */ or $a1,$s0,$zero -/* f112200: 0fc4478a */ jal func0f111e28 +/* f112200: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f112204: 02002025 */ or $a0,$s0,$zero /* f112208: 10400003 */ beqz $v0,.L0f112218 /* f11220c: 00003825 */ or $a3,$zero,$zero @@ -900,7 +885,7 @@ glabel func0f1120f0 /* f112290: 000e78c0 */ sll $t7,$t6,0x3 /* f112294: 05e10009 */ bgez $t7,.L0f1122bc /* f112298: 00000000 */ sll $zero,$zero,0x0 -/* f11229c: 0fc4478a */ jal func0f111e28 +/* f11229c: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f1122a0: 00c02025 */ or $a0,$a2,$zero /* f1122a4: 10400003 */ beqz $v0,.L0f1122b4 /* f1122a8: 00000000 */ sll $zero,$zero,0x0 @@ -910,7 +895,7 @@ glabel func0f1120f0 /* f1122b4: 10000007 */ beqz $zero,.L0f1122d4 /* f1122b8: 00003825 */ or $a3,$zero,$zero .L0f1122bc: -/* f1122bc: 0fc4478a */ jal func0f111e28 +/* f1122bc: 0fc4478a */ jal currentPlayerGiveWeaponWithArgument /* f1122c0: 00c02825 */ or $a1,$a2,$zero /* f1122c4: 10400003 */ beqz $v0,.L0f1122d4 /* f1122c8: 00003825 */ or $a3,$zero,$zero diff --git a/src/include/game/game_111600.h b/src/include/game/game_111600.h index 2bc3c4b93..de9e7ebc1 100644 --- a/src/include/game/game_111600.h +++ b/src/include/game/game_111600.h @@ -20,7 +20,7 @@ bool currentPlayerCanHaveAllGunsWeapon(s32 weaponnum); bool currentPlayerCanHaveWeapon(s32 weaponnum); bool func0f111cf8(s32 weapon1, s32 weapon2); bool currentPlayerGiveWeapon(s32 weaponnum); -void func0f111e28(s32 weapon, s32 weaponarg); +bool currentPlayerGiveWeaponWithArgument(s32 weapon1, s32 weapon2); void func0f111ea4(u32 arg0); u32 func0f111fcc(void); u32 func0f112054(void); diff --git a/src/include/types.h b/src/include/types.h index 2bbaf8ad1..33288bf7c 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5067,10 +5067,23 @@ struct memorypool { /*0x10*/ u32 unk10; }; +struct invitem_type1 { + s16 weapon1; + s16 weapon2; +}; + +struct invitem_type3 { + s32 weapon1; + s32 weapon2; +}; + struct invitem { - /*0x00*/ u32 unk00; - /*0x04*/ s16 weapon04; - /*0x06*/ s16 weapon06; + /*0x00*/ u32 type; + + union { + struct invitem_type1 type1; + struct invitem_type3 type3; + }; }; #endif