Displays on screen the position and speed of Pac-Man.
--GBA Pac-Man World - hud speed script v1.0 by ThunderAxe31
local addr_x = 0x000B40
local addr_y = 0x000B44
local addr_z = 0x000B48
local old_x_pixel = 0
local old_x_subpixel = 0
local old_x_combined = 0
local old_y_pixel = 0
local old_y_subpixel = 0
local old_y_combined = 0
local old_z_pixel = 0
local old_z_subpixel = 0
local old_z_combined = 0
local framecount = -1
if memory.usememorydomain("EWRAM") then
while true do
local x_pixel = memory.read_s16_le(addr_x + 1)
local x_subpixel = memory.read_u8(addr_x)
local x_combined = memory.read_s32_le(addr_x)
local y_pixel = memory.read_s16_le(addr_y + 1)
local y_subpixel = memory.read_u8(addr_y)
local y_combined = memory.read_s32_le(addr_y)
local z_pixel = memory.read_s16_le(addr_z + 1)
local z_subpixel = memory.read_u8(addr_z)
local z_combined = memory.read_s32_le(addr_z)
local speed_x_pixel = x_pixel - old_x_pixel
local speed_x_subpixel = x_subpixel - old_x_subpixel
local speed_x_combined = x_combined - old_x_combined
local speed_y_pixel = y_pixel - old_y_pixel
local speed_y_subpixel = y_subpixel - old_y_subpixel
local speed_y_combined = y_combined - old_y_combined
local speed_z_pixel = z_pixel - old_z_pixel
local speed_z_subpixel = z_subpixel - old_z_subpixel
local speed_z_combined = z_combined - old_z_combined
if speed_x_pixel > 0 then speed_x_pixel = "+" .. speed_x_pixel end
if speed_x_subpixel > 0 then speed_x_subpixel = "+" .. speed_x_subpixel end
if speed_x_combined > 0 then speed_x_combined = "+" .. speed_x_combined end
if speed_y_pixel > 0 then speed_y_pixel = "+" .. speed_y_pixel end
if speed_y_subpixel > 0 then speed_y_subpixel = "+" .. speed_y_subpixel end
if speed_y_combined > 0 then speed_y_combined = "+" .. speed_y_combined end
if speed_z_pixel > 0 then speed_z_pixel = "+" .. speed_z_pixel end
if speed_z_subpixel > 0 then speed_z_subpixel = "+" .. speed_z_subpixel end
if speed_z_combined > 0 then speed_z_combined = "+" .. speed_z_combined end
if framecount ~= emu.framecount()-1 then
speed_x_pixel = ""
speed_x_subpixel = ""
speed_x_combined = ""
speed_y_pixel = ""
speed_y_subpixel = ""
speed_y_combined = ""
speed_z_pixel = ""
speed_z_subpixel = ""
speed_z_combined = ""
end
old_x_pixel = x_pixel
old_x_subpixel = x_subpixel
old_x_combined = x_combined
old_y_pixel = y_pixel
old_y_subpixel = y_subpixel
old_y_combined = y_combined
old_z_pixel = z_pixel
old_z_subpixel = z_subpixel
old_z_combined = z_combined
gui.pixelText(0, 132, " X Pos X Spe | Y Pos Y Spe | Z Pos Z Spe\n Pixel:" .. string.format("%7s", x_pixel) .. string.format("%6s", speed_x_pixel) .. " |" .. string.format("%7s", y_pixel) .. string.format("%6s", speed_y_pixel) .. " |" .. string.format("%7s", z_pixel) .. string.format("%6s", speed_z_pixel) .. "\nSubpixel:" .. string.format("%7s", x_subpixel) .. string.format("%6s", speed_x_subpixel) .. " |" .. string.format("%7s", y_subpixel) .. string.format("%6s", speed_y_subpixel) .. " |" .. string.format("%7s", z_subpixel) .. string.format("%6s", speed_z_subpixel) .. "\nCombined:" .. string.format("%7s", x_combined) .. string.format("%6s", speed_x_combined) .. " |" .. string.format("%7s", y_combined) .. string.format("%6s", speed_y_combined) .. " |" .. string.format("%7s", z_combined) .. string.format("%6s", speed_z_combined))
framecount = emu.framecount()
emu.frameadvance()
end
end