Advertisement
CasualPokePlayer

lolx2

May 5th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 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. return bit.band(get_lcd_status(), (0x80))
  10. end
  11.  
  12. function getinputbyte()
  13. if not movie.isloaded() then
  14. return 0
  15. end
  16.  
  17. local t = movie.getinput(emu.framecount())
  18. local b = 0
  19.  
  20. for i = 0, 7 do
  21. if t[inputlabels[i + 1]] then
  22. b = b + bit.lshift(1, i)
  23. end
  24. end
  25.  
  26. return b
  27. end
  28.  
  29. function tryinput(file)
  30. local input = getinputbyte()
  31. file:write(string.char(input))
  32. lastinput = input
  33. end
  34.  
  35. local demo = io.open("bgb.dem", "wb")
  36. local lastinput = -1
  37.  
  38. tryinput(demo)
  39.  
  40. while emu.framecount() <= movie.length() do
  41.  
  42. if determine_lcd_status() ~= 0 then
  43. tryinput(demo)
  44. end
  45.  
  46. emu.frameadvance()
  47. end
  48.  
  49. tryinput(demo)
  50. demo:close()
  51.  
  52. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement