/* Function Tone for C. for compilers which has no this function or Sound, Delay and Nosound funcions from "C primer plus" by M.Waite, S.Prata and D.Martin. */ #include #define TIMERMODE 182 #define FREQSCALE 1190000L #define TIMESCALE 100L /* You can change it for your computer */ #define T_MODEPORT 67 #define FREQPORT 66 #define BEEPPORT 97 #define ON 79 tone(freq, time) int freq, time; { int hibyt, lobyt, port; long i, count, divisor; count = TIMESCALE * time; port = inp(BEEPPORT); if (freq > 0) { divisor = FREQSCALE / freq; lobyt = divisor % 256; hibyt = divisor / 256; outp(T_MODEPORT, TIMERMODE); outp(FREQPORT, lobyt); outp(FREQPORT, hibyt); outp(BEEPPORT, ON); } for (i = 0;i < count;i++) ; outp(BEEPPORT, port); }