Advertisement
CasualPokePlayer

lol

May 5th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"}
  2.  
  3. function get_lcd_status()
  4. memory.usememorydomain("System Bus")
  5. return memory.readbyte(0xFF40)
  6. end
  7.  
  8. function determine_lcd_status()
  9. val = (get_lcd_status)
  10. amt = 0x80
  11. return bit.band(val, amt)
  12. end
  13.  
  14. function getinputbyte()
  15. if not movie.isloaded() then
  16. return 0
  17. end
  18.  
  19. local t = movie.getinput(emu.framecount())
  20. local b = 0
  21.  
  22. for i = 0, 7 do
  23. if t[inputlabels[i + 1]] then
  24. b = b + bit.lshift(1, i)
  25. end
  26. end
  27.  
  28. return b
  29. end
  30.  
  31. function tryinput(file)
  32. local input = getinputbyte()
  33. file:write(string.format(input))
  34. file:write("\n")
  35. lastinput = input
  36. end
  37.  
  38. local demo = io.open("bgb.dem", "w")
  39. local lastinput = -1
  40.  
  41. tryinput(demo)
  42.  
  43. while emu.framecount() <= movie.length() do
  44.  
  45. if (determine_lcd_status) ~= 0 then
  46. tryinput(demo)
  47. end
  48.  
  49. emu.frameadvance()
  50. end
  51.  
  52. tryinput(demo)
  53. demo:close()
  54.  
  55. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement