User File #11429271374803498

Upload All User Files

#11429271374803498 - HUD display for The Adventures of Batman and Robin

TheAdventuresOfBatmanAndRobin.lua
1106 downloads
Uploaded 12/19/2013 4:51 PM by Truncated (see all 22)
Some additions and changes to the script by feos and r57shell. - emu.registerafter changed to gui.register. This means that the HUD is shown also on the frame a state is loaded. - X positions in pixels:subpixels added at top of screen, for movement comparisons.
-- The Adventures of Batman and Robin
-- 2013, feos and r57shell
function EnemyPos(Base)
  x1 = memory.readwordsigned(Base+0x12)-xcam
  y1 = memory.readwordsigned(Base+0x14)
  x2 = memory.readwordsigned(Base+0x16)-xcam
  y2 = memory.readwordsigned(Base+0x18)
  hp = memory.readwordsigned(Base+0x1E)
end
function PlayerPos()
  sbase1 = memory.readword(0xFFAD5C)+0xFF0000
  sbase2 = memory.readword(0xFFADB6)+0xFF0000
  p1speedx = memory.readlongsigned(sbase1+0x18)
  p1speedy = memory.readlongsigned(sbase1+0x1C)
  p2speedx = memory.readlongsigned(sbase2+0x18)
  p2speedy = memory.readlongsigned(sbase2+0x1C)
  p1accelx = memory.readlong(sbase1+0x20)
  p1accely = memory.readlong(sbase1+0x28)
  p2accelx = memory.readlong(sbase2+0x20)
  p2accely = memory.readlong(sbase2+0x28)
end

gui.register(function ()
  xcam = memory.readwordunsigned(0xFFDFC4)
  ycam = memory.readwordunsigned(0xFFCD70)
  X1 = memory.readword(0xFFAD92)-xcam
  Y1 = memory.readword(0xFFAD96)
  X2 = memory.readword(0xFFADEC)-xcam
  Y2 = memory.readword(0xFFADF0)
  
  Xpos1    = memory.readword(0xFFAD92)
  Xpossub1 = memory.readbyteunsigned(0xFFAD94)
  Xpos2    = memory.readword(0xFFADEC)
  Xpossub2 = memory.readbyteunsigned(0xFFADEE)
  
  PlayerPos()
  base = memory.readword(0xFFDEB2)
  i = 0
  while (base~=0) do
    base = base+0xFF0000
    if (memory.readword(base+2) == 0) then
      break
    end
    EnemyPos(base)
    gui.box(x1,y1,x2,y2,"#00ff0000")
    base = memory.readword(base+2)
    i = i+1;
    if (i>400) then
      break;
    end
  end
  base = memory.readword(0xFFDEBA)
  i = 0
  while (base ~= 0) do
    base = base+0xFF0000
    if (memory.readword(base+2) == 0) then
      break
    end
    EnemyPos(base)
    gui.box(x1,y1,x2,y2,"#00ffff00")
    gui.text(x1+2,y1+1,hp,"#ff00ff")
    if (x2<   0) then gui.text(x1+2,y2-7,"x:"..x1    ) end
    if (x1>=320) then gui.text(x1+2,y2-7,"x:"..x1-320) end
    if (y2<   0) then gui.text(x2+2,y2-7,"y:"..y2    ) end    
    base = memory.readword(base+2)
    i = i+1;
    if (i>400) then
      break;
    end
  end
  gui.text(X1,Y1,string.format("%.3f\n%.3f",p1speedx/0x10000,p1speedy/0x10000,X1))
  gui.text(X2,Y2,string.format("%.3f\n%.3f",p2speedx/0x10000,p2speedy/0x10000))
  
  gui.text(130,10,"X1: " .. Xpos1 .. ":" .. Xpossub1, "grey")
  gui.text(130,20,"X2: " .. Xpos2 .. ":" .. Xpossub2, "green")
  
end)