PROGRAM XMSPlayer; {Test Player Just for You To Test the XMS-Object !}

USES CRT,FADE;     {Fade.TPU Is just a small Effect for the Text to Fade away}


{$F+}
{$L XMSOBJ.OBJ}    {The XMS-Object should be used is normaly set to $L+}
PROCEDURE _XMSFMPlayer; near; EXTERNAL;
PROCEDURE _StopXMSFM; near; EXTERNAL;
PROCEDURE _InitXMSFM; near; EXTERNAL;
{$F-}


type XMSFM = record
              Name   : string;
              Lenght : integer;
              OkeY   : boolean;
              Tune   : pointer;
              Buffer : pointer;
     end;

var Musik : XMSFM;


PROCEDURE LoadSong (VAR Test : XMSFM);
  VAR F : FILE;
  BEGIN
    ASSIGN (F,Test.Name);  {Here You can even put +(.xms) Then you don't need the Extension !}
    {$I-} RESET (F,1); {$I+}
    IF IORESULT <> 0
      THEN Test.OkeY := FALSE
      ELSE
        BEGIN
          Test.Lenght :=  FILESIZE (F);
          GETMEM (Test.Tune,Test.Lenght);
          GETMEM (Test.Buffer,1314);
          BLOCKREAD (F,Test.Tune^,Test.Lenght);
          Test.OkeY := TRUE;
          CLOSE (F)
        END
  END;

PROCEDURE ClearSong (VAR Test : XMSFM);  {IMPORTANT: YoU have to call these at }
  BEGIN                                  {the end of your Program to make sure }
    Test.OkeY := FALSE;                  {that the hole Buffer will be free again !}
    FREEMEM (Test.Tune,Test.Lenght);
    FREEMEM (Test.Buffer,1314);
    Test.Lenght := 0
  END;

var i : byte;


BEGIN
  IF PARAMCOUNT = 1
    THEN
      BEGIN
        Musik.Name := PARAMSTR (1);
        LoadSong (Musik);
        IF Musik.OkeY
          THEN
            BEGIN
              ClrScr;
              TextColor(LightRed);
              writeln(' บ  TEST-PlaYeR - AcTiVe NoW ! บ');
              TextColor(Red);
              Writeln('Here YoU Can Play with Your Fantasy !');
              TextColor(LightBlue);
              writeln(' ESC - For Ending !');
              asm
                 push   ds
                 push   es
                 les    di,Musik.Buffer
                 lds    si,Musik.Tune
                 xor    al,al           { IRQ-Modus it is used by _InitXMSFM ! }
                 call   _InitXMSFM
                 pop    es
                 pop    ds
              end;
              repeat until port[$60]=1;  {Just ESC-Key !}
              FadeOut;                   {The FadeOut Effect for the Text !}
              ResetTextMode;
              TextColor(Red);
              writeln('Coded by Madokan in 1996');
              TextColor(LightRed);
              writeln('ษออออออออออออออออออออออออออออออออออออออออออออออออป');
              writeln('บ            -=>   TEST-PlaYeR   <=-             บ');
              writeln('บ          ThiS LiTTle ShIt Is FreeWaRe          บ');
              writeln('บ                                                บ');
              writeln('บ   YoU CaN UsE It FoR FreE WiTh OuT An RuLeZ!   บ');
              writeln('บ     ThE FoRmaT WaS CreaTeD To ShoW YoU HoW     บ');
              writeln('บ            SmaLL A SouNd CoULD Be !            บ');
              writeln('ศออออออออออออออออออออออออออออออออออออออออออออออออผ');

              asm
                 call   _StopXMSFM   {Need to Stop Playing the Song !}
              end;

              ClearSong (Musik);
            END
    END;
END.
