diff options
author | Paul Gilbert | 2015-01-23 21:25:58 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-23 21:25:58 -0500 |
commit | fac1d0642fe21600c775be6379c5fd4098ab9d4e (patch) | |
tree | 0749ecd2e5547a7c26bab9266b96338aec160ee9 /engines/xeen | |
parent | c08e54fde105637082ee7eb79eeacd1cb4137d57 (diff) | |
download | scummvm-rg350-fac1d0642fe21600c775be6379c5fd4098ab9d4e.tar.gz scummvm-rg350-fac1d0642fe21600c775be6379c5fd4098ab9d4e.tar.bz2 scummvm-rg350-fac1d0642fe21600c775be6379c5fd4098ab9d4e.zip |
XEEN: Implement script opcodes for cmdCallEvent and cmdReturn
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/scripts.cpp | 35 | ||||
-rw-r--r-- | engines/xeen/scripts.h | 9 |
2 files changed, 39 insertions, 5 deletions
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index bbba4b9630..247165f085 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -109,7 +109,7 @@ void Scripts::checkEvents() { // int varA = 0; _animCounter = 0; // int var4E = 0; - const Common::Point pt = party._mazePosition; + _currentPos = party._mazePosition; _charIndex = 1; _v2 = 1; _nEdamageType = 0; @@ -127,8 +127,8 @@ void Scripts::checkEvents() { for (eventIndex = 0; eventIndex < map._events.size(); ++eventIndex) { MazeEvent &event = map._events[eventIndex]; - if (event._position == pt && party._mazeDirection != (pt.x | pt.y) - && event._line == _lineNum) { + if (event._position == _currentPos && party._mazeDirection != + (_currentPos.x | _currentPos.y) && event._line == _lineNum) { if (event._direction == party._mazeDirection || event._direction == DIR_ALL) { _vm->_mode = MODE_9; _paramText = event._parameters.size() == 0 ? "" : @@ -454,8 +454,33 @@ void Scripts::cmdConfirmWord(Common::Array<byte> ¶ms) { void Scripts::cmdDamage(Common::Array<byte> ¶ms) { error("TODO"); } void Scripts::cmdJumpRnd(Common::Array<byte> ¶ms) { error("TODO"); } void Scripts::cmdAfterEvent(Common::Array<byte> ¶ms) { error("TODO"); } -void Scripts::cmdCallEvent(Common::Array<byte> ¶ms) { error("TODO"); } -void Scripts::cmdReturn(Common::Array<byte> ¶ms) { error("TODO"); } + +/** + * Stores the current location and line for later resuming, and set up to execute + * a script at a given location + */ +void Scripts::cmdCallEvent(Common::Array<byte> ¶ms) { + _stack.push(StackEntry(_currentPos, _lineNum)); + _currentPos = Common::Point(params[0], params[1]); + _lineNum = params[2] - 1; + + _var4F = true; + cmdNoAction(params); +} + +/** + * Return from executing a script to the script location that previously + * called the script + */ +void Scripts::cmdReturn(Common::Array<byte> ¶ms) { + StackEntry &se = _stack.top(); + _currentPos = se; + _lineNum = se.line; + + _var4F = true; + cmdNoAction(params); +} + void Scripts::cmdSetVar(Common::Array<byte> ¶ms) { error("TODO"); } void Scripts::cmdCutsceneEndClouds(Common::Array<byte> ¶ms) { error("TODO"); } diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h index 5f931c1fb5..2924d43b7e 100644 --- a/engines/xeen/scripts.h +++ b/engines/xeen/scripts.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/serializer.h" +#include "common/stack.h" #include "common/str-array.h" #include "xeen/files.h" @@ -117,6 +118,12 @@ public: void synchronize(XeenSerializer &s); }; +struct StackEntry : public Common::Point { + int line; + + StackEntry(const Common::Point &pt, int l) : Common::Point(pt), line(l) {} +}; + class Scripts { private: XeenEngine *_vm; @@ -133,6 +140,8 @@ private: int _nEdamageType; Common::String _paramText; MazeEvent *_event; + Common::Point _currentPos; + Common::Stack<StackEntry> _stack; void doOpcode(MazeEvent &event); void cmdDisplay1(Common::Array<byte> ¶ms); |