Advertisement
Extrems

Untitled

May 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local inputlabels = {"P1 A", "P1 B", "P1 Select", "P1 Start", "P1 Right", "P1 Left", "P1 Up", "P1 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.  
  23.   if input ~= lastinput then
  24.     local cycles = emu.totalexecutedcycles();
  25.    
  26.     cycles = (cycles + 70224 * 14 - 456 * 90 - 1024) / 1024;
  27.    
  28.     file:write(string.format("%08X %04X", cycles, input))
  29.     file:write("\n")
  30.     lastinput = input
  31.   end
  32. end
  33.  
  34. local timestamps = io.open("timestamps.txt", "w")
  35. local lastinput = -1
  36.  
  37. tryinput(timestamps)
  38.  
  39. while emu.framecount() <= movie.length() do
  40.  
  41.   tryinput(timestamps)
  42.  
  43.   emu.frameadvance()
  44. end
  45.  
  46. tryinput(timestamps)
  47. timestamps:close()
  48.  
  49. client.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement