mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
Moved PALANIM_* to a class.
svn-id: r14540
This commit is contained in:
parent
fe7ac87bc7
commit
720ea20bed
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
104
saga/palanim.cpp
104
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;
|
||||
}
|
||||
|
||||
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 @@ 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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user