memory.usememorydomain("IWRAM");
while true do
XPos = memory.read_s16_le(0x1BC4);
YPos = memory.read_s16_le(0x1BC8);
XSpd = memory.read_s16_le(0x1BCC);
YSpd = memory.read_s16_le(0x1BD0);
XYSpd = math.sqrt(XSpd^2+YSpd^2);
gui.drawRectangle(2, 32, 70, 29, 0x00000000, 0x77000000);
gui.text(12, 100, "X Position: "..XPos);
gui.text(12, 115, "Y Position: "..YPos);
gui.text(12, 135, "X Speed: "..XSpd);
gui.text(12, 150, "Y Speed: "..YSpd);
gui.text(12, 165, "XY Speed: "..XYSpd);
gui.drawRectangle(90, 16, 141, 141, 0x00000000, 0x77000000);
gui.drawLine(89, 86, 232, 86);
gui.drawPixel(90, 85);
gui.drawPixel(90, 87);
gui.drawPixel(231, 85);
gui.drawPixel(231, 87);
gui.text(700, 250, "X");
gui.drawLine(160, 15, 160, 158);
gui.drawPixel(159, 16);
gui.drawPixel(161, 16);
gui.drawPixel(159, 157);
gui.drawPixel(161, 157);
gui.text(475, 25, "Y");
gui.drawLine(160, 86, 160+XSpd/110, 86+YSpd/110, 0xFFFF0000);
emu.frameadvance();
end