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 #include <stdint.h> 25 26 #include "qtypes.h" 27 28 // this file is shared by quake and qcc 29 30 typedef int32_t func_t; 31 typedef int32_t string_t; 32 33 #ifdef _MSC_VER 34 typedef int etype_t; 35 36 #define ev_void 0 37 #define ev_string 1 38 #define ev_float 2 39 #define ev_vector 3 40 #define ev_entity 4 41 #define ev_field 5 42 #define ev_function 6 43 #define ev_pointer 7 44 #else 45 typedef enum { 46 ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, 47 ev_function, ev_pointer, ENSURE_INT_ETYPE = 0x70000000 48 } etype_t; 49 #endif 50 51 52 #define OFS_NULL 0 53 #define OFS_RETURN 1 54 #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors 55 #define OFS_PARM1 7 56 #define OFS_PARM2 10 57 #define OFS_PARM3 13 58 #define OFS_PARM4 16 59 #define OFS_PARM5 19 60 #define OFS_PARM6 22 61 #define OFS_PARM7 25 62 #define RESERVED_OFS 28 63 64 65 enum { 66 OP_DONE, 67 OP_MUL_F, 68 OP_MUL_V, 69 OP_MUL_FV, 70 OP_MUL_VF, 71 OP_DIV_F, 72 OP_ADD_F, 73 OP_ADD_V, 74 OP_SUB_F, 75 OP_SUB_V, 76 77 OP_EQ_F, 78 OP_EQ_V, 79 OP_EQ_S, 80 OP_EQ_E, 81 OP_EQ_FNC, 82 83 OP_NE_F, 84 OP_NE_V, 85 OP_NE_S, 86 OP_NE_E, 87 OP_NE_FNC, 88 89 OP_LE, 90 OP_GE, 91 OP_LT, 92 OP_GT, 93 94 OP_LOAD_F, 95 OP_LOAD_V, 96 OP_LOAD_S, 97 OP_LOAD_ENT, 98 OP_LOAD_FLD, 99 OP_LOAD_FNC, 100 101 OP_ADDRESS, 102 103 OP_STORE_F, 104 OP_STORE_V, 105 OP_STORE_S, 106 OP_STORE_ENT, 107 OP_STORE_FLD, 108 OP_STORE_FNC, 109 110 OP_STOREP_F, 111 OP_STOREP_V, 112 OP_STOREP_S, 113 OP_STOREP_ENT, 114 OP_STOREP_FLD, 115 OP_STOREP_FNC, 116 117 OP_RETURN, 118 OP_NOT_F, 119 OP_NOT_V, 120 OP_NOT_S, 121 OP_NOT_ENT, 122 OP_NOT_FNC, 123 OP_IF, 124 OP_IFNOT, 125 OP_CALL0, 126 OP_CALL1, 127 OP_CALL2, 128 OP_CALL3, 129 OP_CALL4, 130 OP_CALL5, 131 OP_CALL6, 132 OP_CALL7, 133 OP_CALL8, 134 OP_STATE, 135 OP_GOTO, 136 OP_AND, 137 OP_OR, 138 139 OP_BITAND, 140 OP_BITOR 141 }; 142 143 144 typedef struct statement_s { 145 uint16_t op; 146 int16_t a, b, c; 147 } dstatement_t; 148 149 typedef struct { 150 uint16_t type; /* if DEF_SAVEGLOBGAL bit is set, the variable needs 151 to be saved in savegames */ 152 uint16_t ofs; 153 int32_t s_name; 154 } ddef_t; 155 156 #define DEF_SAVEGLOBAL (1<<15) 157 158 #define MAX_PARMS 8 159 160 typedef struct { 161 int32_t first_statement; /* negative numbers are builtins */ 162 int32_t parm_start; 163 int32_t locals; /* total ints of parms + locals */ 164 165 int32_t profile; /* runtime */ 166 167 int32_t s_name; 168 int32_t s_file; /* source file defined in */ 169 170 int32_t numparms; 171 byte parm_size[MAX_PARMS]; 172 } dfunction_t; 173 174 175 #define PROG_VERSION 6 176 typedef struct { 177 int32_t version; 178 int32_t crc; /* check of header file */ 179 180 int32_t ofs_statements; 181 int32_t numstatements; /* statement 0 is an error */ 182 183 int32_t ofs_globaldefs; 184 int32_t numglobaldefs; 185 186 int32_t ofs_fielddefs; 187 int32_t numfielddefs; 188 189 int32_t ofs_functions; 190 int32_t numfunctions; /* function 0 is an empty */ 191 192 int32_t ofs_strings; 193 int32_t strings_size; /* first string is a null string */ 194 195 int32_t ofs_globals; 196 int32_t numglobals; 197 198 int32_t entityfields; 199 } dprograms_t; 200 201 #endif /* PR_COMP_H */ 202