From: Eric S. Raymond Date: Thu, 16 Feb 2017 18:14:57 +0000 (-0500) Subject: Minimal forward-port to modern C - just enough to get it to compile. X-Git-Tag: seed~113 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=50ab7b9d47ffefaf3d526c50b34fda9280823937;p=open-adventure.git Minimal forward-port to modern C - just enough to get it to compile. --- diff --git a/Makefile b/Makefile index 1b88b81..499ff70 100644 --- a/Makefile +++ b/Makefile @@ -21,3 +21,6 @@ actions2.o: misc.h main.h share.h funcs.h score.o: misc.h main.h share.h misc.o: misc.h main.h + +clean: + rm -f *.o adventure diff --git a/actions1.c b/actions1.c index 57e8cb1..464faff 100644 --- a/actions1.c +++ b/actions1.c @@ -17,7 +17,7 @@ extern carry(), discard(long), attack(), throw(), feed(), fill(); /* ANALYSE A VERB. REMEMBER WHAT IT WAS, GO BACK FOR OBJECT IF SECOND WORD * UNLESS VERB IS "SAY", WHICH SNARFS ARBITRARY SECOND WORD. */ -action(STARTAT)long STARTAT; { +int action(STARTAT)long STARTAT; { switch(STARTAT) { case 4000: goto L4000; case 4090: goto L4090; diff --git a/init.c b/init.c index 6b2edea..2ded06d 100644 --- a/init.c +++ b/init.c @@ -3,6 +3,7 @@ #include "share.h" #include "funcs.h" #include +#include #define TRUE (0==0) #define FALSE (0!=0) @@ -164,13 +165,20 @@ * %B = VARIABLE NUMBER OF BLANKS * %! = THE ENTIRE MESSAGE SHOULD BE SUPPRESSED */ -initialise() { +static bool quick_init(void); +static int raw_init(void); +static void report(void); +static void quick_save(void); +static int finish_init(void); +static void quick_io(void); + +void initialise() { printf("Initialising...\n"); if(!quick_init()){raw_init(); report(); quick_save();} finish_init(); } -static raw_init() { +static int raw_init(void) { printf("Couldn't find adventure.data, using adventure.text...\n"); /* CLEAR OUT THE VARIOUS TEXT-POINTER ARRAYS. ALL TEXT IS STORED IN ARRAY @@ -366,7 +374,7 @@ L1092: LOCSND[K]=KK; * CORRECT LINK TO USE.) ABB IS ZEROED; IT CONTROLS WHETHER THE ABBREVIATED * DESCRIPTION IS PRINTED. COUNTS MOD 5 UNLESS "LOOK" IS USED. */ -static finish_init() { +static int finish_init(void) { /* 1101 */ for (I=1; I<=100; I++) { PLACE[I]=0; PROP[I]=0; @@ -590,7 +598,7 @@ L1800: {long x = 2*I+81; if(RTEXT[x] != 0)MAXDIE=I+1;} /* REPORT ON AMOUNT OF ARRAYS ACTUALLY USED, TO PERMIT REDUCTIONS. */ -static report() { +static void report(void) { /* 1998 */ for (K=1; K<=LOCSIZ; K++) { KK=LOCSIZ+1-K; if(LTEXT[KK] != 0) goto L1997; @@ -632,7 +640,7 @@ static FILE *f; static void quick_item(long*); static void quick_array(long*, long); -static quick_init() { +static bool quick_init(void) { #ifdef AMIGA f = fopen("ram:adventure.data", READ_MODE); #else @@ -652,19 +660,18 @@ static quick_init() { return(init_cksum == 0); } -static quick_save() { +static void quick_save(void) { printf("Writing adventure.data...\n"); f = fopen("adventure.data",WRITE_MODE); - if(f == NULL){printf("Can't open file!\n"); return(0);} + if(f == NULL){printf("Can't open file!\n"); return;} init_reading = FALSE; init_cksum = 1; quick_io(); fwrite(&init_cksum,4,1,f); fclose(f); - return(0); } -static quick_io() { +static void quick_io(void) { quick_item(&LINUSE); quick_item(&TRVS); quick_item(&CLSSES); @@ -692,7 +699,6 @@ static quick_io() { quick_array(FIXD,100); quick_array(ACTSPK,VRBSIZ); quick_array((long *)HINTS,(HNTMAX+1)*5-1); - return(0); } static void quick_item(W)long *W; { diff --git a/main.c b/main.c index 6977bc5..0f11fd4 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,6 @@ +#include +#include + #include "misc.h" #ifdef __MSDOS__ #include "alloc.h" @@ -35,15 +38,15 @@ long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BO VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X, WZDARK = FALSE, ZZWORD; -extern initialise(); +extern void initialise(); extern void score(long); -extern action(long); +extern int action(long); /* * MAIN PROGRAM */ -main() { +int main() { /* ADVENTURE (REV 2: 20 TREASURES) */