delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/11/20:34:03

From: Lars Erdmann <lars DOT erdmann AT arcor DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Question about djgpp's int-wrapper
Date: Wed, 12 Jun 2002 01:11:40 +0200
Organization: Arcor
Lines: 44
Message-ID: <3D0683AC.8AE2DB20@arcor.de>
References: <5 DOT 0 DOT 2 DOT 1 DOT 2 DOT 20020609104552 DOT 009e64e0 AT pop DOT gmx DOT net> <advaa1$cgm$1 AT antares DOT lu DOT erisoft DOT se> <DILM8.896$ca2 DOT 121610 AT newsfep1-win DOT server DOT ntli DOT net>
NNTP-Posting-Host: b10f7.pppool.de
Mime-Version: 1.0
X-Trace: newsread1.arcor-online.net 21100 NG bGFycy5lcmRtYW5u
X-Complaints-To: abuse AT arcor-online DOT net
NNTP-Posting-Date: Tue, 11 Jun 2002 23:12:30 +0000 (UTC)
X-Priority: 1 (Highest)
X-Mailer: Mozilla 4.61 [de] (OS/2; U)
X-Accept-Language: de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I have had a discussion with Martin Kiewitz (who patched a couple of DOS
games to make sound work under OS/2).
The stuff below is just bad coding. If you use "cli" you should use
"sti", since once you used "cli" you don't know the state of the irq
flag anyways (apart from having it pushed on the stack) and in that
case, you should always use "sti" to reenable them.
If you use "cli" anywhere else but in an interrupt handler, you know
that irqs will have been enabled before (so the sequence cli,sti will
definitely return you to the state that the irq flag was before).
For an ISR (as far as I remember), interrupts are always disabled on
entry (aren't they ?), so only the sequence sti,cli would make sense.

So, for usage outside of an ISR this would be:
pushf
cli
...
sti
popf

Martin did exactly that to patch the DOS games (hexen,heretic,doom,doom
2) and guess what, they work perfectly well under OS/2 now.

Lars


> This design fault prevents many protected mode games, like Doom and
> DukeNukem3D, from running with sound on NT, Win2K and XP.  In many cases the
> sound driver disables interrupts around sound card h/w accesses with code
> like...
> 
> pushf
> cli
> ...
> popf ; Restore IRQ state
> 
> Here the cli traps to NTVDM which obligingly disables the virtual interrupt
> state.  However the popf that should restore the interrupt state does
> nothing so virtual interrupts remain disabled.
> 
> If you want to run these games with a sound card emulator like SoundFX
> (www.softsystem.co.uk/sndfx202.zip) then it's necessary to patch the code to
> remove the cli opcodes.

- Raw text -


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