home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sound / sbutil / source.exe / SBVOX.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1991-04-25  |  7.1 KB  |  244 lines

  1. {**************************************************************************
  2.  
  3.                                SBVOX
  4.                        SoundBlaster VOC Utilitys
  5.  
  6.                              Date: 4/4/91
  7.                               Version: 1
  8.  
  9. ***************************************************************************
  10.  
  11.                    Copyright (c) 1991, Zackzon Labs.
  12.  
  13.                        Author: Anthony Rumble
  14.  
  15. ==========
  16. Addresses:
  17. ==========
  18. InterNet: c9106510@cc.newcastle.edu
  19. SIGNet: 28:2200/108
  20.  
  21. Snail Mail:
  22.  32 Woolwich Rd.
  23.  Hunters Hill, NSW, 2110
  24.  Australia
  25.  
  26. -------------------------------------------------------------------------
  27.                               HISTORY
  28. -------------------------------------------------------------------------
  29. 1.0 - Works fine so far
  30. *************************************************************************}
  31. unit sbvox;
  32.  
  33. interface
  34.  
  35. uses misc;
  36.  
  37. const
  38.  GET_VERSION_NUM     =  0;
  39.  SET_BASE_IO_ADDX    =  1;
  40.  SET_INTERRUPT_NUM   =  2;
  41.  INITIAL_DRIVER      =  3;
  42.  ON_OFF_SPEAKER      =  4;
  43.  SET_STATUS_ADDX     =  5;
  44.  OUTPUT_VOICE        =  6;
  45.  INPUT_VOICE         =  7;
  46.  TERMINATE_PROCESS   =  8;
  47.  UNINSTALL_DRIVER    =  9;
  48.  PAUSE_VOICE         = 10;
  49.  CONTINUE_VOICE      = 11;
  50.  BREAK_LOOP          = 12;
  51.  SET_USER_FUNCTION   = 13;
  52.  
  53. var
  54.  _voice_drv:pointer;
  55.  x:integer;
  56.  err:integer;
  57.  fVOICE:file;
  58.  size:word;
  59.  result:word;
  60.  exitsave:pointer;
  61.  rslt:word;
  62.  
  63. function vox_get_version:word;
  64. function vox_initial:integer;
  65. procedure vox_status_addx(p:pointer);
  66. procedure vox_output(p:pointer);
  67. procedure vox_terminate;
  68. function vox_pause:integer;
  69. function vox_continue:integer;
  70. function load_voc(fname:string):pointer;
  71.  
  72. implementation
  73.  
  74. {***************************************************************************
  75.                           VOX_GET_VERSION
  76. ---------------------------------------------------------------------------
  77. HI(vox_get_version) = Major Version Number
  78. LO(vox_get_version) = Minor Version Number
  79. ***************************************************************************}
  80. function vox_get_version:word; assembler;
  81. asm
  82.        MOV    BX,GET_VERSION_NUM
  83.        CALL   _voice_drv
  84. end;
  85. {***************************************************************************
  86.                              VOX_INITIAL
  87. ---------------------------------------------------------------------------
  88. Initialises the driver.
  89.  
  90. Returns 0: Successfully initialise
  91.         1: Voice Card Fails
  92.         2: I/O read/write fails
  93.         3: Interupt for DMA fails
  94. ***************************************************************************}
  95. function vox_initial:integer; assembler;
  96. asm
  97.        MOV    BX,INITIAL_DRIVER
  98.        CALL   _voice_drv
  99. end;
  100. {***************************************************************************
  101.                              VOX_STATUS_ADDX
  102. ---------------------------------------------------------------------------
  103. vox_status_addx(pointer) Pointer must point to a Global Word
  104.  
  105. The soundblaster routines will update this global word
  106.  
  107. eg/
  108.  
  109.  vox_status_addx(@status);
  110.  
  111. ***************************************************************************}
  112. procedure vox_status_addx(p:pointer); assembler;
  113. asm
  114.        PUSH   ES
  115.        PUSH   DI
  116.  
  117.        LES    DI,p
  118.        MOV    BX,SET_STATUS_ADDX
  119.        CALL   _voice_drv
  120.  
  121.        POP    DI
  122.        POP    ES
  123. end;
  124. {***************************************************************************
  125.                              VOX_OUTPUT
  126. ---------------------------------------------------------------------------
  127. pointer must point to  the first voice data block in the buffer
  128. ***************************************************************************}
  129. procedure vox_output(p:pointer); assembler;
  130. asm
  131.        PUSH   ES
  132.        PUSH   DI
  133.  
  134.        MOV    BX,OUTPUT_VOICE
  135.  
  136.        LES    DI,p
  137.        CALL   _voice_drv
  138.  
  139.        POP    DI
  140.        POP    ES
  141. end;
  142. {***************************************************************************
  143.                              VOX_TERMINATE
  144. ----------------------------------------------------------------------------
  145. Terminates any voice input/output and sets the status variable to zero
  146. ***************************************************************************}
  147. procedure vox_terminate; assembler;
  148. asm
  149.        MOV    BX,TERMINATE_PROCESS
  150.        CALL   _voice_drv
  151. end;
  152. {***************************************************************************
  153.                              VOX_PAUSE
  154. ----------------------------------------------------------------------------
  155. Returns 0: Succesfull
  156.         1: Voice output not in process
  157. ***************************************************************************}
  158. function vox_pause:integer; assembler;
  159. asm
  160.        MOV    BX,PAUSE_VOICE
  161.        CALL   _voice_drv
  162. end;
  163. {***************************************************************************
  164.                              VOX_CONTINUE
  165. ----------------------------------------------------------------------------
  166. Returns 0: Succesfull
  167.         1: No voice to continue
  168. ***************************************************************************}
  169. function vox_continue:integer; assembler;
  170. asm
  171.        MOV    BX,CONTINUE_VOICE
  172.        CALL   _voice_drv
  173. end;
  174. {***************************************************************************
  175.                               LOAD_VOC
  176. ---------------------------------------------------------------------------
  177. Given a filename, will allocate memory and load into it,
  178. returning a pointer to the start of the data
  179. ***************************************************************************}
  180. function load_voc(fname:string):pointer;
  181. var
  182.  tmp_ptr:pointer;
  183.  offset:^word;
  184. begin
  185.  assign(fVOICE, fname);
  186.  {$I-}
  187.  reset(fVOICE,1);
  188.  {$I+}
  189.  err:=IORESULT;
  190.  if err<>0 then
  191.  begin
  192.   writeln('Trouble loading ',fname);
  193.   halt(1);
  194.  end;
  195.  size:=filesize(fVOICE);
  196.  rslt:=malloc(tmp_ptr, size);
  197.  if rslt<>0 then
  198.  begin
  199.   writeln('Error Allocating Memory');
  200.   halt(1);
  201.  end;
  202.  blockread(fVOICE, tmp_ptr^, size, result);
  203.  close(fVOICE);
  204.  offset:=ptr(seg(tmp_ptr^), ofs(tmp_ptr^)+$14);
  205.  tmp_ptr:=ptr(seg(tmp_ptr^), ofs(tmp_ptr^)+offset^);
  206.  load_voc:=tmp_ptr;
  207. end;
  208. {***************************************************************************
  209.                              EXIT_PROC
  210. ***************************************************************************}
  211. {$F+}
  212. procedure exit_proc;
  213. begin
  214.  exitproc:=exitsave;
  215.  rslt:=dalloc(_voice_drv);
  216. end;
  217. {$F-}
  218. {***************************************************************************
  219.                              AUTO_SETUP
  220. ***************************************************************************}
  221. begin
  222.  assign(fVOICE, 'CT-VOICE.DRV');
  223.  {$I-}
  224.  reset(fVOICE,1);
  225.  {$I+}
  226.  err:=IORESULT;
  227.  if err<>0 then
  228.  begin
  229.   writeln('Trouble loading CT-VOICE.DRV');
  230.   halt(1);
  231.  end;
  232.  size:=filesize(fVOICE);
  233.  rslt:=malloc(_voice_drv, size);
  234.  if rslt<>0 then
  235.  begin
  236.   writeln('Error Allocating Memory');
  237.   halt(1);
  238.  end;
  239. { new(drv); }
  240.  blockread(fVOICE, _voice_drv^, size, result);
  241.  close(fVOICE);
  242.  exitsave:=exitproc;         {Save exitprocs....}
  243.  exitproc:=@exit_proc;
  244. end.