Advertisement
Guest User

timestamps

a guest
Apr 7th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 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()
  21.   local input = getinputbyte()
  22.  
  23.   if input ~= lastinput then
  24.     io.write(string.format("%08X %02X", emu.totalexecutedcycles(), input))
  25.     lastinput = input
  26.   end
  27. end
  28.  
  29. local timestamps = io.open("timestamps.txt", "w")
  30. local lastinput = -1
  31.  
  32. io.output(timestamps)
  33. tryinput()
  34.  
  35. while emu.framecount() <= movie.length() do
  36.   if emu.getregister("PC") == 0x40 then
  37.     tryinput()
  38.   end
  39.  
  40.   emu.frameadvance()
  41. end
  42.  
  43. tryinput()
  44. io.close()
  45.  
  46. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement