Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pbase = 0xC00
- local ppbase = 0xCC0
- local ebase = 0x19C0
- local epbase = 0xEC0
- function findbit(p)
- return 2 ^ (p - 1)
- end
- function hasbit(x, p)
- return x % (p + p) >= p
- end
- local function hex(val)
- val = string.format("%X",val)
- return val
- end
- local function camera()
- cx = memory.readword(0xD9)
- cy = memory.readword(0xDB)
- end
- local function drawbox(p,x,y,base,player,color)
- local box = {0,0,0,0} --xoff/yoff/xrad/yrad
- box[1] = memory.readbytesigned(p + 0x800000)
- box[2] = memory.readbytesigned(p + 0x800001)
- box[3] = memory.readbyte(p + 0x800002)
- box[4] = memory.readbyte(p + 0x800003)
- if player == false then
- if hasbit(memory.readbyte(base+0x14),findbit(7)) then -- megaman facing right
- box[1] = box[1] * - 1
- end
- else
- if hasbit(memory.readbyte(base+0x4A),findbit(3)) then -- enemy facing left
- box[1] = box[1] * - 1
- end
- end
- gui.box(x+box[1]+box[3],y+box[2]+box[4],x+box[1]-box[3],y+box[2]-box[4],color .. "40",color .. "FF")
- return box
- end
- local function proj_vuln(base,x,y,xoff,yoff,xrad,yrad)
- local offset = memory.readbyte(0x8087D0 +(memory.readbyte(base + 0x31) * 2))
- local property = memory.readbytesigned(0x8087D0 + offset)
- if property <= 0 then
- gui.line(x + xoff + xrad,y + yoff,x + xoff - xrad, y + yoff)
- gui.line(x + xoff,y + yoff + yrad, x + xoff,y + yoff - yrad)
- end
- --gui.text(x-40,y-20,hex(offset) .. " " .. hex(base))
- end
- local function player()
- local x = memory.readword(pbase + 5) - cx
- local y = memory.readword(pbase + 8) - cy
- local pointer = memory.readword(pbase + 0x24)
- local hp = memory.readbytesigned(pbase + 0x2F)
- drawbox(pointer,x,y,pbase,true,"#0000FF")
- gui.text(x-4,y,"HP:" .. hp)
- end
- local function player_projectiles()
- local x
- local y
- local base
- local pointer
- local active
- local anim
- for i = 0,7,1 do
- base = ppbase + (i * 0x40)
- active = memory.readbyte(base)
- anim = memory.readbyte(base + 1)
- if active ~= 0 and anim > 1 then
- x = memory.readword(base + 5) - cx
- y = memory.readword(base + 8) - cy
- pointer = memory.readword(base + 0x24)
- drawbox(pointer,x,y,base,false,"#FFFFFF")
- end
- end
- end
- local function enemy_projectiles()
- local x
- local y
- local base
- local pointer
- local active
- local anim
- for i = 0,7,1 do
- base = epbase + (i * 0x40)
- active = memory.readbyte(base)
- anim = memory.readbyte(base + 1)
- if active ~= 0 and anim > 1 then
- x = memory.readword(base + 5) - cx
- y = memory.readword(base + 8) - cy
- pointer = memory.readword(base + 0x24)
- drawbox(pointer,x,y,base,false,"#00FF00")
- end
- end
- end
- local function objects()
- local x
- local y
- local hp
- local base
- local pointer
- local active
- local anim
- local box
- for i = 0,15,1 do
- base = ebase + (i * 0x40)
- active = memory.readbyte(base)
- anim = memory.readbyte(base + 1)
- if active ~= 0 and anim > 1 then
- x = memory.readword(base + 5) - cx
- y = memory.readword(base + 8) - cy
- pointer = memory.readword(base + 0x24)
- hp = memory.readbytesigned(base + 0x2F)
- if hp > 0 then
- gui.text(x-8,y-8,"HP: " .. hp)
- end
- box = drawbox(pointer,x,y,base,false,"#FF0000")
- proj_vuln(base,x,y,box[1],box[2],box[3],box[4])
- end
- end
- end
- emu.registerafter(function()
- camera()
- enemy_projectiles()
- player_projectiles()
- objects()
- player()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement