home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / SOUND.CPP < prev    next >
Text File  |  1992-05-30  |  603b  |  29 lines

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