1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_DCSCRIPT_H
#define WINTERMUTE_DCSCRIPT_H
namespace WinterMute {
#define SCRIPT_MAGIC 0xDEC0ADDE
#define SCRIPT_VERSION 0x0102
// value types
typedef enum {
VAL_NULL,
VAL_STRING,
VAL_INT,
VAL_BOOL,
VAL_FLOAT,
VAL_OBJECT,
VAL_NATIVE,
VAL_VARIABLE_REF
} TValType;
// script states
typedef enum {
SCRIPT_RUNNING,
SCRIPT_WAITING,
SCRIPT_SLEEPING,
SCRIPT_FINISHED,
SCRIPT_PERSISTENT,
SCRIPT_ERROR,
SCRIPT_PAUSED,
SCRIPT_WAITING_SCRIPT,
SCRIPT_THREAD_FINISHED
} TScriptState;
// opcodes
typedef enum {
II_DEF_VAR = 0,
II_DEF_GLOB_VAR,
II_RET,
II_RET_EVENT,
II_CALL,
II_CALL_BY_EXP,
II_EXTERNAL_CALL,
II_SCOPE,
II_CORRECT_STACK,
II_CREATE_OBJECT,
II_POP_EMPTY,
II_PUSH_VAR,
II_PUSH_VAR_REF,
II_POP_VAR,
II_PUSH_VAR_THIS, // push current this on stack
II_PUSH_INT,
II_PUSH_BOOL,
II_PUSH_FLOAT,
II_PUSH_STRING,
II_PUSH_NULL,
II_PUSH_THIS_FROM_STACK,
II_PUSH_THIS,
II_POP_THIS,
II_PUSH_BY_EXP,
II_POP_BY_EXP,
II_JMP,
II_JMP_FALSE,
II_ADD,
II_SUB,
II_MUL,
II_DIV,
II_MODULO,
II_NOT,
II_AND,
II_OR,
II_CMP_EQ,
II_CMP_NE,
II_CMP_L,
II_CMP_G,
II_CMP_LE,
II_CMP_GE,
II_CMP_STRICT_EQ,
II_CMP_STRICT_NE,
II_DBG_LINE,
II_POP_REG1,
II_PUSH_REG1,
II_DEF_CONST_VAR
} TInstruction;
// external data types
typedef enum {
TYPE_VOID = 0,
TYPE_BOOL,
TYPE_LONG,
TYPE_BYTE,
TYPE_STRING,
TYPE_FLOAT,
TYPE_DOUBLE,
TYPE_MEMBUFFER
} TExternalType;
// call types
typedef enum {
CALL_STDCALL = 0,
CALL_CDECL,
CALL_THISCALL
} TCallType;
// element types
typedef enum {
ELEMENT_STRING = 0
} TElementType;
// compiler interface
typedef byte *(DLL_LOAD_FILE)(void *data, char *filename, uint32 *size);
typedef void (DLL_CLOSE_FILE)(void *data, byte *buffer);
typedef void (DLL_ADD_ERROR)(void *data, int line, char *text);
typedef void (DLL_PARSE_ELEMENT)(void *data, int line, int type, void *elementData);
typedef struct {
DLL_LOAD_FILE *Dll_LoadFile;
DLL_CLOSE_FILE *Dll_CloseFile;
DLL_ADD_ERROR *Dll_AddError;
DLL_PARSE_ELEMENT *Dll_ParseElement;
} CALLBACKS;
} // end of namespace WinterMute
#endif
|