program testtmap;
uses crt,gfx3,m3d52;
var l1,ode,l3:integer;
    l2:word;
    c1,c2,c3:byte;
    co:integer;

Procedure SetUpVirtual;
   { This sets up the memory needed for the virtual screen }
BEGIN
  GetMem (VirScr,64000);
  vaddr := seg (virscr^);
    GetMem (VirScr2,64000);
  vaddr2 := seg (virscr2^);

END;

{컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴}
Procedure ShutDown;
   { This frees the memory used by the virtual screen }
BEGIN
  FreeMem (VirScr,64000);
  freemem(virscr2,64000);
END;


Procedure MotionClear(Var D; Step : Byte); Assembler;
Asm
  Les  di,D
  Mov  bl,Step
  Mov  cx,64000
 @Looper:
  Mov al,es:[di]
  Sub al,bl
  Jns @SkipZero
  Mov al,0
 @SkipZero:
  Mov es:[di],al
  Inc di
  Dec  cx
  Jnz @Looper
End;

procedure buildpal;
var l1:integer;
     r,g,b:byte;
begin
  for l1:=1 to 255 do begin
    r:= palar[l1,1];
    g:=palar[l1,2];
    b:=palar[l1,3];
    pal(l1,r,g,b);
  end;
end;


begin
  setupvirtual;
  setmcga;
  setup('helios.euv');
  for l1:=1 to 255 do pal(l1,l1 div 4,l1 div 4 ,l1 div 4);


  l1:=0;
  zoff:=-150;
  d:=0.3;
  cls(vaddr2,0);
  cls(vaddr,0);
  ambient:=20;
  con:=64;
  RANDOMIZE;
  ode:=l1;
  repeat
    l1:=(l1+5) mod (360);
    rotatepoints2(0,l1,l1);
    showpolys(0,vaddr2);

{    phongit(vaddr2,vaddr);
     for l2:=1 to 63999 do begin
       if mem[vaddr2:l2]>0 then mem[sega000:l2]:=mem[vaddr2:l2]+128
       else mem[sega000:l2]:=mem[vaddr:l2];
     end;                  }
{     flip(vaddr2,vga);}
      fedges(2,vaddr2,vaddr);
      flip(vaddr,vga);
        cls32(vaddr2,0);
        cls32(vaddr,0);
  until keypressed;
  shut;
  readln;

  shutdown;
  settext;
end.

