home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 215 / DDJ9302.ZIP / DFPP01.ZIP / SPEAKER.CPP < prev    next >
C/C++ Source or Header  |  1992-11-21  |  559b  |  23 lines

  1. // -------- speaker.cpp
  2.  
  3. #include <dos.h>
  4. #include <conio.h>
  5. #include "speaker.h"
  6. #include "dflatdef.h"
  7.  
  8. // -------- sound a tone
  9. void Speaker::Beep()
  10. {
  11.     outp(0x43, 0xb6);               // program the frequency
  12.     outp(0x42, (int) (COUNT % 256));
  13.     outp(0x42, (int) (COUNT / 256));
  14.     outp(0x61, inp(0x61) | 3);      // start the sound
  15.     // -------- wait two clock ticks
  16.     const int far *clk = (int far *) MK_FP(0x40,0x6c);
  17.     int then = *clk+2;
  18.     while (*clk < then)
  19.         ;
  20.     outp(0x61, inp(0x61) & ~3);     // stop the sound
  21. }
  22.  
  23.