User File #49178644084685899

Upload All User Files

#49178644084685899 - SNES Prince of Persia - lag detector v1.1

SNES Prince of Persia - lag detector v1.1.lua
763 downloads
Uploaded 8/15/2018 6:09 PM by ThunderAxe31 (see all 111)
Script that displays X position, internal frame count and hidden lag count.
--SNES Prince of Persia - lag detector v1.1 by ThunderAxe31

local lag_check_addr   = 0x000000
local frame_count_addr = 0x000002
local player_x_addr    = 0x000468

local framecount_old = -1
local framecount = 0

local lag_count = 0

while true do
	framecount = emu.framecount()
	
	if framecount_old ~= (framecount-1) then --if a state has been loaded, reset values
		lag_count = 0
	end
	
	if memory.read_u8(lag_check_addr) > 3 then --checks if the check value is unchanged
		lag_count = lag_count + 1 --updates the lag count
	end
	
	framecount_old = framecount --updates the frame count
	
	local internal_framecount = memory.read_u16_le(frame_count_addr)
	
	gui.pixelText(0, 216, "Player X: " .. string.format("%3s", memory.read_u8(player_x_addr)) .. "   Frame counter: " .. string.format("%5s", internal_framecount) .. "   Hidden lag: " .. lag_count)
	
	emu.frameadvance()
end