Advertisement
CasualPokePlayer

luabad

May 5th, 2020
75
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. 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. function lcdbad()
  39. if determine_lcd_status() ~= 0 then
  40. tryinput(demo)
  41. end
  42. end
  43.  
  44. local vblank = 0x0040
  45.  
  46. while emu.framecount() <= movie.length() do
  47. event.onmemoryexecute(lcdbad, vblank)
  48. emu.frameadvance()
  49. end
  50.  
  51. demo:close()
  52.  
  53. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement