Decompile aiRetreat

This commit is contained in:
Ryan Dwyer 2020-02-12 17:19:02 +10:00
parent 89f66348b1
commit 819216b65c
13 changed files with 45 additions and 87 deletions

View File

@ -3781,7 +3781,7 @@ u8 func042f_surrendering_guard[] = {
label(0x58)
restart_timer
retreat(0x02, 0x02)
retreat(SPEED_RUN, 2)
beginloop(0x0a)
if_distance_to_target_gt(300, /*goto*/ 0x06)

View File

@ -1643,7 +1643,7 @@ u8 func0411_labtech_alerted[] = {
goto_first(0x42)
label(0x04)
retreat(0x02, 0x02)
retreat(SPEED_RUN, 2)
restart_timer
beginloop(0x14)

View File

@ -4481,7 +4481,7 @@ u8 func0404_holo4_guard2[] = {
label(0x2f)
restart_timer
retreat(0x02, 0x01)
retreat(SPEED_RUN, 1)
beginloop(0x09)
if_timer_gt(60, /*goto*/ 0x06)
@ -4741,7 +4741,7 @@ u8 func0407_holo5_guard1[] = {
label(0x2f)
restart_timer
retreat(0x02, 0x01)
retreat(SPEED_RUN, 1)
beginloop(0x09)
if_timer_gt(60, /*goto*/ 0x06)

View File

@ -1146,7 +1146,7 @@ u8 func0405_elvis_follow_nocombat[] = {
label(0x08)
restart_timer
say_quip(CHR_BOND, 0x29, 0xff, 0x14, 0xff, BANK_1, 0x00, 0x00)
retreat(0x02, 0x01)
retreat(SPEED_RUN, 1)
beginloop(0x09)
if_timer_gt(120, /*goto*/ 0x2e)
@ -3488,7 +3488,7 @@ u8 func040f_miniskedar[] = {
label(0x2e)
label(0x2f)
retreat(0x02, 0x01)
retreat(SPEED_RUN, 1)
beginloop(0x0c)
if_timer_gt(120, /*goto*/ 0x06)

View File

@ -1675,7 +1675,7 @@ u8 func0413_bugspotter[] = {
// No other guard to run to
label(0x0b)
retreat(0x02, 0x02)
retreat(SPEED_RUN, 2)
beginloop(0x07)
if_stage_flag_eq(STAGEFLAG_LIMO_READY_TO_LEAVE, TRUE, /*goto*/ LABEL_RUN_AWAY)

View File

@ -829,7 +829,7 @@ u8 func0404_miniskedar[] = {
label(0x2d)
label(0x2e)
retreat(0x02, 0x01)
retreat(SPEED_RUN, 1)
beginloop(0x0d)
if_timer_gt(120, /*goto*/ 0x06)

View File

@ -143,7 +143,6 @@ const u32 var7f1a9d80[] = {0x7f05b0bc};
const u32 var7f1a9d84[] = {0x7f05b100};
const u32 var7f1a9d88[] = {0x7f05b140};
const u32 var7f1a9d8c[] = {0x7f05b184};
const u32 var7f1a9d90[] = {0x461c4000};
/**
* @cmd 0000
@ -9787,72 +9786,24 @@ bool aiIfHasOrders(void)
/**
* @cmd 0136
*/
GLOBAL_ASM(
glabel ai0136
/* f05b2f8: 27bdffd8 */ addiu $sp,$sp,-40
/* f05b2fc: afb00018 */ sw $s0,0x18($sp)
/* f05b300: 3c10800a */ lui $s0,%hi(g_Vars)
/* f05b304: 26109fc0 */ addiu $s0,$s0,%lo(g_Vars)
/* f05b308: 8e0e0434 */ lw $t6,0x434($s0)
/* f05b30c: 8e0f0438 */ lw $t7,0x438($s0)
/* f05b310: afbf001c */ sw $ra,0x1c($sp)
/* f05b314: 24010001 */ addiu $at,$zero,0x1
/* f05b318: 01cf1821 */ addu $v1,$t6,$t7
/* f05b31c: 90620003 */ lbu $v0,0x3($v1)
/* f05b320: 14400011 */ bnez $v0,.L0f05b368
/* f05b324: 00000000 */ sll $zero,$zero,0x0
/* f05b328: 90650002 */ lbu $a1,0x2($v1)
/* f05b32c: 3c017f1b */ lui $at,%hi(var7f1a9d90)
/* f05b330: 30b80010 */ andi $t8,$a1,0x10
/* f05b334: 13000005 */ beqz $t8,.L0f05b34c
/* f05b338: 00000000 */ sll $zero,$zero,0x0
/* f05b33c: 3c0143c8 */ lui $at,0x43c8
/* f05b340: 44810000 */ mtc1 $at,$f0
/* f05b344: 10000003 */ beqz $zero,.L0f05b354
/* f05b348: 8e040424 */ lw $a0,0x424($s0)
.L0f05b34c:
/* f05b34c: c4209d90 */ lwc1 $f0,%lo(var7f1a9d90)($at)
/* f05b350: 8e040424 */ lw $a0,0x424($s0)
.L0f05b354:
/* f05b354: 44060000 */ mfc1 $a2,$f0
/* f05b358: 0fc130ba */ jal func0f04c2e8
/* f05b35c: 248702c8 */ addiu $a3,$a0,0x2c8
/* f05b360: 10000018 */ beqz $zero,.L0f05b3c4
/* f05b364: 8e190438 */ lw $t9,0x438($s0)
.L0f05b368:
/* f05b368: 1441000d */ bne $v0,$at,.L0f05b3a0
/* f05b36c: 2405090a */ addiu $a1,$zero,0x90a
/* f05b370: 8e040424 */ lw $a0,0x424($s0)
/* f05b374: 0fc0a221 */ jal chrGetTargetProp
/* f05b378: afa30024 */ sw $v1,0x24($sp)
/* f05b37c: 8fa30024 */ lw $v1,0x24($sp)
/* f05b380: 3c06461c */ lui $a2,0x461c
/* f05b384: 34c64000 */ ori $a2,$a2,0x4000
/* f05b388: 8e040424 */ lw $a0,0x424($s0)
/* f05b38c: 24470008 */ addiu $a3,$v0,0x8
/* f05b390: 0fc130ba */ jal func0f04c2e8
/* f05b394: 90650002 */ lbu $a1,0x2($v1)
/* f05b398: 1000000a */ beqz $zero,.L0f05b3c4
/* f05b39c: 8e190438 */ lw $t9,0x438($s0)
.L0f05b3a0:
/* f05b3a0: 8e040424 */ lw $a0,0x424($s0)
/* f05b3a4: 00003025 */ or $a2,$zero,$zero
/* f05b3a8: 0fc12e8d */ jal func0f04ba34
/* f05b3ac: afa30024 */ sw $v1,0x24($sp)
/* f05b3b0: 8fa30024 */ lw $v1,0x24($sp)
/* f05b3b4: 8e040424 */ lw $a0,0x424($s0)
/* f05b3b8: 0fc1309a */ jal chrGoToCover
/* f05b3bc: 90650002 */ lbu $a1,0x2($v1)
/* f05b3c0: 8e190438 */ lw $t9,0x438($s0)
.L0f05b3c4:
/* f05b3c4: 8fbf001c */ lw $ra,0x1c($sp)
/* f05b3c8: 00001025 */ or $v0,$zero,$zero
/* f05b3cc: 27280004 */ addiu $t0,$t9,0x4
/* f05b3d0: ae080438 */ sw $t0,0x438($s0)
/* f05b3d4: 8fb00018 */ lw $s0,0x18($sp)
/* f05b3d8: 03e00008 */ jr $ra
/* f05b3dc: 27bd0028 */ addiu $sp,$sp,0x28
);
bool aiRetreat(void)
{
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
if (cmd[3] == 0) {
chrRunFromPos(g_Vars.chrdata, cmd[2], (cmd[2] & 0x10) ? 400.0f : 10000.0f, &g_Vars.chrdata->runfrompos);
} else if (cmd[3] == 1) {
struct prop *target = chrGetTargetProp(g_Vars.chrdata);
chrRunFromPos(g_Vars.chrdata, cmd[2], 10000, &target->pos);
} else {
func0f04ba34(g_Vars.chrdata, 2314, 0);
chrGoToCover(g_Vars.chrdata, cmd[2]);
}
g_Vars.aioffset += 4;
return false;
}
/**
* @cmd 0137

View File

@ -6529,7 +6529,7 @@ bool (*g_CommandPointers[])(void) = {
/*0x0133*/ ai0133,
/*0x0134*/ aiIfOrders,
/*0x0135*/ aiIfHasOrders,
/*0x0136*/ ai0136,
/*0x0136*/ aiRetreat,
/*0x0137*/ aiIfChrInSquadronDoingAction,
/*0x0138*/ aiIfChannelIdle,
/*0x0139*/ ai0139,

View File

@ -34285,7 +34285,7 @@ s16 chrGoToCover(struct chrdata *chr, u8 speed)
}
GLOBAL_ASM(
glabel func0f04c2e8
glabel chrRunFromPos
/* f04c2e8: 27bdffb0 */ addiu $sp,$sp,-80
/* f04c2ec: afbf0024 */ sw $ra,0x24($sp)
/* f04c2f0: afb00020 */ sw $s0,0x20($sp)

View File

@ -394,7 +394,7 @@ glabel func0f197600
/* f197a84: 34c64000 */ ori $a2,$a2,0x4000
/* f197a88: 24050002 */ addiu $a1,$zero,0x2
/* f197a8c: 8fa7001c */ lw $a3,0x1c($sp)
/* f197a90: 0fc130ba */ jal func0f04c2e8
/* f197a90: 0fc130ba */ jal chrRunFromPos
/* f197a94: afa80054 */ sw $t0,0x54($sp)
/* f197a98: 10000010 */ beqz $zero,.L0f197adc
/* f197a9c: 8fa80054 */ lw $t0,0x54($sp)

View File

@ -2641,13 +2641,20 @@
mkshort(0x0135), \
label,
// u1 can theoretically be any value but in practice is only ever 2.
// u2 can be either 0, 1 or 2 and determines what the command does,
// but in practice is only ever 1 or 2.
#define retreat(u1, u2) \
/**
* If operation is 0, looks like the chr runs from their runfrompos property.
* The distance they run is controlled by bit 0x10 in speed. If set then the run
* distance will be 400 units. If unset it will be 10,000.
*
* If operation is 1, the chr tries to run 10,000 units away from their target.
*
* If operation is anything else, looks like it tries to find a cover point
* within 2314 units then runs to it.
*/
#define retreat(speed, operation) \
mkshort(0x0136), \
u1, \
u2,
speed, \
operation,
#define if_chr_in_squadron_doing_action(action, label) \
mkshort(0x0137), \

View File

@ -308,7 +308,7 @@
/*0x0133*/ bool ai0133(void);
/*0x0134*/ bool aiIfOrders(void);
/*0x0135*/ bool aiIfHasOrders(void);
/*0x0136*/ bool ai0136(void);
/*0x0136*/ bool aiRetreat(void);
/*0x0137*/ bool aiIfChrInSquadronDoingAction(void);
/*0x0138*/ bool aiIfChannelIdle(void);
/*0x0139*/ bool ai0139(void);

View File

@ -206,9 +206,9 @@ bool chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, s16 *room, f32 arg4,
u32 func0f04b658(struct chrdata *chr);
bool chrMoveToPos(struct chrdata *chr, struct coord *pos, s16 *room, f32 arg3, u32 allowonscreen);
u32 func0f04b950(struct chrdata *chr, u32 cover, u32 arg2);
u32 func0f04ba34(struct chrdata *chr, u16 arg1, u32 arg2);
s32 func0f04ba34(struct chrdata *chr, u16 arg1, u32 arg2);
u32 func0f04bffc(struct chrdata *chr, u32 arg1, u32 arg2);
u32 func0f04c2e8(void);
void chrRunFromPos(struct chrdata *chr, u32 speed, f32 distance, struct coord *pos);
u32 func0f04c784(void);
void func0f04c874(struct chrdata *chr, u32 flags, struct coord *pos, s32 arg3, s32 arg4);
u32 rebuildTeams(void);