Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"}
- function get_lcd_status()
- memory.usememorydomain("System Bus")
- return memory.readbyte(0xFF40)
- end
- function determine_lcd_status()
- return bit.band(get_lcd_status(), 0x80)
- end
- 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 lcdbad()
- if determine_lcd_status() ~= 0 then
- tryinput(demo)
- end
- end
- local vblank = 0x0040
- while emu.framecount() <= movie.length() do
- event.onmemoryexecute(lcdbad, vblank)
- emu.frameadvance()
- end
- demo:close()
- client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement