Guest User

Untitled

a guest
Aug 1st, 2013
116
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- HUD (all functions except stuff()) by Pasky13
  2. -- rest made by mostly feos and MESHUGGAH
  3.  
  4. local camx
  5.  
  6. lastXpos = 0
  7.  
  8. function findbit(p)
  9.     return 2 ^ (p - 1)
  10. end
  11.  
  12. function hasbit(x, p)
  13.     return x % (p + p) >= p
  14. end
  15.  
  16. local function hex(val)
  17.     val = string.format("%X",val)
  18.     if string.len(val) == 1 then
  19.         val = "0" .. val
  20.     end
  21.     return val
  22. end
  23.  
  24. local function axis(x,y,color)
  25.     gui.line(x,y-16,x,y+16,color)
  26.     gui.line(x-16,y,x+16,y,color)
  27. end
  28.  
  29. local function camera()
  30.     camx = memory.readbyte(0xF2) + (memory.readbyte(0xF3) * 256)
  31. end
  32.  
  33. local function player()
  34.     local x = (memory.readbyte(0x720) + memory.readbyte(0x730) * 256) - camx
  35.     local y = memory.readbyte(0x640)
  36.     local offset = memory.readbytesigned(0x7D0)
  37.     local action = memory.readbyte(0x620)
  38.     if hasbit(action,findbit(3)) == true then
  39.         axis(x,y,"#FF0000")
  40.     else
  41.         axis(x,y,"#FFB000")
  42.     end
  43.    
  44. end
  45.  
  46. local function objects()
  47.     for i = 1,15,1 do
  48.         if memory.readbytesigned(0x700 + i) < 0 then
  49.        
  50.             local x = (memory.readbyte(0x720 + i) + memory.readbyte(0x730 + i) * 256) - camx
  51.             local y = memory.readbyte(0x640 + i)
  52.             local fill  = "#FF0000FF"
  53.             local outl = "#FF000030"
  54.             local xrad = 0
  55.             local yrad = 0
  56.             local enemy = false
  57.             local offset = 0
  58.            
  59.             local etype = memory.readbytesigned(0x7D0 + i)
  60.             if etype < 0 then
  61.                 if bit.band(etype,0x70)  == 0 then
  62.                     fill = "#FFFF00FF"
  63.                     outl = "#FFFF0030"
  64.                 else
  65.                     enemy = true
  66.                 end
  67.                
  68.                 offset = bit.band(etype,0x7F)
  69.                 if enemy == true then
  70.                     if memory.readbyte(0x620) == 3 then
  71.                         offset = offset + 7
  72.                     end
  73.                 end
  74.                
  75.                 xrad = rom.readbyte(0x1F4C8 + offset)
  76.                 yrad = rom.readbyte(0x1F4A8 + offset)
  77.                 if xrad < 0x50 then
  78.                     gui.box(x+xrad,y+yrad,x-xrad,y-yrad,outl,fill)
  79.                 end
  80.             else
  81.                 offset = memory.readbyte(0x610 + i)
  82.                 xrad = rom.readbyte(0x18675 + offset)
  83.                 offset = bit.band(memory.readbyte(0x7D0+i),0x7F)
  84.                 yrad = rom.readbyte(0x1F4A8 + offset)
  85.                 if xrad < 0x50 then
  86.                     gui.box(x+xrad,y+yrad,x-xrad,y-yrad,outl,fill)
  87.                 end
  88.             end
  89.             --gui.text(x,y,"E" .. hex(i) .. "/" .. hex(offset) .. "/" .. hex(xrad) .. "/" .. hex(yrad))
  90.         end
  91.        
  92.     end
  93. end
  94.  
  95.  
  96.  
  97. function Stuff()
  98.     camera()
  99.     player()
  100.     objects()
  101.  
  102.     local Xpos = memory.readbyte(0x720) + memory.readbyte(0x730) * 0x100
  103.     local Xsub = memory.readbyte(0x670)
  104.     local Ypos = memory.readbyte(0x640)
  105.     local Ysub = memory.readbyte(0x660)
  106.     local Yspd = memory.readbyte(0x7C0) + memory.readbyte(0x7B0) / 1000
  107.    
  108.     local Xspd = Xpos + (Xsub / 1000) - lastXpos
  109.  
  110.     local bossHP = memory.readbyte(0xB1)
  111.     local bossInv = memory.readbyte(0x6FF)
  112.  
  113.     local rng = {memory.readbyte(0xC0), memory.readbyte(0xC1), memory.readbyte(0xC2), memory.readbyte(0xC3)}
  114.  
  115.     local scrnX = memory.readbyte(0x650)
  116.     gui.text(scrnX-10, Ypos+10, string.format("%.3f\n%.3f",Xspd,Yspd), "#ffff00ff")
  117.     gui.text( 0, 8, string.format("X: %4d.%3d\nY: %4d.%3d",Xpos,Xsub,Ypos,Ysub))
  118.     gui.text(70, 8, string.format("Boss HP:%d\nBoss Inv:%d",bossHP,bossInv))
  119.     gui.text(140,8, string.format("RNG: %2x:%2x:%2x:%2x", rng[1], rng[2], rng[3], rng[4]))
  120.     lastXpos = Xpos + Xsub / 1000
  121. end
  122.  
  123. emu.registerafter(Stuff)
RAW Paste Data