aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2004-08-10 19:20:33 +0000
committerEugene Sandulenko2004-08-10 19:20:33 +0000
commit720ea20bed7c6c81af7e0ce41faeaee8c76ad2ce (patch)
treee955dc568dc88052d5ce66f845309f47a785b254
parentfe7ac87bc76ec6f0d99322d0089ff640a4564eaa (diff)
downloadscummvm-rg350-720ea20bed7c6c81af7e0ce41faeaee8c76ad2ce.tar.gz
scummvm-rg350-720ea20bed7c6c81af7e0ce41faeaee8c76ad2ce.tar.bz2
scummvm-rg350-720ea20bed7c6c81af7e0ce41faeaee8c76ad2ce.zip
Moved PALANIM_* to a class.
svn-id: r14540
-rw-r--r--saga/events.cpp6
-rw-r--r--saga/ihnm_introproc.cpp1
-rw-r--r--saga/ite_introproc.cpp2
-rw-r--r--saga/palanim.cpp104
-rw-r--r--saga/palanim.h21
-rw-r--r--saga/palanim_mod.h39
-rw-r--r--saga/saga.cpp3
-rw-r--r--saga/saga.h2
-rw-r--r--saga/scene.cpp6
9 files changed, 85 insertions, 99 deletions
diff --git a/saga/events.cpp b/saga/events.cpp
index 5af56f5633..515fcc16bc 100644
--- a/saga/events.cpp
+++ b/saga/events.cpp
@@ -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 @@ int Events::handleOneShot(R_EVENT *event) {
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;
diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp
index 82d565a99a..79f179b7a2 100644
--- a/saga/ihnm_introproc.cpp
+++ b/saga/ihnm_introproc.cpp
@@ -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"
diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp
index 8f88381b26..830412f6d1 100644
--- a/saga/ite_introproc.cpp
+++ b/saga/ite_introproc.cpp
@@ -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"
diff --git a/saga/palanim.cpp b/saga/palanim.cpp
index 0a7145b388..c763680444 100644
--- a/saga/palanim.cpp
+++ b/saga/palanim.cpp
@@ -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;
+}
+
+PalAnim::~PalAnim(void) {
+}
-int PALANIM_Load(const byte *resdata, size_t resdata_len) {
+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 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) {
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 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) {
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 @@ int PALANIM_CycleStart() {
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 @@ int PALANIM_CycleStep(int vectortime) {
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 @@ int PALANIM_CycleStep(int vectortime) {
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;
}
diff --git a/saga/palanim.h b/saga/palanim.h
index 95dda8bf1c..d19fc62b24 100644
--- a/saga/palanim.h
+++ b/saga/palanim.h
@@ -39,9 +39,24 @@ struct PALANIM_ENTRY {
};
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
diff --git a/saga/palanim_mod.h b/saga/palanim_mod.h
deleted file mode 100644
index 3dcd416d30..0000000000
--- a/saga/palanim_mod.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* 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$
- *
- */
-
-// Palette animation module public header file
-
-
-#ifndef SAGA_PALANIM_MOD_H__
-#define SAGA_PALANIM_MOD_H__
-
-namespace Saga {
-
-int PALANIM_Load(const byte *, size_t);
-int PALANIM_CycleStart();
-int PALANIM_CycleStep(int vectortime);
-int PALANIM_Free();
-
-} // End of namespace Saga
-
-#endif
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 68034f8d1b..e6a9af6ea6 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -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 @@ void SagaEngine::go() {
_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 @@ void SagaEngine::shutdown() {
delete _console;
CVAR_Shutdown();
delete _events;
+ delete _palanim;
delete _interface;
delete _render;
diff --git a/saga/saga.h b/saga/saga.h
index 0a5353c484..e1d72f77b7 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -58,6 +58,7 @@ class Scene;
class Interface;
class Console;
class Events;
+class PalAnim;
using Common::MemoryReadStream;
@@ -118,6 +119,7 @@ public:
Interface *_interface;
Console *_console;
Events *_events;
+ PalAnim *_palanim;
private:
int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);
diff --git a/saga/scene.cpp b/saga/scene.cpp
index d39af2e3f9..2e62875afa 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -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 @@ int Scene::processSceneResources() {
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 @@ int Scene::endScene() {
// Free animation info list
_vm->_anim->reset();
- PALANIM_Free();
+ _vm->_palanim->freePalAnim();
_vm->_objectMap->freeMem();
_vm->_actionMap->freeMap();