home *** CD-ROM | disk | FTP | other *** search
- {**************************************************************************
-
- CMSPRD
- CMS Utilitys
-
- Date: 6/5/91
- Version: 1
-
- ***************************************************************************
-
- Copyright (c) 1991, Zackzon Labs.
-
- Author: Anthony Rumble
- ==========
- Addresses:
- ==========
- InterNet: c9106510@cc.newcastle.edu
- FIDONet: 3:713/802.3
- SIGNet: 28:2200/102.2
-
- Snail Mail:
- 32 Woolwich Rd.
- Hunters Hill, NSW, 2110
- Australia
-
- -------------------------------------------------------------------------
- HISTORY
- -------------------------------------------------------------------------
- 1.0 - Works fine so far
- *************************************************************************}
- unit cmsprg;
-
- interface
-
- uses dos, misc;
-
- const
- teststring = 'CMSDRV';
- GetVersion = 0;
- PlayMusic = 1;
- PauseMusic = 2;
- ResumeMusic = 3;
- StopMusic = 4;
- DisableBreak = 5;
-
- type
-
- header_data = array[1..6] of char;
-
- Var
- Regs : Registers;
- intp : pointer;
- LibInt : word;
- CMSf : file;
- CMS_SONG: pointer;
- ERR : word;
- Size : word;
- Status : word;
-
- function initialize:boolean;
- function CMS_Get_Version:word;
- function CMS_Play_Music(p:pointer):boolean;
- procedure CMS_Stop_Music;
- function CMS_Pause_Music:boolean;
- function CMS_Resume_Music:boolean;
- function CMS_Load_CMS(fn:string):pointer;
-
- implementation
-
- {****************************************************************************
- INITIALIZE
- ----------------------------------------------------------------------------
- Checks for the driver. If present will initialise it, and return TRUE
- else will return FALSE
- ****************************************************************************}
- function initialize:boolean;
- var
- Signature:string[6];
- x,w:word;
- p:^header_data;
- begin
- for w:=$80 to $BF do
- begin
- getintvec(w,intp);
-
- p := ptr(seg(intp^), $104);
-
- for x:= 1 to 6 do
- begin
- Signature[x] := p^[x];
- end;
- Signature[0] := #6;
- if Signature = TestString then
- begin
- LibInt:=w;
- initialize:=true;
- exit;
- end
- else initialize := FALSE;
- end;
- end;
- {****************************************************************************
- CMS_GET_VERSION
- ----------------------------------------------------------------------------
- Returns the Version Number HI(v) Major Version. LO(v) Minor Version
- ****************************************************************************}
- function CMS_Get_Version:word;
- begin
- Regs.bx:=GetVersion;
- INTR(LibInt, Regs);
- CMS_Get_Version:=regs.AX;
- end;
- {****************************************************************************
- CMS_PLAY_MUSIC
- ----------------------------------------------------------------------------
- Plays the music at the pointer.
- Will Return TRUE if OK. Else, FALSE if music is allready playing
- ****************************************************************************}
- function CMS_Play_Music(p:pointer):boolean;
- begin
-
- CMS_Play_Music:=true;
- Regs.ah:=PlayMusic;
- Regs.al:=1; {Play the song only once}
- Regs.ES:=seg(status);
- Regs.BX:=ofs(status);
-
- Regs.CX:=seg(p^);
-
- INTR(LibInt, Regs);
-
- case Regs.AX of
- 0:exit;
- 1:writeln('non-CMS File Structure');
- 2:writeln('wrong COMPOSEr version');
- end;
- CMS_Play_Music:=false;
- end;
- {****************************************************************************
- CMS_STOP_MUSIC
- ----------------------------------------------------------------------------
- Stops The currently Playing Music
- ****************************************************************************}
- procedure CMS_Stop_Music;
- begin
- Regs.ah:=StopMusic;
- INTR(LibInt, Regs);
- end;
- {****************************************************************************
- CMS_PAUSE_MUSIC
- ----------------------------------------------------------------------------
- Pauses The currently Playing Music
- Returns TRUE is No error. Else FALSE if There was no music
- ****************************************************************************}
- function CMS_Pause_Music:boolean;
- begin
- Regs.ax:=PauseMusic;
- INTR(LibInt, Regs);
- if Regs.AX=0 then CMS_Pause_Music:=TRUE else CMS_Pause_Music:=FALSE;
- end;
- {****************************************************************************
- CMS_RESUME_MUSIC
- ----------------------------------------------------------------------------
- Resumes The currently Paused Music
- Returns TRUE is No error. Else FALSE if There was no paused music
- ****************************************************************************}
- function CMS_Resume_Music:boolean;
- begin
- Regs.ah:=ResumeMusic;
- INTR(LibInt, Regs);
- if Regs.AX=0 then CMS_Resume_Music:=TRUE else CMS_Resume_Music:=FALSE;
- end;
- {****************************************************************************
- CMS_DISABLE_BREAK
- ----------------------------------------------------------------------------
- This procedure disables the CMS break function (CTRL-Keypad5)
- ****************************************************************************}
- procedure CMS_disable_break;
- begin
- Regs.ah:=DisableBreak;
- INTR(LibInt, Regs);
- end;
- {****************************************************************************
- CMS_LOAD_CMS
- ----------------------------------------------------------------------------
- Loads a CMS file
- fn:=the full path and file name. Inc .CMS if neads be
- Returns a Pointer to Play.
- ****************************************************************************}
- function CMS_Load_CMS(fn:string):pointer;
- var
- rslt, result:word;
- begin
- assign(CMSf, fn);
- {$I-}
- reset(CMSf,1);
- {$I+}
- err:=IORESULT;
- if err<>0 then
- begin
- writeln('Problem Loading ',fn);
- halt(1);
- end;
- size:=filesize(CMSf);
- rslt:=malloc(CMS_SONG, size);
- if rslt<>0 then
- begin
- writeln('Error Allocating Memory, Size=',size);
- halt(1);
- end;
- blockread(CMSf, CMS_SONG^, size, result);
- close(CMSf);
- CMS_Load_CMS:=CMS_SONG;
- end;
-
- end.
-