Advertisement
Guest User

Aero 2 syntax fixes

a guest
May 27th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. local scroll_x = 0
  2. local scroll_y = 0
  3.  
  4. function draw_trig(base)
  5. if base ~= 0xFFFFFF then
  6. if memory.read_u16_be(base) <= 0x8000 then
  7. local posx = memory.read_u16_be(base+2)
  8. local posy = memory.read_u16_be(base+4)
  9. local posxa = bit.band(posx,0xFFE0)
  10. if posx ~= posxa then
  11. posx()
  12. end
  13. local posya = bit.band(posy,0xFFE0)
  14. local x1 = bit.band(posxa+scroll_x-0x180,0xFFFF)+320/2
  15. if x1 >= 0x8000 then
  16. x1 = -(0x10000-x1)
  17. end
  18. local x2 = x1+0x1F
  19. local x3 = bit.band(posxa+scroll_x+0x40,0xFFFF)+320/2
  20. if x3 >= 0x8000 then
  21. x3 = -(0x10000-x3)
  22. end
  23. local x4 = x3+0x1F
  24. local y1 = bit.band(posya-scroll_y-0x120,0xFFFF)+224/2
  25. if posy ~= posya then
  26. y1 = y1+0x20
  27. end
  28. if y1 >= 0x8000 then
  29. y1 = -(0x10000-y1)
  30. end
  31. local y2 = y1+0x160+0x1F
  32. if posy ~= posya then
  33. y2 = y2-0x20
  34. end
  35. gui.drawBox(x1,y1,x2,y2,"#00ff0000")
  36. gui.drawBox(x3,y1,x4,y2,"#ff000000")
  37. end
  38. draw_trig(memory.read_u16_be(base+6)+0xFF0000)
  39. draw_trig(memory.read_u16_be(base+8)+0xFF0000)
  40. end
  41. end
  42.  
  43. function draw_yet(base)
  44. if base ~= 0xFFFFFF then
  45. if memory.read_u16_be(base) <= 0x8000 then
  46. local posx = memory.read_u16_be(base+2)
  47. local posy = memory.read_u16_be(base+4)
  48. local posxa = bit.band(posx,0xFFE0)
  49. local posya = bit.band(posy,0xFFF0)
  50. if posx ~= posxa then
  51. posx()
  52. end
  53. if posy ~= posya then
  54. posx()
  55. end
  56. local x1 = bit.band(posxa+scroll_x-0x180,0xFFFF)+320/2
  57. if x1 >= 0x8000 then
  58. x1 = -(0x10000-x1)
  59. end
  60. local x2 = x1+0x180+0x40+0x1F
  61. local y1 = bit.band(posy-scroll_y+0x40,0xFFFF)+224/2
  62. if y1 >= 0x8000 then
  63. y1 = -(0x10000-y1)
  64. end
  65. local y2 = y1+0xF
  66. local y3 = bit.band(posy-scroll_y-0x120,0xFFFF)+224/2
  67. if y3 >= 0x8000 then
  68. y3 = -(0x10000-y3)
  69. end
  70. local y4 = y3+0xF
  71. gui.drawBox(x1,y1,x2,y2,"#00ff0000")
  72. gui.drawBox(x1,y3,x2,y4,"#ff000000")
  73. end
  74. draw_yet(memory.read_u16_be(base+10)+0xFF0000)
  75. draw_yet(memory.read_u16_be(base+12)+0xFF0000)
  76. end
  77. end
  78.  
  79. function draw_enemy(base)
  80. local x = memory.read_u16_be(base+8)
  81. local y = memory.read_u16_be(base+12)
  82. local x1 = x-1
  83. local x2 = x+1
  84. local y1 = y-1
  85. local y2 = y+1
  86. if memory.read_u16_be(base+0x14) >= 0 then
  87. local bbox = memory.read_u32_be(base+0x38)
  88. x1 = x+memory.read_u16_be(bbox+0)
  89. x2 = x1+memory.read_u16_be(bbox+2)-1
  90. y1 = y+memory.read_u16_be(bbox+4)
  91. y2 = y1+memory.read_u16_be(bbox+6)-1
  92. end
  93. gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#ff000000")
  94. end
  95.  
  96. function draw_enemies()
  97. local base = memory.read_u16_be(0xFF3662)+0xFF0000
  98. while base ~= 0xFFFFFF do
  99. draw_enemy(base)
  100. base = memory.read_u16_be(base+2)+0xFF0000
  101. end
  102. end
  103.  
  104. function draw_bullet(base)
  105. local x = memory.read_u16_be(base+0x1C)
  106. local y = memory.read_u16_be(base+0x20)
  107. local x1 = x
  108. local x2 = x+12
  109. local y1 = y
  110. local y2 = y+12
  111. gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#ff000000")
  112. end
  113.  
  114. function draw_bullets()
  115. local base = memory.read_u16_be(0xFF3BDA)+0xFF0000
  116. while base ~= 0xFFFFFF do
  117. draw_bullet(base)
  118. base = memory.read_u16_be(base+2)+0xFF0000
  119. end
  120. end
  121.  
  122. function draw_aero()
  123. local state = memory.read_u16_be(0xFF3688)
  124. local dir = memory.read_u16_be(0xFF368A)
  125. local x = memory.read_u16_be(0xFF0176)
  126. local y = memory.read_u16_be(0xFF017A)
  127. local x1 = x-12
  128. local x2 = x
  129. local y1 = y
  130. local y2 = y+12
  131. if state == 2 or state == 3 then
  132. x1 = x-16-dir
  133. x2 = x1+32
  134. y1 = y+0x18
  135. y2 = y1+16
  136. end
  137. if state == 1 then
  138. x1 = x-16-dir
  139. x2 = x1+32
  140. y1 = y+4
  141. y2 = y1+16
  142. end
  143. gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#00ffff00")
  144. end
  145.  
  146. event.onframeend(function ()
  147. gui.drawBox(320/2-1,224/2-1,320/2+1,224/2+1,"#ff000000")
  148. scroll_x = memory.read_u16_be(0xFFD114)
  149. scroll_y = memory.read_u16_be(0xFFD074)
  150. draw_trig(memory.read_u16_be(0xFFCB02)+0xFF0000)
  151. draw_yet(memory.read_u16_be(0xFFCB04)+0xFF0000)
  152. draw_enemies()
  153. draw_bullets()
  154. draw_aero()
  155. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement