home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / pc_hw / sound / sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-25  |  363 b   |  19 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <pc.h>
  3.  
  4. void
  5. sound(int freq)
  6. {
  7.   int scale;
  8.   if (freq == 0)
  9.   {
  10.     outportb(0x61, inportb(0x61) & ~3);
  11.     return;
  12.   }
  13.   scale = 1193046 / freq;
  14.   outportb(0x43, 0xb6);
  15.   outportb(0x42, scale & 0xff);
  16.   outportb(0x42, scale >> 8);
  17.   outportb(0x61, inportb(0x61) | 3);
  18. }
  19.