Files
OpenMaidEngine/engine/Age.Engine.Tests/WaitForInputTests.cs
gamer147 ea0f1ddc7a feat(a2b): implement 0x208 get-texture-size (geometry keystone)
Promote 0x208 from stub to a real VM op that writes the loaded texture's
width/height into its two output globals, via new IHost.GetTextureSize. This is
the single native primitive the CG-load subroutine (SC0000 label_12649) needs;
all downstream centering/anchor geometry is already computed in bytecode.

Non-Godot hosts return (0,0) so trace/selftest parity holds (engine 9/9 incl.
TraceDiffTests). Godot host gets a temporary (0,0) stub; real impl in the
compositor task.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 22:48:10 -04:00

38 lines
1.4 KiB
C#

using System.Collections.Generic;
using Age.Engine.Hosting;
using Age.Engine.Sys4;
using Age.Engine.Vm;
using Xunit;
public class WaitForInputTests
{
private sealed class CountHost : IHost
{
public int Waits;
public List<int> Emitted = new();
public void ShowText(int offset, string text) => Emitted.Add(offset);
public void CallScript(long id) { }
public void OnStub(int opcode) { }
public void WaitForInput() => Waits++;
public void CreateTexture(int slot, int w, int h) { }
public void SetTexture(long resId, int slot) { }
public void DrawTexture(int slot, int srcX, int srcY, int w, int h, int dstX, int dstY) { }
public (int Width, int Height) GetTextureSize(int slot) => (0, 0);
public void PlayBgm(long id) { }
public void PlayVoice(long id) { }
}
[Fact]
public void WaitForInputFiresAndEmittedIsStable()
{
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
var script = Sys4Loader.Load(Paths.Scripts()["SC0000.BIN"], table);
var host = new CountHost();
var vm = new VirtualMachine(script, table, host);
vm.Run();
Assert.True(host.Waits > 0, "wait-for-input (0x72) should fire at least once");
Assert.Equal(186, host.Emitted.Count); // unchanged vs the A1 SC0000 trace
Assert.Equal("exit", vm.HaltReason);
}
}