This script shows an OSD of the current internal values of the trackball for Millipede running under MAME, made to help with a BizHawk github issue I'm about to open regarding problems with trackball support in MAMEHawk.
local function getscreen()
for k,v in pairs(manager.machine.screens) do return v end
end
local screen = getscreen()
local function framecount()
x = manager.machine.ioport.ports[":TRACK0_X"]:read()
y = manager.machine.ioport.ports[":TRACK0_Y"]:read()
str = string.format("x: %d\ny: %d", x, y)
--print(str)
screen:draw_text(0, 0, str, 0xffffffff, 0xff000000)
end
emu.register_frame_done(framecount)