home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcw_c.zip / SOUND.C < prev    next >
Text File  |  1990-01-16  |  1KB  |  39 lines

  1.  
  2. /************************************************************/
  3. /* Module Id.                     Sound.C                   */
  4. /* Author.                        Stan Milam.               */
  5. /* Date Written.                  08/11/88.                 */
  6. /*                                                          */
  7. /*           (c) Copyright 1989-90 by Stan Milam            */
  8. /*                                                          */
  9. /* Comments: Two functions here - one to create a specified */
  10. /* tone (sound()) and one to turn off the tone (nosound()). */
  11. /************************************************************/
  12.  
  13. #include "pcwproto.h"
  14.  
  15. #ifdef MSC
  16. #    include <conio.h>
  17. #else
  18. #    include <dos.h>
  19. #endif
  20.  
  21. #define SOUNDPORT 0x61
  22. #define TONEPORT  0x42
  23.  
  24. void _sound(unsigned freq) {
  25.  
  26.   short     i, j;
  27.  
  28.   freq = (unsigned) (1193182L / (long) freq);
  29.   i    = freq & 0x00ff;
  30.   j    = (freq & 0xff00) >> 8;
  31.   outportb(TONEPORT, i); outportb(TONEPORT, j);
  32.   outportb(SOUNDPORT, inportb(SOUNDPORT) | 0x3);
  33. }
  34.  
  35. void _nosound(void) {
  36.   outportb(SOUNDPORT, inportb(SOUNDPORT) & 0xfc);
  37. }
  38.  
  39.