diff options
author | Eugene Sandulenko | 2005-04-16 20:59:24 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-04-16 20:59:24 +0000 |
commit | 44acfd9467e126d324a6ac730dccedd30c916480 (patch) | |
tree | fed123167f011ddcec3a44879993d126e1eb8130 | |
parent | aea451f092a90bdc28bc8bd82508ec40b9920868 (diff) | |
download | scummvm-rg350-44acfd9467e126d324a6ac730dccedd30c916480.tar.gz scummvm-rg350-44acfd9467e126d324a6ac730dccedd30c916480.tar.bz2 scummvm-rg350-44acfd9467e126d324a6ac730dccedd30c916480.zip |
Implement sfGetDeltaFrame and sfEnableZone. Fixes freeze when sanctuary
gates open and also used in world map.
Spelling and indentation fixes here and there.
svn-id: r17640
-rw-r--r-- | saga/animation.cpp | 11 | ||||
-rw-r--r-- | saga/animation.h | 1 | ||||
-rw-r--r-- | saga/objectmap.h | 11 | ||||
-rw-r--r-- | saga/script.h | 4 | ||||
-rw-r--r-- | saga/sfuncs.cpp | 29 |
5 files changed, 40 insertions, 16 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp index 0f2ffca611..5948cb78d5 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -157,7 +157,7 @@ int Anim::link(int16 anim_id1, int16 anim_id2) { void Anim::setCycles(uint animId, int cycles) { if (animId >= _anim_count) { - warning("Anim::setStopFrame(): wrong animation number (%d)", animId); + warning("Anim::setCycles(): wrong animation number (%d)", animId); return; } @@ -393,6 +393,15 @@ int Anim::setFrameTime(uint16 anim_id, int time) { return SUCCESS; } +int16 Anim::getCurrentFrame(uint16 animId) { + if (animId >= _anim_count) { + warning("Anim::stop(): wrong animation number (%d)", animId); + return 0; + } + + return _anim_tbl[animId]->current_frame; +} + int Anim::freeId(uint16 anim_id) { ANIMATION *anim; diff --git a/saga/animation.h b/saga/animation.h index b1f6cd405b..5f990545b1 100644 --- a/saga/animation.h +++ b/saga/animation.h @@ -120,6 +120,7 @@ public: void stop(uint16 animId); void finish(uint16 animId); void resume(uint16 animId, int cycles); + int16 getCurrentFrame(uint16 anim_id); private: int ITE_DecodeFrame(const byte *anim_resource, size_t anim_resource_len, size_t frame_offset, byte *buf, size_t buf_len); diff --git a/saga/objectmap.h b/saga/objectmap.h index dc97271912..76a45dd284 100644 --- a/saga/objectmap.h +++ b/saga/objectmap.h @@ -37,8 +37,8 @@ private: int pointsCount; Point *points; }; + public: - HitZone(MemoryReadStreamEndian *readStream, int index); ~HitZone(); @@ -60,6 +60,12 @@ public: int getFlags() const { return _flags; } + void setFlag(HitZoneFlags flag) { + _flags |= flag; + } + void clearFlag(HitZoneFlags flag) { + _flags &= ~flag; + } int getDirection() const { return ((_flags >> 4) & 0xF); } @@ -72,6 +78,7 @@ public: bool getSpecialPoint(Point &specialPoint) const; void draw(SURFACE *ds, int color); bool hitTest(const Point &testPoint); + private: int _flags; // Saga::HitZoneFlags int _clickAreasCount; @@ -99,7 +106,7 @@ public: void draw(SURFACE *drawSurface, const Point& testPoint, int color, int color2); int hitTest(const Point& testPoint); - const HitZone * getHitZone(int index) const { + HitZone *getHitZone(int16 index) { if ((index < 0) || (index >= _hitZoneListCount)) { error("ObjectMap::getHitZone wrong index 0x%X", index); } diff --git a/saga/script.h b/saga/script.h index ccb81ab1a4..394a561ba9 100644 --- a/saga/script.h +++ b/saga/script.h @@ -486,7 +486,7 @@ private: void sfDoCenterActor(SCRIPTFUNC_PARAMS); void sfStartBgdAnimSpeed(SCRIPTFUNC_PARAMS); void sfScriptWalkToAsync(SCRIPTFUNC_PARAMS); - void SF_enableZone(SCRIPTFUNC_PARAMS); + void sfEnableZone(SCRIPTFUNC_PARAMS); void sfSetActorState(SCRIPTFUNC_PARAMS); void sfScriptMoveTo(SCRIPTFUNC_PARAMS); void SF_sceneEq(SCRIPTFUNC_PARAMS); @@ -530,7 +530,7 @@ private: void sfEnableEscape(SCRIPTFUNC_PARAMS); void sfPlaySound(SCRIPTFUNC_PARAMS); void SF_playLoopedSound(SCRIPTFUNC_PARAMS); - void SF_getDeltaFrame(SCRIPTFUNC_PARAMS); + void sfGetDeltaFrame(SCRIPTFUNC_PARAMS); void SF_showProtect(SCRIPTFUNC_PARAMS); void SF_protectResult(SCRIPTFUNC_PARAMS); void sfRand(SCRIPTFUNC_PARAMS); diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index 68b21b082d..947ae14dce 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -78,7 +78,7 @@ void Script::setupScriptFuncList(void) { OPCODE(sfDoCenterActor), OPCODE(sfStartBgdAnimSpeed), OPCODE(sfScriptWalkToAsync), - OPCODE(SF_enableZone), + OPCODE(sfEnableZone), OPCODE(sfSetActorState), OPCODE(sfScriptMoveTo), OPCODE(SF_sceneEq), @@ -122,7 +122,7 @@ void Script::setupScriptFuncList(void) { OPCODE(sfEnableEscape), OPCODE(sfPlaySound), OPCODE(SF_playLoopedSound), - OPCODE(SF_getDeltaFrame), + OPCODE(sfGetDeltaFrame), OPCODE(SF_showProtect), OPCODE(SF_protectResult), OPCODE(sfRand), @@ -610,7 +610,6 @@ void Script::sfSetBgdAnimSpeed(SCRIPTFUNC_PARAMS) { _vm->_anim->setFrameTime(animId, ticksToMSec(speed)); debug(1, "sfSetBgdAnimSpeed(%d, %d)", animId, speed); - } // Script function #24 (0x18) @@ -665,11 +664,20 @@ void Script::sfScriptWalkToAsync(SCRIPTFUNC_PARAMS) { } // Script function #28 (0x1C) -void Script::SF_enableZone(SCRIPTFUNC_PARAMS) { - for (int i = 0; i < nArgs; i++) - thread->pop(); +void Script::sfEnableZone(SCRIPTFUNC_PARAMS) { + int16 hitZoneIndex = objectIdToIndex(thread->pop()); + int16 flag = thread->pop(); + HitZone *hitZone; + + debug(0, "sfEnableZone(%d, %d)", hitZoneIndex, flag); + hitZone = _vm->_scene->_objectMap->getHitZone(hitZoneIndex); - debug(1, "stub: SF_enableZone(), %d args", nArgs); + if (flag) { + hitZone->setFlag(kHitZoneEnabled); + } else { + hitZone->clearFlag(kHitZoneEnabled); + _vm->_actor->_protagonist->lastZone = NULL; + } } // Script function #29 (0x1D) @@ -1587,11 +1595,10 @@ void Script::SF_playLoopedSound(SCRIPTFUNC_PARAMS) { } // Script function #72 (0x48) -void Script::SF_getDeltaFrame(SCRIPTFUNC_PARAMS) { - for (int i = 0; i < nArgs; i++) - thread->pop(); +void Script::sfGetDeltaFrame(SCRIPTFUNC_PARAMS) { + uint16 animId = (uint16)thread->pop(); - debug(1, "stub: SF_getDeltaFrame(), %d args", nArgs); + thread->_returnValue = _vm->_anim->getCurrentFrame(animId); } // Script function #73 (0x49) |