aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/script.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-06-28 16:19:10 +0000
committerDenis Kasak2009-06-28 16:19:10 +0000
commitf61b2d289d0e6ec960e20ac5b59a0fe7dfe8740e (patch)
tree2acbce26249ce6b898032ba8590a094ec3faada5 /engines/draci/script.cpp
parent948bf2cfcc23dc95fa7b29ff2f6ae7a27af132bd (diff)
downloadscummvm-rg350-f61b2d289d0e6ec960e20ac5b59a0fe7dfe8740e.tar.gz
scummvm-rg350-f61b2d289d0e6ec960e20ac5b59a0fe7dfe8740e.tar.bz2
scummvm-rg350-f61b2d289d0e6ec960e20ac5b59a0fe7dfe8740e.zip
Changed Script::run() to accept a GPL2Program struct instead of a byte pointer and a length. Also, Script::run() now executes the GPL program until a gplend instruction rather than to the end of the whole program. Modified GameObject according to the new changes.
svn-id: r41927
Diffstat (limited to 'engines/draci/script.cpp')
-rw-r--r--engines/draci/script.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index c04100af78..751aadc3f3 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -246,8 +246,7 @@ GPL2Command *Script::findCommand(byte num, byte subnum) {
/**
* @brief GPL2 bytecode disassembler
- * @param gplcode A pointer to the bytecode
- * @param len Length of the bytecode
+ * @param program GPL program in the form of a GPL2Program struct
*
* 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.
@@ -275,10 +274,11 @@ GPL2Command *Script::findCommand(byte num, byte subnum) {
* value comes from.
*/
-int Script::run(byte *gplcode, uint16 len) {
- Common::MemoryReadStream reader(gplcode, len);
+int Script::run(GPL2Program program) {
+ Common::MemoryReadStream reader(program._bytecode, program._length);
- while (!reader.eos()) {
+ GPL2Command *cmd;
+ do {
// read in command pair
uint16 cmdpair = reader.readUint16BE();
@@ -288,7 +288,6 @@ int Script::run(byte *gplcode, uint16 len) {
// extract low byte, i.e. the command subnumber
byte subnum = cmdpair & 0xFF;
- GPL2Command *cmd;
if ((cmd = findCommand(num, subnum))) {
// Print command name
@@ -308,9 +307,7 @@ int Script::run(byte *gplcode, uint16 len) {
debugC(2, kDraciBytecodeDebugLevel, "Unknown opcode %hu, %hu",
num, subnum);
}
-
-
- }
+ } while (cmd->_name != "gplend");
return 0;
}