fix: avoid AGF decode during movie preroll

This commit is contained in:
gamer147
2026-07-21 15:15:23 -04:00
parent fdcfbd9fa6
commit 9fd94ff540
5 changed files with 67 additions and 8 deletions

View File

@@ -100,6 +100,33 @@ public class MovieOpcodeTests
Assert.Equal(0x33, vm.Gfx.SnapshotVisibleObjects().Single().SurfaceResId);
}
[Fact]
public void PlayMovieKeepsCreatedSurfaceBlankDuringSynchronousHostSetup()
{
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
var script = ScriptAssembler.Assemble(table, "MOVIE-PREROLL", new List<(int, Operand[])>
{
(0x1f8, new[] { new Operand(0, 5), new Operand(0, 800), new Operand(0, 600), new Operand(0, 0) }),
(0x1fb, new[]
{
new Operand(0, 1), new Operand(0, 5), new Operand(0, 0), new Operand(0, 0),
new Operand(0, 800), new Operand(0, 600), new Operand(0, 0), new Operand(0, 0),
}),
(0x236, new[] { new Operand(0, 0x33), new Operand(0, 5), new Operand(0, 2), new Operand(0, 0) }),
(0x2, System.Array.Empty<Operand>()),
}, System.Array.Empty<string>());
var host = new RecordingHost();
VirtualMachine? vm = null;
long resourceDuringSetup = -1;
host.OnPlayMovie = () => resourceDuringSetup = vm!.Gfx.SnapshotVisibleObjects().Single().SurfaceResId;
vm = new VirtualMachine(script, table, host);
vm.Run();
Assert.Equal(0, resourceDuringSetup);
Assert.Equal(0x33, vm.Gfx.SnapshotVisibleObjects().Single().SurfaceResId);
}
[Fact]
public void QueryMovieStopTimeReturnsTheValueRetainedByPlayMovie()
{

View File

@@ -38,6 +38,7 @@ internal class RecordingHost : IHost
public readonly List<int> SfxReleases = new();
public readonly List<(int Target, long Duration)> BgmFades = new();
public readonly List<(long Resource, int Surface, long Flags, long SyncMask)> Movies = new();
public System.Action? OnPlayMovie;
public long? MovieStopTimeMs;
public readonly List<(long Resource, int Surface, long Flags)> ModalMovies = new();
public readonly List<int> ClearedRenderTargets = new();
@@ -151,6 +152,7 @@ internal class RecordingHost : IHost
public long? PlayMovieToSurface(long resourceId, int surfaceSlot, long movieFlags, long syncMask)
{
Movies.Add((resourceId, surfaceSlot, movieFlags, syncMask));
OnPlayMovie?.Invoke();
return MovieStopTimeMs;
}
public void PlayModalMovieToSurface(long rawResourceId, int surfaceSlot, long movieFlags)