Skip to content

Commit

Permalink
Merge pull request #354 from KSSBrawl/anmmanager-executescript
Browse files Browse the repository at this point in the history
Match AnmManager::ExecuteScript
  • Loading branch information
roblabla authored Dec 22, 2024
2 parents dc1df44 + 3eabce5 commit 34d2b61
Showing 1 changed file with 10 additions and 31 deletions.
41 changes: 10 additions & 31 deletions src/AnmManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ ZunResult AnmManager::LoadAnm(i32 anmIdx, char *path, i32 spriteIdxOffset)
}

#pragma var_order(curInstr, local_c, local_10, local_14, local_18, local_1c, local_20, nextInstr, local_28, local_2c, \
local_30, local_34, local_38, local_3c, local_68, local_6a, local_70, curTime, scaleInterpCurTime, \
local_c4, local_cc, randValue)
local_30, local_34, local_38, local_3c)
i32 AnmManager::ExecuteScript(AnmVm *vm)
{
AnmRawInstr *curInstr;
Expand All @@ -684,14 +683,6 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
i32 local_34;
i32 local_38;
f32 local_3c;
u32 local_68;
u16 local_6a;
u32 local_70;
i32 curTime;
i32 scaleInterpCurTime;
i32 local_c4;
i32 local_cc;
u32 randValue;

if (vm->currentInstruction == NULL)
{
Expand All @@ -703,7 +694,7 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
goto yolo;
}

while ((curInstr = vm->currentInstruction, curTime = vm->currentTimeInScript.current, curInstr->time <= curTime))
while (curInstr = vm->currentInstruction, curInstr->time <= vm->currentTimeInScript.AsFrames())
{
switch (curInstr->opcode)
{
Expand All @@ -715,24 +706,14 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
case AnmOpcode_SetActiveSprite:
vm->flags.isVisible = 1;
this->SetActiveSprite(vm, curInstr->args[0] + this->spriteIndices[vm->anmFileIndex]);
local_68 = vm->currentTimeInScript.current;
vm->timeOfLastSpriteSet = local_68;
vm->timeOfLastSpriteSet = vm->currentTimeInScript.AsFrames();
break;
case AnmOpcode_SetRandomSprite:
vm->flags.isVisible = 1;
local_c = &curInstr->args[0];
local_6a = local_c[1];
if (local_6a != 0)
{
randValue = g_Rng.GetRandomU16() % local_6a;
}
else
{
randValue = 0;
}
this->SetActiveSprite(vm, local_c[0] + (u16)randValue + this->spriteIndices[vm->anmFileIndex]);
local_70 = vm->currentTimeInScript.current;
vm->timeOfLastSpriteSet = local_70;
this->SetActiveSprite(vm, local_c[0] + g_Rng.GetRandomU16InRange(local_c[1]) +
this->spriteIndices[vm->anmFileIndex]);
vm->timeOfLastSpriteSet = vm->currentTimeInScript.AsFrames();
break;
case AnmOpcode_SetScale:
vm->scaleX = *(f32 *)&curInstr->args[0];
Expand Down Expand Up @@ -933,8 +914,7 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
if (vm->scaleInterpEndTime > 0)
{
vm->scaleInterpTime.Tick();
scaleInterpCurTime = vm->scaleInterpTime.current;
if (scaleInterpCurTime >= vm->scaleInterpEndTime)
if (vm->scaleInterpTime.AsFrames() >= vm->scaleInterpEndTime)
{
vm->scaleY = vm->scaleInterpFinalY;
vm->scaleX = vm->scaleInterpFinalX;
Expand Down Expand Up @@ -987,8 +967,7 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
COLOR_SET_COMPONENT(local_2c, local_38, local_34 >= 256 ? 255 : local_34);
}
vm->color = local_2c;
local_c4 = vm->alphaInterpTime.current;
if (local_c4 >= vm->alphaInterpEndTime)
if (vm->alphaInterpTime.AsFrames() >= vm->alphaInterpEndTime)
{
vm->alphaInterpEndTime = 0;
}
Expand Down Expand Up @@ -1025,8 +1004,8 @@ i32 AnmManager::ExecuteScript(AnmVm *vm)
vm->posOffset.y = local_3c * vm->posInterpFinal.y + (1.0f - local_3c) * vm->posInterpInitial.y;
vm->posOffset.z = local_3c * vm->posInterpFinal.z + (1.0f - local_3c) * vm->posInterpInitial.z;
}
local_cc = vm->posInterpTime.current;
if (local_cc >= vm->posInterpEndTime)

if (vm->posInterpTime.AsFrames() >= vm->posInterpEndTime)
{
vm->posInterpEndTime = 0;
}
Expand Down

0 comments on commit 34d2b61

Please sign in to comment.