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