--https://github.com/TASEmulators/BizHawk/issues/3447
--Originally from vadosnaprimer
--CoolHandMike for Karnov Arcade
--local function main()
if emu.registerafter ~= nil then
-- -- FCEUX
-- emu.registerafter(function()
-- emu.setlagflag(memory.readbyte(0xCC) ~= 0)
-- end)
else
-- BizHawk
--Was able to find an address 0x60000 that seems to correspond without taking any input.
event.onframeend(function()
local lag = memory.readbyte(0x60000) == 0
emu.setislagged(lag)
tastudio.setlag(emu.framecount(), lag)
lagcount = emu.lagcount()
if lag then
lagcount = lagcount+1
emu.setlagcount(lagcount)
end
end)
event.onloadstate(function()
lagcount = emu.lagcount()
end)
end
--end
while true do
--main();
emu.frameadvance();
end