home *** CD-ROM | disk | FTP | other *** search
- // DSP.CPP (Visual C++ 1.00) -- Plays sound on DSP in "direct 8 bit DAC mode"
- // Needs Soundblaster-compatible card at 0220h
-
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
-
- void Play() {
- printf("Press a key to stop...\n");
- while (_inp(0x022C) & 0x80); // ready to recieve command?
- _outp(0x022C, 0xD1); // speaker on
- while(!_kbhit()) {
- static int i;
- while (_inp(0x022C) & 0x80); // ready to recieve command?
- _outp(0x022C, 0x10); // direct 8 bit DAC mode
- while (_inp(0x022C) & 0x80); // ready to recieve data?
- _outp(0x022C, i); // send data
- i += 4;
- }
- _bdos(0x0C, 0, 0); // throw away the key
- }
-
- int main() {
- _bdos(0x0D, 0, 0); // SOS (save our source)
- _outp(0x0226, 1); // reset = 1
- for (int i = 0; i < 3 * 2; i++) {
- _inp(0x61); // wait 3 us
- }
- _outp(0x0226, 0); // reset = 0
- for (i = 0; i < 100; i++) {
- if (_inp(0x022E) & 0x80) { // data available?
- if (_inp(0x022A) == 0xAA) { // DSP ready?
- Play();
- return 0;
- } else {
- printf("DSP reset error\n");
- return 1;
- }
- }
- }
- printf("DSP not found at 0220h\n");
- return 1;
- }
-