mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-31 12:05:05 +02:00
26 lines
826 B
Lua
26 lines
826 B
Lua
-- frame_clock.lua -- read-only frame counter side channel for host-driven tests.
|
|
--
|
|
-- Writes the current frame number to $FRAME_CLOCK once per frame so a host
|
|
-- client can align an injection with a known emulated frame (and therefore with
|
|
-- the driver's VT1200_DUMP_FRAMES schedule). No breakpoints, no memory writes
|
|
-- except this file. Optionally exits at $FRAME_STOP.
|
|
local machine = manager.machine
|
|
local path = os.getenv("FRAME_CLOCK")
|
|
local stop = tonumber(os.getenv("FRAME_STOP") or "0")
|
|
local f = 0
|
|
|
|
emu.register_frame_done(function()
|
|
f = f + 1
|
|
if path then
|
|
local fh = io.open(path, "w")
|
|
if fh then
|
|
fh:write(string.format("%d\n", f))
|
|
fh:close()
|
|
end
|
|
end
|
|
if stop > 0 and f >= stop then
|
|
print(string.format("frame_clock: stopping at frame %d", f))
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-frame-clock")
|