Attempt to decompile doorsCheckAutomatic

This commit is contained in:
Ryan Dwyer 2021-03-01 18:55:09 +10:00
parent e81a05d2cb
commit 01dc299e14
7 changed files with 84 additions and 19 deletions

View File

@ -1396,5 +1396,5 @@ void bbikeTick(void)
currentPlayerUpdatePerimInfo();
bmove0f0cb8c4(g_Vars.currentplayer);
objectiveCheckRoomEntered(g_Vars.currentplayer->prop->rooms[0]);
func0f08c190();
doorsCheckAutomatic();
}

View File

@ -2129,7 +2129,7 @@ void bgrabTick(void)
objectiveCheckRoomEntered(g_Vars.currentplayer->prop->rooms[0]);
bmove0f0cc19c(&g_Vars.currentplayer->prop->pos);
currentPlayerUpdatePerimInfo();
func0f08c190();
doorsCheckAutomatic();
if (g_Vars.currentplayer->grabbedprop) {
// Determine if the grabbed prop should be force released

View File

@ -2757,5 +2757,5 @@ void bwalkTick(void)
}
currentPlayerUpdatePerimInfo();
func0f08c190();
doorsCheckAutomatic();
}

View File

@ -22729,7 +22729,7 @@ glabel var7f1a9260
/* f045b44: 00000000 */ nop
/* f045b48: 8fab0030 */ lw $t3,0x30($sp)
/* f045b4c: 8e050004 */ lw $a1,0x4($s0)
/* f045b50: 0fc24030 */ jal doorChooseSwingDirection
/* f045b50: 0fc24030 */ jal doorsChooseSwingDirection
/* f045b54: 8d64001c */ lw $a0,0x1c($t3)
/* f045b58: 02002025 */ or $a0,$s0,$zero
/* f045b5c: 0fc198c4 */ jal doorCallLift

View File

@ -19237,18 +19237,18 @@ glabel var7f1aa43c
// && (door->base.flags & OBJFLAG_DOOR_KEEPOPEN) == 0
// && door->lastopen60 < g_Vars.lvframe60 - door->autoclosetime) {
// // 004
// // Check if any sibling has DOORFLAG_0010
// // Check if any sibling has DOORFLAG_AUTOMATIC
// struct doorobj *loopdoor = door->sibling;
// s32 hasflag = door->doorflags & DOORFLAG_0010;
// s32 hasflag = door->doorflags & DOORFLAG_AUTOMATIC;
//
// while (loopdoor && loopdoor != door && !hasflag) {
// hasflag = loopdoor->doorflags & DOORFLAG_0010;
// hasflag = loopdoor->doorflags & DOORFLAG_AUTOMATIC;
// loopdoor = loopdoor->sibling;
// }
//
// if (hasflag == false) {
// doorsRequestMode(door, DOORMODE_CLOSING);
// } else if (door->doorflags & DOORFLAG_0010) {
// } else if (door->doorflags & DOORFLAG_AUTOMATIC) {
// // Check if any sibling has a false return value
// s32 pass = func0f08c040(door) == false;
// struct doorobj *loopdoor = door->sibling;
@ -25568,7 +25568,7 @@ glabel var7f1aa6e4
/* f07d6f8: 00000000 */ nop
/* f07d6fc: 45000007 */ bc1f .L0f07d71c
/* f07d700: 00000000 */ nop
/* f07d704: 0fc24030 */ jal doorChooseSwingDirection
/* f07d704: 0fc24030 */ jal doorsChooseSwingDirection
/* f07d708: e7ac0058 */ swc1 $f12,0x58($sp)
/* f07d70c: 8fa401a0 */ lw $a0,0x1a0($sp)
/* f07d710: 0fc23922 */ jal doorsRequestMode
@ -26328,7 +26328,7 @@ glabel var7f1aa6e4
// + (doorprop->pos.z - prop->pos.z) * (doorprop->pos.z - prop->pos.z);
//
// if (dist < 200 * 200) {
// doorChooseSwingDirection(prop, door);
// doorsChooseSwingDirection(prop, door);
// doorsRequestMode(door, DOORMODE_OPENING);
// }
//
@ -42433,7 +42433,7 @@ glabel func0f08c040
);
GLOBAL_ASM(
glabel func0f08c190
glabel doorsCheckAutomatic
/* f08c190: 27bdfd90 */ addiu $sp,$sp,-624
/* f08c194: afb50034 */ sw $s5,0x34($sp)
/* f08c198: 3c15800a */ lui $s5,%hi(g_Vars)
@ -42615,6 +42615,71 @@ glabel func0f08c190
/* f08c420: 27bd0270 */ addiu $sp,$sp,0x270
);
/**
* Find automatic doors and open them if the player is close to them.
*/
// Mismatch: regalloc when preparing arguments for func0f08c190.
//void doorsCheckAutomatic(void)
//{
// s16 *propnumptr;
// s16 propnums[256];
//
// roomGetProps(g_Vars.currentplayer->prop->rooms, propnums, 256);
// propnumptr = propnums;
//
// while (*propnumptr >= 0) {
// struct prop *doorprop = &g_Vars.props[*propnumptr];
//
// if (doorprop->type == PROPTYPE_DOOR) {
// struct doorobj *door = doorprop->door;
//
// if ((door->doorflags & DOORFLAG_AUTOMATIC)
// && doorIsUnlocked(g_Vars.currentplayer->prop, doorprop)
// && (door->mode == DOORMODE_CLOSING || (door->mode == DOORMODE_IDLE && door->frac <= 0))) {
// bool canopen = false;
// struct defaultobj *obj = NULL;
// bool isbike = false;
// struct doorobj *sibling;
//
// if (g_Vars.currentplayer->bondmovemode == MOVEMODE_GRAB) {
// obj = bmoveGetGrabbedProp()->obj;
// } else if (g_Vars.currentplayer->bondmovemode == MOVEMODE_BIKE) {
// obj = bmoveGetHoverbike()->obj;
// isbike = true;
// }
//
// if (posIsInFrontOfDoor(&g_Vars.currentplayer->prop->pos, door) != func0f08bf78(door, &g_Vars.currentplayer->bond2.unk00)) {
// canopen = func0f08bdd4(door, &g_Vars.currentplayer->prop->pos, 0, isbike);
//
// if (!canopen && obj) {
// canopen = func0f08be80(door, obj, isbike);
// }
// }
//
// sibling = door->sibling;
//
// while (sibling && sibling != door && !canopen) {
// if (posIsInFrontOfDoor(&g_Vars.currentplayer->prop->pos, sibling) != func0f08bf78(sibling, &g_Vars.currentplayer->bond2.unk00)) {
// canopen = func0f08bdd4(sibling, &g_Vars.currentplayer->prop->pos, 0, isbike);
//
// if (!canopen && obj) {
// canopen = func0f08be80(door, obj, isbike);
// }
// }
//
// sibling = sibling->sibling;
// }
//
// if (canopen) {
// doorsRequestMode(door, DOORMODE_OPENING);
// }
// }
// }
//
// propnumptr++;
// }
//}
GLOBAL_ASM(
glabel func0f08c424
/* f08c424: 27bdffe8 */ addiu $sp,$sp,-24
@ -46294,7 +46359,7 @@ glabel posIsInFrontOfDoor
/* f0900bc: 27bd0080 */ addiu $sp,$sp,0x80
);
void doorChooseSwingDirection(struct prop *playerprop, struct doorobj *door)
void doorsChooseSwingDirection(struct prop *playerprop, struct doorobj *door)
{
if ((door->base.flags & OBJFLAG_DOOR_TWOWAY) && door->mode == DOORMODE_IDLE && door->frac == 0) {
bool infront = posIsInFrontOfDoor(&playerprop->pos, door);
@ -46330,7 +46395,7 @@ bool propdoorInteract(struct prop *doorprop)
struct prop *playerprop = usingeyespy ? g_Vars.currentplayer->eyespy->prop : g_Vars.currentplayer->prop;
if (doorIsUnlocked(playerprop, doorprop)) {
doorChooseSwingDirection(playerprop, door);
doorsChooseSwingDirection(playerprop, door);
doorsActivate(doorprop, true);
} else if (door->mode == DOORMODE_IDLE && door->frac < 0.5f * door->maxfrac) {
if ((door->base.flags2 & OBJFLAG2_00000004) == 0) {

View File

@ -652,7 +652,7 @@
#define DOORFLAG_WINDOWED 0x0002
#define DOORFLAG_0004 0x0004
#define DOORFLAG_0008 0x0008 // Changes the angle at which one-way doors can be opened
#define DOORFLAG_0010 0x0010 // Rescue door bottoms, training doors in Defense
#define DOORFLAG_AUTOMATIC 0x0010
#define DOORFLAG_0040 0x0040
#define DOORFLAG_0080 0x0080
#define DOORFLAG_0100 0x0100

View File

@ -296,11 +296,11 @@ void func0f08bb5c(struct prop *prop, bool firing, s32 room);
s32 func0f08bc5c(struct prop *prop);
u32 func0f08bcf4(void);
bool doorIsUnlocked(struct prop *playerprop, struct prop *doorprop);
u32 func0f08bdd4(void);
u32 func0f08be80(void);
u32 func0f08bf78(void);
bool func0f08bdd4(struct doorobj *door, struct coord *pos, f32 arg2, bool isbike);
bool func0f08be80(struct doorobj *door, struct defaultobj *obj, bool isbike);
bool func0f08bf78(struct doorobj *door, struct coord *pos);
s32 func0f08c040(struct doorobj *door);
void func0f08c190(void);
void doorsCheckAutomatic(void);
void func0f08c424(struct doorobj *door, void *arg1);
void func0f08c484(struct doorobj *door, void *arg1);
u32 func0f08c54c(struct doorobj *door);
@ -337,7 +337,7 @@ bool func0f08f968(struct doorobj *door, bool arg1);
bool doorTestForInteract(struct prop *prop);
void doorsActivate(struct prop *prop, bool allowliftclose);
bool posIsInFrontOfDoor(struct coord *pos, struct doorobj *door);
void doorChooseSwingDirection(struct prop *playerprop, struct doorobj *door);
void doorsChooseSwingDirection(struct prop *playerprop, struct doorobj *door);
bool propdoorInteract(struct prop *doorprop);
void alarmStopAudio(void);
u32 func0f09044c(void);