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
264 OP_SUB_S, //(float)c = (char*)a - (char*)b
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.
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
358 // qtest structs (used for reordering and not execution)
359 typedef struct qtest_statement_s
361 unsigned int line; // line number in source code file
363 unsigned short a,b,c;
366 typedef struct qtest_def_s
368 unsigned int type; // no DEFGLOBAL found in qtest progs
369 unsigned int s_name; // different order!
373 typedef struct qtest_function_s
377 int locals; // assumed! (always 0 in real qtest progs)
378 int profile; // assumed! (always 0 in real qtest progs)
384 int parm_start; // different order
385 int parm_size[MAX_PARMS]; // ints instead of bytes...
389 typedef struct statement16_s
392 unsigned short a,b,c;
394 typedef struct statement32_s
400 typedef struct QCC_statement16_s
403 unsigned short a,b,c;
404 } QCC_dstatement16_t;
405 typedef struct QCC_statement32_s
409 } QCC_dstatement32_t;
410 #define QCC_dstatement_t QCC_dstatement32_t
413 //these should be the same except the string type
415 typedef struct ddef16_s
417 unsigned short type; // if DEF_SAVEGLOBAL bit is set
418 // the variable needs to be saved in savegames
423 typedef struct ddef32_s
425 unsigned int type; // if DEF_SAVEGLOBAL bit is set
426 // the variable needs to be saved in savegames
431 typedef struct fdef_s
433 unsigned int type; // if DEF_SAVEGLOBAL bit is set
434 // the variable needs to be saved in savegames
436 unsigned int progsofs; //used at loading time, so maching field offsets (unions/members) are positioned at the same runtime offset.
440 typedef void *ddefXX_t;
442 typedef struct QCC_ddef16_s
444 unsigned short type; // if DEF_SAVEGLOBAL bit is set
445 // the variable needs to be saved in savegames
450 typedef struct QCC_ddef32_s
452 unsigned int type; // if DEF_SAVEGLOBAL bit is set
453 // the variable needs to be saved in savegames
458 #define QCC_ddef_t QCC_ddef32_t
461 #define DEF_SAVEGLOBAL (1<<15)
462 #define DEF_SHARED (1<<14)
467 int first_statement; // negative numbers are builtins
469 int locals; // total ints of parms + locals
471 int profile; // runtime
474 string_t s_file; // source file defined in
477 qbyte parm_size[MAX_PARMS];
482 unsigned int first_statement; // negative numbers are builtins
483 unsigned int parm_start;
484 int locals; // total ints of parms + locals
486 int profile; // runtime
489 QCC_string_t s_file; // source file defined in
492 qbyte parm_size[MAX_PARMS];
496 #define PROG_QTESTVERSION 3
497 #define PROG_VERSION 6
498 #define PROG_KKQWSVVERSION 7
499 #define PROG_EXTENDEDVERSION 7
500 #define PROG_SECONDARYVERSION16 (*(int*)"1FTE" ^ *(int*)"PROG") //something unlikly and still meaningful (to me)
501 #define PROG_SECONDARYVERSION32 (*(int*)"1FTE" ^ *(int*)"32B ") //something unlikly and still meaningful (to me)
505 int crc; // check of header file
507 unsigned int ofs_statements; //comp 1
508 unsigned int numstatements; // statement 0 is an error
510 unsigned int ofs_globaldefs; //comp 2
511 unsigned int numglobaldefs;
513 unsigned int ofs_fielddefs; //comp 4
514 unsigned int numfielddefs;
516 unsigned int ofs_functions; //comp 8
517 unsigned int numfunctions; // function 0 is an empty
519 unsigned int ofs_strings; //comp 16
520 unsigned int numstrings; // first string is a null string
522 unsigned int ofs_globals; //comp 32
523 unsigned int numglobals;
525 unsigned int entityfields;
527 //debug / version 7 extensions
528 unsigned int ofsfiles; //non list format. no comp
529 unsigned int ofslinenums; //numstatements big //comp 64
530 unsigned int ofsbodylessfuncs; //no comp
531 unsigned int numbodylessfuncs;
533 unsigned int ofs_types; //comp 128
534 unsigned int numtypes;
535 unsigned int blockscompressed;
537 int secondaryversion; //Constant - to say that any version 7 progs are actually ours, not someone else's alterations.
539 #define standard_dprograms_t_size ((size_t)&((dprograms_t*)NULL)->ofsfiles)
553 } includeddatafile_t;
558 typedef struct typeinfo_s
566 int ofs; //inside a structure.