[Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.7,1.8 animation.h,1.5,1.6 events.cpp,1.11,1.12 ihnm_introproc.cpp,1.7,1.8 ite_introproc.cpp,1.10,1.11 saga.cpp,1.21,1.22 saga.h,1.13,1.14 scene.cpp,1.10,1.11 sceneproc.cpp,1.9,1.10 sfuncs.cpp,1.5,1.6
Jonathan Gray
khalek at users.sourceforge.net
Sat Jul 31 06:35:00 CEST 2004
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23539
Modified Files:
animation.cpp animation.h events.cpp ihnm_introproc.cpp
ite_introproc.cpp saga.cpp saga.h scene.cpp sceneproc.cpp
sfuncs.cpp
Log Message:
merge animation.h and animation_mod.h into a class
Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- animation.cpp 27 Jun 2004 21:30:32 -0000 1.7
+++ animation.cpp 31 Jul 2004 13:34:43 -0000 1.8
@@ -31,26 +31,24 @@
#include "events_mod.h"
#include "render_mod.h"
-#include "animation_mod.h"
#include "animation.h"
namespace Saga {
static R_ANIMINFO AnimInfo;
-int ANIM_Register() {
+int Anim::reg() {
CVAR_RegisterFunc(CF_anim_info, "anim_info", NULL, R_CVAR_NONE, 0, 0);
return R_SUCCESS;
}
-int ANIM_Init() {
+Anim::Anim(void) {
AnimInfo.anim_limit = R_MAX_ANIMATIONS;
AnimInfo.anim_count = 0;
AnimInfo.initialized = 1;
- return R_SUCCESS;
}
-int ANIM_Shutdown(void) {
+Anim::~Anim(void) {
uint16 i;
for (i = 0; i < R_MAX_ANIMATIONS; i++) {
@@ -58,10 +56,9 @@
}
AnimInfo.initialized = 0;
- return R_SUCCESS;
}
-int ANIM_Load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p) {
+int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p) {
R_ANIMATION *new_anim;
uint16 anim_id = 0;
@@ -93,7 +90,7 @@
new_anim->resdata_len = anim_resdata_len;
if (GAME_GetGameType() == R_GAMETYPE_ITE) {
- if (ANIM_GetNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames) != R_SUCCESS) {
+ if (getNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames) != R_SUCCESS) {
warning("Error: Couldn't get animation frame count");
return R_FAILURE;
}
@@ -106,12 +103,12 @@
}
for (i = 0; i < new_anim->n_frames; i++) {
- ANIM_GetFrameOffset(anim_resdata, anim_resdata_len, i + 1, &new_anim->frame_offsets[i]);
+ getFrameOffset(anim_resdata, anim_resdata_len, i + 1, &new_anim->frame_offsets[i]);
}
} else {
new_anim->cur_frame_p = anim_resdata + SAGA_FRAME_HEADER_LEN;
new_anim->cur_frame_len = anim_resdata_len - SAGA_FRAME_HEADER_LEN;
- ANIM_GetNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames);
+ getNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames);
}
// Set animation data
@@ -134,7 +131,7 @@
return R_SUCCESS;
}
-int ANIM_Link(uint16 anim_id1, uint16 anim_id2) {
+int Anim::link(uint16 anim_id1, uint16 anim_id2) {
R_ANIMATION *anim1;
R_ANIMATION *anim2;
@@ -157,7 +154,7 @@
return R_SUCCESS;
}
-int ANIM_Play(uint16 anim_id, int vector_time) {
+int Anim::play(uint16 anim_id, int vector_time) {
R_EVENT event;
R_ANIMATION *anim;
R_ANIMATION *link_anim;
@@ -195,20 +192,20 @@
result = ITE_DecodeFrame(anim->resdata, anim->resdata_len, anim->frame_offsets[frame - 1], display_buf,
disp_info.logical_w * disp_info.logical_h);
if (result != R_SUCCESS) {
- warning("ANIM_Play: Error decoding frame %u", anim->current_frame);
+ warning("ANIM::play: Error decoding frame %u", anim->current_frame);
anim->play_flag = 0;
return R_FAILURE;
}
} else {
if (anim->cur_frame_p == NULL) {
- warning("ANIM_Play: Frames exhausted");
+ warning("ANIM::play: Frames exhausted");
return R_FAILURE;
}
result = IHNM_DecodeFrame(display_buf, disp_info.logical_w * disp_info.logical_h,
anim->cur_frame_p, anim->cur_frame_len, &nextf_p, &nextf_len);
if (result != R_SUCCESS) {
- warning("ANIM_Play: Error decoding frame %u", anim->current_frame);
+ warning("ANIM::play: Error decoding frame %u", anim->current_frame);
anim->play_flag = 0;
return R_FAILURE;
}
@@ -270,12 +267,12 @@
return R_SUCCESS;
}
-int ANIM_Reset() {
+int Anim::reset() {
uint16 i;
for (i = 0; i < R_MAX_ANIMATIONS; i++) {
- ANIM_Free(i);
+ freeId(i);
}
AnimInfo.anim_count = 0;
@@ -283,7 +280,7 @@
return R_SUCCESS;
}
-int ANIM_SetFlag(uint16 anim_id, uint16 flag) {
+int Anim::setFlag(uint16 anim_id, uint16 flag) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
@@ -300,7 +297,7 @@
return R_SUCCESS;
}
-int ANIM_SetFrameTime(uint16 anim_id, int time) {
+int Anim::setFrameTime(uint16 anim_id, int time) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
@@ -317,7 +314,7 @@
return R_SUCCESS;
}
-int ANIM_Free(uint16 anim_id) {
+int Anim::freeId(uint16 anim_id) {
R_ANIMATION *anim;
if (anim_id > AnimInfo.anim_count) {
@@ -345,7 +342,7 @@
// sometimes less than number present in the .nframes member of the
// animation header. For this reason, the function attempts to find
// the last valid frame number, which it returns via 'n_frames'
-int ANIM_GetNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames) {
+int Anim::getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames) {
R_ANIMATION_HEADER ah;
size_t offset;
@@ -373,7 +370,7 @@
if (ah.magic == 68) {
for (x = ah.nframes; x > 0; x--) {
- if (ANIM_GetFrameOffset(anim_resource, anim_resource_len, x, &offset) != R_SUCCESS) {
+ if (getFrameOffset(anim_resource, anim_resource_len, x, &offset) != R_SUCCESS) {
return R_FAILURE;
}
@@ -390,7 +387,7 @@
return R_FAILURE;
}
-int ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset, byte *buf, size_t buf_len) {
+int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset, byte *buf, size_t buf_len) {
R_ANIMATION_HEADER ah;
R_FRAME_HEADER fh;
@@ -552,7 +549,7 @@
return R_SUCCESS;
}
-int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
+int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
size_t thisf_len, const byte **nextf_p, size_t *nextf_len) {
int in_ch;
int decoded_data = 0;
@@ -776,7 +773,7 @@
return R_SUCCESS;
}
-int ANIM_GetFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_frame, size_t *frame_offset_p) {
+int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_frame, size_t *frame_offset_p) {
R_ANIMATION_HEADER ah;
uint16 num_frames;
Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- animation.h 4 May 2004 03:33:03 -0000 1.5
+++ animation.h 31 Jul 2004 13:34:43 -0000 1.6
@@ -93,11 +93,31 @@
R_ANIMATION *anim_tbl[R_MAX_ANIMATIONS];
};
-int ANIM_GetNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames);
-int ITE_DecodeFrame(const byte *anim_resource, size_t anim_resource_len, size_t frame_offset, byte *buf, size_t buf_len);
-int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
+enum ANIM_FLAGS {
+ ANIM_LOOP = 0x01,
+ ANIM_ENDSCENE = 0x80 // When animation ends, dispatch scene end event
+};
+
+class Anim {
+public:
+ int reg(void);
+ Anim(void);
+ ~Anim(void);
+ int load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p);
+ int freeId(uint16 anim_id);
+ int play(uint16 anim_id, int vector_time);
+ int link(uint16 anim_id1, uint16 anim_id2);
+ int setFlag(uint16 anim_id, uint16 flag);
+ int setFrameTime(uint16 anim_id, int time);
+ int reset(void);
+private:
+ int getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames);
+ int ITE_DecodeFrame(const byte *anim_resource, size_t anim_resource_len, size_t frame_offset, byte *buf, size_t buf_len);
+ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
size_t thisf_len, const byte **nextf_p, size_t *nextf_len);
-int ANIM_GetFrameOffset(const byte *anim_resource, size_t anim_resource_len, uint16 find_frame, size_t *frame_offset);
+ int getFrameOffset(const byte *anim_resource, size_t anim_resource_len, uint16 find_frame, size_t *frame_offset);
+};
+
static void CF_anim_info(int argc, char *argv[]);
} // End of namespace Saga
Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/events.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- events.cpp 31 Jul 2004 12:37:36 -0000 1.11
+++ events.cpp 31 Jul 2004 13:34:43 -0000 1.12
@@ -29,7 +29,7 @@
#include "yslib.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "console_mod.h"
#include "scene_mod.h"
#include "gfx_mod.h"
@@ -270,7 +270,7 @@
case R_ANIM_EVENT:
switch (event->op) {
case EVENT_FRAME:
- ANIM_Play(event->param, event->time);
+ _vm->_anim->play(event->param, event->time);
break;
default:
break;
Index: ihnm_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ihnm_introproc.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ihnm_introproc.cpp 31 Jul 2004 12:37:36 -0000 1.7
+++ ihnm_introproc.cpp 31 Jul 2004 13:34:43 -0000 1.8
@@ -28,7 +28,7 @@
#include "reinherit.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "cvar_mod.h"
#include "events_mod.h"
#include "font_mod.h"
@@ -119,9 +119,9 @@
event.param = SET_PALETTE;
event.time = 0;
EVENT_Queue(&event);
- ANIM_SetFrameTime(0, R_IHNM_INTRO_FRAMETIME);
- ANIM_SetFlag(0, ANIM_ENDSCENE);
- ANIM_Play(0, 0);
+ _vm->_anim->setFrameTime(0, R_IHNM_INTRO_FRAMETIME);
+ _vm->_anim->setFlag(0, ANIM_ENDSCENE);
+ _vm->_anim->play(0, 0);
break;
default:
break;
@@ -173,8 +173,8 @@
q_event = EVENT_Chain(q_event, &event);
- ANIM_SetFlag(0, ANIM_LOOP);
- ANIM_Play(0, R_IHNM_PALFADE_TIME * 2);
+ _vm->_anim->setFlag(0, ANIM_LOOP);
+ _vm->_anim->play(0, R_IHNM_PALFADE_TIME * 2);
// Queue end of scene after looping animation for a while
event.type = R_ONESHOT_EVENT;
@@ -233,7 +233,7 @@
q_event = EVENT_Chain(q_event, &event);
- ANIM_Play(0, 0);
+ _vm->_anim->play(0, 0);
// Queue end of scene after a while
event.type = R_ONESHOT_EVENT;
@@ -266,8 +266,8 @@
q_event = EVENT_Queue(&event);
- ANIM_SetFlag(0, ANIM_LOOP);
- ANIM_Play(0, 0);
+ _vm->_anim->setFlag(0, ANIM_LOOP);
+ _vm->_anim->play(0, 0);
break;
default:
break;
Index: ite_introproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/ite_introproc.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ite_introproc.cpp 31 Jul 2004 12:37:36 -0000 1.10
+++ ite_introproc.cpp 31 Jul 2004 13:34:43 -0000 1.11
@@ -29,7 +29,7 @@
#include "yslib.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "cvar_mod.h"
#include "events_mod.h"
#include "font_mod.h"
@@ -186,23 +186,23 @@
debug(0, "Intro animation procedure started.");
debug(0, "Linking animation resources...");
- ANIM_SetFrameTime(0, ITE_INTRO_FRAMETIME);
+ _vm->_anim->setFrameTime(0, ITE_INTRO_FRAMETIME);
// Link this scene's animation resources for continuous
// playback
- ANIM_Link(0, 1);
- ANIM_Link(1, 2);
- ANIM_Link(2, 3);
- ANIM_Link(3, 4);
- ANIM_Link(4, 5);
- ANIM_Link(5, 6);
+ _vm->_anim->link(0, 1);
+ _vm->_anim->link(1, 2);
+ _vm->_anim->link(2, 3);
+ _vm->_anim->link(3, 4);
+ _vm->_anim->link(4, 5);
+ _vm->_anim->link(5, 6);
// Scene should end on display of last animation frame
- ANIM_SetFlag(6, ANIM_ENDSCENE);
+ _vm->_anim->setFlag(6, ANIM_ENDSCENE);
debug(0, "Beginning animation playback.");
- ANIM_Play(0, 0);
+ _vm->_anim->play(0, 0);
// Queue intro music playback
event.type = R_ONESHOT_EVENT;
@@ -674,8 +674,8 @@
debug(0, "Beginning animation playback.");
// Begin title screen background animation
- ANIM_SetFlag(0, ANIM_LOOP);
- ANIM_Play(0, 0);
+ _vm->_anim->setFlag(0, ANIM_LOOP);
+ _vm->_anim->play(0, 0);
// Begin ITE title theme music
_vm->_music->stop();
@@ -791,8 +791,8 @@
event_delay = DISSOLVE_DURATION;
// Begin title screen background animation
- ANIM_SetFrameTime(0, 100);
- ANIM_Play(0, event_delay);
+ _vm->_anim->setFrameTime(0, 100);
+ _vm->_anim->play(0, event_delay);
// Queue game credits list
text_entry.color = 255;
@@ -900,8 +900,8 @@
event_delay = DISSOLVE_DURATION;
// Begin title screen background animation
- ANIM_SetFlag(0, ANIM_LOOP);
- ANIM_Play(0, event_delay);
+ _vm->_anim->setFlag(0, ANIM_LOOP);
+ _vm->_anim->play(0, event_delay);
// Queue game credits list
text_entry.color = 255;
Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- saga.cpp 25 Jun 2004 20:01:31 -0000 1.21
+++ saga.cpp 31 Jul 2004 13:34:43 -0000 1.22
@@ -39,7 +39,7 @@
#include "rscfile_mod.h"
#include "render_mod.h"
#include "actor_mod.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "console_mod.h"
#include "cvar_mod.h"
#include "events_mod.h"
@@ -120,7 +120,7 @@
RENDER_Register();
GAME_Register();
- ANIM_Register();
+ _anim->reg();
ACTIONMAP_Register();
OBJECTMAP_Register();
SCRIPT_Register();
@@ -159,7 +159,7 @@
EVENT_Init();
FONT_Init();
SPRITE_Init();
- ANIM_Init();
+ _anim = new Anim();
ACTIONMAP_Init();
OBJECTMAP_Init();
ISOMAP_Init();
@@ -235,7 +235,6 @@
SCENE_Shutdown();
ACTOR_Shutdown();
SCRIPT_Shutdown();
- ANIM_Shutdown();
SPRITE_Shutdown();
OBJECTMAP_Shutdown();
FONT_Shutdown();
@@ -247,6 +246,7 @@
// Shutdown system modules */
delete _music;
delete _sound;
+ delete _anim;
_system->quit();
}
Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- saga.h 25 Jun 2004 21:47:37 -0000 1.13
+++ saga.h 31 Jul 2004 13:34:43 -0000 1.14
@@ -41,6 +41,7 @@
class SndRes;
class Sound;
class Music;
+class Anim;
using Common::MemoryReadStream;
@@ -67,6 +68,7 @@
SndRes *_sndRes;
Sound *_sound;
Music *_music;
+ Anim *_anim;
};
// FIXME: Global var. We use it until everything will be turned into objects
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- scene.cpp 31 Jul 2004 12:37:36 -0000 1.10
+++ scene.cpp 31 Jul 2004 13:34:43 -0000 1.11
@@ -28,7 +28,7 @@
#include "yslib.h"
#include "game_mod.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "console_mod.h"
#include "cvar_mod.h"
#include "events_mod.h"
@@ -692,7 +692,7 @@
return R_MEM;
}
- if (ANIM_Load(SceneModule.reslist[i].res_data,
+ if (_vm->_anim->load(SceneModule.reslist[i].res_data,
SceneModule.reslist[i].res_data_len,
&new_anim_id) == R_SUCCESS) {
} else {
@@ -789,7 +789,7 @@
}
// Free animation info list
- ANIM_Reset();
+ _vm->_anim->reset();
PALANIM_Free();
OBJECTMAP_Free();
Index: sceneproc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sceneproc.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sceneproc.cpp 31 Jul 2004 12:37:36 -0000 1.9
+++ sceneproc.cpp 31 Jul 2004 13:34:43 -0000 1.10
@@ -28,7 +28,7 @@
#include "yslib.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "events_mod.h"
#include "scene_mod.h"
#include "palanim_mod.h"
@@ -101,8 +101,8 @@
q_event = EVENT_Chain(q_event, &event);
- ANIM_SetFlag(0, ANIM_LOOP);
- ANIM_Play(0, delay_time);
+ _vm->_anim->setFlag(0, ANIM_LOOP);
+ _vm->_anim->play(0, delay_time);
debug(0, "InitialSceneproc(): Scene started");
break;
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sfuncs.cpp 31 Jul 2004 12:37:36 -0000 1.5
+++ sfuncs.cpp 31 Jul 2004 13:34:43 -0000 1.6
@@ -26,11 +26,12 @@
#include "reinherit.h"
#include "actor_mod.h"
-#include "animation_mod.h"
+#include "animation.h"
#include "console_mod.h"
#include "interface_mod.h"
#include "text_mod.h"
+#include "saga.h"
#include "script.h"
#include "sfuncs.h"
@@ -272,8 +273,8 @@
frame_count = SDATA_ReadWordS(frame_parm);
anim_id = SDATA_ReadWordS(anim_id_parm);
- if (ANIM_Play(anim_id, 0) != R_SUCCESS) {
- CON_Print(S_WARN_PREFIX "SF.26: ANIM_Play() failed. Anim id: %u\n", anim_id);
+ if (_vm->_anim->play(anim_id, 0) != R_SUCCESS) {
+ CON_Print(S_WARN_PREFIX "SF.26: Anim::play() failed. Anim id: %u\n", anim_id);
return R_FAILURE;
}
@@ -487,8 +488,8 @@
anim_id1 = SDATA_ReadWordU(anim1_parm);
anim_id2 = SDATA_ReadWordU(anim2_parm);
- if (ANIM_Link(anim_id1, anim_id2) != R_SUCCESS) {
- CON_Print(S_WARN_PREFIX "SF.41: ANIM_Link() failed. (%u->%u)\n", anim_id1, anim_id2);
+ if (_vm->_anim->link(anim_id1, anim_id2) != R_SUCCESS) {
+ CON_Print(S_WARN_PREFIX "SF.41: Anim::link() failed. (%u->%u)\n", anim_id1, anim_id2);
return R_FAILURE;
}
More information about the Scummvm-git-logs
mailing list