Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- HUD (all functions except stuff()) by Pasky13
- -- rest made by mostly feos and MESHUGGAH
- local camx
- lastXpos = 0
- 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 axis(x,y,color)
- gui.line(x,y-16,x,y+16,color)
- gui.line(x-16,y,x+16,y,color)
- end
- local function camera()
- camx = memory.readbyte(0xF2) + (memory.readbyte(0xF3) * 256)
- end
- local function player()
- local x = (memory.readbyte(0x720) + memory.readbyte(0x730) * 256) - camx
- local y = memory.readbyte(0x640)
- local offset = memory.readbytesigned(0x7D0)
- local action = memory.readbyte(0x620)
- if hasbit(action,findbit(3)) == true then
- axis(x,y,"#FF0000")
- else
- axis(x,y,"#FFB000")
- end
- end
- local function objects()
- for i = 1,15,1 do
- if memory.readbytesigned(0x700 + i) < 0 then
- local x = (memory.readbyte(0x720 + i) + memory.readbyte(0x730 + i) * 256) - camx
- local y = memory.readbyte(0x640 + i)
- local fill = "#FF0000FF"
- local outl = "#FF000030"
- local xrad = 0
- local yrad = 0
- local enemy = false
- local offset = 0
- local etype = memory.readbytesigned(0x7D0 + i)
- if etype < 0 then
- if bit.band(etype,0x70) == 0 then
- fill = "#FFFF00FF"
- outl = "#FFFF0030"
- else
- enemy = true
- end
- offset = bit.band(etype,0x7F)
- if enemy == true then
- if memory.readbyte(0x620) == 3 then
- offset = offset + 7
- end
- end
- xrad = rom.readbyte(0x1F4C8 + offset)
- yrad = rom.readbyte(0x1F4A8 + offset)
- if xrad < 0x50 then
- gui.box(x+xrad,y+yrad,x-xrad,y-yrad,outl,fill)
- end
- else
- offset = memory.readbyte(0x610 + i)
- xrad = rom.readbyte(0x18675 + offset)
- offset = bit.band(memory.readbyte(0x7D0+i),0x7F)
- yrad = rom.readbyte(0x1F4A8 + offset)
- if xrad < 0x50 then
- gui.box(x+xrad,y+yrad,x-xrad,y-yrad,outl,fill)
- end
- end
- --gui.text(x,y,"E" .. hex(i) .. "/" .. hex(offset) .. "/" .. hex(xrad) .. "/" .. hex(yrad))
- end
- end
- end
- function Stuff()
- camera()
- player()
- objects()
- local Xpos = memory.readbyte(0x720) + memory.readbyte(0x730) * 0x100
- local Xsub = memory.readbyte(0x670)
- local Ypos = memory.readbyte(0x640)
- local Ysub = memory.readbyte(0x660)
- local Yspd = memory.readbyte(0x7C0) + memory.readbyte(0x7B0) / 1000
- local Xspd = Xpos + (Xsub / 1000) - lastXpos
- local bossHP = memory.readbyte(0xB1)
- local bossInv = memory.readbyte(0x6FF)
- local rng = {memory.readbyte(0xC0), memory.readbyte(0xC1), memory.readbyte(0xC2), memory.readbyte(0xC3)}
- local scrnX = memory.readbyte(0x650)
- gui.text(scrnX-10, Ypos+10, string.format("%.3f\n%.3f",Xspd,Yspd), "#ffff00ff")
- gui.text( 0, 8, string.format("X: %4d.%3d\nY: %4d.%3d",Xpos,Xsub,Ypos,Ysub))
- gui.text(70, 8, string.format("Boss HP:%d\nBoss Inv:%d",bossHP,bossInv))
- gui.text(140,8, string.format("RNG: %2x:%2x:%2x:%2x", rng[1], rng[2], rng[3], rng[4]))
- lastXpos = Xpos + Xsub / 1000
- end
- emu.registerafter(Stuff)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement