local drawn = false
memory.usememorydomain("System Bus")
function axis(x,y,color,xsize,ysize)
if xsize == nil then
xsize = 2
end
if ysize == nil then
ysize = 2
end
gui.drawLine(x+xsize,y,x-xsize,y,color)
gui.drawLine(x,y+ysize,x,y-ysize,color)
gui.drawLine(x,y,x,y,0xFF000000)
end
local function pattack()
if memory.read_u8(0xCA55) == 0xB9 and memory.read_u8(0xCA56) == 0xF0 and memory.read_u8(0xCA57) == 0x04 then
local xreg = emu.getregister("X")
local yreg = emu.getregister("Y")
local x = memory.read_u8(0x550 + yreg)
local y = memory.read_u8(0x580 + yreg) - 0x03
local xrad = 0x20
if bit.band(memory.read_u8(0x4F0 + yreg),0x40) == 0x40 then
xrad = -0x20
end
gui.drawLine(x,y,x+xrad,y,0xFFFFFFFF)
x = memory.read_u8(0x550 + xreg)
y = memory.read_u8(0x580 + xreg)
xrad = memory.read_u8(0x610 + xreg)
local yrad = memory.read_u8(0x628 + xreg)
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFF00FF00,0x4000FF00)
end
end
local function collision()
if memory.read_u8(0xCC33) == 0xB9 and memory.read_u8(0xCC34) == 0x50 and memory.read_u8(0xCC35) == 0x05 then
local xreg = emu.getregister("X")
local yreg = emu.getregister("Y")
local x = memory.read_u8(0x550 + yreg)
local y = memory.read_u8(0x580 + yreg)
local xrad = memory.read_u8(0x610 + yreg)
local yrad = memory.read_u8(0x628 + yreg)
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFF0000,0x40FF0000)
if drawn == false then
local x = memory.read_u8(0x550)
local y = memory.read_u8(0x580)
local hp = memory.read_u8(0x80)
local xrad = 0x06
local yrad = 0x10
if bit.band(memory.read_u8(0x520),0x02) == 0x02 then
yrad = 0x0C
end
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFF0000FF,0x400000FF)
drawn = true
end
end
end
local function subweapon()
if memory.read_u8(0xCB2F) == 0xBD and memory.read_u8(0xCB30) == 0x50 and memory.read_u8(0xCB31) == 0x05 then
local xreg = emu.getregister("X")
local yreg = emu.getregister("Y")
local x = memory.read_u8(0x550 + yreg)
local y = memory.read_u8(0x580 + yreg)
local xrad = memory.read_u8(0xC0)
local yrad = memory.read_u8(0xC0)
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFFFFF,0x40FFFFFF)
x = memory.read_u8(0x550 + xreg)
y = memory.read_u8(0x580 + xreg)
xrad = memory.read_u8(0x610 + xreg)
yrad = memory.read_u8(0x628 + xreg)
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFF00FF00,0x4000FF00)
end
end
event.onmemoryexecute(collision,0xCC33)
event.onmemoryexecute(pattack,0xCA55)
event.onmemoryexecute(subweapon,0xCB2F)
while true do
emu.frameadvance()
drawn = false
end