{this is convert from tunell asm src to PURE pascal,
 DAT files are from original zip. Simple code but how can I angle and
 depth data ? help me via e-mail}
program tunnel;
uses crt,mygraph;
const vga=$a000;
      maxframe=400;

type     virtual = Array [1..64000] of byte;
         VirtPtr = ^Virtual;
var angle,depth,texture,screen:word;
    Virangle,virdepth,virscr,virtexture: VirtPtr;
    addr_x,addr_y:word;
    timer:word;

procedure virtinit; {alokace pameti}
begin
  GetMem (Virangle,64000);
  angle := seg (virangle^);
  GetMem (Virdepth,64000);
  depth := seg (virdepth^);
  getmem (virtexture,64000);
  texture :=seg(virtexture^);
  getmem (virscr,64000);
  screen :=seg(virscr^);
END;

Procedure ShutDown;
   {Uvolneni pameti  }
BEGIN
  FreeMem (VirScr,64000);
  FreeMem (Virtexture,64000);
  freemem (virdepth,64000);
  freemem (virangle,64000);
END;  {Shutdown}

procedure init;
var soub:file;
begin
assign(soub,'angle.dat');
reset(soub,1);
blockread(soub,mem[angle:0],64000);

assign(soub,'depth.dat');
reset(soub,1);
blockread(soub,mem[depth:0],64000);

assign(soub,'screen1.dat');
reset(soub,1);
blockread(soub,mem[texture:0],64000);

loadpalette('palette.pal',0);
end;

procedure tuneling;
var x,y:integer;
    text_x,text_y,text_map:word;
begin
inc(addr_x,6);
inc(addr_y,6);
for x:= 0 to 320 DO
 for y:=0 to 200 DO
  begin
   text_x:=(mem[angle:(x+y*320)]+addr_x) and 255;
   text_y:=(mem[depth:(x+y*320)]+addr_y) and 255;
   text_map:=(text_x+text_y*320);
   mem[screen:(x+y*320)]:=mem[texture:text_map];
  end;
end;

procedure fade;
var a:integer;
begin
if timer<64 then
 begin
  for a:= 0 to 255 do
   begin
    If StorePal[a,1] > ActivePal[a,1] then
     activepal[a,1]:=ActivePal[a,1]+1;
    If StorePal[a,2] > ActivePal[a,2] then
     activepal[a,2]:=ActivePal[a,2]+1;
    If StorePal[a,3] > ActivePal[a,3] then
     activepal[a,3]:=ActivePal[a,3]+1;
   end;
  SetPalette;
 end;
if timer>=(maxframe-64) then
 begin
  for a:=0 to 255 do
   begin
    if activepal[a,1]>0 then
     activepal[a,1]:=ActivePal[a,1]-1;
    if activepal[a,2]>0 then
     activepal[a,2]:=ActivePal[a,2]-1;
    if activepal[a,3]>0 then
     activepal[a,3]:=ActivePal[a,3]-1;
   end;
   setpalette;
  end;
end;


begin
virtinit;
init;
setmode;
setpalette;
getpalette;
nullpalette;
addr_x:=0;
addr_y:=0;

for timer:=1 to maxframe do
 begin
 fade;
 tuneling;
 waitretrace;
 flip(screen,vga);
 if port[$60]=$01 then break;
end;
shutdown;
end.
