X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=pr_comp.h;h=20801b84c9dda98aea68db85a2b2b3911419dbd9;hb=5fd2c001d6a6927f57020d24d34cd2fcbc6c439e;hp=7a744645669fa785d49d721c059f4f07587eda88;hpb=b9f20aade86302d710a5b4d9f6669961b5b2503c;p=xonotic%2Fdarkplaces.git diff --git a/pr_comp.h b/pr_comp.h index 7a744645..20801b84 100644 --- a/pr_comp.h +++ b/pr_comp.h @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef unsigned int func_t; typedef int string_t; -typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; +typedef enum etype_e {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; #define OFS_NULL 0 @@ -42,7 +42,8 @@ typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_f #define RESERVED_OFS 28 -enum { +typedef enum opcode_e +{ OP_DONE, OP_MUL_F, OP_MUL_V, @@ -53,19 +54,19 @@ enum { OP_ADD_V, OP_SUB_F, OP_SUB_V, - + OP_EQ_F, OP_EQ_V, OP_EQ_S, OP_EQ_E, OP_EQ_FNC, - + OP_NE_F, OP_NE_V, OP_NE_S, OP_NE_E, OP_NE_FNC, - + OP_LE, OP_GE, OP_LT, @@ -115,30 +116,129 @@ enum { OP_GOTO, OP_AND, OP_OR, - + OP_BITAND, - OP_BITOR -}; + OP_BITOR, + + OP_STORE_I = 113, + + OP_ADD_I = 116, + OP_ADD_FI, + OP_ADD_IF, + + OP_SUB_I, + OP_SUB_FI, + OP_SUB_IF, + OP_CONV_IF, + OP_CONV_FI, + + OP_LOAD_I = 126, + OP_STOREP_I, + + OP_BITAND_I = 130, + OP_BITOR_I, + + OP_MUL_I, + OP_DIV_I, + OP_EQ_I, + OP_NE_I, + OP_NOT_I = 138, -typedef struct statement_s + OP_DIV_VF, + + OP_STORE_P = 152, + + OP_LE_I = 161, + OP_GE_I, + OP_LT_I, + OP_GT_I, + + OP_LE_IF, + OP_GE_IF, + OP_LT_IF, + OP_GT_IF, + + OP_LE_FI, + OP_GE_FI, + OP_LT_FI, + OP_GT_FI, + + OP_EQ_IF, + OP_EQ_FI, + + OP_MUL_IF = 179, + OP_MUL_FI, + OP_MUL_VI, + OP_DIV_IF = 183, + OP_DIV_FI, + OP_BITAND_IF, + OP_BITOR_IF, + OP_BITAND_FI, + OP_BITOR_FI, + OP_AND_I, + OP_OR_I, + OP_AND_IF, + OP_OR_IF, + OP_AND_FI, + OP_OR_FI, + OP_NE_IF, + OP_NE_FI, + + OP_GSTOREP_I, + OP_GSTOREP_F, + OP_GSTOREP_ENT, + OP_GSTOREP_FLD, + OP_GSTOREP_S, + OP_GSTOREP_FNC, + OP_GSTOREP_V, + OP_GADDRESS, + OP_GLOAD_I, + OP_GLOAD_F, + OP_GLOAD_FLD, + OP_GLOAD_ENT, + OP_GLOAD_S, + OP_GLOAD_FNC, + OP_BOUNDCHECK, + OP_GLOAD_V = 216 +} +opcode_t; + + +typedef struct statement16_s { unsigned short op; signed short a,b,c; -} dstatement_t; +} +dstatement16_t; +typedef struct statement32_s +{ + unsigned int op; + signed int a,b,c; +} +dstatement32_t; -typedef struct +typedef struct ddef16_s { unsigned short type; // if DEF_SAVEGLOBGAL bit is set // the variable needs to be saved in savegames unsigned short ofs; int s_name; -} ddef_t; +} +ddef16_t; +typedef struct ddef32_s +{ + unsigned int type; // if DEF_SAVEGLOBGAL bit is set + // the variable needs to be saved in savegames + unsigned int ofs; + int s_name; +} +ddef32_t, mdef_t; #define DEF_SAVEGLOBAL (1<<15) #define MAX_PARMS 8 -typedef struct +typedef struct dfunction_s { int first_statement; // negative numbers are builtins int parm_start; @@ -150,52 +250,92 @@ typedef struct int s_file; // source file defined in int numparms; - qbyte parm_size[MAX_PARMS]; -} dfunction_t; + unsigned char parm_size[MAX_PARMS]; +} +dfunction_t; -typedef struct +typedef struct mfunction_s { int first_statement; // negative numbers are builtins int parm_start; int locals; // total ints of parms + locals - int profile; // runtime - int builtinsprofile; // cost of builtin functions called by this function + // these are doubles so that they can count up to 54bits or so rather than 32bit + double tprofile; // realtime in this function + double tbprofile; // realtime in builtins called by this function (NOTE: builtins also have a tprofile!) + double profile; // runtime + double builtinsprofile; // cost of builtin functions called by this function + double callcount; // times the functions has been called since the last profile call + double totaltime; // total execution time of this function DIRECTLY FROM THE ENGINE + double tprofile_total; // runtime (NOTE: tbprofile_total makes no real sense, so not accumulating that) + double profile_total; // runtime + double builtinsprofile_total; // cost of builtin functions called by this function + int recursion; int s_name; int s_file; // source file defined in int numparms; - qbyte parm_size[MAX_PARMS]; -} mfunction_t; + unsigned char parm_size[MAX_PARMS]; +} +mfunction_t; + +typedef struct mstatement_s +{ + opcode_t op; + int operand[3]; // always a global or -1 for unused + int jumpabsolute; // only used by IF, IFNOT, GOTO +} +mstatement_t; #define PROG_VERSION 6 -typedef struct +typedef struct dprograms_s { int version; int crc; // check of header file - int ofs_statements; - int numstatements; // statement 0 is an error + unsigned int ofs_statements; + unsigned int numstatements; // statement 0 is an error + + unsigned int ofs_globaldefs; + unsigned int numglobaldefs; + + unsigned int ofs_fielddefs; + unsigned int numfielddefs; + + unsigned int ofs_functions; + unsigned int numfunctions; // function 0 is an empty + + unsigned int ofs_strings; + unsigned int numstrings; // first string is a null string - int ofs_globaldefs; - int numglobaldefs; + unsigned int ofs_globals; + unsigned int numglobals; - int ofs_fielddefs; - int numfielddefs; + unsigned int entityfields; +} +dprograms_t; - int ofs_functions; - int numfunctions; // function 0 is an empty +typedef struct dprograms_v7_s +{ //extended header written by fteqcc. + dprograms_t v6; //for easier casting. - int ofs_strings; - int numstrings; // first string is a null string + //debug / version 7 extensions + unsigned int ofsfiles; //ignored. deprecated, should be 0. source files can instead be embedded by simply treating the .dat as a zip. + unsigned int ofslinenums; //ignored. alternative to external .lno files. + unsigned int ofsbodylessfuncs; //unsupported. function names imported from other modules. must be 0. + unsigned int numbodylessfuncs; //unsupported. must be 0. - int ofs_globals; - int numglobals; + unsigned int ofs_types; //unsupported+deprecated. rich type info. must be 0. + unsigned int numtypes; //unsupported+deprecated. rich type info. must be 0. + unsigned int blockscompressed; //unsupported. per-block compression. must be 0. - int entityfields; -} dprograms_t; + int secondaryversion; //if not known then its kkqwsv's v7, qfcc's v7, or uhexen2's v7, or something. abandon all hope when not recognised. +#define PROG_SECONDARYVERSION16 ((('1'<<0)|('F'<<8)|('T'<<16)|('E'<<24))^(('P'<<0)|('R'<<8)|('O'<<16)|('G'<<24))) //regular 16bit statements. +#define PROG_SECONDARYVERSION32 ((('1'<<0)|('F'<<8)|('T'<<16)|('E'<<24))^(('3'<<0)|('2'<<8)|('B'<<16)|(' '<<24))) //statements+globaldefs+fielddefs extended to 32bit. +} +dprograms_v7_t; #endif