OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
scriptopcodes.h
1/*
2===========================================================================
3Copyright (C) 2015 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// scriptopcodes.h
24
25#pragma once
26
27#include "q_shared.h"
28
30using opval_t = uint8_t;
32using op_name_t = uint32_t;
34using op_ev_t = uint32_t;
36using op_evName_t = uint32_t;
38using op_offset_t = uint32_t;
40using op_parmNum_t = uint8_t;
42using op_arrayParmNum_t = uint16_t;
43
44typedef struct {
45 const char *opcodename;
46 int opcodelength;
47 short opcodestackoffset;
48 char isexternal;
49} opcode_t;
50
51typedef struct {
52 unsigned char opcode;
53 signed char VarStackOffset;
55
56typedef enum {
57 OP_DONE,
58 OP_BOOL_JUMP_FALSE4,
59 OP_BOOL_JUMP_TRUE4,
60 OP_VAR_JUMP_FALSE4,
61 OP_VAR_JUMP_TRUE4,
62
63 OP_BOOL_LOGICAL_AND,
64 OP_BOOL_LOGICAL_OR,
65 OP_VAR_LOGICAL_AND,
66 OP_VAR_LOGICAL_OR,
67
68 OP_BOOL_TO_VAR,
69
70 OP_JUMP4,
71 OP_JUMP_BACK4,
72
73 OP_STORE_INT0,
74 OP_STORE_INT1,
75 OP_STORE_INT2,
76 OP_STORE_INT3,
77 OP_STORE_INT4,
78
79 OP_BOOL_STORE_FALSE,
80 OP_BOOL_STORE_TRUE,
81
82 OP_STORE_STRING,
83 OP_STORE_FLOAT,
84 OP_STORE_VECTOR,
85 OP_CALC_VECTOR,
86 OP_STORE_NULL,
87 OP_STORE_NIL,
88
89 OP_EXEC_CMD0, // exec normal
90 OP_EXEC_CMD1,
91 OP_EXEC_CMD2,
92 OP_EXEC_CMD3,
93 OP_EXEC_CMD4,
94 OP_EXEC_CMD5,
95 OP_EXEC_CMD_COUNT1,
96
97 OP_EXEC_CMD_METHOD0, // exec from listener
98 OP_EXEC_CMD_METHOD1,
99 OP_EXEC_CMD_METHOD2,
100 OP_EXEC_CMD_METHOD3,
101 OP_EXEC_CMD_METHOD4,
102 OP_EXEC_CMD_METHOD5,
103 OP_EXEC_CMD_METHOD_COUNT1,
104
105 OP_EXEC_METHOD0, // exec from listener with return
106 OP_EXEC_METHOD1,
107 OP_EXEC_METHOD2,
108 OP_EXEC_METHOD3,
109 OP_EXEC_METHOD4,
110 OP_EXEC_METHOD5,
111 OP_EXEC_METHOD_COUNT1,
112
113 OP_LOAD_GAME_VAR,
114 OP_LOAD_LEVEL_VAR,
115 OP_LOAD_LOCAL_VAR,
116 OP_LOAD_PARM_VAR,
117 OP_LOAD_SELF_VAR,
118 OP_LOAD_GROUP_VAR,
119 OP_LOAD_OWNER_VAR,
120 OP_LOAD_FIELD_VAR,
121 OP_LOAD_ARRAY_VAR,
122 OP_LOAD_CONST_ARRAY1,
123
124 OP_STORE_FIELD_REF,
125 OP_STORE_ARRAY_REF,
126
127 OP_MARK_STACK_POS,
128
129 OP_STORE_PARAM,
130
131 OP_RESTORE_STACK_POS,
132
133 OP_LOAD_STORE_GAME_VAR,
134 OP_LOAD_STORE_LEVEL_VAR,
135 OP_LOAD_STORE_LOCAL_VAR,
136 OP_LOAD_STORE_PARM_VAR,
137 OP_LOAD_STORE_SELF_VAR,
138 OP_LOAD_STORE_GROUP_VAR,
139 OP_LOAD_STORE_OWNER_VAR,
140
141 OP_STORE_GAME_VAR,
142 OP_STORE_LEVEL_VAR,
143 OP_STORE_LOCAL_VAR,
144 OP_STORE_PARM_VAR,
145 OP_STORE_SELF_VAR,
146 OP_STORE_GROUP_VAR,
147 OP_STORE_OWNER_VAR,
148 OP_STORE_FIELD,
149 OP_STORE_ARRAY,
150 OP_STORE_GAME,
151 OP_STORE_LEVEL,
152 OP_STORE_LOCAL,
153 OP_STORE_PARM,
154 OP_STORE_SELF,
155 OP_STORE_GROUP,
156 OP_STORE_OWNER,
157
158 OP_BIN_BITWISE_AND,
159 OP_BIN_BITWISE_OR,
160 OP_BIN_BITWISE_EXCL_OR,
161 OP_BIN_EQUALITY,
162 OP_BIN_INEQUALITY,
163 OP_BIN_LESS_THAN,
164 OP_BIN_GREATER_THAN,
165 OP_BIN_LESS_THAN_OR_EQUAL,
166 OP_BIN_GREATER_THAN_OR_EQUAL,
167 OP_BIN_PLUS,
168 OP_BIN_MINUS,
169 OP_BIN_MULTIPLY,
170 OP_BIN_DIVIDE,
171 OP_BIN_PERCENTAGE,
172
173 OP_UN_MINUS,
174 OP_UN_COMPLEMENT,
175 OP_UN_TARGETNAME,
176 OP_BOOL_UN_NOT,
177 OP_VAR_UN_NOT,
178 OP_UN_CAST_BOOLEAN,
179 OP_UN_INC,
180 OP_UN_DEC,
181 OP_UN_SIZE,
182
183 OP_SWITCH,
184
185 OP_FUNC,
186
187 OP_NOP,
188
189 OP_BIN_SHIFT_LEFT,
190 OP_BIN_SHIFT_RIGHT,
191
192 OP_END,
193 OP_RETURN,
194
195 OP_PREVIOUS,
196 OP_MAX = OP_PREVIOUS
197} opcode_e;
198
199const char *VarGroupName(int iVarGroup);
200const char *OpcodeName(int opcode);
201int OpcodeLength(int opcode);
202int OpcodeVarStackOffset(int opcode);
203void SetOpcodeVarStackOffset(int opcode, int iVarStackOffset);
204bool IsExternalOpcode(int opcode);
Definition scriptopcodes.h:51
Definition scriptopcodes.h:44