Mail Archives: djgpp/2000/09/26/18:31:27
"Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> wrote:
> > Even so, can someone point me to the sources for nosound()?
>
> It's in <pc.h> ;-)
LOL. Ah!, so grepping the whole of /djgpp/src is no use. ;-)
Anyhow, I would say the NT fix should be simple. Maybe someone wants
to try this?...
Download and install djlsr203.zip
Edit the file \djgpp\src\libc\pc_hw\sound\sound.c
change:
int scale;
if (freq == 0)
{
outportb(0x61, inportb(0x61) & ~3);
return;
}
to:
int scale;
outportb(0x61, inportb(0x61) & ~3);
if (freq == 0)
{
return;
}
Recompile and merge with libc:
C:\djgpp\src\libc\pc_hw\sound>gcc -O2 -Wall -c sound.c
C:\djgpp\src\libc\pc_hw\sound>ar rvs /djgpp/lib/libc.a sound.o
r - sound.o
And test to see if the bug is fixed for NT.
[Note to Eli, is it really necessary to specify drive letter to ar?
If not then there is a redundant note in the FAQ about this.]
Here is a patch for the above code in case it tests ok without further
changes:
--- src/libc/pc_hw/sound/sound.c.original Sat Feb 25 22:19:34 1995
+++ src/libc/pc_hw/sound/sound.c Tue Sep 26 22:48:38 2000
@@ -5,14 +5,18 @@
sound(int freq)
{
int scale;
+
+ /* Always disable PC speaker first.
+ This is to work around an nt4 bug */
+ outportb(0x61, inportb(0x61) & ~3);
+
if (freq == 0)
- {
- outportb(0x61, inportb(0x61) & ~3);
return;
- }
+
scale = 1193046 / freq;
+
outportb(0x43, 0xb6);
outportb(0x42, scale & 0xff);
outportb(0x42, scale >> 8);
- outportb(0x61, inportb(0x61) | 3);
+ outportb(0x61, inportb(0x61) | 3); /* re-enable PC speaker */
}
- Raw text -