[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.2,1.3 events.cpp,1.3,1.4 ite_introproc.cpp,1.3,1.4 saga.cpp,1.8,1.9 saga.h,1.4,1.5 sndres.cpp,1.3,1.4 sndres.h,1.3,1.4 sndres_mod.h,1.1,NONE

Eugene Sandulenko sev at users.sourceforge.net
Wed Apr 28 16:12:01 CEST 2004


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

Modified Files:
	actor.cpp events.cpp ite_introproc.cpp saga.cpp saga.h 
	sndres.cpp sndres.h 
Removed Files:
	sndres_mod.h 
Log Message:
Objectize sndres.cpp


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- actor.cpp	25 Apr 2004 14:42:13 -0000	1.2
+++ actor.cpp	28 Apr 2004 23:10:59 -0000	1.3
@@ -30,6 +30,7 @@
     Hardcoded actor table present in r_actordata.c
 */
 
+#include "saga.h"
 #include "reinherit.h"
 
 #include "yslib.h"
@@ -42,7 +43,7 @@
 #include "console_mod.h"
 #include "rscfile_mod.h"
 #include "script_mod.h"
-#include "sndres_mod.h"
+#include "sndres.h"
 #include "sprite_mod.h"
 #include "font_mod.h"
 #include "text_mod.h"
@@ -678,7 +679,7 @@
 		if (!a_dialogue->d_playing) {
 			/* Dialogue voice hasn't played yet - play it now */
 
-			SND_PlayVoice(a_dialogue->d_voice_rn);
+			_vm->_snd->playVoice(a_dialogue->d_voice_rn);
 			a_dialogue->d_playing = 1;
 		}
 
@@ -732,7 +733,7 @@
 {
 	int voice_len;
 
-	voice_len = SND_GetVoiceLength(d_voice_rn);
+	voice_len = _vm->_snd->getVoiceLength(d_voice_rn);
 
 	if (voice_len < 0) {
 		voice_len = strlen(d_string) * ACTOR_DIALOGUE_LETTERTIME;

Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/events.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- events.cpp	25 Apr 2004 14:42:13 -0000	1.3
+++ events.cpp	28 Apr 2004 23:10:59 -0000	1.4
@@ -29,6 +29,7 @@
  Notes: 
 */
 
+#include "saga.h"
 #include "reinherit.h"
 
 #include "yslib.h"
@@ -44,7 +45,8 @@
 #include "text_mod.h"
 #include "palanim_mod.h"
 #include "render_mod.h"
-#include "sndres_mod.h"
+#include "game_mod.h"
+#include "sndres.h"
 
 /*
  * Begin module
@@ -308,7 +310,7 @@
 
 	case R_VOICE_EVENT:
 
-		SND_PlayVoice(event->param);
+		_vm->_snd->playVoice(event->param);
 		break;
 
 	case R_MUSIC_EVENT:

Index: ite_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ite_introproc.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ite_introproc.cpp	25 Apr 2004 15:14:46 -0000	1.3
+++ ite_introproc.cpp	28 Apr 2004 23:10:59 -0000	1.4
@@ -27,15 +27,11 @@
 
  Notes: 
 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "saga.h"
+#include "reinherit.h"
 
 #include "yslib.h"
 
-#include "reinherit.h"
-
 /*
  * Uses the following modules:
 \*--------------------------------------------------------------------------*/
@@ -46,7 +42,7 @@
 #include "game_mod.h"
 #include "rscfile_mod.h"
 #include "scene_mod.h"
-#include "sndres_mod.h"
+#include "sndres.h"
 #include "text_mod.h"
 #include "palanim_mod.h"
 
@@ -354,7 +350,7 @@
 			q_event = EVENT_Chain(q_event, &event);
 
 			voice_len =
-			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
+			    _vm->_snd->getVoiceLength(IntroDiag[i].i_voice_rn);
 			if (voice_len < 0) {
 				voice_len = strlen(IntroDiag[i].i_str) *
 				    VOICE_LETTERLEN;
@@ -474,7 +470,7 @@
 			q_event = EVENT_Chain(q_event, &event);
 
 			voice_len =
-			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
+			    _vm->_snd->getVoiceLength(IntroDiag[i].i_voice_rn);
 			if (voice_len < 0) {
 				voice_len = strlen(IntroDiag[i].i_str) *
 				    VOICE_LETTERLEN;
@@ -592,7 +588,7 @@
 			q_event = EVENT_Chain(q_event, &event);
 
 			voice_len =
-			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
+			    _vm->_snd->getVoiceLength(IntroDiag[i].i_voice_rn);
 			if (voice_len < 0) {
 				voice_len = strlen(IntroDiag[i].i_str) *
 				    VOICE_LETTERLEN;
@@ -709,7 +705,7 @@
 			q_event = EVENT_Chain(q_event, &event);
 
 			voice_len =
-			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
+			    _vm->_snd->getVoiceLength(IntroDiag[i].i_voice_rn);
 			if (voice_len < 0) {
 				voice_len = strlen(IntroDiag[i].i_str) *
 				    VOICE_LETTERLEN;

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- saga.cpp	28 Apr 2004 00:30:16 -0000	1.8
+++ saga.cpp	28 Apr 2004 23:10:59 -0000	1.9
@@ -50,7 +50,7 @@
 #include "isomap_mod.h"
 #include "script_mod.h"
 #include "scene_mod.h"
-#include "sndres_mod.h"
+#include "sndres.h"
 #include "sprite_mod.h"
 #include "text_mod.h"
 #include "objectmap_mod.h"
@@ -132,6 +132,8 @@
 
 static R_MAIN_DATA MainData;
 
+SagaEngine *_vm = NULL;
+
 SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
 	: Engine(syst) {
 
@@ -144,8 +146,7 @@
 
 	_mixer->setVolume(ConfMan.getInt("sfx_volume") * ConfMan.getInt("master_volume") / 255);
 
-	// Initialize backend
-	//syst->initSize(320, 240);
+	_vm = this;
 }
 
 SagaEngine::~SagaEngine() {
@@ -210,7 +211,7 @@
 
 	/* Initialize engine modules
 	 * \*------------------------------------------------------------- */
-	SND_Init();
+	_snd = new Snd();
 	EVENT_Init();
 	FONT_Init();
 	SPRITE_Init();

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- saga.h	12 Apr 2004 21:40:47 -0000	1.4
+++ saga.h	28 Apr 2004 23:10:59 -0000	1.5
@@ -24,6 +24,7 @@
 #ifndef SAGA_H
 #define SAGA_H
 
+#include "common/stdafx.h"
 #include "common/scummsys.h"
 #include "base/engine.h"
 #include "base/gameDetector.h"
@@ -33,6 +34,8 @@
 
 namespace Saga {
 
+class Snd;
+
 #define R_PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))
 
 enum SAGAGameId {
@@ -50,10 +53,13 @@
 
  public:
 	SagaEngine(GameDetector * detector, OSystem * syst);
-	virtual ~ SagaEngine();
-
+	virtual ~SagaEngine();
+	Snd *_snd;
 };
 
+// FIXME: Global var. We use it until everything will be turned into objects
+extern SagaEngine *_vm;
+
 } // End of namespace Saga
 
 #endif

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sndres.cpp	28 Apr 2004 22:21:50 -0000	1.3
+++ sndres.cpp	28 Apr 2004 23:10:59 -0000	1.4
@@ -43,41 +43,36 @@
 /*
  * Begin module component
 \*--------------------------------------------------------------------------*/
-#include "sndres_mod.h"
 #include "sndres.h"
 
 namespace Saga {
 
-R_SNDRES_MODULE SndModule;
-
-int SND_Init(void) {
+Snd::Snd(void) {
 	int result;
 
 	/* Load sound module resource file contexts */
-	result = GAME_GetFileContext(&SndModule.sfx_ctxt, R_GAME_SOUNDFILE, 0);
+	result = GAME_GetFileContext(&_sfx_ctxt, R_GAME_SOUNDFILE, 0);
 	if (result != R_SUCCESS) {
-		return R_FAILURE;
+		return;
 	}
 
-	result = GAME_GetFileContext(&SndModule.voice_ctxt,
+	result = GAME_GetFileContext(&_voice_ctxt,
 	    R_GAME_VOICEFILE, 0);
 	if (result != R_SUCCESS) {
-		return R_FAILURE;
+		return;
 	}
 
 	/* Grab sound resource information for the current game */
-	GAME_GetSoundInfo(&SndModule.snd_info);
-
-	SndModule.init = 1;
+	GAME_GetSoundInfo(&_snd_info);
 
-	return R_SUCCESS;
+	_init = 1;
 }
 
-int SND_PlayVoice(ulong voice_rn) {
+int Snd::playVoice(ulong voice_rn) {
 	R_SOUNDBUFFER snd_buffer;
 	int result;
 
-	result = SND_Load(SndModule.voice_ctxt, voice_rn, &snd_buffer);
+	result = load(_voice_ctxt, voice_rn, &snd_buffer);
 	if (result != R_SUCCESS) {
 		return R_FAILURE;
 	}
@@ -87,7 +82,7 @@
 	return R_SUCCESS;
 }
 
-int SND_Load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i) {
+int Snd::load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i) {
 	uchar *snd_res;
 	size_t snd_res_len;
 
@@ -100,11 +95,11 @@
 		return R_FAILURE;
 	}
 
-	switch (SndModule.snd_info.res_type) {
+	switch (_snd_info.res_type) {
 	case R_GAME_SOUND_PCM:
-		snd_buf_i->s_freq = SndModule.snd_info.freq;
-		snd_buf_i->s_samplebits = SndModule.snd_info.sample_size;
-		snd_buf_i->s_stereo = SndModule.snd_info.stereo;
+		snd_buf_i->s_freq = _snd_info.freq;
+		snd_buf_i->s_samplebits = _snd_info.sample_size;
+		snd_buf_i->s_stereo = _snd_info.stereo;
 
 		snd_buf_i->res_data = snd_res;
 		snd_buf_i->res_len = snd_res_len;
@@ -117,7 +112,7 @@
 		break;
 
 	case R_GAME_SOUND_VOC:
-		if (LoadVocSound(snd_res, snd_res_len, snd_buf_i) != R_SUCCESS) {
+		if (loadVocSound(snd_res, snd_res_len, snd_buf_i) != R_SUCCESS) {
 
 			RSC_FreeResource(snd_res);
 
@@ -137,7 +132,7 @@
 	return R_SUCCESS;
 }
 
-int LoadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) {
+int Snd::loadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) {
 	R_VOC_HEADER_BLOCK voc_hb;
 	R_VOC_GENBLOCK voc_gb;
 	R_VOC_BLOCK1 voc_b1;
@@ -197,7 +192,7 @@
 			read_len -= 2;
 
 			if (voc_b1.pack_method != 0) {
-				/* Packed VOC files not supported */
+				debug(0, "Packed VOC files not supported");
 				return R_FAILURE;
 			}
 
@@ -230,7 +225,7 @@
 	return R_SUCCESS;
 }
 
-int SND_GetVoiceLength(ulong voice_rn) {
+int Snd::getVoiceLength(ulong voice_rn) {
 	ulong length;
 
 	double ms_f;
@@ -238,20 +233,20 @@
 
 	int result;
 
-	assert(SndModule.init);
+	assert(_init);
 
-	result = RSC_GetResourceSize(SndModule.voice_ctxt, voice_rn, &length);
+	result = RSC_GetResourceSize(_voice_ctxt, voice_rn, &length);
 	if (result != R_SUCCESS) {
 		return -1;
 	}
 
-	if (SndModule.snd_info.res_type == R_GAME_SOUND_PCM) {
+	if (_snd_info.res_type == R_GAME_SOUND_PCM) {
 		ms_f = (double)length /
-		    (SndModule.snd_info.sample_size / CHAR_BIT) /
-		    (SndModule.snd_info.freq) * 1000.0;
+		    (_snd_info.sample_size / CHAR_BIT) /
+		    (_snd_info.freq) * 1000.0;
 
 		ms_i = (int)ms_f;
-	} else if (SndModule.snd_info.res_type == R_GAME_SOUND_VOC) {
+	} else if (_snd_info.res_type == R_GAME_SOUND_VOC) {
 		/* Rough hack, fix this to be accurate */
 		ms_f = (double)length / 14705 * 1000.0;
 		ms_i = (int)ms_f;
@@ -262,7 +257,7 @@
 	return ms_i;
 }
 
-int SND_ITEVOC_Resample(long src_freq, long dst_freq, uchar *src_buf, 
+int Snd::ITEVOC_Resample(long src_freq, long dst_freq, uchar *src_buf, 
 						size_t src_buf_len, uchar **dst_buf, size_t *dst_buf_len) {
 	uchar *resamp_buf;
 	size_t resamp_len;

Index: sndres.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sndres.h	28 Apr 2004 22:21:51 -0000	1.3
+++ sndres.h	28 Apr 2004 23:10:59 -0000	1.4
@@ -62,17 +62,28 @@
 	int pack_method;	/* BYTE */
 };
 
-struct R_SNDRES_MODULE {
-	int init;
+class Snd {
+ public:
 
-	R_RSCFILE_CONTEXT *sfx_ctxt;
-	R_RSCFILE_CONTEXT *voice_ctxt;
+	Snd(void);
 
-	R_GAME_SOUNDINFO snd_info;
-};
+	int loadSound(ulong sound_rn);
+	int playVoice(ulong voice_rn);
+	int getVoiceLength(ulong voice_rn);
+	int ITEVOC_Resample(long src_freq, long dst_freq, uchar *src_buf,
+						size_t src_buf_len, uchar **dst_buf, size_t *dst_buf_len);
 
-int SND_Load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i);
-int LoadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i);
+ private:
+	int load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i);
+	int loadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i);
+
+	int _init;
+
+	R_RSCFILE_CONTEXT *_sfx_ctxt;
+	R_RSCFILE_CONTEXT *_voice_ctxt;
+
+	R_GAME_SOUNDINFO _snd_info;
+ };
 
 } // End of namespace Saga
 

--- sndres_mod.h DELETED ---





More information about the Scummvm-git-logs mailing list