[Scummvm-cvs-logs] CVS: scummvm/saga sound.h,NONE,1.1 actor.cpp,1.4,1.5 reinherit.h,1.8,1.9 saga.cpp,1.10,1.11 saga.h,1.6,1.7 sceneproc.cpp,1.2,1.3 sndres.cpp,1.5,1.6 sndres.h,1.5,1.6 sound.cpp,1.1,1.2

Eugene Sandulenko sev at users.sourceforge.net
Wed Apr 28 16:55:05 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20759

Modified Files:
	actor.cpp reinherit.h saga.cpp saga.h sceneproc.cpp sndres.cpp 
	sndres.h sound.cpp 
Added Files:
	sound.h 
Log Message:
Objectizing sound.cpp


--- NEW FILE: sound.h ---
/* 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: /cvsroot/scummvm/scummvm/saga/sound.h,v 1.1 2004/04/28 23:54:40 sev Exp $
 *
 */
/*
 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_ */

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- actor.cpp	28 Apr 2004 23:19:45 -0000	1.4
+++ actor.cpp	28 Apr 2004 23:54:40 -0000	1.5
@@ -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 @@
 					ys_dll_delete(a_dnode);
 
 					/* And stop any currently playing voices */
-					SYSSOUND_StopVoice();
+					_vm->_sound->stopVoice();
 				}
 			}
 		}

Index: reinherit.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/reinherit.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- reinherit.h	28 Apr 2004 02:11:09 -0000	1.8
+++ reinherit.h	28 Apr 2004 23:54:40 -0000	1.9
@@ -143,12 +143,6 @@
 
 
 /*
- * r_main.c
-\*--------------------------------------------------------------------------*/
-
-void R_Shutdown(int param);
-
-/*
  * r_transitions.c
 \*--------------------------------------------------------------------------*/
 int TRANSITION_Dissolve(uchar *dst_img,
@@ -161,22 +155,6 @@
 \*--------------------------------------------------------------------------*/
 
 /*
- * 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 {

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- saga.cpp	28 Apr 2004 23:19:45 -0000	1.10
+++ saga.cpp	28 Apr 2004 23:54:40 -0000	1.11
@@ -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 @@
 
 	/* Initialize engine modules
 	 * \*------------------------------------------------------------- */
-	_sndRes = new SndRes();
+	_sndRes = new SndRes(this);
 	EVENT_Init();
 	FONT_Init();
 	SPRITE_Init();
@@ -252,7 +253,7 @@
 	}
 
 	/* 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 @@
 
 	}			/* 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 @@
 	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);
 }
 

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- saga.h	28 Apr 2004 23:19:45 -0000	1.6
+++ saga.h	28 Apr 2004 23:54:40 -0000	1.7
@@ -35,6 +35,7 @@
 namespace Saga {
 
 class SndRes;
+class Sound;
 
 #define R_PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
 
@@ -49,12 +50,15 @@
 
  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

Index: sceneproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sceneproc.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sceneproc.cpp	25 Apr 2004 14:42:14 -0000	1.2
+++ sceneproc.cpp	28 Apr 2004 23:54:40 -0000	1.3
@@ -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 @@
 	case SCENE_BEGIN:
 
 		SYSMUSIC_Stop();
-		SYSSOUND_StopVoice();
+		_vm->_sound->stopVoice();
 
 		/* Fade palette to black from intro scene
 		 * \*----------------------------------------------------- */

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sndres.cpp	28 Apr 2004 23:19:45 -0000	1.5
+++ sndres.cpp	28 Apr 2004 23:54:40 -0000	1.6
@@ -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 @@
 	/* Grab sound resource information for the current game */
 	GAME_GetSoundInfo(&_snd_info);
 
+	_vm = vm;
 	_init = 1;
 }
 
@@ -77,7 +80,7 @@
 		return R_FAILURE;
 	}
 
-	SYSSOUND_PlayVoice(&snd_buffer);
+	_vm->_sound->playVoice(&snd_buffer);
 
 	return R_SUCCESS;
 }

Index: sndres.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sndres.h	28 Apr 2004 23:19:45 -0000	1.5
+++ sndres.h	28 Apr 2004 23:54:40 -0000	1.6
@@ -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 @@
 class SndRes {
  public:
 
-	SndRes(void);
+	SndRes(SagaEngine *vm);
 
 	int loadSound(ulong sound_rn);
 	int playVoice(ulong voice_rn);
@@ -83,6 +86,8 @@
 	R_RSCFILE_CONTEXT *_voice_ctxt;
 
 	R_GAME_SOUNDINFO _snd_info;
+
+	SagaEngine *_vm;
  };
 
 } // End of namespace Saga

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sound.cpp	28 Apr 2004 23:24:56 -0000	1.1
+++ sound.cpp	28 Apr 2004 23:54:40 -0000	1.2
@@ -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 @@
  * 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 @@
 	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;
 	}
 





More information about the Scummvm-git-logs mailing list