delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/27/20:00:32

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to ring tge bell?
Date: Wed, 27 Sep 2000 20:36:56 +0100
Organization: Customer of Energis Squared
Lines: 41
Message-ID: <gvi4tskv68samurki5qesncu616534e3q5@4ax.com>
References: <7e82tsc2jrko61qdim56cnehgbhkrbtqcv AT 4ax DOT com> <Pine DOT SUN DOT 3 DOT 91 DOT 1000927070649 DOT 26042C-100000 AT is>
NNTP-Posting-Host: modem-235.california.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: newsg4.svr.pol.co.uk 970083497 11039 62.137.56.235 (27 Sep 2000 19:38:17 GMT)
NNTP-Posting-Date: 27 Sep 2000 19:38:17 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> But please first test that the original libc version does have
> problems as reported in this thread, before you try the new version
> above.  Otherwise, we don't know that this change indeed fixes that
> problem.

ok, I managed to get access to an NT machine to do some testing.  The
patch I posted does not in fact fix the problem.  

Below is a description of the bug and a patch which fixes sound() to
work on NT.  This has been tested (on NT) but I would appreciate
someone with knowledge of PC hardware programming to look at it to
determine that nothing will get broken by the changes.

In an NT 'DOS box', the first call to sound() is ignored.  Subsequent
calls to sound() are honoured.  The effect persists for each DOS box
session, ie the second time a program is run, its first call to
sound() will work.  If the DOS box is closed and another is opened,
then again the first call to sound() will be ignored.

The patch I previously posted assumed that the suggestion to call
nosound() before sound() would fix the problem, it does not.

Here is a patch that causes sound() to behave on NT:

--- src/libc/pc_hw/sound/sound.c.original Wed Sep 27 11:52:52 2000
+++ src/libc/pc_hw/sound/sound.c	Wed Sep 27 11:55:34 2000
@@ -11,8 +11,11 @@
     return;
   }
   scale = 1193046 / freq;
+  
+  	/* Enable PC-speaker; do this first to work around a NT bug */
+  outportb(0x61, inportb(0x61) | 3);
+  
   outportb(0x43, 0xb6);
   outportb(0x42, scale & 0xff);
   outportb(0x42, scale >> 8);
-  outportb(0x61, inportb(0x61) | 3);
 }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019