Restructure weapon function structs and decompile func0f011560

This commit is contained in:
Ryan Dwyer 2020-02-02 23:03:27 +10:00
parent cbd4799e52
commit aeb34076f1
9 changed files with 1369 additions and 1653 deletions

View File

@ -320,4 +320,4 @@ clean:
binclean:
rm -f build/ntsc-final/ucode/*.bin
find src/{boot,game,gamedata,gvars,library,inflate} -name '*.o' -delete
find src/{boot,game,gvars,library,inflate} -name '*.o' -delete

File diff suppressed because it is too large Load Diff

View File

@ -370,65 +370,34 @@ glabel func0f011130
/* f01155c: 27bd0040 */ addiu $sp,$sp,0x40
);
GLOBAL_ASM(
glabel func0f011560
/* f011560: 27bdffd0 */ addiu $sp,$sp,-48
/* f011564: 00047080 */ sll $t6,$a0,0x2
/* f011568: 3c028007 */ lui $v0,0x8007
/* f01156c: afb50028 */ sw $s5,0x28($sp)
/* f011570: afb40024 */ sw $s4,0x24($sp)
/* f011574: afb30020 */ sw $s3,0x20($sp)
/* f011578: afb2001c */ sw $s2,0x1c($sp)
/* f01157c: afb10018 */ sw $s1,0x18($sp)
/* f011580: afb00014 */ sw $s0,0x14($sp)
/* f011584: 004e1021 */ addu $v0,$v0,$t6
/* f011588: afbf002c */ sw $ra,0x2c($sp)
/* f01158c: 00008025 */ or $s0,$zero,$zero
/* f011590: 8c52ff18 */ lw $s2,-0xe8($v0)
/* f011594: 00008825 */ or $s1,$zero,$zero
/* f011598: 24130201 */ addiu $s3,$zero,0x201
/* f01159c: 24140008 */ addiu $s4,$zero,0x8
/* f0115a0: 24150002 */ addiu $s5,$zero,0x2
.L0f0115a4:
/* f0115a4: 8e430014 */ lw $v1,0x14($s2)
/* f0115a8: 50600015 */ beqzl $v1,.L0f011600
/* f0115ac: 26310004 */ addiu $s1,$s1,0x4
/* f0115b0: 8c640000 */ lw $a0,0x0($v1)
/* f0115b4: 00601025 */ or $v0,$v1,$zero
/* f0115b8: 16640008 */ bne $s3,$a0,.L0f0115dc
/* f0115bc: 00000000 */ sll $zero,$zero,0x0
/* f0115c0: 8c640040 */ lw $a0,0x40($v1)
/* f0115c4: 0482000e */ bltzl $a0,.L0f011600
/* f0115c8: 26310004 */ addiu $s1,$s1,0x4
/* f0115cc: 0fc2486d */ jal func0f0921b4
/* f0115d0: 00000000 */ sll $zero,$zero,0x0
/* f0115d4: 10000009 */ beqz $zero,.L0f0115fc
/* f0115d8: 02028025 */ or $s0,$s0,$v0
.L0f0115dc:
/* f0115dc: 56a40008 */ bnel $s5,$a0,.L0f011600
/* f0115e0: 26310004 */ addiu $s1,$s1,0x4
/* f0115e4: 8c440014 */ lw $a0,0x14($v0)
/* f0115e8: 04820005 */ bltzl $a0,.L0f011600
/* f0115ec: 26310004 */ addiu $s1,$s1,0x4
/* f0115f0: 0fc2486d */ jal func0f0921b4
/* f0115f4: 00000000 */ sll $zero,$zero,0x0
/* f0115f8: 02028025 */ or $s0,$s0,$v0
.L0f0115fc:
/* f0115fc: 26310004 */ addiu $s1,$s1,0x4
.L0f011600:
/* f011600: 1634ffe8 */ bne $s1,$s4,.L0f0115a4
/* f011604: 26520004 */ addiu $s2,$s2,0x4
/* f011608: 8fbf002c */ lw $ra,0x2c($sp)
/* f01160c: 02001025 */ or $v0,$s0,$zero
/* f011610: 8fb00014 */ lw $s0,0x14($sp)
/* f011614: 8fb10018 */ lw $s1,0x18($sp)
/* f011618: 8fb2001c */ lw $s2,0x1c($sp)
/* f01161c: 8fb30020 */ lw $s3,0x20($sp)
/* f011620: 8fb40024 */ lw $s4,0x24($sp)
/* f011624: 8fb50028 */ lw $s5,0x28($sp)
/* f011628: 03e00008 */ jr $ra
/* f01162c: 27bd0030 */ addiu $sp,$sp,0x30
);
u32 func0f011560(s32 weaponnum)
{
u32 flags = 0;
struct weapon *weapon = g_Weapons[weaponnum];
s32 i;
for (i = 0; i != 2; i++) {
if (weapon->functions[i]) {
struct weaponfunc *genericfunc = weapon->functions[i];
if (genericfunc->type == INVENTORYFUNCTYPE_SHOOT_PROJECTILE) {
struct weaponfunc_shootprojectile *func = (struct weaponfunc_shootprojectile *)genericfunc;
if (func->projectilemodelnum >= 0) {
flags |= func0f0921b4(func->projectilemodelnum);
}
} else if (genericfunc->type == INVENTORYFUNCTYPE_THROW) {
struct weaponfunc_throw *func = (struct weaponfunc_throw *)genericfunc;
if (func->projectilemodelnum >= 0) {
flags |= func0f0921b4(func->projectilemodelnum);
}
}
}
}
return flags;
}
void currentPlayerInitEyespy(void)
{

View File

@ -3476,8 +3476,8 @@ s32 menuhandlerChangeAgent(s32 operation, struct menu_item *item, s32 *value)
char *func0f105864(s32 arg0)
{
struct inventory_function *primaryfunc = weaponGetFunctionById(var800a21c0, 0);
struct inventory_function *secondaryfunc = weaponGetFunctionById(var800a21c0, 1);
struct weaponfunc *primaryfunc = weaponGetFunctionById(var800a21c0, 0);
struct weaponfunc *secondaryfunc = weaponGetFunctionById(var800a21c0, 1);
if (primaryfunc && secondaryfunc) {
return textGet(primaryfunc->name);
@ -3488,8 +3488,8 @@ char *func0f105864(s32 arg0)
char *func0f1058d0(s32 arg0)
{
struct inventory_function *primaryfunc = weaponGetFunctionById(var800a21c0, 0);
struct inventory_function *secondaryfunc = weaponGetFunctionById(var800a21c0, 1);
struct weaponfunc *primaryfunc = weaponGetFunctionById(var800a21c0, 0);
struct weaponfunc *secondaryfunc = weaponGetFunctionById(var800a21c0, 1);
if (secondaryfunc) {
return textGet(secondaryfunc->name);

View File

@ -508,12 +508,14 @@
#define INTROTYPE_HILL 11
#define INTROTYPE_END 12
#define INVENTORYFUNCTYPE_NONE 0
#define INVENTORYFUNCTYPE_SHOOT 1
#define INVENTORYFUNCTYPE_THROW 2
#define INVENTORYFUNCTYPE_CLOSE 3
#define INVENTORYFUNCTYPE_SPECIAL 4
#define INVENTORYFUNCTYPE_VISUAL 5
#define INVENTORYFUNCTYPE_NONE 0x0000
#define INVENTORYFUNCTYPE_SHOOT_SINGLE 0x0001
#define INVENTORYFUNCTYPE_SHOOT_AUTOMATIC 0x0101
#define INVENTORYFUNCTYPE_SHOOT_PROJECTILE 0x0201
#define INVENTORYFUNCTYPE_THROW 0x0002
#define INVENTORYFUNCTYPE_CLOSE 0x0003
#define INVENTORYFUNCTYPE_SPECIAL 0x0004
#define INVENTORYFUNCTYPE_VISUAL 0x0005
// These actions are assigned to chr->myaction
#define MA_NONE 0

View File

@ -6,7 +6,7 @@
void func0f011110(void);
void func0f011124(s32 value);
u32 func0f011130(void);
void func0f011560(s32 weapon);
u32 func0f011560(s32 weaponnum);
void currentPlayerInitEyespy(void);
void currentPlayerInit(void);

View File

@ -343,7 +343,7 @@ s32 setupGetCommandLength(u32 *ptr);
u32 func0f092004(u32 arg0);
u32 func0f092098(struct tag *tag);
u32 func0f092124(void);
u32 func0f0921b4(void);
u32 func0f0921b4(s32 modelnum);
u32 func0f09220c(void);
u32 func0f092304(void);
u32 func0f09233c(void);

View File

@ -18,7 +18,7 @@ u32 func0f0b0764(void);
u32 func0f0b0818(void);
s32 func0f0b09f4(s32 arg0, s32 arg1);
struct weapon *weaponFindById(s32 itemid);
struct inventory_function *weaponGetFunctionById(s32 weapon_id, s32 which);
struct weaponfunc *weaponGetFunctionById(s32 weapon_id, s32 which);
u32 func0f0b103c(void);
u32 func0f0b107c(void);
u32 func0f0b10b8(void);

View File

@ -2774,16 +2774,111 @@ struct inventory_typef {
u32 unk10;
};
struct inventory_function {
u16 unk00;
u8 unk02;
u8 type;
u16 name;
u8 unk06;
s8 unk07;
struct inventory_menupos *menupos;
u32 *fire_animation;
u32 flags;
struct weaponfunc {
/*0x00*/ u32 type;
/*0x04*/ u16 name;
/*0x06*/ u8 unk06;
/*0x07*/ s8 unk07;
/*0x08*/ struct inventory_menupos *menupos;
/*0x0c*/ u32 *fire_animation;
/*0x10*/ u32 flags;
};
struct weaponfunc_shootsingle {
struct weaponfunc 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;
};
struct weaponfunc_shootauto {
struct weaponfunc 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*/ u32 unk48;
/*0x4c*/ u32 unk4c;
/*0x50*/ u32 unk50;
};
struct weaponfunc_shootprojectile {
struct weaponfunc 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*/ s32 projectilemodelnum;
/*0x44*/ u32 unk44;
/*0x48*/ u32 unk48;
/*0x4c*/ u32 unk4c;
/*0x50*/ u32 unk50;
/*0x54*/ u32 unk54;
/*0x58*/ u32 unk58;
/*0x5c*/ u32 unk5c;
/*0x60*/ u32 unk60;
};
struct weaponfunc_throw {
struct weaponfunc base;
/*0x14*/ s32 projectilemodelnum;
/*0x18*/ u32 unk18;
/*0x1c*/ u32 unk1c;
/*0x20*/ u32 unk20;
};
struct weaponfunc_close {
struct weaponfunc 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*/ u32 unk48;
};
struct weaponfunc_special {
struct weaponfunc base;
/*0x14*/ u32 unk14;
/*0x18*/ u32 unk18;
/*0x1c*/ u32 unk1c;
};
struct weaponfunc_visual {
struct weaponfunc base;
/*0x14*/ u32 unk14;
};
struct inventory_ammo {
@ -2803,8 +2898,7 @@ struct weapon {
/*0x08*/ u32 *unequip_animation;
/*0x0c*/ u32 *pritosec_animation;
/*0x10*/ u32 *sectopri_animation;
/*0x14*/ struct inventory_function *pri_function;
/*0x18*/ struct inventory_function *sec_function;
/*0x14*/ void *functions[2];
/*0x1c*/ struct inventory_ammo *pri_ammo;
/*0x20*/ struct inventory_ammo *sec_ammo;
/*0x24*/ struct inventory_typee *eptr;