{----------------------------------- XtaC -----------------------------------}
{ File - DEMO.PAS                                                            }
{ Created - 19/08/1996, 2:45:00 AM                                           }
{ Programmer - Milton Moura aka XtaC aka U2RDEAD aka Xboy¨                   }
{ Comments - This is, like, my 1st demo... Cewl, Hum?                        }
{----------------------------------- XtaC -----------------------------------}
(* Sets enough Heap Space for Virtual Screens & ModPlay *)
{$M 65520,0,65530}
Uses Crt, Dos,
	  MemGrfx, Routines, Plasma, TDStar, Copper;

Type Virtual = Array[1..64000] Of Byte;
	  VirtPtr = ^Virtual;

Var VirtScr: VirtPtr;
	 VAddr: Word;

{$L PLAYER.DAT}
{$F+}
Procedure ModVolume(v1,v2,v3,v4: integer); External;
Procedure ModDevice(Var device: integer); External;
Procedure ModSetup(Var status: integer;device,mixspeed,pro,loop: integer;Var str: String); External;
Procedure ModStop; External;
Procedure ModInit; External;
{$F-}

Procedure ModPlay(Str: String);
Var Dev, Mix, Stat, Pro, Loop: Integer;
Begin
	ModInit;
	Mix := 10000; Dev := 7; Pro := 10; Loop := 4;
	ModVolume (255,255,255,255);
	ModSetup ( Stat, Dev, Mix, Pro, Loop, Str );
End;

Procedure SetUpVirtual;
Begin
  GetMem (VirtScr,64000);
  Vaddr := seg (virtscr^);
End;

procedure flip(source,dest:Word);
begin
  asm
	 push    ds
	 mov     ax, [Dest]
    mov     es, ax
	 mov     ax, [Source]
    mov     ds, ax
	 xor     si, si
	 xor     di, di
    mov     cx, 32000
	 rep     movsw
    pop     ds
  end;
end;


Var i: byte;
	 Pall: Array[0..255,0..2] of Byte;

Begin
	FadeCurs;
	Randomize;
	If Check4Files<>'ALL' Then Begin
		Settext;
		Writeln(Check4Files + 'is missing...');
		Writeln('Program Halted...');
		Halt;
	End;
	ModPlay('Song.Dat');
	SetMcga;
	SetUpVirtual;
	for i:=0 to 255 do
		GetPal(i,Pall[i][0], Pall[i][1], Pall[i][2]);
	LoadPal('Palette.Dat');
	Readfile('Demo.Dat', Vaddr);
	flip(vaddr,vga);
	Delay(3000);
	Cls(0,Vga);
	for i:=0 to 255 do
		Pal(i,Pall[i][0], Pall[i][1], Pall[i][2]);
	MakeMovingStars;
	FadeOut;
	Do3DStarField;
	FadeOut;
	InitPlasma;
	FadeOut;
	DoCopperBars;
	Cls(0,Vga);
	MakeBlood;
	ModStop;
	FreeMem (VirtScr,64000);
	SetText;
	Writeln('XtaC Demo');
	Writeln('Milton Moura, 1996');
End.