From 0495628b99be104b5f3831138ef28daf90b4fe96 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Tue, 7 Jul 2026 23:38:15 -0400 Subject: [PATCH] feat(gfx): dispatch anim-start 0x234 + set-anim-clock 0x238 (revised global-clock model) Co-Authored-By: Claude Opus 4.8 --- engine/Age.Engine.Tests/GfxAnimationTests.cs | 23 ++++++++++++++++++++ engine/Age.Engine/Vm/VirtualMachine.cs | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/engine/Age.Engine.Tests/GfxAnimationTests.cs b/engine/Age.Engine.Tests/GfxAnimationTests.cs index ef3f353..a2b558a 100644 --- a/engine/Age.Engine.Tests/GfxAnimationTests.cs +++ b/engine/Age.Engine.Tests/GfxAnimationTests.cs @@ -69,4 +69,27 @@ public class GfxAnimationTests Assert.False(o.AnimNormalized); Assert.True(o.AnimEnabled); } + + [Fact] + public void AnimStartAndClock_DispatchSetTargetDurationClockAndGeneration() + { + var t = T(); + // anim-start(handle=0x1000, duration=30, target=(0,0,5)); set-anim-clock(400) + var scene = ScriptAssembler.Assemble(t, "ANIM", new List<(int, Operand[])> + { + MovGI(1, 0x1000), MovGI(2, 30), MovGI(3, 0), MovGI(4, 0), MovGI(5, 5), MovGI(6, 400), + (0x234, new[] { G(1), G(2), G(3), G(4), G(5) }), + (0x238, new[] { G(6) }), + Exit(), + }, System.Array.Empty()); + var vm = new VirtualMachine(scene, t, new RecordingHost()); + vm.Run(); + var o = vm.Gfx.TryGet(0x1000)!; + Assert.Equal((0L, 0L, 5L), o.AnimTarget); + Assert.Equal(30, o.AnimDurationTicks); + Assert.Equal(1, o.AnimGeneration); + Assert.True(o.AnimEnabled); + Assert.Equal(400, vm.Gfx.AnimClockDurationTicks); + Assert.Equal(1, vm.Gfx.AnimClockGeneration); + } } diff --git a/engine/Age.Engine/Vm/VirtualMachine.cs b/engine/Age.Engine/Vm/VirtualMachine.cs index edfd195..5d761c4 100644 --- a/engine/Age.Engine/Vm/VirtualMachine.cs +++ b/engine/Age.Engine/Vm/VirtualMachine.cs @@ -277,6 +277,10 @@ public sealed class VirtualMachine case "set-anim-transform-norm": // 0x21e — same, operands are ~percent (/_DAT_00571c28) Gfx.SetAnimTransform(Read(a[0]), Read(a[1]), Read(a[2]), (Read(a[3]), Read(a[4]), Read(a[5])), normalized: true); return pc + 1; + case "anim-start": // 0x234 (handle)(duration)(x)(y)(z) — animate toward target over the global clock + Gfx.StartAnim(Read(a[0]), Read(a[1]), (Read(a[2]), Read(a[3]), Read(a[4]))); return pc + 1; + case "set-anim-clock": // 0x238 (duration) — global, non-blocking (host advances it per-frame) + Gfx.SetAnimClock(Read(a[0])); return pc + 1; default: // Stub is per-instruction frequency (the VM handles ~30 ops; the rest hit here, e.g. // 0x258/0x259 stmt markers appear en masse), so gate it with Step — else --trace floods.