diff --git a/asm/nonmatchings/code_f2470_len_27f0/ClearPartnerMoveHistory.s b/asm/nonmatchings/code_f2470_len_27f0/ClearPartnerMoveHistory.s deleted file mode 100644 index 0df55d3a6f..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/ClearPartnerMoveHistory.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel ClearPartnerMoveHistory -/* 0F3D20 802CF370 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0F3D24 802CF374 AFB00010 */ sw $s0, 0x10($sp) -/* 0F3D28 802CF378 0080802D */ daddu $s0, $a0, $zero -/* 0F3D2C 802CF37C AFBF0014 */ sw $ra, 0x14($sp) -/* 0F3D30 802CF380 8E02000C */ lw $v0, 0xc($s0) -/* 0F3D34 802CF384 0C0B1EAF */ jal get_variable -/* 0F3D38 802CF388 8C450000 */ lw $a1, ($v0) -/* 0F3D3C 802CF38C 0200202D */ daddu $a0, $s0, $zero -/* 0F3D40 802CF390 0C0B36B0 */ jal resolve_npc -/* 0F3D44 802CF394 0040282D */ daddu $a1, $v0, $zero -/* 0F3D48 802CF398 50400004 */ beql $v0, $zero, .L802CF3AC -/* 0F3D4C 802CF39C 24020002 */ addiu $v0, $zero, 2 -/* 0F3D50 802CF3A0 0C03BD17 */ jal clear_partner_move_history -/* 0F3D54 802CF3A4 0040202D */ daddu $a0, $v0, $zero -/* 0F3D58 802CF3A8 24020002 */ addiu $v0, $zero, 2 -.L802CF3AC: -/* 0F3D5C 802CF3AC 8FBF0014 */ lw $ra, 0x14($sp) -/* 0F3D60 802CF3B0 8FB00010 */ lw $s0, 0x10($sp) -/* 0F3D64 802CF3B4 03E00008 */ jr $ra -/* 0F3D68 802CF3B8 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/DisablePartnerAI.s b/asm/nonmatchings/code_f2470_len_27f0/DisablePartnerAI.s deleted file mode 100644 index 5f5fb43f4d..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/DisablePartnerAI.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel DisablePartnerAI -/* 0F3E98 802CF4E8 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0F3E9C 802CF4EC AFBF0010 */ sw $ra, 0x10($sp) -/* 0F3EA0 802CF4F0 8C82000C */ lw $v0, 0xc($a0) -/* 0F3EA4 802CF4F4 0C0B1EAF */ jal get_variable -/* 0F3EA8 802CF4F8 8C450000 */ lw $a1, ($v0) -/* 0F3EAC 802CF4FC 14400005 */ bnez $v0, .L802CF514 -/* 0F3EB0 802CF500 00000000 */ nop -/* 0F3EB4 802CF504 0C03BCC5 */ jal func_800EF314 -/* 0F3EB8 802CF508 00000000 */ nop -/* 0F3EBC 802CF50C 080B3D47 */ j .L802CF51C -/* 0F3EC0 802CF510 00000000 */ nop - -.L802CF514: -/* 0F3EC4 802CF514 0C03BCC0 */ jal func_800EF300 -/* 0F3EC8 802CF518 00000000 */ nop -.L802CF51C: -/* 0F3ECC 802CF51C 8FBF0010 */ lw $ra, 0x10($sp) -/* 0F3ED0 802CF520 24020002 */ addiu $v0, $zero, 2 -/* 0F3ED4 802CF524 03E00008 */ jr $ra -/* 0F3ED8 802CF528 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/EnableNpcBlur.s b/asm/nonmatchings/code_f2470_len_27f0/EnableNpcBlur.s deleted file mode 100644 index f9afaf4111..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/EnableNpcBlur.s +++ /dev/null @@ -1,42 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel EnableNpcBlur -/* 0F3C9C 802CF2EC 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F3CA0 802CF2F0 AFB10014 */ sw $s1, 0x14($sp) -/* 0F3CA4 802CF2F4 0080882D */ daddu $s1, $a0, $zero -/* 0F3CA8 802CF2F8 AFBF0018 */ sw $ra, 0x18($sp) -/* 0F3CAC 802CF2FC AFB00010 */ sw $s0, 0x10($sp) -/* 0F3CB0 802CF300 8E30000C */ lw $s0, 0xc($s1) -/* 0F3CB4 802CF304 8E050000 */ lw $a1, ($s0) -/* 0F3CB8 802CF308 0C0B1EAF */ jal get_variable -/* 0F3CBC 802CF30C 26100004 */ addiu $s0, $s0, 4 -/* 0F3CC0 802CF310 0220202D */ daddu $a0, $s1, $zero -/* 0F3CC4 802CF314 8E050000 */ lw $a1, ($s0) -/* 0F3CC8 802CF318 0C0B1EAF */ jal get_variable -/* 0F3CCC 802CF31C 0040802D */ daddu $s0, $v0, $zero -/* 0F3CD0 802CF320 0220202D */ daddu $a0, $s1, $zero -/* 0F3CD4 802CF324 0200282D */ daddu $a1, $s0, $zero -/* 0F3CD8 802CF328 0C0B36B0 */ jal resolve_npc -/* 0F3CDC 802CF32C 0040802D */ daddu $s0, $v0, $zero -/* 0F3CE0 802CF330 5040000A */ beql $v0, $zero, .L802CF35C -/* 0F3CE4 802CF334 24020002 */ addiu $v0, $zero, 2 -/* 0F3CE8 802CF338 12000005 */ beqz $s0, .L802CF350 -/* 0F3CEC 802CF33C 00000000 */ nop -/* 0F3CF0 802CF340 0C00EB49 */ jal enable_npc_blur -/* 0F3CF4 802CF344 0040202D */ daddu $a0, $v0, $zero -/* 0F3CF8 802CF348 080B3CD7 */ j .L802CF35C -/* 0F3CFC 802CF34C 24020002 */ addiu $v0, $zero, 2 - -.L802CF350: -/* 0F3D00 802CF350 0C00EB6B */ jal disable_npc_blur -/* 0F3D04 802CF354 0040202D */ daddu $a0, $v0, $zero -/* 0F3D08 802CF358 24020002 */ addiu $v0, $zero, 2 -.L802CF35C: -/* 0F3D0C 802CF35C 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F3D10 802CF360 8FB10014 */ lw $s1, 0x14($sp) -/* 0F3D14 802CF364 8FB00010 */ lw $s0, 0x10($sp) -/* 0F3D18 802CF368 03E00008 */ jr $ra -/* 0F3D1C 802CF36C 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/EnableNpcShadow.s b/asm/nonmatchings/code_f2470_len_27f0/EnableNpcShadow.s deleted file mode 100644 index 6fd53b6e0a..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/EnableNpcShadow.s +++ /dev/null @@ -1,42 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel EnableNpcShadow -/* 0F3C18 802CF268 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0F3C1C 802CF26C AFB10014 */ sw $s1, 0x14($sp) -/* 0F3C20 802CF270 0080882D */ daddu $s1, $a0, $zero -/* 0F3C24 802CF274 AFBF0018 */ sw $ra, 0x18($sp) -/* 0F3C28 802CF278 AFB00010 */ sw $s0, 0x10($sp) -/* 0F3C2C 802CF27C 8E30000C */ lw $s0, 0xc($s1) -/* 0F3C30 802CF280 8E050000 */ lw $a1, ($s0) -/* 0F3C34 802CF284 0C0B1EAF */ jal get_variable -/* 0F3C38 802CF288 26100004 */ addiu $s0, $s0, 4 -/* 0F3C3C 802CF28C 0220202D */ daddu $a0, $s1, $zero -/* 0F3C40 802CF290 8E050000 */ lw $a1, ($s0) -/* 0F3C44 802CF294 0C0B1EAF */ jal get_variable -/* 0F3C48 802CF298 0040802D */ daddu $s0, $v0, $zero -/* 0F3C4C 802CF29C 0220202D */ daddu $a0, $s1, $zero -/* 0F3C50 802CF2A0 0200282D */ daddu $a1, $s0, $zero -/* 0F3C54 802CF2A4 0C0B36B0 */ jal resolve_npc -/* 0F3C58 802CF2A8 0040802D */ daddu $s0, $v0, $zero -/* 0F3C5C 802CF2AC 5040000A */ beql $v0, $zero, .L802CF2D8 -/* 0F3C60 802CF2B0 24020002 */ addiu $v0, $zero, 2 -/* 0F3C64 802CF2B4 12000005 */ beqz $s0, .L802CF2CC -/* 0F3C68 802CF2B8 00000000 */ nop -/* 0F3C6C 802CF2BC 0C00EAE8 */ jal enable_npc_shadow -/* 0F3C70 802CF2C0 0040202D */ daddu $a0, $v0, $zero -/* 0F3C74 802CF2C4 080B3CB6 */ j .L802CF2D8 -/* 0F3C78 802CF2C8 24020002 */ addiu $v0, $zero, 2 - -.L802CF2CC: -/* 0F3C7C 802CF2CC 0C00EAFF */ jal disable_npc_shadow -/* 0F3C80 802CF2D0 0040202D */ daddu $a0, $v0, $zero -/* 0F3C84 802CF2D4 24020002 */ addiu $v0, $zero, 2 -.L802CF2D8: -/* 0F3C88 802CF2D8 8FBF0018 */ lw $ra, 0x18($sp) -/* 0F3C8C 802CF2DC 8FB10014 */ lw $s1, 0x14($sp) -/* 0F3C90 802CF2E0 8FB00010 */ lw $s0, 0x10($sp) -/* 0F3C94 802CF2E4 03E00008 */ jr $ra -/* 0F3C98 802CF2E8 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/code_f2470_len_27f0/EnablePartnerAI.s b/asm/nonmatchings/code_f2470_len_27f0/EnablePartnerAI.s index 18711a8d6f..8b681d06f3 100644 --- a/asm/nonmatchings/code_f2470_len_27f0/EnablePartnerAI.s +++ b/asm/nonmatchings/code_f2470_len_27f0/EnablePartnerAI.s @@ -12,6 +12,7 @@ glabel EnablePartnerAI /* 0F3EF4 802CF544 03E00008 */ jr $ra /* 0F3EF8 802CF548 27BD0018 */ addiu $sp, $sp, 0x18 +glabel func_802CF54C /* 0F3EFC 802CF54C 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 0F3F00 802CF550 AFBF0010 */ sw $ra, 0x10($sp) /* 0F3F04 802CF554 0C03BD0F */ jal func_800EF43C @@ -21,6 +22,7 @@ glabel EnablePartnerAI /* 0F3F14 802CF564 03E00008 */ jr $ra /* 0F3F18 802CF568 27BD0018 */ addiu $sp, $sp, 0x18 +glabel func_802CF56C /* 0F3F1C 802CF56C 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 0F3F20 802CF570 AFBF0010 */ sw $ra, 0x10($sp) /* 0F3F24 802CF574 8C82000C */ lw $v0, 0xc($a0) diff --git a/asm/nonmatchings/code_f2470_len_27f0/GetPartnerPos.s b/asm/nonmatchings/code_f2470_len_27f0/GetPartnerPos.s deleted file mode 100644 index 08befc6ef9..0000000000 --- a/asm/nonmatchings/code_f2470_len_27f0/GetPartnerPos.s +++ /dev/null @@ -1,51 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel GetPartnerPos -/* 0F3DE8 802CF438 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0F3DEC 802CF43C AFB10014 */ sw $s1, 0x14($sp) -/* 0F3DF0 802CF440 0080882D */ daddu $s1, $a0, $zero -/* 0F3DF4 802CF444 AFBF0024 */ sw $ra, 0x24($sp) -/* 0F3DF8 802CF448 AFB40020 */ sw $s4, 0x20($sp) -/* 0F3DFC 802CF44C AFB3001C */ sw $s3, 0x1c($sp) -/* 0F3E00 802CF450 AFB20018 */ sw $s2, 0x18($sp) -/* 0F3E04 802CF454 AFB00010 */ sw $s0, 0x10($sp) -/* 0F3E08 802CF458 8E22000C */ lw $v0, 0xc($s1) -/* 0F3E0C 802CF45C 8C520000 */ lw $s2, ($v0) -/* 0F3E10 802CF460 24420004 */ addiu $v0, $v0, 4 -/* 0F3E14 802CF464 8C530000 */ lw $s3, ($v0) -/* 0F3E18 802CF468 8C540004 */ lw $s4, 4($v0) -/* 0F3E1C 802CF46C 0C00EABB */ jal get_npc_unsafe -/* 0F3E20 802CF470 2404FFFC */ addiu $a0, $zero, -4 -/* 0F3E24 802CF474 0040802D */ daddu $s0, $v0, $zero -/* 0F3E28 802CF478 12000012 */ beqz $s0, .L802CF4C4 -/* 0F3E2C 802CF47C 0220202D */ daddu $a0, $s1, $zero -/* 0F3E30 802CF480 C6000038 */ lwc1 $f0, 0x38($s0) -/* 0F3E34 802CF484 4600008D */ trunc.w.s $f2, $f0 -/* 0F3E38 802CF488 44061000 */ mfc1 $a2, $f2 -/* 0F3E3C 802CF48C 0C0B2026 */ jal set_variable -/* 0F3E40 802CF490 0240282D */ daddu $a1, $s2, $zero -/* 0F3E44 802CF494 0220202D */ daddu $a0, $s1, $zero -/* 0F3E48 802CF498 C600003C */ lwc1 $f0, 0x3c($s0) -/* 0F3E4C 802CF49C 4600008D */ trunc.w.s $f2, $f0 -/* 0F3E50 802CF4A0 44061000 */ mfc1 $a2, $f2 -/* 0F3E54 802CF4A4 0C0B2026 */ jal set_variable -/* 0F3E58 802CF4A8 0260282D */ daddu $a1, $s3, $zero -/* 0F3E5C 802CF4AC 0220202D */ daddu $a0, $s1, $zero -/* 0F3E60 802CF4B0 C6000040 */ lwc1 $f0, 0x40($s0) -/* 0F3E64 802CF4B4 4600008D */ trunc.w.s $f2, $f0 -/* 0F3E68 802CF4B8 44061000 */ mfc1 $a2, $f2 -/* 0F3E6C 802CF4BC 0C0B2026 */ jal set_variable -/* 0F3E70 802CF4C0 0280282D */ daddu $a1, $s4, $zero -.L802CF4C4: -/* 0F3E74 802CF4C4 24020002 */ addiu $v0, $zero, 2 -/* 0F3E78 802CF4C8 8FBF0024 */ lw $ra, 0x24($sp) -/* 0F3E7C 802CF4CC 8FB40020 */ lw $s4, 0x20($sp) -/* 0F3E80 802CF4D0 8FB3001C */ lw $s3, 0x1c($sp) -/* 0F3E84 802CF4D4 8FB20018 */ lw $s2, 0x18($sp) -/* 0F3E88 802CF4D8 8FB10014 */ lw $s1, 0x14($sp) -/* 0F3E8C 802CF4DC 8FB00010 */ lw $s0, 0x10($sp) -/* 0F3E90 802CF4E0 03E00008 */ jr $ra -/* 0F3E94 802CF4E4 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index 470df683ca..5cba91bd98 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -191,19 +191,107 @@ INCLUDE_API_ASM(code_f2470_len_27f0, SetNpcFlagBits); INCLUDE_API_ASM(code_f2470_len_27f0, GetNpcPos); -INCLUDE_API_ASM(code_f2470_len_27f0, EnableNpcShadow); +ApiStatus EnableNpcShadow(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + s32 enableShadow = get_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); -INCLUDE_API_ASM(code_f2470_len_27f0, EnableNpcBlur); + if (npcPtr != NULL) { + if (enableShadow) { + enable_npc_shadow(npcPtr); + return ApiStatus_DONE2; + } + else { + disable_npc_shadow(npcPtr); + } + } + return ApiStatus_DONE2; +} + +ApiStatus EnableNpcBlur(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + s32 enableBlur = get_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + if (enableBlur) { + enable_npc_blur(npcPtr); + return ApiStatus_DONE2; + } + else { + disable_npc_blur(npcPtr); + } + } + return ApiStatus_DONE2; +} + +ApiStatus ClearPartnerMoveHistory(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + NpcId npcID = get_variable(script, *ptrReadPos++); + Npc* npcPtr = resolve_npc(script, npcID); + + if (npcPtr != NULL) { + clear_partner_move_history(npcPtr); + return ApiStatus_DONE2; + } + return ApiStatus_DONE2; +} -INCLUDE_API_ASM(code_f2470_len_27f0, ClearPartnerMoveHistory); INCLUDE_API_ASM(code_f2470_len_27f0, NpcSetHomePosToCurrent); -INCLUDE_API_ASM(code_f2470_len_27f0, GetPartnerPos); +ApiStatus GetPartnerPos(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + Bytecode posX = *ptrReadPos++; + Bytecode posY = *ptrReadPos++; + Bytecode posZ = *ptrReadPos++; + Npc* npcPtr = get_npc_unsafe(-4); -INCLUDE_API_ASM(code_f2470_len_27f0, DisablePartnerAI); + if (npcPtr != NULL) { + set_variable(script, posX, npcPtr->pos.x); + set_variable(script, posY, npcPtr->pos.y); + set_variable(script, posZ, npcPtr->pos.z); + return ApiStatus_DONE2; + } + return ApiStatus_DONE2; +} -INCLUDE_API_ASM(code_f2470_len_27f0, EnablePartnerAI); +ApiStatus DisablePartnerAI(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + + if (get_variable(script, *ptrReadPos++) == 0) { + func_800EF314(); + } else { + func_800EF300(); + } + return ApiStatus_DONE2; +} + +ApiStatus EnablePartnerAI(ScriptInstance* script, s32 isInitialCall) { + enable_partner_ai(); + return ApiStatus_DONE2; +} + +// TODO: Figure out what this function does +ApiStatus func_802CF54C(ScriptInstance* script, s32 isInitialCall) { + func_800EF43C(); + return ApiStatus_DONE2; +} + +// TODO: Figure out what this function does +ApiStatus func_802CF56C(ScriptInstance* script, s32 isInitialCall) { + Bytecode* ptrReadPos = script->ptrReadPos; + s32 value = get_variable(script, *ptrReadPos++); + + if(value == 2) { + func_800EF3E4(); + } else { + func_800EF3D4(value); + } + return ApiStatus_DONE2; +} INCLUDE_API_ASM(code_f2470_len_27f0, BringPartnerOut);