Game Development Reference
In-Depth Information
short CADConvert::GetChannel(int index)
{
BYTE hb,lb,res;
int i;
short advalue;
//Write channel
_outp(baseaddress + 2, index);
//Wait for convert ready
i=0;
res=1;
while (res){
res = _inp(baseaddress + 2) & 0x80;
i++;
if (i>1000){
AfxMessageBox(”A/D card not ready. Timed out.”);
return -1;
}
}
//Start conversion
_outp(baseaddress + 1, 1);
//Wait for conversion to complete
i=0;
res=1;
while (res){
res = _inp(baseaddress + 2) & 0x80;
i++;
if (i>1000){
AfxMessageBox(”A/D card not ready. Timed out.”);
return -1;
}
}
//Read high and low bytes
hb = _inp(baseaddress + 1);
lb = _inp(baseaddress);
advalue =((short)hb << 4) + (lb>>4);
return advalue;
}
Search Nedrilad ::




Custom Search