Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Author Pasky 13
- --Player
- local px = 0x54C
- local py = 0x532
- --Player projectiles
- local projxbase = 0x588
- local projybase = 0x578
- --Enemies
- local ex = 0x53C
- local ey = 0x522
- local function hex(val)
- val = string.format("%X",val)
- return val
- end
- local function draw_axis(x,y,color)
- gui.line(x,y-4,x,y+4,color)
- gui.line(x-4,y,x+4,y,color)
- end
- local function sign(val)
- if val > 0x7F then
- val = 256 + (val * -1)
- end
- return val
- end
- local box_data = {
- 0xEA,0xF4,0x2A,0x16,0xF0,0xFA,0x1E,0x0A,0xE5,0xF7,0x34,0x10,0xE1,0xEB,0x3C,0x28,
- 0xF1,0xEF,0x28,0x20,0xE1,0xD3,0x3C,0x58,0xD1,0xDB,0x6C,0x48,0xD1,0xEB,0x5C,0x28,
- 0xF2,0xF2,0x1A,0x1A,0xF8,0xF8,0x0E,0x0E,0xED,0xF5,0x24,0x14,0xE9,0xE9,0x2C,0x2C,
- 0xF9,0xED,0x18,0x24,0xE9,0xD1,0x2C,0x5C,0xD9,0xD9,0x5C,0x4C,0xD9,0xE9,0x4C,0x2C,
- 0xEA,0xEA,0x16,0x2A,0xF0,0xF0,0x0A,0x1E,0xE5,0xED,0x20,0x24,0xE1,0xE1,0x28,0x3C,
- 0xF1,0xE5,0x14,0x34,0xE1,0xC9,0x28,0x6C,0xD1,0xD1,0x58,0x5C,0xD1,0xE1,0x48,0x3C,
- 0xEA,0xF4,0x22,0x16,0xF0,0xFA,0x16,0x0A,0xE5,0xF7,0x2C,0x10,0xE1,0xEB,0x34,0x28,
- 0xF1,0xEF,0x20,0x20,0xE1,0xD3,0x34,0x58,0xD1,0xDB,0x64,0x48,0xD1,0xEB,0x54,0x28,
- 0xF8,0xF4,0x1A,0x16,0xFE,0xFA,0x0E,0x0A,0xF3,0xF7,0x24,0x10,0xEF,0xEB,0x2C,0x28,
- 0xFF,0xEF,0x18,0x20,0xEF,0xD3,0x2C,0x58,0xDF,0xDB,0x5C,0x48,0xDF,0xEB,0x4C,0x28,
- 0xF3,0xF3,0x18,0x18,0xF7,0xF7,0x10,0x10,0xEC,0xF3,0x26,0x18,0xEB,0xEB,0x28,0x28,
- 0xFB,0xEF,0x14,0x20,0xEB,0xD3,0x28,0x58,0xD3,0xEB,0x28,0x28,0xDB,0xEB,0x48,0x28,
- 0xF0,0xF4,0x1E,0x16,0xF6,0xFA,0x12,0x0A,0xEB,0xF7,0x28,0x10,0xE7,0xEB,0x30,0x28,
- 0xF7,0xEF,0x1C,0x20,0xE7,0xD3,0x30,0x58,0xD7,0xDB,0x60,0x48,0xD7,0xEB,0x50,0x28,
- 0xA5,0x5B,0x29,0x01,0xAA,0xB5,0xC6,0x38,0x65,0x07,0xA8,0xBD,0x4C,0x05,0xF9,0x01,
- 0xA0,0xE5,0x05,0xD9,0x03,0xA0,0xB0,0x0D,0xBD,0x32,0x05,0xF9,0x00,0xA0,0xE5,0x06 }
- local function Player()
- -- Player 1
- if memory.readbyte(0xC6) ~= 0 then
- local x = memory.readbyte(px)
- local y = memory.readbyte(py)
- draw_axis(x,y,"#0000FFFF")
- end
- -- Player 2
- if memory.readbyte(0xC7) ~= 0 then
- x = memory.readbyte(px+1)
- y = memory.readbyte(py+1)
- draw_axis(x,y,"#0000FFFF")
- end
- end
- local function bullets()
- -- P1
- if memory.readbyte(0xC6) ~= 0 then
- for i = 0,9,1 do
- local x = memory.readbyte(projxbase + i)
- local y = memory.readbyte(projybase + i)
- if memory.readbyte(0x638 + i) > 0 then
- gui.box(x-2,y-2,x+2,y+2,"#FFFFFF40","#FFFFFFFF")
- end
- end
- end
- -- P2
- if memory.readbyte(0xC7) ~= 0 then
- for i = 0,9,1 do
- local x = memory.readbyte(0x592 + i)
- local y = memory.readbyte(0x582 + i)
- if memory.readbyte(0x642 + i) > 0 then
- gui.box(x-2,y-2,x+2,y+2,"#FFFFFF40","#FFFFFFFF")
- end
- end
- end
- end
- local function enemies()
- local active
- local etype
- local fill
- local outl
- for i = 0,0x0D,1 do
- active = memory.readbyte(0x508+i) -- sprite frame
- etype = memory.readbyte(0x73A + i)
- if etype == 4 or etype == 0x0C then -- Enemy projectiles
- fill = "#00FF00FF"
- outl = "#00FF0035"
- else
- fill = "#FF0000FF"
- outl = "#FF000035"
- end
- local x = memory.readbyte(ex + i)
- local y = memory.readbyte(ey + i)
- -- Collision detection player 1
- if memory.readbyte(0xC6) ~= 0 then
- if active > 0 then
- local offset = ((memory.readbyte(0xC6) + etype + 1) % 0x100)
- local xoff = sign(box_data[1 + 1 + offset]) + 1
- local xrad = box_data[1 + 3 + offset]
- local yoff = sign(box_data[1 + offset]) + 1
- local yrad = box_data[1 + 2 + offset]
- gui.box(x-xoff,y-yoff,x-xoff+xrad,y-yoff+yrad,outl,fill)
- end
- end
- -- Collision detection player 2
- if memory.readbyte(0xC7) ~= 0 then
- if active > 0 then
- local offset = ((memory.readbyte(0xC7) + etype + 1) % 0x100)
- local xoff = sign(box_data[1 + 1 + offset]) + 1
- local xrad = box_data[1 + 3 + offset]
- local yoff = sign(box_data[1 + offset]) + 1
- local yrad = box_data[1 + 2 + offset]
- gui.box(x-xoff,y-yoff,x-xoff+xrad,y-yoff+yrad,outl,fill)
- end
- end
- -- Projectile collision
- if active > 0 and etype ~= 4 and etype ~= 0x0C then
- local poffset = etype + 0xA0
- local pxoff = sign(box_data[1 + 1 + poffset]) + 1
- local pxrad = box_data[1 + 3 + poffset] - 2
- local pyoff = sign(box_data[1 + poffset]) + 1
- local pyrad = box_data[1 + 2 + poffset] - 2
- gui.box(x-pxoff,y-pyoff,x-pxoff+pxrad,y-pyoff+pyrad,"#FFFF0040","#FFFF00FF")
- end
- end
- end
- while true do
- Player()
- bullets()
- enemies()
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement