home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / STK100.ZIP / FINDSB.BAS < prev    next >
BASIC Source File  |  1995-02-02  |  4KB  |  132 lines

  1. '******************************************************************************
  2. 'File:      findsb.bas
  3. 'Tab stops: every 2 collumns
  4. 'Project:   FINDSB utility
  5. 'Copyright: 1994 DiamondWare, Ltd.  All rights reserved.
  6. 'Written:   Erik Lorenzen & Don Lemons
  7. 'Purpose:   Example code to autodetect and print out the sound hardware
  8. 'History:   KW 10/21/94 Started findsb.c
  9. '           DL 11/12/94 translated to BASIC
  10. '           EL 02/02/95 Cleaned up & Finalized
  11. '******************************************************************************
  12.  
  13.  
  14.  
  15. '$INCLUDE: 'dws.bi'
  16.  
  17.  
  18.  
  19. 'DECLARE VARIABLES
  20.     COMMON SHARED dov     AS dwsDETECTOVERRIDES
  21.     COMMON SHARED dres    AS dwsDETECTRESULTS
  22.     COMMON SHARED ideal AS dwsIDEAL
  23.  
  24.  
  25.  
  26. SUB DisplayError(errornum)
  27.     SELECT CASE errornum
  28.  
  29.         'Note that only those errors which could occur when calling
  30.         'dws_DetectHardWare are checked for.
  31.  
  32.         CASE dwsALREADYINITTED
  33.             'If we get here, it means you've called dws_Init() already.  Calling
  34.             'dws_DetectHardWare() at this point would cause zillions of
  35.             'problems if we let the call through.
  36.             PRINT "The STK was already initialized"
  37.  
  38.         CASE dwsDetectHardwareUNSTABLESYSTEM
  39.             'Please report it to DiamondWare if you get here!
  40.             '
  41.             'Ideally, you would disable control-C here, so that the user can't
  42.             'hit control-alt-delete, causing SmartDrive to flush its (possibly
  43.             'currupt) buffers.
  44.             PRINT "The system is unstable!"
  45.             PRINT "Please power down now!"
  46.  
  47.             AGAIN:
  48.             GOTO AGAIN
  49.  
  50.         'The following three errors are USER/PROGRAMMER errors.  You forgot
  51.         'to fill the cardtyp struct full of -1's (except in those fields
  52.         'you intended to override, or the user (upon the unlikly event that
  53.         'the STK was unable to find a card) gave you a bad overide value.
  54.  
  55.         CASE dwsDetectHardwareBADBASEPORT
  56.             'You set dov.baseport to a bad value, or
  57.             'didn't fill it with a -1.
  58.             PRINT "Bad port address"
  59.  
  60.         CASE dwsDetectHardwareBADDMA
  61.             'You set dov.digdma to a bad value, or
  62.             'didn't fill it with a -1.
  63.             PRINT "Bad DMA channel"
  64.  
  65.         CASE dwsDetectHardwareBADIRQ
  66.             'You set dov.digirq to a bad value, or
  67.             'didn't fill it with a -1.
  68.             PRINT "Bad IRQ level"
  69.  
  70.         CASE ELSE
  71.             'This should never occur and probably will not affect sound
  72.             'play(?). If it happens please contact DiamondWare.
  73.             PRINT "I'm confused!  Where am I?  HOW DID I GET HERE????"
  74.             PRINT "The ERROR number is:";errornum
  75.  
  76.     END SELECT
  77.  
  78. END SUB
  79.  
  80.  
  81.  
  82. 'START OF MAIN
  83.  
  84.     PRINT
  85.     PRINT "FINDSB is Copyright 1994, DiamondWare, Ltd."
  86.     PRINT "All rights reserved."
  87.     PRINT : PRINT : PRINT
  88.  
  89.     'We need to set every field to -1 in dws_DETECTOVERRIDES struct; this
  90.     'tells the STK to autodetect everything.  Any other value
  91.     'overrides the autodetect routine, and will be accepted on
  92.     'faith, though the STK will verify it if possible.
  93.  
  94.     dov.baseport = -1
  95.     dov.digdma     = -1
  96.     dov.digirq     = -1
  97.  
  98.     IF DWSDetectHardWare(dov, dres) = 0 THEN
  99.         errnum = dwsErrNo
  100.         DisplayError(errnum)
  101.     END IF
  102.  
  103.     IF (dres.capability AND dwscapabilityFM) = dwscapabilityFM THEN
  104.  
  105.         PRINT "Base port is ";HEX$(dres.baseport);" hex."
  106.         PRINT
  107.  
  108.         IF dres.mixtyp = 1 THEN
  109.             PRINT "Mixing will be done in software."
  110.             PRINT
  111.         ELSE
  112.             PRINT "The sound hardware supports mixing."
  113.             PRINT
  114.         ENDIF
  115.  
  116.         IF (dres.capability AND dwscapabilityFM) = dwscapabilityFM THEN
  117.             PRINT "The sound hardware supports FM music playback."
  118.             PRINT
  119.         END IF
  120.  
  121.         IF (dres.capability AND dwscapabilityDIG) = dwscapabilityDIG THEN
  122.             PRINT "The sound hardware supports digitized sound playback."
  123.             PRINT "The sound hardware uses DMA channel";dres.digdma;"and IRQ level";dres.digirq;"."
  124.             PRINT
  125.         END IF
  126.  
  127.     ELSE
  128.         PRINT "No sound hardware detected."
  129.         PRINT
  130.     ENDIF
  131. END
  132.