From 406921523d4c2155778398681e04329f5a6c2771 Mon Sep 17 00:00:00 2001 From: Eric Vidal Date: Sat, 20 Nov 2021 13:18:06 +0800 Subject: [PATCH] - sb first sample fix, more memory reclamations --- README.md | 7 ++++--- WOLFSRC/ID_SD.C | 30 ++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 69d4e9f..b3330f8 100644 --- a/README.md +++ b/README.md @@ -243,11 +243,12 @@ Version History - Added "nompu" command-line parameter to disable MPU-401 usage and revert to OPL2 music. Removing/renaming your MUSIC directory has the same effect. Just in case you REALLY want that... - Fixed the sound attenuation behavior on SB pro, because SB pro volume level 7 of 15 (the minimum volume encoded into the Wolf3D volume lookup table) is actually near inaudible instead of half volume as one might expect. Since the developer intention seems to be for attenuating sounds only down to the half-volume point (coupled with the fact that non-SB-pro devices do not attenuate volume, making it "unfair" for SB pro owners if they don't hear some sounds), the value sent to the SB pro is now adjusted closer to the SB pro's real half-volume point. This fix also reduces (but not eliminates) sounds getting cut off abruptly -- which is actually a low-volume sound effect taking precedence over a high-volume one -- and also makes the sound positioning a bit more pleasing with headphones due to the more-balanced volume distribution. - Added special cases for door sounds, which account for many of the sound cut-off issues players experience in Wolf3D. Direct door interaction by the player should now always play a sound regardless of a currently-playing sound's priority, but the sound can be overridden by higher-priority sound effects afterwards. Ambient door closing sounds will not override other door sounds anymore (but ambient door opening still will, to alert the player of an enemy opening a door). Reopening a currently-closing door should also now override the door-closing sound with a door-open sound. All that said, the real solution to the sound cut-off problem is to do software-based mixing of simultaneous sounds ala Doom, which would require significant engine changes and may be too much work for 286 (don't know when/if this will happen at all). -- Fixed Covox support where the first few digitized sounds will not play (but subsequent ones work fine). -- Fixed slowdown issue with Covox and DMA-less SB mode combined with very short non-digitized AdLib sound effects (i.e., the digitized sound's pitch lowers when the player runs into a wall or holds the Open key). +- Fixed classic Sound Blaster code where the first parts of digitized sounds can get dropped sometimes due to a wayward interrupt. +- Fixed new Covox support where the first few digitized sounds will not play (but subsequent ones work fine). +- Fixed slowdown issue with Covox and DMA-less SB support combined with very short non-digitized AdLib sound effects (i.e., the digitized sound's pitch lowers when the player runs into a wall or holds the Open key). - Fixed DONOTHINGSND not getting played on tiles previously occupied by pushwalls (it now plays, as with any other tile, for consistency). - PUSHWALLSND is now a positioned sound. -- Fixed rare possibility for the automap to break when the player is straferunning through a one-tile-wide corridor and experiencing framerate drops, which can result in the player skipping entire tiles (and breaking spotvis connectivity). Item pickup logic has also been fixed to not skip these tiles. +- Fixed rare possibility for the automap to break when the player is straferunning through a one-tile-wide corridor on lower framerates, which can result in the player skipping entire tiles (and breaking spotvis connectivity). Item pickup logic has also been fixed to not skip these tiles (except if COMP 4 is specified). - Previous version cleared keyboard inputs after screen fade-/fizzle-in, but this changed the level start's feel significantly (players would start pressing directional keys during the fade-in only for the movement to not register, killing running starts). Changed so that only the LastScan code is cleared, which only affects the processing of the menu keys Esc and F1-F10 (which was the intended fix). - Previous version broke some behavioral compatibility with existing maps with holowalls -- in particular, shooting inside a holowall should alert all enemies in the level. (Fixed in this version.) - Reverted SAVENEARHEAP to its original value (it was modified to help reduce the memory requirement to 576 KB, but it apparently causes random crashes; still not sure why). diff --git a/WOLFSRC/ID_SD.C b/WOLFSRC/ID_SD.C index 7db9085..20a662a 100644 --- a/WOLFSRC/ID_SD.C +++ b/WOLFSRC/ID_SD.C @@ -788,6 +788,13 @@ SDL_SBService(void) sbIn(sbDataAvail); // Ack interrupt to SB +#ifdef WOLFDOSMPU + // fix for first sample sometimes not getting played: + // a delayed interrupt can cause SDL_DigitizedDone to be called while no sound is being played, + // causing DigiMissed to be set to true and SD_Poll() to play the second sample immediately, + // even before the first sample has finished + if (sbSamplePlaying) +#endif // WOLFDOSMPU if (sbNextSegPtr) { used = SDL_SBPlaySeg(sbNextSegPtr,sbNextSegLen); @@ -2377,9 +2384,13 @@ SD_SetMusicMode(SMMode mode) { boolean result = false; +#ifdef WOLFDOSMPU + SD_MusicOff(); +#else // WOLFDOSMPU SD_FadeOutMusic(); while (SD_MusicPlaying()) ; +#endif // WOLFDOSMPU switch (mode) { @@ -2581,6 +2592,7 @@ SD_Startup(void) } #ifdef WOLFDOSMPU + // unused #else // WOLFDOSMPU /////////////////////////////////////////////////////////////////////////// // @@ -2741,13 +2753,15 @@ SD_PlaySound(soundnames sound) else { // a far-away closing door sound is meant to be ambience only and should - // not override another door sound (*especially* near ones); a far-away - // opening door sound, however, should play according to regular priority - // rules (including overriding a near door sound, to alert the player - // that an enemy is opening a door) + // not override another door sound whether opening or closing (*especially* near ones) if (sound == CLOSEDOORSND && (DigiNumber == OPENDOORSND || DigiNumber == CLOSEDOORSND || SD_SoundPlaying() == OPENDOORSND || SD_SoundPlaying() == CLOSEDOORSND)) return false; + // a far-away opening door sound should not override another opening door + // sound (*especially* near ones), but should override closing door sounds + // to alert the player of enemies + if (sound == OPENDOORSND && (DigiNumber == OPENDOORSND || SD_SoundPlaying() == OPENDOORSND)) + return false; } #endif // WOLFDOSMPU @@ -2972,6 +2986,9 @@ asm popf // to see if the fadeout is complete // /////////////////////////////////////////////////////////////////////////// +#ifdef WOLFDOSMPU + // unused +#else // WOLFDOSMPU void SD_FadeOutMusic(void) { @@ -2983,6 +3000,7 @@ SD_FadeOutMusic(void) break; } } +#endif // WOLFDOSMPU /////////////////////////////////////////////////////////////////////////// // @@ -2990,6 +3008,9 @@ SD_FadeOutMusic(void) // not // /////////////////////////////////////////////////////////////////////////// +#ifdef WOLFDOSMPU + // unused +#else // WOLFDOSMPU boolean SD_MusicPlaying(void) { @@ -3007,3 +3028,4 @@ SD_MusicPlaying(void) return(result); } +#endif // WOLFDOSMPU