]> git.xonotic.org Git - xonotic/darkplaces.git/blob - pr_comp.h
sv_airstrafeaccel_qw cvar for tuning CPMA-style physics
[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         double  totaltime; // total execution time of this function DIRECTLY FROM THE ENGINE
171         double  profile_total;          // runtime
172         double  builtinsprofile_total; // cost of builtin functions called by this function
173         int     recursion;
174
175         int             s_name;
176         int             s_file;                 // source file defined in
177
178         int             numparms;
179         unsigned char   parm_size[MAX_PARMS];
180 }
181 mfunction_t;
182
183
184 #define PROG_VERSION    6
185 typedef struct dprograms_s
186 {
187         int             version;
188         int             crc;                    // check of header file
189
190         int             ofs_statements;
191         int             numstatements;  // statement 0 is an error
192
193         int             ofs_globaldefs;
194         int             numglobaldefs;
195
196         int             ofs_fielddefs;
197         int             numfielddefs;
198
199         int             ofs_functions;
200         int             numfunctions;   // function 0 is an empty
201
202         int             ofs_strings;
203         int             numstrings;             // first string is a null string
204
205         int             ofs_globals;
206         int             numglobals;
207
208         int             entityfields;
209 }
210 dprograms_t;
211
212 #endif
213