home *** CD-ROM | disk | FTP | other *** search
/ PC Action 1998 January / PCA0198.ISO / MENUE / POSTFACH / 98012060.TXT < prev    next >
Text File  |  1997-11-25  |  4KB  |  185 lines

  1. 0
  2. Soundblaster-Erkennung, und ZusΣtze:
  3. Der Zauberleerling
  4. Listings
  5. {Variablen--------------------------------------
  6. -----------------------------}
  7.  
  8. Type  Tickarray   = array[1..5] of byte;
  9.  
  10. var   BasePort    : integer;
  11.       Blastername : String;
  12.       DSPVersion  : string[4];
  13.       LFSuccess   : Boolean;
  14.  
  15. {Prozeduren-------------------------------------
  16. -----------------------------}
  17.  
  18. procedure GetTicks (VAR Ticks: Tickarray);
  19. begin
  20. Inline($1E/$31/$C0/$8E/$D8/$BE/$6C/$04/$C4/$7E/<
  21. TICKS/$FC/$AB/$FA/$A4/$A5/$FB/$1F)
  22. end;
  23.  
  24. function ConvertTicks (Ticks: TickArray): 
  25. longint;
  26. begin
  27.   ConvertTicks := Round(((Ticks[5]*256.0) + 
  28. Ticks[4])*256 + Ticks[3]);
  29. end;
  30.  
  31. Procedure Delay(Ticks: Longint); { 1 Tick ist 
  32. ungefähr 1/20 sek }
  33. var ticked : tickarray; temp   : longint;
  34. begin Getticks(Ticked); 
  35. temp:=ConvertTicks(Ticked); repeat 
  36. Getticks(Ticked);
  37. until Convertticks(Ticked)-temp >= Ticks; end;
  38.  
  39. function sbfind:integer;
  40. var   Basis, MaxPort, n,n2 : word;
  41. const TestCount=15; TestCount2=40;
  42. begin
  43. Basis:=$210; MaxPort:=$260; n:=TestCount;
  44. while n<=MaxPort do
  45.  begin
  46.   port[Basis+$6]:=1; port[Basis+$6]:=0; 
  47. n2:=TestCount2;
  48.   while (n2>0) and (port[Basis+$e] and 128=0) do 
  49. dec(n2); 
  50.   while (n2>0) and (port[Basis+$e] and 128=0) do 
  51. dec(n2);
  52.   if (n2=0) or (port[Basis+$a]<>$aa) then dec(n) 
  53. else
  54.     begin
  55.      sbfind:=Basis;
  56.      exit;
  57.     end;
  58.       Basis:=Basis+$10;
  59.    end;
  60.   sbfind:=-1;
  61. end;
  62.  
  63. Procedure ResetDSP; Assembler;
  64. asm
  65.   mov LFSuccess, False
  66.   mov dx, BasePort;
  67.   add dl, 6
  68.   mov al, 1
  69.   out dx, al
  70.   sub al, al
  71. @Delay:
  72.   dec al
  73.   jnz @Delay
  74.   out dx, al
  75.   sub cx, cx
  76. @Empty:
  77.   mov dx, BasePort
  78.   add dl, 0Eh
  79.   in  al, dx
  80.   or  al, al
  81.   jns @Nextattempt
  82.   sub dl, 4
  83.   in  al, dx
  84.   cmp al, 0AAh
  85.   mov LFSuccess, True
  86.   je  @Finish
  87. @Nextattempt:
  88.   Loop @Empty
  89. @Finish:
  90. end;
  91.  
  92. function ReadFromDSP : Byte;
  93. begin
  94. asm
  95.   mov dx, BasePort;
  96.   add dl, 0Eh
  97. @Busy:
  98.   in  al, dx
  99.   or  al, al
  100.   jns @Busy
  101.   sub dl, 4
  102.   in  al, dx
  103.   mov @Result, al
  104. end;
  105. end;
  106.  
  107. Procedure WriteToDSP( ToWrite : Byte ); 
  108. assembler;
  109. asm
  110.   mov dx, BasePort;
  111.   add dl, 0Ch
  112. @Busy:
  113.   in  al, dx
  114.   or  al, al
  115.   js  @Busy
  116.   mov al, ToWrite
  117.   out dx, al
  118. end;
  119.  
  120. Procedure SetSpeaker( On : Boolean );
  121. begin
  122. If On then WriteToDSP($D1) else WriteToDSP($D3);
  123. end;
  124.  
  125. Procedure GetBlaster;
  126. var DSPV1, DSPV2 : byte;
  127. begin
  128. ResetDSP;
  129. WriteToDSP($E1);
  130. DSPV1:=ReadFromDSP;
  131. DSPV2:=ReadFromDSP;
  132. str(dspv1,DSPVersion);
  133. str(dspv2,Blastername);
  134. DSPVersion:=DSPVersion+'.';
  135. if Dspv2 < 10 then 
  136. DSPVersion:=DSPVersion+'0'+Blastername else 
  137. DSPVersion:=DSPVersion+Blastername;
  138. If DSPV1 = 1 then BlasterName := 'Sound-Blaster 
  139. 1.5'else
  140. If DSPV1 = 2 then
  141.  begin
  142.   if DSPV2 > 0 then BlasterName := 
  143. 'Sound-Blaster 2.0' else
  144.                     BlasterName := 
  145. 'Sound-Blaster 1.5';
  146.  end;
  147. If DSPV1 = 3 then
  148.  begin
  149.   if port[$388] = $06 then BlasterName := 
  150. 'Sound-Blaster Pro 1.0' else
  151.   BlasterName := 'Sound-Blaster Pro 2.0';
  152.  end else
  153. If DSPV1 = 4 then BlasterName := 'Sound-Blaster 
  154. 16' else
  155. BlasterName := 'Keine zum Programm kompatible 
  156. Soundkarte gefunden.';
  157. end;
  158.  
  159. Procedure SetTimeConstant(Channels : byte; 
  160. SamplingRate : Word);
  161. var temp : longint;
  162. begin
  163. temp:=65536-(256000000 div (Channels * 
  164. SamplingRate));
  165. WriteToDSP($40);
  166. WriteToDSP(temp);
  167. end;
  168.  
  169. {Programm---------------------------------------
  170. -----------------------------}
  171.  
  172. begin
  173. BasePort:=SbFind;
  174. if BasePort <> -1 then Getblaster
  175. else
  176. begin
  177. Blastername:='Keine Soundkarte gefunden';
  178. DSPVersion :='-';
  179. end;
  180. Writeln(BlasterName);
  181. Writeln(DSPVersion);
  182. Setspeaker(True);
  183. Setspeaker(False);
  184. end.
  185.