Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scroll_x = 0
- local scroll_y = 0
- function draw_trig(base)
- if base ~= 0xFFFFFF then
- if memory.read_u16_be(base) <= 0x8000 then
- local posx = memory.read_u16_be(base+2)
- local posy = memory.read_u16_be(base+4)
- local posxa = bit.band(posx,0xFFE0)
- if posx ~= posxa then
- posx()
- end
- local posya = bit.band(posy,0xFFE0)
- local x1 = bit.band(posxa+scroll_x-0x180,0xFFFF)+320/2
- if x1 >= 0x8000 then
- x1 = -(0x10000-x1)
- end
- local x2 = x1+0x1F
- local x3 = bit.band(posxa+scroll_x+0x40,0xFFFF)+320/2
- if x3 >= 0x8000 then
- x3 = -(0x10000-x3)
- end
- local x4 = x3+0x1F
- local y1 = bit.band(posya-scroll_y-0x120,0xFFFF)+224/2
- if posy ~= posya then
- y1 = y1+0x20
- end
- if y1 >= 0x8000 then
- y1 = -(0x10000-y1)
- end
- local y2 = y1+0x160+0x1F
- if posy ~= posya then
- y2 = y2-0x20
- end
- gui.drawBox(x1,y1,x2,y2,"#00ff0000")
- gui.drawBox(x3,y1,x4,y2,"#ff000000")
- end
- draw_trig(memory.read_u16_be(base+6)+0xFF0000)
- draw_trig(memory.read_u16_be(base+8)+0xFF0000)
- end
- end
- function draw_yet(base)
- if base ~= 0xFFFFFF then
- if memory.read_u16_be(base) <= 0x8000 then
- local posx = memory.read_u16_be(base+2)
- local posy = memory.read_u16_be(base+4)
- local posxa = bit.band(posx,0xFFE0)
- local posya = bit.band(posy,0xFFF0)
- if posx ~= posxa then
- posx()
- end
- if posy ~= posya then
- posx()
- end
- local x1 = bit.band(posxa+scroll_x-0x180,0xFFFF)+320/2
- if x1 >= 0x8000 then
- x1 = -(0x10000-x1)
- end
- local x2 = x1+0x180+0x40+0x1F
- local y1 = bit.band(posy-scroll_y+0x40,0xFFFF)+224/2
- if y1 >= 0x8000 then
- y1 = -(0x10000-y1)
- end
- local y2 = y1+0xF
- local y3 = bit.band(posy-scroll_y-0x120,0xFFFF)+224/2
- if y3 >= 0x8000 then
- y3 = -(0x10000-y3)
- end
- local y4 = y3+0xF
- gui.drawBox(x1,y1,x2,y2,"#00ff0000")
- gui.drawBox(x1,y3,x2,y4,"#ff000000")
- end
- draw_yet(memory.read_u16_be(base+10)+0xFF0000)
- draw_yet(memory.read_u16_be(base+12)+0xFF0000)
- end
- end
- function draw_enemy(base)
- local x = memory.read_u16_be(base+8)
- local y = memory.read_u16_be(base+12)
- local x1 = x-1
- local x2 = x+1
- local y1 = y-1
- local y2 = y+1
- if memory.read_u16_be(base+0x14) >= 0 then
- local bbox = memory.read_u32_be(base+0x38)
- x1 = x+memory.read_u16_be(bbox+0)
- x2 = x1+memory.read_u16_be(bbox+2)-1
- y1 = y+memory.read_u16_be(bbox+4)
- y2 = y1+memory.read_u16_be(bbox+6)-1
- end
- gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#ff000000")
- end
- function draw_enemies()
- local base = memory.read_u16_be(0xFF3662)+0xFF0000
- while base ~= 0xFFFFFF do
- draw_enemy(base)
- base = memory.read_u16_be(base+2)+0xFF0000
- end
- end
- function draw_bullet(base)
- local x = memory.read_u16_be(base+0x1C)
- local y = memory.read_u16_be(base+0x20)
- local x1 = x
- local x2 = x+12
- local y1 = y
- local y2 = y+12
- gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#ff000000")
- end
- function draw_bullets()
- local base = memory.read_u16_be(0xFF3BDA)+0xFF0000
- while base ~= 0xFFFFFF do
- draw_bullet(base)
- base = memory.read_u16_be(base+2)+0xFF0000
- end
- end
- function draw_aero()
- local state = memory.read_u16_be(0xFF3688)
- local dir = memory.read_u16_be(0xFF368A)
- local x = memory.read_u16_be(0xFF0176)
- local y = memory.read_u16_be(0xFF017A)
- local x1 = x-12
- local x2 = x
- local y1 = y
- local y2 = y+12
- if state == 2 or state == 3 then
- x1 = x-16-dir
- x2 = x1+32
- y1 = y+0x18
- y2 = y1+16
- end
- if state == 1 then
- x1 = x-16-dir
- x2 = x1+32
- y1 = y+4
- y2 = y1+16
- end
- gui.drawBox(x1-bit.band(-scroll_x,0xFFFF), y1-scroll_y, x2-bit.band(-scroll_x,0xFFFF)+2, y2-scroll_y+2,"#00ffff00")
- end
- event.onframeend(function ()
- gui.drawBox(320/2-1,224/2-1,320/2+1,224/2+1,"#ff000000")
- scroll_x = memory.read_u16_be(0xFFD114)
- scroll_y = memory.read_u16_be(0xFFD074)
- draw_trig(memory.read_u16_be(0xFFCB02)+0xFF0000)
- draw_yet(memory.read_u16_be(0xFFCB04)+0xFF0000)
- draw_enemies()
- draw_bullets()
- draw_aero()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement