X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=f211eac6e2651386312e3ae2ab1eeaae8cec4cad;hb=91ad0185ffcbda83f115433c630b40e4ea6f7a41;hp=5c71c744d7067f4806e5664e2878324c8ce82ff0;hpb=07c0020a7aaa0ab34ee0e4f6e3a9ae0e1fe06c25;p=open-adventure.git diff --git a/misc.c b/misc.c index 5c71c74..f211eac 100644 --- a/misc.c +++ b/misc.c @@ -16,10 +16,10 @@ void SPEAK(vocab_t N) { long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE; /* Print the message which starts at LINES(N). Precede it with a blank line - * unless BLKLIN is false. */ + * unless game.blklin is false. */ if(N == 0)return; - BLANK=BLKLIN; + BLANK=game.blklin; K=N; NPARMS=1; L10: L=labs(LINES[K])-1; @@ -168,12 +168,12 @@ long JUNK; * WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */ -L10: if(BLKLIN)TYPE0(); +L10: if(game.blklin)TYPE0(); MAPLIN(input); if (feof(input)) return false; WORD1=GETTXT(true,true,true); - if(BLKLIN && WORD1 < 0) goto L10; + if(game.blklin && WORD1 < 0) goto L10; WORD1X=GETTXT(false,true,true); L12: JUNK=GETTXT(false,true,true); if(JUNK > 0) goto L12; @@ -245,7 +245,7 @@ long GETTXT(bool SKIP,bool ONEWRD, bool 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; @@ -275,12 +275,13 @@ long GETTXT(bool SKIP,bool ONEWRD, bool UPPER) { token_t MAKEWD(long LETTRS) { long I, L, WORD; -/* Combine five uppercase letters (represented by pairs of decimal digits - * in lettrs) to form a 30-bit value matching the one that GETTXT would - * return given those characters plus trailing blanks. Caution: - * lettrs will overflow 31 bits if 5-letter word starts with V-Z. As a - * kludgey workaround, you can increment a letter by 5 by adding 50 to - * the next pair of digits. */ +/* Combine TOKLEN (currently 5) uppercase letters (represented by + * pairs of decimal digits in lettrs) to form a 30-bit value matching + * the one that GETTXT would return given those characters plus + * trailing blanks. Caution: lettrs will overflow 31 bits if + * 5-letter word starts with V-Z. As a kludgey workaround, you can + * increment a letter by 5 by adding 50 to the next pair of + * digits. */ WORD=0; I=1; @@ -299,15 +300,17 @@ long I, L, WORD; void fPUTTXT(token_t WORD, long *sTATE, long CASE) { long ALPH1, ALPH2, BYTE, DIV, I, W; -/* Unpack the 30-bit value in word to obtain up to 5 integer-encoded chars, - * and store them in inline starting at LNPOSN. If LNLENG>=LNPOSN, shift - * existing characters to the right to make room. STATE will be zero when - * puttxt is called with the first of a sequence of words, but is thereafter - * unchanged by the caller, so PUTTXT can use it to maintain state across - * calls. LNPOSN and LNLENG are incremented by the number of chars stored. - * If CASE=1, all letters are made uppercase; if -1, lowercase; if 0, as is. - * any other value for case is the same as 0 but also causes trailing blanks - * to be included (in anticipation of subsequent additional text). */ +/* Unpack the 30-bit value in word to obtain up to TOKLEN (currently + * 5) integer-encoded chars, and store them in inline starting at + * LNPOSN. If LNLENG>=LNPOSN, shift existing characters to the right + * to make room. STATE will be zero when puttxt is called with the + * first of a sequence of words, but is thereafter unchanged by the + * caller, so PUTTXT can use it to maintain state across calls. + * LNPOSN and LNLENG are incremented by the number of chars stored. + * If CASE=1, all letters are made uppercase; if -1, lowercase; if 0, + * as is. any other value for case is the same as 0 but also causes + * trailing blanks to be included (in anticipation of subsequent + * additional text). */ ALPH1=13*CASE+24; @@ -316,7 +319,7 @@ long ALPH1, ALPH2, BYTE, DIV, I, W; /* ALPH1&2 DEFINE RANGE OF WRONG-CASE CHARS, 11-36 OR 37-62 OR EMPTY. */ DIV=64L*64L*64L*64L; W=WORD; - /* 18 */ for (I=1; I<=5; I++) { + /* 18 */ for (I=1; I<=TOKLEN; I++) { if(W <= 0 && STATE == 0 && labs(CASE) <= 1)return; BYTE=W/DIV; if(STATE != 0 || BYTE != 63) goto L12; @@ -546,12 +549,12 @@ long TEMP; /* Start toting an object, removing it from the list of things at its former * location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS - * (moving "fixed" second loc), don't change PLACE or HOLDNG. */ + * (moving "fixed" second loc), don't change PLACE or game.holdng. */ if(OBJECT > NOBJECTS) goto L5; if(PLACE[OBJECT] == -1)return; PLACE[OBJECT]= -1; - HOLDNG=HOLDNG+1; + game.holdng=game.holdng+1; L5: if(ATLOC[WHERE] != OBJECT) goto L6; ATLOC[WHERE]=LINK[OBJECT]; return; @@ -565,10 +568,10 @@ L8: LINK[TEMP]=LINK[OBJECT]; void DROP(long OBJECT, long WHERE) { /* Place an object at a given loc, prefixing it onto the ATLOC list. Decr - * HOLDNG if the object was being toted. */ + * game.holdng if the object was being toted. */ if(OBJECT > NOBJECTS) goto L1; - if(PLACE[OBJECT] == -1)HOLDNG=HOLDNG-1; + if(PLACE[OBJECT] == -1)game.holdng=game.holdng-1; PLACE[OBJECT]=WHERE; goto L2; L1: {long x = OBJECT-NOBJECTS; FIXED[x]=WHERE;} @@ -589,7 +592,7 @@ long AT, I; AT=0; - if(DFLAG < 2)return(AT); + if(game.dflag < 2)return(AT); AT= -1; for (I=1; I<=NDWARVES-1; I++) { if(game.dloc[I] == WHERE) goto L2;