LIBS/WAVPLAV/SB.CPP
2021-09-08 21:26:43 +02:00

58 lines
916 B
C++

#include <dos.h>
int SBDetect(void);
void SBSendByte(unsigned char b);
/*
Soporte de Sound Blaster
*/
unsigned BPORT = 0x210,
XPORT = 0x216,
WPORT = 0x21C,
RPORT = 0x21A,
APORT = 0x21E;
char READY = 0xAA;
int SBDetect(void)
{
char Status,Ct;
Status = 0;
while (Status!=READY && BPORT<0x270)
{
outportb(XPORT,1);
outportb(XPORT,0);
Ct = 0;
while (Status!=READY && Ct<100)
{
Status = inportb(RPORT);
Ct++;
};
if (Status!=READY)
{
BPORT += 0x10;
XPORT += 0x10;
WPORT += 0x10;
RPORT += 0x10;
APORT += 0x10;
}
}
if (BPORT!=0x270)
{
while ((inport(WPORT) & 128) != 0);
outportb(WPORT,0xD1);
return(0);
}
else return(-1);
}
void SBSendByte(unsigned char b)
{
while ((inport(WPORT) & 128) != 0);
outportb(WPORT,0x10);
while ((inport(WPORT) & 128) != 0);
outportb(WPORT,b);
}