Advertisement
Kaztalek

Frame Count Average Thing

May 28th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. --"avgtime.lua"
  2. --For use in MM (J1.1) on BizHawk 1.9.1
  3. --Measures frames starting from load state and ending on loading zone
  4. --
  5. --Addresses:
  6. --0x09CE75 determines if loading zone has been entered
  7.  
  8. local zone
  9. local switch = 1
  10. local startframe
  11. local runs = 0
  12. local frames = 0
  13. local total = 0
  14. local avg = 0
  15. local best = 99999999999
  16. local height = client.screenheight()
  17. function startCount()
  18.     if switch == 1 then
  19.         startframe = emu.framecount()
  20.         switch = 0
  21.     end
  22. end
  23.  
  24. while true do
  25.     zone = memory.readbyte(0x09CE75)
  26.     if switch == 0 and zone ~= 63 then
  27.         frames = emu.framecount() - startframe
  28.         if frames < best then
  29.             best = frames
  30.         end
  31.         total = total + frames
  32.         runs = runs + 1
  33.         avg = math.floor(total/runs)
  34.         switch = 1
  35.     end
  36.     event.onloadstate(startCount)
  37.     gui.text(0,height-14*5,"Frames: "..frames)
  38.     gui.text(0,height-14*4,"Runs: "..runs)
  39.     gui.text(0,height-14*3,"Average: "..avg)
  40.     if best < 99999999999 then
  41.         gui.text(0,height-14*2,"Best: "..best)
  42.     end
  43.     emu.frameadvance()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement