1 ///////////////////////////////////////////////////////////////////////////
\r
3 // SDL_CheckSB() - Checks to see if a SoundBlaster resides at a
\r
4 // particular I/O location
\r
6 ///////////////////////////////////////////////////////////////////////////
\r
8 SDL_CheckSB(int port)
\r
12 sbLocation = port << 4; // Initialize stuff for later use
\r
14 sbOut(sbReset,true); // Reset the SoundBlaster DSP
\r
15 asm mov dx,0x388 // Wait >4usec
\r
26 sbOut(sbReset,false); // Turn off sb DSP reset
\r
27 asm mov dx,0x388 // Wait >100usec
\r
33 for (i = 0;i < 100;i++)
\r
35 if (sbIn(sbDataAvail) & 0x80) // If data is available...
\r
37 if (sbIn(sbReadData) == 0xaa) // If it matches correct value
\r
41 sbLocation = -1; // Otherwise not a SoundBlaster
\r
46 sbLocation = -1; // Retry count exceeded - fail
\r
50 ///////////////////////////////////////////////////////////////////////////
\r
52 // Checks to see if a SoundBlaster is in the system. If the port passed is
\r
53 // -1, then it scans through all possible I/O locations. If the port
\r
54 // passed is 0, then it uses the default (2). If the port is >0, then
\r
55 // it just passes it directly to SDL_CheckSB()
\r
57 ///////////////////////////////////////////////////////////////////////////
\r
59 SDL_DetectSoundBlaster(int port)
\r
63 if (port == 0) // If user specifies default, use 2
\r
67 if (SDL_CheckSB(2)) // Check default before scanning
\r
70 if (SDL_CheckSB(4)) // Check other SB Pro location before scan
\r
73 for (i = 1;i <= 6;i++) // Scan through possible SB locations
\r
75 if ((i == 2) || (i == 4))
\r
78 if (SDL_CheckSB(i)) // If found at this address,
\r
79 return(true); // return success
\r
81 return(false); // All addresses failed, return failure
\r
84 return(SDL_CheckSB(port)); // User specified address or default
\r