Uses Crt,ModeXLib,Gif,var_3d;

Const
    worldlen=8*3;               {Point-Array}
    Worldconst:Array[0..worldlen-1] of Integer =
    (-200,-200,-200,
    -200,-200,200,
    -200,200,-200,
    -200,200,200,
    200,-200,-200,
    200,-200,200,
    200,200,-200,
    200,200,200);
    surfclen=38;                {Surface-Array}
    surfcconst:Array[0..surfclen-1] of Word=
    ($fee0,4, 0,2,6,4,
     $fec0,4, 0,1,3,2,
     $fec0,4, 4,6,7,5,
     $fee0,4, 1,5,7,3,
     $fec0,4, 2,3,7,6,
     $fec0,4, 0,4,5,1,0,0);
    { $fe = use light source, primary color in the low-byte}

Var
    i,j:Word;

Procedure Shad_Pal;             {prepare palette for shading}
Begin
  For j:=192 to 223 do Begin    {prepare colors 192 - 223 and 224 - 255}
    i:=trunc((j/32)*43);        {determine brightness}
    Fillchar(Palette[j*3],3,i+20);  {colors 192-223 to gray tones}

    Palette[(j+32)*3]:=i+20;    {colors 224-255 to red tones}
    Palette[(j+32)*3+1]:=0;
    Palette[(j+32)*3+2]:=0;
  End;
  Setpal;                       {set this palette}
End;

procedure drawworld;external;   {draws the world on current video page}
{$l 3dasm.obj}
{$l poly.obj}
{$l bres.obj}
{$l root.obj}

Begin
  vz:=1000;                     {solid is located at 1000 unit depth}
  vpage:=0;                     {start with page 0}
  LoadGif('logor.gif');         {load wallpaper}
  init_modex;                   {enable ModeX}
  Shad_Pal;                     {calculate shading palette}
  rotx:=0;                      {initial values for rotation}
  roty:=0;
  rotz:=0;
  Fill:=true;                   {SurfaceFill on}
  sf_sort:=true;                {SurfaceSort on}
  sf_shift:=true;               {SurfaceShift suppression on}
  Glass:=false;                 {glass surfaces off}
  p13_2_modex(16000*2,16000);   {wallpaper to VGA page 2}
  repeat
    CopyScreen(vpage,16000*2);  {wallpaper to current page}
    DrawWorld;                  {draw world}
    switch;                     {switch to finished picture}
    WaitRetrace;                {wait for next retrace}
    Inc(rotx);                  {continue rotating ... }
    If rotx=120 Then rotx:=0;
    Inc(rotz);
    If rotz=120 Then rotz:=0;
    inc(roty);
    if roty=120 Then roty:=0;
  Until KeyPressed;             { ... until key}
  TextMode(3);
End.
