Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local camx
- local camy
- 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)
- if string.len(val) == 1 then
- val = "0" .. val
- end
- return val
- end
- local function camera()
- camx = memory.readword(0x47)
- camy = memory.readword(0x4F)
- end
- local function drawbox(x1,x2,y1,y2,outl,fill)
- gui.box(x1,y1,x2,y2,outl,fill)
- end
- local function player()
- local x = memory.readword(0x185C) - camx
- local y = memory.readword(0x1860) - camy
- memory.registerexec(0x80B3F7, function()
- if memory.getregister("Y") == 0x1858 then -- is player
- local x1 = memory.readword(0x7B) -camx
- local x2 = memory.readword(0x7D) -camx
- local y1 = memory.readword(0x7F) -camy
- local y2 = memory.readword(0x81) -camy
- drawbox(x1,x2,y1,y2,"#0000FF40","#0000FFFF")
- end
- end)
- end
- local function enemies()
- memory.registerexec(0x80AD32, function()
- if hasbit(memory.readword(0x1E + memory.getregister("Y")),findbit(15)) then
- local flip = true
- else
- local flip = false
- end
- local x = memory.readword((memory.getregister("DB") * 0x10000) + 4 + memory.getregister("Y")) -camx
- local y = memory.readword((memory.getregister("DB") * 0x10000) + 8 + memory.getregister("Y")) -camy
- local x1 = memory.readword(0x77) -camx
- local x2 = memory.readword(0x79) -camx
- local y1 = memory.readwordsigned(0x838002 + memory.getregister("X")) + y
- local y2 = memory.readwordsigned(0x838006 + memory.getregister("X")) + y
- drawbox(x1,x2,y1,y2,"#FF000040","#FF0000FF")
- end)
- end
- local function test()
- --memory.writeword(0x7E2b96,1240)
- end
- while true do
- camera()
- player()
- enemies()
- test()
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement