Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. function getTile(dx, dy)
  2. if gameinfo.getromname() == "Super Mario World (USA)" then
  3. x = math.floor((marioX+dx+8)/16)
  4. y = math.floor((marioY+dy)/16)
  5.  
  6. return memory.readbyte(0x1C800 + math.floor(x/0x10)*0x1B0 + y*0x10 + x%0x10)
  7. elseif gameinfo.getromname() == "Super Mario Bros." then
  8. local x = marioX + dx + 8
  9. local y = marioY + dy - 16
  10. local page = math.floor(x/256)%2
  11.  
  12. local subx = math.floor((x%256)/16)
  13. local suby = math.floor((y - 32)/16)
  14. local addr = 0x500 + page*13*16+suby*16+subx
  15.  
  16. if suby >= 13 or suby < 0 then
  17. return 0
  18. end
  19.  
  20. if memory.readbyte(addr) ~= 0 then
  21. return 1
  22. else
  23. return 0
  24. end
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement