sound.c 388 B

12345678910111213141516171819202122232425262728
  1. #include <bios.h>
  2. static int port_val = -1;
  3. sound(freq)
  4. unsigned freq; /* freq is in hertz */
  5. {
  6. if(port_val == -1 )
  7. port_val = inp(0x61);
  8. freq = 1193180L / freq;
  9. outp(0x61, port_val|3);
  10. outp(0x43, 0xb6);
  11. outp(0x42, freq&0xFF);
  12. outp(0x42, (freq>>8)&0xFF);
  13. }
  14. nosound()
  15. {
  16. if( port_val )
  17. outp(0x61, port_val);
  18. else
  19. outp(0x61, inp(0x61)&~3);
  20. }