aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-01-01 18:22:41 +0000
committerMax Horn2003-01-01 18:22:41 +0000
commit535ad0a4cf8fe0325f04a665c4dbf0773f7e66b0 (patch)
tree2ddde9bb8c58f1059e6df4278d1720738c152e24
parent53a8fc24fe6b248234a2e2b5036526097f5a7834 (diff)
downloadscummvm-rg350-535ad0a4cf8fe0325f04a665c4dbf0773f7e66b0.tar.gz
scummvm-rg350-535ad0a4cf8fe0325f04a665c4dbf0773f7e66b0.tar.bz2
scummvm-rg350-535ad0a4cf8fe0325f04a665c4dbf0773f7e66b0.zip
moved Scumm::faceActorToObj to Actor::faceToObject; moved various functions in script.cpp (grouping cutscene/override related stuff)
svn-id: r6317
-rw-r--r--scumm/actor.cpp16
-rw-r--r--scumm/actor.h20
-rw-r--r--scumm/script.cpp218
-rw-r--r--scumm/script_v5.cpp7
-rw-r--r--scumm/script_v6.cpp9
-rw-r--r--scumm/scumm.h1
6 files changed, 136 insertions, 135 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 2442e8fa73..746e26fe81 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -27,7 +27,7 @@
#include "charset.h"
#include "costume.h"
#include "resource.h"
-#include "scumm/sound.h"
+#include "sound.h"
#include <math.h>
@@ -722,6 +722,20 @@ void Actor::adjustActorPos()
}
}
+void Actor::factToObject(int obj)
+{
+ int x2, y2, dir;
+
+ if (!isInCurrentRoom())
+ return;
+
+ if (_vm->getObjectOrActorXY(obj, x2, y2) == -1)
+ return;
+
+ dir = (x2 > x) ? 90 : 270;
+ turnToDirection(dir);
+}
+
void Actor::turnToDirection(int newdir)
{
if (newdir == -1)
diff --git a/scumm/actor.h b/scumm/actor.h
index f1e993f863..c32bf8e0a4 100644
--- a/scumm/actor.h
+++ b/scumm/actor.h
@@ -124,23 +124,16 @@ protected:
int actorWalkStep();
int remapDirection(int dir, bool is_walking);
void setupActorScale();
-public:
- void stopActorMoving();
- void startWalkAnim(int cmd, int angle);
- void startAnimActor(int frame);
-protected:
void setBox(int box);
int updateActorDirection(bool is_walking);
+ void adjustActorPos();
public:
- void setDirection(int direction);
- int getActorXYPos(int &x, int &y);
-
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
-protected:
- void adjustActorPos();
-public:
+
+ void setDirection(int direction);
+ void factToObject(int obj);
void turnToDirection(int newdir);
void walkActor();
void drawActorCostume();
@@ -148,6 +141,9 @@ public:
void setActorCostume(int c);
byte *getActorName();
void startWalkActor(int x, int y, int dir);
+ void stopActorMoving();
+ void startWalkAnim(int cmd, int angle);
+ void startAnimActor(int frame);
void remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold);
void walkActorOld();
@@ -158,6 +154,8 @@ public:
return room == _vm->_currentRoom;
}
+ int getActorXYPos(int &x, int &y);
+
int getRoom() {
return room;
}
diff --git a/scumm/script.cpp b/scumm/script.cpp
index f64e4658c7..8583d5663e 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -758,6 +758,43 @@ void Scumm::killAllScriptsExceptCurrent()
}
}
+void Scumm::doSentence(int c, int b, int a)
+{
+ SentenceTab *st;
+
+ if (_features & GF_AFTER_V7) {
+
+ if (b == a)
+ return;
+
+ st = &_sentence[_sentenceNum - 1];
+
+
+ // Check if this doSentence request is identical to the previous one;
+ // if yes, ignore this invocation.
+ if (_sentenceNum && st->unk5 == c && st->unk4 == b && st->unk3 == a)
+ return;
+
+ _sentenceNum++;
+ st++;
+
+ } else {
+
+ st = &_sentence[_sentenceNum++];
+
+ if (!(st->unk3 & 0xFF00))
+ st->unk2 = 0;
+ else
+ st->unk2 = 1;
+
+ }
+
+ st->unk5 = c;
+ st->unk4 = b;
+ st->unk3 = a;
+ st->freezeCount = 0;
+}
+
void Scumm::checkAndRunSentenceScript()
{
int i;
@@ -915,62 +952,6 @@ int Scumm::getVerbEntrypoint(int obj, int entry)
}
}
-void Scumm::endCutscene()
-{
- ScriptSlot *ss = &vm.slot[_currentScript];
- int args[16];
-
- memset(args, 0, sizeof(args));
-
- if (ss->cutsceneOverride > 0) // Only terminate if active
- ss->cutsceneOverride--;
-
- args[0] = vm.cutSceneData[vm.cutSceneStackPointer];
- _vars[VAR_OVERRIDE] = 0;
-
- if (vm.cutScenePtr[vm.cutSceneStackPointer] && (ss->cutsceneOverride > 0)) // Only terminate if active
- ss->cutsceneOverride--;
-
- vm.cutSceneScript[vm.cutSceneStackPointer] = 0;
- vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
- vm.cutSceneStackPointer--;
-
- if (_vars[VAR_CUTSCENE_END_SCRIPT])
- runScript(_vars[VAR_CUTSCENE_END_SCRIPT], 0, 0, args);
-}
-
-void Scumm::cutscene(int *args)
-{
- int scr = _currentScript;
- vm.slot[scr].cutsceneOverride++;
-
- if (++vm.cutSceneStackPointer > sizeof(vm.cutSceneData) / sizeof(vm.cutSceneData[0]))
- error("Cutscene stack overflow");
-
- vm.cutSceneData[vm.cutSceneStackPointer] = args[0];
- vm.cutSceneScript[vm.cutSceneStackPointer] = 0;
- vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
-
- vm.cutSceneScriptIndex = scr;
- if (_vars[VAR_CUTSCENE_START_SCRIPT])
- runScript(_vars[VAR_CUTSCENE_START_SCRIPT], 0, 0, args);
- vm.cutSceneScriptIndex = 0xFF;
-}
-
-void Scumm::faceActorToObj(int act, int obj)
-{
- int x, x2, y, dir;
-
- if (getObjectOrActorXY(act, x, y) == -1)
- return;
-
- if (getObjectOrActorXY(obj, x2, y) == -1)
- return;
-
- dir = (x2 > x) ? 90 : 270;
- derefActorSafe(act, "faceActorToObj")->turnToDirection(dir);
-}
-
bool Scumm::isScriptRunning(int script)
{
int i;
@@ -992,38 +973,6 @@ bool Scumm::isRoomScriptRunning(int script)
}
-
-void Scumm::beginOverride()
-{
- int idx;
-
- idx = vm.cutSceneStackPointer;
- assert(idx < 5);
-
- vm.cutScenePtr[idx] = _scriptPointer - _scriptOrgPointer;
- vm.cutSceneScript[idx] = _currentScript;
-
- // Skip the jump instruction following the override instruction
- // (the jump is responsible for "skipping" cutscenes, and the reason
- // why we record the current script position in vm.cutScenePtr).
- fetchScriptByte();
- fetchScriptWord();
- _vars[VAR_OVERRIDE] = 0;
-}
-
-void Scumm::endOverride()
-{
- int idx;
-
- idx = vm.cutSceneStackPointer;
- assert(idx < 5);
-
- vm.cutScenePtr[idx] = 0;
- vm.cutSceneScript[idx] = 0;
- _vars[VAR_OVERRIDE] = 0;
-}
-
-
int Scumm::defineArray(int array, int type, int dim2, int dim1)
{
int id;
@@ -1139,6 +1088,48 @@ int Scumm::resStrLen(const byte *src) const
return num;
}
+void Scumm::cutscene(int *args)
+{
+ int scr = _currentScript;
+ vm.slot[scr].cutsceneOverride++;
+
+ if (++vm.cutSceneStackPointer > sizeof(vm.cutSceneData) / sizeof(vm.cutSceneData[0]))
+ error("Cutscene stack overflow");
+
+ vm.cutSceneData[vm.cutSceneStackPointer] = args[0];
+ vm.cutSceneScript[vm.cutSceneStackPointer] = 0;
+ vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
+
+ vm.cutSceneScriptIndex = scr;
+ if (_vars[VAR_CUTSCENE_START_SCRIPT])
+ runScript(_vars[VAR_CUTSCENE_START_SCRIPT], 0, 0, args);
+ vm.cutSceneScriptIndex = 0xFF;
+}
+
+void Scumm::endCutscene()
+{
+ ScriptSlot *ss = &vm.slot[_currentScript];
+ int args[16];
+
+ memset(args, 0, sizeof(args));
+
+ if (ss->cutsceneOverride > 0) // Only terminate if active
+ ss->cutsceneOverride--;
+
+ args[0] = vm.cutSceneData[vm.cutSceneStackPointer];
+ _vars[VAR_OVERRIDE] = 0;
+
+ if (vm.cutScenePtr[vm.cutSceneStackPointer] && (ss->cutsceneOverride > 0)) // Only terminate if active
+ ss->cutsceneOverride--;
+
+ vm.cutSceneScript[vm.cutSceneStackPointer] = 0;
+ vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
+ vm.cutSceneStackPointer--;
+
+ if (_vars[VAR_CUTSCENE_END_SCRIPT])
+ runScript(_vars[VAR_CUTSCENE_END_SCRIPT], 0, 0, args);
+}
+
void Scumm::exitCutscene()
{
uint32 offs = vm.cutScenePtr[vm.cutSceneStackPointer];
@@ -1151,44 +1142,37 @@ void Scumm::exitCutscene()
if (ss->cutsceneOverride > 0)
ss->cutsceneOverride--;
-printf("exitCutscene()\n");
_vars[VAR_OVERRIDE] = 1;
vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
}
}
-void Scumm::doSentence(int c, int b, int a)
-{
- SentenceTab *st;
-
- if (_features & GF_AFTER_V7) {
- if (b == a)
- return;
-
- st = &_sentence[_sentenceNum - 1];
-
-
- // Check if this doSentence request is identical to the previous one;
- // if yes, ignore this invocation.
- if (_sentenceNum && st->unk5 == c && st->unk4 == b && st->unk3 == a)
- return;
+void Scumm::beginOverride()
+{
+ int idx;
- _sentenceNum++;
- st++;
+ idx = vm.cutSceneStackPointer;
+ assert(idx < 5);
- } else {
+ vm.cutScenePtr[idx] = _scriptPointer - _scriptOrgPointer;
+ vm.cutSceneScript[idx] = _currentScript;
- st = &_sentence[_sentenceNum++];
+ // Skip the jump instruction following the override instruction
+ // (the jump is responsible for "skipping" cutscenes, and the reason
+ // why we record the current script position in vm.cutScenePtr).
+ fetchScriptByte();
+ fetchScriptWord();
+ _vars[VAR_OVERRIDE] = 0;
+}
- if (!(st->unk3 & 0xFF00))
- st->unk2 = 0;
- else
- st->unk2 = 1;
+void Scumm::endOverride()
+{
+ int idx;
- }
+ idx = vm.cutSceneStackPointer;
+ assert(idx < 5);
- st->unk5 = c;
- st->unk4 = b;
- st->unk3 = a;
- st->freezeCount = 0;
+ vm.cutScenePtr[idx] = 0;
+ vm.cutSceneScript[idx] = 0;
+ _vars[VAR_OVERRIDE] = 0;
}
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 6310f058f5..007c527cc9 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -866,9 +866,14 @@ void Scumm_v5::o5_expression()
void Scumm_v5::o5_faceActor()
{
int act, obj;
+ Actor *a;
act = getVarOrDirectByte(0x80);
obj = getVarOrDirectWord(0x40);
- faceActorToObj(act, obj);
+
+ a = derefActorSafe(act, "o5_faceActor");
+ assert(a);
+
+ a->factToObject(obj);
}
void Scumm_v5::o5_findInventory()
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index 8320058411..8ba698c26e 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -1135,10 +1135,11 @@ void Scumm_v6::o6_putActorAtObject()
void Scumm_v6::o6_faceActor()
{
- int act, obj;
- obj = pop();
- act = pop();
- faceActorToObj(act, obj);
+ int obj = pop();
+ Actor *a = derefActorSafe(pop(), "o6_faceActor");
+ assert(a);
+
+ a->factToObject(obj);
}
void Scumm_v6::o6_animateActor()
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 947ec74367..716d94927f 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -644,7 +644,6 @@ public:
void resetActorBgs();
void processActors();
int getActorFromPos(int x, int y);
- void faceActorToObj(int act, int obj);
void actorFollowCamera(int act);
bool isCostumeInUse(int i);