diff options
-rw-r--r-- | saga/animation.cpp | 24 | ||||
-rw-r--r-- | saga/animation.h | 16 | ||||
-rw-r--r-- | saga/rscfile.cpp | 13 | ||||
-rw-r--r-- | saga/scene.cpp | 8 | ||||
-rw-r--r-- | saga/scene.h | 2 |
5 files changed, 48 insertions, 15 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp index 732c32efa2..799fd3f974 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -36,6 +36,9 @@ namespace Saga { Anim::Anim(SagaEngine *vm) : _vm(vm) { uint16 i; + _cutawayList = NULL; + _cutawayListLength = 0; + for (i = 0; i < MAX_ANIMATIONS; i++) _animations[i] = NULL; } @@ -44,6 +47,27 @@ Anim::~Anim(void) { reset(); } +void Anim::loadCutawayList(const byte *resourcePointer, size_t resourceLength) { + free(_cutawayList); + _cutawayListLength = resourceLength / 8; + _cutawayList = (Cutaway *)malloc(_cutawayListLength * sizeof(Cutaway)); + + MemoryReadStream cutawayS(resourcePointer, resourceLength); + + for (int i = 0; i < _cutawayListLength; i++) { + _cutawayList[i].backgroundID = cutawayS.readUint16LE(); + _cutawayList[i].frameID = cutawayS.readUint16LE(); + _cutawayList[i].maxFrame = (int16)cutawayS.readUint16LE(); + _cutawayList[i].frameRate = (int16)cutawayS.readUint16LE(); + } +} + +void Anim::freeCutawayList(void) { + free(_cutawayList); + _cutawayList = NULL; + _cutawayListLength = 0; +} + void Anim::load(uint16 animId, const byte *animResourceData, size_t animResourceLength) { AnimationData *anim; uint16 temp; diff --git a/saga/animation.h b/saga/animation.h index dc138eed31..e594a0ba80 100644 --- a/saga/animation.h +++ b/saga/animation.h @@ -33,7 +33,6 @@ namespace Saga { #define MAX_ANIMATIONS 10 #define DEFAULT_FRAME_TIME 140 - #define SAGA_FRAME_START 0xF #define SAGA_FRAME_END 0x3F #define SAGA_FRAME_NOOP 0x1F @@ -52,6 +51,15 @@ enum AnimationState { ANIM_ENDSCENE = 0x80 // When animation ends, dispatch scene end event }; +// Cutaway info array member. Cutaways are basically animations with a really +// bad attitude. +struct Cutaway { + uint16 backgroundID; + uint16 frameID; + int16 maxFrame; + int16 frameRate; +}; + // Animation info array member struct AnimationData { byte *resourceData; @@ -99,6 +107,9 @@ public: Anim(SagaEngine *vm); ~Anim(void); + void loadCutawayList(const byte *resourcePointer, size_t resourceLength); + void freeCutawayList(void); + void load(uint16 animId, const byte *animResourceData, size_t animResourceLength); void freeId(uint16 animId); void play(uint16 animId, int vectorTime, bool playing = true); @@ -156,7 +167,8 @@ private: SagaEngine *_vm; AnimationData *_animations[MAX_ANIMATIONS]; - + Cutaway *_cutawayList; + int _cutawayListLength; }; } // End of namespace Saga diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index 2a38b2f7e5..c4bd242090 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -25,6 +25,7 @@ #include "saga/saga.h" #include "saga/actor.h" +#include "saga/animation.h" #include "saga/interface.h" #include "saga/music.h" #include "saga/rscfile.h" @@ -521,11 +522,15 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_actor->loadObjList(_metaResource.objectCount, _metaResource.objectsResourceID); - // TODO: cutawayList + _vm->_resource->loadResource(resourceContext, _metaResource.cutawayListResourceID, resourcePointer, resourceLength); - // TODO: songTable Long - _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, - resourcePointer, resourceLength); + if (resourceLength == 0) { + error("Resource::loadGlobalResources Can't load cutaway list"); + } + + _vm->_anim->loadCutawayList(resourcePointer, resourceLength); + + _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, resourcePointer, resourceLength); if (resourceLength == 0) { error("Resource::loadGlobalResources Can't load songs list for current track"); diff --git a/saga/scene.cpp b/saga/scene.cpp index ae8104a924..dd58ba67cb 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -478,12 +478,6 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy loadScene(&sceneParams); } -void Scene::freeCutawayList() { - // TODO - // It has to be in different class - warning("STUB: freeCutawayList()"); -} - void Scene::getSlopes(int &beginSlope, int &endSlope) { beginSlope = _vm->getSceneHeight() - _sceneDescription.beginSlope; endSlope = _vm->getSceneHeight() - _sceneDescription.endSlope; @@ -608,7 +602,7 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { if (loadSceneParams->chapter == 6) _vm->_interface->setLeftPortrait(0); - freeCutawayList(); + _vm->_anim->freeCutawayList(); _vm->_script->freeModules(); // deleteAllScenes(); diff --git a/saga/scene.h b/saga/scene.h index 2547016afb..f47dac78d4 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -251,11 +251,9 @@ class Scene { _sceneQueue.clear(); } void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = NO_CHAPTER_CHANGE); - void freeCutawayList(); bool isSceneLoaded() const { return _sceneLoaded; } - int getSceneResourceId(int sceneNumber) { if ((sceneNumber < 0) || (sceneNumber >= _sceneCount)) { error("getSceneResourceId: wrong sceneNumber %i", sceneNumber); |