From 3a410419a8edad92cdaed5c2eb0a0cbc0a23d955 Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 12:38:25 -0700 Subject: [PATCH 01/10] Match SetNpcSpeed --- .../code_f2470_len_27f0/SetNpcSpeed.s | 34 ------------------- src/code_f2470_len_27f0.c | 9 ++--- 2 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcSpeed.s diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcSpeed.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcSpeed.s deleted file mode 100644 index 3d9bd78dce..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcSpeed.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcSpeed -/* 0F29CC 802CE01C 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0F29D0 802CE020 AFB10014 */ sw $s1, 0x14($sp) -/* 0F29D4 802CE024 0080882D */ daddu $s1, $a0, $zero -/* 0F29D8 802CE028 AFBF0018 */ sw $ra, 0x18($sp) -/* 0F29DC 802CE02C AFB00010 */ sw $s0, 0x10($sp) -/* 0F29E0 802CE030 F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0F29E4 802CE034 8E30000C */ lw $s0, 0xc($s1) -/* 0F29E8 802CE038 8E050000 */ lw $a1, ($s0) -/* 0F29EC 802CE03C 0C0B1EAF */ jal get_variable -/* 0F29F0 802CE040 26100004 */ addiu $s0, $s0, 4 -/* 0F29F4 802CE044 0220202D */ daddu $a0, $s1, $zero -/* 0F29F8 802CE048 8E050000 */ lw $a1, ($s0) -/* 0F29FC 802CE04C 0C0B210B */ jal get_float_variable -/* 0F2A00 802CE050 0040802D */ daddu $s0, $v0, $zero -/* 0F2A04 802CE054 0220202D */ daddu $a0, $s1, $zero -/* 0F2A08 802CE058 0200282D */ daddu $a1, $s0, $zero -/* 0F2A0C 802CE05C 0C0B36B0 */ jal resolve_npc -/* 0F2A10 802CE060 46000506 */ mov.s $f20, $f0 -/* 0F2A14 802CE064 54400001 */ bnel $v0, $zero, .L802CE06C -/* 0F2A18 802CE068 E4540018 */ swc1 $f20, 0x18($v0) -.L802CE06C: -/* 0F2A1C 802CE06C 24020002 */ addiu $v0, $zero, 2 -/* 0F2A20 802CE070 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F2A24 802CE074 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2A28 802CE078 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2A2C 802CE07C D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0F2A30 802CE080 03E00008 */ jr $ra -/* 0F2A34 802CE084 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index df130c56d2..33ea802e81 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -40,21 +40,18 @@ INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcScale); INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcCollisionSize); -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcSpeed); -// TODO: Fix issue with BNEZL vs BNEZ -/* ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall) { - Vytecode* ptrReadPos = script->ptrReadPos; + Bytecode* ptrReadPos = script->ptrReadPos; NpcId npcID = get_variable(script, *ptrReadPos++); f32 speed = get_float_variable(script, *ptrReadPos); Npc* npcPtr = resolve_npc(script, npcID); - npcPtr->moveSpeed = speed; if(npcPtr != NULL) { + npcPtr->moveSpeed = speed; return ApiStatus_DONE2; } + return ApiStatus_DONE2; } -*/ INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcJumpscale); From d5438113de1941e5f5c55b92efd7b922316e1fdb Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 13:44:19 -0700 Subject: [PATCH 02/10] Match SetNpcCollisionSize (Note: includes TODO) --- .../code_f2470_len_27f0/SetNpcCollisionSize.s | 43 ------------------- src/code_f2470_len_27f0.c | 18 +++++++- 2 files changed, 17 insertions(+), 44 deletions(-) delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcCollisionSize.s diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcCollisionSize.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcCollisionSize.s deleted file mode 100644 index e3286cfde6..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcCollisionSize.s +++ /dev/null @@ -1,43 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcCollisionSize -/* 0F293C 802CDF8C 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0F2940 802CDF90 AFB10014 */ sw $s1, 0x14($sp) -/* 0F2944 802CDF94 0080882D */ daddu $s1, $a0, $zero -/* 0F2948 802CDF98 AFBF0020 */ sw $ra, 0x20($sp) -/* 0F294C 802CDF9C AFB3001C */ sw $s3, 0x1c($sp) -/* 0F2950 802CDFA0 AFB20018 */ sw $s2, 0x18($sp) -/* 0F2954 802CDFA4 AFB00010 */ sw $s0, 0x10($sp) -/* 0F2958 802CDFA8 8E30000C */ lw $s0, 0xc($s1) -/* 0F295C 802CDFAC 8E050000 */ lw $a1, ($s0) -/* 0F2960 802CDFB0 0C0B1EAF */ jal get_variable -/* 0F2964 802CDFB4 26100004 */ addiu $s0, $s0, 4 -/* 0F2968 802CDFB8 8E050000 */ lw $a1, ($s0) -/* 0F296C 802CDFBC 26100004 */ addiu $s0, $s0, 4 -/* 0F2970 802CDFC0 0220202D */ daddu $a0, $s1, $zero -/* 0F2974 802CDFC4 0C0B1EAF */ jal get_variable -/* 0F2978 802CDFC8 0040902D */ daddu $s2, $v0, $zero -/* 0F297C 802CDFCC 0220202D */ daddu $a0, $s1, $zero -/* 0F2980 802CDFD0 8E050000 */ lw $a1, ($s0) -/* 0F2984 802CDFD4 0C0B1EAF */ jal get_variable -/* 0F2988 802CDFD8 0040982D */ daddu $s3, $v0, $zero -/* 0F298C 802CDFDC 0220202D */ daddu $a0, $s1, $zero -/* 0F2990 802CDFE0 0240282D */ daddu $a1, $s2, $zero -/* 0F2994 802CDFE4 0C0B36B0 */ jal resolve_npc -/* 0F2998 802CDFE8 0040802D */ daddu $s0, $v0, $zero -/* 0F299C 802CDFEC 0040182D */ daddu $v1, $v0, $zero -/* 0F29A0 802CDFF0 10600003 */ beqz $v1, .L802CE000 -/* 0F29A4 802CDFF4 24020002 */ addiu $v0, $zero, 2 -/* 0F29A8 802CDFF8 A47300A8 */ sh $s3, 0xa8($v1) -/* 0F29AC 802CDFFC A47000A6 */ sh $s0, 0xa6($v1) -.L802CE000: -/* 0F29B0 802CE000 8FBF0020 */ lw $ra, 0x20($sp) -/* 0F29B4 802CE004 8FB3001C */ lw $s3, 0x1c($sp) -/* 0F29B8 802CE008 8FB20018 */ lw $s2, 0x18($sp) -/* 0F29BC 802CE00C 8FB10014 */ lw $s1, 0x14($sp) -/* 0F29C0 802CE010 8FB00010 */ lw $s0, 0x10($sp) -/* 0F29C4 802CE014 03E00008 */ jr $ra -/* 0F29C8 802CE018 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 33ea802e81..6cc2eaae16 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -38,7 +38,23 @@ INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcRotation); INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcScale); -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcCollisionSize); +ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + s32 height = get_variable(script, *ptrReadPos++); + s32 radius = get_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching + + if (npcPtr != NULL) { + if (todo) { + npcPtr->collisionHeight = height; + npcPtr->collisionRadius = radius; + } + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall) { Bytecode* ptrReadPos = script->ptrReadPos; From d5bc60ffc970a8a94c1c3a79d86298370d21637b Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 13:46:15 -0700 Subject: [PATCH 03/10] Move todo variable declaration into if block for SetNpcCollisionSize --- src/code_f2470_len_27f0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 6cc2eaae16..04557a7f37 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -44,9 +44,9 @@ ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) { s32 height = get_variable(script, *ptrReadPos++); s32 radius = get_variable(script, *ptrReadPos++); Npc* npcPtr = resolve_npc(script, npcID); - s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching if (npcPtr != NULL) { + s32 todo = 1; if (todo) { npcPtr->collisionHeight = height; npcPtr->collisionRadius = radius; From e8d377eda00ab097cc41aefa663e64c55c556a64 Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 13:47:06 -0700 Subject: [PATCH 04/10] ...And include comment --- src/code_f2470_len_27f0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 04557a7f37..0a00d1d447 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -46,7 +46,7 @@ ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) { Npc* npcPtr = resolve_npc(script, npcID); if (npcPtr != NULL) { - s32 todo = 1; + s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching if (todo) { npcPtr->collisionHeight = height; npcPtr->collisionRadius = radius; From b88d8f7afc3bf858de5f61214d25962db60e374d Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 14:12:26 -0700 Subject: [PATCH 05/10] Match SetNpcScale, SetNpcJumpScale --- .../code_f2470_len_27f0/SetNpcJumpscale.s | 34 ------------ .../code_f2470_len_27f0/SetNpcScale.s | 53 ------------------- src/code_f2470_len_27f0.c | 35 ++++++++++-- 3 files changed, 32 insertions(+), 90 deletions(-) delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcJumpscale.s delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcScale.s diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcJumpscale.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcJumpscale.s deleted file mode 100644 index 6e3fc9f082..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcJumpscale.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcJumpscale -/* 0F2A38 802CE088 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0F2A3C 802CE08C AFB10014 */ sw $s1, 0x14($sp) -/* 0F2A40 802CE090 0080882D */ daddu $s1, $a0, $zero -/* 0F2A44 802CE094 AFBF0018 */ sw $ra, 0x18($sp) -/* 0F2A48 802CE098 AFB00010 */ sw $s0, 0x10($sp) -/* 0F2A4C 802CE09C F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0F2A50 802CE0A0 8E30000C */ lw $s0, 0xc($s1) -/* 0F2A54 802CE0A4 8E050000 */ lw $a1, ($s0) -/* 0F2A58 802CE0A8 0C0B1EAF */ jal get_variable -/* 0F2A5C 802CE0AC 26100004 */ addiu $s0, $s0, 4 -/* 0F2A60 802CE0B0 0220202D */ daddu $a0, $s1, $zero -/* 0F2A64 802CE0B4 8E050000 */ lw $a1, ($s0) -/* 0F2A68 802CE0B8 0C0B210B */ jal get_float_variable -/* 0F2A6C 802CE0BC 0040802D */ daddu $s0, $v0, $zero -/* 0F2A70 802CE0C0 0220202D */ daddu $a0, $s1, $zero -/* 0F2A74 802CE0C4 0200282D */ daddu $a1, $s0, $zero -/* 0F2A78 802CE0C8 0C0B36B0 */ jal resolve_npc -/* 0F2A7C 802CE0CC 46000506 */ mov.s $f20, $f0 -/* 0F2A80 802CE0D0 54400001 */ bnel $v0, $zero, .L802CE0D8 -/* 0F2A84 802CE0D4 E4540014 */ swc1 $f20, 0x14($v0) -.L802CE0D8: -/* 0F2A88 802CE0D8 24020002 */ addiu $v0, $zero, 2 -/* 0F2A8C 802CE0DC 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F2A90 802CE0E0 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2A94 802CE0E4 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2A98 802CE0E8 D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0F2A9C 802CE0EC 03E00008 */ jr $ra -/* 0F2AA0 802CE0F0 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcScale.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcScale.s deleted file mode 100644 index 6c7965f07a..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcScale.s +++ /dev/null @@ -1,53 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcScale -/* 0F2884 802CDED4 27BDFFC8 */ addiu $sp, $sp, -0x38 -/* 0F2888 802CDED8 AFB10014 */ sw $s1, 0x14($sp) -/* 0F288C 802CDEDC 0080882D */ daddu $s1, $a0, $zero -/* 0F2890 802CDEE0 AFBF001C */ sw $ra, 0x1c($sp) -/* 0F2894 802CDEE4 AFB20018 */ sw $s2, 0x18($sp) -/* 0F2898 802CDEE8 AFB00010 */ sw $s0, 0x10($sp) -/* 0F289C 802CDEEC F7B80030 */ sdc1 $f24, 0x30($sp) -/* 0F28A0 802CDEF0 F7B60028 */ sdc1 $f22, 0x28($sp) -/* 0F28A4 802CDEF4 F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0F28A8 802CDEF8 8E30000C */ lw $s0, 0xc($s1) -/* 0F28AC 802CDEFC 8E050000 */ lw $a1, ($s0) -/* 0F28B0 802CDF00 0C0B1EAF */ jal get_variable -/* 0F28B4 802CDF04 26100004 */ addiu $s0, $s0, 4 -/* 0F28B8 802CDF08 8E050000 */ lw $a1, ($s0) -/* 0F28BC 802CDF0C 26100004 */ addiu $s0, $s0, 4 -/* 0F28C0 802CDF10 0220202D */ daddu $a0, $s1, $zero -/* 0F28C4 802CDF14 0C0B210B */ jal get_float_variable -/* 0F28C8 802CDF18 0040902D */ daddu $s2, $v0, $zero -/* 0F28CC 802CDF1C 8E050000 */ lw $a1, ($s0) -/* 0F28D0 802CDF20 26100004 */ addiu $s0, $s0, 4 -/* 0F28D4 802CDF24 0220202D */ daddu $a0, $s1, $zero -/* 0F28D8 802CDF28 0C0B210B */ jal get_float_variable -/* 0F28DC 802CDF2C 46000606 */ mov.s $f24, $f0 -/* 0F28E0 802CDF30 0220202D */ daddu $a0, $s1, $zero -/* 0F28E4 802CDF34 8E050000 */ lw $a1, ($s0) -/* 0F28E8 802CDF38 0C0B210B */ jal get_float_variable -/* 0F28EC 802CDF3C 46000586 */ mov.s $f22, $f0 -/* 0F28F0 802CDF40 0220202D */ daddu $a0, $s1, $zero -/* 0F28F4 802CDF44 0240282D */ daddu $a1, $s2, $zero -/* 0F28F8 802CDF48 0C0B36B0 */ jal resolve_npc -/* 0F28FC 802CDF4C 46000506 */ mov.s $f20, $f0 -/* 0F2900 802CDF50 0040182D */ daddu $v1, $v0, $zero -/* 0F2904 802CDF54 10600004 */ beqz $v1, .L802CDF68 -/* 0F2908 802CDF58 24020002 */ addiu $v0, $zero, 2 -/* 0F290C 802CDF5C E4780054 */ swc1 $f24, 0x54($v1) -/* 0F2910 802CDF60 E4760058 */ swc1 $f22, 0x58($v1) -/* 0F2914 802CDF64 E474005C */ swc1 $f20, 0x5c($v1) -.L802CDF68: -/* 0F2918 802CDF68 8FBF001C */ lw $ra, 0x1c($sp) -/* 0F291C 802CDF6C 8FB20018 */ lw $s2, 0x18($sp) -/* 0F2920 802CDF70 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2924 802CDF74 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2928 802CDF78 D7B80030 */ ldc1 $f24, 0x30($sp) -/* 0F292C 802CDF7C D7B60028 */ ldc1 $f22, 0x28($sp) -/* 0F2930 802CDF80 D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0F2934 802CDF84 03E00008 */ jr $ra -/* 0F2938 802CDF88 27BD0038 */ addiu $sp, $sp, 0x38 - diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 0a00d1d447..46fbbeb616 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -36,7 +36,25 @@ INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcPos); INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcRotation); -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcScale); +ApiStatus SetNpcScale(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + f32 sizeX = get_float_variable(script, *ptrReadPos++); + f32 sizeY = get_float_variable(script, *ptrReadPos++); + f32 sizeZ = get_float_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching + if (todo) { + npcPtr->scale.x = sizeX; + npcPtr->scale.y = sizeY; + npcPtr->scale.z = sizeZ; + } + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) { Bytecode* ptrReadPos = script->ptrReadPos; @@ -64,12 +82,23 @@ ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall) { if(npcPtr != NULL) { npcPtr->moveSpeed = speed; - return ApiStatus_DONE2; + return ApiStatus_DONE2; // Doesn't match if omitted } return ApiStatus_DONE2; } -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcJumpscale); +ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + f32 jumpScale = get_float_variable(script, *ptrReadPos); + Npc* npcPtr = resolve_npc(script, npcID); + + if(npcPtr != NULL) { + npcPtr->jumpScale = jumpScale; + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcAnimation); From cd11b621c32d7f46d66b43f334dd4c6e0bb64460 Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 14:29:25 -0700 Subject: [PATCH 06/10] Modifed Npc struct w/ new float value. Match SetNpcAnimation, GetNpcAnimation, func_802CE1C (sets a float value in Npc struct) --- .../code_f2470_len_27f0/GetNpcAnimation.s | 60 ------------------- .../code_f2470_len_27f0/SetNpcAnimation.s | 34 ----------- include/common_structs.h | 4 +- src/code_f2470_len_27f0.c | 40 ++++++++++++- 4 files changed, 41 insertions(+), 97 deletions(-) delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/GetNpcAnimation.s delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcAnimation.s diff --git a/asm/nonmatchings/code_f2470_len_27f0/GetNpcAnimation.s b/asm/nonmatchings/code_f2470_len_27f0/GetNpcAnimation.s deleted file mode 100644 index 903a0fc206..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/GetNpcAnimation.s +++ /dev/null @@ -1,60 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel GetNpcAnimation -/* 0F2B10 802CE160 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F2B14 802CE164 AFB10014 */ sw $s1, 0x14($sp) -/* 0F2B18 802CE168 0080882D */ daddu $s1, $a0, $zero -/* 0F2B1C 802CE16C AFBF0018 */ sw $ra, 0x18($sp) -/* 0F2B20 802CE170 AFB00010 */ sw $s0, 0x10($sp) -/* 0F2B24 802CE174 8E30000C */ lw $s0, 0xc($s1) -/* 0F2B28 802CE178 8E050000 */ lw $a1, ($s0) -/* 0F2B2C 802CE17C 0C0B1EAF */ jal get_variable -/* 0F2B30 802CE180 26100004 */ addiu $s0, $s0, 4 -/* 0F2B34 802CE184 0220202D */ daddu $a0, $s1, $zero -/* 0F2B38 802CE188 8E100000 */ lw $s0, ($s0) -/* 0F2B3C 802CE18C 0C0B36B0 */ jal resolve_npc -/* 0F2B40 802CE190 0040282D */ daddu $a1, $v0, $zero -/* 0F2B44 802CE194 10400004 */ beqz $v0, .L802CE1A8 -/* 0F2B48 802CE198 0220202D */ daddu $a0, $s1, $zero -/* 0F2B4C 802CE19C 8C460028 */ lw $a2, 0x28($v0) -/* 0F2B50 802CE1A0 0C0B2026 */ jal set_variable -/* 0F2B54 802CE1A4 0200282D */ daddu $a1, $s0, $zero -.L802CE1A8: -/* 0F2B58 802CE1A8 24020002 */ addiu $v0, $zero, 2 -/* 0F2B5C 802CE1AC 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F2B60 802CE1B0 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2B64 802CE1B4 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2B68 802CE1B8 03E00008 */ jr $ra -/* 0F2B6C 802CE1BC 27BD0020 */ addiu $sp, $sp, 0x20 - -/* 0F2B70 802CE1C0 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0F2B74 802CE1C4 AFB10014 */ sw $s1, 0x14($sp) -/* 0F2B78 802CE1C8 0080882D */ daddu $s1, $a0, $zero -/* 0F2B7C 802CE1CC AFBF0018 */ sw $ra, 0x18($sp) -/* 0F2B80 802CE1D0 AFB00010 */ sw $s0, 0x10($sp) -/* 0F2B84 802CE1D4 F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0F2B88 802CE1D8 8E30000C */ lw $s0, 0xc($s1) -/* 0F2B8C 802CE1DC 8E050000 */ lw $a1, ($s0) -/* 0F2B90 802CE1E0 0C0B1EAF */ jal get_variable -/* 0F2B94 802CE1E4 26100004 */ addiu $s0, $s0, 4 -/* 0F2B98 802CE1E8 0220202D */ daddu $a0, $s1, $zero -/* 0F2B9C 802CE1EC 8E050000 */ lw $a1, ($s0) -/* 0F2BA0 802CE1F0 0C0B210B */ jal get_float_variable -/* 0F2BA4 802CE1F4 0040802D */ daddu $s0, $v0, $zero -/* 0F2BA8 802CE1F8 0220202D */ daddu $a0, $s1, $zero -/* 0F2BAC 802CE1FC 0200282D */ daddu $a1, $s0, $zero -/* 0F2BB0 802CE200 0C0B36B0 */ jal resolve_npc -/* 0F2BB4 802CE204 46000506 */ mov.s $f20, $f0 -/* 0F2BB8 802CE208 54400001 */ bnel $v0, $zero, .L802CE210 -/* 0F2BBC 802CE20C E4540030 */ swc1 $f20, 0x30($v0) -.L802CE210: -/* 0F2BC0 802CE210 24020002 */ addiu $v0, $zero, 2 -/* 0F2BC4 802CE214 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F2BC8 802CE218 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2BCC 802CE21C 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2BD0 802CE220 D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0F2BD4 802CE224 03E00008 */ jr $ra -/* 0F2BD8 802CE228 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcAnimation.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcAnimation.s deleted file mode 100644 index d431726f57..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcAnimation.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcAnimation -/* 0F2AA4 802CE0F4 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F2AA8 802CE0F8 AFB10014 */ sw $s1, 0x14($sp) -/* 0F2AAC 802CE0FC 0080882D */ daddu $s1, $a0, $zero -/* 0F2AB0 802CE100 AFBF0018 */ sw $ra, 0x18($sp) -/* 0F2AB4 802CE104 AFB00010 */ sw $s0, 0x10($sp) -/* 0F2AB8 802CE108 8E30000C */ lw $s0, 0xc($s1) -/* 0F2ABC 802CE10C 8E050000 */ lw $a1, ($s0) -/* 0F2AC0 802CE110 0C0B1EAF */ jal get_variable -/* 0F2AC4 802CE114 26100004 */ addiu $s0, $s0, 4 -/* 0F2AC8 802CE118 0220202D */ daddu $a0, $s1, $zero -/* 0F2ACC 802CE11C 8E050000 */ lw $a1, ($s0) -/* 0F2AD0 802CE120 0C0B1EAF */ jal get_variable -/* 0F2AD4 802CE124 0040802D */ daddu $s0, $v0, $zero -/* 0F2AD8 802CE128 0220202D */ daddu $a0, $s1, $zero -/* 0F2ADC 802CE12C 0200282D */ daddu $a1, $s0, $zero -/* 0F2AE0 802CE130 0C0B36B0 */ jal resolve_npc -/* 0F2AE4 802CE134 0040802D */ daddu $s0, $v0, $zero -/* 0F2AE8 802CE138 10400003 */ beqz $v0, .L802CE148 -/* 0F2AEC 802CE13C 0040202D */ daddu $a0, $v0, $zero -/* 0F2AF0 802CE140 0C0B36C3 */ jal set_npc_animation -/* 0F2AF4 802CE144 0200282D */ daddu $a1, $s0, $zero -.L802CE148: -/* 0F2AF8 802CE148 24020002 */ addiu $v0, $zero, 2 -/* 0F2AFC 802CE14C 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F2B00 802CE150 8FB10014 */ lw $s1, 0x14($sp) -/* 0F2B04 802CE154 8FB00010 */ lw $s0, 0x10($sp) -/* 0F2B08 802CE158 03E00008 */ jr $ra -/* 0F2B0C 802CE15C 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/common_structs.h b/include/common_structs.h index 4594c1bd46..42eb93da85 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -61,7 +61,9 @@ typedef struct Npc { /* 0x020 */ struct NpcBlurData* blurData; /* related to movement somehow... */ /* 0x024 */ char unk_24[4]; /* 0x028 */ u32 currentAnim; - /* 0x02C */ char unk_2C[12]; + /* 0x02C */ char unk_2C[4]; + /* 0x030 */ f32 unk_30; + /* 0x034 */ char unk_34[4]; /* 0x038 */ struct Vec3f pos; /* 0x044 */ struct Vec3f rotation; /* 0x050 */ char unk_50[4]; diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 46fbbeb616..fe95dd047c 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -100,9 +100,45 @@ ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcAnimation); +ApiStatus SetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + s32 animation = get_variable(script, *ptrReadPos); + Npc* npcPtr = resolve_npc(script, npcID); -INCLUDE_API_ASM(code_f2470_len_27f0, GetNpcAnimation); + if (npcPtr != NULL) { + set_npc_animation(npcPtr, animation); + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} + +ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + Bytecode outVar = *ptrReadPos++; + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + set_variable(script, outVar, npcPtr->currentAnim); + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} + +// TODO: Figure out meaning of float value in Npc struct that this function is setting +ApiStatus func_802CE1C0(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + f32 value1 = get_float_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + npcPtr->unk_30 = value1; + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} INCLUDE_API_ASM(code_f2470_len_27f0, NpcMoveTo); From d844156076d805d48f9c74318d6a675d901529ee Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 15:51:58 -0700 Subject: [PATCH 07/10] Rename func_802CE1C0 to SetNpcAnimationSpeed --- include/common_structs.h | 2 +- src/code_f2470_len_27f0.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 42eb93da85..a56d5e37ca 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -62,7 +62,7 @@ typedef struct Npc { /* 0x024 */ char unk_24[4]; /* 0x028 */ u32 currentAnim; /* 0x02C */ char unk_2C[4]; - /* 0x030 */ f32 unk_30; + /* 0x030 */ f32 animationSpeed; /* 0x034 */ char unk_34[4]; /* 0x038 */ struct Vec3f pos; /* 0x044 */ struct Vec3f rotation; diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index fe95dd047c..68c1fa7b40 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -127,14 +127,14 @@ ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { } // TODO: Figure out meaning of float value in Npc struct that this function is setting -ApiStatus func_802CE1C0(ScriptInstance* script, s32 isInitialCall) { +ApiStatus SetNpcAnimationSpeed(ScriptInstance* script, s32 isInitialCall) { Bytecode* ptrReadPos = script->ptrReadPos; NpcId npcID = get_variable(script, *ptrReadPos++); - f32 value1 = get_float_variable(script, *ptrReadPos++); + f32 animationSpeed = get_float_variable(script, *ptrReadPos++); Npc* npcPtr = resolve_npc(script, npcID); if (npcPtr != NULL) { - npcPtr->unk_30 = value1; + npcPtr->animationSpeed = animationSpeed; return ApiStatus_DONE2; // Doesn't match if omitted } return ApiStatus_DONE2; From 63f82542274abc8bfb3dbd1749d3b0dcacf4b0cd Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 15:53:04 -0700 Subject: [PATCH 08/10] And remove TODO --- src/code_f2470_len_27f0.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 68c1fa7b40..28e3c0c15d 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -126,7 +126,6 @@ ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -// TODO: Figure out meaning of float value in Npc struct that this function is setting ApiStatus SetNpcAnimationSpeed(ScriptInstance* script, s32 isInitialCall) { Bytecode* ptrReadPos = script->ptrReadPos; NpcId npcID = get_variable(script, *ptrReadPos++); From 17d513eeba24fd2a87b172740441f5c707c06820 Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 17:31:39 -0700 Subject: [PATCH 09/10] Added function prototype for set_npc_yaw. Match NpcJump0, NpcJump1, GetNpcYaw, SetNpcYaw --- .../code_f2470_len_27f0/GetNpcYaw.s | 36 ----------------- .../code_f2470_len_27f0/NpcJump0.s | 13 ------- .../code_f2470_len_27f0/NpcJump1.s | 13 ------- .../code_f2470_len_27f0/SetNpcYaw.s | 39 ------------------- include/functions.h | 1 + src/code_13870_len_6980.c | 2 +- src/code_f2470_len_27f0.c | 36 +++++++++++++++-- 7 files changed, 34 insertions(+), 106 deletions(-) delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/GetNpcYaw.s delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/NpcJump0.s delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/NpcJump1.s delete mode 100644 asm/nonmatchings/code_f2470_len_27f0/SetNpcYaw.s diff --git a/asm/nonmatchings/code_f2470_len_27f0/GetNpcYaw.s b/asm/nonmatchings/code_f2470_len_27f0/GetNpcYaw.s deleted file mode 100644 index 87129f245b..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/GetNpcYaw.s +++ /dev/null @@ -1,36 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel GetNpcYaw -/* 0F33C0 802CEA10 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F33C4 802CEA14 AFB10014 */ sw $s1, 0x14($sp) -/* 0F33C8 802CEA18 0080882D */ daddu $s1, $a0, $zero -/* 0F33CC 802CEA1C AFBF0018 */ sw $ra, 0x18($sp) -/* 0F33D0 802CEA20 AFB00010 */ sw $s0, 0x10($sp) -/* 0F33D4 802CEA24 8E30000C */ lw $s0, 0xc($s1) -/* 0F33D8 802CEA28 8E050000 */ lw $a1, ($s0) -/* 0F33DC 802CEA2C 0C0B1EAF */ jal get_variable -/* 0F33E0 802CEA30 26100004 */ addiu $s0, $s0, 4 -/* 0F33E4 802CEA34 0220202D */ daddu $a0, $s1, $zero -/* 0F33E8 802CEA38 8E100000 */ lw $s0, ($s0) -/* 0F33EC 802CEA3C 0C0B36B0 */ jal resolve_npc -/* 0F33F0 802CEA40 0040282D */ daddu $a1, $v0, $zero -/* 0F33F4 802CEA44 5040000A */ beql $v0, $zero, .L802CEA70 -/* 0F33F8 802CEA48 24020002 */ addiu $v0, $zero, 2 -/* 0F33FC 802CEA4C C44C000C */ lwc1 $f12, 0xc($v0) -/* 0F3400 802CEA50 0C00A6C9 */ jal clamp_angle -/* 0F3404 802CEA54 00000000 */ nop -/* 0F3408 802CEA58 0220202D */ daddu $a0, $s1, $zero -/* 0F340C 802CEA5C 4600008D */ trunc.w.s $f2, $f0 -/* 0F3410 802CEA60 44061000 */ mfc1 $a2, $f2 -/* 0F3414 802CEA64 0C0B2026 */ jal set_variable -/* 0F3418 802CEA68 0200282D */ daddu $a1, $s0, $zero -/* 0F341C 802CEA6C 24020002 */ addiu $v0, $zero, 2 -.L802CEA70: -/* 0F3420 802CEA70 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F3424 802CEA74 8FB10014 */ lw $s1, 0x14($sp) -/* 0F3428 802CEA78 8FB00010 */ lw $s0, 0x10($sp) -/* 0F342C 802CEA7C 03E00008 */ jr $ra -/* 0F3430 802CEA80 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/NpcJump0.s b/asm/nonmatchings/code_f2470_len_27f0/NpcJump0.s deleted file mode 100644 index 4562c6e55d..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/NpcJump0.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel NpcJump0 -/* 0F3074 802CE6C4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0F3078 802CE6C8 AFBF0010 */ sw $ra, 0x10($sp) -/* 0F307C 802CE6CC 0C0B390D */ jal _npc_jump_to -/* 0F3080 802CE6D0 0000302D */ daddu $a2, $zero, $zero -/* 0F3084 802CE6D4 8FBF0010 */ lw $ra, 0x10($sp) -/* 0F3088 802CE6D8 03E00008 */ jr $ra -/* 0F308C 802CE6DC 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/NpcJump1.s b/asm/nonmatchings/code_f2470_len_27f0/NpcJump1.s deleted file mode 100644 index 990cfe08e0..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/NpcJump1.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel NpcJump1 -/* 0F3090 802CE6E0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0F3094 802CE6E4 AFBF0010 */ sw $ra, 0x10($sp) -/* 0F3098 802CE6E8 0C0B390D */ jal _npc_jump_to -/* 0F309C 802CE6EC 24060001 */ addiu $a2, $zero, 1 -/* 0F30A0 802CE6F0 8FBF0010 */ lw $ra, 0x10($sp) -/* 0F30A4 802CE6F4 03E00008 */ jr $ra -/* 0F30A8 802CE6F8 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/SetNpcYaw.s b/asm/nonmatchings/code_f2470_len_27f0/SetNpcYaw.s deleted file mode 100644 index 293c1c3504..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/SetNpcYaw.s +++ /dev/null @@ -1,39 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel SetNpcYaw -/* 0F3434 802CEA84 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F3438 802CEA88 AFB20018 */ sw $s2, 0x18($sp) -/* 0F343C 802CEA8C 0080902D */ daddu $s2, $a0, $zero -/* 0F3440 802CEA90 AFBF001C */ sw $ra, 0x1c($sp) -/* 0F3444 802CEA94 AFB10014 */ sw $s1, 0x14($sp) -/* 0F3448 802CEA98 AFB00010 */ sw $s0, 0x10($sp) -/* 0F344C 802CEA9C 8E50000C */ lw $s0, 0xc($s2) -/* 0F3450 802CEAA0 8E050000 */ lw $a1, ($s0) -/* 0F3454 802CEAA4 0C0B1EAF */ jal get_variable -/* 0F3458 802CEAA8 26100004 */ addiu $s0, $s0, 4 -/* 0F345C 802CEAAC 0240202D */ daddu $a0, $s2, $zero -/* 0F3460 802CEAB0 0C0B36B0 */ jal resolve_npc -/* 0F3464 802CEAB4 0040282D */ daddu $a1, $v0, $zero -/* 0F3468 802CEAB8 0040882D */ daddu $s1, $v0, $zero -/* 0F346C 802CEABC 1220000B */ beqz $s1, .L802CEAEC -/* 0F3470 802CEAC0 24020002 */ addiu $v0, $zero, 2 -/* 0F3474 802CEAC4 8E050000 */ lw $a1, ($s0) -/* 0F3478 802CEAC8 0C0B1EAF */ jal get_variable -/* 0F347C 802CEACC 0240202D */ daddu $a0, $s2, $zero -/* 0F3480 802CEAD0 44820000 */ mtc1 $v0, $f0 -/* 0F3484 802CEAD4 00000000 */ nop -/* 0F3488 802CEAD8 46800020 */ cvt.s.w $f0, $f0 -/* 0F348C 802CEADC 44050000 */ mfc1 $a1, $f0 -/* 0F3490 802CEAE0 0C00ECD0 */ jal set_npc_yaw -/* 0F3494 802CEAE4 0220202D */ daddu $a0, $s1, $zero -/* 0F3498 802CEAE8 24020002 */ addiu $v0, $zero, 2 -.L802CEAEC: -/* 0F349C 802CEAEC 8FBF001C */ lw $ra, 0x1c($sp) -/* 0F34A0 802CEAF0 8FB20018 */ lw $s2, 0x18($sp) -/* 0F34A4 802CEAF4 8FB10014 */ lw $s1, 0x14($sp) -/* 0F34A8 802CEAF8 8FB00010 */ lw $s0, 0x10($sp) -/* 0F34AC 802CEAFC 03E00008 */ jr $ra -/* 0F34B0 802CEB00 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/functions.h b/include/functions.h index e61f021837..69350a9b51 100644 --- a/include/functions.h +++ b/include/functions.h @@ -35,6 +35,7 @@ f32 update_lerp(Easing easing, f32 start, f32 end, s32 elapsed, s32 duration); Npc* get_npc_safe(NpcId npcId); Npc* get_npc_unsafe(NpcId npcId); Npc* resolve_npc(ScriptInstance* script, NpcId npcIdOrPtr); +void set_npc_yaw(Npc* npcPtr, f32 angle); f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by); f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz); diff --git a/src/code_13870_len_6980.c b/src/code_13870_len_6980.c index 12cc0c59b8..b28c9c5755 100644 --- a/src/code_13870_len_6980.c +++ b/src/code_13870_len_6980.c @@ -64,7 +64,7 @@ INCLUDE_ASM(code_13870_len_6980, func_8003B1A8); INCLUDE_ASM(code_13870_len_6980, func_8003B1B0); -INCLUDE_ASM(code_13870_len_6980, set_npc_yaw); +void INCLUDE_ASM(code_13870_len_6980, set_npc_yaw, Npc* npcPtr, f32 angle); INCLUDE_ASM(code_13870_len_6980, func_8003B3D0); diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 28e3c0c15d..20d8b64b5b 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -143,15 +143,43 @@ INCLUDE_API_ASM(code_f2470_len_27f0, NpcMoveTo); INCLUDE_ASM(code_f2470_len_27f0, _npc_jump_to); -INCLUDE_API_ASM(code_f2470_len_27f0, NpcJump0); +void NpcJump0(ScriptInstance* script, s32 isInitialCall) { + _npc_jump_to(script, isInitialCall, 0); +} -INCLUDE_API_ASM(code_f2470_len_27f0, NpcJump1); +void NpcJump1(ScriptInstance* script, s32 isInitialCall) { + _npc_jump_to(script, isInitialCall, 1); +} INCLUDE_API_ASM(code_f2470_len_27f0, NpcFlyTo); -INCLUDE_API_ASM(code_f2470_len_27f0, GetNpcYaw); +ApiStatus GetNpcYaw(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + Bytecode outVar = *ptrReadPos++; + Npc* npcPtr = resolve_npc(script, npcID); -INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcYaw); + if (npcPtr != NULL) { + s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching + if (todo) { + set_variable(script, outVar, clamp_angle(npcPtr->yaw)); + } + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} + +ApiStatus SetNpcYaw(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + set_npc_yaw(npcPtr, get_variable(script, *ptrReadPos++)); + return ApiStatus_DONE2; // Doesn't match if omitted + } + return ApiStatus_DONE2; +} INCLUDE_API_ASM(code_f2470_len_27f0, InterpNpcYaw); From 2864ba6476d419720e4da7c0fbbcaca6bc6e272b Mon Sep 17 00:00:00 2001 From: Jdog Date: Tue, 18 Aug 2020 18:24:56 -0700 Subject: [PATCH 10/10] Remove comments about omitting return statements --- src/code_f2470_len_27f0.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 20d8b64b5b..470df683ca 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -51,7 +51,7 @@ ApiStatus SetNpcScale(ScriptInstance* script, s32 isInitialCall) { npcPtr->scale.y = sizeY; npcPtr->scale.z = sizeZ; } - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -69,7 +69,7 @@ ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) { npcPtr->collisionHeight = height; npcPtr->collisionRadius = radius; } - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -82,7 +82,7 @@ ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall) { if(npcPtr != NULL) { npcPtr->moveSpeed = speed; - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -95,7 +95,7 @@ ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall) { if(npcPtr != NULL) { npcPtr->jumpScale = jumpScale; - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -108,7 +108,7 @@ ApiStatus SetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { if (npcPtr != NULL) { set_npc_animation(npcPtr, animation); - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -121,7 +121,7 @@ ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall) { if (npcPtr != NULL) { set_variable(script, outVar, npcPtr->currentAnim); - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -134,7 +134,7 @@ ApiStatus SetNpcAnimationSpeed(ScriptInstance* script, s32 isInitialCall) { if (npcPtr != NULL) { npcPtr->animationSpeed = animationSpeed; - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -164,7 +164,7 @@ ApiStatus GetNpcYaw(ScriptInstance* script, s32 isInitialCall) { if (todo) { set_variable(script, outVar, clamp_angle(npcPtr->yaw)); } - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; } @@ -176,7 +176,7 @@ ApiStatus SetNpcYaw(ScriptInstance* script, s32 isInitialCall) { if (npcPtr != NULL) { set_npc_yaw(npcPtr, get_variable(script, *ptrReadPos++)); - return ApiStatus_DONE2; // Doesn't match if omitted + return ApiStatus_DONE2; } return ApiStatus_DONE2; }