local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"} function getinputbyte() if not movie.isloaded() then return 0 end local t = movie.getinput(emu.framecount()) local b = 0 for i = 0, 7 do if t[inputlabels[i + 1]] then b = b + bit.lshift(1, i) end end return b end function tryinput(file) local input = getinputbyte() file:write(string.char(input)) lastinput = input end local demo = io.open("bgb.dem", "wb") local lastinput = -1 function luabad() tryinput(demo) end local vblank = 0x0040 event.onmemoryexecute(luabad, vblank) while emu.framecount() <= movie.length() do emu.frameadvance() end demo:close() client.pause()