From a63372bb7a87b177d492cd4eb3d0b85d0f289b6b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 19 Oct 2019 22:36:17 +1000 Subject: [PATCH] Decompile aiSetDoorClosed --- src/game/chr/chraicommands.c | 65 +++++++++------------------- src/include/game/chr/chraicommands.h | 2 +- src/include/gvars/gvars.h | 2 +- src/include/types.h | 32 +++++++++++--- src/setup/setup_000000.c | 2 +- 5 files changed, 48 insertions(+), 55 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index dd0e9f3c9..96e167b12 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -9825,51 +9825,26 @@ glabel ai00e5 /** * @cmd 00e8 */ -GLOBAL_ASM( -glabel ai00e8 -/* f057b78: 3c03800a */ lui $v1,0x800a -/* f057b7c: 24639fc0 */ addiu $v1,$v1,-24640 -/* f057b80: 8c6e0434 */ lw $t6,0x434($v1) -/* f057b84: 8c6f0438 */ lw $t7,0x438($v1) -/* f057b88: 27bdffe0 */ addiu $sp,$sp,-32 -/* f057b8c: afbf0014 */ sw $ra,0x14($sp) -/* f057b90: 01cf1021 */ addu $v0,$t6,$t7 -/* f057b94: 0fc2556c */ jal objFindByTagId -/* f057b98: 90440002 */ lbu $a0,0x2($v0) -/* f057b9c: 10400016 */ beqz $v0,.L0f057bf8 -/* f057ba0: 00000000 */ sll $zero,$zero,0x0 -/* f057ba4: 8c580014 */ lw $t8,0x14($v0) -/* f057ba8: 13000013 */ beqz $t8,.L0f057bf8 -/* f057bac: 00000000 */ sll $zero,$zero,0x0 -/* f057bb0: c444005c */ lwc1 $f4,0x5c($v0) -/* f057bb4: 44803000 */ mtc1 $zero,$f6 -/* f057bb8: 3c19800a */ lui $t9,0x800a -/* f057bbc: e444007c */ swc1 $f4,0x7c($v0) -/* f057bc0: e4460080 */ swc1 $f6,0x80($v0) -/* f057bc4: 8f399fc8 */ lw $t9,-0x6038($t9) -/* f057bc8: a0400084 */ sb $zero,0x84($v0) -/* f057bcc: 00402025 */ or $a0,$v0,$zero -/* f057bd0: ac5900c0 */ sw $t9,0xc0($v0) -/* f057bd4: 0fc23153 */ jal func0f08c54c -/* f057bd8: afa20018 */ sw $v0,0x18($sp) -/* f057bdc: 0fc2353a */ jal func0f08d4e8 -/* f057be0: 8fa40018 */ lw $a0,0x18($sp) -/* f057be4: 8fa70018 */ lw $a3,0x18($sp) -/* f057be8: 24050001 */ addiu $a1,$zero,0x1 -/* f057bec: 3406ffff */ dli $a2,0xffff -/* f057bf0: 0fc249af */ jal func0f0926bc -/* f057bf4: 8ce40014 */ lw $a0,0x14($a3) -.L0f057bf8: -/* f057bf8: 3c08800a */ lui $t0,0x800a -/* f057bfc: 8d08a3f8 */ lw $t0,-0x5c08($t0) -/* f057c00: 8fbf0014 */ lw $ra,0x14($sp) -/* f057c04: 3c01800a */ lui $at,0x800a -/* f057c08: 25090003 */ addiu $t1,$t0,0x3 -/* f057c0c: ac29a3f8 */ sw $t1,-0x5c08($at) -/* f057c10: 27bd0020 */ addiu $sp,$sp,0x20 -/* f057c14: 03e00008 */ jr $ra -/* f057c18: 00001025 */ or $v0,$zero,$zero -); +bool aiSetDoorClosed(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + struct defaultobj *obj = objFindByTagId(cmd[2]); + + if (obj && obj->pos) { + struct doorobj *door = (struct doorobj *) obj; + door->speed = door->unk5c; + door->unk80 = 0; + door->unkc0 = g_Vars.unk000008; + door->state = 0; + func0f08c54c(door); + func0f08d4e8(door); + func0f0926bc(door->base.pos, 1, 0xffff); + } + + g_Vars.aioffset += 3; + + return false; +} /** * @cmd 00e9 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 7450eea13..8feacec47 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -232,7 +232,7 @@ /*0x00e3*/ bool ai00e3(void); /*0x00e4*/ bool ai00e4(void); /*0x00e5*/ bool ai00e5(void); -/*0x00e8*/ bool ai00e8(void); +/*0x00e8*/ bool aiSetDoorClosed(void); /*0x00e9*/ bool ai00e9(void); /*0x00ea*/ bool ai00ea(void); /*0x00eb*/ bool ai00eb(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 76c6cbe91..c4de2b30a 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -281,7 +281,7 @@ struct g_vars { /*00041c*/ u32 unk00041c; /*000420*/ u32 unk000420; /*000424*/ struct chrdata *chrdata; - /*000428*/ struct defaultobj *objdata; + /*000428*/ struct standardobj *objdata; /*00042c*/ struct otheraidata *aicdata; /*000430*/ struct otheraidata *aiddata; /*000434*/ u8 *ailist; diff --git a/src/include/types.h b/src/include/types.h index 9d987374a..4a01f6278 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -265,16 +265,12 @@ struct defaultobj { /*0x54*/ u32 nextcol; /*0x58*/ u16 floorcol; /*0x5a*/ u8 numtiles; - - // These properties might not be part of defaultobj, - // but rather standard objs only - /*0x5c*/ u8 *ailist; - /*0x60*/ u16 aioffset; - /*0x62*/ u16 aireturnlist; }; struct doorobj { // objtype 0x01 struct defaultobj base; + /*0x5c*/ float unk5c; + /*0x60*/ u32 unk60; /*0x64*/ u32 unk64; /*0x68*/ u32 unk68; /*0x6c*/ u32 unk6c; @@ -282,8 +278,30 @@ struct doorobj { // objtype 0x01 /*0x74*/ u32 unk74; /*0x78*/ u32 unk78; /*0x7c*/ float speed; - /*0x80*/ u32 unk80; + /*0x80*/ float unk80; /*0x84*/ s8 state; + /*0x88*/ u32 unk88; + /*0x8c*/ u32 unk8c; + /*0x90*/ u32 unk90; + /*0x94*/ u32 unk94; + /*0x98*/ u32 unk98; + /*0x9c*/ u32 unk9c; + /*0xa0*/ u32 unka0; + /*0xa4*/ u32 unka4; + /*0xa8*/ u32 unka8; + /*0xac*/ u32 unkac; + /*0xb0*/ u32 unkb0; + /*0xb4*/ u32 unkb4; + /*0xb8*/ u32 unkb8; + /*0xbc*/ u32 unkbc; + /*0xc0*/ u32 unkc0; +}; + +struct standardobj { // objtype 0x03 + struct defaultobj base; + /*0x5c*/ u8 *ailist; + /*0x60*/ u16 aioffset; + /*0x62*/ u16 aireturnlist; }; struct image { diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 113ccff8f..a1263adca 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14185,7 +14185,7 @@ bool (*command_pointers[])(void) = { /*0x00e5*/ ai00e5, /*0x00e6*/ NULL, /*0x00e7*/ NULL, - /*0x00e8*/ ai00e8, + /*0x00e8*/ aiSetDoorClosed, /*0x00e9*/ ai00e9, /*0x00ea*/ ai00ea, /*0x00eb*/ ai00eb,