Attempt to decompile frChooseAutogunTarget

This commit is contained in:
Ryan Dwyer 2020-08-04 22:31:52 +10:00
parent 7336a45509
commit d4b50adbde
4 changed files with 46 additions and 5 deletions

View File

@ -21987,7 +21987,7 @@ glabel var7f1aa580
/* f079038: 8fa800ac */ lw $t0,0xac($sp) /* f079038: 8fa800ac */ lw $t0,0xac($sp)
/* f07903c: 8fa400b0 */ lw $a0,0xb0($sp) /* f07903c: 8fa400b0 */ lw $a0,0xb0($sp)
/* f079040: afa800ac */ sw $t0,0xac($sp) /* f079040: afa800ac */ sw $t0,0xac($sp)
/* f079044: 0fc67ce7 */ jal func0f19f39c /* f079044: 0fc67ce7 */ jal frChooseAutogunTarget
/* f079048: 24840008 */ addiu $a0,$a0,0x8 /* f079048: 24840008 */ addiu $a0,$a0,0x8
/* f07904c: 3c09800a */ lui $t1,%hi(g_Vars) /* f07904c: 3c09800a */ lui $t1,%hi(g_Vars)
/* f079050: 8fa800ac */ lw $t0,0xac($sp) /* f079050: 8fa800ac */ lw $t0,0xac($sp)

View File

@ -2160,7 +2160,7 @@ bool func0f19f2ec(struct prop *prop, struct coord *pos)
return false; return false;
} }
angle = func0f19f294(&prop->pos, g_FiringRangeData.targets[i].unk28, pos); angle = func0f19f294(&prop->pos, g_FiringRangeData.targets[i].angle, pos);
//if (angle > DEG2RAD(90) && angle < DEG2RAD(270)) { //if (angle > DEG2RAD(90) && angle < DEG2RAD(270)) {
if (angle > 1.5707963705063f && angle < 4.7116389274597f) { if (angle > 1.5707963705063f && angle < 4.7116389274597f) {
@ -2175,7 +2175,7 @@ bool func0f19f2ec(struct prop *prop, struct coord *pos)
} }
GLOBAL_ASM( GLOBAL_ASM(
glabel func0f19f39c glabel frChooseAutogunTarget
.late_rodata .late_rodata
glabel var7f1b94b8 glabel var7f1b94b8
.word 0x4096c5bf .word 0x4096c5bf
@ -2289,6 +2289,47 @@ glabel var7f1b94bc
/* f19f520: 27bd00d0 */ addiu $sp,$sp,0xd0 /* f19f520: 27bd00d0 */ addiu $sp,$sp,0xd0
); );
// Regalloc: s3 and s4 are swapped.
// s3 should be autogunpos and s4 should be facingtargets.
//struct prop *frChooseAutogunTarget(struct coord *autogunpos)
//{
// f32 closestdist = 0x20000000;
// s32 facingtargets[ARRAYCOUNT(g_FiringRangeData.targets)];
// s32 len = 0;
// struct prop *closesttarget = NULL;
// s32 i;
//
// // Make list of targets which are facing the laptop gun
// for (i = 0; i < ARRAYCOUNT(g_FiringRangeData.targets); i++) {
// if (g_FiringRangeData.targets[i].unk00_01
// && g_FiringRangeData.targets[i].unk00_03 == 0
// && g_FiringRangeData.targets[i].unk00_02) {
// f32 angle = func0f19f294(&g_FiringRangeData.targets[i].prop->pos, g_FiringRangeData.targets[i].angle, autogunpos);
//
// //if (!(angle > BADDEG2RAD(90) && angle < BADDEG2RAD(270))) {
// if (!(angle > 1.5707963705063f && angle < 4.7116389274597f)) {
// facingtargets[len++] = i;
// }
// }
// }
//
// // Determine which of the facing targets is closest
// for (i = 0; i < len; i++) {
// struct prop *prop = g_FiringRangeData.targets[facingtargets[i]].prop;
// f32 xdiff = prop->pos.x - autogunpos->x;
// f32 ydiff = prop->pos.y - autogunpos->y;
// f32 zdiff = prop->pos.z - autogunpos->z;
// f32 dist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
//
// if (dist < closestdist) {
// closestdist = dist;
// closesttarget = prop;
// }
// }
//
// return closesttarget;
//}
GLOBAL_ASM( GLOBAL_ASM(
glabel func0f19f524 glabel func0f19f524
/* f19f524: 27bdfd40 */ addiu $sp,$sp,-704 /* f19f524: 27bdfd40 */ addiu $sp,$sp,-704

View File

@ -53,7 +53,7 @@ void func0f19f18c(void);
bool func0f19f220(struct prop *prop); bool func0f19f220(struct prop *prop);
f32 func0f19f294(struct coord *a, f32 angle, struct coord *b); f32 func0f19f294(struct coord *a, f32 angle, struct coord *b);
bool func0f19f2ec(struct prop *prop, struct coord *pos); bool func0f19f2ec(struct prop *prop, struct coord *pos);
u32 func0f19f39c(void); struct prop *frChooseAutogunTarget(struct coord *arg0);
u32 func0f19f524(void); u32 func0f19f524(void);
void frTick(void); void frTick(void);
void func0f1a0924(struct prop *prop); void func0f1a0924(struct prop *prop);

View File

@ -5306,7 +5306,7 @@ struct frtarget {
/*0x20*/ u8 unk20; /*0x20*/ u8 unk20;
/*0x21*/ u8 unk21; /*0x21*/ u8 unk21;
/*0x24*/ f32 unk24; /*0x24*/ f32 unk24;
/*0x28*/ f32 unk28; /*0x28*/ f32 angle;
/*0x2c*/ f32 unk2c; /*0x2c*/ f32 unk2c;
/*0x30*/ u8 flags; /*0x30*/ u8 flags;
/*0x31*/ u8 unk31; /*0x31*/ u8 unk31;