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 #ifndef __PR_COMP_H__ 22 #define __PR_COMP_H__ 23 24 // this file is shared by quake and qcc 25 26 typedef int func_t; 27 typedef int string_t; 28 typedef intptr_t stringptr_t; 29 30 typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; 31 32 33 #define OFS_NULL 0 34 #define OFS_RETURN 1 35 #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors 36 #define OFS_PARM1 7 37 #define OFS_PARM2 10 38 #define OFS_PARM3 13 39 #define OFS_PARM4 16 40 #define OFS_PARM5 19 41 #define OFS_PARM6 22 42 #define OFS_PARM7 25 43 #define RESERVED_OFS 28 44 45 46 enum { 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 short a,b,c; 129 } dstatement_t; 130 131 typedef struct 132 { 133 unsigned short type; // if DEF_SAVEGLOBGAL bit is set 134 // the variable needs to be saved in savegames 135 unsigned short ofs; 136 int s_name; 137 } ddef_t; 138 #define DEF_SAVEGLOBAL (1<<15) 139 140 #define MAX_PARMS 8 141 142 typedef struct 143 { 144 int first_statement; // negative numbers are builtins 145 int parm_start; 146 int locals; // total ints of parms + locals 147 148 int profile; // runtime 149 150 int s_name; 151 int s_file; // source file defined in 152 153 int numparms; 154 byte parm_size[MAX_PARMS]; 155 } dfunction_t; 156 157 158 #define PROG_VERSION 6 159 typedef struct 160 { 161 int version; 162 int crc; // check of header file 163 164 int ofs_statements; 165 int numstatements; // statement 0 is an error 166 167 int ofs_globaldefs; 168 int numglobaldefs; 169 170 int ofs_fielddefs; 171 int numfielddefs; 172 173 int ofs_functions; 174 int numfunctions; // function 0 is an empty 175 176 int ofs_strings; 177 int numstrings; // first string is a null string 178 179 int ofs_globals; 180 int numglobals; 181 182 int entityfields; 183 } dprograms_t; 184 185 #endif /* !__PR_COMP_H__ */ 186