home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 25 / CD_ASCQ_25_1095.iso / dos / prg / dwstk200 / findsb.pas < prev    next >
Pascal/Delphi Source File  |  1995-06-26  |  4KB  |  156 lines

  1. (******************************************************************************
  2. File:                          findsb.pas
  3. Version:                     2.00
  4. Tab stops:                 every 2 columns
  5. Project:                     FINDSB utility
  6. Copyright:                 1994-1995 DiamondWare, Ltd.    All rights reserved.
  7. Written:                     Keith Weiner & Erik Lorenzen
  8. Pascal Conversion: David A. Johndrow
  9. Purpose:           Example code to autodetect and print out the sound hardware
  10. History:                     94/10/21 KW Started
  11.                                      94/11/11 DJ Converted
  12.                                      95/02/02 EL Cleaned up & Finalized
  13.                                      95/03/22 EL Finalized for 1.01
  14.                                      95/04/11 EL Finalized for 1.02
  15.                                      95/06/06 EL Finalized for 1.03 (no changes)
  16.                                      95/06/06 EL Finalized for 2.00 (no changes)
  17. ******************************************************************************)
  18.  
  19.  
  20.  
  21. Program FindSb;
  22.  
  23. uses crt, err, dws;
  24.  
  25.  
  26.  
  27. Var
  28.     ver:        word;
  29.     dov:        dws_DOPTR;
  30.     dres:     dws_DRPTR;
  31.  
  32. Function HVal(i: word): char;
  33. begin
  34.     if (i < 10) then
  35.     begin
  36.         HVal := chr(i+48);
  37.     end
  38.     else
  39.     begin
  40.         HVal := chr(i+55);
  41.     end;
  42. end;
  43.  
  44.  
  45. Function HexStr(d: word): string;
  46. Var
  47.     s: string;
  48.  
  49. begin
  50.     s := '    ';
  51.  
  52.     s[4] := HVal(d mod 16);
  53.     s[3] := HVal((d div 16) mod 16);
  54.     s[2] := HVal((d div 256) mod 16);
  55.     s[1] := HVal((d div 4096) mod 16);
  56.  
  57.     while (s[1] = '0') and (length(s) > 1) do
  58.     begin
  59.         Delete(s,1,1);
  60.     end;
  61.  
  62.     HexStr := s;
  63. end;
  64.  
  65.  
  66.  
  67. begin
  68.     new(dov);
  69.     new(dres);
  70.  
  71.     writeln;
  72.     writeln('FINDSB 2.00 is Copyright 1994-95, DiamondWare, Ltd.');
  73.     writeln('All rights reserved.');
  74.     writeln;
  75.     writeln;
  76.  
  77.     (*
  78.      . We need to set every field to -1 (65635) in dws_DETECTOVERRIDES struct;
  79.      . this tells the STK to autodetect everything.  Any other value
  80.      . overrides the autodetect routine, and will be accepted on
  81.      . faith, though the STK will verify it if possible.
  82.     *)
  83.     dov^.baseport := 65535;
  84.     dov^.digdma     := 65535;
  85.     dov^.digirq     := 65535;
  86.  
  87.     if (dws_DetectHardWare(dov, dres) = 0) then
  88.     begin
  89.         err_Display;
  90.         halt(65535);
  91.     end;
  92.  
  93.  
  94.     if (((dres^.capability and dws_capability_FM) = dws_capability_FM) or
  95.             ((dres^.baseport <> 904) and (dres^.baseport <> 65535))) then
  96.     begin
  97.         writeln('Base port is ',HexStr(dres^.baseport),' hex');
  98.         writeln('');
  99.  
  100.         if (dres^.mixtyp <> 1) then
  101.         begin
  102.             writeln('The sound hardware supports mixing.');
  103.             writeln('');
  104.         end
  105.         else
  106.         begin
  107.             writeln('Mixing will be done in software.');
  108.             writeln('');
  109.         end;
  110.  
  111.         if ((dres^.capability and dws_capability_FM) = dws_capability_FM) then
  112.         begin
  113.             writeln('The sound hardware supports FM music playback.');
  114.             writeln;
  115.         end
  116.         else
  117.         begin
  118.             writeln('Support for FM music playback not found.');
  119.             writeln('');
  120.         end;
  121.  
  122.         if ((dres^.capability and dws_capability_DIG) = dws_capability_DIG) then
  123.         begin
  124.             (* If we got here dws_DetectHardWare got PORT, IRQ, & DMA *)
  125.             writeln('The sound hardware supports digitized sound playback.');
  126.             writeln('The sound hardware uses DMA channel ',dres^.digdma,' and IRQ level ',dres^.digirq,'.');
  127.             writeln;
  128.         end
  129.         else if ((dres^.baseport <> 904) and (dres^.baseport <> 65535)) then
  130.         begin
  131.             (*
  132.              . If dres.baseport isn't either 388hex, or -1, then it's a valid
  133.              . baseport.    So if we got here, then we didn't find either IRQ
  134.              . level, and/or DMA channel.  In order to play digitized sounds,
  135.              . we need these settings as well.    In your application, you should
  136.              . ask the user.
  137.             *)
  138.             writeln('The sound hardware supports digitized sound playback,');
  139.             writeln('but we could not find the DMA channel and/or IRQ level.');
  140.  
  141.         end
  142.         else
  143.         begin
  144.             writeln('Support for digitized playback not found.');
  145.             writeln('');
  146.         end;
  147.  
  148.     end
  149.     else
  150.     begin
  151.         writeln('No sound hardware detected.');
  152.         writeln;
  153.     end;
  154.  
  155. end.
  156.