diff options
author | Travis Howell | 2005-02-28 13:23:10 +0000 |
---|---|---|
committer | Travis Howell | 2005-02-28 13:23:10 +0000 |
commit | 36705d43444e5e5ec668b8b895278ca9c38c0240 (patch) | |
tree | 662629d9bf2d3f19363813d2f0d219b0e36ed378 | |
parent | 9424c5aef252869835a296c1c497807fe6f3c0c6 (diff) | |
download | scummvm-rg350-36705d43444e5e5ec668b8b895278ca9c38c0240.tar.gz scummvm-rg350-36705d43444e5e5ec668b8b895278ca9c38c0240.tar.bz2 scummvm-rg350-36705d43444e5e5ec668b8b895278ca9c38c0240.zip |
Add support for script cycles used by HE90+ games.
svn-id: r16958
-rw-r--r-- | scumm/saveload.cpp | 4 | ||||
-rw-r--r-- | scumm/saveload.h | 2 | ||||
-rw-r--r-- | scumm/script.cpp | 28 | ||||
-rw-r--r-- | scumm/script.h | 1 | ||||
-rw-r--r-- | scumm/script_v90he.cpp | 4 | ||||
-rw-r--r-- | scumm/scumm.cpp | 3 | ||||
-rw-r--r-- | scumm/scumm.h | 7 | ||||
-rw-r--r-- | scumm/vars.cpp | 5 |
8 files changed, 39 insertions, 15 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index d6de19dbcd..5d32a184c5 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -404,8 +404,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { MKLINE(ObjectData, parent, sleByte, VER(8)), MKLINE(ObjectData, state, sleByte, VER(8)), MKLINE(ObjectData, fl_object_index, sleByte, VER(8)), - // TODO - //MKLINE(ObjectData, flag, sleByte, VER(XXX)), + MKLINE(ObjectData, flags, sleByte, VER(46)), MKEND() }; @@ -609,6 +608,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { MKLINE(ScriptSlot, freezeCount, sleByte, VER(8)), MKLINE(ScriptSlot, didexec, sleByte, VER(8)), MKLINE(ScriptSlot, cutsceneOverride, sleByte, VER(8)), + MKLINE(ScriptSlot, cycle, sleByte, VER(46)), MK_OBSOLETE(ScriptSlot, unk5, sleByte, VER(8), VER(10)), MKEND() }; diff --git a/scumm/saveload.h b/scumm/saveload.h index 747e06799f..0844dac53f 100644 --- a/scumm/saveload.h +++ b/scumm/saveload.h @@ -32,7 +32,7 @@ namespace Scumm { // Can be useful for other ports too :) #define VER(x) x -#define CURRENT_VER 45 +#define CURRENT_VER 46 // To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types, // we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC diff --git a/scumm/script.cpp b/scumm/script.cpp index 7c6d5c582e..b5e106703f 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -33,7 +33,7 @@ namespace Scumm { /* Start executing script 'script' with the given parameters */ -void ScummEngine::runScript(int script, bool freezeResistant, bool recursive, int *lvarptr) { +void ScummEngine::runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle) { ScriptSlot *s; byte *scriptPtr; uint32 scriptOffs; @@ -63,6 +63,9 @@ void ScummEngine::runScript(int script, bool freezeResistant, bool recursive, in vm.slot[_currentScript].number, _roomResource); } + if (cycle == 0) + cycle = (_heversion >= 90) ? VAR(VAR_SCRIPT_CYCLE) : 1; + slot = getScriptSlot(); s = &vm.slot[slot]; @@ -74,13 +77,14 @@ void ScummEngine::runScript(int script, bool freezeResistant, bool recursive, in s->recursive = recursive; s->freezeCount = 0; s->delayFrameCount = 0; + s->cycle = cycle; initializeLocals(slot, lvarptr); runScriptNested(slot); } -void ScummEngine::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars, int slot) { +void ScummEngine::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars, int slot, int cycle) { ScriptSlot *s; uint32 obcd; int where, offs; @@ -108,6 +112,9 @@ void ScummEngine::runObjectScript(int object, int entry, bool freezeResistant, b if (offs == 0) return; + if (cycle == 0) + cycle = (_heversion >= 90) ? VAR(VAR_SCRIPT_CYCLE) : 1; + s = &vm.slot[slot]; s->number = object; s->offs = obcd + offs; @@ -117,6 +124,7 @@ void ScummEngine::runObjectScript(int object, int entry, bool freezeResistant, b s->recursive = recursive; s->freezeCount = 0; s->delayFrameCount = 0; + s->cycle = cycle; initializeLocals(slot, vars); @@ -781,12 +789,16 @@ void ScummEngine::runAllScripts() { // for loop. But in that case, _curExecScript will be equal to _currentScript. Hence // it would seem we can replace all occurances of _curExecScript by _currentScript. _currentScript = 0xFF; - for (_curExecScript = 0; _curExecScript < NUM_SCRIPT_SLOT; _curExecScript++) { - if (vm.slot[_curExecScript].status == ssRunning && vm.slot[_curExecScript].didexec == 0) { - _currentScript = (byte)_curExecScript; - getScriptBaseAddress(); - getScriptEntryPoint(); - executeScript(); + int numCycles = (_heversion >= 90) ? VAR(VAR_NUM_SCRIPT_CYCLES) : 1; + + for (int cycle = 1; cycle <= numCycles; cycle++) { + for (_curExecScript = 0; _curExecScript < NUM_SCRIPT_SLOT; _curExecScript++) { + if (vm.slot[_curExecScript].status == ssRunning && vm.slot[_curExecScript].didexec == 0) { + _currentScript = (byte)_curExecScript; + getScriptBaseAddress(); + getScriptEntryPoint(); + executeScript(); + } } } } diff --git a/scumm/script.h b/scumm/script.h index aa51e611ac..798420251b 100644 --- a/scumm/script.h +++ b/scumm/script.h @@ -50,6 +50,7 @@ struct ScriptSlot { byte where; byte freezeCount; byte cutsceneOverride; + byte cycle; }; struct NestedScript { diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index 0003c049e4..05dfc69f89 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -457,7 +457,7 @@ void ScummEngine_v90he::o90_startScriptUnk() { cycle = pop(); script = pop(); flags = fetchScriptByte(); - runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); + runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args, cycle); } void ScummEngine_v90he::o90_jumpToScriptUnk() { @@ -470,7 +470,7 @@ void ScummEngine_v90he::o90_jumpToScriptUnk() { script = pop(); flags = fetchScriptByte(); stopObjectCode(); - runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); + runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args, cycle); } void ScummEngine_v90he::o90_wizImageOps() { diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index dbeca2b03b..46d110809f 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -965,6 +965,9 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS VAR_MUSIC_CHANNEL = 0xFF; VAR_SOUND_CHANNEL = 0xFF; + VAR_NUM_SCRIPT_CYCLES = 0xFF; + VAR_SCRIPT_CYCLE = 0xFF; + VAR_NUM_ROOMS = 0xFF; VAR_NUM_SCRIPTS = 0xFF; VAR_NUM_SOUNDS = 0xFF; diff --git a/scumm/scumm.h b/scumm/scumm.h index 856931c2f6..202f40d5f8 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -560,12 +560,12 @@ protected: void startManiac(); public: - void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr); + void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0); void stopScript(int script); void nukeArrays(byte script); protected: - void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1); + void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1, int cycle = 0); void runScriptNested(int script); void executeScript(); void updateScriptPtr(); @@ -1297,6 +1297,9 @@ public: byte VAR_MUSIC_CHANNEL; byte VAR_SOUND_CHANNEL; + byte VAR_SCRIPT_CYCLE; + byte VAR_NUM_SCRIPT_CYCLES; + byte VAR_NUM_ROOMS; byte VAR_NUM_SCRIPTS; byte VAR_NUM_SOUNDS; diff --git a/scumm/vars.cpp b/scumm/vars.cpp index 4a8ced0de1..326739c339 100644 --- a/scumm/vars.cpp +++ b/scumm/vars.cpp @@ -265,6 +265,9 @@ void ScummEngine_v72he::setupScummVars() { VAR_WINDOWS_VERSION = 79; VAR_KEY_STATE = 86; if (_heversion >= 90) { + VAR_SCRIPT_CYCLE = 103; + VAR_NUM_SCRIPT_CYCLES = 104; + VAR_NUM_SPRITES = 106; VAR_WIZ_TCOLOR = 117; } @@ -508,6 +511,8 @@ void ScummEngine::initScummVars() { if (_heversion >= 80) VAR(VAR_WINDOWS_VERSION) = 40; if (_heversion >= 90) { + VAR(VAR_SCRIPT_CYCLE) = 1; + VAR(VAR_NUM_SCRIPT_CYCLES) = 1; VAR(VAR_WIZ_TCOLOR) = 5; VAR(VAR_NUM_SPRITES) = _numSprites - 1; } |