-
Notifications
You must be signed in to change notification settings - Fork 4
/
pr_comp.pas
223 lines (182 loc) · 4.37 KB
/
pr_comp.pas
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// ------------------------------------------------------------------------------
// DelphiQuake, Copyright (C) 2005-2011 by Jim Valavanis
// E-Mail: jimmyvalavanis@yahoo.gr
//
// Copyright (C) 1996-1997 Id Software, Inc.
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// ------------------------------------------------------------------------------
{$I dquake.inc}
{$Z4}
unit pr_comp;
// this file is shared by quake and qcc
interface
uses
q_delphi;
type
func_t = integer;
Pfunc_t = ^func_t;
string_t = integer;
Pstring_t = ^string_t;
type
etype_t = (
ev_void,
ev_string,
ev_float,
ev_vector,
ev_entity,
ev_field,
ev_function,
ev_pointer
);
const
OFS_NULL = 0;
OFS_RETURN = 1;
OFS_PARM0 = 4; // leave 3 ofs for each parm to hold vectors
OFS_PARM1 = 7;
OFS_PARM2 = 10;
OFS_PARM3 = 13;
OFS_PARM4 = 16;
OFS_PARM5 = 19;
OFS_PARM6 = 22;
OFS_PARM7 = 25;
RESERVED_OFS = 28;
const
OP_DONE = 0;
OP_MUL_F = 1;
OP_MUL_V = 2;
OP_MUL_FV = 3;
OP_MUL_VF = 4;
OP_DIV_F = 5;
OP_ADD_F = 6;
OP_ADD_V = 7;
OP_SUB_F = 8;
OP_SUB_V = 9;
OP_EQ_F = 10;
OP_EQ_V = 11;
OP_EQ_S = 12;
OP_EQ_E = 13;
OP_EQ_FNC = 14;
OP_NE_F = 15;
OP_NE_V = 16;
OP_NE_S = 17;
OP_NE_E = 18;
OP_NE_FNC = 19;
OP_LE = 20;
OP_GE = 21;
OP_LT = 22;
OP_GT = 23;
OP_LOAD_F = 24;
OP_LOAD_V = 25;
OP_LOAD_S = 26;
OP_LOAD_ENT = 27;
OP_LOAD_FLD = 28;
OP_LOAD_FNC = 29;
OP_ADDRESS = 30;
OP_STORE_F = 31;
OP_STORE_V = 32;
OP_STORE_S = 33;
OP_STORE_ENT = 34;
OP_STORE_FLD = 35;
OP_STORE_FNC = 36;
OP_STOREP_F = 37;
OP_STOREP_V = 38;
OP_STOREP_S = 39;
OP_STOREP_ENT = 40;
OP_STOREP_FLD = 41;
OP_STOREP_FNC = 42;
OP_RETURN = 43;
OP_NOT_F = 44;
OP_NOT_V = 45;
OP_NOT_S = 46;
OP_NOT_ENT = 47;
OP_NOT_FNC = 48;
OP_IF = 49;
OP_IFNOT = 50;
OP_CALL0 = 51;
OP_CALL1 = 52;
OP_CALL2 = 53;
OP_CALL3 = 54;
OP_CALL4 = 55;
OP_CALL5 = 56;
OP_CALL6 = 57;
OP_CALL7 = 58;
OP_CALL8 = 59;
OP_STATE = 60;
OP_GOTO = 61;
OP_AND = 62;
OP_OR = 63;
OP_BITAND = 64;
OP_BITOR = 65;
type
dstatement_t = record
op: unsigned_short;
a, b, c: short;
end;
Pdstatement_t = ^dstatement_t;
dstatement_tArray = array[0..$FFFF] of dstatement_t;
Pdstatement_tArray = ^dstatement_tArray;
type
ddef_t = record
_type: unsigned_short; // if DEF_SAVEGLOBGAL bit is set
// the variable needs to be saved in savegames
ofs: unsigned_short;
s_name: integer;
end;
Pddef_t = ^ddef_t;
ddef_tArray = array[0..$FFFF] of ddef_t;
Pddef_tArray = ^ddef_tArray;
const
DEF_SAVEGLOBAL = 1 shl 15;
MAX_PARMS = 8;
type
dfunction_t = record
first_statement: integer; // negative numbers are builtins
parm_start: integer;
locals: integer; // total ints of parms + locals
profile: integer; // runtime
s_name: integer;
s_file: integer; // source file defined in
numparms: integer;
parm_size: array[0..MAX_PARMS - 1] of byte;
end;
Pdfunction_t = ^dfunction_t;
dfunction_tArray = array[0..$FFFF] of dfunction_t;
Pdfunction_tArray = ^dfunction_tArray;
const
PROG_VERSION = 6;
type
dprograms_t = record
version: integer;
crc: integer; // check of header file
ofs_statements: integer;
numstatements: integer; // statement 0 is an error
ofs_globaldefs: integer;
numglobaldefs: integer;
ofs_fielddefs: integer;
numfielddefs: integer;
ofs_functions: integer;
numfunctions: integer; // function 0 is an empty
ofs_strings: integer;
numstrings: integer; // first string is a null string
ofs_globals: integer;
numglobals: integer;
entityfields: integer;
end;
Pdprograms_t = ^dprograms_t;
implementation
end.