diff --git a/include/common_structs.h b/include/common_structs.h index e3d352c136..16222a7037 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -191,7 +191,7 @@ typedef struct script_context { /* 0x06C */ struct script_context* parentScript; /* brother? */ /* 0x070 */ s32 functionTemp[4]; /* 0x080 */ UNK_PTR callFunction; - /* 0x084 */ u32 varTable[16]; + /* 0x084 */ s32 varTable[16]; /* 0x0C4 */ s32 varFlags[3]; /* 0x0D0 */ s32 loopStartTable[8]; /* 0x0F0 */ s32 loopCounterTable[8]; diff --git a/include/functions.h b/include/functions.h index c533f9d6fd..9f5f91a185 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3,6 +3,7 @@ #include "ultra64.h" #include "common_structs.h" +#include "enums.h" void osCleanupThread(void); @@ -19,6 +20,7 @@ s32 func_800554E8(s32, s32); s32 func_800555E4(s32); void func_80137D88(s32, f32); void func_80137E10(s32, u8, u8, u8); +f32 update_lerp(EASING easing, f32 start, f32 end, s32 elapsed, s32 duration); s32 play_sound_at_position(s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ); s32 set_music_track(s32 musicPlayer, s32 songID, s32 variation, s32 unk, s32 volume); diff --git a/src/code_42e0_len_1f60.c b/src/code_42e0_len_1f60.c index d7c0efcc80..4144290940 100644 --- a/src/code_42e0_len_1f60.c +++ b/src/code_42e0_len_1f60.c @@ -78,7 +78,7 @@ f32 INCLUDE_ASM(code_42e0_len_1f60, sin_deg, f32 x); f32 INCLUDE_ASM(code_42e0_len_1f60, cos_deg, f32 x); -INCLUDE_ASM(code_42e0_len_1f60, update_lerp); +f32 INCLUDE_ASM(code_42e0_len_1f60, update_lerp, EASING easing, f32 start, f32 end, s32 elapsed, s32 duration); INCLUDE_ASM(code_42e0_len_1f60, func_8002A904); diff --git a/src/code_f8f60_len_1560.c b/src/code_f8f60_len_1560.c index 0935aafadf..ad6c681d63 100644 --- a/src/code_f8f60_len_1560.c +++ b/src/code_f8f60_len_1560.c @@ -7,12 +7,29 @@ s32 MakeLerp(script_context* script, s32 initialCall) { script->varTable[0xD] = get_variable(script, *ptrReadPos++); // end script->varTable[0xF] = get_variable(script, *ptrReadPos++); // duration script->varTable[0xB] = get_variable(script, *ptrReadPos++); // easing type - script->varTable[0xE] = 0; + script->varTable[0xE] = 0; // elapsed return 2; } -INCLUDE_ASM(code_f8f60_len_1560, UpdateLerp); +s32 UpdateLerp(script_context* script, s32 initialCall) { + script->varTable[0x0] = (s32) update_lerp( + script->varTable[0xB], + (s32) script->varTable[0xC], + (s32) script->varTable[0xD], + script->varTable[0xE], + script->varTable[0xF] + ); + + if (script->varTable[0xE] >= script->varTable[0xF]) { + script->varTable[0x1] = 0; // finished + } else { + script->varTable[0x1] = 1; // lerping + } + script->varTable[0xE]++; + + return 2; +} INCLUDE_ASM(code_f8f60_len_1560, RandInt);