Guest User

Untitled

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