7 /* hack to ignore GCC Unused Result */
8 #define IGNORE(r) do{if(r){}}while(0)
10 /* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
14 long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE;
16 /* Print the message which starts at LINES(N). Precede it with a blank line
17 * unless BLKLIN is false. */
24 L10: L=IABS(LINES[K])-1;
29 for (I=K; I<=L; I++) {
30 PUTTXT(LINES[I],STATE,2,I);
34 L32: if(LNPOSN > LNLENG) goto L40;
35 if(INLINE[LNPOSN] != 63) goto L30;
36 {long x = LNPOSN+1; PRMTYP=INLINE[x];}
37 /* 63 is a "%"; the next character determine the type of parameter: 1 (!) =
38 * suppress message completely, 29 (S) = NULL If PARM=1, else 'S' (optional
39 * plural ending), 33 (W) = word (two 30-bit values) with trailing spaces
40 * suppressed, 22 (L) or 31 (U) = word but map to lower/upper case, 13 (C) =
41 * word in lower case with first letter capitalised, 30 (T) = text ending
42 * with a word of -1, 65-73 (1-9) = number using that many characters,
43 * 12 (B) = variable number of blanks. */
44 if(PRMTYP == 1)return;
45 if(PRMTYP == 29) goto L320;
46 if(PRMTYP == 30) goto L340;
47 if(PRMTYP == 12) goto L360;
48 if(PRMTYP == 33 || PRMTYP == 22 || PRMTYP == 31 || PRMTYP == 13) goto
51 if(PRMTYP < 1 || PRMTYP > 9) goto L30;
52 SHFTXT(LNPOSN+2,PRMTYP-2);
54 PARM=IABS(PARMS[NPARMS]);
56 if(PARMS[NPARMS] < 0)NEG=9;
57 /* 390 */ for (I=1; I<=PRMTYP; I++) {
59 INLINE[LNPOSN]=MOD(PARM,10)+64;
60 if(I == 1 || PARM != 0) goto L390;
66 L395: NPARMS=NPARMS+1;
69 L320: SHFTXT(LNPOSN+2,-1);
71 if(PARMS[NPARMS] == 1)SHFTXT(LNPOSN+1,-1);
74 L340: SHFTXT(LNPOSN+2,-2);
77 L345: if(PARMS[NPARMS] < 0) goto L395;
78 {long x = NPARMS+1; if(PARMS[x] < 0)CASE=0;}
79 PUTTXT(PARMS[NPARMS],STATE,CASE,0);
83 L360: PRMTYP=PARMS[NPARMS];
84 SHFTXT(LNPOSN+2,PRMTYP-2);
85 if(PRMTYP == 0) goto L395;
86 for (I=1; I<=PRMTYP; I++) {
92 L380: SHFTXT(LNPOSN+2,-2);
95 if(PRMTYP == 31)CASE=1;
96 if(PRMTYP == 33)CASE=0;
98 PUTTXT(PARMS[NPARMS],STATE,CASE,0);
99 {long x = NPARMS+1; PUTTXT(PARMS[x],STATE,CASE,0);}
100 if(PRMTYP == 13 && INLINE[I] >= 37 && INLINE[I] <=
101 62)INLINE[I]=INLINE[I]-26;
105 L40: if(BLANK)TYPE0();
109 if(LINES[K] >= 0) goto L10;
115 #define SPEAK(N) fSPEAK(N)
117 void fPSPEAK(long MSG,long SKIP) {
120 /* Find the skip+1st message from msg and print it. MSG should be the index of
121 * the inventory message for object. (INVEN+N+1 message is PROP=N message). */
125 if(SKIP < 0) goto L9;
126 for (I=0; I<=SKIP; I++) {
127 L1: M=IABS(LINES[M]);
128 if(LINES[M] >= 0) goto L1;
137 #define PSPEAK(MSG,SKIP) fPSPEAK(MSG,SKIP)
139 void fRSPEAK(long I) {
142 /* Print the I-TH "random" message (section 6 of database). */
145 if(I != 0)SPEAK(RTEXT[I]);
151 #define RSPEAK(I) fRSPEAK(I)
153 void fSETPRM(long FIRST, long P1, long P2) {
156 /* Stores parameters into the PRMCOM parms array for use by speak. P1 and P2
157 * are stored into PARMS(FIRST) and PARMS(FIRST+1). */
160 if(FIRST >= 25)BUG(29);
162 {long x = FIRST+1; PARMS[x]=P2;}
168 #define SETPRM(FIRST,P1,P2) fSETPRM(FIRST,P1,P2)
170 #define WORD1 (*wORD1)
171 #define WORD1X (*wORD1X)
172 #define WORD2 (*wORD2)
173 #define WORD2X (*wORD2X)
174 void fGETIN(long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) {
177 /* Get a command from the adventurer. snarf out the first word, pad it with
178 * blanks, and return it in WORD1. Chars 6 thru 10 are returned in WORD1X, in
179 * case we need to print out the whole word in an error message. Any number of
180 * blanks may follow the word. If a second word appears, it is returned in
181 * WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */
184 L10: if(BLKLIN)TYPE0();
186 if(feof(stdin)) score(1);
187 WORD1=GETTXT(true,true,true,0);
188 if(BLKLIN && WORD1 < 0) goto L10;
189 WORD1X=GETTXT(false,true,true,0);
190 L12: JUNK=GETTXT(false,true,true,0);
191 if(JUNK > 0) goto L12;
192 WORD2=GETTXT(true,true,true,0);
193 WORD2X=GETTXT(false,true,true,0);
194 L22: JUNK=GETTXT(false,true,true,0);
195 if(JUNK > 0) goto L22;
196 if(GETTXT(true,true,true,0) <= 0)return;
207 #define GETIN(WORD1,WORD1X,WORD2,WORD2X) fGETIN(&WORD1,&WORD1X,&WORD2,&WORD2X)
209 long fYES(long X, long Y, long Z) {
211 long YES, REPLY, JUNK1, JUNK2, JUNK3;
213 /* Print message X, wait for yes/no answer. If yes, print Y and return true;
214 * if no, print Z and return false. */
217 GETIN(REPLY,JUNK1,JUNK2,JUNK3);
218 if(REPLY == MAKEWD(250519) || REPLY == MAKEWD(25)) goto L10;
219 if(REPLY == MAKEWD(1415) || REPLY == MAKEWD(14)) goto L20;
234 /* Line-parsing routines (GETNUM, GETTXT, MAKEWD, PUTTXT, SHFTXT, TYPE0)
237 /* The routines on this page handle all the stuff that would normally be
238 * taken care of by format statements. We do it this way instead so that
239 * we can handle textual data in a machine independent fashion. All the
240 * machine dependent i/o stuff is on the following page. See that page
241 * for a description of MAPCOM's inline array. */
243 #define YES(X,Y,Z) fYES(X,Y,Z)
245 long fGETNUM(FILE *source) {
246 long DIGIT, GETNUM, SIGN;
248 /* Obtain the next integer from an input line. If K>0, we first read a
249 * new input line from a file; if K<0, we read a line from the keyboard;
250 * if K=0 we use a line that has already been read (and perhaps partially
251 * scanned). If we're at the end of the line or encounter an illegal
252 * character (not a digit, hyphen, or blank), we return 0. */
255 if(source != NULL)MAPLIN(source);
257 L10: if(LNPOSN > LNLENG)return(GETNUM);
258 if(INLINE[LNPOSN] != 0) goto L20;
263 if(INLINE[LNPOSN] != 9) goto L32;
265 L30: LNPOSN=LNPOSN+1;
266 L32: if(LNPOSN > LNLENG || INLINE[LNPOSN] == 0) goto L42;
267 DIGIT=INLINE[LNPOSN]-64;
268 if(DIGIT < 0 || DIGIT > 9) goto L40;
269 GETNUM=GETNUM*10+DIGIT;
273 L42: GETNUM=GETNUM*SIGN;
280 #define GETNUM(K) fGETNUM(K)
282 long fGETTXT(long SKIP,long ONEWRD, long UPPER, long HASH) {
283 long CHAR, GETTXT, I; static long SPLITTING = -1;
285 /* Take characters from an input line and pack them into 30-bit words.
286 * Skip says to skip leading blanks. ONEWRD says stop if we come to a
287 * blank. UPPER says to map all letters to uppercase. HASH may be used
288 * as a parameter for encrypting the text if desired; however, a hash of 0
289 * should result in unmodified bytes being packed. If we reach the
290 * end of the line, the word is filled up with blanks (which encode as 0's).
291 * If we're already at end of line when GETTXT is called, we return -1. */
293 if(LNPOSN != SPLITTING)SPLITTING = -1;
295 L10: if(LNPOSN > LNLENG)return(GETTXT);
296 if((!SKIP) || INLINE[LNPOSN] != 0) goto L11;
301 /* 15 */ for (I=1; I<=5; I++) {
303 if(LNPOSN > LNLENG || (ONEWRD && INLINE[LNPOSN] == 0)) goto L15;
305 if(CHAR >= 63) goto L12;
307 if(UPPER && CHAR >= 37)CHAR=CHAR-26;
311 L12: if(SPLITTING == LNPOSN) goto L13;
316 L13: GETTXT=GETTXT+CHAR-63;
318 L14: LNPOSN=LNPOSN+1;
322 if(HASH)GETTXT=GETTXT+MOD(HASH*13579L+5432L,97531L)*12345L+HASH;
328 #define GETTXT(SKIP,ONEWRD,UPPER,HASH) fGETTXT(SKIP,ONEWRD,UPPER,HASH)
330 long fMAKEWD(long LETTRS) {
333 /* Combine five uppercase letters (represented by pairs of decimal digits
334 * in lettrs) to form a 30-bit value matching the one that GETTXT would
335 * return given those characters plus trailing blanks and HASH=0. Caution:
336 * lettrs will overflow 31 bits if 5-letter word starts with V-Z. As a
337 * kludgey workaround, you can increment a letter by 5 by adding 50 to
338 * the next pair of digits. */
344 L10: MAKEWD=MAKEWD+I*(MOD(L,50)+10);
346 if(MOD(L,100) > 50)MAKEWD=MAKEWD+I*5;
349 I=64L*64L*64L*64L*64L/I;
356 #define MAKEWD(LETTRS) fMAKEWD(LETTRS)
358 #define STATE (*sTATE)
359 void fPUTTXT(long WORD, long *sTATE, long CASE, long HASH) {
360 long ALPH1, ALPH2, BYTE, DIV, I, W;
362 /* Unpack the 30-bit value in word to obtain up to 5 integer-encoded chars,
363 * and store them in inline starting at LNPOSN. If LNLENG>=LNPOSN, shift
364 * existing characters to the right to make room. HASH must be the same
365 * as it was when gettxt created the 30-bit word. STATE will be zero when
366 * puttxt is called with the first of a sequence of words, but is thereafter
367 * unchanged by the caller, so PUTTXT can use it to maintain state across
368 * calls. LNPOSN and LNLENG are incremented by the number of chars stored.
369 * If CASE=1, all letters are made uppercase; if -1, lowercase; if 0, as is.
370 * any other value for case is the same as 0 but also causes trailing blanks
371 * to be included (in anticipation of subsequent additional text). */
375 ALPH2=26*IABS(CASE)+ALPH1;
376 if(IABS(CASE) > 1)ALPH1=ALPH2;
377 /* ALPH1&2 DEFINE RANGE OF WRONG-CASE CHARS, 11-36 OR 37-62 OR EMPTY. */
380 if(HASH)W=W-MOD(HASH*13579L+5432L,97531L)*12345L-HASH;
381 /* 18 */ for (I=1; I<=5; I++) {
382 if(W <= 0 && STATE == 0 && IABS(CASE) <= 1)return;
384 if(STATE != 0 || BYTE != 63) goto L12;
388 L12: SHFTXT(LNPOSN,1);
390 if(STATE < ALPH2 && STATE >= ALPH1)STATE=STATE-26*CASE;
391 INLINE[LNPOSN]=STATE;
394 L18: W=(W-BYTE*DIV)*64;
402 #define PUTTXT(WORD,STATE,CASE,HASH) fPUTTXT(WORD,&STATE,CASE,HASH)
404 void fSHFTXT(long FROM, long DELTA) {
407 /* Move INLINE(N) to INLINE(N+DELTA) for N=FROM,LNLENG. Delta can be
408 * negative. LNLENG is updated; LNPOSN is not changed. */
411 if(LNLENG < FROM || DELTA == 0) goto L2;
412 for (I=FROM; I<=LNLENG; I++) {
414 if(DELTA > 0)II=FROM+LNLENG-I;
416 INLINE[JJ]=INLINE[II];
418 L2: LNLENG=LNLENG+DELTA;
424 #define SHFTXT(FROM,DELTA) fSHFTXT(FROM,DELTA)
429 /* Type a blank line. This procedure is provided as a convenience for callers
430 * who otherwise have no use for MAPCOM. */
442 #define TYPE0() fTYPE0()
445 /* Suspend/resume I/O routines (SAVWDS, SAVARR, SAVWRD) */
448 void fSAVWDS(long *W1, long *W2, long *W3, long *W4, long *W5, long *W6, long *W7) {
450 /* Write or read 7 variables. See SAVWRD. */
464 #define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7)
466 void fSAVARR(long ARR[], long N) {
469 /* Write or read an array of N words. See SAVWRD. */
472 for (I=1; I<=N; I++) {
480 #define SAVARR(ARR,N) fSAVARR(ARR,N)
483 void fSAVWRD(long OP, long *wORD) {
484 static long BUF[250], CKSUM = 0, H1, HASH = 0, N = 0, STATE = 0;
486 /* If OP<0, start writing a file, using word to initialise encryption; save
487 * word in the file. If OP>0, start reading a file; read the file to find
488 * the value with which to decrypt the rest. In either case, if a file is
489 * already open, finish writing/reading it and don't start a new one. If OP=0,
490 * read/write a single word. Words are buffered in case that makes for more
491 * efficient disk use. We also compute a simple checksum to catch elementary
492 * poking within the saved file. When we finish reading/writing the file,
493 * we store zero into WORD if there's no checksum error, else nonzero. */
496 if(OP != 0){long ifvar; ifvar=(STATE); switch (ifvar<0? -1 : ifvar>0? 1 :
497 0) { case -1: goto L30; case 0: goto L10; case 1: goto L30; }}
498 if(STATE == 0)return;
499 if(N == 250)SAVEIO(1,STATE > 0,BUF);
501 H1=MOD(HASH*1093L+221573L,1048576L);
502 HASH=MOD(H1*1093L+221573L,1048576L);
503 H1=MOD(H1,1234)*765432+MOD(HASH,123);
505 if(STATE > 0)WORD=BUF[N]+H1;
508 CKSUM=MOD(CKSUM*13+WORD,1000000000L);
512 SAVEIO(0,STATE > 0,BUF);
514 if(STATE > 0) goto L15;
515 HASH=MOD(WORD,1048576L);
516 BUF[0]=1234L*5678L-HASH;
520 L15: SAVEIO(1,true,BUF);
521 HASH=MOD(1234L*5678L-BUF[0],1048576L);
524 L30: if(N == 250)SAVEIO(1,STATE > 0,BUF);
526 if(STATE > 0) goto L32;
527 N--; BUF[N]=CKSUM; N++;
529 L32: N--; WORD=BUF[N]-CKSUM; N++;
530 SAVEIO(-1,STATE > 0,BUF);
539 /* Data struc. routines (VOCAB, DSTROY, JUGGLE, MOVE, PUT, CARRY, DROP, ATDWRF)
543 #define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD)
545 long fVOCAB(long ID, long INIT) {
548 /* Look up ID in the vocabulary (ATAB) and return its "definition" (KTAB), or
549 * -1 if not found. If INIT is positive, this is an initialisation call setting
550 * up a keyword variable, and not finding it constitutes a bug. It also means
551 * that only KTAB values which taken over 1000 equal INIT may be considered.
552 * (Thus "STEPS", which is a motion verb as well as an object, may be located
553 * as an object.) And it also means the KTAB value is taken modulo 1000. */
556 /* 1 */ for (I=1; I<=TABSIZ; I++) {
557 if(KTAB[I] == -1) goto L2;
559 if(INIT >= 0 && KTAB[I]/1000 != INIT) goto L1;
560 if(ATAB[I] == ID+HASH*HASH) goto L3;
566 if(INIT < 0)return(VOCAB);
570 if(INIT >= 0)VOCAB=MOD(VOCAB,1000);
576 #define VOCAB(ID,INIT) fVOCAB(ID,INIT)
578 void fDSTROY(long OBJECT) {
581 /* Permanently eliminate "OBJECT" by moving to a non-existent location. */
590 #define DSTROY(OBJECT) fDSTROY(OBJECT)
592 void fJUGGLE(long OBJECT) {
595 /* Juggle an object by picking it up and putting it down again, the purpose
596 * being to get the object to the front of the chain of things at its loc. */
608 #define JUGGLE(OBJECT) fJUGGLE(OBJECT)
610 void fMOVE(long OBJECT, long WHERE) {
613 /* Place any object anywhere by picking it up and dropping it. May already be
614 * toting, in which case the carry is a no-op. Mustn't pick up objects which
615 * are not at any loc, since carry wants to remove objects from ATLOC chains. */
618 if(OBJECT > 100) goto L1;
621 L1: {long x = OBJECT-100; FROM=FIXED[x];}
622 L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM);
629 #define MOVE(OBJECT,WHERE) fMOVE(OBJECT,WHERE)
631 long fPUT(long OBJECT, long WHERE, long PVAL) {
634 /* PUT is the same as MOVE, except it returns a value used to set up the
635 * negated PROP values for the repository objects. */
645 #define PUT(OBJECT,WHERE,PVAL) fPUT(OBJECT,WHERE,PVAL)
647 void fCARRY(long OBJECT, long WHERE) {
650 /* Start toting an object, removing it from the list of things at its former
651 * location. Incr holdng unless it was already being toted. If OBJECT>100
652 * (moving "fixed" second loc), don't change PLACE or HOLDNG. */
655 if(OBJECT > 100) goto L5;
656 if(PLACE[OBJECT] == -1)return;
659 L5: if(ATLOC[WHERE] != OBJECT) goto L6;
660 ATLOC[WHERE]=LINK[OBJECT];
662 L6: TEMP=ATLOC[WHERE];
663 L7: if(LINK[TEMP] == OBJECT) goto L8;
666 L8: LINK[TEMP]=LINK[OBJECT];
672 #define CARRY(OBJECT,WHERE) fCARRY(OBJECT,WHERE)
674 void fDROP(long OBJECT, long WHERE) {
677 /* Place an object at a given loc, prefixing it onto the ATLOC list. Decr
678 * HOLDNG if the object was being toted. */
681 if(OBJECT > 100) goto L1;
682 if(PLACE[OBJECT] == -1)HOLDNG=HOLDNG-1;
685 L1: {long x = OBJECT-100; FIXED[x]=WHERE;}
686 L2: if(WHERE <= 0)return;
687 LINK[OBJECT]=ATLOC[WHERE];
694 #define DROP(OBJECT,WHERE) fDROP(OBJECT,WHERE)
696 long fATDWRF(long WHERE) {
699 /* Return the index of first dwarf at the given location, zero if no dwarf is
700 * there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore
701 * the pirate (6th dwarf). */
705 if(DFLAG < 2)return(ATDWRF);
707 for (I=1; I<=5; I++) {
708 if(DLOC[I] == WHERE) goto L2;
709 if(DLOC[I] != 0)ATDWRF=0;
720 #define ATDWRF(WHERE) fATDWRF(WHERE)
724 /* Utility routines (SETBIT, TSTBIT, RAN, RNDVOC, BUG) */
727 long fSETBIT(long BIT) {
730 /* Returns 2**bit for use in constructing bit-masks. */
734 if(BIT <= 0)return(SETBIT);
735 for (I=1; I<=BIT; I++) {
736 SETBIT=SETBIT+SETBIT;
743 #define SETBIT(BIT) fSETBIT(BIT)
745 long fTSTBIT(long MASK, long BIT) {
748 /* Returns true if the specified bit is set in the mask. */
751 TSTBIT=MOD(MASK/SETBIT(BIT),2) != 0;
757 #define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT)
759 long fRAN(long RANGE) {
760 static long D, R = 0, RAN, T;
762 /* Since the ran function in LIB40 seems to be a real lose, we'll use one of
763 * our own. It's been run through many of the tests in Knuth vol. 2 and
764 * seems to be quite reliable. RAN returns a value uniformly selected
765 * between 0 and range-1. */
769 if(R != 0 && RANGE >= 0) goto L1;
773 L1: for (T=1; T<=D; T++) {
774 R=MOD(R*1093L+221587L,1048576L);
776 RAN=(RANGE*R)/1048576;
782 #define RAN(RANGE) fRAN(RANGE)
784 long fRNDVOC(long CHAR, long FORCE) {
785 long DIV, I, J, RNDVOC;
787 /* Searches the vocabulary for a word whose second character is char, and
788 * changes that word such that each of the other four characters is a
789 * random letter. If force is non-zero, it is used as the new word.
790 * Returns the new word. */
794 if(RNDVOC != 0) goto L3;
795 for (I=1; I<=5; I++) {
802 for (I=1; I<=TABSIZ; I++) {
804 if(MOD((ATAB[I]-J*J)/DIV,64L) == CHAR) goto L8;
809 L8: ATAB[I]=RNDVOC+J*J;
815 #define RNDVOC(CHAR,FORCE) fRNDVOC(CHAR,FORCE)
817 void fBUG(long NUM) {
819 /* The following conditions are currently considered fatal bugs. Numbers < 20
820 * are detected while reading the database; the others occur at "run time".
821 * 0 Message line > 70 characters
822 * 1 Null line in message
823 * 2 Too many words of messages
824 * 3 Too many travel options
825 * 4 Too many vocabulary words
826 * 5 Required vocabulary word not found
827 * 6 Too many RTEXT messages
829 * 8 Location has cond bit being set twice
830 * 9 Invalid section number in database
831 * 10 Too many locations
832 * 11 Too many class or turn messages
833 * 20 Special travel (500>L>300) exceeds goto list
834 * 21 Ran off end of vocabulary table
835 * 22 Vocabulary type (N/1000) not between 0 and 3
836 * 23 Intransitive action verb exceeds goto list
837 * 24 Transitive action verb exceeds goto list
838 * 25 Conditional travel entry with no alternative
839 * 26 Location has no travel entries
840 * 27 Hint number exceeds goto list
841 * 28 Invalid month returned by date function
842 * 29 Too many parameters given to SETPRM */
844 printf("Fatal error %ld. See source code for interpretation.\n",
853 /* Machine dependent routines (MAPLIN, TYPE, MPINIT, SAVEIO) */
855 #define BUG(NUM) fBUG(NUM)
857 void fMAPLIN(FILE *OPENED) {
860 /* Read a line of input, from the specified input source,
861 * translate the chars to integers in the range 0-126 and store
862 * them in the common array "INLINE". Integer values are as follows:
863 * 0 = space [ASCII CODE 40 octal, 32 decimal]
864 * 1-2 = !" [ASCII 41-42 octal, 33-34 decimal]
865 * 3-10 = '()*+,-. [ASCII 47-56 octal, 39-46 decimal]
866 * 11-36 = upper-case letters
867 * 37-62 = lower-case letters
868 * 63 = percent (%) [ASCII 45 octal, 37 decimal]
869 * 64-73 = digits, 0 through 9
870 * Remaining characters can be translated any way that is convenient;
871 * The "TYPE" routine below is used to map them back to characters when
872 * necessary. The above mappings are required so that certain special
873 * characters are known to fit in 6 bits and/or can be easily spotted.
874 * Array elements beyond the end of the line should be filled with 0,
875 * and LNLENG should be set to the index of the last character.
877 * If the data file uses a character other than space (e.g., tab) to
878 * separate numbers, that character should also translate to 0.
880 * This procedure may use the map1,map2 arrays to maintain static data for
881 * the mapping. MAP2(1) is set to 0 when the program starts
882 * and is not changed thereafter unless the routines on this page choose
885 if(MAP2[1] == 0)MPINIT();
887 IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED));
893 IGNORE(fputs(INLINE+1, logfp));
895 for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) {
898 if(INLINE[I] != 0)LNLENG=I;
903 #define MAPLIN(FIL) fMAPLIN(FIL)
909 /* Type the first "LNLENG" characters stored in inline, mapping them
910 * from integers to text per the rules described above. INLINE(I),
911 * I=1,LNLENG may be changed by this routine. */
914 if(LNLENG != 0) goto L10;
918 L10: if(MAP2[1] == 0)MPINIT();
919 for (I=1; I<=LNLENG; I++) {
921 {long x = VAL+1; INLINE[I]=MAP2[x];}
923 {long x = LNLENG+1; INLINE[x]=0;}
924 printf("%s\n",INLINE+1);
930 #define TYPE() fTYPE()
933 long FIRST, I, J, LAST, VAL;
934 static long RUNS[7][2] = {32,34, 39,46, 65,90, 97,122, 37,37, 48,57, 0,126};
937 for (I=1; I<=128; I++) {
941 for (I=0; I<7; I++) {
944 /* 22 */ for (J=FIRST; J<=LAST; J++) {
945 J++; if(MAP1[J] >= 0) goto L22;
953 /* For this version, tab (9) maps to space (32), so del (127) uses tab's value */
957 for (I=0; I<=126; I++) {
958 I++; VAL=MAP1[I]+1; I--;
959 MAP2[VAL]=I*('B'-'A');
960 if(I >= 64)MAP2[VAL]=(I-64)*('B'-'A')+'@';
968 #define MPINIT() fMPINIT()
970 void fSAVEIO(long OP, long IN, long ARR[]) {
971 static FILE *F; char NAME[50];
973 /* If OP=0, ask for a file name and open a file. (If IN=true, the file is for
974 * input, else output.) If OP>0, read/write ARR from/into the previously-opened
975 * file. (ARR is a 250-integer array.) If OP<0, finish reading/writing the
976 * file. (Finishing writing can be a no-op if a "stop" statement does it
977 * automatically. Finishing reading can be a no-op as long as a subsequent
978 * SAVEIO(0,false,X) will still work.) If you can catch errors (e.g., no such
979 * file) and try again, great. DEC F40 can't. */
982 {long ifvar; ifvar=(OP); switch (ifvar<0? -1 : ifvar>0? 1 : 0) { case -1:
983 goto L10; case 0: goto L20; case 1: goto L30; }}
988 L20: printf("\nFile name: ");
989 IGNORE(fgets(NAME, sizeof(NAME), stdin));
990 F=fopen(NAME,(IN ? READ_MODE : WRITE_MODE));
991 if(F == NULL) {printf("Can't open file, try again.\n"); goto L20;}
994 L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F));
995 if(!IN)fwrite(ARR,sizeof(long),250,F);
1002 long fIABS(N)long N; {return(N<0? -N : N);}
1003 long fMOD(N,M)long N, M; {return(N%M);}