From c8de7d508997c26295dbbb6f4853a8a113b74d8a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 2 Oct 2003 07:01:12 +0000 Subject: Cleanups, mostly related to sound effects. svn-id: r10532 --- sword2/driver/d_draw.cpp | 7 +++++ sword2/driver/d_sound.cpp | 69 +++++------------------------------------------ sword2/driver/d_sound.h | 3 --- sword2/driver/sprite.cpp | 5 ++-- sword2/sound.cpp | 2 -- 5 files changed, 16 insertions(+), 70 deletions(-) (limited to 'sword2') diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp index f9930cb118..6821df34bd 100644 --- a/sword2/driver/d_draw.cpp +++ b/sword2/driver/d_draw.cpp @@ -322,5 +322,12 @@ int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut) { BS2_SetPalette(0, 256, oldPal, RDPAL_INSTANT); } + // Lead-in and lead-out music are, as far as I can tell, only used for + // the animated cut-scenes, so this seems like a good place to close + // both of them. + + g_sound->closeFx(-1); + g_sound->closeFx(-2); + return RD_OK; } diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 3e1369a1a1..6f2dca6851 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -50,7 +50,7 @@ static File fpMus; #define GetCompressedSign(n) (((n) >> 3) & 1) #define GetCompressedAmplitude(n) ((n) & 7) -int32 panTable[33] = { +static int32 panTable[33] = { -127, -119, -111, -103, -95, -87, -79, -71, -63, -55, -47, -39, -31, -23, -15, -7, 0, @@ -58,7 +58,7 @@ int32 panTable[33] = { 71, 79, 87, 95, 103, 111, 119, 127 }; -int32 musicVolTable[17] = { +static int32 musicVolTable[17] = { 0, 15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239, 255 }; @@ -249,8 +249,6 @@ void Sword2Sound::playLeadOut(uint8 *leadOut) { ServiceWindows(); g_system->delay_msecs(30); } - - closeFx(-2); } // -------------------------------------------------------------------------- @@ -271,12 +269,6 @@ int32 Sword2Sound::isFxOpen(int32 id) { return getFxIndex(id) == MAXFX; } -// -------------------------------------------------------------------------- -// This function checks the status of all current sound effects, and clears -// out the ones which are no longer required in a buffer. It is called by -// a separate thread. -// -------------------------------------------------------------------------- - void Sword2Sound::fxServer(int16 *data, uint len) { StackLock lock(_mutex); @@ -287,48 +279,6 @@ void Sword2Sound::fxServer(int16 *data, uint len) { if (!_music[0]._streaming && !_music[1]._streaming && fpMus.isOpen()) fpMus.close(); - - // FIXME: Doing this sort of things from a separate thread seems like - // just asking for trouble. But removing it outright causes regressions - // which need to be investigated. - // - // I've fixed one such regression, and as far as I can tell it's - // working now. - -#if 0 - int i; - - if (_fxPaused) { - for (i = 0; i < MAXFX; i++) { - if ((_fx[i]._id == -1) || (_fx[i]._id == -2)) { - if (!_fx[i]._handle) { - _fx[i]._id = 0; - if (_fx[i]._buf != NULL) { - free(_fx[i]._buf); - _fx[i]._buf = NULL; - } - _fx[i]._bufSize = 0; - _fx[i]._flags = 0; - } - } - } - return; - } - - for (i = 0; i < MAXFX; i++) { - if (_fx[i]._id) { - if (!_fx[i]._handle) { - _fx[i]._id = 0; - if (_fx[i]._buf != NULL) { - free(_fx[i]._buf); - _fx[i]._buf = NULL; - } - _fx[i]._bufSize = 0; - _fx[i]._flags = 0; - } - } - } -#endif } /** @@ -610,17 +560,10 @@ int32 Sword2Sound::openFx(int32 id, uint8 *data) { if (fxi == MAXFX) { // Expire the first sound effect that isn't currently - // playing. - - // FIXME. This may need a bit of work. I still haven't - // grasped all the intricacies of the sound effects - // handling. - // - // Anyway, it'd be nicer - in theory - to expire the - // least recently used slot. - // - // This used to be done by the "garbage collector" in - // fxServer(). + // playing. This usually shouldn't happen since the + // game engine manually clears all sound effects (at + // least except for lead-ins and lead-outs) when moving + // between rooms. for (fxi = 0; fxi < MAXFX; fxi++) { if (!_fx[fxi]._handle) diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h index c99098a9f5..abc76f3d05 100644 --- a/sword2/driver/d_sound.h +++ b/sword2/driver/d_sound.h @@ -73,9 +73,6 @@ private: FxHandle _fx[MAXFX]; MusicHandle _music[MAXMUS + 1]; - // We used to have two music volumes - one for each channel - - // but they were always set to the same value. - uint8 _musicVol; uint8 _soundOn; diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp index 5bb634ca92..64189ca167 100644 --- a/sword2/driver/sprite.cpp +++ b/sword2/driver/sprite.cpp @@ -615,6 +615,8 @@ int32 DrawSprite(_spriteInfo *s) { dst += screenWide; } } else if (s->blend & 0x02) { + debug(2, "DrawSprite: s->blend & 0x02"); + // FIXME: This case looks bogus to me. The // same value for the red, green and blue // parameters, and we multiply with the source @@ -622,8 +624,7 @@ int32 DrawSprite(_spriteInfo *s) { // component. // // But as far as I can see, that's how the - // original - // code did it. + // original code did it. // // Does anyone know where this case was used // anyway? diff --git a/sword2/sound.cpp b/sword2/sound.cpp index ae3eb43de9..3e20c01402 100644 --- a/sword2/sound.cpp +++ b/sword2/sound.cpp @@ -240,8 +240,6 @@ int32 FN_play_fx(int32 *params) { res_man.close(fxq[j].resource); } - // (James07uag97) - if (fxq[j].type == FX_LOOP) { // play now, rather than in Process_fx_queue where it was // getting played again & again! -- cgit v1.2.3