Guest User

Untitled

a guest
Nov 29th, 2015
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. showSplits = 1
  2. framerules = 1
  3.  
  4. framerate = 39375000/655171
  5. start = 197 + 21*framerules
  6. stop = 0
  7. split = 1
  8. frames = 0
  9. diff = 0
  10. facing2 = 0
  11. world12 = 0
  12. world22 = 0
  13. next = 0
  14.  
  15. comp = {}
  16. comp[1] = 2293
  17. comp[2] = 3825
  18. comp[3] = 6433
  19. comp[4] = 7840
  20. comp[5] = 10907
  21. comp[6] = 13071
  22. comp[7] = 15193
  23. comp[8] = 17891
  24.  
  25.  
  26. while true do
  27.  
  28. -- detect start
  29.  
  30. joy = joypad.get();
  31. for button, value in pairs(joypad.get()) do
  32. if button == 'Reset' and value == true then
  33. start = emu.framecount() + 197 + 21*framerules
  34. end
  35. end
  36.  
  37. -- detect end
  38.  
  39. if stop == 1 then stop = 2 end
  40.  
  41. for i = 0, 5 do
  42. if
  43. memory.readbyte((0x0016) + i) == 0x2d
  44. and memory.readbyte(0x075F) == 7
  45. and memory.readbyte(0x01ED) == 242
  46. and memory.readbyte(0x03AD) > 210
  47. and stop == 0
  48. then
  49. stop = 1
  50. end
  51. end
  52.  
  53.  
  54. -- get time
  55.  
  56. if stop < 2 then
  57. frames = emu.framecount() - start
  58. end
  59.  
  60. time = (frames / framerate)
  61. minutes = math.floor(time / 60)
  62. seconds = time % 60
  63.  
  64. if frames < 0 then
  65. minutes = 0
  66. seconds = 0
  67. end
  68.  
  69. -- draw timer
  70.  
  71. minutesString = string.format("%.0f", minutes)
  72.  
  73. secondsString = string.format("%.3f", seconds)
  74. if seconds < 10 then secondsString = "0" .. secondsString end
  75.  
  76. gui.drawBox(205, 228, 245, 234, "black", "black")
  77. gui.text(410, 455, minutesString .. ":" .. secondsString)
  78.  
  79.  
  80. -- detect split
  81.  
  82. facing1 = memory.readbyte(0x0033)
  83. world11 = memory.readbyte(0x075F)
  84. world21 = memory.readbyte(0x0760)
  85.  
  86. if
  87. (world11 > world12 or world21 > world22)
  88. and (world11 > 0 or world21 > 1)
  89. and (world11 ~= 3 or world21 ~= 1)
  90. and frames > 100
  91. then
  92. next = 1
  93. end
  94.  
  95. if
  96. (split == 8 and stop == 2)
  97. or
  98. (facing1 == 1 and facing2 == 0 and next == 1)
  99. then
  100. diff = (frames - comp[split]) / framerate
  101. split = split + 1
  102. next = 0
  103. end
  104.  
  105. facing2 = memory.readbyte(0x0033)
  106. world12 = memory.readbyte(0x075F)
  107. world22 = memory.readbyte(0x0760)
  108.  
  109.  
  110. -- draw split
  111.  
  112. diffString = string.format("%.3f", diff)
  113. if diff == 0 then diffString = "-" .. diffString end
  114. if diff > 0 then diffString = "+" .. diffString end
  115.  
  116. if split > 1 and showSplits == 1 then
  117. gui.drawBox(164, 228, 195, 234, "black", "black")
  118. gui.text(330, 455, diffString)
  119. end
  120.  
  121.  
  122. emu.frameadvance()
  123.  
  124. end
Advertisement
Add Comment
Please, Sign In to add comment