+VECTOR_MAKE(int, code_globals );
+VECTOR_MAKE(char, code_strings );
+
+void code_init() {
+ /*
+ * The way progs.dat is suppose to work is odd, there needs to be
+ * some null (empty) statements, functions, and 28 globals
+ */
+ prog_section_function empty_function = {0,0,0,0,0,0,0,{0}};
+ prog_section_statement empty_statement = {0,{0},{0},{0}};
+ int i;
+ for(i = 0; i < 28; i++)
+ code_globals_add(0);
+
+ code_strings_add ('\0');
+ code_functions_add (empty_function);
+ code_statements_add(empty_statement);
+}
+
+void code_test() {
+ const char *X;
+ size_t size = sizeof(X);
+ size_t iter = 0;
+
+ #define FOO(Y) \
+ X = Y; \
+ size = sizeof(Y); \
+ for (iter=0; iter < size; iter++) { \
+ code_strings_add(X[iter]); \
+ }
+
+ FOO("m_init");
+ FOO("print");
+ FOO("hello world\n");
+ FOO("m_keydown");
+ FOO("m_draw");
+ FOO("m_toggle");
+ FOO("m_shutdown");
+
+ code_globals_add(1); /* m_init */
+ code_globals_add(2); /* print */
+ code_globals_add(14); /* hello world in string table */
+
+ /* now the defs */
+ code_defs_add((prog_section_def){.type=TYPE_VOID, .offset=28/*globals[28]*/, .name=1 }); /* m_init */
+ code_defs_add((prog_section_def){.type=TYPE_FUNCTION,.offset=29/*globals[29]*/, .name=8 }); /* print */
+ code_defs_add((prog_section_def){.type=TYPE_STRING, .offset=30/*globals[30]*/, .name=14}); /*hello_world*/
+
+ code_functions_add((prog_section_function){1, 0, 0, 0, .name=1, 0, 0, {0}}); /* m_init */
+ code_functions_add((prog_section_function){-4, 0, 0, 0, .name=8, 0, 0, {0}}); /* print */
+ code_functions_add((prog_section_function){0, 0, 0, 0, .name=14+13, 0,0, {0}}); /* m_keydown */
+ code_functions_add((prog_section_function){0, 0, 0, 0, .name=14+13+10, 0,0, {0}});
+ code_functions_add((prog_section_function){0, 0, 0, 0, .name=14+13+10+7, 0,0, {0}});
+ code_functions_add((prog_section_function){0, 0, 0, 0, .name=14+13+10+7+9, 0,0, {0}});
+
+ code_statements_add((prog_section_statement){INSTR_STORE_F, {30}/*30 is hello_world */, {OFS_PARM0}, {0}});
+ code_statements_add((prog_section_statement){INSTR_CALL1, {29}/*29 is print */, {0}, {0}});
+ code_statements_add((prog_section_statement){INSTR_RETURN, {0}, {0}, {0}});
+}