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=
    ($ff00,4, 0,2,6,4,
     $ff01,4, 0,1,3,2,
     $ff02,4, 4,6,7,5,
     $ff00,4, 1,5,7,3,
     $ff03,4, 2,3,7,6,
     $ff04,4, 0,4,5,1,0,0);

    { $ff = use textures, number in the low-byte}

Var
    i,j:Word;

Procedure Prep_Textures;
{load texture variables}
Begin
  LoadGif('Texture');           {load texture image}
  GetMem(Txt_Pic,64000);        {get memory for this}
  Move(VScreen^,Txt_Pic^,64000);{and copy to memory}
  For i:=0 to Txt_Number-1 do Begin
    Txt_Data[i]:=Txt_Pic;       {load pointer to data}
    Txt_Offs[i]:=i*64;          {determine offset}
  End;
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}
  init_modex;                   {enable ModeX}
  Prep_Textures;
  LoadGif('logo.gif');          {load wallpaper}
  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.
