Bite the bullet - size siymbols have to be shared.
[open-adventure.git] / compile.c
index f8b1167b667a279867c587054b57abd989a89262..f0306562bf9eb77c24b599be8a9ef6bc2aeae245 100644 (file)
--- a/compile.c
+++ b/compile.c
@@ -1,13 +1,21 @@
+/*
+ * The dungeon compiler. Turns adventure.text into a set of C initializers
+ * defining (mostly) invariant state.  A couple of slots are messed with
+ * at runtime.
+ */
+#include "sizes.h"
+
 #define LINESIZE 100
 #define RTXSIZ 277
 #define CLSMAX 12
-#define LOCSIZ 185
 #define LINSIZ 12600
 #define TRNSIZ 5
 #define TABSIZ 330
 #define VRBSIZ 35
 #define HNTSIZ 20
 #define TRVSIZ 885
+#define TOKLEN 5
+#define HINTLEN 5
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -55,7 +63,7 @@ long ATAB[TABSIZ + 1];
 long PLAC[NOBJECTS+1];
 long FIXD[NOBJECTS+1];
 long ACTSPK[VRBSIZ + 1];
-long HINTS[HNTSIZ + 1][5];
+long HINTS[HNTSIZ + 1][HINTLEN];
 
 bool is_set(long, long);
 long GETTXT(long, long, long);
@@ -73,7 +81,7 @@ void read_hints(FILE*);
 void read_sound_text(FILE*);
 void write_0d(FILE*, FILE*, long, char*);
 void write_1d(FILE*, FILE*, long[], long, char*);
-void write_hints(FILE*, FILE*, long[][5], long, long, char*);
+void write_hints(FILE*, FILE*, long[][HINTLEN], long, long, char*);
 void write_files(FILE*, FILE*);
 
 bool is_set(long var, long position)
@@ -105,7 +113,7 @@ long GETTXT(long SKIP,long ONEWRD, long UPPER) {
   }
 
   TEXT=0;
-  for (int I=1; I<=5; I++) {
+  for (int I=1; I<=TOKLEN; I++) {
     TEXT=TEXT*64;
     if(LNPOSN > LNLENG || (ONEWRD && INLINE[LNPOSN] == 0))
       continue;
@@ -500,7 +508,7 @@ void read_sound_text(FILE* database)
  *  to set up ATLOC(N) as the first object at location N, and
  *  LINK(OBJ) as the next object at the same location as OBJ.
  *  (OBJ>NOBJECTS indicates that FIXED(OBJ-NOBJECTS)=LOC; LINK(OBJ) is
- *  still the correct link to use.)  ABB is zeroed; it controls
+ *  still the correct link to use.)  game.abbrev is zeroed; it controls
  *  whether the abbreviated description is printed.  Counts modulo 5
  *  unless "LOOK" is used. */
 
@@ -527,7 +535,7 @@ void write_1d(FILE* c_file, FILE* header_file, long array[], long dim, char* var
   fprintf(header_file, "extern long %s[%ld];\n", varname, dim);
 }
 
-void write_hints(FILE* c_file, FILE* header_file, long matrix[][5], long dim1, long dim2, char* varname)
+void write_hints(FILE* c_file, FILE* header_file, long matrix[][HINTLEN], long dim1, long dim2, char* varname)
 {
   fprintf(c_file, "long %s[][%ld] = {\n", varname, dim2);
   for (int i = 0; i < dim1; ++i)
@@ -546,16 +554,17 @@ void write_hints(FILE* c_file, FILE* header_file, long matrix[][5], long dim1, l
 void write_files(FILE* c_file, FILE* header_file)
 {
   // preprocessor defines for the header
-  fprintf(header_file, "#define NOBJECTS %d\n", NOBJECTS);
+  fprintf(header_file, "#include \"sizes.h\"\n");
   fprintf(header_file, "#define RTXSIZ 277\n");
   fprintf(header_file, "#define CLSMAX 12\n");
-  fprintf(header_file, "#define LOCSIZ 185\n");
   fprintf(header_file, "#define LINSIZ %d\n", LINSIZ);
   fprintf(header_file, "#define TRNSIZ 5\n");
   fprintf(header_file, "#define TABSIZ 330\n");
   fprintf(header_file, "#define VRBSIZ 35\n");
   fprintf(header_file, "#define HNTSIZ 20\n");
   fprintf(header_file, "#define TRVSIZ 885\n");
+  fprintf(header_file, "#define TOKLEN %d\n", TOKLEN);
+  fprintf(header_file, "#define HINTLEN %d\n", HINTLEN);
   fprintf(header_file, "\n");
 
   // include the header in the C file