[Scummvm-cvs-logs] CVS: scummvm/saga events.cpp,1.21,1.22 ihnm_introproc.cpp,1.15,1.16 ite_introproc.cpp,1.19,1.20 palanim.cpp,1.13,1.14 palanim.h,1.5,1.6 saga.cpp,1.44,1.45 saga.h,1.34,1.35 scene.cpp,1.28,1.29 palanim_mod.h,1.3,NONE

Eugene Sandulenko sev at users.sourceforge.net
Tue Aug 10 12:21:04 CEST 2004


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

Modified Files:
	events.cpp ihnm_introproc.cpp ite_introproc.cpp palanim.cpp 
	palanim.h saga.cpp saga.h scene.cpp 
Removed Files:
	palanim_mod.h 
Log Message:
Moved PALANIM_* to a class.


Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/events.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- events.cpp	10 Aug 2004 19:00:30 -0000	1.21
+++ events.cpp	10 Aug 2004 19:20:33 -0000	1.22
@@ -34,7 +34,7 @@
 #include "saga/scene.h"
 #include "saga/interface.h"
 #include "saga/text.h"
-#include "saga/palanim_mod.h"
+#include "saga/palanim.h"
 #include "saga/render.h"
 #include "saga/game_mod.h"
 #include "saga/sndres.h"
@@ -286,10 +286,10 @@
 	case R_PALANIM_EVENT:
 		switch (event->op) {
 		case EVENT_CYCLESTART:
-			PALANIM_CycleStart();
+			_vm->_palanim->cycleStart();
 			break;
 		case EVENT_CYCLESTEP:
-			PALANIM_CycleStep(event->time);
+			_vm->_palanim->cycleStep(event->time);
 			break;
 		default:
 			break;

Index: ihnm_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ihnm_introproc.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ihnm_introproc.cpp	10 Aug 2004 19:00:30 -0000	1.15
+++ ihnm_introproc.cpp	10 Aug 2004 19:20:33 -0000	1.16
@@ -31,7 +31,6 @@
 #include "saga/cvar_mod.h"
 #include "saga/events.h"
 #include "saga/rscfile_mod.h"
-#include "saga/palanim_mod.h"
 
 #include "saga/scene.h"
 #include "saga/ihnm_introproc.h"

Index: ite_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ite_introproc.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ite_introproc.cpp	10 Aug 2004 19:00:30 -0000	1.19
+++ ite_introproc.cpp	10 Aug 2004 19:20:33 -0000	1.20
@@ -36,7 +36,7 @@
 #include "saga/rscfile_mod.h"
 #include "saga/sndres.h"
 #include "saga/text.h"
-#include "saga/palanim_mod.h"
+#include "saga/palanim.h"
 #include "saga/music.h"
 
 #include "saga/scene.h"

Index: palanim.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/palanim.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- palanim.cpp	10 Aug 2004 19:00:30 -0000	1.13
+++ palanim.cpp	10 Aug 2004 19:20:33 -0000	1.14
@@ -28,20 +28,26 @@
 #include "saga/events.h"
 #include "saga/game_mod.h"
 
-#include "saga/palanim_mod.h"
 #include "saga/palanim.h"
 
 namespace Saga {
 
-static PALANIM_DATA PAnimData;
+PalAnim::PalAnim(SagaEngine *vm) : _vm(vm) {
+	_loaded = false;
+	_entryCount = 0;
+	_entries = NULL;
+}
 
-int PALANIM_Load(const byte *resdata, size_t resdata_len) {
+PalAnim::~PalAnim(void) {
+}
+
+int PalAnim::loadPalAnim(const byte *resdata, size_t resdata_len) {
 	void *test_p;
 
 	uint16 i;
 
-	if (PAnimData.loaded) {
-		PALANIM_Free();
+	if (_loaded) {
+		freePalAnim();
 	}
 
 	if (resdata == NULL) {
@@ -54,19 +60,19 @@
 		return R_SUCCESS;
 	}
 
-	PAnimData.entry_count = readS.readUint16LE();
+	_entryCount = readS.readUint16LE();
 
-	debug(0, "PALANIM_Load(): Loading %d PALANIM entries.", PAnimData.entry_count);
+	debug(0, "PalAnim::loadPalAnim(): Loading %d PALANIM entries.", _entryCount);
 
-	test_p = calloc(PAnimData.entry_count, sizeof(PALANIM_ENTRY));
+	test_p = calloc(_entryCount, sizeof(PALANIM_ENTRY));
 	if (test_p == NULL) {
-		warning("PALANIM_Load(): Allocation failure");
+		warning("PalAnim::loadPalAnim(): Allocation failure");
 		return R_MEM;
 	}
 
-	PAnimData.entries = (PALANIM_ENTRY *)test_p;
+	_entries = (PALANIM_ENTRY *)test_p;
 
-	for (i = 0; i < PAnimData.entry_count; i++) {
+	for (i = 0; i < _entryCount; i++) {
 		int color_count;
 		int pal_count;
 		int p, c;
@@ -74,48 +80,48 @@
 		color_count = readS.readUint16LE();
 		pal_count = readS.readUint16LE();
 
-		PAnimData.entries[i].pal_count = pal_count;
-		PAnimData.entries[i].color_count = color_count;
+		_entries[i].pal_count = pal_count;
+		_entries[i].color_count = color_count;
 
-		debug(2, "PALANIM_Load(): Entry %d: Loading %d palette indices.\n", i, pal_count);
+		debug(2, "PalAnim::loadPalAnim(): Entry %d: Loading %d palette indices.\n", i, pal_count);
 
 		test_p = calloc(1, sizeof(char) * pal_count);
 		if (test_p == NULL) {
-			warning("PALANIM_Load(): Allocation failure");
+			warning("PalAnim::loadPalAnim(): Allocation failure");
 			return R_MEM;
 		}
 
-		PAnimData.entries[i].pal_index = (byte *)test_p;
+		_entries[i].pal_index = (byte *)test_p;
 
-		debug(2, "PALANIM_Load(): Entry %d: Loading %d SAGA_COLOR structures.", i, color_count);
+		debug(2, "PalAnim::loadPalAnim(): Entry %d: Loading %d SAGA_COLOR structures.", i, color_count);
 
 		test_p = calloc(1, sizeof(R_COLOR) * color_count);
 		if (test_p == NULL) {
-			warning("PALANIM_Load(): Allocation failure");
+			warning("PalAnim::loadPalAnim(): Allocation failure");
 			return R_MEM;
 		}
 
-		PAnimData.entries[i].colors = (R_COLOR *)test_p;
+		_entries[i].colors = (R_COLOR *)test_p;
 
 		for (p = 0; p < pal_count; p++) {
-			PAnimData.entries[i].pal_index[p] = readS.readByte();
+			_entries[i].pal_index[p] = readS.readByte();
 		}
 
 		for (c = 0; c < color_count; c++) {
-			PAnimData.entries[i].colors[c].red = readS.readByte();
-			PAnimData.entries[i].colors[c].green = readS.readByte();
-			PAnimData.entries[i].colors[c].blue = readS.readByte();
+			_entries[i].colors[c].red = readS.readByte();
+			_entries[i].colors[c].green = readS.readByte();
+			_entries[i].colors[c].blue = readS.readByte();
 		}
 	}
 
-	PAnimData.loaded = 1;
+	_loaded = true;
 	return R_SUCCESS;
 }
 
-int PALANIM_CycleStart() {
+int PalAnim::cycleStart() {
 	R_EVENT event;
 
-	if (!PAnimData.loaded) {
+	if (!_loaded) {
 		return R_FAILURE;
 	}
 
@@ -129,7 +135,7 @@
 	return R_SUCCESS;
 }
 
-int PALANIM_CycleStep(int vectortime) {
+int PalAnim::cycleStep(int vectortime) {
 	R_SURFACE *back_buf;
 
 	static PALENTRY pal[256];
@@ -142,28 +148,28 @@
 
 	R_EVENT event;
 
-	if (!PAnimData.loaded) {
+	if (!_loaded) {
 		return R_FAILURE;
 	}
 
 	_vm->_gfx->getCurrentPal(pal);
 	back_buf = _vm->_gfx->getBackBuffer();
 
-	for (i = 0; i < PAnimData.entry_count; i++) {
-		cycle = PAnimData.entries[i].cycle;
-		cycle_limit = PAnimData.entries[i].color_count;
-		for (j = 0; j < PAnimData.entries[i].pal_count; j++) {
-			pal_index = (unsigned char)PAnimData.entries[i].pal_index[j];
+	for (i = 0; i < _entryCount; i++) {
+		cycle = _entries[i].cycle;
+		cycle_limit = _entries[i].color_count;
+		for (j = 0; j < _entries[i].pal_count; j++) {
+			pal_index = (unsigned char)_entries[i].pal_index[j];
 			col_index = (cycle + j) % cycle_limit;
-			pal[pal_index].red = (byte) PAnimData.entries[i].colors[col_index].red;
-			pal[pal_index].green = (byte) PAnimData.entries[i].colors[col_index].green;
-			pal[pal_index].blue = (byte) PAnimData.entries[i].colors[col_index].blue;
+			pal[pal_index].red = (byte) _entries[i].colors[col_index].red;
+			pal[pal_index].green = (byte) _entries[i].colors[col_index].green;
+			pal[pal_index].blue = (byte) _entries[i].colors[col_index].blue;
 		}
 
-		PAnimData.entries[i].cycle++;
+		_entries[i].cycle++;
 
-		if (PAnimData.entries[i].cycle == cycle_limit) {
-			PAnimData.entries[i].cycle = 0;
+		if (_entries[i].cycle == cycle_limit) {
+			_entries[i].cycle = 0;
 		}
 	}
 
@@ -179,25 +185,25 @@
 	return R_SUCCESS;
 }
 
-int PALANIM_Free() {
+int PalAnim::freePalAnim() {
 	uint16 i;
 
-	if (!PAnimData.loaded) {
+	if (!_loaded) {
 		return R_FAILURE;
 	}
 
-	for (i = 0; i < PAnimData.entry_count; i++) {
-		debug(2, "PALANIM_Free(): Entry %d: Freeing colors.", i);
-		free(PAnimData.entries[i].colors);
-		debug(2, "PALANIM_Free(): Entry %d: Freeing indices.", i);
-		free(PAnimData.entries[i].pal_index);
+	for (i = 0; i < _entryCount; i++) {
+		debug(2, "PalAnim::freePalAnim(): Entry %d: Freeing colors.", i);
+		free(_entries[i].colors);
+		debug(2, "PalAnim::freePalAnim(): Entry %d: Freeing indices.", i);
+		free(_entries[i].pal_index);
 	}
 
-	debug(0, "PALANIM_Free(): Freeing entries.");
+	debug(0, "PalAnim::freePalAnim(): Freeing entries.");
 
-	free(PAnimData.entries);
+	free(_entries);
 
-	PAnimData.loaded = 0;
+	_loaded = false;
 
 	return R_SUCCESS;
 }

Index: palanim.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/palanim.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- palanim.h	1 Aug 2004 01:56:21 -0000	1.5
+++ palanim.h	10 Aug 2004 19:20:33 -0000	1.6
@@ -39,9 +39,24 @@
 };
 
 struct PALANIM_DATA {
-	int loaded;
-	uint16 entry_count;
-	PALANIM_ENTRY *entries;
+};
+
+class PalAnim {
+ public:
+	PalAnim(SagaEngine *vm);
+	~PalAnim(void);
+
+	int loadPalAnim(const byte *, size_t);
+	int cycleStart();
+	int cycleStep(int vectortime);
+	int freePalAnim();
+
+ private:
+	SagaEngine *_vm;
+
+	bool _loaded;
+	uint16 _entryCount;
+	PALANIM_ENTRY *_entries;
 };
 
 } // End of namespace Saga

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- saga.cpp	10 Aug 2004 19:00:30 -0000	1.44
+++ saga.cpp	10 Aug 2004 19:20:33 -0000	1.45
@@ -56,6 +56,7 @@
 #include "saga/sound.h"
 #include "saga/music.h"
 #include "saga/game_mod.h"
+#include "saga/palanim.h"
 
 GameList Engine_SAGA_gameList() {
 	return Saga::GAME_GameList();
@@ -144,6 +145,7 @@
 	_sdata = new SData();
 	_interface = new Interface(this); // requires script module
 	_actor = new Actor(this);
+	_palanim = new PalAnim(this);
 	_scene = new Scene(this);
 
 	if (!_scene->initialized()) {
@@ -244,6 +246,7 @@
 	delete _console;
 	CVAR_Shutdown();
 	delete _events;
+	delete _palanim;
 
 	delete _interface;
 	delete _render;

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- saga.h	10 Aug 2004 19:00:30 -0000	1.34
+++ saga.h	10 Aug 2004 19:20:33 -0000	1.35
@@ -58,6 +58,7 @@
 class Interface;
 class Console;
 class Events;
+class PalAnim;
 
 using Common::MemoryReadStream;
 
@@ -118,6 +119,7 @@
 	Interface *_interface;
 	Console *_console;
 	Events *_events;
+	PalAnim *_palanim;
 	
 private:
 	int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- scene.cpp	10 Aug 2004 19:00:30 -0000	1.28
+++ scene.cpp	10 Aug 2004 19:20:33 -0000	1.29
@@ -35,7 +35,7 @@
 #include "saga/isomap.h"
 #include "saga/script_mod.h"
 #include "saga/objectmap.h"
-#include "saga/palanim_mod.h"
+#include "saga/palanim.h"
 #include "saga/render.h"
 #include "saga/rscfile_mod.h"
 #include "saga/script.h"
@@ -722,7 +722,7 @@
 			break;
 		case SAGA_PAL_ANIM:
 			debug(0, "Loading palette animation resource.");
-			PALANIM_Load(_resList[i].res_data, _resList[i].res_data_len);
+			_vm->_palanim->loadPalAnim(_resList[i].res_data, _resList[i].res_data_len);
 			break;
 		default:
 			warning("Scene::ProcessSceneResources(): Encountered unknown resource type: %d", _resList[i].res_type);
@@ -804,7 +804,7 @@
 	// Free animation info list
 	_vm->_anim->reset();
 
-	PALANIM_Free();
+	_vm->_palanim->freePalAnim();
 	_vm->_objectMap->freeMem();
 	_vm->_actionMap->freeMap();
 

--- palanim_mod.h DELETED ---





More information about the Scummvm-git-logs mailing list