local f = 0 emu.addEventCallback(function() f = f + 1 if f == 1 then local ok, err = pcall(function() local h = io.open(os.getenv("TBG_LOAD"), "rb"); local d = h:read("a"); h:close() print("len", #d); emu.loadSavestate(d) end) print("load", ok, err) end if f == 10 then print("pc", emu.getState()["cpu.k"], emu.getState()["cpu.pc"]); emu.stop(0) end end, emu.eventType.endFrame)