27 #ifndef ICB_GAME_ENGINE_SCRIPTENGINE_H 28 #define ICB_GAME_ENGINE_SCRIPTENGINE_H 30 #include "engines/icb/common/px_string.h" 31 #include "engines/icb/common/px_game_object.h" 32 #include "engines/icb/common/px_globalvariables.h" 36 #define SCRIPT_CHECK_TEXT "SDS>" 37 #define SCRIPT_CHECK_TEXT_LEN 4 39 enum scriptInterpreterReturnCodes {
40 IR_RET_END_THE_CYCLE = 0,
41 IR_RET_SCRIPT_FINISHED = 1,
42 IR_RET_CONT_THIS_CYCLE = 2
45 scriptInterpreterReturnCodes RunScript(
const char *&scriptData,
47 int32 *engineReturnValue = NULL,
48 const char *scriptSourceName = NULL);
50 void SetScriptDebugging(bool8 f);
52 extern CpxGlobalScriptVariables *g_globalScriptVariables;
54 #define CP_END_SCRIPT 0 // Terminate a script 55 #define CP_PUSH_INT32 1 // Push a number on to the stack 56 #define CP_PUSH_ADDRESS_LOCAL_VAR32 2 // Push the address of a local variable 61 #define CP_SKIPONFALSE 4 // Skip if the bottom value on the stack is false 62 #define CP_SKIPALLWAYS 5 // Skip a block of code 63 #define CP_SKIPONTRUE 6 // Skip if the bottom value on the stack is true 64 #define CP_RETURN 7 // return the value on the stack to the game engine 65 #define CP_PUSH_GLOBAL_VAR32 8 // Set a variable to 1 66 #define CP_POP_GLOBAL_VAR32 9 // Pop a global variable 67 #define CP_CALL_MCODE 10 // Call a machine code function 68 #define CP_QUIT 11 // Quit for a cycle 69 #define CP_PUSH_STRING 12 // Push a pointer to a string 71 #define CP_CALL_VSCRIPT_ON_TRUE 14 // Call a virtual script if the expression result is true 74 #define CP_SAVE_MCODE_START 15 // Save the mcode code start for restarting when necessary 75 #define CP_PUSH_LOCAL_VAR32 16 // Push a local variable on to the stack 76 #define CP_POP_LOCAL_VAR32 17 // Pop a local variable from the stack 77 #define CP_PUSH_LOCAL_VARSTRING 18 // Push a local variable on to the stack 78 #define CP_DEBUG 19 // A debug command 79 #define CP_INITIALISEGLOBAL 20 // Initialise a global variable 81 #define CP_SWITCH 21 // takes value of the stack and uses with switch table... 83 #define CP_PUSH_0 22 // push 0 on the stack (a slight speed advantage and a space saving) 84 #define CP_PUSH_1 23 // push 1 on the stack (a slight speed advantage and a space saving) 91 #define CP_PUSH_INT16 26 92 #define CP_PUSH_INT8 27 93 #define CP_PUSH_STRING_REFERENCE 28 96 #define CP_INVALID_TOKEN 29 // For functions where a token is required, but not appropriate 100 #define OP_ISEQUAL 30 // '==' 101 #define OP_PLUS 31 // '+' 102 #define OP_TIMES 32 // '*' 103 #define OP_MINUS 33 // '-' 104 #define OP_DIVIDE 34 // '/' 105 #define OP_LSTHAN 35 // < 106 #define OP_NOTEQUAL 36 // '!=' 107 #define OP_ANDAND 37 // && 108 #define OP_OROR 38 // || or OR 109 #define OP_GTTHAN 39 // > 110 #define OP_GTTHANE 41 // >= 111 #define OP_LSTHANE 42 // <= 115 #define TK_UNARY_NOT 50 // ! Invert a boolean 116 #define TK_UNARY_MINUS 51 // - Negate a number 119 #define CP_PUSH_STRING_PLAYER 52 122 #define CP_CALL_MCODE_EXPR 53 125 #define CT_IF 100 // An if statement 126 #define CT_CLOSEBRACKET 101 // ) 127 #define CT_SEMICOLON 102 // ; 128 #define CT_ONCE 103 // the 'once' command 129 #define CT_CLOSEBRACE 104 // } 130 #define CT_DOUBLECLOSEBRACE 105 // Two tab indent reduction 131 #define CT_DO 106 // the 'do' command 132 #define CT_RETURN 107 // return a value to the engine 133 #define CT_SWITCH 108 // Switch 134 #define CT_QUIT 109 // Quit for a cycle 135 #define CT_COMMA 110 // , 136 #define CT_OPENBRACE 111 // { 137 #define CT_DEBUG 112 // Debug commands 138 #define CT_INITIALISEGLOBAL 113 // Initialise a global variable 139 #define CT_WHILE 114 // the 'while' command