Modifed Npc struct w/ new float value. Match SetNpcAnimation, GetNpcAnimation, func_802CE1C (sets a float value in Npc struct)

This commit is contained in:
Jdog 2020-08-18 14:29:25 -07:00
parent b88d8f7afc
commit cd11b621c3
4 changed files with 41 additions and 97 deletions

View File

@ -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

View File

@ -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

View File

@ -61,7 +61,9 @@ typedef struct Npc {
/* 0x020 */ struct NpcBlurData* blurData; /* related to movement somehow... */ /* 0x020 */ struct NpcBlurData* blurData; /* related to movement somehow... */
/* 0x024 */ char unk_24[4]; /* 0x024 */ char unk_24[4];
/* 0x028 */ u32 currentAnim; /* 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; /* 0x038 */ struct Vec3f pos;
/* 0x044 */ struct Vec3f rotation; /* 0x044 */ struct Vec3f rotation;
/* 0x050 */ char unk_50[4]; /* 0x050 */ char unk_50[4];

View File

@ -100,9 +100,45 @@ ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2; 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); INCLUDE_API_ASM(code_f2470_len_27f0, NpcMoveTo);