1 // this file is shared by the execution and compiler
3 /*i'm part way through making this work
4 I've given up now that I can't work out a way to load pointers.
5 Setting them should be fine.
11 /*this distinction is made as the execution uses c pointers while compiler uses pointers from the start of the string table of the current progs*/
13 typedef int QCC_string_t;
15 //typedef char *string_t;
18 //typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer, ev_integer, ev_struct, ev_union} etype_t;
19 // 0 1 2 3 4 5 6 7 8 9 10
23 #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
31 #define RESERVED_OFS 28
94 OP_CALL0, //careful... hexen2 and q1 have different calling conventions
95 OP_CALL1, //remap hexen2 calls to OP_CALL2H
112 //these following ones are Hexen 2 constants.
169 //mostly they are various different ways of adding two vars with conversions.
222 OP_POINTER_ADD, //32 bit pointers
232 OP_STORE_P, //152... erm.. wait...
261 //-------------------------------------
262 //string manipulation.
263 OP_ADD_SF, //(char*)c = (char*)a + (float)b add_fi->i
264 OP_SUB_S, //(float)c = (char*)a - (char*)b sub_ii->f
265 OP_STOREP_C,//(float)c = *(char*)b = (float)a
266 OP_LOADP_C, //(float)c = *(char*)
267 //-------------------------------------
289 //erm... FTEQCC doesn't make use of these... These are for DP.
293 OP_GSTOREP_FLD, // integers //200
295 OP_GSTOREP_FNC, // pointers
306 //back to ones that we do use.
307 OP_UNUSED, //used to be OP_STOREP_P, which is now emulated with OP_STOREP_I, fteqcc nor fte generated it
308 OP_PUSH, //push 4octets onto the local-stack (which is ALWAYS poped on function return). Returns a pointer.
309 OP_POP, //pop those ones that were pushed (don't over do it). Needs assembler.
320 These ops are emulated out, always, and are only present in the compiler.
335 OP_MULSTORE_IF, //230
346 OP_DIVSTORE_FI, //240
364 // qtest structs (used for reordering and not execution)
365 typedef struct qtest_statement_s
367 unsigned int line; // line number in source code file
369 unsigned short a,b,c;
372 typedef struct qtest_def_s
374 unsigned int type; // no DEFGLOBAL found in qtest progs
375 unsigned int s_name; // different order!
379 typedef struct qtest_function_s
383 int locals; // assumed! (always 0 in real qtest progs)
384 int profile; // assumed! (always 0 in real qtest progs)
390 int parm_start; // different order
391 int parm_size[MAX_PARMS]; // ints instead of bytes...
395 typedef struct statement16_s
398 unsigned short a,b,c;
400 typedef struct statement32_s
406 typedef struct QCC_statement16_s
409 unsigned short a,b,c;
410 } QCC_dstatement16_t;
411 typedef struct QCC_statement32_s
415 } QCC_dstatement32_t;
416 #define QCC_dstatement_t QCC_dstatement32_t
419 //these should be the same except the string type
421 typedef struct ddef16_s
423 unsigned short type; // if DEF_SAVEGLOBAL bit is set
424 // the variable needs to be saved in savegames
429 typedef struct ddef32_s
431 unsigned int type; // if DEF_SAVEGLOBAL bit is set
432 // the variable needs to be saved in savegames
437 typedef struct fdef_s
439 unsigned int type; // if DEF_SAVEGLOBAL bit is set
440 // the variable needs to be saved in savegames
442 unsigned int progsofs; //used at loading time, so maching field offsets (unions/members) are positioned at the same runtime offset.
446 typedef void *ddefXX_t;
448 typedef struct QCC_ddef16_s
450 unsigned short type; // if DEF_SAVEGLOBAL bit is set
451 // the variable needs to be saved in savegames
456 typedef struct QCC_ddef32_s
458 unsigned int type; // if DEF_SAVEGLOBAL bit is set
459 // the variable needs to be saved in savegames
464 #define QCC_ddef_t QCC_ddef32_t
467 #define DEF_SAVEGLOBAL (1<<15)
468 #define DEF_SHARED (1<<14)
473 int first_statement; // negative numbers are builtins
475 int locals; // total ints of parms + locals
477 int profile; // runtime
480 string_t s_file; // source file defined in
483 qbyte parm_size[MAX_PARMS];
488 unsigned int first_statement; // negative numbers are builtins
489 unsigned int parm_start;
490 int locals; // total ints of parms + locals
492 int profile; // runtime
495 QCC_string_t s_file; // source file defined in
498 qbyte parm_size[MAX_PARMS];
502 #define PROG_QTESTVERSION 3
503 #define PROG_VERSION 6
504 #define PROG_KKQWSVVERSION 7
505 #define PROG_EXTENDEDVERSION 7
506 #define PROG_SECONDARYVERSION16 (*(int*)"1FTE" ^ *(int*)"PROG") //something unlikly and still meaningful (to me)
507 #define PROG_SECONDARYVERSION32 (*(int*)"1FTE" ^ *(int*)"32B ") //something unlikly and still meaningful (to me)
511 int crc; // check of header file
513 unsigned int ofs_statements; //comp 1
514 unsigned int numstatements; // statement 0 is an error
516 unsigned int ofs_globaldefs; //comp 2
517 unsigned int numglobaldefs;
519 unsigned int ofs_fielddefs; //comp 4
520 unsigned int numfielddefs;
522 unsigned int ofs_functions; //comp 8
523 unsigned int numfunctions; // function 0 is an empty
525 unsigned int ofs_strings; //comp 16
526 unsigned int numstrings; // first string is a null string
528 unsigned int ofs_globals; //comp 32
529 unsigned int numglobals;
531 unsigned int entityfields;
533 //debug / version 7 extensions
534 unsigned int ofsfiles; //non list format. no comp
535 unsigned int ofslinenums; //numstatements big //comp 64
536 unsigned int ofsbodylessfuncs; //no comp
537 unsigned int numbodylessfuncs;
539 unsigned int ofs_types; //comp 128
540 unsigned int numtypes;
541 unsigned int blockscompressed;
543 int secondaryversion; //Constant - to say that any version 7 progs are actually ours, not someone else's alterations.
545 #define standard_dprograms_t_size ((size_t)&((dprograms_t*)NULL)->ofsfiles)
559 } includeddatafile_t;
564 typedef struct typeinfo_s
572 int ofs; //inside a structure.