From 885ce59ce8b02046e165598c40facccceda48927 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sat, 4 Jul 2009 14:48:36 +0000 Subject: Restructured Script so I can start adding callbacks to GPL commands (added DraciEngine * member to Script, added Script::setupCommandList() which initialises the command list array, added Script::dummy() callback for the Load command for testing). svn-id: r42090 --- engines/draci/script.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'engines/draci/script.h') diff --git a/engines/draci/script.h b/engines/draci/script.h index ac994f1d27..c4d9e75100 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -28,13 +28,21 @@ #include "common/str.h" #include "common/stream.h" +#include "common/queue.h" namespace Draci { /** The maximum number of parameters for a GPL command */ const int kMaxParams = 3; -// FIXME: Add function handlers +class DraciEngine; +class Script; + +enum { + kNumCommands = 55 +}; + +typedef void (Script::* GPLHandler)(Common::Queue &); /** * Represents a single command in the GPL scripting language bytecode. @@ -48,6 +56,7 @@ struct GPL2Command { Common::String _name; uint16 _numParams; int _paramTypes[kMaxParams]; + GPLHandler _handler; }; /** @@ -65,11 +74,22 @@ struct GPL2Program { class Script { public: + Script(DraciEngine *vm) : _vm(vm) { setupCommandList(); }; + int run(GPL2Program program, uint16 offset); - + private: - GPL2Command *findCommand(byte num, byte subnum); - void handleMathExpression(Common::MemoryReadStream &reader); + + /** List of all GPL commands. Initialised in the constructor. */ + const GPL2Command *_commandList; + + void dummy(Common::Queue ¶ms); + + void setupCommandList(); + const GPL2Command *findCommand(byte num, byte subnum); + int handleMathExpression(Common::MemoryReadStream &reader); + + DraciEngine *_vm; }; -- cgit v1.2.3