Guest User

Castlevania Collision box viewer (BIZHAWK)

a guest
Oct 7th, 2012
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | None | 0 0
  1. local px = 0x38C
  2. local py = 0x354
  3. local pl = 0x45
  4.  
  5. local ex = 0x38C
  6. local ey = 0x354
  7.  
  8. memory.usememorydomain("PRG ROM")
  9.  
  10. local function whip()
  11.     local box = {0,0,0} -- xoff/yoff/xrad/yrad
  12.     local wtype = mainmemory.read_u8(0x70)
  13.     local pos = bit.band(mainmemory.read_u8(0x434),0x7F)  -- Simons acting positon (jumping/crouching, etc...)
  14.     box[1] = memory.read_s8(0x1E45D + wtype)  
  15.     wtype = wtype * 2
  16.     box[2] = memory.read_s8(0x1E460 + pos)
  17.     box[3] = memory.read_u8(0x1E464 + wtype)
  18.     box[4] = memory.read_u8(0x1E465 + wtype)
  19.    
  20.     if mainmemory.read_u8(0x450) == 1 then  -- Simon is facing left
  21.         box[1] = box[1] * -1
  22.         box[3] = box[3] * -1
  23.     end
  24.     return box
  25. end
  26.  
  27. local function player()
  28.     local x = mainmemory.read_u8(px)
  29.     local y = mainmemory.read_u8(py)
  30.     local box
  31.     gui.drawBox(x+4,y+mainmemory.read_u8(0x5F),x-4,y-mainmemory.read_u8(0x5F),0xFF0000FF,0x400000FF)
  32.    
  33.     if mainmemory.read_u8(0x568) == 0x11 then -- Whip is active
  34.         box = whip()
  35.         gui.drawBox(x+box[1]+box[3],y+box[2]+box[4],x+box[1]-box[3],y+box[2]-box[4],0xFFFFFFFF,0x40FFFFFF)
  36.     end
  37.    
  38. end
  39.  
  40. local function buildbox(i)
  41.     local box = {0,0}  -- xrad/yrad
  42.     local dracform = mainmemory.read_u8(0x434 + i)
  43.        
  44.     if offset == 0x1D then
  45.         dracform = mainmemory.read_u8(0x7A)
  46.         if dracform == 1 then
  47.             offset = 0x30 * 2
  48.         else
  49.             offset = offset * 2
  50.         end
  51.     else
  52.         offset = offset * 2
  53.     end
  54.  
  55.     box = { memory.read_u8(0x1E46A + offset),memory.read_u8(0x1E46B + offset) }
  56.    
  57.     return box
  58. end
  59.  
  60. local function getcolor(x)
  61.     local color = {0,0} -- Fill/Outline
  62.     if x >= 0x28 and x < 0x30 then
  63.         color = {0x40FFA500,0xFFFFA500}
  64.     elseif x >= 0x30 and x <= 0x35 then
  65.         return color
  66.     elseif x == 0x17 then -- Simon subweapon
  67.         color = {0x4000FFFF,0xFF00FFFF}
  68.     elseif x == 0x1D then -- dracula invuln box
  69.         color = {0x40FF0000,0xFFFFFFFF}
  70.     else
  71.         color = {0x40FF0000,0xFFFF0000}
  72.     end
  73.     return color
  74. end
  75.  
  76. local function objects()
  77.     local x
  78.     local y
  79.     local active
  80.     local box
  81.     local etype
  82.     local c
  83.     local oob
  84.    
  85.     for i = 3,20,1 do
  86.         oob = mainmemory.read_u8(0x300 + i)
  87.         if oob == 0 or oob == 0x80 then
  88.             box = buildbox(i)
  89.             etype = mainmemory.read_u8(0x434 + i)
  90.             c = getcolor(etype)
  91.             x = mainmemory.read_u8(ex + i)
  92.             y = mainmemory.read_u8(ey + i)
  93.             gui.drawBox(x+box[1],y+box[2],x-box[1],y-box[2],c[2],c[1])
  94.             if etype == 0x1D then -- if dracula's invuln box
  95.                 gui.drawLine(x+box[1],y,x-box[1],y,0xFFFFFFFF)
  96.                 gui.drawLine(x,y+box[2],x,y-box[2],0xFFFFFFFF)
  97.             end
  98.         end
  99.     end
  100. end
  101.  
  102.  
  103. while true do
  104.     player()
  105.     objects()
  106.     emu.frameadvance()
  107. end
Advertisement
Add Comment
Please, Sign In to add comment