OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [adventure/] [misc.c] - Blame information for rev 160

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 90 ja_rd
#include "main.h"
2
#include "misc.h"
3
#include <stdio.h>
4
 
5
#include "../common/baremetal.h"
6
#include "adv_baremetal.h"
7
 
8
#define TRUE  (0==0)
9
#define FALSE (0!=0)
10
 
11
/*  I/O ROUTINES (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
12
 
13
#undef SPEAK
14
void fSPEAK(N)long N; {
15
long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE;
16
 
17
/*  PRINT THE MESSAGE WHICH STARTS AT LINES(N).  PRECEDE IT WITH A BLANK LINE
18
 *  UNLESS BLKLIN IS FALSE. */
19
 
20
 
21
        if(N == 0)return;
22
        BLANK=BLKLIN;
23
        K=N;
24
        NPARMS=1;
25
L10:    L=IABS(LINES[K])-1;
26
        K=K+1;
27
        LNLENG=0;
28
        LNPOSN=1;
29
        STATE=0;
30
        /* 20 */ for (I=K; I<=L; I++) {
31
L20:    PUTTXT(LINES[I],STATE,2,I);
32
        } /* end loop */
33
        LNPOSN=0;
34
L30:    LNPOSN=LNPOSN+1;
35
L32:    if(LNPOSN > LNLENG) goto L40;
36
        if(INLINE[LNPOSN] != 63) goto L30;
37
        {long x = LNPOSN+1; PRMTYP=INLINE[x];}
38
/*  63 IS A "%"; THE NEXT CHARACTER DETERMINE THE TYPE OF PARAMETER:  1 (!) =
39
 *  SUPPRESS MESSAGE COMPLETELY, 29 (S) = NULL IF PARM=1, ELSE 'S' (OPTIONAL
40
 *  PLURAL ENDING), 33 (W) = WORD (TWO 30-BIT VALUES) WITH TRAILING SPACES
41
 *  SUPPRESSED, 22 (L) OR 31 (U) = WORD BUT MAP TO LOWER/UPPER CASE, 13 (C) =
42
 *  WORD IN LOWER CASE WITH FIRST LETTER CAPITALISED, 30 (T) = TEXT ENDING
43
 *  WITH A WORD OF -1, 65-73 (1-9) = NUMBER USING THAT MANY CHARACTERS,
44
 *  12 (B) = VARIABLE NUMBER OF BLANKS. */
45
        if(PRMTYP == 1)return;
46
        if(PRMTYP == 29) goto L320;
47
        if(PRMTYP == 30) goto L340;
48
        if(PRMTYP == 12) goto L360;
49
        if(PRMTYP == 33 || PRMTYP == 22 || PRMTYP == 31 || PRMTYP == 13) goto
50
                L380;
51
        PRMTYP=PRMTYP-64;
52
        if(PRMTYP < 1 || PRMTYP > 9) goto L30;
53
        SHFTXT(LNPOSN+2,PRMTYP-2);
54
        LNPOSN=LNPOSN+PRMTYP;
55
        PARM=IABS(PARMS[NPARMS]);
56
        NEG=0;
57
        if(PARMS[NPARMS] < 0)NEG=9;
58
        /* 390 */ for (I=1; I<=PRMTYP; I++) {
59
        LNPOSN=LNPOSN-1;
60
        INLINE[LNPOSN]=MOD(PARM,10)+64;
61
        if(I == 1 || PARM != 0) goto L390;
62
        INLINE[LNPOSN]=NEG;
63
        NEG=0;
64
L390:   PARM=PARM/10;
65
        } /* end loop */
66
        LNPOSN=LNPOSN+PRMTYP;
67
L395:   NPARMS=NPARMS+1;
68
         goto L32;
69
 
70
L320:   SHFTXT(LNPOSN+2,-1);
71
        INLINE[LNPOSN]=55;
72
        if(PARMS[NPARMS] == 1)SHFTXT(LNPOSN+1,-1);
73
         goto L395;
74
 
75
L340:   SHFTXT(LNPOSN+2,-2);
76
        STATE=0;
77
        CASE=2;
78
L345:   if(PARMS[NPARMS] < 0) goto L395;
79
        {long x = NPARMS+1; if(PARMS[x] < 0)CASE=0;}
80
        PUTTXT(PARMS[NPARMS],STATE,CASE,0);
81
        NPARMS=NPARMS+1;
82
         goto L345;
83
 
84
L360:   PRMTYP=PARMS[NPARMS];
85
        SHFTXT(LNPOSN+2,PRMTYP-2);
86
        if(PRMTYP == 0) goto L395;
87
        /* 365 */ for (I=1; I<=PRMTYP; I++) {
88
        INLINE[LNPOSN]=0;
89
L365:   LNPOSN=LNPOSN+1;
90
        } /* end loop */
91
         goto L395;
92
 
93
L380:   SHFTXT(LNPOSN+2,-2);
94
        STATE=0;
95
        CASE= -1;
96
        if(PRMTYP == 31)CASE=1;
97
        if(PRMTYP == 33)CASE=0;
98
        I=LNPOSN;
99
        PUTTXT(PARMS[NPARMS],STATE,CASE,0);
100
        {long x = NPARMS+1; PUTTXT(PARMS[x],STATE,CASE,0);}
101
        if(PRMTYP == 13 && INLINE[I] >= 37 && INLINE[I] <=
102
                62)INLINE[I]=INLINE[I]-26;
103
        NPARMS=NPARMS+2;
104
         goto L32;
105
 
106
L40:    if(BLANK)TYPE0();
107
        BLANK=FALSE;
108
        TYPE();
109
        K=L+1;
110
        if(LINES[K] >= 0) goto L10;
111
        return;
112
}
113
 
114
 
115
 
116
#define SPEAK(N) fSPEAK(N)
117
#undef PSPEAK
118
void fPSPEAK(MSG,SKIP)long MSG, SKIP; {
119
long I, M;
120
 
121
/*  FIND THE SKIP+1ST MESSAGE FROM MSG AND PRINT IT.  MSG SHOULD BE THE INDEX OF
122
 *  THE INVENTORY MESSAGE FOR OBJECT.  (INVEN+N+1 MESSAGE IS PROP=N MESSAGE). */
123
 
124
 
125
        M=PTEXT[MSG];
126
        if(SKIP < 0) goto L9;
127
        /* 3 */ for (I=0; I<=SKIP; I++) {
128
L1:     M=IABS(LINES[M]);
129
        if(LINES[M] >= 0) goto L1;
130
L3:     /*etc*/ ;
131
        } /* end loop */
132
L9:     SPEAK(M);
133
        return;
134
}
135
 
136
 
137
 
138
#define PSPEAK(MSG,SKIP) fPSPEAK(MSG,SKIP)
139
#undef RSPEAK
140
void fRSPEAK(I)long I; {
141
;
142
 
143
/*  PRINT THE I-TH "RANDOM" MESSAGE (SECTION 6 OF DATABASE). */
144
 
145
 
146
        if(I != 0)SPEAK(RTEXT[I]);
147
        return;
148
}
149
 
150
 
151
 
152
#define RSPEAK(I) fRSPEAK(I)
153
#undef SETPRM
154
void fSETPRM(FIRST,P1,P2)long FIRST, P1, P2; {
155
;
156
 
157
/*  STORES PARAMETERS INTO THE PRMCOM PARMS ARRAY FOR USE BY SPEAK.  P1 AND P2
158
 *  ARE STORED INTO PARMS(FIRST) AND PARMS(FIRST+1). */
159
 
160
 
161
        if(FIRST >= 25)BUG(29);
162
        PARMS[FIRST]=P1;
163
        {long x = FIRST+1; PARMS[x]=P2;}
164
        return;
165
}
166
 
167
 
168
 
169
#define SETPRM(FIRST,P1,P2) fSETPRM(FIRST,P1,P2)
170
#undef GETIN
171
#define WORD1 (*wORD1)
172
#define WORD1X (*wORD1X)
173
#define WORD2 (*wORD2)
174
#define WORD2X (*wORD2X)
175
void fGETIN(wORD1,wORD1X,wORD2,wORD2X)long *wORD1, *wORD1X, *wORD2, *wORD2X; {
176
long JUNK;
177
 
178
/*  GET A COMMAND FROM THE ADVENTURER.  SNARF OUT THE FIRST WORD, PAD IT WITH
179
 *  BLANKS, AND RETURN IT IN WORD1.  CHARS 6 THRU 10 ARE RETURNED IN WORD1X, IN
180
 *  CASE WE NEED TO PRINT OUT THE WHOLE WORD IN AN ERROR MESSAGE.  ANY NUMBER OF
181
 *  BLANKS MAY FOLLOW THE WORD.  IF A SECOND WORD APPEARS, IT IS RETURNED IN
182
 *  WORD2 (CHARS 6 THRU 10 IN WORD2X), ELSE WORD2 IS -1. */
183
 
184
 
185
L10:    if(BLKLIN)TYPE0();
186
        MAPLIN(FALSE);
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;
197
        RSPEAK(53);
198
         goto L10;
199
}
200
 
201
 
202
 
203
#undef WORD1
204
#undef WORD1X
205
#undef WORD2
206
#undef WORD2X
207
#define GETIN(WORD1,WORD1X,WORD2,WORD2X) fGETIN(&WORD1,&WORD1X,&WORD2,&WORD2X)
208
#undef YES
209
long fYES(X,Y,Z)long X, Y, Z; {
210
 
211
long YES, REPLY, JUNK1, JUNK2, JUNK3;
212
 
213
/*  PRINT MESSAGE X, WAIT FOR YES/NO ANSWER.  IF YES, PRINT Y AND RETURN TRUE;
214
 *  IF NO, PRINT Z AND RETURN FALSE. */
215
 
216
L1:     RSPEAK(X);
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;
220
        RSPEAK(185);
221
         goto L1;
222
L10:    YES=TRUE;
223
        RSPEAK(Y);
224
        return(YES);
225
L20:    YES=FALSE;
226
        RSPEAK(Z);
227
        return(YES);
228
}
229
 
230
 
231
 
232
 
233
 
234
/*  LINE-PARSING ROUTINES (GETNUM, GETTXT, MAKEWD, PUTTXT, SHFTXT, TYPE0)
235
                */
236
 
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. */
242
 
243
#define YES(X,Y,Z) fYES(X,Y,Z)
244
#undef GETNUM
245
long fGETNUM(K)long K; {
246
long DIGIT, GETNUM, SIGN;
247
 
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. */
253
 
254
 
255
        if(K != 0)MAPLIN(K > 0);
256
        GETNUM=0;
257
L10:    if(LNPOSN > LNLENG)return(GETNUM);
258
        if(INLINE[LNPOSN] != 0) goto L20;
259
        LNPOSN=LNPOSN+1;
260
         goto L10;
261
 
262
L20:    SIGN=1;
263
        if(INLINE[LNPOSN] != 9) goto L32;
264
        SIGN= -1;
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;
270
         goto L30;
271
 
272
L40:    GETNUM=0;
273
L42:    GETNUM=GETNUM*SIGN;
274
        LNPOSN=LNPOSN+1;
275
        return(GETNUM);
276
}
277
 
278
 
279
 
280
#define GETNUM(K) fGETNUM(K)
281
#undef GETTXT
282
long fGETTXT(SKIP,ONEWRD,UPPER,HASH)long HASH, ONEWRD, SKIP, UPPER; {
283
long CHAR, GETTXT, I; static long SPLITTING = -1;
284
 
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. */
292
 
293
        if(LNPOSN != SPLITTING)SPLITTING = -1;
294
        GETTXT= -1;
295
L10:    if(LNPOSN > LNLENG)return(GETTXT);
296
        if((!SKIP) || INLINE[LNPOSN] != 0) goto L11;
297
        LNPOSN=LNPOSN+1;
298
         goto L10;
299
 
300
L11:    GETTXT=0;
301
        /* 15 */ for (I=1; I<=5; I++) {
302
        GETTXT=GETTXT*64;
303
        if(LNPOSN > LNLENG || (ONEWRD && INLINE[LNPOSN] == 0)) goto L15;
304
        CHAR=INLINE[LNPOSN];
305
        if(CHAR >= 63) goto L12;
306
        SPLITTING = -1;
307
        if(UPPER && CHAR >= 37)CHAR=CHAR-26;
308
        GETTXT=GETTXT+CHAR;
309
         goto L14;
310
 
311
L12:    if(SPLITTING == LNPOSN) goto L13;
312
        GETTXT=GETTXT+63;
313
        SPLITTING = LNPOSN;
314
         goto L15;
315
 
316
L13:    GETTXT=GETTXT+CHAR-63;
317
        SPLITTING = -1;
318
L14:    LNPOSN=LNPOSN+1;
319
L15:    /*etc*/ ;
320
        } /* end loop */
321
 
322
        if(HASH)GETTXT=GETTXT+MOD(HASH*13579L+5432L,97531L)*12345L+HASH;
323
        return(GETTXT);
324
}
325
 
326
 
327
 
328
#define GETTXT(SKIP,ONEWRD,UPPER,HASH) fGETTXT(SKIP,ONEWRD,UPPER,HASH)
329
#undef MAKEWD
330
long fMAKEWD(LETTRS)long LETTRS; {
331
long I, L, MAKEWD;
332
 
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. */
339
 
340
 
341
        MAKEWD=0;
342
        I=1;
343
        L=LETTRS;
344
L10:    MAKEWD=MAKEWD+I*(MOD(L,50)+10);
345
        I=I*64;
346
        if(MOD(L,100) > 50)MAKEWD=MAKEWD+I*5;
347
        L=L/100;
348
        if(L != 0) goto L10;
349
        I=64L*64L*64L*64L*64L/I;
350
        MAKEWD=MAKEWD*I;
351
        return(MAKEWD);
352
}
353
 
354
 
355
 
356
#define MAKEWD(LETTRS) fMAKEWD(LETTRS)
357
#undef PUTTXT
358
#define STATE (*sTATE)
359
void fPUTTXT(WORD,sTATE,CASE,HASH)long CASE, HASH, *sTATE, WORD; {
360
long ALPH1, ALPH2, BYTE, DIV, I, W;
361
 
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). */
372
 
373
 
374
        ALPH1=13*CASE+24;
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. */
378
        DIV=64L*64L*64L*64L;
379
        W=WORD;
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;
383
        BYTE=W/DIV;
384
        if(STATE != 0 || BYTE != 63) goto L12;
385
        STATE=63;
386
         goto L18;
387
 
388
L12:    SHFTXT(LNPOSN,1);
389
        STATE=STATE+BYTE;
390
        if(STATE < ALPH2 && STATE >= ALPH1)STATE=STATE-26*CASE;
391
        INLINE[LNPOSN]=STATE;
392
        LNPOSN=LNPOSN+1;
393
        STATE=0;
394
L18:    W=(W-BYTE*DIV)*64;
395
        } /* end loop */
396
        return;
397
}
398
 
399
 
400
 
401
#undef STATE
402
#define PUTTXT(WORD,STATE,CASE,HASH) fPUTTXT(WORD,&STATE,CASE,HASH)
403
#undef SHFTXT
404
void fSHFTXT(FROM,DELTA)long DELTA, FROM; {
405
long I, II, JJ;
406
 
407
/*  MOVE INLINE(N) TO INLINE(N+DELTA) FOR N=FROM,LNLENG.  DELTA CAN BE
408
 *  NEGATIVE.  LNLENG IS UPDATED; LNPOSN IS NOT CHANGED. */
409
 
410
 
411
        if(LNLENG < FROM || DELTA == 0) goto L2;
412
        /* 1 */ for (I=FROM; I<=LNLENG; I++) {
413
        II=I;
414
        if(DELTA > 0)II=FROM+LNLENG-I;
415
        JJ=II+DELTA;
416
L1:     INLINE[JJ]=INLINE[II];
417
        } /* end loop */
418
L2:     LNLENG=LNLENG+DELTA;
419
        return;
420
}
421
 
422
 
423
 
424
#define SHFTXT(FROM,DELTA) fSHFTXT(FROM,DELTA)
425
#undef TYPE0
426
void fTYPE0() {
427
long TEMP;
428
 
429
/*  TYPE A BLANK LINE.  THIS PROCEDURE IS PROVIDED AS A CONVENIENCE FOR CALLERS
430
 *  WHO OTHERWISE HAVE NO USE FOR MAPCOM. */
431
 
432
 
433
        TEMP=LNLENG;
434
        LNLENG=0;
435
        TYPE();
436
        LNLENG=TEMP;
437
        return;
438
}
439
 
440
 
441
 
442
#define TYPE0() fTYPE0()
443
 
444
 
445
/*  SUSPEND/RESUME I/O ROUTINES (SAVWDS, SAVARR, SAVWRD) */
446
 
447
#undef SAVWDS
448
void fSAVWDS(W1,W2,W3,W4,W5,W6,W7)long *W1, *W2, *W3, *W4, *W5, *W6, *W7; {
449
;
450
 
451
/*  WRITE OR READ 7 VARIABLES.  SEE SAVWRD. */
452
 
453
 
454
        SAVWRD(0,(*W1));
455
        SAVWRD(0,(*W2));
456
        SAVWRD(0,(*W3));
457
        SAVWRD(0,(*W4));
458
        SAVWRD(0,(*W5));
459
        SAVWRD(0,(*W6));
460
        SAVWRD(0,(*W7));
461
        return;
462
}
463
 
464
 
465
#define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7)
466
#undef SAVARR
467
void fSAVARR(ARR,N)long ARR[], N; {
468
long I;
469
 
470
/*  WRITE OR READ AN ARRAY OF N WORDS.  SEE SAVWRD. */
471
 
472
 
473
        /* 1 */ for (I=1; I<=N; I++) {
474
L1:     SAVWRD(0,ARR[I]);
475
        } /* end loop */
476
        return;
477
}
478
 
479
 
480
 
481
#define SAVARR(ARR,N) fSAVARR(ARR,N)
482
#undef SAVWRD
483
#define WORD (*wORD)
484
void fSAVWRD(OP,wORD)long OP, *wORD; {
485
static long BUF[250], CKSUM = 0, H1, HASH = 0, N = 0, STATE = 0;
486
 
487
/*  IF OP<0, START WRITING A FILE, USING WORD TO INITIALISE ENCRYPTION; SAVE
488
 *  WORD IN THE FILE.  IF OP>0, START READING A FILE; READ THE FILE TO FIND
489
 *  THE VALUE WITH WHICH TO DECRYPT THE REST.  IN EITHER CASE, IF A FILE IS
490
 *  ALREADY OPEN, FINISH WRITING/READING IT AND DON'T START A NEW ONE.  IF OP=0,
491
 *  READ/WRITE A SINGLE WORD.  WORDS ARE BUFFERED IN CASE THAT MAKES FOR MORE
492
 *  EFFICIENT DISK USE.  WE ALSO COMPUTE A SIMPLE CHECKSUM TO CATCH ELEMENTARY
493
 *  POKING WITHIN THE SAVED FILE.  WHEN WE FINISH READING/WRITING THE FILE,
494
 *  WE STORE ZERO INTO WORD IF THERE'S NO CHECKSUM ERROR, ELSE NONZERO. */
495
 
496
 
497
        if(OP != 0){long ifvar; ifvar=(STATE); switch (ifvar<0? -1 : ifvar>0? 1 :
498
                0) { case -1: goto L30; case 0: goto L10; case 1: goto L30; }}
499
        if(STATE == 0)return;
500
        if(N == 250)SAVEIO(1,STATE > 0,BUF);
501
        N=MOD(N,250)+1;
502
        H1=MOD(HASH*1093L+221573L,1048576L);
503
        HASH=MOD(H1*1093L+221573L,1048576L);
504
        H1=MOD(H1,1234)*765432+MOD(HASH,123);
505
        N--;
506
        if(STATE > 0)WORD=BUF[N]+H1;
507
        BUF[N]=WORD-H1;
508
        N++;
509
        CKSUM=MOD(CKSUM*13+WORD,1000000000L);
510
        return;
511
 
512
L10:    STATE=OP;
513
        SAVEIO(0,STATE > 0,BUF);
514
        N=1;
515
        if(STATE > 0) goto L15;
516
        HASH=MOD(WORD,1048576L);
517
        BUF[0]=1234L*5678L-HASH;
518
L13:    CKSUM=BUF[0];
519
        return;
520
 
521
L15:    SAVEIO(1,TRUE,BUF);
522
        HASH=MOD(1234L*5678L-BUF[0],1048576L);
523
         goto L13;
524
 
525
L30:    if(N == 250)SAVEIO(1,STATE > 0,BUF);
526
        N=MOD(N,250)+1;
527
        if(STATE > 0) goto L32;
528
        N--; BUF[N]=CKSUM; N++;
529
        SAVEIO(1,FALSE,BUF);
530
L32:    N--; WORD=BUF[N]-CKSUM; N++;
531
        SAVEIO(-1,STATE > 0,BUF);
532
        STATE=0;
533
        return;
534
}
535
 
536
 
537
 
538
 
539
 
540
/*  DATA STRUC. ROUTINES (VOCAB, DSTROY, JUGGLE, MOVE, PUT, CARRY, DROP, ATDWRF)
541
                */
542
 
543
#undef WORD
544
#define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD)
545
#undef VOCAB
546
long fVOCAB(ID,INIT)long ID, INIT; {
547
long HASH, I, VOCAB;
548
 
549
/*  LOOK UP ID IN THE VOCABULARY (ATAB) AND RETURN ITS "DEFINITION" (KTAB), OR
550
 *  -1 IF NOT FOUND.  IF INIT IS POSITIVE, THIS IS AN INITIALISATION CALL SETTING
551
 *  UP A KEYWORD VARIABLE, AND NOT FINDING IT CONSTITUTES A BUG.  IT ALSO MEANS
552
 *  THAT ONLY KTAB VALUES WHICH TAKEN OVER 1000 EQUAL INIT MAY BE CONSIDERED.
553
 *  (THUS "STEPS", WHICH IS A MOTION VERB AS WELL AS AN OBJECT, MAY BE LOCATED
554
 *  AS AN OBJECT.)  AND IT ALSO MEANS THE KTAB VALUE IS TAKEN MOD 1000. */
555
 
556
        HASH=10000;
557
        /* 1 */ for (I=1; I<=TABSIZ; I++) {
558
        if(KTAB[I] == -1) goto L2;
559
        HASH=HASH+7;
560
        if(INIT >= 0 && KTAB[I]/1000 != INIT) goto L1;
561
        if(ATAB[I] == ID+HASH*HASH) goto L3;
562
L1:     /*etc*/ ;
563
        } /* end loop */
564
        BUG(21);
565
 
566
L2:     VOCAB= -1;
567
        if(INIT < 0)return(VOCAB);
568
        BUG(5);
569
 
570
L3:     VOCAB=KTAB[I];
571
        if(INIT >= 0)VOCAB=MOD(VOCAB,1000);
572
        return(VOCAB);
573
}
574
 
575
 
576
 
577
#define VOCAB(ID,INIT) fVOCAB(ID,INIT)
578
#undef DSTROY
579
void fDSTROY(OBJECT)long OBJECT; {
580
;
581
 
582
/*  PERMANENTLY ELIMINATE "OBJECT" BY MOVING TO A NON-EXISTENT LOCATION. */
583
 
584
 
585
        MOVE(OBJECT,0);
586
        return;
587
}
588
 
589
 
590
 
591
#define DSTROY(OBJECT) fDSTROY(OBJECT)
592
#undef JUGGLE
593
void fJUGGLE(OBJECT)long OBJECT; {
594
long I, J;
595
 
596
/*  JUGGLE AN OBJECT BY PICKING IT UP AND PUTTING IT DOWN AGAIN, THE PURPOSE
597
 *  BEING TO GET THE OBJECT TO THE FRONT OF THE CHAIN OF THINGS AT ITS LOC. */
598
 
599
 
600
        I=PLACE[OBJECT];
601
        J=FIXED[OBJECT];
602
        MOVE(OBJECT,I);
603
        MOVE(OBJECT+100,J);
604
        return;
605
}
606
 
607
 
608
 
609
#define JUGGLE(OBJECT) fJUGGLE(OBJECT)
610
#undef MOVE
611
void fMOVE(OBJECT,WHERE)long OBJECT, WHERE; {
612
long FROM;
613
 
614
/*  PLACE ANY OBJECT ANYWHERE BY PICKING IT UP AND DROPPING IT.  MAY ALREADY BE
615
 *  TOTING, IN WHICH CASE THE CARRY IS A NO-OP.  MUSTN'T PICK UP OBJECTS WHICH
616
 *  ARE NOT AT ANY LOC, SINCE CARRY WANTS TO REMOVE OBJECTS FROM ATLOC CHAINS. */
617
 
618
 
619
        if(OBJECT > 100) goto L1;
620
        FROM=PLACE[OBJECT];
621
         goto L2;
622
L1:     {long x = OBJECT-100; FROM=FIXED[x];}
623
L2:     if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM);
624
        DROP(OBJECT,WHERE);
625
        return;
626
}
627
 
628
 
629
 
630
#define MOVE(OBJECT,WHERE) fMOVE(OBJECT,WHERE)
631
#undef PUT
632
long fPUT(OBJECT,WHERE,PVAL)long OBJECT, PVAL, WHERE; {
633
long PUT;
634
 
635
/*  PUT IS THE SAME AS MOVE, EXCEPT IT RETURNS A VALUE USED TO SET UP THE
636
 *  NEGATED PROP VALUES FOR THE REPOSITORY OBJECTS. */
637
 
638
 
639
        MOVE(OBJECT,WHERE);
640
        PUT=(-1)-PVAL;
641
        return(PUT);
642
}
643
 
644
 
645
 
646
#define PUT(OBJECT,WHERE,PVAL) fPUT(OBJECT,WHERE,PVAL)
647
#undef CARRY
648
void fCARRY(OBJECT,WHERE)long OBJECT, WHERE; {
649
long TEMP;
650
 
651
/*  START TOTING AN OBJECT, REMOVING IT FROM THE LIST OF THINGS AT ITS FORMER
652
 *  LOCATION.  INCR HOLDNG UNLESS IT WAS ALREADY BEING TOTED.  IF OBJECT>100
653
 *  (MOVING "FIXED" SECOND LOC), DON'T CHANGE PLACE OR HOLDNG. */
654
 
655
 
656
        if(OBJECT > 100) goto L5;
657
        if(PLACE[OBJECT] == -1)return;
658
        PLACE[OBJECT]= -1;
659
        HOLDNG=HOLDNG+1;
660
L5:     if(ATLOC[WHERE] != OBJECT) goto L6;
661
        ATLOC[WHERE]=LINK[OBJECT];
662
        return;
663
L6:     TEMP=ATLOC[WHERE];
664
L7:     if(LINK[TEMP] == OBJECT) goto L8;
665
        TEMP=LINK[TEMP];
666
         goto L7;
667
L8:     LINK[TEMP]=LINK[OBJECT];
668
        return;
669
}
670
 
671
 
672
 
673
#define CARRY(OBJECT,WHERE) fCARRY(OBJECT,WHERE)
674
#undef DROP
675
void fDROP(OBJECT,WHERE)long OBJECT, WHERE; {
676
;
677
 
678
/*  PLACE AN OBJECT AT A GIVEN LOC, PREFIXING IT ONTO THE ATLOC LIST.  DECR
679
 *  HOLDNG IF THE OBJECT WAS BEING TOTED. */
680
 
681
 
682
        if(OBJECT > 100) goto L1;
683
        if(PLACE[OBJECT] == -1)HOLDNG=HOLDNG-1;
684
        PLACE[OBJECT]=WHERE;
685
         goto L2;
686
L1:     {long x = OBJECT-100; FIXED[x]=WHERE;}
687
L2:     if(WHERE <= 0)return;
688
        LINK[OBJECT]=ATLOC[WHERE];
689
        ATLOC[WHERE]=OBJECT;
690
        return;
691
}
692
 
693
 
694
 
695
#define DROP(OBJECT,WHERE) fDROP(OBJECT,WHERE)
696
#undef ATDWRF
697
long fATDWRF(WHERE)long WHERE; {
698
long ATDWRF, I;
699
 
700
/*  RETURN THE INDEX OF FIRST DWARF AT THE GIVEN LOCATION, ZERO IF NO DWARF IS
701
 *  THERE (OR IF DWARVES NOT ACTIVE YET), -1 IF ALL DWARVES ARE DEAD.  IGNORE
702
 *  THE PIRATE (6TH DWARF). */
703
 
704
 
705
        ATDWRF=0;
706
        if(DFLAG < 2)return(ATDWRF);
707
        ATDWRF= -1;
708
        /* 1 */ for (I=1; I<=5; I++) {
709
        if(DLOC[I] == WHERE) goto L2;
710
L1:     if(DLOC[I] != 0)ATDWRF=0;
711
        } /* end loop */
712
        return(ATDWRF);
713
 
714
L2:     ATDWRF=I;
715
        return(ATDWRF);
716
}
717
 
718
 
719
 
720
 
721
#define ATDWRF(WHERE) fATDWRF(WHERE)
722
 
723
 
724
 
725
/*  UTILITY ROUTINES (SETBIT, TSTBIT, RAN, RNDVOC, BUG) */
726
 
727
#undef SETBIT
728
long fSETBIT(BIT)long BIT; {
729
long I, SETBIT;
730
 
731
/*  RETURNS 2**BIT FOR USE IN CONSTRUCTING BIT-MASKS. */
732
 
733
 
734
        SETBIT=1;
735
        if(BIT <= 0)return(SETBIT);
736
        /* 1 */ for (I=1; I<=BIT; I++) {
737
L1:     SETBIT=SETBIT+SETBIT;
738
        } /* end loop */
739
        return(SETBIT);
740
}
741
 
742
 
743
 
744
#define SETBIT(BIT) fSETBIT(BIT)
745
#undef TSTBIT
746
long fTSTBIT(MASK,BIT)long BIT, MASK; {
747
long TSTBIT;
748
 
749
/*  RETURNS TRUE IF THE SPECIFIED BIT IS SET IN THE MASK. */
750
 
751
 
752
        TSTBIT=MOD(MASK/SETBIT(BIT),2) != 0;
753
        return(TSTBIT);
754
}
755
 
756
 
757
 
758
#define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT)
759
#undef RAN
760
long fRAN(RANGE)long RANGE; {
761
static long D, R = 0, RAN, T;
762
 
763
/*  SINCE THE RAN FUNCTION IN LIB40 SEEMS TO BE A REAL LOSE, WE'LL USE ONE OF
764
 *  OUR OWN.  IT'S BEEN RUN THROUGH MANY OF THE TESTS IN KNUTH VOL. 2 AND
765
 *  SEEMS TO BE QUITE RELIABLE.  RAN RETURNS A VALUE UNIFORMLY SELECTED
766
 *  BETWEEN 0 AND RANGE-1. */
767
 
768
 
769
        D=1;
770
        if(R != 0 && RANGE >= 0) goto L1;
771
        DATIME(D,T);
772
        R=MOD(T+5,1048576L);
773
        D=1000+MOD(D,1000);
774
L1:     /* 2 */ for (T=1; T<=D; T++) {
775
L2:     R=MOD(R*1093L+221587L,1048576L);
776
        } /* end loop */
777
        RAN=(RANGE*R)/1048576;
778
        return(RAN);
779
}
780
 
781
 
782
 
783
#define RAN(RANGE) fRAN(RANGE)
784
#undef RNDVOC
785
long fRNDVOC(CHAR,FORCE)long CHAR, FORCE; {
786
long DIV, I, J, RNDVOC;
787
 
788
/*  SEARCHES THE VOCABULARY FOR A WORD WHOSE SECOND CHARACTER IS CHAR, AND
789
 *  CHANGES THAT WORD SUCH THAT EACH OF THE OTHER FOUR CHARACTERS IS A
790
 *  RANDOM LETTER.  IF FORCE IS NON-ZERO, IT IS USED AS THE NEW WORD.
791
 *  RETURNS THE NEW WORD. */
792
 
793
 
794
        RNDVOC=FORCE;
795
        if(RNDVOC != 0) goto L3;
796
        /* 1 */ for (I=1; I<=5; I++) {
797
        J=11+RAN(26);
798
        if(I == 2)J=CHAR;
799
L1:     RNDVOC=RNDVOC*64+J;
800
        } /* end loop */
801
L3:     J=10000;
802
        DIV=64L*64L*64L;
803
        /* 5 */ for (I=1; I<=TABSIZ; I++) {
804
        J=J+7;
805
        if(MOD((ATAB[I]-J*J)/DIV,64L) == CHAR) goto L8;
806
L5:     /*etc*/ ;
807
        } /* end loop */
808
        BUG(5);
809
 
810
L8:     ATAB[I]=RNDVOC+J*J;
811
        return(RNDVOC);
812
}
813
 
814
 
815
 
816
#define RNDVOC(CHAR,FORCE) fRNDVOC(CHAR,FORCE)
817
#undef BUG
818
void fBUG(NUM)long NUM; {
819
 
820
/*  THE FOLLOWING CONDITIONS ARE CURRENTLY CONSIDERED FATAL BUGS.  NUMBERS < 20
821
 *  ARE DETECTED WHILE READING THE DATABASE; THE OTHERS OCCUR AT "RUN TIME".
822
 *      0        MESSAGE LINE > 70 CHARACTERS
823
 *      1       NULL LINE IN MESSAGE
824
 *      2       TOO MANY WORDS OF MESSAGES
825
 *      3       TOO MANY TRAVEL OPTIONS
826
 *      4       TOO MANY VOCABULARY WORDS
827
 *      5       REQUIRED VOCABULARY WORD NOT FOUND
828
 *      6       TOO MANY RTEXT MESSAGES
829
 *      7       TOO MANY HINTS
830
 *      8       LOCATION HAS COND BIT BEING SET TWICE
831
 *      9       INVALID SECTION NUMBER IN DATABASE
832
 *      10      TOO MANY LOCATIONS
833
 *      11      TOO MANY CLASS OR TURN MESSAGES
834
 *      20      SPECIAL TRAVEL (500>L>300) EXCEEDS GOTO LIST
835
 *      21      RAN OFF END OF VOCABULARY TABLE
836
 *      22      VOCABULARY TYPE (N/1000) NOT BETWEEN 0 AND 3
837
 *      23      INTRANSITIVE ACTION VERB EXCEEDS GOTO LIST
838
 *      24      TRANSITIVE ACTION VERB EXCEEDS GOTO LIST
839
 *      25      CONDITIONAL TRAVEL ENTRY WITH NO ALTERNATIVE
840
 *      26      LOCATION HAS NO TRAVEL ENTRIES
841
 *      27      HINT NUMBER EXCEEDS GOTO LIST
842
 *      28      INVALID MONTH RETURNED BY DATE FUNCTION
843
 *      29      TOO MANY PARAMETERS GIVEN TO SETPRM */
844
 
845
    puts("Fatal error ");
846
    po_num(NUM);
847
    puts(".  See source code for interpretation.\n");
848
        exit(FALSE);
849
}
850
 
851
 
852
 
853
 
854
 
855
/*  MACHINE DEPENDENT ROUTINES (MAPLIN, TYPE, MPINIT, SAVEIO) */
856
 
857
#define BUG(NUM) fBUG(NUM)
858
#undef MAPLIN
859
void fMAPLIN(FIL)long FIL; {
860
long I, VAL; static MFILE *OPENED = NULL;
861
 
862
/*  READ A LINE OF INPUT, EITHER FROM A FILE (IF FIL=.TRUE.) OR FROM THE
863
 *  KEYBOARD, TRANSLATE THE CHARS TO INTEGERS IN THE RANGE 0-126 AND STORE
864
 *  THEM IN THE COMMON ARRAY "INLINE".  INTEGER VALUES ARE AS FOLLOWS:
865
 *     0   = SPACE [ASCII CODE 40 OCTAL, 32 DECIMAL]
866
 *    1-2  = !" [ASCII 41-42 OCTAL, 33-34 DECIMAL]
867
 *    3-10 = '()*+,-. [ASCII 47-56 OCTAL, 39-46 DECIMAL]
868
 *   11-36 = UPPER-CASE LETTERS
869
 *   37-62 = LOWER-CASE LETTERS
870
 *    63   = PERCENT (%) [ASCII 45 OCTAL, 37 DECIMAL]
871
 *   64-73 = DIGITS, 0 THROUGH 9
872
 *  REMAINING CHARACTERS CAN BE TRANSLATED ANY WAY THAT IS CONVENIENT;
873
 *  THE "TYPE" ROUTINE BELOW IS USED TO MAP THEM BACK TO CHARACTERS WHEN
874
 *  NECESSARY.  THE ABOVE MAPPINGS ARE REQUIRED SO THAT CERTAIN SPECIAL
875
 *  CHARACTERS ARE KNOWN TO FIT IN 6 BITS AND/OR CAN BE EASILY SPOTTED.
876
 *  ARRAY ELEMENTS BEYOND THE END OF THE LINE SHOULD BE FILLED WITH 0,
877
 *  AND LNLENG SHOULD BE SET TO THE INDEX OF THE LAST CHARACTER.
878
 *
879
 *  IF THE DATA FILE USES A CHARACTER OTHER THAN SPACE (E.G., TAB) TO
880
 *  SEPARATE NUMBERS, THAT CHARACTER SHOULD ALSO TRANSLATE TO 0.
881
 *
882
 *  THIS PROCEDURE MAY USE THE MAP1,MAP2 ARRAYS TO MAINTAIN STATIC DATA FOR
883
 *  THE MAPPING.  MAP2(1) IS SET TO 0 WHEN THE PROGRAM STARTS
884
 *  AND IS NOT CHANGED THEREAFTER UNLESS THE ROUTINES ON THIS PAGE CHOOSE
885
 *  TO DO SO.
886
 *
887
 *  NOTE THAT MAPLIN IS EXPECTED TO OPEN THE FILE THE FIRST TIME IT IS
888
 *  ASKED TO READ A LINE FROM IT.  THAT IS, THERE IS NO OTHER PLACE WHERE
889
 *  THE DATA FILE IS OPENED. */
890
 
891
 
892
        if(MAP2[1] == 0)MPINIT();
893
 
894
        if(FIL) goto L15;
895
        get_command(INLINE+1);
896
        /* EMBEDDED: we don't support 'quitting by closing stdin' */
897
        /* if(feof(stdin)) score(1); */
898
    goto L20;
899
 
900
L15:    if(!OPENED){
901
                OPENED=mopen("adventure.text","r" /* NOT binary */);
902
                if(!OPENED){puts("Can't read adventure.text!\n"); exit(FALSE);}
903
                }
904
        mgets(INLINE+1,100,OPENED);
905
 
906
L20:    LNLENG=0;
907
        /* 25 */ for (I=1; I<=100 && INLINE[I]!=0; I++) {
908
        VAL=INLINE[I]+1;
909
        INLINE[I]=MAP1[VAL];
910
L25:    if(INLINE[I] != 0)LNLENG=I;
911
        } /* end loop */
912
        LNPOSN=1;
913
        if(FIL && LNLENG == 0) goto L15;
914
/*  ABOVE IS TO GET AROUND AN F40 COMPILER BUG WHEREIN IT READS A BLANK
915
 *  LINE WHENEVER A CRLF IS BROKEN ACROSS A RECORD BOUNDARY. */
916
        return;
917
}
918
 
919
 
920
 
921
#define MAPLIN(FIL) fMAPLIN(FIL)
922
#undef TYPE
923
void fTYPE() {
924
long I, VAL;
925
 
926
/*  TYPE THE FIRST "LNLENG" CHARACTERS STORED IN INLINE, MAPPING THEM
927
 *  FROM INTEGERS TO TEXT PER THE RULES DESCRIBED ABOVE.  INLINE(I),
928
 *  I=1,LNLENG MAY BE CHANGED BY THIS ROUTINE. */
929
 
930
 
931
        if(LNLENG != 0) goto L10;
932
        puts("\n");
933
        return;
934
 
935
L10:    if(MAP2[1] == 0)MPINIT();
936
        /* 20 */ for (I=1; I<=LNLENG; I++) {
937
        VAL=INLINE[I];
938
L20:    {long x = VAL+1; INLINE[I]=MAP2[x];}
939
        } /* end loop */
940
        {long x = LNLENG+1; INLINE[x]=0;}
941
        puts(INLINE+1);
942
        puts("\n");
943
        return;
944
}
945
 
946
 
947
 
948
#define TYPE() fTYPE()
949
#undef MPINIT
950
void fMPINIT() {
951
long FIRST, I, J, LAST, VAL;
952
static const long RUNS[7][2] = {32,34, 39,46, 65,90, 97,122, 37,37, 48,57, 0,126};
953
 
954
 
955
        /* 10 */ for (I=1; I<=128; I++) {
956
L10:    MAP1[I]= -1;
957
        } /* end loop */
958
        VAL=0;
959
        /* 20 */ for (I=0; I<7; I++) {
960
        FIRST=RUNS[I][0];
961
        LAST=RUNS[I][1];
962
        /* 22 */ for (J=FIRST; J<=LAST; J++) {
963
        J++; if(MAP1[J] >= 0) goto L22;
964
        MAP1[J]=VAL;
965
        VAL=VAL+1;
966
L22:    J--;
967
        } /* end loop */
968
L20:    /*etc*/ ;
969
        } /* end loop */
970
        MAP1[128]=MAP1[10];
971
/*  FOR THIS VERSION, TAB (9) MAPS TO SPACE (32), SO DEL (127) USES TAB'S VALUE */
972
        MAP1[10]=MAP1[33];
973
        MAP1[11]=MAP1[33];
974
 
975
        /* 30 */ for (I=0; I<=126; I++) {
976
        I++; VAL=MAP1[I]+1; I--;
977
        MAP2[VAL]=I*('B'-'A');
978
L30:    if(I >= 64)MAP2[VAL]=(I-64)*('B'-'A')+'@';
979
        } /* end loop */
980
 
981
        return;
982
}
983
 
984
 
985
 
986
#define MPINIT() fMPINIT()
987
#undef SAVEIO
988
void fSAVEIO(OP,IN,ARR)long ARR[], IN, OP; {
989
static FILE *F; char NAME[50];
990
 
991
/*  IF OP=0, ASK FOR A FILE NAME AND OPEN A FILE.  (IF IN=.TRUE., THE FILE IS FOR
992
 *  INPUT, ELSE OUTPUT.)  IF OP>0, READ/WRITE ARR FROM/INTO THE PREVIOUSLY-OPENED
993
 *  FILE.  (ARR IS A 250-INTEGER ARRAY.)  IF OP<0, FINISH READING/WRITING THE
994
 *  FILE.  (FINISHING WRITING CAN BE A NO-OP IF A "STOP" STATEMENT DOES IT
995
 *  AUTOMATICALLY.  FINISHING READING CAN BE A NO-OP AS LONG AS A SUBSEQUENT
996
 *  SAVEIO(0,.FALSE.,X) WILL STILL WORK.)  IF YOU CAN CATCH ERRORS (E.G., NO SUCH
997
 *  FILE) AND TRY AGAIN, GREAT.  DEC F40 CAN'T. */
998
 
999
/* EMBEDDED version supports no saves */
1000
/*
1001
        {long ifvar; ifvar=(OP); switch (ifvar<0? -1 : ifvar>0? 1 : 0) { case -1:
1002
                goto L10; case 0: goto L20; case 1: goto L30; }}
1003
 
1004
L10:    fclose(F);
1005
        return;
1006
 
1007
L20:    puts("\nFile name: ");
1008
        gets(NAME);
1009
        F=mopen(NAME,(IN ? READ_MODE : WRITE_MODE));
1010
        if(F == NULL) {puts("Can't open file, try again.\n"); goto L20;}
1011
        return;
1012
 
1013
L30:    if(IN)fread(ARR,4,250,F);
1014
        if(!IN)fwrite(ARR,4,250,F);
1015
        return;
1016
*/
1017
return;
1018
}
1019
 
1020
 
1021
 
1022
long fIABS(N)long N; {return(N<0? -N : N);}
1023
long fMOD(N,M)long N, M; {return(N%M);}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.