]> git.xonotic.org Git - xonotic/darkplaces.git/blob - pr_comp.h
patch from div to fix icc warnings
[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 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
124
125 typedef struct statement_s
126 {
127         unsigned short  op;
128         signed short    a,b,c;
129 }
130 dstatement_t;
131
132 typedef struct ddef_s
133 {
134         unsigned short  type;           // if DEF_SAVEGLOBGAL bit is set
135                                                                 // the variable needs to be saved in savegames
136         unsigned short  ofs;
137         int                     s_name;
138 }
139 ddef_t;
140 #define DEF_SAVEGLOBAL  (1<<15)
141
142 #define MAX_PARMS       8
143
144 typedef struct dfunction_s
145 {
146         int             first_statement;        // negative numbers are builtins
147         int             parm_start;
148         int             locals;                         // total ints of parms + locals
149
150         int             profile;                // runtime
151
152         int             s_name;
153         int             s_file;                 // source file defined in
154
155         int             numparms;
156         unsigned char   parm_size[MAX_PARMS];
157 }
158 dfunction_t;
159
160 typedef struct mfunction_s
161 {
162         int             first_statement;        // negative numbers are builtins
163         int             parm_start;
164         int             locals;                         // total ints of parms + locals
165
166         // these are doubles so that they can count up to 54bits or so rather than 32bit
167         double  profile;                // runtime
168         double  builtinsprofile; // cost of builtin functions called by this function
169         double  callcount; // times the functions has been called since the last profile call
170
171         int             s_name;
172         int             s_file;                 // source file defined in
173
174         int             numparms;
175         unsigned char   parm_size[MAX_PARMS];
176 }
177 mfunction_t;
178
179
180 #define PROG_VERSION    6
181 typedef struct dprograms_s
182 {
183         int             version;
184         int             crc;                    // check of header file
185
186         int             ofs_statements;
187         int             numstatements;  // statement 0 is an error
188
189         int             ofs_globaldefs;
190         int             numglobaldefs;
191
192         int             ofs_fielddefs;
193         int             numfielddefs;
194
195         int             ofs_functions;
196         int             numfunctions;   // function 0 is an empty
197
198         int             ofs_strings;
199         int             numstrings;             // first string is a null string
200
201         int             ofs_globals;
202         int             numglobals;
203
204         int             entityfields;
205 }
206 dprograms_t;
207
208 #endif
209