aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-10-01 06:36:25 +0000
committerTorbjörn Andersson2003-10-01 06:36:25 +0000
commit2a41216f086315009e07a7d379ebf72305e7dd1e (patch)
tree599ad23e89759ca54dd4ad25ede5dcc47c12df11
parent7c04dc7a86d15795ad55f24b13345b739ee18428 (diff)
downloadscummvm-rg350-2a41216f086315009e07a7d379ebf72305e7dd1e.tar.gz
scummvm-rg350-2a41216f086315009e07a7d379ebf72305e7dd1e.tar.bz2
scummvm-rg350-2a41216f086315009e07a7d379ebf72305e7dd1e.zip
ScummVM naming conventions and cleanup in the Sword2Sound class.
svn-id: r10514
-rw-r--r--sword2/anims.cpp12
-rw-r--r--sword2/controls.cpp58
-rw-r--r--sword2/driver/d_sound.cpp565
-rw-r--r--sword2/driver/d_sound.h146
-rw-r--r--sword2/function.cpp14
-rw-r--r--sword2/mouse.cpp10
-rw-r--r--sword2/sound.cpp90
-rw-r--r--sword2/speech.cpp24
-rw-r--r--sword2/startup.cpp4
9 files changed, 430 insertions, 493 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index a06d3b7c20..4e4f1bef47 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -563,7 +563,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
else
strcpy(speechFile, "speech.clu");
- sequence_text_list[line].speechBufferSize = g_sound->PreFetchCompSpeech((char *) speechFile, wavId, &sequence_text_list[line].speech_mem);
+ sequence_text_list[line].speechBufferSize = g_sound->preFetchCompSpeech((char *) speechFile, wavId, &sequence_text_list[line].speech_mem);
if (sequence_text_list[line].speechBufferSize) {
// ok, we've got speech!
speechRunning = 1;
@@ -670,14 +670,14 @@ int32 FN_smacker_lead_in(int32 *params) {
leadIn += sizeof(_standardHeader);
// wav data gets copied to sound memory
- rv = g_sound->PlayFx(0, leadIn, 0, 0, RDSE_FXLEADIN);
+ rv = g_sound->playFx(0, leadIn, 0, 0, RDSE_FXLEADIN);
if (rv)
- debug(5, "SFX ERROR: PlayFx() returned %.8x", rv);
+ debug(5, "SFX ERROR: playFx() returned %.8x", rv);
res_man.close(params[0]);
- // fade out any music that is currently playing (James22july97)
+ // fade out any music that is currently playing
FN_stop_music(NULL);
// continue script
@@ -750,7 +750,7 @@ int32 FN_play_sequence(int32 *params) {
FN_stop_music(NULL);
// pause sfx during sequence, except the one used for lead-in music
- g_sound->PauseFxForSequence();
+ g_sound->pauseFxForSequence();
if (sequenceTextLines && g_sword2->_gameId == GID_SWORD2)
rv = PlaySmacker(filename, sequenceSpeechArray, leadOut);
@@ -758,7 +758,7 @@ int32 FN_play_sequence(int32 *params) {
rv = PlaySmacker(filename, NULL, leadOut);
// unpause sound fx again, in case we're staying in same location
- g_sound->UnpauseFx();
+ g_sound->unpauseFx();
// close the lead-out music resource
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 819a7b6a76..5f704f7be0 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -787,12 +787,12 @@ public:
_objectLabelsSwitch->setValue(pointerTextSelected != 0);
_subtitlesSwitch->setValue(subtitles != 0);
_reverseStereoSwitch->setValue(stereoReversed != 0);
- _musicSwitch->setValue(g_sound->IsMusicMute() == 0);
- _speechSwitch->setValue(g_sound->IsSpeechMute() == 0);
- _fxSwitch->setValue(g_sound->IsFxMute() == 0);
- _musicSlider->setValue(g_sound->GetMusicVolume());
- _speechSlider->setValue(g_sound->GetSpeechVolume());
- _fxSlider->setValue(g_sound->GetFxVolume());
+ _musicSwitch->setValue(g_sound->isMusicMute() == 0);
+ _speechSwitch->setValue(g_sound->isSpeechMute() == 0);
+ _fxSwitch->setValue(g_sound->isFxMute() == 0);
+ _musicSlider->setValue(g_sound->getMusicVolume());
+ _speechSlider->setValue(g_sound->getSpeechVolume());
+ _fxSlider->setValue(g_sound->getFxVolume());
_gfxSlider->setValue(GetRenderType());
_gfxPreview->setState(GetRenderType());
}
@@ -851,13 +851,13 @@ public:
if (widget == _reverseStereoSwitch) {
if (result != stereoReversed)
- g_sound->ReverseStereo();
+ g_sound->reverseStereo();
stereoReversed = result;
} else if (widget == _musicSwitch) {
- g_sound->MuteMusic(result);
+ g_sound->muteMusic(result);
} else if (widget == _musicSlider) {
- g_sound->SetMusicVolume(result);
- g_sound->MuteMusic(result == 0);
+ g_sound->setMusicVolume(result);
+ g_sound->muteMusic(result == 0);
_musicSwitch->setValue(result != 0);
} else if (widget == _speechSlider) {
_speechSwitch->setValue(result != 0);
@@ -868,12 +868,12 @@ public:
UpdateGraphicsLevel(result);
} else if (widget == _okButton) {
// Apply the changes
- g_sound->MuteMusic(_musicSwitch->getValue() == 0);
- g_sound->MuteSpeech(_speechSwitch->getValue() == 0);
- g_sound->MuteFx(_fxSwitch->getValue() == 0);
- g_sound->SetMusicVolume(_musicSlider->getValue());
- g_sound->SetSpeechVolume(_speechSlider->getValue());
- g_sound->SetFxVolume(_fxSlider->getValue());
+ g_sound->muteMusic(_musicSwitch->getValue() == 0);
+ g_sound->muteSpeech(_speechSwitch->getValue() == 0);
+ g_sound->muteFx(_fxSwitch->getValue() == 0);
+ g_sound->setMusicVolume(_musicSlider->getValue());
+ g_sound->setSpeechVolume(_speechSlider->getValue());
+ g_sound->setFxVolume(_fxSlider->getValue());
UpdateGraphicsLevel(_gfxSlider->getValue());
@@ -1467,12 +1467,12 @@ int32 ReadOptionSettings(void) {
delete fp;
delete mgr;
- g_sound->SetMusicVolume(buff[0]);
- g_sound->SetSpeechVolume(buff[1]);
- g_sound->SetFxVolume(buff[2]);
- g_sound->MuteMusic(buff[3]);
- g_sound->MuteSpeech(buff[4]);
- g_sound->MuteFx(buff[5]);
+ g_sound->setMusicVolume(buff[0]);
+ g_sound->setSpeechVolume(buff[1]);
+ g_sound->setFxVolume(buff[2]);
+ g_sound->muteMusic(buff[3]);
+ g_sound->muteSpeech(buff[4]);
+ g_sound->muteFx(buff[5]);
UpdateGraphicsLevel(buff[6]);
@@ -1481,7 +1481,7 @@ int32 ReadOptionSettings(void) {
pointerTextSelected = buff[8];
if (buff[9] != stereoReversed)
- g_sound->ReverseStereo();
+ g_sound->reverseStereo();
stereoReversed = buff[9];
return 0;
@@ -1495,12 +1495,12 @@ int32 WriteOptionSettings(void) {
sprintf(filename, "%s-settings.dat", g_sword2->_game_name);
- buff[0] = g_sound->GetMusicVolume();
- buff[1] = g_sound->GetSpeechVolume();
- buff[2] = g_sound->GetFxVolume();
- buff[3] = g_sound->IsMusicMute();
- buff[4] = g_sound->IsSpeechMute();
- buff[5] = g_sound->IsFxMute();
+ buff[0] = g_sound->getMusicVolume();
+ buff[1] = g_sound->getSpeechVolume();
+ buff[2] = g_sound->getFxVolume();
+ buff[3] = g_sound->isMusicMute();
+ buff[4] = g_sound->isSpeechMute();
+ buff[5] = g_sound->isFxMute();
buff[6] = GetRenderType();
buff[7] = subtitles;
buff[8] = pointerTextSelected;
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index f2e31f66d0..3e1369a1a1 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -122,31 +122,31 @@ bool MusicHandle::eos() const {
}
static void premix_proc(void *param, int16 *data, uint len) {
- ((Sword2Sound *) param)->FxServer(data, len);
+ ((Sword2Sound *) param)->fxServer(data, len);
}
Sword2Sound::Sword2Sound(SoundMixer *mixer) {
_mutex = g_system->create_mutex();
- soundOn = 0;
- speechStatus = 0;
- fxPaused = 0;
- speechPaused = 0;
- speechVol = 14;
- fxVol = 14;
- speechMuted = 0;
- fxMuted = 0;
- musicVol = 16;
-
- musicMuted = 0;
+ _soundOn = 0;
+ _speechStatus = 0;
+ _fxPaused = 0;
+ _speechPaused = 0;
+ _speechVol = 14;
+ _fxVol = 14;
+ _speechMuted = 0;
+ _fxMuted = 0;
+ _musicVol = 16;
+
+ _musicMuted = 0;
_mixer = mixer;
- memset(fx, 0, sizeof(fx));
+ memset(_fx, 0, sizeof(_fx));
- soundHandleSpeech = 0;
- soundOn = 1;
+ _soundHandleSpeech = 0;
+ _soundOn = 1;
- _converter = makeRateConverter(music[0].getRate(), _mixer->getOutputRate(), music[0].isStereo(), false);
+ _converter = makeRateConverter(_music[0].getRate(), _mixer->getOutputRate(), _music[0].isStereo(), false);
_mixer->setupPremix(premix_proc, this);
}
@@ -166,16 +166,12 @@ Sword2Sound::~Sword2Sound() {
* This function reverses the pan table, thus reversing the stereo.
*/
-int32 Sword2Sound::ReverseStereo(void) {
- int i, j;
-
- for (i = 0; i < 16; i++) {
- j = panTable[i];
+void Sword2Sound::reverseStereo(void) {
+ for (int i = 0; i < 16; i++) {
+ int j = panTable[i];
panTable[i] = panTable[32 - i];
panTable[32 - i] = j;
}
-
- return RD_OK;
}
// Save/Restore information about current music so that we can restore it
@@ -186,22 +182,22 @@ void Sword2Sound::saveMusicState() {
int saveStream;
- if (music[0]._streaming && !music[0]._fading) {
+ if (_music[0]._streaming && !_music[0]._fading) {
saveStream = 0;
- } else if (music[1]._streaming && !music[0]._fading) {
+ } else if (_music[1]._streaming && !_music[0]._fading) {
saveStream = 1;
} else {
- music[2]._streaming = false;
+ _music[2]._streaming = false;
return;
}
- music[2]._streaming = true;
- music[2]._fading = 0;
- music[2]._looping = music[saveStream]._looping;
- music[2]._fileStart = music[saveStream]._fileStart;
- music[2]._filePos = music[saveStream]._filePos;
- music[2]._fileEnd = music[saveStream]._fileEnd;
- music[2]._lastSample = music[saveStream]._lastSample;
+ _music[2]._streaming = true;
+ _music[2]._fading = 0;
+ _music[2]._looping = _music[saveStream]._looping;
+ _music[2]._fileStart = _music[saveStream]._fileStart;
+ _music[2]._filePos = _music[saveStream]._filePos;
+ _music[2]._fileEnd = _music[saveStream]._fileEnd;
+ _music[2]._lastSample = _music[saveStream]._lastSample;
}
void Sword2Sound::restoreMusicState() {
@@ -209,29 +205,29 @@ void Sword2Sound::restoreMusicState() {
int restoreStream;
- if (!music[2]._streaming)
+ if (!_music[2]._streaming)
return;
// Fade out any music that happens to be playing
for (int i = 0; i < MAXMUS; i++) {
- if (music[i]._streaming && !music[i]._fading)
- music[i]._fading = FADE_SAMPLES;
+ if (_music[i]._streaming && !_music[i]._fading)
+ _music[i]._fading = FADE_SAMPLES;
}
- if (!music[0]._streaming && !music[0]._fading) {
+ if (!_music[0]._streaming && !_music[0]._fading) {
restoreStream = 0;
} else {
restoreStream = 1;
}
- music[restoreStream]._streaming = true;
- music[restoreStream]._fading = 0;
- music[restoreStream]._looping = music[2]._looping;
- music[restoreStream]._fileStart = music[2]._fileStart;
- music[restoreStream]._filePos = music[2]._filePos;
- music[restoreStream]._fileEnd = music[2]._fileEnd;
- music[restoreStream]._lastSample = music[2]._lastSample;
+ _music[restoreStream]._streaming = true;
+ _music[restoreStream]._fading = 0;
+ _music[restoreStream]._looping = _music[2]._looping;
+ _music[restoreStream]._fileStart = _music[2]._fileStart;
+ _music[restoreStream]._filePos = _music[2]._filePos;
+ _music[restoreStream]._fileEnd = _music[2]._fileEnd;
+ _music[restoreStream]._lastSample = _music[2]._lastSample;
}
void Sword2Sound::playLeadOut(uint8 *leadOut) {
@@ -240,39 +236,39 @@ void Sword2Sound::playLeadOut(uint8 *leadOut) {
if (!leadOut)
return;
- PlayFx(0, leadOut, 0, 0, RDSE_FXLEADOUT);
+ playFx(0, leadOut, 0, 0, RDSE_FXLEADOUT);
- i = GetFxIndex(-1);
+ i = getFxIndex(-1);
if (i == MAXFX) {
warning("playLeadOut: Can't find lead-out sound handle");
return;
}
- while (fx[i]._handle) {
+ while (_fx[i]._handle) {
ServiceWindows();
g_system->delay_msecs(30);
}
- CloseFx(-2);
+ closeFx(-2);
}
// --------------------------------------------------------------------------
// This function returns the index of the sound effect with the ID passed in.
// --------------------------------------------------------------------------
-int32 Sword2Sound::GetFxIndex(int32 id) {
+int32 Sword2Sound::getFxIndex(int32 id) {
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id == id)
+ if (_fx[i]._id == id)
return i;
}
return MAXFX;
}
-int32 Sword2Sound::IsFxOpen(int32 id) {
+int32 Sword2Sound::isFxOpen(int32 id) {
// FIXME: This seems backwards to me, but changing it breaks sound.
- return GetFxIndex(id) == MAXFX;
+ return getFxIndex(id) == MAXFX;
}
// --------------------------------------------------------------------------
@@ -281,15 +277,15 @@ int32 Sword2Sound::IsFxOpen(int32 id) {
// a separate thread.
// --------------------------------------------------------------------------
-void Sword2Sound::FxServer(int16 *data, uint len) {
+void Sword2Sound::fxServer(int16 *data, uint len) {
StackLock lock(_mutex);
- if (!soundOn)
+ if (!_soundOn)
return;
- UpdateCompSampleStreaming(data, len);
+ updateCompSampleStreaming(data, len);
- if (!music[0]._streaming && !music[1]._streaming && fpMus.isOpen())
+ if (!_music[0]._streaming && !_music[1]._streaming && fpMus.isOpen())
fpMus.close();
// FIXME: Doing this sort of things from a separate thread seems like
@@ -302,17 +298,17 @@ void Sword2Sound::FxServer(int16 *data, uint len) {
#if 0
int i;
- if (fxPaused) {
+ 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;
+ 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;
+ _fx[i]._bufSize = 0;
+ _fx[i]._flags = 0;
}
}
}
@@ -320,15 +316,15 @@ void Sword2Sound::FxServer(int16 *data, uint len) {
}
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;
+ 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;
+ _fx[i]._bufSize = 0;
+ _fx[i]._flags = 0;
}
}
}
@@ -339,8 +335,8 @@ void Sword2Sound::FxServer(int16 *data, uint len) {
* Returns either RDSE_QUIET or RDSE_SPEAKING
*/
-int32 Sword2Sound::AmISpeaking() {
- if (!speechMuted && !speechPaused && soundHandleSpeech != 0)
+int32 Sword2Sound::amISpeaking() {
+ if (!_speechMuted && !_speechPaused && _soundHandleSpeech != 0)
return RDSE_SPEAKING;
return RDSE_QUIET;
@@ -355,7 +351,7 @@ int32 Sword2Sound::AmISpeaking() {
* @param buf a pointer to the buffer that will be allocated for the sound
*/
-uint32 Sword2Sound::PreFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf) {
+uint32 Sword2Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf) {
uint32 i;
uint8 *data8;
uint32 speechIndex[2];
@@ -445,15 +441,15 @@ uint32 Sword2Sound::PreFetchCompSpeech(const char *filename, uint32 speechid, ui
* @param pan panning, -16 (full left) to 16 (full right)
*/
-int32 Sword2Sound::PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan) {
+int32 Sword2Sound::playCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan) {
uint16 *data16;
uint32 bufferSize;
- if (!speechMuted) {
- if (GetSpeechStatus() == RDERR_SPEECHPLAYING)
+ if (!_speechMuted) {
+ if (getSpeechStatus() == RDERR_SPEECHPLAYING)
return RDERR_SPEECHPLAYING;
- bufferSize = PreFetchCompSpeech(filename, speechid, &data16);
+ bufferSize = preFetchCompSpeech(filename, speechid, &data16);
// We don't know exactly what went wrong here.
if (bufferSize == 0)
@@ -461,18 +457,18 @@ int32 Sword2Sound::PlayCompSpeech(const char *filename, uint32 speechid, uint8 v
// Modify the volume according to the master volume
- byte volume = speechMuted ? 0 : vol * speechVol;
+ byte volume = _speechMuted ? 0 : vol * _speechVol;
int8 p = panTable[pan + 16];
// Start the speech playing
- speechPaused = 1;
+ _speechPaused = 1;
uint32 flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE;
- _mixer->playRaw(&soundHandleSpeech, data16, bufferSize, 22050, flags, -1, volume, p);
+ _mixer->playRaw(&_soundHandleSpeech, data16, bufferSize, 22050, flags, -1, volume, p);
- speechStatus = 1;
+ _speechStatus = 1;
}
// DipMusic();
@@ -484,13 +480,13 @@ int32 Sword2Sound::PlayCompSpeech(const char *filename, uint32 speechid, uint8 v
* Stops the speech from playing.
*/
-int32 Sword2Sound::StopSpeechSword2(void) {
- if (!soundOn)
+int32 Sword2Sound::stopSpeech(void) {
+ if (!_soundOn)
return RD_OK;
- if (speechStatus) {
- g_engine->_mixer->stopHandle(soundHandleSpeech);
- speechStatus = 0;
+ if (_speechStatus) {
+ g_engine->_mixer->stopHandle(_soundHandleSpeech);
+ _speechStatus = 0;
return RD_OK;
}
return RDERR_SPEECHNOTPLAYING;
@@ -500,15 +496,15 @@ int32 Sword2Sound::StopSpeechSword2(void) {
* @return Either RDSE_SAMPLEPLAYING or RDSE_SAMPLEFINISHED
*/
-int32 Sword2Sound::GetSpeechStatus(void) {
- if (!soundOn || !speechStatus)
+int32 Sword2Sound::getSpeechStatus(void) {
+ if (!_soundOn || !_speechStatus)
return RDSE_SAMPLEFINISHED;
- if (speechPaused)
+ if (_speechPaused)
return RDSE_SAMPLEPLAYING;
- if (!soundHandleSpeech) {
- speechStatus = 0;
+ if (!_soundHandleSpeech) {
+ _speechStatus = 0;
return RDSE_SAMPLEFINISHED;
}
return RDSE_SAMPLEPLAYING;
@@ -519,10 +515,10 @@ int32 Sword2Sound::GetSpeechStatus(void) {
* @param volume volume, from 0 (silent) to 14 (max)
*/
-void Sword2Sound::SetSpeechVolume(uint8 volume) {
- speechVol = volume;
- if (soundHandleSpeech != 0 && !speechMuted && GetSpeechStatus() == RDSE_SAMPLEPLAYING) {
- g_engine->_mixer->setChannelVolume(soundHandleSpeech, 16 * speechVol);
+void Sword2Sound::setSpeechVolume(uint8 volume) {
+ _speechVol = volume;
+ if (_soundHandleSpeech != 0 && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) {
+ g_engine->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol);
}
}
@@ -530,8 +526,8 @@ void Sword2Sound::SetSpeechVolume(uint8 volume) {
* @return the volume setting for speech
*/
-uint8 Sword2Sound::GetSpeechVolume() {
- return speechVol;
+uint8 Sword2Sound::getSpeechVolume() {
+ return _speechVol;
}
/**
@@ -540,13 +536,13 @@ uint8 Sword2Sound::GetSpeechVolume() {
* Otherwise the speech is muted (volume 0).
*/
-void Sword2Sound::MuteSpeech(uint8 mute) {
- speechMuted = mute;
+void Sword2Sound::muteSpeech(uint8 mute) {
+ _speechMuted = mute;
- if (GetSpeechStatus() == RDSE_SAMPLEPLAYING) {
- byte volume = mute ? 0 : 16 * speechVol;
+ if (getSpeechStatus() == RDSE_SAMPLEPLAYING) {
+ byte volume = mute ? 0 : 16 * _speechVol;
- g_engine->_mixer->setChannelVolume(soundHandleSpeech, volume);
+ g_engine->_mixer->setChannelVolume(_soundHandleSpeech, volume);
}
}
@@ -554,32 +550,30 @@ void Sword2Sound::MuteSpeech(uint8 mute) {
* @return the speech's mute state, 1 if mute, 0 if not mute
*/
-uint8 Sword2Sound::IsSpeechMute(void) {
- return speechMuted;
+uint8 Sword2Sound::isSpeechMute(void) {
+ return _speechMuted;
}
/**
* Stops the speech dead in its tracks.
*/
-int32 Sword2Sound::PauseSpeech(void) {
- if (GetSpeechStatus() == RDSE_SAMPLEPLAYING) {
- speechPaused = 1;
- g_engine->_mixer->pauseHandle(soundHandleSpeech, true);
+void Sword2Sound::pauseSpeech(void) {
+ if (getSpeechStatus() == RDSE_SAMPLEPLAYING) {
+ _speechPaused = 1;
+ g_engine->_mixer->pauseHandle(_soundHandleSpeech, true);
}
- return RD_OK;
}
/**
* Restarts the speech from where it was stopped.
*/
-int32 Sword2Sound::UnpauseSpeech(void) {
- if (speechPaused) {
- speechPaused = 0;
- g_engine->_mixer->pauseHandle(soundHandleSpeech, false);
+void Sword2Sound::unpauseSpeech(void) {
+ if (_speechPaused) {
+ _speechPaused = 0;
+ g_engine->_mixer->pauseHandle(_soundHandleSpeech, false);
}
- return RD_OK;
}
/**
@@ -590,27 +584,27 @@ int32 Sword2Sound::UnpauseSpeech(void) {
* @warning Zero is not a valid id
*/
-int32 Sword2Sound::OpenFx(int32 id, uint8 *data) {
+int32 Sword2Sound::openFx(int32 id, uint8 *data) {
int32 i, fxi;
uint32 *data32 = NULL;
_wavHeader *wav;
wav = (_wavHeader *) data;
- if (soundOn) {
+ if (_soundOn) {
// Check for a valid id.
if (id == 0)
return RDERR_INVALIDID;
// Check that the fx is not already open
for (i = 0; i < MAXFX; i++) {
- if (fx[i]._id == id)
+ if (_fx[i]._id == id)
return RDERR_FXALREADYOPEN;
}
// Now choose a free slot for the fx
for (fxi = 0; fxi < MAXFX; fxi++) {
- if (fx[fxi]._id == 0)
+ if (_fx[fxi]._id == 0)
break;
}
@@ -626,17 +620,17 @@ int32 Sword2Sound::OpenFx(int32 id, uint8 *data) {
// least recently used slot.
//
// This used to be done by the "garbage collector" in
- // FxServer().
+ // fxServer().
for (fxi = 0; fxi < MAXFX; fxi++) {
- if (!fx[fxi]._handle)
+ if (!_fx[fxi]._handle)
break;
}
// Still no dice? I give up!
if (fxi == MAXFX) {
- warning("OpenFx: No free sound slots");
+ warning("openFx: No free sound slots");
return RDERR_NOFREEBUFFERS;
}
}
@@ -656,25 +650,25 @@ int32 Sword2Sound::OpenFx(int32 id, uint8 *data) {
if (!data32)
return RDERR_INVALIDWAV;
- fx[fxi]._bufSize = READ_LE_UINT32(data32 + 1);
+ _fx[fxi]._bufSize = READ_LE_UINT32(data32 + 1);
// Fill the speech buffer with data
- if (fx[fxi]._buf != NULL)
- free(fx[fxi]._buf);
- fx[fxi]._buf = (uint16 *) malloc(fx[fxi]._bufSize);
- memcpy(fx[fxi]._buf, (uint8 *) (data32 + 2), fx[fxi]._bufSize);
- fx[fxi]._flags = SoundMixer::FLAG_16BITS;
+ if (_fx[fxi]._buf != NULL)
+ free(_fx[fxi]._buf);
+ _fx[fxi]._buf = (uint16 *) malloc(_fx[fxi]._bufSize);
+ memcpy(_fx[fxi]._buf, (uint8 *) (data32 + 2), _fx[fxi]._bufSize);
+ _fx[fxi]._flags = SoundMixer::FLAG_16BITS;
if (FROM_LE_16(wav->channels) == 2)
- fx[fxi]._flags |= SoundMixer::FLAG_STEREO;
+ _fx[fxi]._flags |= SoundMixer::FLAG_STEREO;
- fx[fxi]._rate = FROM_LE_16(wav->samplesPerSec);
+ _fx[fxi]._rate = FROM_LE_16(wav->samplesPerSec);
// Until the mixer supports LE samples natively, we need to
// convert our LE ones to BE
- for (int32 j = 0; j < fx[fxi]._bufSize / 2; j++)
- fx[fxi]._buf[j] = SWAP_BYTES_16(fx[fxi]._buf[j]);
+ for (int32 j = 0; j < _fx[fxi]._bufSize / 2; j++)
+ _fx[fxi]._buf[j] = SWAP_BYTES_16(_fx[fxi]._buf[j]);
- fx[fxi]._id = id;
+ _fx[fxi]._id = id;
}
return RD_OK;
}
@@ -693,7 +687,7 @@ int32 Sword2Sound::OpenFx(int32 id, uint8 *data) {
* @warning Zero is not a valid id
*/
-int32 Sword2Sound::PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) {
+int32 Sword2Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) {
int32 i, loop;
uint32 hr;
@@ -702,26 +696,26 @@ int32 Sword2Sound::PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type
else
loop = 0;
- if (soundOn) {
+ if (_soundOn) {
if (data == NULL) {
- i = GetFxIndex(id);
+ i = getFxIndex(id);
if (i == MAXFX) {
- warning("PlayFx(%d, %d, %d, %d) - Not open", id, vol, pan, type);
+ warning("playFx(%d, %d, %d, %d) - Not open", id, vol, pan, type);
return RDERR_FXNOTOPEN;
}
if (loop == 1)
- fx[i]._flags |= SoundMixer::FLAG_LOOP;
+ _fx[i]._flags |= SoundMixer::FLAG_LOOP;
else
- fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
+ _fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
- fx[i]._volume = vol;
+ _fx[i]._volume = vol;
// Start the sound effect playing
- byte volume = fxMuted ? 0 : vol * fxVol;
+ byte volume = _fxMuted ? 0 : vol * _fxVol;
int8 p = panTable[pan + 16];
- g_engine->_mixer->playRaw(&fx[i]._handle, fx[i]._buf, fx[i]._bufSize, fx[i]._rate, fx[i]._flags, -1, volume, p);
+ g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
} else {
if (type == RDSE_FXLEADIN || type == RDSE_FXLEADOUT) {
if (type == RDSE_FXLEADIN)
@@ -729,46 +723,47 @@ int32 Sword2Sound::PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type
else
id = -1;
- hr = OpenFx(id, data);
+ hr = openFx(id, data);
if (hr != RD_OK)
return hr;
- i = GetFxIndex(id);
+ i = getFxIndex(id);
if (i == MAXFX) {
- warning("PlayFx(%d, %d, %d, %d) - Not found", id, vol, pan, type);
+ warning("playFx(%d, %d, %d, %d) - Not found", id, vol, pan, type);
return RDERR_FXFUCKED;
}
- fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
+ _fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
- byte volume = musicMuted ? 0 : musicVolTable[musicVol];
+ byte volume = _musicMuted ? 0 : musicVolTable[_musicVol];
- g_engine->_mixer->playRaw(&fx[i]._handle, fx[i]._buf, fx[i]._bufSize, fx[i]._rate, fx[i]._flags, -1, volume, 0);
+ g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, 0);
} else {
- hr = OpenFx(id, data);
+ hr = openFx(id, data);
if (hr != RD_OK) {
return hr;
}
- i = GetFxIndex(id);
+ i = getFxIndex(id);
if (i == MAXFX) {
- warning("PlayFx(%d, %d, %d, %d) - Not found", id, vol, pan, type);
+ warning("playFx(%d, %d, %d, %d) - Not found", id, vol, pan, type);
return RDERR_FXFUCKED;
}
if (loop == 1)
- fx[i]._flags |= SoundMixer::FLAG_LOOP;
+ _fx[i]._flags |= SoundMixer::FLAG_LOOP;
else
- fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
- fx[i]._volume = vol;
+ _fx[i]._flags &= ~SoundMixer::FLAG_LOOP;
+ _fx[i]._volume = vol;
// Start the sound effect playing
- byte volume = fxMuted ? 0 : vol * fxVol;
+ byte volume = _fxMuted ? 0 : vol * _fxVol;
int8 p = panTable[pan + 16];
- g_engine->_mixer->playRaw(&fx[i]._handle, fx[i]._buf, fx[i]._bufSize, fx[i]._rate, fx[i]._flags, -1, volume, p);
+ g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
}
}
}
+
return RD_OK;
}
@@ -779,28 +774,29 @@ int32 Sword2Sound::PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type
* @param pan panning
*/
-int32 Sword2Sound::SetFxVolumePan(int32 id, uint8 vol, int8 pan) {
- int32 i = GetFxIndex(id);
+int32 Sword2Sound::setFxIdVolumePan(int32 id, uint8 vol, int8 pan) {
+ int32 i = getFxIndex(id);
+
if (i == MAXFX)
return RDERR_FXNOTOPEN;
- fx[i]._volume = vol;
- if (!fxMuted) {
- g_engine->_mixer->setChannelVolume(fx[i]._handle, vol * fxVol);
- g_engine->_mixer->setChannelPan(fx[i]._handle, panTable[pan + 16]);
+ _fx[i]._volume = vol;
+ if (!_fxMuted) {
+ g_engine->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol);
+ g_engine->_mixer->setChannelPan(_fx[i]._handle, panTable[pan + 16]);
}
return RD_OK;
}
-int32 Sword2Sound::SetFxIdVolume(int32 id, uint8 vol) {
- int32 i = GetFxIndex(id);
+int32 Sword2Sound::setFxIdVolume(int32 id, uint8 vol) {
+ int32 i = getFxIndex(id);
if (i == MAXFX)
return RDERR_FXNOTOPEN;
- fx[i]._volume = vol;
- if (!fxMuted)
- g_engine->_mixer->setChannelVolume(fx[i]._handle, vol * fxVol);
+ _fx[i]._volume = vol;
+ if (!_fxMuted)
+ g_engine->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol);
return RD_OK;
}
@@ -810,25 +806,23 @@ int32 Sword2Sound::SetFxIdVolume(int32 id, uint8 vol) {
* playing, irrespective of type.
*/
-int32 Sword2Sound::ClearAllFx(void) {
- if (!soundOn)
- return(RD_OK);
+void Sword2Sound::clearAllFx(void) {
+ if (!_soundOn)
+ return;
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id && fx[i]._id != -1 && fx[i]._id != -2) {
- g_engine->_mixer->stopHandle(fx[i]._handle);
- fx[i]._id = 0;
- fx[i]._paused = false;
- if (fx[i]._buf != NULL) {
- free(fx[i]._buf);
- fx[i]._buf = NULL;
+ if (_fx[i]._id && _fx[i]._id != -1 && _fx[i]._id != -2) {
+ g_engine->_mixer->stopHandle(_fx[i]._handle);
+ _fx[i]._id = 0;
+ _fx[i]._paused = false;
+ if (_fx[i]._buf != NULL) {
+ free(_fx[i]._buf);
+ _fx[i]._buf = NULL;
}
- fx[i]._bufSize = 0;
- fx[i]._flags = 0;
+ _fx[i]._bufSize = 0;
+ _fx[i]._flags = 0;
}
}
-
- return RD_OK;
}
/**
@@ -838,78 +832,74 @@ int32 Sword2Sound::ClearAllFx(void) {
* @param id the id of the sound to close
*/
-int32 Sword2Sound::CloseFx(int32 id) {
+int32 Sword2Sound::closeFx(int32 id) {
int i;
- if (!soundOn)
+ if (!_soundOn)
return RD_OK;
- i = GetFxIndex(id);
- if (i < MAXFX) {
- g_engine->_mixer->stopHandle(fx[i]._handle);
- fx[i]._id = 0;
- fx[i]._paused = false;
- if (fx[i]._buf != NULL) {
- free(fx[i]._buf);
- fx[i]._buf = NULL;
- }
- fx[i]._bufSize = 0;
- fx[i]._flags = 0;
+ i = getFxIndex(id);
+
+ if (i == MAXFX)
+ return RDERR_FXNOTOPEN;
+
+ g_engine->_mixer->stopHandle(_fx[i]._handle);
+ _fx[i]._id = 0;
+ _fx[i]._paused = false;
+ if (_fx[i]._buf != NULL) {
+ free(_fx[i]._buf);
+ _fx[i]._buf = NULL;
}
+ _fx[i]._bufSize = 0;
+ _fx[i]._flags = 0;
return RD_OK;
}
-int32 Sword2Sound::PauseFx(void) {
- if (!fxPaused) {
+void Sword2Sound::pauseFx(void) {
+ if (!_fxPaused) {
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id) {
- g_engine->_mixer->pauseHandle(fx[i]._handle, true);
- fx[i]._paused = true;
+ if (_fx[i]._id) {
+ g_engine->_mixer->pauseHandle(_fx[i]._handle, true);
+ _fx[i]._paused = true;
} else
- fx[i]._paused = false;
+ _fx[i]._paused = false;
}
- fxPaused = 1;
+ _fxPaused = 1;
}
-
- return RD_OK;
}
-int32 Sword2Sound::PauseFxForSequence(void) {
- if (!fxPaused) {
+void Sword2Sound::pauseFxForSequence(void) {
+ if (!_fxPaused) {
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id && fx[i]._id != -2) {
- g_engine->_mixer->pauseHandle(fx[i]._handle, true);
- fx[i]._paused = true;
+ if (_fx[i]._id && _fx[i]._id != -2) {
+ g_engine->_mixer->pauseHandle(_fx[i]._handle, true);
+ _fx[i]._paused = true;
} else {
- fx[i]._paused = false;
+ _fx[i]._paused = false;
}
}
- fxPaused = 1;
+ _fxPaused = 1;
}
-
- return RD_OK;
}
-int32 Sword2Sound::UnpauseFx(void) {
- if (fxPaused) {
+void Sword2Sound::unpauseFx(void) {
+ if (_fxPaused) {
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._paused && fx[i]._id) {
- g_engine->_mixer->pauseHandle(fx[i]._handle, false);
+ if (_fx[i]._paused && _fx[i]._id) {
+ g_engine->_mixer->pauseHandle(_fx[i]._handle, false);
}
}
- fxPaused = 0;
+ _fxPaused = 0;
}
-
- return RD_OK;
}
/**
* @return the master volume setting for sound effects
*/
-uint8 Sword2Sound::GetFxVolume() {
- return fxVol;
+uint8 Sword2Sound::getFxVolume() {
+ return _fxVol;
}
/**
@@ -918,13 +908,13 @@ uint8 Sword2Sound::GetFxVolume() {
* @param volume volume, from 0 (silent) to 14 (max)
*/
-void Sword2Sound::SetFxVolume(uint8 volume) {
- fxVol = volume;
+void Sword2Sound::setFxVolume(uint8 volume) {
+ _fxVol = volume;
// Now update the volume of any fxs playing
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id && !fxMuted)
- g_engine->_mixer->setChannelVolume(fx[i]._handle, fx[i]._volume * fxVol);
+ if (_fx[i]._id && !_fxMuted)
+ g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol);
}
}
@@ -934,15 +924,15 @@ void Sword2Sound::SetFxVolume(uint8 volume) {
* Otherwise the sound effects are muted (volume 0).
*/
-void Sword2Sound::MuteFx(uint8 mute) {
- fxMuted = mute;
+void Sword2Sound::muteFx(uint8 mute) {
+ _fxMuted = mute;
// Now update the volume of any fxs playing
for (int i = 0; i < MAXFX; i++) {
- if (fx[i]._id) {
- byte volume = mute ? 0 : fx[i]._volume * fxVol;
+ if (_fx[i]._id) {
+ byte volume = mute ? 0 : _fx[i]._volume * _fxVol;
- g_engine->_mixer->setChannelVolume(fx[i]._handle, volume);
+ g_engine->_mixer->setChannelVolume(_fx[i]._handle, volume);
}
}
}
@@ -951,8 +941,8 @@ void Sword2Sound::MuteFx(uint8 mute) {
* @return the sound effects's mute state, 1 if mute, 0 if not mute
*/
-uint8 Sword2Sound::IsFxMute(void) {
- return fxMuted;
+uint8 Sword2Sound::isFxMute(void) {
+ return _fxMuted;
}
/**
@@ -963,12 +953,9 @@ uint8 Sword2Sound::IsFxMute(void) {
* @return RD_OK or an error code
*/
-int32 Sword2Sound::StreamCompMusic(const char *filename, uint32 musicId, bool looping) {
+int32 Sword2Sound::streamCompMusic(const char *filename, uint32 musicId, bool looping) {
StackLock lock(_mutex);
- return StreamCompMusicFromLock(filename, musicId, looping);
-}
-int32 Sword2Sound::StreamCompMusicFromLock(const char *filename, uint32 musicId, bool looping) {
uint32 len;
int32 primaryStream = -1;
int32 secondaryStream = -1;
@@ -976,21 +963,21 @@ int32 Sword2Sound::StreamCompMusicFromLock(const char *filename, uint32 musicId,
// If both music streams are playing, that should mean one of them is
// fading out. Pick that one.
- if (music[0]._streaming && music[1]._streaming) {
- if (music[0]._fading)
+ if (_music[0]._streaming && _music[1]._streaming) {
+ if (_music[0]._fading)
primaryStream = 0;
else
primaryStream = 1;
- music[primaryStream]._fading = 0;
- music[primaryStream]._streaming = false;
+ _music[primaryStream]._fading = 0;
+ _music[primaryStream]._streaming = false;
}
// Pick the available music stream. If no music is playing it doesn't
// matter which we use, so pick the first one.
- if (music[0]._streaming || music[1]._streaming) {
- if (music[0]._streaming) {
+ if (_music[0]._streaming || _music[1]._streaming) {
+ if (_music[0]._streaming) {
primaryStream = 1;
secondaryStream = 0;
} else {
@@ -1001,11 +988,11 @@ int32 Sword2Sound::StreamCompMusicFromLock(const char *filename, uint32 musicId,
primaryStream = 0;
// Save looping info and tune id
- music[primaryStream]._looping = looping;
- music[primaryStream]._id = musicId;
+ _music[primaryStream]._looping = looping;
+ _music[primaryStream]._id = musicId;
// Don't start streaming if the volume is off.
- if (IsMusicMute())
+ if (isMusicMute())
return RD_OK;
// The assumption here is that we are never playing music from two
@@ -1018,39 +1005,39 @@ int32 Sword2Sound::StreamCompMusicFromLock(const char *filename, uint32 musicId,
return RDERR_INVALIDFILENAME;
// Start other music stream fading out
- if (secondaryStream != -1 && !music[secondaryStream]._fading)
- music[secondaryStream]._fading = FADE_SAMPLES;
+ if (secondaryStream != -1 && !_music[secondaryStream]._fading)
+ _music[secondaryStream]._fading = FADE_SAMPLES;
fpMus.seek((musicId + 1) * 8, SEEK_SET);
- music[primaryStream]._fileStart = fpMus.readUint32LE();
+ _music[primaryStream]._fileStart = fpMus.readUint32LE();
len = fpMus.readUint32LE();
- if (!music[primaryStream]._fileStart || !len)
+ if (!_music[primaryStream]._fileStart || !len)
return RDERR_INVALIDID;
- music[primaryStream]._fileEnd = music[primaryStream]._fileStart + len;
- music[primaryStream]._filePos = music[primaryStream]._fileStart;
- music[primaryStream]._streaming = true;
- music[primaryStream]._firstTime = true;
+ _music[primaryStream]._fileEnd = _music[primaryStream]._fileStart + len;
+ _music[primaryStream]._filePos = _music[primaryStream]._fileStart;
+ _music[primaryStream]._streaming = true;
+ _music[primaryStream]._firstTime = true;
return RD_OK;
}
-void Sword2Sound::UpdateCompSampleStreaming(int16 *data, uint len) {
+void Sword2Sound::updateCompSampleStreaming(int16 *data, uint len) {
for (int i = 0; i < MAXMUS; i++) {
- if (!music[i]._streaming || music[i]._paused)
+ if (!_music[i]._streaming || _music[i]._paused)
continue;
- st_sample_t volume = musicMuted ? 0 : musicVolTable[musicVol];
+ st_sample_t volume = _musicMuted ? 0 : musicVolTable[_musicVol];
- fpMus.seek(music[i]._filePos, SEEK_SET);
- _converter->flow(music[i], data, len, volume, volume);
+ fpMus.seek(_music[i]._filePos, SEEK_SET);
+ _converter->flow(_music[i], data, len, volume, volume);
}
// DipMusic();
}
-int32 Sword2Sound::DipMusic() {
+int32 Sword2Sound::dipMusic() {
// disable this func for now
return RD_OK;
@@ -1066,7 +1053,7 @@ int32 Sword2Sound::DipMusic() {
HRESULT hr = DS_OK;
LPDIRECTSOUNDBUFFER dsbMusic = NULL;
- int32 currentMusicVol = musicVolTable[volMusic[0]];
+ int32 currentMusicVol = musicVolTable[musicVol];
int32 minMusicVol;
// Find which music buffer is currently playing
@@ -1076,11 +1063,11 @@ int32 Sword2Sound::DipMusic() {
dsbMusic = lpDsbMus[i];
}
- if ((!musicMuted) && dsbMusic && (!speechMuted) && (volMusic[0]>2))
+ if ((!_musicMuted) && dsbMusic && (!_speechMuted) && (musicVol>2))
{
- minMusicVol = musicVolTable[volMusic[0] - 3];
+ minMusicVol = musicVolTable[musicVol - 3];
- if (speechStatus)
+ if (_speechStatus)
{
IDirectSoundBuffer_GetStatus(dsbSpeech, &status);
if ((hr = IDirectSoundBuffer_GetCurrentPosition(dsbMusic, &readCursor, &writeCursor)) != DS_OK)
@@ -1129,12 +1116,12 @@ int32 Sword2Sound::DipMusic() {
* @return the time left for the current music, in seconds.
*/
-int32 Sword2Sound::MusicTimeRemaining() {
+int32 Sword2Sound::musicTimeRemaining() {
StackLock lock(_mutex);
for (int i = 0; i < MAXMUS; i++) {
- if (music[i]._streaming && !music[i]._fading)
- return (music[i]._fileEnd - music[i]._filePos) / 22050;
+ if (_music[i]._streaming && !_music[i]._fading)
+ return (_music[i]._fileEnd - _music[i]._filePos) / 22050;
}
return 0;
@@ -1144,14 +1131,14 @@ int32 Sword2Sound::MusicTimeRemaining() {
* Fades out and stops the music.
*/
-void Sword2Sound::StopMusic(void) {
+void Sword2Sound::stopMusic(void) {
StackLock lock(_mutex);
for (int i = 0; i < MAXMUS; i++) {
- if (music[i]._streaming)
- music[i]._fading = FADE_SAMPLES;
+ if (_music[i]._streaming)
+ _music[i]._fading = FADE_SAMPLES;
else
- music[i]._looping = false;
+ _music[i]._looping = false;
}
}
@@ -1159,33 +1146,31 @@ void Sword2Sound::StopMusic(void) {
* Stops the music dead in its tracks.
*/
-int32 Sword2Sound::PauseMusic(void) {
+void Sword2Sound::pauseMusic(void) {
StackLock lock(_mutex);
- if (soundOn) {
+ if (_soundOn) {
for (int i = 0; i < MAXMUS; i++) {
- if (music[i]._streaming) {
- music[i]._paused = true;
+ if (_music[i]._streaming) {
+ _music[i]._paused = true;
} else {
- music[i]._paused = false;
+ _music[i]._paused = false;
}
}
}
- return RD_OK;
}
/**
* Restarts the music from where it was stopped.
*/
-int32 Sword2Sound::UnpauseMusic(void) {
+void Sword2Sound::unpauseMusic(void) {
StackLock lock(_mutex);
- if (soundOn) {
+ if (_soundOn) {
for (int i = 0; i < MAXMUS; i++)
- music[i]._paused = false;
+ _music[i]._paused = false;
}
- return RD_OK;
}
/**
@@ -1193,16 +1178,16 @@ int32 Sword2Sound::UnpauseMusic(void) {
* @param volume volume, from 0 (silent) to 16 (max)
*/
-void Sword2Sound::SetMusicVolume(uint8 volume) {
- musicVol = volume;
+void Sword2Sound::setMusicVolume(uint8 volume) {
+ _musicVol = volume;
}
/**
* @return the volume setting for music
*/
-uint8 Sword2Sound::GetMusicVolume() {
- return musicVol;
+uint8 Sword2Sound::getMusicVolume() {
+ return _musicVol;
}
/**
@@ -1211,14 +1196,14 @@ uint8 Sword2Sound::GetMusicVolume() {
* Otherwise the music is muted (volume 0).
*/
-void Sword2Sound::MuteMusic(uint8 mute) {
- musicMuted = mute;
+void Sword2Sound::muteMusic(uint8 mute) {
+ _musicMuted = mute;
}
/**
* @return the music's mute state, 1 if mute, 0 if not mute
*/
-uint8 Sword2Sound::IsMusicMute(void) {
- return musicMuted;
+uint8 Sword2Sound::isMusicMute(void) {
+ return _musicMuted;
}
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index 35f317506a..c99098a9f5 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -64,79 +64,79 @@ public:
};
class Sword2Sound {
- public:
- Sword2Sound(SoundMixer *mixer);
- ~Sword2Sound();
- void FxServer(int16 *data, uint len);
- int32 PlaySpeech(uint8 *data, uint8 vol, int8 pan);
- int32 PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
- uint32 PreFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf);
- int32 AmISpeaking();
- int32 StopSpeechSword2(void);
- int32 GetSpeechStatus(void);
- int32 PauseSpeech(void);
- int32 UnpauseSpeech(void);
- int32 OpenFx(int32 id, uint8 *data);
- int32 PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
- int32 CloseFx(int32 id);
- int32 ClearAllFx(void);
- int32 PauseFx(void);
- int32 PauseFxForSequence(void);
- int32 UnpauseFx(void);
- int32 PauseMusic(void);
- int32 UnpauseMusic(void);
- int32 StreamCompMusic(const char *filename, uint32 musicId, bool looping);
- void saveMusicState();
- void restoreMusicState();
- void playLeadOut(uint8 *leadOut);
- int32 MusicTimeRemaining();
- int32 ReverseStereo(void);
- uint8 GetFxVolume(void);
- uint8 GetSpeechVolume(void);
- uint8 GetMusicVolume(void);
- uint8 IsMusicMute(void);
- uint8 IsFxMute(void);
- uint8 IsSpeechMute(void);
- void StopMusic(void);
- void SetFxVolume(uint8 vol);
- void SetSpeechVolume(uint8 vol);
- void SetMusicVolume(uint8 vol);
- void MuteMusic(uint8 mute);
- void MuteFx(uint8 mute);
- void MuteSpeech(uint8 mute);
- int32 IsFxOpen(int32 id);
- int32 SetFxVolumePan(int32 id, uint8 vol, int8 pan);
- int32 SetFxIdVolume(int32 id, uint8 vol);
- void UpdateCompSampleStreaming(int16 *data, uint len);
- SoundMixer *_mixer;
- private:
- int32 StreamCompMusicFromLock(const char *filename, uint32 musicId, bool looping);
- int32 GetFxIndex(int32 id);
- int32 DipMusic();
-
- OSystem::MutexRef _mutex;
- RateConverter *_converter;
-
- 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;
- uint8 speechStatus;
- uint8 fxPaused;
- uint8 speechPaused;
- uint8 speechVol;
- uint8 fxVol;
- uint8 speechMuted;
- uint8 fxMuted;
-
- PlayingSoundHandle soundHandleSpeech;
- uint8 musicMuted;
-};
+private:
+ SoundMixer *_mixer;
+
+ OSystem::MutexRef _mutex;
+ RateConverter *_converter;
+
+ 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;
+ uint8 _speechStatus;
+ uint8 _fxPaused;
+ uint8 _speechPaused;
+ uint8 _speechVol;
+ uint8 _fxVol;
+ uint8 _speechMuted;
+ uint8 _fxMuted;
+ PlayingSoundHandle _soundHandleSpeech;
+ uint8 _musicMuted;
+
+ int32 getFxIndex(int32 id);
+ int32 dipMusic();
+
+ void updateCompSampleStreaming(int16 *data, uint len);
+
+public:
+ Sword2Sound(SoundMixer *mixer);
+ ~Sword2Sound();
+ void fxServer(int16 *data, uint len);
+ int32 playCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
+ uint32 preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf);
+ int32 amISpeaking();
+ int32 stopSpeech(void);
+ int32 getSpeechStatus(void);
+ void pauseSpeech(void);
+ void unpauseSpeech(void);
+ int32 openFx(int32 id, uint8 *data);
+ int32 playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
+ int32 closeFx(int32 id);
+ void clearAllFx(void);
+ void pauseFx(void);
+ void pauseFxForSequence(void);
+ void unpauseFx(void);
+ void pauseMusic(void);
+ void unpauseMusic(void);
+ int32 streamCompMusic(const char *filename, uint32 musicId, bool looping);
+ void saveMusicState();
+ void restoreMusicState();
+ void playLeadOut(uint8 *leadOut);
+ int32 musicTimeRemaining();
+ void reverseStereo(void);
+ uint8 getFxVolume(void);
+ uint8 getSpeechVolume(void);
+ uint8 getMusicVolume(void);
+ uint8 isMusicMute(void);
+ uint8 isFxMute(void);
+ uint8 isSpeechMute(void);
+ void stopMusic(void);
+ void setFxVolume(uint8 vol);
+ void setSpeechVolume(uint8 vol);
+ void setMusicVolume(uint8 vol);
+ void muteMusic(uint8 mute);
+ void muteFx(uint8 mute);
+ void muteSpeech(uint8 mute);
+ int32 isFxOpen(int32 id);
+ int32 setFxIdVolumePan(int32 id, uint8 vol, int8 pan);
+ int32 setFxIdVolume(int32 id, uint8 vol);
+};
#endif
diff --git a/sword2/function.cpp b/sword2/function.cpp
index e1557bdd84..5480f3fe7d 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -398,9 +398,9 @@ int32 FN_play_credits(int32 *params) {
g_sound->saveMusicState();
- g_sound->MuteFx(1);
- g_sound->MuteSpeech(1);
- g_sound->StopMusic();
+ g_sound->muteFx(1);
+ g_sound->muteSpeech(1);
+ g_sound->stopMusic();
memcpy(oldPal, palCopy, 1024);
memset(tmpPal, 0, 1024);
@@ -421,13 +421,13 @@ int32 FN_play_credits(int32 *params) {
pars[1] = FX_SPOT;
FN_play_music(pars);
- music_length = 1000 * g_sound->MusicTimeRemaining();
+ music_length = 1000 * g_sound->musicTimeRemaining();
debug(0, "Credits music length: ~%d ms", music_length);
CloseMenuImmediately();
- while (g_sound->MusicTimeRemaining()) {
+ while (g_sound->musicTimeRemaining()) {
EraseBackBuffer();
SetNeedRedraw();
@@ -454,8 +454,8 @@ int32 FN_play_credits(int32 *params) {
Build_display();
WaitForFade();
- g_sound->MuteFx(0);
- g_sound->MuteSpeech(0);
+ g_sound->muteFx(0);
+ g_sound->muteSpeech(0);
}
// FIXME: This probably isn't the correct way of shutting down ScummVM
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 9581075ac2..0cea0783ac 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -171,7 +171,6 @@ void System_menu(void) {
_mouseEvent *me;
int j, hit;
uint8 *icon;
- uint32 rv; // for drivers return value
int32 pars[2];
uint32 icon_list[5] = {
OPTIONS_ICON,
@@ -215,9 +214,7 @@ void System_menu(void) {
}
}
- rv = g_sound->PauseFx();
- if (rv != RD_OK)
- debug(5, "ERROR: PauseFx() returned %.8x in SystemMenu()", rv);
+ g_sound->pauseFx();
// NB. Need to keep a safe copy of
// 'looping_music_id' for savegame & for
@@ -282,7 +279,6 @@ void System_menu(void) {
if (this_screen.new_palette != 99) {
// '0' means put back game screen
// palette; see Build_display.cpp
- // (James17jun97)
SetFullPalette(0);
@@ -293,9 +289,7 @@ void System_menu(void) {
} else
this_screen.new_palette = 1;
- rv = g_sound->UnpauseFx();
- if (rv != RD_OK)
- debug(5, "ERROR: UnpauseFx() returned %.8x in SystemMenu()", rv);
+ g_sound->unpauseFx();
// If there was looping music before coming
// into the control panels then restart it!
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index b35baa3589..ae3eb43de9 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -91,7 +91,7 @@ void Process_fx_queue(void) {
break;
case FX_SPOT2:
// Once the Fx has finished remove it from the queue.
- if (g_sound->IsFxOpen(j + 1))
+ if (g_sound->isFxOpen(j + 1))
fxq[j].resource = 0;
break;
}
@@ -112,7 +112,7 @@ void Trigger_fx(uint8 j) {
data = res_man.open(fxq[j].resource);
data += sizeof(_standardHeader);
// wav data gets copied to sound memory
- rv = g_sound->PlayFx(id, data, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT);
+ rv = g_sound->playFx(id, data, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT);
// release the sample
res_man.close(fxq[j].resource);
} else {
@@ -122,15 +122,15 @@ void Trigger_fx(uint8 j) {
if (fxq[j].type == FX_RANDOM) {
// Not looped
- rv = g_sound->PlayFx(id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT);
+ rv = g_sound->playFx(id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT);
} else {
// Looped
- rv = g_sound->PlayFx(id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXLOOP);
+ rv = g_sound->playFx(id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXLOOP);
}
}
if (rv)
- debug(5, "SFX ERROR: PlayFx() returned %.8x", rv);
+ debug(5, "SFX ERROR: playFx() returned %.8x", rv);
}
// called from script only
@@ -231,10 +231,10 @@ int32 FN_play_fx(int32 *params) {
data += sizeof(_standardHeader);
// copy it to sound memory, using position in queue as 'id'
- rv = g_sound->OpenFx(id, data);
+ rv = g_sound->openFx(id, data);
if (rv)
- debug(5, "SFX ERROR: OpenFx() returned %.8x", rv);
+ debug(5, "SFX ERROR: openFx() returned %.8x", rv);
// release the sample
res_man.close(fxq[j].resource);
@@ -269,9 +269,9 @@ int32 FN_set_fx_vol_and_pan(int32 *params) {
debug(5, "FN_set_fx_vol_and_pan(%d, %d, %d)", params[0], params[1], params[2]);
- // SetFxVolumePan(int32 id, uint8 vol, uint8 pan);
+ // setFxIdVolumePan(int32 id, uint8 vol, uint8 pan);
// driver fx_id is 1 + <pos in queue>
- g_sound->SetFxVolumePan(1 + params[0], params[1], params[2]);
+ g_sound->setFxIdVolumePan(1 + params[0], params[1], params[2]);
return IR_CONT;
}
@@ -283,7 +283,7 @@ int32 FN_set_fx_vol(int32 *params) {
// 1 new volume (0..16)
// SetFxIdVolume(int32 id, uint8 vol);
- g_sound->SetFxIdVolume(1 + params[0], params[1]);
+ g_sound->setFxIdVolume(1 + params[0], params[1]);
return IR_CONT;
}
@@ -304,10 +304,10 @@ int32 FN_stop_fx(int32 *params) {
id = (uint32) j + 1; // because 0 is not a valid id
// stop fx & remove sample from sound memory
- rv = g_sound->CloseFx(id);
+ rv = g_sound->closeFx(id);
if (rv)
- debug(5, "SFX ERROR: CloseFx() returned %.8x", rv);
+ debug(5, "SFX ERROR: closeFx() returned %.8x", rv);
}
// remove from queue
@@ -330,34 +330,12 @@ int32 FN_stop_all_fx(int32 *params) {
void Clear_fx_queue(void) {
// stop all fx & remove the samples from sound memory
- g_sound->ClearAllFx();
+ g_sound->clearAllFx();
// clean out the queue
Init_fx_queue();
}
-// ===========================================================================
-// int32 StreamMusic(uint8 *filename, int32 loopFlag)
-//
-// Streams music from the file defined by filename. The loopFlag should
-// be set to RDSE_FXLOOP if the music is to loop back to the start.
-// Otherwise, it should be RDSE_FXSPOT.
-// The return value must be checked for any problems.
-//
-// ---------------------------------------------------------------------------
-//
-// int32 PauseMusic(void)
-//
-// Stops the music dead in it's tracks.
-//
-// ---------------------------------------------------------------------------
-//
-// int32 UnpauseMusic(void)
-//
-// Re-starts the music from where it was stopped.
-//
-// ===========================================================================
-
int32 FN_prepare_music(int32 *params) {
return IR_CONT;
}
@@ -406,10 +384,10 @@ int32 FN_play_music(int32 *params) {
strcpy(filename, "music.clu");
}
- rv = g_sound->StreamCompMusic(filename, params[0], loopFlag);
+ rv = g_sound->streamCompMusic(filename, params[0], loopFlag);
if (rv)
- debug(5, "ERROR: StreamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv);
+ debug(5, "ERROR: streamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv);
return IR_CONT;
}
@@ -418,13 +396,13 @@ int32 FN_stop_music(int32 *params) { // called from script only
// params: none
looping_music_id = 0; // clear the 'looping' flag
- g_sound->StopMusic();
+ g_sound->stopMusic();
return IR_CONT;
}
void Kill_music(void) { // James22aug97
looping_music_id = 0; // clear the 'looping' flag
- g_sound->StopMusic();
+ g_sound->stopMusic();
}
int32 FN_check_music_playing(int32 *params) {
@@ -434,39 +412,19 @@ int32 FN_check_music_playing(int32 *params) {
// or 0 if no music playing
// in seconds, rounded up to the nearest second
- RESULT = g_sound->MusicTimeRemaining();
+ RESULT = g_sound->musicTimeRemaining();
return IR_CONT;
}
void PauseAllSound(void) {
- uint32 rv;
-
- rv = g_sound->PauseMusic();
- if (rv != RD_OK)
- debug(5, "ERROR: PauseMusic() returned %.8x in PauseAllSound()", rv);
-
- rv = g_sound->PauseSpeech();
- if (rv != RD_OK)
- debug(5, "ERROR: PauseSpeech() returned %.8x in PauseAllSound()", rv);
-
- rv = g_sound->PauseFx();
- if (rv != RD_OK)
- debug(5, "ERROR: PauseFx() returned %.8x in PauseAllSound()", rv);
+ g_sound->pauseMusic();
+ g_sound->pauseSpeech();
+ g_sound->pauseFx();
}
void UnpauseAllSound(void) {
- uint32 rv;
-
- rv = g_sound->UnpauseMusic();
- if (rv != RD_OK)
- debug(5, "ERROR: UnpauseMusic() returned %.8x in UnpauseAllSound()", rv);
-
- rv = g_sound->UnpauseSpeech();
- if (rv != RD_OK)
- debug(5, "ERROR: UnpauseSpeech() returned %.8x in UnpauseAllSound()", rv);
-
- rv = g_sound->UnpauseFx();
- if (rv != RD_OK)
- debug(5, "ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv);
+ g_sound->unpauseMusic();
+ g_sound->unpauseSpeech();
+ g_sound->unpauseFx();
}
diff --git a/sword2/speech.cpp b/sword2/speech.cpp
index fddcb59f4f..ba6c4ce57b 100644
--- a/sword2/speech.cpp
+++ b/sword2/speech.cpp
@@ -968,7 +968,7 @@ int32 FN_i_speak(int32 *params) {
// New fudge to wait for smacker samples to finish
// since they can over-run into the game
- if (g_sound->GetSpeechStatus() != RDSE_SAMPLEFINISHED)
+ if (g_sound->getSpeechStatus() != RDSE_SAMPLEFINISHED)
return IR_REPEAT;
// New fudge for 'fx' subtitles
@@ -1199,7 +1199,7 @@ int32 FN_i_speak(int32 *params) {
strcpy(speechFile, "speech.clu");
// Load speech but don't start playing yet
- rv = g_sound->PlayCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan);
+ rv = g_sound->playCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan);
if (rv == RD_OK) {
// ok, we've got something to play
// (2 means not playing yet - see below)
@@ -1207,7 +1207,7 @@ int32 FN_i_speak(int32 *params) {
// set it playing now (we might want to do
// this next cycle, don't know yet)
- g_sound->UnpauseSpeech();
+ g_sound->unpauseSpeech();
} else {
debug(5, "ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv);
}
@@ -1247,7 +1247,7 @@ int32 FN_i_speak(int32 *params) {
// if playing a sample
if (!unpause_zone) {
// if we're at a quiet bit
- if (g_sound->AmISpeaking() == RDSE_QUIET) {
+ if (g_sound->amISpeaking() == RDSE_QUIET) {
// restart from frame 0
// ('closed mouth' frame)
ob_graphic->anim_pc = 0;
@@ -1277,11 +1277,11 @@ int32 FN_i_speak(int32 *params) {
// if playing a sample (note that value of '2' means about to play!)
- if (speechRunning==1) {
+ if (speechRunning == 1) {
if (!unpause_zone) {
- // has it finished? James25feb97
- if (g_sound->GetSpeechStatus() == RDSE_SAMPLEFINISHED)
- speechFinished=1;
+ // has it finished?
+ if (g_sound->getSpeechStatus() == RDSE_SAMPLEFINISHED)
+ speechFinished = 1;
} else
unpause_zone--;
} else if (speechRunning == 0 && speech_time) {
@@ -1289,7 +1289,7 @@ int32 FN_i_speak(int32 *params) {
// ends the speech
// if no sample then we're using speech_time to end speech
- // naturally James25feb97
+ // naturally
speech_time--;
if (!speech_time)
@@ -1315,7 +1315,7 @@ int32 FN_i_speak(int32 *params) {
// mouse click, after click_delay has expired -> end the speech
// we ignore mouse releases
-#ifdef _SWORD2_DEBUG // (James26jun97)
+#ifdef _SWORD2_DEBUG
// if testing text & speech
if (SYSTEM_TESTING_TEXT) {
// and RB used to click past text
@@ -1334,12 +1334,12 @@ int32 FN_i_speak(int32 *params) {
me = MouseEvent();
} while (me);
- speechFinished = 1; // James25feb97
+ speechFinished = 1;
// if speech sample playing
if (speechRunning) {
// halt the sample prematurely
- g_sound->StopSpeechSword2();
+ g_sound->stopSpeech();
}
}
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index 4009f3451b..3c778b8d5a 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -255,8 +255,8 @@ uint32 Con_start(uint8 *input) {
FN_stop_music(NULL);
// halt the sample prematurely
- g_sound->UnpauseSpeech();
- g_sound->StopSpeechSword2();
+ g_sound->unpauseSpeech();
+ g_sound->stopSpeech();
// clean out all resources & flags, ready for a total
// restart (James24mar97)