pr_comp.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // this file is shared by quake and qcc
  16. typedef int func_t;
  17. typedef int string_t;
  18. typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t;
  19. #define OFS_NULL 0
  20. #define OFS_RETURN 1
  21. #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
  22. #define OFS_PARM1 7
  23. #define OFS_PARM2 10
  24. #define OFS_PARM3 13
  25. #define OFS_PARM4 16
  26. #define OFS_PARM5 19
  27. #define OFS_PARM6 22
  28. #define OFS_PARM7 25
  29. #define RESERVED_OFS 28
  30. enum {
  31. OP_DONE,
  32. OP_MUL_F,
  33. OP_MUL_V,
  34. OP_MUL_FV,
  35. OP_MUL_VF,
  36. OP_DIV_F,
  37. OP_ADD_F,
  38. OP_ADD_V,
  39. OP_SUB_F,
  40. OP_SUB_V,
  41. OP_EQ_F,
  42. OP_EQ_V,
  43. OP_EQ_S,
  44. OP_EQ_E,
  45. OP_EQ_FNC,
  46. OP_NE_F,
  47. OP_NE_V,
  48. OP_NE_S,
  49. OP_NE_E,
  50. OP_NE_FNC,
  51. OP_LE,
  52. OP_GE,
  53. OP_LT,
  54. OP_GT,
  55. OP_LOAD_F,
  56. OP_LOAD_V,
  57. OP_LOAD_S,
  58. OP_LOAD_ENT,
  59. OP_LOAD_FLD,
  60. OP_LOAD_FNC,
  61. OP_ADDRESS,
  62. OP_STORE_F,
  63. OP_STORE_V,
  64. OP_STORE_S,
  65. OP_STORE_ENT,
  66. OP_STORE_FLD,
  67. OP_STORE_FNC,
  68. OP_STOREP_F,
  69. OP_STOREP_V,
  70. OP_STOREP_S,
  71. OP_STOREP_ENT,
  72. OP_STOREP_FLD,
  73. OP_STOREP_FNC,
  74. OP_RETURN,
  75. OP_NOT_F,
  76. OP_NOT_V,
  77. OP_NOT_S,
  78. OP_NOT_ENT,
  79. OP_NOT_FNC,
  80. OP_IF,
  81. OP_IFNOT,
  82. OP_CALL0,
  83. OP_CALL1,
  84. OP_CALL2,
  85. OP_CALL3,
  86. OP_CALL4,
  87. OP_CALL5,
  88. OP_CALL6,
  89. OP_CALL7,
  90. OP_CALL8,
  91. OP_STATE,
  92. OP_GOTO,
  93. OP_AND,
  94. OP_OR,
  95. OP_BITAND,
  96. OP_BITOR
  97. };
  98. typedef struct statement_s
  99. {
  100. unsigned short op;
  101. short a,b,c;
  102. } dstatement_t;
  103. typedef struct
  104. {
  105. unsigned short type; // if DEF_SAVEGLOBGAL bit is set
  106. // the variable needs to be saved in savegames
  107. unsigned short ofs;
  108. int s_name;
  109. } ddef_t;
  110. #define DEF_SAVEGLOBAL (1<<15)
  111. #define MAX_PARMS 8
  112. typedef struct
  113. {
  114. int first_statement; // negative numbers are builtins
  115. int parm_start;
  116. int locals; // total ints of parms + locals
  117. int profile; // runtime
  118. int s_name;
  119. int s_file; // source file defined in
  120. int numparms;
  121. byte parm_size[MAX_PARMS];
  122. } dfunction_t;
  123. #define PROG_VERSION 6
  124. typedef struct
  125. {
  126. int version;
  127. int crc; // check of header file
  128. int ofs_statements;
  129. int numstatements; // statement 0 is an error
  130. int ofs_globaldefs;
  131. int numglobaldefs;
  132. int ofs_fielddefs;
  133. int numfielddefs;
  134. int ofs_functions;
  135. int numfunctions; // function 0 is an empty
  136. int ofs_strings;
  137. int numstrings; // first string is a null string
  138. int ofs_globals;
  139. int numglobals;
  140. int entityfields;
  141. } dprograms_t;