{ GRAPHICS DONE BY THE WILD BUNCH Copyright (c) 1994 }
const
name = 's.vga';
name1= 'aa.vga';
pal[768]:byte = incdat 'a.pal';
data[1242]:byte = incdat 'a.dat';
fire[5,5]:byte =  ((0, 0, 40, 0, 0),
                   (0, 40,42, 40, 0),
                   (40,42,42, 42, 40),
                   (0, 40,42, 40, 0),
                   (0, 0, 40, 0, 0));
newtype shoot
        on:byte;
        xpos:longint;
        ypos:longint;
        endtype;

newtype enemy
        x:longint;
        y:longint;
        speed:longint;
        endtype;

var
VGAMEM:DWORD;
handle:dword;
handle1:dword;
p:dword;
i,i1:dword;
x,y:longint;
scroll:longint;
mem:dword;
enemymem:dword;
s[10]:shoot;
delay:byte;
e[2]:enemy;
Begin
  begin
  mem = getmem (64006);
  handle = openfile( offset(name) );
  readfile (mem,64006,handle) ;
  closefile (handle);

  enemymem = getmem (1246);
  handle = openfile( offset(name1) );
  readfile (enemymem,1246,handle) ;
  closefile (handle);

  VGAMEM = GETREL ($A0000);
  if set_vga_modex (0,320*4,200,1) = 0 then
        exit;

  load_dac_register (offset (pal),0,255,0);
  x=0;
  y=20;
  scroll = 0;
  delay = 1;
  draw_bitmap (mem+4,0,0,320,200);
  copy_bitmap (0,0,20,319,200,0,320,20) ;
  copy_bitmap (0,0,20,319,200,0,640,20) ;
  copy_bitmap (0,0,20,319,200,0,960,20) ;
  splitscreen (360);

  for i = 0 to 2 do begin
        e[i].x = 320;
        e[i].y = random(150 /30)*30+20;
        e[i].speed = random(4)+1;
        end;
  repeat

  for i = 0 to 2 do
        for i1 = 0 to 10  do
                if s[i1].on = 1 and
                   s[i1].xpos >= e[i].x and s[i1].xpos <= e[i].x + 29 and
                   s[i1].ypos >= e[i].y and s[i1].ypos <= e[i].y + 29 then
                        begin
                        e[i].x = 320;
                        e[i].y = random(150 /30)*30+20;
                        e[i].speed = random(4)+1;
                        s[i1].on = 0;
                        end;
  if inkey[29] = 1  then
    delay = delay - 1
  else
    delay = 1;

    if delay = 0 then begin
        i = 0;
        while s[i].on = 1 and i < 10 do
                i = i + 1;
        if i < 10 then begin
                s[i].on = 1;
                s[i].xpos = x+37;
                s[i].ypos = y+14;
                delay = 15;
                end
                else
                delay = 1;
        end;


  if inkey[72] = 1 then begin
        y = y - 4;
        if y < 20 then y = 20;
        end;
  if inkey[80] = 1 then begin
        y = y + 4;
        if y > 170 then y = 170
        end;

  if inkey[77] = 1 then begin
        x = x + 4;
        if x > 160 then x = 160;
        end;
  if inkey[75] = 1 then begin
        x = x - 4;
        if x < 0 then x = 0;
        end;
  tdraw_bitmap (offset (data),x+scroll,y,37,30);
  for i = 0 to 10 do
        if s[i].on = 1 then begin
                tdraw_bitmap (offset (fire),s[i].xpos+scroll,s[i].ypos,5,5);
                end;

  for i = 0 to 2 do
                tdraw_bitmap (enemymem+4,e[i].x+scroll,e[i].y,39,31);
  

  set_window (0,scroll,20);
  copy_bitmap (0,x+scroll+640,y,x+scroll+680,y+40,0,x+scroll,y) ;
  for i = 0 to 2 do begin
        copy_bitmap (0,e[i].x+scroll+640,e[i].y,e[i].x+scroll+680,e[i].y+40,0,e[i].x+scroll,e[i].y) ;
        e[i].x = e[i].x - e[i].speed;
        if e[i].x < 1 then begin
                e[i].x = 320;
                e[i].y = random(150 /30)*30+20;
                end;
        end;
  for i = 0 to 10 do
        if s[i].on = 1 then begin
                copy_bitmap (0,s[i].xpos+scroll+640,s[i].ypos,s[i].xpos+scroll+645
                ,s[i].ypos+5,0, s[i].xpos+scroll,s[i].ypos) ;
                s[i].xpos = s[i].xpos + 10;
                if s[i].xpos > 320 then s[i].on = 0;
                end;
  scroll = scroll + 1;
  if scroll > 320 then scroll = 0;
  until inkey[1]=1;
  end;
  mode03;
END.



