Attempt to decompile goPosUpdateLiftAction

This commit is contained in:
Ryan Dwyer 2021-05-21 23:03:04 +10:00
parent 1a8400e4ec
commit 362a3a4b59
5 changed files with 151 additions and 16 deletions

View File

@ -7173,8 +7173,8 @@ void chrGoPosClearRestartTtl(struct chrdata *chr)
void chrGoPosConsiderRestart(struct chrdata *chr)
{
if (chr->act_gopos.waydata.mode != WAYMODE_CHEAP
&& chr->liftaction != LA_3
&& chr->liftaction != LA_1) {
&& chr->liftaction != LIFTACTION_WAITINGONLIFT
&& chr->liftaction != LIFTACTION_WAITINGFORLIFT) {
if (chr->act_gopos.restartttl == 0) {
#if VERSION >= VERSION_PAL_FINAL
s32 value = (chrGoPosCalculateBaseTtl(chr) * 100 + 15000) / 60;
@ -12172,8 +12172,6 @@ void chrTickDruggedDrop(struct chrdata *chr)
chrAlertOthersOfInjury(chr, true);
}
u32 var8006843c = 0x0000ffff;
void chrTickDruggedKo(struct chrdata *chr)
{
bool reap = false;
@ -26281,7 +26279,7 @@ glabel var7f1a927c
);
GLOBAL_ASM(
glabel func0f046648
glabel goPosUpdateLiftAction
/* f046648: 27bdff60 */ addiu $sp,$sp,-160
/* f04664c: afb00018 */ sw $s0,0x18($sp)
/* f046650: 00808025 */ or $s0,$a0,$zero
@ -26303,7 +26301,7 @@ glabel func0f046648
/* f04668c: 8ca40004 */ lw $a0,0x4($a1)
/* f046690: afa8009c */ sw $t0,0x9c($sp)
/* f046694: afa30044 */ sw $v1,0x44($sp)
/* f046698: 0fc1c3ab */ jal func0f070eac
/* f046698: 0fc1c3ab */ jal liftGetY
/* f04669c: afa40038 */ sw $a0,0x38($sp)
/* f0466a0: 8fae00b4 */ lw $t6,0xb4($sp)
/* f0466a4: 8fa30044 */ lw $v1,0x44($sp)
@ -26553,6 +26551,142 @@ glabel func0f046648
/* f046a2c: 00000000 */ nop
);
u32 var8006843c = 0x0000ffff;
// Mismatch: Goal loads arrivingatlift into a0 then later copies s0 (chr) to a0.
// The below loads arrivingatlift into v1 and copies s0 to a0 earlier.
//bool goPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, bool arrivingatlift, s16 curpadnum, s32 nextpadnum)
//{
// bool advance = false;
// struct pad nextpad;
// u32 nextpadflags = 0;
// f32 nextground;
// f32 lifty;
// struct liftobj *lift;
// struct prop *liftprop = liftFindByPad(curpadnum);
// u32 stack;
//
// if (!liftprop) {
// return false;
// }
//
// lift = (struct liftobj *) liftprop->obj;
//
// lifty = liftGetY(lift);
//
// if (nextpadnum >= 0) {
// padUnpack(nextpadnum, PADFIELD_POS | PADFIELD_ROOM | PADFIELD_FLAGS, &nextpad);
// nextpadflags = nextpad.flags;
// }
//
// if (curpadflags & PADFLAG_AIWAITLIFT) {
// if (nextpadflags & PADFLAG_AIONLIFT) {
// if (arrivingatlift || chr->liftaction == LIFTACTION_WAITINGFORLIFT) {
// // Begin entering lift if lift is under 40cm above this level
// advance = (lifty <= chr->manground + 40);
//
// // ...and (if solo mode) lift is over 1m under this level
// // (this logic allows MP simulants to drop down onto lifts)
// if (!g_Vars.normmplayerisrunning && advance) {
// advance = (lifty > chr->manground - 100);
// }
//
// // ...and if the lift has a door, is at least halfway open
// if (advance && lift->doors[lift->levelcur] && lift->doors[lift->levelcur]->frac < 0.5f) {
// advance = false;
// }
// }
//
// if (!advance) {
// if (arrivingatlift && chr->liftaction != LIFTACTION_WAITINGFORLIFT) {
// // Just arrived at lift
// chr->liftaction = LIFTACTION_WAITINGFORLIFT;
//
// chrStandChooseAnimation(chr, 16);
//
// if (nextpadnum >= 0) {
// // Call the lift
// chrOpenDoor(chr, &nextpad.pos);
// }
// }
// } else {
// // Enter lift
// chr->liftaction = LIFTACTION_NOTUSINGLIFT;
//
// if (func0f02e064(chr)) {
// if (chr->actiontype == ACT_PATROL) {
// func0f038868(chr);
// } else {
// chrGoPosChooseAnimation(chr);
// }
// }
// }
// } else {
// // On a wait lift pad, but the next pad in the route is not on the
// // lift, so the chr is running past the lift without using it.
// if (arrivingatlift) {
// advance = true;
// chr->liftaction = LIFTACTION_NOTUSINGLIFT;
// }
// }
// } else if (curpadflags & PADFLAG_AIONLIFT) {
// if (nextpadflags & PADFLAG_AIWAITLIFT) {
// // Waiting for door to close or lift to arrive at destination
// if (arg2 || chr->liftaction == LIFTACTION_WAITINGONLIFT) {
// // Continue waiting
// s16 rooms[] = {0, -1};
// u32 stack2;
//
// rooms[0] = nextpad.room;
//
// nextground = func0002a36c(&nextpad.pos, rooms, NULL, NULL);
//
// // Begin exiting lift if lift is 30cm under destination or higher
// advance = (lifty >= nextground - 30);
//
// // ...and (if solo) lift is under 1m above destination
// if (!g_Vars.normmplayerisrunning && advance) {
// advance = (lifty < nextground + 100);
// }
//
// // ...and if the lift has a door, is at least halfway open
// if (advance && lift->doors[lift->levelcur] && lift->doors[lift->levelcur]->frac < 0.5f) {
// advance = false;
// }
// }
//
// if (!advance) {
// if (arg2 && chr->liftaction != LIFTACTION_WAITINGONLIFT) {
// // Just arrived inside lift
// chr->liftaction = LIFTACTION_WAITINGONLIFT;
// chrStandChooseAnimation(chr, 16);
// }
// } else {
// // Start disembarking
// chr->liftaction = LIFTACTION_ONLIFT;
//
// if (func0f02e064(chr)) {
// if (chr->actiontype == ACT_PATROL) {
// func0f038868(chr);
// } else {
// chrGoPosChooseAnimation(chr);
// }
// }
// }
// } else {
// // Not our stop? Not sure why advance is true here. I guess the chr
// // can't go anywhere anyway because the next pad is above or below
// // them.
// if (arg2) {
// advance = true;
// chr->liftaction = LIFTACTION_ONLIFT;
// }
// }
// }
//
// return advance;
//}
s32 chrIsUsingLift(struct chrdata *chr)
{
return (chr->actiontype == ACT_GOPOS || chr->actiontype == ACT_PATROL) && chr->liftaction > 0;
@ -26699,7 +26833,7 @@ void chrTickGoPos(struct chrdata *chr)
}
if ((pad.flags & PADFLAG_AIWAITLIFT) || (pad.flags & PADFLAG_AIONLIFT)) {
advance = func0f046648(chr, pad.flags, sp184, sp188, waypoint->padnum, chrGoPosGetNextPadNum(chr));
advance = goPosUpdateLiftAction(chr, pad.flags, sp184, sp188, waypoint->padnum, chrGoPosGetNextPadNum(chr));
} else {
if (sp188 || (sp184 && (chr->inlift || (pad.flags & PADFLAG_8000)))) {
advance = true;
@ -27022,7 +27156,7 @@ glabel chrTickPatrol
/* f047604: 8fa60044 */ lw $a2,0x44($sp)
/* f047608: 8fa70040 */ lw $a3,0x40($sp)
/* f04760c: afa20014 */ sw $v0,0x14($sp)
/* f047610: 0fc11992 */ jal func0f046648
/* f047610: 0fc11992 */ jal goPosUpdateLiftAction
/* f047614: afb90010 */ sw $t9,0x10($sp)
/* f047618: 10000004 */ b .L0f04762c
/* f04761c: 00401825 */ or $v1,$v0,$zero
@ -27211,7 +27345,7 @@ glabel chrTickPatrol
/* f047604: 8fa60044 */ lw $a2,0x44($sp)
/* f047608: 8fa70040 */ lw $a3,0x40($sp)
/* f04760c: afa20014 */ sw $v0,0x14($sp)
/* f047610: 0fc11992 */ jal func0f046648
/* f047610: 0fc11992 */ jal goPosUpdateLiftAction
/* f047614: afb90010 */ sw $t9,0x10($sp)
/* f047618: 10000004 */ b .L0f04762c
/* f04761c: 00401825 */ or $v1,$v0,$zero

View File

@ -16365,7 +16365,7 @@ struct prop *liftFindByPad(s16 padnum)
}
GLOBAL_ASM(
glabel func0f070eac
glabel liftGetY
/* f070eac: 808f005a */ lb $t7,0x5a($a0)
/* f070eb0: 8c8e0014 */ lw $t6,0x14($a0)
/* f070eb4: 19e00012 */ blez $t7,.L0f070f00

View File

@ -1134,9 +1134,10 @@
#define INVITEMTYPE_PROP 2
#define INVITEMTYPE_DUAL 3
// Lift actions
#define LA_1 1 // either waiting for lift or in lift
#define LA_3 3 // either waiting for lift or in lift
#define LIFTACTION_NOTUSINGLIFT 0
#define LIFTACTION_WAITINGFORLIFT 1
#define LIFTACTION_ONLIFT 2
#define LIFTACTION_WAITINGONLIFT 3
#define LANGUAGE_NTSC_EN 0
#define LANGUAGE_NTSC_JP 1

View File

@ -92,7 +92,7 @@ void func0f0375e8(struct chrdata *chr, struct waydata *waydata, f32 arg2, struct
void chrCalculatePosition(struct chrdata *chr, struct coord *pos);
void chrGoPosChooseAnimation(struct chrdata *chr);
bool chrGoToPos(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 flags);
u32 func0f038868(void);
void func0f038868(struct chrdata *chr);
void func0f038b9c(struct chrdata *chr, struct path *path);
bool chrCanSeeEntity(struct chrdata *chr, struct coord *pos, s16 *rooms, bool arg3, u32 entitytype, u32 entityid);
bool chrCanSeeAttackTarget(struct chrdata *chr, struct coord *pos, s16 *rooms, bool arg3);
@ -171,7 +171,7 @@ u32 func0f0451a8(void);
u32 func0f045760(void);
struct prop *chrOpenDoor(struct chrdata *chr, struct coord *coord);
void func0f045b9c(struct chrdata *chr, struct coord *pos, struct waydata *waydata, bool arg3);
bool func0f046648(struct chrdata *chr, u32 padflags, u32 arg2, u32 arg3, s32 padnum, u32 arg5);
bool goPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, bool arrivingatlift, s16 curpadnum, s32 nextpadnum);
s16 chrGoPosGetNextPadNum(struct chrdata *chr);
void chrTickGoPos(struct chrdata *chr);
void chrTickPatrol(struct chrdata *chr);

View File

@ -141,7 +141,7 @@ u32 func0f070bd0(void);
void func0f070ca0(struct defaultobj *obj, void *ptr, s32 arg2, s32 arg3, union modelrodata *rodata);
void liftActivate(struct prop *prop, u8 liftnum);
struct prop *liftFindByPad(s16 padnum);
u32 func0f070eac(void);
f32 liftGetY(struct liftobj *lift);
void func0f070f08(struct liftobj *lift, bool arg0);
void liftGoToStop(struct liftobj *lift, s32 stopnum);
f32 objGetHov04(struct defaultobj *obj);