diff options
author | Denis Kasak | 2009-06-28 16:28:16 +0000 |
---|---|---|
committer | Denis Kasak | 2009-06-28 16:28:16 +0000 |
commit | 6a78781889a9803ae06f2818c2809f2625baefb8 (patch) | |
tree | f050c6533978cdc61812f115222f03ae37d01a0a | |
parent | f61b2d289d0e6ec960e20ac5b59a0fe7dfe8740e (diff) | |
download | scummvm-rg350-6a78781889a9803ae06f2818c2809f2625baefb8.tar.gz scummvm-rg350-6a78781889a9803ae06f2818c2809f2625baefb8.tar.bz2 scummvm-rg350-6a78781889a9803ae06f2818c2809f2625baefb8.zip |
Added an offset parameter to Script::run() so we can specify where to start the GPL program execution. Also, the init script for the dragon object is now run inside Game::Game().
svn-id: r41928
-rw-r--r-- | engines/draci/game.cpp | 1 | ||||
-rw-r--r-- | engines/draci/script.cpp | 11 | ||||
-rw-r--r-- | engines/draci/script.h | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 9b8a2855ef..76dee965f1 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -123,6 +123,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { // assert(curOffset == _info->_numDialogBlocks); loadObject(0, &_heroObj); + _vm->_script->run(_heroObj._program, _heroObj._init); } void Game::loadObject(uint16 objNum, GameObject *obj) { diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 751aadc3f3..ce38960265 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -247,6 +247,7 @@ GPL2Command *Script::findCommand(byte num, byte subnum) { /** * @brief GPL2 bytecode disassembler * @param program GPL program in the form of a GPL2Program struct + * offset Offset into the program where execution should begin * * GPL2 is short for Game Programming Language 2 which is the script language * used by Draci Historie. This is a simple disassembler for the language. @@ -274,9 +275,17 @@ GPL2Command *Script::findCommand(byte num, byte subnum) { * value comes from. */ -int Script::run(GPL2Program program) { +int Script::run(GPL2Program program, uint16 offset) { Common::MemoryReadStream reader(program._bytecode, program._length); + // Offset is given as number of 16-bit integers so we need to convert + // it to a number of bytes + offset -= 1; + offset *= 2; + + // Seek to the requested part of the program + reader.seek(offset); + GPL2Command *cmd; do { // read in command pair diff --git a/engines/draci/script.h b/engines/draci/script.h index 55712e99f2..ac994f1d27 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -65,7 +65,7 @@ struct GPL2Program { class Script { public: - int run(GPL2Program program); + int run(GPL2Program program, uint16 offset); private: GPL2Command *findCommand(byte num, byte subnum); |