Advertisement
CasualPokePlayer

bk2_to_dem.lua

May 5th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"}
  2.  
  3. function getinputbyte()
  4. if not movie.isloaded() then
  5. return 0
  6. end
  7.  
  8. local t = movie.getinput(emu.framecount())
  9. local b = 0
  10.  
  11. for i = 0, 7 do
  12. if t[inputlabels[i + 1]] then
  13. b = b + bit.lshift(1, i)
  14. end
  15. end
  16.  
  17. return b
  18. end
  19.  
  20. function tryinput(file)
  21. local input = getinputbyte()
  22. file:write(string.char(input))
  23. lastinput = input
  24. end
  25.  
  26. local demo = io.open("bgb.dem", "wb")
  27. local lastinput = -1
  28.  
  29. function luabad()
  30. tryinput(demo)
  31. end
  32.  
  33. local vblank = 0x0040
  34. event.onmemoryexecute(luabad, vblank)
  35.  
  36. while emu.framecount() <= movie.length() do
  37. emu.frameadvance()
  38. end
  39.  
  40. demo:close()
  41.  
  42. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement