SHARE
TWEET

Bizhawk Cycle-Timestamp Inputs Lua Script

tikevin83 Apr 18th, 2018 (edited) 232 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local inputlabels = {"A", "B", "Select", "Start", "Right", "Left", "Up", "Down"}
  2. local powerOnCycles = 0;
  3.  
  4. function getinputbyte(t)
  5.   if not movie.isloaded() then
  6.     return 0
  7.   end
  8.  
  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 t = movie.getinput(emu.framecount());
  22.   local input = getinputbyte(t);
  23.   local cycles = emu.totalexecutedcycles();
  24.   if t["Power"] then
  25.     powerOnCycles = cycles;
  26.   end
  27.  
  28.   if input ~= lastinput then
  29.       cycles = (cycles - powerOnCycles + 485376) / 512;
  30.    
  31.     file:write(string.format("%08X %04X", cycles, input))
  32.     file:write("\n")
  33.     lastinput = input
  34.   end
  35. end
  36.  
  37. local timestamps = io.open("timestamps.txt", "w")
  38. local lastinput = -1
  39.  
  40. tryinput(timestamps)
  41.  
  42. while emu.framecount() <= movie.length() do
  43.  
  44.     tryinput(timestamps)
  45.  
  46.   emu.frameadvance()
  47. end
  48.  
  49. tryinput(timestamps)
  50. timestamps:close()
  51.  
  52. client.pause()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top