--Cabbage Patch Kids script v1.0 by ThunderAxe31
local addr_masterpointer = 0x000410
local addr_offset_x = 0x20
local addr_offset_y = 0x24
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 framecount = -1
if memory.usememorydomain("EWRAM") then
while true do
local masterpointer = memory.read_u32_le(addr_masterpointer) - 0x02000000
local x_pixel = memory.read_s16_le(masterpointer + addr_offset_x + 1)
local x_subpixel = memory.read_u8(masterpointer + addr_offset_x)
local x_combined = memory.read_s32_le(masterpointer + addr_offset_x)
local y_pixel = memory.read_s16_le(masterpointer + addr_offset_y + 1)
local y_subpixel = memory.read_u8(masterpointer + addr_offset_y)
local y_combined = memory.read_s32_le(masterpointer + addr_offset_y)
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
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 framecount ~= emu.framecount()-1 then
speed_x_pixel = ""
speed_x_subpixel = ""
speed_x_combined = ""
speed_y_pixel = ""
speed_y_subpixel = ""
speed_y_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
gui.pixelText(0, 132, "X position | speed\npixel: " .. string.format("%7s", x_pixel) .. string.format("%8s", speed_x_pixel) .. "\nsubpixel:" .. string.format("%7s", x_subpixel) .. string.format("%8s", speed_x_subpixel) .. "\ncombined:" .. string.format("%7s", x_combined) .. string.format("%8s", speed_x_combined) )
gui.pixelText(143, 132, "Y position | speed\npixel: " .. string.format("%7s", y_pixel) .. string.format("%8s", speed_y_pixel) .. "\nsubpixel:" .. string.format("%7s", y_subpixel) .. string.format("%8s", speed_y_subpixel) .. "\ncombined:" .. string.format("%7s", y_combined) .. string.format("%8s", speed_y_combined) )
framecount = emu.framecount()
emu.frameadvance()
end
end