From: Jason S. Ninneman Date: Sat, 10 Jun 2017 20:36:29 +0000 (-0700) Subject: Use a header/source set common to both advent and the dungeon builder. X-Git-Tag: 1.1~447 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1173a9a265a3132688830c26077129e3c624cd13;p=open-adventure.git Use a header/source set common to both advent and the dungeon builder. --- diff --git a/Makefile b/Makefile index 46fe7ca..0b3e9a7 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ ifeq ($(UNAME_S),Linux) LIBS=-lrt endif -OBJS=main.o init.o actions.o score.o misc.o saveresume.o -SOURCES=$(OBJS:.o=.c) dungeon.c advent.h sizes.h adventure.text Makefile control linenoise/linenoise.[ch] +OBJS=main.o init.o actions.o score.o misc.o saveresume.o common.o +SOURCES=$(OBJS:.o=.c) dungeon.c advent.h common.h adventure.text Makefile control linenoise/linenoise.[ch] .c.o: $(CC) $(CCFLAGS) $(DBX) -c $< @@ -30,19 +30,21 @@ SOURCES=$(OBJS:.o=.c) dungeon.c advent.h sizes.h adventure.text Makefile control advent: $(OBJS) database.o linenoise.o $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) database.o linenoise.o $(LDFLAGS) $(LIBS) -main.o: advent.h database.h database.c sizes.h +main.o: advent.h database.h database.c common.h -init.o: advent.h database.h database.c sizes.h +init.o: advent.h database.h database.c common.h -actions.o: advent.h database.h database.c sizes.h +actions.o: advent.h database.h database.c common.h -score.o: advent.h database.h database.c sizes.h +score.o: advent.h database.h database.c common.h -misc.o: advent.h database.h database.c sizes.h +misc.o: advent.h database.h database.c common.h -saveresume.o: advent.h database.h database.c sizes.h +saveresume.o: advent.h database.h database.c common.h -database.o: database.c database.h sizes.h +common.o: common.h + +database.o: database.c database.h common.h $(CC) $(CCFLAGS) $(DBX) -c database.c database.c database.h: dungeon @@ -51,8 +53,8 @@ database.c database.h: dungeon linenoise.o: linenoise/linenoise.h $(CC) $(CCFLAGS) $(DBX) -c linenoise/linenoise.c -dungeon: dungeon.c - $(CC) $(CCFLAGS) -o $@ $< +dungeon: dungeon.o common.o + $(CC) $(CCFLAGS) -o $@ dungeon.o common.o clean: rm -f *.o advent *.html database.[ch] dungeon *.gcno *.gcda diff --git a/advent.h b/advent.h index df6efdb..16b721c 100644 --- a/advent.h +++ b/advent.h @@ -1,7 +1,7 @@ #include #include -#include "sizes.h" +#include "common.h" #define LINESIZE 100 #define NDWARVES 6 diff --git a/common.h b/common.h new file mode 100644 index 0000000..4daed0e --- /dev/null +++ b/common.h @@ -0,0 +1,8 @@ +/* maximum size limits shared by dungeon compiler and runtime */ + +#define LOCSIZ 185 +#define NOBJECTS 100 +#define HNTSIZ 20 + +extern const char advent_to_ascii[129]; +extern const char ascii_to_advent[129]; diff --git a/dungeon.c b/dungeon.c index 73f1476..0c7ca63 100644 --- a/dungeon.c +++ b/dungeon.c @@ -3,7 +3,7 @@ * defining (mostly) invariant state. A couple of slots are messed with * at runtime. */ -#include "sizes.h" +#include "common.h" #define LINESIZE 100 #define RTXSIZ 277 @@ -24,10 +24,6 @@ /* hard limit, will be propagated to database.h */ #define NOBJECTS 100 -const char advent_to_ascii[] = {0, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 38, 47, 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 0}; -/* Rendered from the now-gone MPINIT() function */ -const char ascii_to_advent[] = {0, 74, 75, 76, 77, 78, 79, 80, 81, 82, 0, 0, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 0, 1, 2, 106, 107, 63, 108, 3, 4, 5, 6, 7, 8, 9, 10, 109, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 110, 111, 112, 113, 114, 115, 116, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 117, 118, 119, 120, 121, 122, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 123, 124, 125, 126, 83}; - // Global variables for use in functions below that can gradually disappear as code is cleaned up static long LNLENG; static long LNPOSN; @@ -565,7 +561,7 @@ void write_files(FILE* c_file, FILE* header_file) } // preprocessor defines for the header - fprintf(header_file, "#include \"sizes.h\"\n"); + fprintf(header_file, "#include \"common.h\"\n"); fprintf(header_file, "#define RTXSIZ 277\n"); fprintf(header_file, "#define CLSMAX 12\n"); fprintf(header_file, "#define LINSIZ %d\n", LINSIZ); diff --git a/misc.c b/misc.c index 95b90ca..6fe53ce 100644 --- a/misc.c +++ b/misc.c @@ -10,10 +10,6 @@ #define PERCENT 63 /* partly hide the packed encoding */ -const char advent_to_ascii[] = {0, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 38, 47, 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 0}; -/* Rendered from the now-gone MPINIT() function */ -const char ascii_to_advent[] = {0, 74, 75, 76, 77, 78, 79, 80, 81, 82, 0, 0, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 0, 1, 2, 106, 107, 63, 108, 3, 4, 5, 6, 7, 8, 9, 10, 109, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 110, 111, 112, 113, 114, 115, 116, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 117, 118, 119, 120, 121, 122, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 123, 124, 125, 126, 83}; - /* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */ void SPEAK(vocab_t msg) diff --git a/sizes.h b/sizes.h deleted file mode 100644 index 66fb404..0000000 --- a/sizes.h +++ /dev/null @@ -1,5 +0,0 @@ -/* maximum size limits shared by dungeon compiler and runtime */ - -#define LOCSIZ 185 -#define NOBJECTS 100 -#define HNTSIZ 20