'=========================================================================== ' Subject: SB/ADLIB DETECTION ROUTINES Date: 03-20-97 (04:46) ' Author: Jesse Dorland Code: QB, QBasic, PDS ' Origin: comp.lang.basic.misc Packet: SOUND.ABC '=========================================================================== ' I've come across some routines (don't remember exactly where I got either of 'them) to detect SoundBlaster and Adlib cards. They return a -1 if a 'compatible card exists, 0 if not: ' ' 'Adlib detection ' ' FUNCTION Adlib% OUT &H388, &H4: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &H60: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT OUT &H388, &H4: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &H80: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT Astat1 = INP(&H388) OUT &H388, &H2: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &HFF: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT OUT &H388, &H4: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &H21: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT Astat2 = INP(&H388) OUT &H388, &H4: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &H60: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT OUT &H388, &H4: FOR A7 = 1 TO 6: A11 = INP(&H388): NEXT OUT &H389, &H80: FOR A7 = 1 TO 35: A11 = INP(&H388): NEXT Ares1 = Astat1 AND &HE0: Ares2 = Astat2 AND &HE0 Adlib% = 0: IF Ares1 = 0 AND Ares2 = 192 THEN Adlib% = -1 END FUNCTION ' ' 'Sound Blaster detection ' ' FUNCTION Blaster% CALL InternalWriteReg(&H4, &H60) 'Reset both timers CALL InternalWriteReg(&H4, &H80) stat1 = INP(&H388) 'Store result CALL InternalWriteReg(&H2, &HFF) CALL InternalWriteReg(&H4, &H21) CALL InternalPause(.08) 'Wait 80msecs stat2 = INP(&H388) 'Store result CALL InternalWriteReg(&H4, &H60) 'Reset both timers CALL InternalWriteReg(&H4, &H80) IF (stat1 AND &HE0) = &H0 THEN IF (stat2 AND &HE0) = &HC0 THEN found% = -1 END IF END IF Blaster% = found% END FUNCTION 'I recently learned a way to tell which type of Sound Blaster is installed (or 'which type the sound card is compatible with) using the BLASTER environment 'variable. The "T" setting holds the type of sound card installed. The values 'for "T" are (thanks to Thomas Gohel for this info): 1 - Sound Blaster 1.0/1.5 (Mono sound) 2 - Sound Blaster Pro (Stereo sound) 3 - Sound Blaster 2.0/2.5 (Mono sound) 4 - Sound Blaster Pro 3.0/Pro 4.0 (Stereo sound) 5 - Sound Blaster Pro Microchannel (Stereo sound) 6 - Sound Blaster 16/16ASP/AWE32 (Stereo sound) 'So, to get the type, you could use this code: BlastEnv$ = ENVIRON$("BLASTER") CardType% = VAL(MID$(BlastEnv$, INSTR(BlastEnv$, "T") + 1, 1)) 'Hope all my relentless babbling is put to good use by someone. :-)