aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp3
-rw-r--r--saga/reinherit.h22
-rw-r--r--saga/saga.cpp19
-rw-r--r--saga/saga.h6
-rw-r--r--saga/sceneproc.cpp8
-rw-r--r--saga/sndres.cpp9
-rw-r--r--saga/sndres.h9
-rw-r--r--saga/sound.cpp74
-rw-r--r--saga/sound.h65
9 files changed, 127 insertions, 88 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 7f270dc541..9ffc3b00f9 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -47,6 +47,7 @@
#include "sprite_mod.h"
#include "font_mod.h"
#include "text_mod.h"
+#include "sound.h"
/*
* Begin module component
@@ -414,7 +415,7 @@ int ACTOR_SkipDialogue(void)
ys_dll_delete(a_dnode);
/* And stop any currently playing voices */
- SYSSOUND_StopVoice();
+ _vm->_sound->stopVoice();
}
}
}
diff --git a/saga/reinherit.h b/saga/reinherit.h
index 8b7690b0b0..8da29e0a19 100644
--- a/saga/reinherit.h
+++ b/saga/reinherit.h
@@ -143,12 +143,6 @@ enum R_ERRORCODE {
/*
- * r_main.c
-\*--------------------------------------------------------------------------*/
-
-void R_Shutdown(int param);
-
-/*
* r_transitions.c
\*--------------------------------------------------------------------------*/
int TRANSITION_Dissolve(uchar *dst_img,
@@ -161,22 +155,6 @@ int TRANSITION_Dissolve(uchar *dst_img,
\*--------------------------------------------------------------------------*/
/*
- * System : Sound
-\*--------------------------------------------------------------------------*/
-int SYSSOUND_Init(int enabled);
-int SYSSOUND_Shutdown(void);
-
-int SYSSOUND_Play(int sound_rn, int channel);
-int SYSSOUND_Pause(int channel);
-int SYSSOUND_Resume(int channel);
-int SYSSOUND_Stop(int channel);
-
-int SYSSOUND_PlayVoice(R_SOUNDBUFFER *);
-int SYSSOUND_PauseVoice(void);
-int SYSSOUND_ResumeVoice(void);
-int SYSSOUND_StopVoice(void);
-
-/*
* System : Music
\*--------------------------------------------------------------------------*/
enum SYSMUSIC_FLAGS {
diff --git a/saga/saga.cpp b/saga/saga.cpp
index bc81793966..2f46cdd658 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -54,6 +54,7 @@
#include "sprite_mod.h"
#include "text_mod.h"
#include "objectmap_mod.h"
+#include "sound.h"
struct SAGAGameSettings {
const char *name;
@@ -211,7 +212,7 @@ void SagaEngine::go() {
/* Initialize engine modules
* \*------------------------------------------------------------- */
- _sndRes = new SndRes();
+ _sndRes = new SndRes(this);
EVENT_Init();
FONT_Init();
SPRITE_Init();
@@ -252,7 +253,7 @@ void SagaEngine::go() {
}
/* Initialize system specific sound */
- SYSSOUND_Init(MainData.sound_enabled);
+ _sound = new Sound(MainData.sound_enabled);
if (!MainData.sound_enabled) {
R_printf(R_STDOUT, "Sound disabled.\n");
}
@@ -298,16 +299,10 @@ void SagaEngine::go() {
} /* end main game engine loop */
- R_Shutdown(0);
-
return;
}
void SagaEngine::shutdown() {
- _system->quit();
-}
-
-void R_Shutdown(int param) {
SCENE_Shutdown();
ACTOR_Shutdown();
SCRIPT_Shutdown();
@@ -321,16 +316,18 @@ void R_Shutdown(int param) {
CVAR_Shutdown();
EVENT_Shutdown();
+ delete _sndRes;
+
/* Shutdown system modules */
SYSMUSIC_Shutdown();
- SYSSOUND_Shutdown();
+ delete _sound;
- /* exit(param); */
+ _system->quit();
}
static void CF_quitfunc(int argc, char *argv[])
{
- R_Shutdown(0);
+ _vm->shutdown();
exit(0);
}
diff --git a/saga/saga.h b/saga/saga.h
index 8395059cd3..270b61e137 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -35,6 +35,7 @@
namespace Saga {
class SndRes;
+class Sound;
#define R_PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
@@ -49,12 +50,15 @@ class SagaEngine:public Engine {
protected:
void go();
- void shutdown();
public:
SagaEngine(GameDetector * detector, OSystem * syst);
virtual ~SagaEngine();
+
+ void shutdown();
+
SndRes *_sndRes;
+ Sound *_sound;
};
// FIXME: Global var. We use it until everything will be turned into objects
diff --git a/saga/sceneproc.cpp b/saga/sceneproc.cpp
index ab9cdab517..3782aa5f3d 100644
--- a/saga/sceneproc.cpp
+++ b/saga/sceneproc.cpp
@@ -28,10 +28,7 @@
Notes:
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
@@ -43,6 +40,7 @@
#include "events_mod.h"
#include "scene_mod.h"
#include "palanim_mod.h"
+#include "sound.h"
/*
* Begin module
@@ -69,7 +67,7 @@ int InitialSceneProc(int param, R_SCENE_INFO * scene_info)
case SCENE_BEGIN:
SYSMUSIC_Stop();
- SYSSOUND_StopVoice();
+ _vm->_sound->stopVoice();
/* Fade palette to black from intro scene
* \*----------------------------------------------------- */
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 9d04069516..5feb0f677a 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -23,11 +23,12 @@
/*
Description:
- Sound resource management module
+ Sound resource management class
Notes:
*/
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
@@ -44,10 +45,11 @@
* Begin module component
\*--------------------------------------------------------------------------*/
#include "sndres.h"
+#include "sound.h"
namespace Saga {
-SndRes::SndRes(void) {
+SndRes::SndRes(SagaEngine *vm) {
int result;
/* Load sound module resource file contexts */
@@ -65,6 +67,7 @@ SndRes::SndRes(void) {
/* Grab sound resource information for the current game */
GAME_GetSoundInfo(&_snd_info);
+ _vm = vm;
_init = 1;
}
@@ -77,7 +80,7 @@ int SndRes::playVoice(ulong voice_rn) {
return R_FAILURE;
}
- SYSSOUND_PlayVoice(&snd_buffer);
+ _vm->_sound->playVoice(&snd_buffer);
return R_SUCCESS;
}
diff --git a/saga/sndres.h b/saga/sndres.h
index f241af4151..8b3a06fefa 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -23,7 +23,7 @@
/*
Description:
- Sound resource management module - private header
+ Sound resource class header
Notes:
*/
@@ -31,6 +31,9 @@
#ifndef SAGA_SNDRES_H_
#define SAGA_SNDRES_H_
+#include "rscfile_mod.h"
+#include "game_mod.h"
+
namespace Saga {
#define R_VOC_TIME_BASE 256000000L
@@ -65,7 +68,7 @@ struct R_VOC_BLOCK1 {
class SndRes {
public:
- SndRes(void);
+ SndRes(SagaEngine *vm);
int loadSound(ulong sound_rn);
int playVoice(ulong voice_rn);
@@ -83,6 +86,8 @@ class SndRes {
R_RSCFILE_CONTEXT *_voice_ctxt;
R_GAME_SOUNDINFO _snd_info;
+
+ SagaEngine *_vm;
};
} // End of namespace Saga
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 07d7091130..7bb2b88b26 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -20,6 +20,7 @@
* $Header$
*
*/
+#include "saga.h"
#include "reinherit.h"
#include "yslib.h"
@@ -27,8 +28,8 @@
/*
* Uses the following modules:
\*--------------------------------------------------------------------------*/
+#include "sound.h"
#include "game_mod.h"
-#include "rscfile_mod.h"
namespace Saga {
@@ -36,53 +37,40 @@ namespace Saga {
* Begin module component
\*--------------------------------------------------------------------------*/
-static int SoundInitialized = 0;
-
-static R_RSCFILE_CONTEXT *SoundContext;
-static R_RSCFILE_CONTEXT *VoiceContext;
-
-int SYSSOUND_Init(int enabled) {
+Sound::Sound(int enabled) {
int result;
- if (SoundInitialized) {
- return R_FAILURE;
- }
-
- /* Load sound module resource file contexts
- * \*------------------------------------------------------------- */
- result = GAME_GetFileContext(&SoundContext, R_GAME_SOUNDFILE, 0);
+ /* Load sound module resource file contexts */
+ result = GAME_GetFileContext(&_soundContext, R_GAME_SOUNDFILE, 0);
if (result != R_SUCCESS) {
- return R_FAILURE;
+ return;
}
- result = GAME_GetFileContext(&VoiceContext, R_GAME_VOICEFILE, 0);
+ result = GAME_GetFileContext(&_voiceContext, R_GAME_VOICEFILE, 0);
if (result != R_SUCCESS) {
- return R_FAILURE;
+ return;
}
- /* Grab sound resource information for the current game
- \*-------------------------------------------------------------*/
+ /* Grab sound resource information for the current game */
//GAME_GetSoundInfo(&SoundModule.snd_info);
- SoundInitialized = 1;
- return R_SUCCESS;
+ _soundInitialized = 1;
+ return;
}
-int SYSSOUND_Shutdown() {
- if (!SoundInitialized) {
- return R_FAILURE;
+Sound::~Sound() {
+ if (!_soundInitialized) {
+ return;
}
- SoundInitialized = 0;
-
- return R_SUCCESS;
+ _soundInitialized = 0;
}
-int SYSSOUND_Play(int sound_rn, int channel) {
+int Sound::play(int sound_rn, int channel) {
int resource_size;
char *resource_data;
- if (!SoundInitialized) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
@@ -93,64 +81,64 @@ int SYSSOUND_Play(int sound_rn, int channel) {
return R_SUCCESS;
}
-int SYSSOUND_Pause(int channel) {
+int Sound::pause(int channel) {
(void)channel;
- if (!SoundInitialized) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_Resume(int channel) {
+int Sound::resume(int channel) {
(void)channel;
- if (!SoundInitialized) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_Stop(int channel) {
+int Sound::stop(int channel) {
(void)channel;
- if (!SoundInitialized) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_PlayVoice(R_SOUNDBUFFER *buf) {
+int Sound::playVoice(R_SOUNDBUFFER *buf) {
(void)buf;
- if (!SoundInitialized) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_PauseVoice(void) {
- if (!SoundInitialized) {
+int Sound::pauseVoice(void) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_ResumeVoice(void) {
- if (!SoundInitialized) {
+int Sound::resumeVoice(void) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
return R_SUCCESS;
}
-int SYSSOUND_StopVoice(void) {
- if (!SoundInitialized) {
+int Sound::stopVoice(void) {
+ if (!_soundInitialized) {
return R_FAILURE;
}
diff --git a/saga/sound.h b/saga/sound.h
new file mode 100644
index 0000000000..ef7d43fc92
--- /dev/null
+++ b/saga/sound.h
@@ -0,0 +1,65 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2004 The ScummVM project
+ *
+ * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+/*
+ Description:
+
+ Sound class
+
+ Notes:
+*/
+
+#ifndef SAGA_SOUND_H_
+#define SAGA_SOUND_H_
+
+#include "rscfile_mod.h"
+
+namespace Saga {
+
+class Sound {
+ public:
+
+ Sound(int enabled);
+ ~Sound(void);
+
+ int play(int sound_rn, int channel);
+ int pause(int channel);
+ int resume(int channel);
+ int stop(int channel);
+
+ int playVoice(R_SOUNDBUFFER *);
+ int pauseVoice(void);
+ int resumeVoice(void);
+ int stopVoice(void);
+
+ private:
+
+ int _soundInitialized;
+
+ R_RSCFILE_CONTEXT *_soundContext;
+ R_RSCFILE_CONTEXT *_voiceContext;
+
+ };
+
+} // End of namespace Saga
+
+#endif /* SAGA_SOUND_H_ */