QCC.C 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. #include "qcc.h"
  2. char sourcedir[1024];
  3. char destfile[1024];
  4. float pr_globals[MAX_REGS];
  5. int numpr_globals;
  6. char strings[MAX_STRINGS];
  7. int strofs;
  8. dstatement_t statements[MAX_STATEMENTS];
  9. int numstatements;
  10. int statement_linenums[MAX_STATEMENTS];
  11. dfunction_t functions[MAX_FUNCTIONS];
  12. int numfunctions;
  13. ddef_t globals[MAX_GLOBALS];
  14. int numglobaldefs;
  15. ddef_t fields[MAX_FIELDS];
  16. int numfielddefs;
  17. char precache_sounds[MAX_SOUNDS][MAX_DATA_PATH];
  18. int precache_sounds_block[MAX_SOUNDS];
  19. int numsounds;
  20. char precache_models[MAX_MODELS][MAX_DATA_PATH];
  21. int precache_models_block[MAX_SOUNDS];
  22. int nummodels;
  23. char precache_files[MAX_FILES][MAX_DATA_PATH];
  24. int precache_files_block[MAX_SOUNDS];
  25. int numfiles;
  26. /*
  27. ============
  28. WriteFiles
  29. Generates files.dat, which contains all of the
  30. data files actually used by the game, to be
  31. processed by qfiles.exe
  32. ============
  33. */
  34. void WriteFiles (void)
  35. {
  36. FILE *f;
  37. int i;
  38. char filename[1024];
  39. sprintf (filename, "%sfiles.dat", sourcedir);
  40. f = fopen (filename, "w");
  41. if (!f)
  42. Error ("Couldn't open %s", filename);
  43. fprintf (f, "%i\n", numsounds);
  44. for (i=0 ; i<numsounds ; i++)
  45. fprintf (f, "%i %s\n", precache_sounds_block[i],
  46. precache_sounds[i]);
  47. fprintf (f, "%i\n", nummodels);
  48. for (i=0 ; i<nummodels ; i++)
  49. fprintf (f, "%i %s\n", precache_models_block[i],
  50. precache_models[i]);
  51. fprintf (f, "%i\n", numfiles);
  52. for (i=0 ; i<numfiles ; i++)
  53. fprintf (f, "%i %s\n", precache_files_block[i],
  54. precache_files[i]);
  55. fclose (f);
  56. }
  57. // CopyString returns an offset from the string heap
  58. int CopyString (char *str)
  59. {
  60. int old;
  61. old = strofs;
  62. strcpy (strings+strofs, str);
  63. strofs += strlen(str)+1;
  64. return old;
  65. }
  66. void PrintStrings (void)
  67. {
  68. int i, l, j;
  69. for (i=0 ; i<strofs ; i += l)
  70. {
  71. l = strlen(strings+i) + 1;
  72. printf ("%5i : ",i);
  73. for (j=0 ; j<l ; j++)
  74. {
  75. if (strings[i+j] == '\n')
  76. {
  77. putchar ('\\');
  78. putchar ('n');
  79. }
  80. else
  81. putchar (strings[i+j]);
  82. }
  83. printf ("\n");
  84. }
  85. }
  86. void PrintFunctions (void)
  87. {
  88. int i,j;
  89. dfunction_t *d;
  90. for (i=0 ; i<numfunctions ; i++)
  91. {
  92. d = &functions[i];
  93. printf ("%s : %s : %i %i (", strings + d->s_file, strings + d->s_name, d->first_statement, d->parm_start);
  94. for (j=0 ; j<d->numparms ; j++)
  95. printf ("%i ",d->parm_size[j]);
  96. printf (")\n");
  97. }
  98. }
  99. void PrintFields (void)
  100. {
  101. int i;
  102. ddef_t *d;
  103. for (i=0 ; i<numfielddefs ; i++)
  104. {
  105. d = &fields[i];
  106. printf ("%5i : (%i) %s\n", d->ofs, d->type, strings + d->s_name);
  107. }
  108. }
  109. void PrintGlobals (void)
  110. {
  111. int i;
  112. ddef_t *d;
  113. for (i=0 ; i<numglobaldefs ; i++)
  114. {
  115. d = &globals[i];
  116. printf ("%5i : (%i) %s\n", d->ofs, d->type, strings + d->s_name);
  117. }
  118. }
  119. void InitData (void)
  120. {
  121. int i;
  122. numstatements = 1;
  123. strofs = 1;
  124. numfunctions = 1;
  125. numglobaldefs = 1;
  126. numfielddefs = 1;
  127. def_ret.ofs = OFS_RETURN;
  128. for (i=0 ; i<MAX_PARMS ; i++)
  129. def_parms[i].ofs = OFS_PARM0 + 3*i;
  130. }
  131. void WriteData (int crc)
  132. {
  133. def_t *def;
  134. ddef_t *dd;
  135. dprograms_t progs;
  136. FILE *h;
  137. int i;
  138. for (def = pr.def_head.next ; def ; def = def->next)
  139. {
  140. if (def->type->type == ev_function)
  141. {
  142. // df = &functions[numfunctions];
  143. // numfunctions++;
  144. }
  145. else if (def->type->type == ev_field)
  146. {
  147. dd = &fields[numfielddefs];
  148. numfielddefs++;
  149. dd->type = def->type->aux_type->type;
  150. dd->s_name = CopyString (def->name);
  151. dd->ofs = G_INT(def->ofs);
  152. }
  153. dd = &globals[numglobaldefs];
  154. numglobaldefs++;
  155. dd->type = def->type->type;
  156. if ( !def->initialized
  157. && def->type->type != ev_function
  158. && def->type->type != ev_field
  159. && def->scope == NULL)
  160. dd->type |= DEF_SAVEGLOBGAL;
  161. dd->s_name = CopyString (def->name);
  162. dd->ofs = def->ofs;
  163. }
  164. //PrintStrings ();
  165. //PrintFunctions ();
  166. //PrintFields ();
  167. //PrintGlobals ();
  168. strofs = (strofs+3)&~3;
  169. printf ("%6i strofs\n", strofs);
  170. printf ("%6i numstatements\n", numstatements);
  171. printf ("%6i numfunctions\n", numfunctions);
  172. printf ("%6i numglobaldefs\n", numglobaldefs);
  173. printf ("%6i numfielddefs\n", numfielddefs);
  174. printf ("%6i numpr_globals\n", numpr_globals);
  175. h = SafeOpenWrite (destfile);
  176. SafeWrite (h, &progs, sizeof(progs));
  177. progs.ofs_strings = ftell (h);
  178. progs.numstrings = strofs;
  179. SafeWrite (h, strings, strofs);
  180. progs.ofs_statements = ftell (h);
  181. progs.numstatements = numstatements;
  182. for (i=0 ; i<numstatements ; i++)
  183. {
  184. statements[i].op = LittleShort(statements[i].op);
  185. statements[i].a = LittleShort(statements[i].a);
  186. statements[i].b = LittleShort(statements[i].b);
  187. statements[i].c = LittleShort(statements[i].c);
  188. }
  189. SafeWrite (h, statements, numstatements*sizeof(dstatement_t));
  190. progs.ofs_functions = ftell (h);
  191. progs.numfunctions = numfunctions;
  192. for (i=0 ; i<numfunctions ; i++)
  193. {
  194. functions[i].first_statement = LittleLong (functions[i].first_statement);
  195. functions[i].parm_start = LittleLong (functions[i].parm_start);
  196. functions[i].s_name = LittleLong (functions[i].s_name);
  197. functions[i].s_file = LittleLong (functions[i].s_file);
  198. functions[i].numparms = LittleLong (functions[i].numparms);
  199. functions[i].locals = LittleLong (functions[i].locals);
  200. }
  201. SafeWrite (h, functions, numfunctions*sizeof(dfunction_t));
  202. progs.ofs_globaldefs = ftell (h);
  203. progs.numglobaldefs = numglobaldefs;
  204. for (i=0 ; i<numglobaldefs ; i++)
  205. {
  206. globals[i].type = LittleShort (globals[i].type);
  207. globals[i].ofs = LittleShort (globals[i].ofs);
  208. globals[i].s_name = LittleLong (globals[i].s_name);
  209. }
  210. SafeWrite (h, globals, numglobaldefs*sizeof(ddef_t));
  211. progs.ofs_fielddefs = ftell (h);
  212. progs.numfielddefs = numfielddefs;
  213. for (i=0 ; i<numfielddefs ; i++)
  214. {
  215. fields[i].type = LittleShort (fields[i].type);
  216. fields[i].ofs = LittleShort (fields[i].ofs);
  217. fields[i].s_name = LittleLong (fields[i].s_name);
  218. }
  219. SafeWrite (h, fields, numfielddefs*sizeof(ddef_t));
  220. progs.ofs_globals = ftell (h);
  221. progs.numglobals = numpr_globals;
  222. for (i=0 ; i<numpr_globals ; i++)
  223. ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]);
  224. SafeWrite (h, pr_globals, numpr_globals*4);
  225. printf ("%6i TOTAL SIZE\n", (int)ftell (h));
  226. progs.entityfields = pr.size_fields;
  227. progs.version = PROG_VERSION;
  228. progs.crc = crc;
  229. // byte swap the header and write it out
  230. for (i=0 ; i<sizeof(progs)/4 ; i++)
  231. ((int *)&progs)[i] = LittleLong ( ((int *)&progs)[i] );
  232. fseek (h, 0, SEEK_SET);
  233. SafeWrite (h, &progs, sizeof(progs));
  234. fclose (h);
  235. }
  236. /*
  237. ===============
  238. PR_String
  239. Returns a string suitable for printing (no newlines, max 60 chars length)
  240. ===============
  241. */
  242. char *PR_String (char *string)
  243. {
  244. static char buf[80];
  245. char *s;
  246. s = buf;
  247. *s++ = '"';
  248. while (string && *string)
  249. {
  250. if (s == buf + sizeof(buf) - 2)
  251. break;
  252. if (*string == '\n')
  253. {
  254. *s++ = '\\';
  255. *s++ = 'n';
  256. }
  257. else if (*string == '"')
  258. {
  259. *s++ = '\\';
  260. *s++ = '"';
  261. }
  262. else
  263. *s++ = *string;
  264. string++;
  265. if (s - buf > 60)
  266. {
  267. *s++ = '.';
  268. *s++ = '.';
  269. *s++ = '.';
  270. break;
  271. }
  272. }
  273. *s++ = '"';
  274. *s++ = 0;
  275. return buf;
  276. }
  277. def_t *PR_DefForFieldOfs (gofs_t ofs)
  278. {
  279. def_t *d;
  280. for (d=pr.def_head.next ; d ; d=d->next)
  281. {
  282. if (d->type->type != ev_field)
  283. continue;
  284. if (*((int *)&pr_globals[d->ofs]) == ofs)
  285. return d;
  286. }
  287. Error ("PR_DefForFieldOfs: couldn't find %i",ofs);
  288. return NULL;
  289. }
  290. /*
  291. ============
  292. PR_ValueString
  293. Returns a string describing *data in a type specific manner
  294. =============
  295. */
  296. char *PR_ValueString (etype_t type, void *val)
  297. {
  298. static char line[256];
  299. def_t *def;
  300. dfunction_t *f;
  301. switch (type)
  302. {
  303. case ev_string:
  304. sprintf (line, "%s", PR_String(strings + *(int *)val));
  305. break;
  306. case ev_entity:
  307. sprintf (line, "entity %i", *(int *)val);
  308. break;
  309. case ev_function:
  310. f = functions + *(int *)val;
  311. if (!f)
  312. sprintf (line, "undefined function");
  313. else
  314. sprintf (line, "%s()", strings + f->s_name);
  315. break;
  316. case ev_field:
  317. def = PR_DefForFieldOfs ( *(int *)val );
  318. sprintf (line, ".%s", def->name);
  319. break;
  320. case ev_void:
  321. sprintf (line, "void");
  322. break;
  323. case ev_float:
  324. sprintf (line, "%5.1f", *(float *)val);
  325. break;
  326. case ev_vector:
  327. sprintf (line, "'%5.1f %5.1f %5.1f'", ((float *)val)[0], ((float *)val)[1], ((float *)val)[2]);
  328. break;
  329. case ev_pointer:
  330. sprintf (line, "pointer");
  331. break;
  332. default:
  333. sprintf (line, "bad type %i", type);
  334. break;
  335. }
  336. return line;
  337. }
  338. /*
  339. ============
  340. PR_GlobalString
  341. Returns a string with a description and the contents of a global,
  342. padded to 20 field width
  343. ============
  344. */
  345. char *PR_GlobalStringNoContents (gofs_t ofs)
  346. {
  347. int i;
  348. def_t *def;
  349. void *val;
  350. static char line[128];
  351. val = (void *)&pr_globals[ofs];
  352. def = pr_global_defs[ofs];
  353. if (!def)
  354. // Error ("PR_GlobalString: no def for %i", ofs);
  355. sprintf (line,"%i(???)", ofs);
  356. else
  357. sprintf (line,"%i(%s)", ofs, def->name);
  358. i = strlen(line);
  359. for ( ; i<16 ; i++)
  360. strcat (line," ");
  361. strcat (line," ");
  362. return line;
  363. }
  364. char *PR_GlobalString (gofs_t ofs)
  365. {
  366. char *s;
  367. int i;
  368. def_t *def;
  369. void *val;
  370. static char line[128];
  371. val = (void *)&pr_globals[ofs];
  372. def = pr_global_defs[ofs];
  373. if (!def)
  374. return PR_GlobalStringNoContents(ofs);
  375. if (def->initialized && def->type->type != ev_function)
  376. {
  377. s = PR_ValueString (def->type->type, &pr_globals[ofs]);
  378. sprintf (line,"%i(%s)", ofs, s);
  379. }
  380. else
  381. sprintf (line,"%i(%s)", ofs, def->name);
  382. i = strlen(line);
  383. for ( ; i<16 ; i++)
  384. strcat (line," ");
  385. strcat (line," ");
  386. return line;
  387. }
  388. /*
  389. ============
  390. PR_PrintOfs
  391. ============
  392. */
  393. void PR_PrintOfs (gofs_t ofs)
  394. {
  395. printf ("%s\n",PR_GlobalString(ofs));
  396. }
  397. /*
  398. =================
  399. PR_PrintStatement
  400. =================
  401. */
  402. void PR_PrintStatement (dstatement_t *s)
  403. {
  404. int i;
  405. printf ("%4i : %4i : %s ", (int)(s - statements), statement_linenums[s-statements], pr_opcodes[s->op].opname);
  406. i = strlen(pr_opcodes[s->op].opname);
  407. for ( ; i<10 ; i++)
  408. printf (" ");
  409. if (s->op == OP_IF || s->op == OP_IFNOT)
  410. printf ("%sbranch %i",PR_GlobalString(s->a),s->b);
  411. else if (s->op == OP_GOTO)
  412. {
  413. printf ("branch %i",s->a);
  414. }
  415. else if ( (unsigned)(s->op - OP_STORE_F) < 6)
  416. {
  417. printf ("%s",PR_GlobalString(s->a));
  418. printf ("%s", PR_GlobalStringNoContents(s->b));
  419. }
  420. else
  421. {
  422. if (s->a)
  423. printf ("%s",PR_GlobalString(s->a));
  424. if (s->b)
  425. printf ("%s",PR_GlobalString(s->b));
  426. if (s->c)
  427. printf ("%s", PR_GlobalStringNoContents(s->c));
  428. }
  429. printf ("\n");
  430. }
  431. /*
  432. ============
  433. PR_PrintDefs
  434. ============
  435. */
  436. void PR_PrintDefs (void)
  437. {
  438. def_t *d;
  439. for (d=pr.def_head.next ; d ; d=d->next)
  440. PR_PrintOfs (d->ofs);
  441. }
  442. /*
  443. ==============
  444. PR_BeginCompilation
  445. called before compiling a batch of files, clears the pr struct
  446. ==============
  447. */
  448. void PR_BeginCompilation (void *memory, int memsize)
  449. {
  450. int i;
  451. pr.memory = memory;
  452. pr.max_memory = memsize;
  453. numpr_globals = RESERVED_OFS;
  454. pr.def_tail = &pr.def_head;
  455. for (i=0 ; i<RESERVED_OFS ; i++)
  456. pr_global_defs[i] = &def_void;
  457. // link the function type in so state forward declarations match proper type
  458. pr.types = &type_function;
  459. type_function.next = NULL;
  460. pr_error_count = 0;
  461. }
  462. /*
  463. ==============
  464. PR_FinishCompilation
  465. called after all files are compiled to check for errors
  466. Returns false if errors were detected.
  467. ==============
  468. */
  469. qboolean PR_FinishCompilation (void)
  470. {
  471. def_t *d;
  472. qboolean errors;
  473. errors = false;
  474. // check to make sure all functions prototyped have code
  475. for (d=pr.def_head.next ; d ; d=d->next)
  476. {
  477. if (d->type->type == ev_function && !d->scope)// function parms are ok
  478. {
  479. // f = G_FUNCTION(d->ofs);
  480. // if (!f || (!f->code && !f->builtin) )
  481. if (!d->initialized)
  482. {
  483. printf ("function %s was not defined\n",d->name);
  484. errors = true;
  485. }
  486. }
  487. }
  488. return !errors;
  489. }
  490. //=============================================================================
  491. /*
  492. ============
  493. PR_WriteProgdefs
  494. Writes the global and entity structures out
  495. Returns a crc of the header, to be stored in the progs file for comparison
  496. at load time.
  497. ============
  498. */
  499. int PR_WriteProgdefs (char *filename)
  500. {
  501. def_t *d;
  502. FILE *f;
  503. unsigned short crc;
  504. int c;
  505. printf ("writing %s\n", filename);
  506. f = fopen (filename, "w");
  507. // print global vars until the first field is defined
  508. fprintf (f,"\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{\tint\tpad[%i];\n", RESERVED_OFS);
  509. for (d=pr.def_head.next ; d ; d=d->next)
  510. {
  511. if (!strcmp (d->name, "end_sys_globals"))
  512. break;
  513. switch (d->type->type)
  514. {
  515. case ev_float:
  516. fprintf (f, "\tfloat\t%s;\n",d->name);
  517. break;
  518. case ev_vector:
  519. fprintf (f, "\tvec3_t\t%s;\n",d->name);
  520. d=d->next->next->next; // skip the elements
  521. break;
  522. case ev_string:
  523. fprintf (f,"\tstring_t\t%s;\n",d->name);
  524. break;
  525. case ev_function:
  526. fprintf (f,"\tfunc_t\t%s;\n",d->name);
  527. break;
  528. case ev_entity:
  529. fprintf (f,"\tint\t%s;\n",d->name);
  530. break;
  531. default:
  532. fprintf (f,"\tint\t%s;\n",d->name);
  533. break;
  534. }
  535. }
  536. fprintf (f,"} globalvars_t;\n\n");
  537. // print all fields
  538. fprintf (f,"typedef struct\n{\n");
  539. for (d=pr.def_head.next ; d ; d=d->next)
  540. {
  541. if (!strcmp (d->name, "end_sys_fields"))
  542. break;
  543. if (d->type->type != ev_field)
  544. continue;
  545. switch (d->type->aux_type->type)
  546. {
  547. case ev_float:
  548. fprintf (f,"\tfloat\t%s;\n",d->name);
  549. break;
  550. case ev_vector:
  551. fprintf (f,"\tvec3_t\t%s;\n",d->name);
  552. d=d->next->next->next; // skip the elements
  553. break;
  554. case ev_string:
  555. fprintf (f,"\tstring_t\t%s;\n",d->name);
  556. break;
  557. case ev_function:
  558. fprintf (f,"\tfunc_t\t%s;\n",d->name);
  559. break;
  560. case ev_entity:
  561. fprintf (f,"\tint\t%s;\n",d->name);
  562. break;
  563. default:
  564. fprintf (f,"\tint\t%s;\n",d->name);
  565. break;
  566. }
  567. }
  568. fprintf (f,"} entvars_t;\n\n");
  569. fclose (f);
  570. // do a crc of the file
  571. CRC_Init (&crc);
  572. f = fopen (filename, "r+");
  573. while ((c = fgetc(f)) != EOF)
  574. CRC_ProcessByte (&crc, (byte)c);
  575. fprintf (f,"#define PROGHEADER_CRC %i\n", crc);
  576. fclose (f);
  577. return crc;
  578. }
  579. void PrintFunction (char *name)
  580. {
  581. int i;
  582. dstatement_t *ds;
  583. dfunction_t *df;
  584. for (i=0 ; i<numfunctions ; i++)
  585. if (!strcmp (name, strings + functions[i].s_name))
  586. break;
  587. if (i==numfunctions)
  588. Error ("No function names \"%s\"", name);
  589. df = functions + i;
  590. printf ("Statements for %s:\n", name);
  591. ds = statements + df->first_statement;
  592. while (1)
  593. {
  594. PR_PrintStatement (ds);
  595. if (!ds->op)
  596. break;
  597. ds++;
  598. }
  599. }
  600. //============================================================================
  601. /*
  602. ============
  603. main
  604. ============
  605. */
  606. void main (int argc, char **argv)
  607. {
  608. char *src;
  609. char *src2;
  610. char filename[1024];
  611. int p, crc;
  612. double start, stop;
  613. start = I_FloatTime ();
  614. myargc = argc;
  615. myargv = argv;
  616. if ( CheckParm ("-?") || CheckParm ("-help"))
  617. {
  618. printf ("qcc looks for progs.src in the current directory.\n");
  619. printf ("to look in a different directory: qcc -src <directory>\n");
  620. printf ("to build a clean data tree: qcc -copy <srcdir> <destdir>\n");
  621. printf ("to build a clean pak file: qcc -pak <srcdir> <packfile>\n");
  622. printf ("to bsp all bmodels: qcc -bspmodels <gamedir>\n");
  623. return;
  624. }
  625. p = CheckParm ("-src");
  626. if (p && p < argc-1 )
  627. {
  628. strcpy (sourcedir, argv[p+1]);
  629. strcat (sourcedir, "/");
  630. printf ("Source directory: %s\n", sourcedir);
  631. }
  632. else
  633. strcpy (sourcedir, "");
  634. InitData ();
  635. sprintf (filename, "%sprogs.src", sourcedir);
  636. LoadFile (filename, (void *)&src);
  637. src = COM_Parse (src);
  638. if (!src)
  639. Error ("No destination filename. qcc -help for info.\n");
  640. strcpy (destfile, com_token);
  641. printf ("outputfile: %s\n", destfile);
  642. pr_dumpasm = false;
  643. PR_BeginCompilation (malloc (0x100000), 0x100000);
  644. // compile all the files
  645. do
  646. {
  647. src = COM_Parse(src);
  648. if (!src)
  649. break;
  650. sprintf (filename, "%s%s", sourcedir, com_token);
  651. printf ("compiling %s\n", filename);
  652. LoadFile (filename, (void *)&src2);
  653. if (!PR_CompileFile (src2, filename) )
  654. exit (1);
  655. } while (1);
  656. if (!PR_FinishCompilation ())
  657. Error ("compilation errors");
  658. p = CheckParm ("-asm");
  659. if (p)
  660. {
  661. for (p++ ; p<argc ; p++)
  662. {
  663. if (argv[p][0] == '-')
  664. break;
  665. PrintFunction (argv[p]);
  666. }
  667. }
  668. // write progdefs.h
  669. crc = PR_WriteProgdefs ("progdefs.h");
  670. // write data file
  671. WriteData (crc);
  672. // write files.dat
  673. WriteFiles ();
  674. stop = I_FloatTime ();
  675. printf ("%i seconds elapsed.\n", (int)(stop-start));
  676. }