User File #638055646214449086

Upload All User Files

#638055646214449086 - [SNES] Prince of Persia (Japan) - LUA Script for precise IGT timing

MovieClockSNESPop.lua
48 downloads
Uploaded 12/2/2022 7:57 AM by eien86 (see all 87)
Title says it all.
Lines 8-9 emulates readword by calling readbyte twice. No, I'm not an idiot, it's just readword didn't work for some reason.
local IGTFramesAddress = 0x052D
local fps = 12

while true do

	emu.frameadvance();
	
	framesLow = memory.readbyte(IGTFramesAddress)
	framesHigh = memory.readbyte(IGTFramesAddress+1)
	frames = framesHigh*256 + framesLow
	tseconds = (frames / fps);
	
	secondsraw = tseconds % 60;
	shift = 10 ^ 2;
	seconds = math.floor((secondsraw * shift) + 0.5) / shift;
	secondsstr = string.format("%.2f", seconds);
	if (seconds < 10) then
		secondsstr = "0" .. secondsstr;
	end

	minutes = (math.floor(tseconds / 60)) % 60;
	minutesstr = minutes;
	if (minutes < 10) then
		minutesstr = "0" .. minutesstr;
	end

	hours = (math.floor(tseconds / 60 / 60)) % 24;
	
	time = minutesstr .. ":" .. secondsstr;
	if (hours > 0) then
		time = "0" .. hours .. ":" .. time;
	end
	gui.text(0, 0, time, nil, 1);

end