]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - code.c
Trash misinofmred README
[xonotic/gmqcc.git] / code.c
diff --git a/code.c b/code.c
index 5c69e8803496775313fd91b3d4e4c54dc8abc312..e828ccc81b5da0c3d6964fa820162600f71922d1 100644 (file)
--- a/code.c
+++ b/code.c
@@ -63,13 +63,17 @@ VECTOR_MAKE(prog_section_function,  code_functions );
 VECTOR_MAKE(int,                    code_globals   );
 VECTOR_MAKE(char,                   code_chars     );
 
+uint16_t                            code_crc;
 uint32_t                            code_entfields;
 
 void code_init() {
     prog_section_function  empty_function  = {0,0,0,0,0,0,0,{0}};
     prog_section_statement empty_statement = {0,{0},{0},{0}};
+    prog_section_def       empty_def       = {0, 0, 0};
     int                    i               = 0;
 
+    code_entfields = 0;
+
     /* omit creation of null code */
     if (OPTS_FLAG(OMIT_NULL_BYTES))
         return;
@@ -84,8 +88,8 @@ void code_init() {
     code_chars_add     ('\0');
     code_functions_add (empty_function);
     code_statements_add(empty_statement);
-
-    code_entfields = 0;
+    code_defs_add      (empty_def);
+    code_fields_add    (empty_def);
 }
 
 uint32_t code_genstring(const char *str)
@@ -183,7 +187,10 @@ bool code_write(const char *filename) {
     code_header.strings.offset    = code_header.globals.offset    + (sizeof(int32_t)                * code_globals_elements);
     code_header.strings.length    = code_chars_elements;
     code_header.version           = 6;
-    code_header.crc16             = 0; /* TODO: */
+    if (opts_forcecrc)
+        code_header.crc16         = opts_forced_crc;
+    else
+        code_header.crc16         = code_crc;
     code_header.entfield          = code_entfields;
 
     if (OPTS_FLAG(DARKPLACES_STRING_TABLE_BUG)) {
@@ -258,7 +265,7 @@ bool code_write(const char *filename) {
             util_debug("GEN", "    CODE:\n");
             for (;;) {
                 if (code_statements_data[j].opcode != AINSTR_END)
-                    util_debug("GEN", "        %s {0x%05x,0x%05x,0x%05x}\n",
+                    util_debug("GEN", "        %-12s {% 5i,% 5i,% 5i}\n",
                         asm_instr[code_statements_data[j].opcode].m,
                         code_statements_data[j].o1.s1,
                         code_statements_data[j].o2.s1,