Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- showSplits = 1
- framerules = 1
- framerate = 39375000/655171
- start = 197 + 21*framerules
- stop = 0
- split = 1
- frames = 0
- diff = 0
- facing2 = 0
- world12 = 0
- world22 = 0
- next = 0
- comp = {}
- comp[1] = 2293
- comp[2] = 3825
- comp[3] = 6433
- comp[4] = 7840
- comp[5] = 10907
- comp[6] = 13071
- comp[7] = 15193
- comp[8] = 17891
- while true do
- -- detect start
- joy = joypad.get();
- for button, value in pairs(joypad.get()) do
- if button == 'Reset' and value == true then
- start = emu.framecount() + 197 + 21*framerules
- end
- end
- -- detect end
- if stop == 1 then stop = 2 end
- for i = 0, 5 do
- if
- memory.readbyte((0x0016) + i) == 0x2d
- and memory.readbyte(0x075F) == 7
- and memory.readbyte(0x01ED) == 242
- and memory.readbyte(0x03AD) > 210
- and stop == 0
- then
- stop = 1
- end
- end
- -- get time
- if stop < 2 then
- frames = emu.framecount() - start
- end
- time = (frames / framerate)
- minutes = math.floor(time / 60)
- seconds = time % 60
- if frames < 0 then
- minutes = 0
- seconds = 0
- end
- -- draw timer
- minutesString = string.format("%.0f", minutes)
- secondsString = string.format("%.3f", seconds)
- if seconds < 10 then secondsString = "0" .. secondsString end
- gui.drawBox(205, 228, 245, 234, "black", "black")
- gui.text(410, 455, minutesString .. ":" .. secondsString)
- -- detect split
- facing1 = memory.readbyte(0x0033)
- world11 = memory.readbyte(0x075F)
- world21 = memory.readbyte(0x0760)
- if
- (world11 > world12 or world21 > world22)
- and (world11 > 0 or world21 > 1)
- and (world11 ~= 3 or world21 ~= 1)
- and frames > 100
- then
- next = 1
- end
- if
- (split == 8 and stop == 2)
- or
- (facing1 == 1 and facing2 == 0 and next == 1)
- then
- diff = (frames - comp[split]) / framerate
- split = split + 1
- next = 0
- end
- facing2 = memory.readbyte(0x0033)
- world12 = memory.readbyte(0x075F)
- world22 = memory.readbyte(0x0760)
- -- draw split
- diffString = string.format("%.3f", diff)
- if diff == 0 then diffString = "-" .. diffString end
- if diff > 0 then diffString = "+" .. diffString end
- if split > 1 and showSplits == 1 then
- gui.drawBox(164, 228, 195, 234, "black", "black")
- gui.text(330, 455, diffString)
- end
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement