aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/animation.cpp11
-rw-r--r--saga/animation.h1
-rw-r--r--saga/objectmap.h11
-rw-r--r--saga/script.h4
-rw-r--r--saga/sfuncs.cpp29
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)