diff options
author | Max Horn | 2003-01-01 18:22:41 +0000 |
---|---|---|
committer | Max Horn | 2003-01-01 18:22:41 +0000 |
commit | 535ad0a4cf8fe0325f04a665c4dbf0773f7e66b0 (patch) | |
tree | 2ddde9bb8c58f1059e6df4278d1720738c152e24 /scumm/script.cpp | |
parent | 53a8fc24fe6b248234a2e2b5036526097f5a7834 (diff) | |
download | scummvm-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
Diffstat (limited to 'scumm/script.cpp')
-rw-r--r-- | scumm/script.cpp | 218 |
1 files changed, 101 insertions, 117 deletions
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; } |