aboutsummaryrefslogtreecommitdiff
path: root/scumm/script_v2.cpp
diff options
context:
space:
mode:
authorMax Horn2003-09-10 15:02:58 +0000
committerMax Horn2003-09-10 15:02:58 +0000
commit1080dac5ac0a52782bbdb25928a3485651a111b9 (patch)
treec8be09c7a752e3f47cdd4d85ce4b5f827232e7e7 /scumm/script_v2.cpp
parent1ccc58aa035d3d74efe1dc66f7327b432727a8f1 (diff)
downloadscummvm-rg350-1080dac5ac0a52782bbdb25928a3485651a111b9.tar.gz
scummvm-rg350-1080dac5ac0a52782bbdb25928a3485651a111b9.tar.bz2
scummvm-rg350-1080dac5ac0a52782bbdb25928a3485651a111b9.zip
instead of abusing the 'recursive' attribute to flag V2 background scripts, use the freezeResistant attribute. This is a bit more consistent. Also, verb 254 should stop *any* sentence script, not just background ones; some cleanup
svn-id: r10159
Diffstat (limited to 'scumm/script_v2.cpp')
-rw-r--r--scumm/script_v2.cpp92
1 files changed, 31 insertions, 61 deletions
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 3a56085e83..ea8546b8a7 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -906,27 +906,34 @@ void Scumm_v2::o2_doSentence() {
st->preposition = (st->objectB != 0);
st->freezeCount = 0;
- // TODO
- switch(fetchScriptByte()) {
+ // Execute or print the sentence
+ _opcode = fetchScriptByte();
+ switch(_opcode) {
+ case 0:
+ // Do nothing (besides setting up the sentence above)
+ break;
case 1:
// Execute the sentence
_sentenceNum--;
if (st->verb == 254) {
- stopObjectScript(st->objectA, true);
+ Scumm::stopObjectScript(st->objectA);
} else if (st->verb != 253 && st->verb != 250) {
VAR(VAR_ACTIVE_VERB) = st->verb;
VAR(VAR_ACTIVE_OBJECT1) = st->objectA;
VAR(VAR_ACTIVE_OBJECT2) = st->objectB;
+ stopObjectScript(st->objectA, false);
runObjectScript(st->objectA, st->verb, false, false, NULL);
- } else
- runObjectScript(st->objectA, 253, (st->verb == 250), true, NULL);
+ } else {
+ bool isBackgroundScript = (st->verb == 250);
+ stopObjectScript(st->objectA, isBackgroundScript);
+ runObjectScript(st->objectA, 253, isBackgroundScript, false, NULL);
+ }
break;
case 2:
// Print the sentence
_sentenceNum--;
- //warning("TODO o2_doSentence(%d, %d, %d): print", st->verb, st->objectA, st->objectB);
VAR(VAR_SENTENCE_VERB) = st->verb;
VAR(VAR_SENTENCE_OBJECT1) = st->objectA;
@@ -934,6 +941,8 @@ void Scumm_v2::o2_doSentence() {
o2_drawSentence();
break;
+ default:
+ error("o2_doSentence: unknown subopcode %d", _opcode);
}
}
@@ -1548,47 +1557,8 @@ enum {
ssRunning = 2
};
-void Scumm_v2::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars) {
- ScriptSlot *s;
- uint32 obcd;
- int slot, where, offs;
-
- if (!object)
- return;
-
- stopObjectScript(object, recursive);
-
- where = whereIsObject(object);
-
- if (where == WIO_NOT_FOUND) {
- warning("Code for object %d not in room %d", object, _roomResource);
- return;
- }
-
- obcd = getOBCDOffs(object);
- slot = getScriptSlot();
-
- offs = getVerbEntrypoint(object, entry);
- if (offs == 0)
- return;
-
- s = &vm.slot[slot];
- s->number = object;
- s->offs = obcd + offs;
- s->status = ssRunning;
- s->where = where;
- s->freezeResistant = freezeResistant;
- s->recursive = recursive;
- s->freezeCount = 0;
- s->delayFrameCount = 0;
-
- initializeLocals(slot, vars);
-
- runScriptNested(slot);
-}
-
/* Stop an object script 'script'*/
-void Scumm_v2::stopObjectScript(int script, bool recursive) {
+void Scumm_v2::stopObjectScript(int script, bool background) {
ScriptSlot *ss;
NestedScript *nest;
int i, num;
@@ -1596,12 +1566,26 @@ void Scumm_v2::stopObjectScript(int script, bool recursive) {
if (script == 0)
return;
+ ss = vm.slot;
+ for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
+ if (script == ss->number && ss->status != ssDead &&
+ ss->freezeResistant == background &&
+ (ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) {
+ if (ss->cutsceneOverride)
+ error("Object %d stopped with active cutscene/override", script);
+ ss->number = 0;
+ ss->status = ssDead;
+ if (_currentScript == i)
+ _currentScript = 0xFF;
+ }
+ }
+
nest = vm.nest;
num = _numNestedScripts;
while (num > 0) {
if (nest->number == script &&
- vm.slot[nest->slot].recursive == recursive &&
+ vm.slot[nest->slot].freezeResistant == background &&
(nest->where == WIO_ROOM || nest->where == WIO_INVENTORY || nest->where == WIO_FLOBJECT)) {
nest->number = 0xFF;
nest->slot = 0xFF;
@@ -1610,18 +1594,4 @@ void Scumm_v2::stopObjectScript(int script, bool recursive) {
nest++;
num--;
}
-
- ss = vm.slot;
- for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
- if (script == ss->number && ss->status != ssDead &&
- ss->recursive == recursive &&
- (ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) {
- if (ss->cutsceneOverride)
- error("Object %d stopped with active cutscene/override", script);
- ss->number = 0;
- ss->status = ssDead;
- if (_currentScript == i)
- _currentScript = 0xFF;
- }
- }
}