Draws a rectangle around where the key is hidden, showing the exact hitbox
local DOMAIN = "Main RAM"
local ADDR_X = 0x2944A4
local ADDR_Y = 0x2944CC
local HALF_W = 0x1C
local HALF_H = 0x16
local OUTLINE = 0xFFFF0000 -- ARGB red
local FILL = 0x00000000 -- transparent
-- 0 for top screen, 192 for bottom screen
local SCREEN_YOFF = 192
while true do
local cx = memory.read_u32_le(ADDR_X, DOMAIN)
local cy = memory.read_u32_le(ADDR_Y, DOMAIN)
local left = cx - HALF_W
local right = cx + HALF_W
local top = cy - HALF_H + SCREEN_YOFF
local bottom = cy + HALF_H + SCREEN_YOFF
gui.drawBox(left, top, right, bottom, OUTLINE, FILL)
gui.text(2, 2* SCREEN_YOFF-30, string.format(
"Key rect: L=%d T=%d R=%d B=%d (cx=%d cy=%d)",
left, top-SCREEN_YOFF, right, bottom-SCREEN_YOFF, cx, cy), 0xFFFFFFFF, 0x80000000)
emu.frameadvance()
end