aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorJonathan Gray2003-07-29 12:34:46 +0000
committerJonathan Gray2003-07-29 12:34:46 +0000
commitf1a6025aa2a8b6c99798e0738eaca4c844933c20 (patch)
tree3e97dd16c86c96e4cbd60ee77437d46e442a567c /sword2
parent11aa36ff90be9c0cee214a7fb2a15f9e97bef918 (diff)
downloadscummvm-rg350-f1a6025aa2a8b6c99798e0738eaca4c844933c20.tar.gz
scummvm-rg350-f1a6025aa2a8b6c99798e0738eaca4c844933c20.tar.bz2
scummvm-rg350-f1a6025aa2a8b6c99798e0738eaca4c844933c20.zip
turn d_sound.cpp into class BS2Sound
svn-id: r9280
Diffstat (limited to 'sword2')
-rw-r--r--sword2/anims.cpp10
-rw-r--r--sword2/controls.cpp82
-rw-r--r--sword2/driver/d_sound.cpp165
-rw-r--r--sword2/driver/d_sound.h93
-rw-r--r--sword2/driver/driver96.h45
-rw-r--r--sword2/function.cpp3
-rw-r--r--sword2/mouse.cpp4
-rw-r--r--sword2/sound.cpp41
-rw-r--r--sword2/speech.cpp12
-rw-r--r--sword2/startup.cpp4
-rw-r--r--sword2/sword2.cpp6
-rw-r--r--sword2/sword2.h2
12 files changed, 249 insertions, 218 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index 918a2ae54e..cd31e429fd 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -601,7 +601,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) // (James23may97)
}
//------------------------------
- wavSize = GetCompSpeechSize(speechFile, wavId); // returns size of decompressed wav, or 0 if wav not found
+ wavSize = g_bs2->_sound->GetCompSpeechSize(speechFile, wavId); // returns size of decompressed wav, or 0 if wav not found
if (wavSize) // if we've got the wav
{
// allocate memory for speech buffer
@@ -609,7 +609,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) // (James23may97)
if (sequence_text_list[line].speech_mem) // if mem allocated ok (should be fine, but worth checking)
{
- if (PreFetchCompSpeech(speechFile, wavId, sequence_text_list[line].speech_mem->ad) == RD_OK) // Load speech & decompress to our buffer
+ if (g_bs2->_sound->PreFetchCompSpeech(speechFile, wavId, sequence_text_list[line].speech_mem->ad) == RD_OK) // Load speech & decompress to our buffer
{
Float_mem (sequence_text_list[line].speech_mem); // now float this buffer so we can make space for the next text sprites and/or speech samples
speechRunning=1; // ok, we've got speech!
@@ -722,7 +722,7 @@ int32 FN_smacker_lead_in(int32 *params) // James(21july97)
//-----------------------------------------
leadIn += sizeof(_standardHeader);
- rv = PlayFx( 0, leadIn, 0, 0, RDSE_FXLEADIN ); // wav data gets copied to sound memory
+ rv = g_bs2->_sound->PlayFx( 0, leadIn, 0, 0, RDSE_FXLEADIN ); // wav data gets copied to sound memory
//-----------------------------------------
#ifdef _BS2_DEBUG
@@ -840,7 +840,7 @@ int32 FN_play_sequence(int32 *params) // James(09apr97)
// play the smacker
FN_stop_music(NULL); // don't want to carry on streaming game music when smacker starts!
- PauseFxForSequence(); // pause sfx during sequence, except the one used for lead-in music
+ g_bs2->_sound->PauseFxForSequence(); // pause sfx during sequence, except the one used for lead-in music
if (sequenceTextLines) // if we have some text to accompany this sequence
rv = PlaySmacker(filename, sequenceSpeechArray, leadOut);
@@ -857,7 +857,7 @@ int32 FN_play_sequence(int32 *params) // James(09apr97)
}
*/
- UnpauseFx(); // unpause sound fx again, in case we're staying in same location
+ g_bs2->_sound->UnpauseFx(); // unpause sound fx again, in case we're staying in same location
//--------------------------------------
// close the lead-out music resource
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 2745c7e560..3c004427ab 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -1929,12 +1929,12 @@ int32 ReadOptionSettings(void) //pete10Jun97
fclose(fp);
- SetMusicVolume(buff[0]);
- SetSpeechVolume(buff[1]);
- SetFxVolume(buff[2]);
- MuteMusic(buff[3]);
- MuteSpeech(buff[4]);
- MuteFx(buff[5]);
+ g_bs2->_sound->SetMusicVolume(buff[0]);
+ g_bs2->_sound->SetSpeechVolume(buff[1]);
+ g_bs2->_sound->SetFxVolume(buff[2]);
+ g_bs2->_sound->MuteMusic(buff[3]);
+ g_bs2->_sound->MuteSpeech(buff[4]);
+ g_bs2->_sound->MuteFx(buff[5]);
UpdateGraphicsLevel(GetRenderType(), buff[6]); // (James13jun97)
@@ -1944,7 +1944,7 @@ int32 ReadOptionSettings(void) //pete10Jun97
pointerTextSelected = buff[8];
if (buff[9] != stereoReversed)
- ReverseStereo();
+ g_bs2->_sound->ReverseStereo();
stereoReversed = buff[9];
@@ -1956,12 +1956,12 @@ int32 WriteOptionSettings(void) //pete10Jun97
uint8 buff[10];
FILE *fp;
- buff[0] = GetMusicVolume();
- buff[1] = GetSpeechVolume();
- buff[2] = GetFxVolume();
- buff[3] = IsMusicMute();
- buff[4] = IsSpeechMute();
- buff[5] = IsFxMute();
+ buff[0] = g_bs2->_sound->GetMusicVolume();
+ buff[1] = g_bs2->_sound->GetSpeechVolume();
+ buff[2] = g_bs2->_sound->GetFxVolume();
+ buff[3] = g_bs2->_sound->IsMusicMute();
+ buff[4] = g_bs2->_sound->IsSpeechMute();
+ buff[5] = g_bs2->_sound->IsFxMute();
buff[6] = GetRenderType();
buff[7] = subtitles;
buff[8] = pointerTextSelected;
@@ -2094,9 +2094,9 @@ void Option_control(void) //Pete6Jun97
int title_len, subtitle_len, ok_len, cancel_len, left_align, test_len;
// slider values
- uint8 musicVolume = GetMusicVolume();
- uint8 speechVolume = GetSpeechVolume();
- uint8 fxVolume = GetFxVolume();
+ uint8 musicVolume = g_bs2->_sound->GetMusicVolume();
+ uint8 speechVolume = g_bs2->_sound->GetSpeechVolume();
+ uint8 fxVolume = g_bs2->_sound->GetFxVolume();
uint8 grfxLevel = GetRenderType();
// safe slider values for restoring on cancel
@@ -2197,9 +2197,9 @@ void Option_control(void) //Pete6Jun97
uint8 subtitle_state = subtitles;
uint8 stereo_state = stereoReversed;
- uint8 music_mute_state = IsMusicMute();
- uint8 speech_mute_state = IsSpeechMute();
- uint8 fx_mute_state = IsFxMute();
+ uint8 music_mute_state = g_bs2->_sound->IsMusicMute();
+ uint8 speech_mute_state = g_bs2->_sound->IsSpeechMute();
+ uint8 fx_mute_state = g_bs2->_sound->IsFxMute();
//build the button surfaces surfaces
@@ -2359,19 +2359,19 @@ void Option_control(void) //Pete6Jun97
}
if (!music_mute_state)
- SetMusicVolume(musicVolume);
+ g_bs2->_sound->SetMusicVolume(musicVolume);
else
- SetMusicVolume(0);
+ g_bs2->_sound->SetMusicVolume(0);
if (!fx_mute_state)
- SetFxVolume(fxVolume);
+ g_bs2->_sound->SetFxVolume(fxVolume);
else
- SetFxVolume(0);
+ g_bs2->_sound->SetFxVolume(0);
if (!speech_mute_state)
- SetSpeechVolume(speechVolume);
+ g_bs2->_sound->SetSpeechVolume(speechVolume);
else
- SetSpeechVolume(0);
+ g_bs2->_sound->SetSpeechVolume(0);
//--------------------------------------------------
// Service windows
@@ -2555,19 +2555,19 @@ void Option_control(void) //Pete6Jun97
{
UpdateGraphicsLevel(safe_grfxLevel, grfxLevel); // (James13jun97)
- MuteMusic(music_mute_state); // Ensure all the levels are recorded correctly (Pete21Aug97)
- MuteSpeech(speech_mute_state);
- MuteFx(fx_mute_state);
- SetMusicVolume(music_target);
- SetSpeechVolume(speech_target);
- SetFxVolume(fx_target);
+ g_bs2->_sound->MuteMusic(music_mute_state); // Ensure all the levels are recorded correctly (Pete21Aug97)
+ g_bs2->_sound->MuteSpeech(speech_mute_state);
+ g_bs2->_sound->MuteFx(fx_mute_state);
+ g_bs2->_sound->SetMusicVolume(music_target);
+ g_bs2->_sound->SetSpeechVolume(speech_target);
+ g_bs2->_sound->SetFxVolume(fx_target);
subtitles = subtitle_state; // Save object label and subtitle settings
pointerTextSelected = object_state;
speechSelected = !speech_mute_state;
if (stereo_state != stereoReversed)
- ReverseStereo();
+ g_bs2->_sound->ReverseStereo();
stereoReversed = stereo_state;
WriteOptionSettings();
@@ -2591,17 +2591,17 @@ void Option_control(void) //Pete6Jun97
if (touching_music_mute && dmusic_mute_state) {
music_mute_state = dmusic_mute_state = 0; // if the button was in now let it out
- MuteMusic(0);
+ g_bs2->_sound->MuteMusic(0);
}
if (touching_fx_mute && dfx_mute_state) {
fx_mute_state = dfx_mute_state = 0; // if the button was in now let it out
- MuteFx(0);
+ g_bs2->_sound->MuteFx(0);
}
if (touching_speech_mute && dspeech_mute_state) {
speech_mute_state = dspeech_mute_state = 0; // if the button was in now let it out
- MuteSpeech(0);
+ g_bs2->_sound->MuteSpeech(0);
}
// Stop tracking any sliders
@@ -2649,7 +2649,7 @@ void Option_control(void) //Pete6Jun97
else
{
music_mute_state = 1;
- MuteMusic(1);
+ g_bs2->_sound->MuteMusic(1);
}
}
@@ -2660,7 +2660,7 @@ void Option_control(void) //Pete6Jun97
else
{
fx_mute_state=1;
- MuteFx(1);
+ g_bs2->_sound->MuteFx(1);
}
}
@@ -2671,7 +2671,7 @@ void Option_control(void) //Pete6Jun97
else
{
speech_mute_state=1;
- MuteSpeech(1);
+ g_bs2->_sound->MuteSpeech(1);
}
}
@@ -2680,7 +2680,7 @@ void Option_control(void) //Pete6Jun97
if (music_mute_state)
{
music_mute_state = 0;
- MuteMusic(0);
+ g_bs2->_sound->MuteMusic(0);
}
if (mousex>(slab_sprite[0].x+SLIDER_W))
@@ -2707,7 +2707,7 @@ void Option_control(void) //Pete6Jun97
if (speech_mute_state)
{
speech_mute_state = 0;
- MuteSpeech(0);
+ g_bs2->_sound->MuteSpeech(0);
}
if (mousex>(slab_sprite[1].x+SLIDER_W))
@@ -2734,7 +2734,7 @@ void Option_control(void) //Pete6Jun97
if (fx_mute_state)
{
fx_mute_state = 0;
- MuteFx(0);
+ g_bs2->_sound->MuteFx(0);
}
if (mousex>(slab_sprite[2].x+SLIDER_W))
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index cc88f6aac0..6fb8ac6274 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -358,6 +358,7 @@
#include "stdafx.h"
#include "driver96.h"
#include "rdwin.h" // for hwnd.
+#include "d_sound.h"
// Decompression macros
#define MakeCompressedByte(shift,sign,amplitude) (((shift)<<4) + ((sign)<<3) + (amplitude))
@@ -366,6 +367,13 @@
#define GetCompressedAmplitude(byte) ((byte) & 7)
#define GetdAPower(dA,power) for (power = 15;power>0 && !((dA) & (1<<power)); power--)
+/*
+LPDIRECTSOUND lpDS;
+LPDIRECTSOUNDBUFFER dsbPrimary;
+LPDIRECTSOUNDBUFFER dsbSpeech;
+LPDIRECTSOUNDBUFFER dsbFx[MAXFX];
+*/
+
int32 panTable[33] = {
-10000,
-1500, -1400, -1300, -1200,
@@ -387,46 +395,6 @@ int32 volTable[241] = {
};
-/*
-LPDIRECTSOUND lpDS;
-LPDIRECTSOUNDBUFFER dsbPrimary;
-LPDIRECTSOUNDBUFFER dsbSpeech;
-LPDIRECTSOUNDBUFFER dsbFx[MAXFX];
-*/
-
-int32 fxId[MAXFX];
-uint8 fxCached[MAXFX];
-uint8 fxiPaused[MAXFX];
-uint8 fxLooped[MAXFX];
-uint8 fxVolume[MAXFX];
-
-uint8 soundOn = 0;
-uint8 speechStatus = 0;
-uint8 fxPaused = 0;
-uint8 speechPaused = 0;
-uint8 speechVol = 14;
-uint8 fxVol = 14;
-uint8 speechMuted = 0;
-uint8 fxMuted = 0;
-uint8 compressedMusic = 0;
-
-int16 musStreaming[MAXMUS];
-int16 musicPaused[MAXMUS];
-int16 musCounter[MAXMUS];
-int16 musFading[MAXMUS];
-int16 musLooping[MAXMUS];
-//DSBUFFERDESC dsbdMus[MAXMUS];
-//LPDIRECTSOUNDBUFFER lpDsbMus[MAXMUS];
-FILE *fpMus[MAXMUS];
-//PCMWAVEFORMAT wfMus[MAXMUS];
-int32 streamCursor[MAXMUS];
-char musFilename[MAXMUS][256];
-int32 musFilePos[MAXMUS];
-int32 musEnd[MAXMUS];
-int16 musLastSample[MAXMUS];
-uint32 musId[MAXMUS];
-uint32 volMusic[2] = {16, 16};
-uint8 musicMuted = 0;
int32 musicVolTable[17] = {
-10000,
-5000, -3000, -2500, -2250,
@@ -437,10 +405,25 @@ int32 musicVolTable[17] = {
-void UpdateSampleStreaming(void);
-void UpdateCompSampleStreaming(void);
-int32 DipMusic(void);
+BS2Sound::BS2Sound(void) {
+
+ soundOn = 0;
+ speechStatus = 0;
+ fxPaused = 0;
+ speechPaused = 0;
+ speechVol = 14;
+ fxVol = 14;
+ speechMuted = 0;
+ fxMuted = 0;
+ compressedMusic = 0;
+ volMusic[0] = 16;
+ volMusic[1] = 16;
+ musicMuted = 0;
+
+}
+
+/* not used seemingly - khalek
#define SPEECH_EXPANSION
@@ -473,12 +456,12 @@ int16 ExpandSpeech(int16 sample)
}
#endif
-
+*/
// --------------------------------------------------------------------------
// This function reverse the pan table, thus reversing the stereo.
// --------------------------------------------------------------------------
-int32 ReverseStereo(void)
+int32 BS2Sound::ReverseStereo(void)
{
int32 i,j;
@@ -497,7 +480,7 @@ int32 ReverseStereo(void)
// --------------------------------------------------------------------------
// This function returns the index of the sound effect with the ID passed in.
// --------------------------------------------------------------------------
-int32 GetFxIndex(int32 id)
+int32 BS2Sound::GetFxIndex(int32 id)
{
@@ -515,7 +498,7 @@ int32 GetFxIndex(int32 id)
}
-int32 IsFxOpen(int32 id)
+int32 BS2Sound::IsFxOpen(int32 id)
{
int32 i = 0;
@@ -540,7 +523,7 @@ int32 IsFxOpen(int32 id)
// out the ones which are no longer required in a buffer. It is called on
// a slow timer from rdwin.c
// --------------------------------------------------------------------------
-void FxServer(void)
+void BS2Sound::FxServer(void)
{
warning("stub FxServer");
@@ -603,7 +586,7 @@ void FxServer(void)
-int32 InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth)
+int32 BS2Sound::InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth)
{
warning("stub InitaliseSound( %d, %d, %d )", freq, channels, bitDepth);
@@ -689,7 +672,7 @@ int32 InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth)
}
-int32 PlaySpeech(uint8 *data, uint8 vol, int8 pan)
+int32 BS2Sound::PlaySpeech(uint8 *data, uint8 vol, int8 pan)
{
warning("stub PlaySpeech");
@@ -793,7 +776,7 @@ int32 PlaySpeech(uint8 *data, uint8 vol, int8 pan)
}
-int32 AmISpeaking()
+int32 BS2Sound::AmISpeaking()
{
warning("stub AmISpeaking");
/*
@@ -837,7 +820,7 @@ int32 AmISpeaking()
}
-int32 GetCompSpeechSize(const char *filename, uint32 speechid)
+int32 BS2Sound::GetCompSpeechSize(const char *filename, uint32 speechid)
{
int32 i;
uint32 speechIndex[2];
@@ -874,7 +857,7 @@ int32 GetCompSpeechSize(const char *filename, uint32 speechid)
}
-int32 PreFetchCompSpeech(const char *filename, uint32 speechid, uint8 *waveMem)
+int32 BS2Sound::PreFetchCompSpeech(const char *filename, uint32 speechid, uint8 *waveMem)
{
uint32 i;
uint16 *data16;
@@ -968,7 +951,7 @@ int32 PreFetchCompSpeech(const char *filename, uint32 speechid, uint8 *waveMem)
}
-int32 PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan)
+int32 BS2Sound::PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan)
{
warning("stub PlayCompSpeech( %s, %d, %d, %d )", filename, speechid, vol, pan);
/*
@@ -1131,7 +1114,7 @@ int32 PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan)
}
-int32 StopSpeechBS2(void)
+int32 BS2Sound::StopSpeechBS2(void)
{
warning("stub StopSpeechBS2");
@@ -1163,7 +1146,7 @@ int32 StopSpeechBS2(void)
-int32 GetSpeechStatus(void)
+int32 BS2Sound::GetSpeechStatus(void)
{
warning("stub GetSpeechStatus");
/*
@@ -1192,7 +1175,7 @@ int32 GetSpeechStatus(void)
}
-void SetSpeechVolume(uint8 volume)
+void BS2Sound::SetSpeechVolume(uint8 volume)
{
warning("stub SetSpeechVolume");
/*
@@ -1203,13 +1186,13 @@ void SetSpeechVolume(uint8 volume)
}
-uint8 GetSpeechVolume()
+uint8 BS2Sound::GetSpeechVolume()
{
return speechVol;
}
-void MuteSpeech(uint8 mute)
+void BS2Sound::MuteSpeech(uint8 mute)
{
warning("stub MuteSpeech( %d )", mute);
/*
@@ -1226,13 +1209,13 @@ void MuteSpeech(uint8 mute)
}
-uint8 IsSpeechMute(void)
+uint8 BS2Sound::IsSpeechMute(void)
{
return (speechMuted);
}
-int32 PauseSpeech(void)
+int32 BS2Sound::PauseSpeech(void)
{
warning("PauseSpeech");
/*
@@ -1245,7 +1228,7 @@ int32 PauseSpeech(void)
return(RD_OK);
}
-int32 UnpauseSpeech(void)
+int32 BS2Sound::UnpauseSpeech(void)
{
warning("UnpauseSpeech");
/*
@@ -1259,7 +1242,7 @@ int32 UnpauseSpeech(void)
}
-int32 OpenFx(int32 id, uint8 *data)
+int32 BS2Sound::OpenFx(int32 id, uint8 *data)
{
warning("stub OpenFx( %d )", id);
@@ -1374,7 +1357,7 @@ int32 OpenFx(int32 id, uint8 *data)
}
-int32 PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type)
+int32 BS2Sound::PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type)
{
warning("stub PlayFx( %d, %d, %d, %d )", id, vol, pan, type);
@@ -1480,7 +1463,7 @@ int32 PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type)
}
-int32 SetFxVolumePan(int32 id, uint8 vol, int8 pan)
+int32 BS2Sound::SetFxVolumePan(int32 id, uint8 vol, int8 pan)
{
warning("stub SetFxVolumePan( %d, %d, %d )", id, vol, pan);
/*
@@ -1496,7 +1479,7 @@ int32 SetFxVolumePan(int32 id, uint8 vol, int8 pan)
return RD_OK;
}
-int32 SetFxIdVolume(int32 id, uint8 vol)
+int32 BS2Sound::SetFxIdVolume(int32 id, uint8 vol)
{
warning("stub SetFxIdVolume( %d, %d )", id, vol);
/*
@@ -1513,7 +1496,7 @@ int32 SetFxIdVolume(int32 id, uint8 vol)
-int32 ClearAllFx(void)
+int32 BS2Sound::ClearAllFx(void)
{
warning("stub ClearAllFx");
@@ -1548,7 +1531,7 @@ int32 ClearAllFx(void)
}
-int32 CloseFx(int32 id)
+int32 BS2Sound::CloseFx(int32 id)
{
warning("stub CloseFx( %d )", id);
@@ -1579,7 +1562,7 @@ int32 CloseFx(int32 id)
}
-int32 PauseFx(void)
+int32 BS2Sound::PauseFx(void)
{
warning("stub PauseFx");
@@ -1614,7 +1597,7 @@ int32 PauseFx(void)
}
-int32 PauseFxForSequence(void)
+int32 BS2Sound::PauseFxForSequence(void)
{
warning("stub PauseFxForSequence");
@@ -1649,7 +1632,7 @@ int32 PauseFxForSequence(void)
-int32 UnpauseFx(void)
+int32 BS2Sound::UnpauseFx(void)
{
warning("stub UnpauseFx");
@@ -1674,13 +1657,13 @@ int32 UnpauseFx(void)
-uint8 GetFxVolume()
+uint8 BS2Sound::GetFxVolume()
{
return fxVol;
}
-void SetFxVolume(uint8 volume)
+void BS2Sound::SetFxVolume(uint8 volume)
{
warning("stub SetFxVolume( %d )", volume);
/*
@@ -1697,7 +1680,7 @@ void SetFxVolume(uint8 volume)
}
-void MuteFx(uint8 mute)
+void BS2Sound::MuteFx(uint8 mute)
{
warning("stub MuteFx( %d )");
/*
@@ -1719,7 +1702,7 @@ void MuteFx(uint8 mute)
*/
}
-uint8 IsFxMute(void)
+uint8 BS2Sound::IsFxMute(void)
{
return (fxMuted);
}
@@ -1727,7 +1710,7 @@ uint8 IsFxMute(void)
-static void StartMusicFadeDown(int i)
+void BS2Sound::StartMusicFadeDown(int i)
{
@@ -1740,7 +1723,7 @@ static void StartMusicFadeDown(int i)
}
-int32 StreamMusic(uint8 *filename, int32 looping)
+int32 BS2Sound::StreamMusic(uint8 *filename, int32 looping)
{
warning("stub StreamMusic( %s, %d )", filename, looping);
@@ -1983,7 +1966,7 @@ int32 StreamMusic(uint8 *filename, int32 looping)
}
-void UpdateSampleStreaming(void)
+void BS2Sound::UpdateSampleStreaming(void)
{
warning("stub UpdateSampleStreaming");
@@ -2139,7 +2122,7 @@ void UpdateSampleStreaming(void)
-int32 StreamCompMusic(const char *filename, uint32 musicId, int32 looping)
+int32 BS2Sound::StreamCompMusic(const char *filename, uint32 musicId, int32 looping)
{
warning("stub StreamCompMusic( %s, %d, %d )", filename, musicId, looping);
/*
@@ -2550,7 +2533,7 @@ int32 StreamCompMusic(const char *filename, uint32 musicId, int32 looping)
}
-void UpdateCompSampleStreaming(void)
+void BS2Sound::UpdateCompSampleStreaming(void)
{
warning("stub UpdateCompSampleStreaming");
/*
@@ -2760,7 +2743,7 @@ void UpdateCompSampleStreaming(void)
*/
}
-int32 DipMusic()
+int32 BS2Sound::DipMusic()
{
warning("stub DipMusic");
/*
@@ -2835,7 +2818,7 @@ int32 DipMusic()
return RD_OK;
}
-int32 MusicTimeRemaining()
+int32 BS2Sound::MusicTimeRemaining()
{
warning("stub MusicTimeRemaaining");
/*
@@ -2862,7 +2845,7 @@ int32 MusicTimeRemaining()
-void StopMusic(void)
+void BS2Sound::StopMusic(void)
{
int32 i;
@@ -2897,7 +2880,7 @@ void StopMusic(void)
}
-int32 PauseMusic(void)
+int32 BS2Sound::PauseMusic(void)
{
warning("stub PauseMusic");
/*
@@ -2924,7 +2907,7 @@ int32 PauseMusic(void)
return(RD_OK);
}
-int32 UnpauseMusic(void)
+int32 BS2Sound::UnpauseMusic(void)
{
warning("stub UnpauseMusic");
/*
@@ -2949,7 +2932,7 @@ int32 UnpauseMusic(void)
}
-void SetMusicVolume(uint8 volume)
+void BS2Sound::SetMusicVolume(uint8 volume)
{
warning("stub SetMusicVolume( %d )", volume);
/*
@@ -2964,13 +2947,13 @@ void SetMusicVolume(uint8 volume)
}
-uint8 GetMusicVolume()
+uint8 BS2Sound::GetMusicVolume()
{
return (uint8) volMusic[0];
}
-void MuteMusic(uint8 mute)
+void BS2Sound::MuteMusic(uint8 mute)
{
warning("stub MuteMusic( %d )", mute);
/*
@@ -2998,14 +2981,14 @@ void MuteMusic(uint8 mute)
}
-uint8 IsMusicMute(void)
+uint8 BS2Sound::IsMusicMute(void)
{
return (musicMuted);
}
-void GetSoundStatus(_drvSoundStatus *s)
+void BS2Sound::GetSoundStatus(_drvSoundStatus *s)
{
int i;
@@ -3050,7 +3033,7 @@ void GetSoundStatus(_drvSoundStatus *s)
}
-void SetSoundStatus(_drvSoundStatus *s)
+void BS2Sound::SetSoundStatus(_drvSoundStatus *s)
{
int i;
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index 5281cf01c9..cdfc740650 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -38,6 +38,97 @@
#ifndef D_SOUND_H
#define D_SOUND_H
-extern void FxServer(void);
+#include "sound/mixer.h"
+
+class BS2Sound {
+ public:
+ BS2Sound(void);
+ void FxServer(void);
+ int32 InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth);
+ int32 PlaySpeech(uint8 *data, uint8 vol, int8 pan);
+ int32 PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
+ int32 PreFetchCompSpeech(const char *filename, uint32 speechid, uint8 *waveMem);
+ int32 GetCompSpeechSize(const char *filename, uint32 speechid);
+ int32 AmISpeaking();
+ int32 StopSpeechBS2(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 StreamMusic(uint8 *filename, int32 looping);
+ int32 StreamCompMusic(const char *filename,uint32 musicId, int32 looping);
+ 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 GetSoundStatus(_drvSoundStatus *s);
+ void SetSoundStatus(_drvSoundStatus *s);
+ 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(void);
+ SoundMixer *_mixer;
+ private:
+ int32 GetFxIndex(int32 id);
+ void StartMusicFadeDown(int i);
+ int32 DipMusic();
+ void UpdateSampleStreaming(void);
+
+ int32 fxId[MAXFX];
+ uint8 fxCached[MAXFX];
+ uint8 fxiPaused[MAXFX];
+ uint8 fxLooped[MAXFX];
+ uint8 fxVolume[MAXFX];
+
+ uint8 soundOn;
+ uint8 speechStatus;
+ uint8 fxPaused;
+ uint8 speechPaused;
+ uint8 speechVol;
+ uint8 fxVol;
+ uint8 speechMuted;
+ uint8 fxMuted;
+ uint8 compressedMusic;
+
+ int16 musStreaming[MAXMUS];
+ int16 musicPaused[MAXMUS];
+ int16 musCounter[MAXMUS];
+ int16 musFading[MAXMUS];
+ int16 musLooping[MAXMUS];
+
+ //DSBUFFERDESC dsbdMus[MAXMUS];
+ //LPDIRECTSOUNDBUFFER lpDsbMus[MAXMUS];
+ FILE *fpMus[MAXMUS];
+ //PCMWAVEFORMAT wfMus[MAXMUS];
+ int32 streamCursor[MAXMUS];
+ char musFilename[MAXMUS][256];
+ int32 musFilePos[MAXMUS];
+ int32 musEnd[MAXMUS];
+ int16 musLastSample[MAXMUS];
+ uint32 musId[MAXMUS];
+ uint32 volMusic[2];
+ uint8 musicMuted;
+
+};
+
#endif
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index e66e007cba..bff1dd29c4 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -1558,51 +1558,6 @@ extern int32 CloseMenuImmediately(void);
//-----------------------------------------------------------------------------
-// Sound driver functions - from d_sound.c
-//-----------------------------------------------------------------------------
-extern int32 InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth);
-extern int32 PlaySpeech(uint8 *data, uint8 vol, int8 pan);
-extern int32 PlayCompSpeech(const char *filename, uint32 speechid, uint8 vol, int8 pan);
-extern int32 PreFetchCompSpeech(const char *filename, uint32 speechid, uint8 *waveMem);
-extern int32 GetCompSpeechSize(const char *filename, uint32 speechid);
-extern int32 AmISpeaking();
-extern int32 StopSpeechBS2(void);
-extern int32 GetSpeechStatus(void);
-extern int32 PauseSpeech(void);
-extern int32 UnpauseSpeech(void);
-extern int32 OpenFx(int32 id, uint8 *data);
-extern int32 PlayFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type);
-extern int32 CloseFx(int32 id);
-extern int32 ClearAllFx(void);
-extern int32 PauseFx(void);
-extern int32 PauseFxForSequence(void);
-extern int32 UnpauseFx(void);
-extern int32 PauseMusic(void);
-extern int32 UnpauseMusic(void);
-extern int32 StreamMusic(uint8 *filename, int32 looping);
-extern int32 StreamCompMusic(const char *filename,uint32 musicId, int32 looping);
-extern int32 MusicTimeRemaining();
-extern int32 ReverseStereo(void);
-extern uint8 GetFxVolume(void);
-extern uint8 GetSpeechVolume(void);
-extern uint8 GetMusicVolume(void);
-extern uint8 IsMusicMute(void);
-extern uint8 IsFxMute(void);
-extern uint8 IsSpeechMute(void);
-extern void StopMusic(void);
-extern void GetSoundStatus(_drvSoundStatus *s);
-extern void SetSoundStatus(_drvSoundStatus *s);
-extern void SetFxVolume(uint8 vol);
-extern void SetSpeechVolume(uint8 vol);
-extern void SetMusicVolume(uint8 vol);
-extern void MuteMusic(uint8 mute);
-extern void MuteFx(uint8 mute);
-extern void MuteSpeech(uint8 mute);
-extern int32 IsFxOpen(int32 id);
-extern int32 SetFxVolumePan(int32 id, uint8 vol, int8 pan);
-extern int32 SetFxIdVolume(int32 id, uint8 vol);
-
-//-----------------------------------------------------------------------------
// Misc functions - from misc.cpp
//-----------------------------------------------------------------------------
extern uint32 SVM_timeGetTime(void);
diff --git a/sword2/function.cpp b/sword2/function.cpp
index 48b06f0812..80b4abb98a 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -412,7 +412,6 @@ int32 FN_reset_globals(int32 *params) //Tony29May97
// This function just quits the game if this is the playable demo, ie. credits are NOT played in the demo any more!
extern uint8 quitGame; // From sword2.cpp
-extern void UpdateCompSampleStreaming(void); // From d_sound.c
int32 FN_play_credits(int32 *params)
{
@@ -431,7 +430,7 @@ int32 FN_play_credits(int32 *params)
StopMusic(); // Stop any streaming music
for (int i = 0; i<16; i++)
- UpdateCompSampleStreaming(); // And wait for it to die
+ g_bs2->_sound->UpdateCompSampleStreaming(); // And wait for it to die
GetDrawStatus (&ds);
GetSoundStatus(&ss);
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 4ace612770..e286872ba3 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -235,7 +235,7 @@ void System_menu(void) //Tony19Mar97
}
//------------------------
- rv = PauseFx();
+ rv = g_bs2->_sound->PauseFx();
if (rv != RD_OK)
Zdebug("ERROR: PauseFx() returned %.8x in SystemMenu()", rv);
//------------------------
@@ -309,7 +309,7 @@ void System_menu(void) //Tony19Mar97
this_screen.new_palette=1;
//------------------------
- rv = UnpauseFx();
+ rv = g_bs2->_sound->UnpauseFx();
if (rv != RD_OK)
Zdebug("ERROR: UnpauseFx() returned %.8x in SystemMenu()", rv);
//------------------------
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index 2bf4b98d02..99ac8e0a5c 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -111,7 +111,7 @@ void Process_fx_queue(void)
}
else if (fxq[j].type == FX_SPOT2)
{
- if (IsFxOpen(j+1))
+ if (g_bs2->_sound->IsFxOpen(j+1))
fxq[j].resource = 0; // Once the Fx has finished remove it from the queue.
}
}
@@ -131,7 +131,7 @@ void Trigger_fx(uint8 j) // called from Process_fx_queue only
{
data = res_man.Res_open(fxq[j].resource); // load in the sample
data += sizeof(_standardHeader);
- rv = PlayFx( id, data, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT ); // wav data gets copied to sound memory
+ rv = g_bs2->_sound->PlayFx( id, data, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT ); // wav data gets copied to sound memory
res_man.Res_close(fxq[j].resource); // release the sample
// fxq[j].resource = 0; // clear spot fx from queue
}
@@ -139,9 +139,9 @@ void Trigger_fx(uint8 j) // called from Process_fx_queue only
{ // - to be referenced by 'j', so pass NULL data
if (fxq[j].type == FX_RANDOM)
- rv = PlayFx( id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT ); // not looped
+ rv = g_bs2->_sound->PlayFx( id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT ); // not looped
else // FX_LOOP
- rv = PlayFx( id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXLOOP ); // looped
+ rv = g_bs2->_sound->PlayFx( id, NULL, fxq[j].volume, fxq[j].pan, RDSE_FXLOOP ); // looped
}
#ifdef _BS2_DEBUG
@@ -251,7 +251,7 @@ int32 FN_play_fx(int32 *params) // called from script only
#endif
data += sizeof(_standardHeader);
- rv = OpenFx(id,data); // copy it to sound memory, using position in queue as 'id'
+ rv = g_bs2->_sound->OpenFx(id,data); // copy it to sound memory, using position in queue as 'id'
#ifdef _BS2_DEBUG
if (rv)
@@ -289,7 +289,7 @@ int32 FN_set_fx_vol_and_pan(int32 *params)
// 2 new pan (-16..16)
// SetFxVolumePan(int32 id, uint8 vol, uint8 pan);
- SetFxVolumePan(1+params[0], params[1], params[2]); // driver fx_id is 1+<pos in queue>
+ g_bs2->_sound->SetFxVolumePan(1+params[0], params[1], params[2]); // driver fx_id is 1+<pos in queue>
// Zdebug("%d",params[2]);
return (IR_CONT);
@@ -302,7 +302,7 @@ int32 FN_set_fx_vol(int32 *params)
// 1 new volume (0..16)
// SetFxIdVolume(int32 id, uint8 vol);
- SetFxIdVolume(1+params[0], params[1]);
+ g_bs2->_sound->SetFxIdVolume(1+params[0], params[1]);
return (IR_CONT);
}
@@ -321,7 +321,7 @@ int32 FN_stop_fx(int32 *params) // called from script only
if ((fxq[j].type == FX_RANDOM) || (fxq[j].type == FX_LOOP))
{
id = (uint32)j+1; // because 0 is not a valid id
- rv = CloseFx(id); // stop fx & remove sample from sound memory
+ rv = g_bs2->_sound->CloseFx(id); // stop fx & remove sample from sound memory
#ifdef _BS2_DEBUG
if (rv)
@@ -350,7 +350,7 @@ int32 FN_stop_all_fx(int32 *params) // called from script only
void Clear_fx_queue(void)
{
- ClearAllFx(); // stop all fx & remove the samples from sound memory
+ g_bs2->_sound->ClearAllFx(); // stop all fx & remove the samples from sound memory
Init_fx_queue(); // clean out the queue
}
@@ -415,7 +415,7 @@ int32 FN_play_music(int32 *params) // updated by James on 10apr97
else
sprintf(filename,"%sCLUSTERS\\MUSIC.CLU", res_man.GetCdPath());
- rv = StreamCompMusic(filename, params[0], loopFlag);
+ rv = g_bs2->_sound->StreamCompMusic(filename, params[0], loopFlag);
#ifdef _BS2_DEBUG
if (rv)
@@ -435,25 +435,24 @@ int32 FN_stop_music(int32 *params) // called from script only
looping_music_id=0; // clear the 'looping' flag
- StopMusic();
+ g_bs2->_sound->StopMusic();
if (params);
return(IR_CONT); // continue script
}
//--------------------------------------------------------------------------------------
-extern void UpdateCompSampleStreaming(void); // used in Kill_music()
//--------------------------------------------------------------------------------------
void Kill_music(void) // James22aug97
{
uint8 count;
looping_music_id=0; // clear the 'looping' flag
- StopMusic();
+ g_bs2->_sound->StopMusic();
// THIS BIT CAUSES THE MUSIC TO STOP INSTANTLY!
for(count=0; count<16; count++)
- UpdateCompSampleStreaming();
+ g_bs2->_sound->UpdateCompSampleStreaming();
}
//--------------------------------------------------------------------------------------
int32 FN_check_music_playing(int32 *params) // James (30july97)
@@ -463,7 +462,7 @@ int32 FN_check_music_playing(int32 *params) // James (30july97)
// sets result to no. of seconds of current tune remaining
// or 0 if no music playing
- RESULT = MusicTimeRemaining(); // in seconds, rounded up to the nearest second
+ RESULT = g_bs2->_sound->MusicTimeRemaining(); // in seconds, rounded up to the nearest second
return(IR_CONT); // continue script
}
@@ -472,15 +471,15 @@ void PauseAllSound(void) // James25july97
{
uint32 rv; // for drivers return value
- rv = PauseMusic();
+ rv = g_bs2->_sound->PauseMusic();
if (rv != RD_OK)
Zdebug("ERROR: PauseMusic() returned %.8x in PauseAllSound()", rv);
- rv = PauseSpeech();
+ rv = g_bs2->_sound->PauseSpeech();
if (rv != RD_OK)
Zdebug("ERROR: PauseSpeech() returned %.8x in PauseAllSound()", rv);
- rv = PauseFx();
+ rv = g_bs2->_sound->PauseFx();
if (rv != RD_OK)
Zdebug("ERROR: PauseFx() returned %.8x in PauseAllSound()", rv);
}
@@ -489,15 +488,15 @@ void UnpauseAllSound(void) // James25july97
{
uint32 rv; // for drivers return value
- rv = UnpauseMusic();
+ rv = g_bs2->_sound->UnpauseMusic();
if (rv != RD_OK)
Zdebug("ERROR: UnpauseMusic() returned %.8x in UnpauseAllSound()", rv);
- rv = UnpauseSpeech();
+ rv = g_bs2->_sound->UnpauseSpeech();
if (rv != RD_OK)
Zdebug("ERROR: UnpauseSpeech() returned %.8x in UnpauseAllSound()", rv);
- rv = UnpauseFx();
+ rv = g_bs2->_sound->UnpauseFx();
if (rv != RD_OK)
Zdebug("ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv);
}
diff --git a/sword2/speech.cpp b/sword2/speech.cpp
index abaf560955..b2196bcede 100644
--- a/sword2/speech.cpp
+++ b/sword2/speech.cpp
@@ -1373,7 +1373,7 @@ int32 FN_i_speak(int32 *params) //Tony18Oct96 (revamped by James01july97)
// New fudge to wait for smacker samples to finish (James31july97)
// since they can over-run into the game
- if (GetSpeechStatus()!=RDSE_SAMPLEFINISHED) // has it finished?
+ if (g_bs2->_sound->GetSpeechStatus()!=RDSE_SAMPLEFINISHED) // has it finished?
return (IR_REPEAT);
//-------------------------
@@ -1584,11 +1584,11 @@ int32 FN_i_speak(int32 *params) //Tony18Oct96 (revamped by James01july97)
//------------------------------
- rv = PlayCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan); // Load speech but don't start playing yet
+ rv = g_bs2->_sound->PlayCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan); // Load speech but don't start playing yet
if (rv == RD_OK)
{
speechRunning=1; // ok, we've got something to play (2 means not playing yet - see below)
- UnpauseSpeech(); // set it playing now (we might want to do this next cycle, don't know yet)
+ g_bs2->_sound->UnpauseSpeech(); // set it playing now (we might want to do this next cycle, don't know yet)
}
#ifdef _BS2_DEBUG
else
@@ -1628,7 +1628,7 @@ int32 FN_i_speak(int32 *params) //Tony18Oct96 (revamped by James01july97)
else if (speechRunning) // if playing a sample
{
if (!unpause_zone)
- { if (AmISpeaking()==RDSE_QUIET) // if we're at a quiet bit
+ { if (g_bs2->_sound->AmISpeaking()==RDSE_QUIET) // if we're at a quiet bit
ob_graphic->anim_pc=0; // restart from frame 0 ('closed mouth' frame)
}
}
@@ -1655,7 +1655,7 @@ int32 FN_i_speak(int32 *params) //Tony18Oct96 (revamped by James01july97)
if (speechRunning==1) // if playing a sample (note that value of '2' means about to play!)
{
if (!unpause_zone)
- { if (GetSpeechStatus()==RDSE_SAMPLEFINISHED) // has it finished?
+ { if (g_bs2->_sound->GetSpeechStatus()==RDSE_SAMPLEFINISHED) // has it finished?
speechFinished=1; // James25feb97
}
else unpause_zone--;
@@ -1704,7 +1704,7 @@ int32 FN_i_speak(int32 *params) //Tony18Oct96 (revamped by James01july97)
if (speechRunning) // if speech sample playing
{
- StopSpeechBS2(); // halt the sample prematurely
+ g_bs2->_sound->StopSpeechBS2(); // halt the sample prematurely
}
}
}
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index 5cb0d9bcf3..4524402deb 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -290,8 +290,8 @@ uint32 Con_start(uint8 *input) //Tony15Oct96
FN_stop_music(NULL); // fade out any music that is currently playing
//---------------------------------------------
- UnpauseSpeech();
- StopSpeechBS2(); // halt the sample prematurely
+ g_bs2->_sound->UnpauseSpeech();
+ g_bs2->_sound->StopSpeechBS2(); // halt the sample prematurely
//--------------------------------------------------------------
// clean out all resources & flags, ready for a total restart (James24mar97)
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index e51aca86c4..288e7f85d0 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -165,7 +165,9 @@ int32 BS2State::InitialiseGame(void)
Zdebug("CALLING: Init_event_system");
Init_event_system();
Zdebug("RETURNED.");
-
+
+ _sound = new BS2Sound;
+
Zdebug("CALLING: Init_fx_queue");
Init_fx_queue(); // initialise the sound fx queue
Zdebug("RETURNED.");
@@ -284,7 +286,7 @@ void BS2State::go()
Zdebug("RETURNED.");
Zdebug("CALLING: InitialiseSound");
- rv = InitialiseSound(22050, 2, 16);
+ rv = _sound->InitialiseSound(22050, 2, 16);
Zdebug("RETURNED with rv = %.8x", rv);
// don't care if this fails, because it should still work without sound cards
// but it should set a global system flag so that we can avoid loading sound fx & streaming music
diff --git a/sword2/sword2.h b/sword2/sword2.h
index 2f13c7bb1c..3488d53b64 100644
--- a/sword2/sword2.h
+++ b/sword2/sword2.h
@@ -21,6 +21,7 @@
#define _SWORD2
//#include "src\driver96.h"
+#include "driver/d_sound.h"
#ifdef _PCF76 // Bodge for PCF76 version so that their demo CD can be labelled "PCF76" rather than "RBSII1"
@@ -60,6 +61,7 @@ class BS2State : public Engine {
GameDetector *_detector;
uint32 _features;
byte _gameId;
+ BS2Sound *_sound;
private:
bool _quit;
};