]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - pr_comp.h
Experimental restoration of GLES2 support. It *might* compile.
[xonotic/darkplaces.git] / pr_comp.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 // this file is shared by quake and qcc
22
23 #ifndef PR_COMP_H
24 #define PR_COMP_H
25
26 typedef unsigned int    func_t;
27 typedef int     string_t;
28
29 typedef enum etype_e {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t;
30
31
32 #define OFS_NULL                0
33 #define OFS_RETURN              1
34 #define OFS_PARM0               4               // leave 3 ofs for each parm to hold vectors
35 #define OFS_PARM1               7
36 #define OFS_PARM2               10
37 #define OFS_PARM3               13
38 #define OFS_PARM4               16
39 #define OFS_PARM5               19
40 #define OFS_PARM6               22
41 #define OFS_PARM7               25
42 #define RESERVED_OFS    28
43
44
45 typedef enum opcode_e
46 {
47         OP_DONE,
48         OP_MUL_F,
49         OP_MUL_V,
50         OP_MUL_FV,
51         OP_MUL_VF,
52         OP_DIV_F,
53         OP_ADD_F,
54         OP_ADD_V,
55         OP_SUB_F,
56         OP_SUB_V,
57
58         OP_EQ_F,
59         OP_EQ_V,
60         OP_EQ_S,
61         OP_EQ_E,
62         OP_EQ_FNC,
63
64         OP_NE_F,
65         OP_NE_V,
66         OP_NE_S,
67         OP_NE_E,
68         OP_NE_FNC,
69
70         OP_LE,
71         OP_GE,
72         OP_LT,
73         OP_GT,
74
75         OP_LOAD_F,
76         OP_LOAD_V,
77         OP_LOAD_S,
78         OP_LOAD_ENT,
79         OP_LOAD_FLD,
80         OP_LOAD_FNC,
81
82         OP_ADDRESS,
83
84         OP_STORE_F,
85         OP_STORE_V,
86         OP_STORE_S,
87         OP_STORE_ENT,
88         OP_STORE_FLD,
89         OP_STORE_FNC,
90
91         OP_STOREP_F,
92         OP_STOREP_V,
93         OP_STOREP_S,
94         OP_STOREP_ENT,
95         OP_STOREP_FLD,
96         OP_STOREP_FNC,
97
98         OP_RETURN,
99         OP_NOT_F,
100         OP_NOT_V,
101         OP_NOT_S,
102         OP_NOT_ENT,
103         OP_NOT_FNC,
104         OP_IF,
105         OP_IFNOT,
106         OP_CALL0,
107         OP_CALL1,
108         OP_CALL2,
109         OP_CALL3,
110         OP_CALL4,
111         OP_CALL5,
112         OP_CALL6,
113         OP_CALL7,
114         OP_CALL8,
115         OP_STATE,
116         OP_GOTO,
117         OP_AND,
118         OP_OR,
119
120         OP_BITAND,
121         OP_BITOR,
122
123         OP_STORE_I = 113,
124
125         OP_ADD_I = 116,
126         OP_ADD_FI,
127         OP_ADD_IF,
128
129         OP_SUB_I,
130         OP_SUB_FI,
131         OP_SUB_IF,
132         OP_CONV_IF,
133         OP_CONV_FI,
134
135         OP_LOAD_I = 126,
136         OP_STOREP_I,
137
138         OP_BITAND_I = 130,
139         OP_BITOR_I,
140
141         OP_MUL_I,
142         OP_DIV_I,
143         OP_EQ_I,
144         OP_NE_I,
145
146         OP_NOT_I = 138,
147
148         OP_DIV_VF,
149         
150         OP_STORE_P = 152,
151
152         OP_LE_I = 161,
153         OP_GE_I,
154         OP_LT_I,
155         OP_GT_I,
156         
157         OP_LE_IF,
158         OP_GE_IF,
159         OP_LT_IF,
160         OP_GT_IF,
161
162         OP_LE_FI,
163         OP_GE_FI,
164         OP_LT_FI,
165         OP_GT_FI,
166
167         OP_EQ_IF,
168         OP_EQ_FI,
169
170         OP_MUL_IF = 179,
171         OP_MUL_FI,
172         OP_MUL_VI,
173         OP_DIV_IF = 183,
174         OP_DIV_FI,
175         OP_BITAND_IF,
176         OP_BITOR_IF,
177         OP_BITAND_FI,
178         OP_BITOR_FI,
179         OP_AND_I,
180         OP_OR_I,
181         OP_AND_IF,
182         OP_OR_IF,
183         OP_AND_FI,
184         OP_OR_FI,
185         OP_NE_IF,
186         OP_NE_FI,
187
188         OP_GSTOREP_I,
189         OP_GSTOREP_F,
190         OP_GSTOREP_ENT,
191         OP_GSTOREP_FLD,
192         OP_GSTOREP_S,
193         OP_GSTOREP_FNC,         
194         OP_GSTOREP_V,
195         OP_GADDRESS,
196         OP_GLOAD_I,
197         OP_GLOAD_F,
198         OP_GLOAD_FLD,
199         OP_GLOAD_ENT,
200         OP_GLOAD_S,
201         OP_GLOAD_FNC,
202         OP_BOUNDCHECK,
203         OP_GLOAD_V = 216
204 }
205 opcode_t;
206
207
208 typedef struct statement_s
209 {
210         unsigned short  op;
211         signed short    a,b,c;
212 }
213 dstatement_t;
214
215 typedef struct ddef_s
216 {
217         unsigned short  type;           // if DEF_SAVEGLOBGAL bit is set
218                                                                 // the variable needs to be saved in savegames
219         unsigned short  ofs;
220         int                     s_name;
221 }
222 ddef_t;
223 #define DEF_SAVEGLOBAL  (1<<15)
224
225 #define MAX_PARMS       8
226
227 typedef struct dfunction_s
228 {
229         int             first_statement;        // negative numbers are builtins
230         int             parm_start;
231         int             locals;                         // total ints of parms + locals
232
233         int             profile;                // runtime
234
235         int             s_name;
236         int             s_file;                 // source file defined in
237
238         int             numparms;
239         unsigned char   parm_size[MAX_PARMS];
240 }
241 dfunction_t;
242
243 typedef struct mfunction_s
244 {
245         int             first_statement;        // negative numbers are builtins
246         int             parm_start;
247         int             locals;                         // total ints of parms + locals
248
249         // these are doubles so that they can count up to 54bits or so rather than 32bit
250         double  tprofile;           // realtime in this function
251         double  tbprofile;          // realtime in builtins called by this function (NOTE: builtins also have a tprofile!)
252         double  profile;                // runtime
253         double  builtinsprofile; // cost of builtin functions called by this function
254         double  callcount; // times the functions has been called since the last profile call
255         double  totaltime; // total execution time of this function DIRECTLY FROM THE ENGINE
256         double  tprofile_total;         // runtime (NOTE: tbprofile_total makes no real sense, so not accumulating that)
257         double  profile_total;          // runtime
258         double  builtinsprofile_total; // cost of builtin functions called by this function
259         int     recursion;
260
261         int             s_name;
262         int             s_file;                 // source file defined in
263
264         int             numparms;
265         unsigned char   parm_size[MAX_PARMS];
266 }
267 mfunction_t;
268
269 typedef struct mstatement_s
270 {
271         opcode_t        op;
272         int                     operand[3]; // always a global or -1 for unused
273         int                     jumpabsolute; // only used by IF, IFNOT, GOTO
274 }
275 mstatement_t;
276
277
278 #define PROG_VERSION    6
279 typedef struct dprograms_s
280 {
281         int             version;
282         int             crc;                    // check of header file
283
284         int             ofs_statements;
285         int             numstatements;  // statement 0 is an error
286
287         int             ofs_globaldefs;
288         int             numglobaldefs;
289
290         int             ofs_fielddefs;
291         int             numfielddefs;
292
293         int             ofs_functions;
294         int             numfunctions;   // function 0 is an empty
295
296         int             ofs_strings;
297         int             numstrings;             // first string is a null string
298
299         int             ofs_globals;
300         int             numglobals;
301
302         int             entityfields;
303 }
304 dprograms_t;
305
306 #endif
307