-
Notifications
You must be signed in to change notification settings - Fork 1
/
C1GADV.m
56 lines (56 loc) · 2.46 KB
/
C1GADV.m
1
2
3
4
5
6
7
8
9
10
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
C1GADV ;ADVENTURE V1.0. FLH. DJW/WV ; 07 FEB 83 3:37 PM
;;1.0;C1GAMES;****;March 1, 2016;
;DNL;20May89 13:00;Copyright (c) 1989 PRx, Inc.
;ADVENTURE V1.0. FLH ; 07 FEB 83 3:37 PM
;
;K S:$ZS<6 $ZS=6 S $ZE="ERR1" S GAVEUP=0,S=1
S GAME=$P(XID,"^",2),NAME=XID("USER")
;NEW (GAME,NAME)
; CTRL-C allowed during debugging- change IF to disallow
I 1 X ^%ZOSF("BRK")
I 0 X ^%ZOSF("NBRK")
S X="^ERR1" X ^%ZOSF("TRAP")
S GAVEUP=0,S=1
S Q=65,Y=54,N=201 D YES I D OLDNAM I D GETGAM I 1
E D NEWNAM,GCOPY,GETGAM
S X="ERR^C1GADV" X ^%ZOSF("TRAP")
S Q=208,Y=1,N=0 D YES I I 'HINTED(3) S HINTED(3)=1,LIMIT=LIMIT+670
G ^C1GADV2
ENDGAM I '(SAVED&GAVEUP) K ^C1GADV(71100.1,G)
E D PUTGAM
S X="^ERR1" X ^%ZOSF("TRAP") S G="" F Z=0:0 S G=$O(^C1GADV(71100.1,G)) Q:G="" I $H-10>^(G) K ^(G)
S X="^%ZTER" X ^%ZOSF("TRAP") Q
TIMO S GAVEUP=1 D ENDGAM G ^XUSCLEAN
;
; no Standard ANSI M way to detect CONTROL-C
ERR ;I $ZE?1"<INRPT".E S $ZE="ERR^C1GADV",RET="TURN^C1GADV3" D @$P(^C1GADV(71100,"QUIT"),"/",3) G @RET
ERR1 D ^%ZTER Q
OLDNAM S M=205 D SPK
OL1 D GETIN I U1="?"!(U1="HELP") D LIST G OLDNAM
I W'?1.5AN S M=203 D SPK G OL1
Q:U1="NEW" S G=U1 I $D(^C1GADV(71100.1,G)) S M=207 D SPK Q
S M=206 D SPK G OLDNAM
LIST W !! S G="" F X=0:8 S G=$O(^C1GADV(71100.1,G)) Q:G="" W ?X,G I X>70 W ! S X=0
Q
NEWNAM S M=202 D SPK
NE1 D GETIN S G=U1,M=$S(W'?1.5AN:203,G="NEW":210,$D(^C1GADV(71100.1,G)):204,1:207) D SPK G:M-207 NE1 S ^C1GADV(71100.1,G)=$H Q
GCOPY F L=1:1:140 S ^C1GADV(71100.1,G,L,"A")=0,^("O")="/"
S N=0,F(N)="^C1GADV(71100,""i"",",T(N)="^C1GADV(71100.1,G,",X=$H D COP K D,F,IN,N,OUT,T,SAVE,X Q
COP S SAVE(N)="",IN(N)=F(N)_"SAVE(N))",OUT(N)=T(N)_"SAVE(N))"
CO1 S SAVE(N)=$O(@IN(N)) I SAVE(N)="" Q
S D=$D(@IN(N)) I D#2 S @OUT(N)=@IN(N) I X'=$H S X=$H W "."
I D>9 S F(N+1)=F(N)_""""_SAVE(N)_""",",T(N+1)=T(N)_""""_SAVE(N)_""",",N=N+1 D COP S N=N-1
G CO1
GETGAM S X="" F Z=0:0 S X=$O(^C1GADV(71100.1,G,"i",X)) Q:X="" S @X=^(X)
Q
PUTGAM S X="" F Z=0:0 S X=$O(^C1GADV(71100.1,G,"i",X)) Q:X="" S ^(X)=@X
W !!,"This adventure saved with name ",G,"." Q
GETIN D KBD S W1=$P(W," ",1),W2=$P(W," ",2),U1=$E($P(SAVE," ",1),1,5),U2=$E($P(SAVE," ",2),1,5) K SAVE Q
YES S M=Q D SPK,KBD I SAVE?1"Y".1"ES" S M=Y D:M SPK
E I SAVE'?1"N".1"O" W " Please answer the question." G YES
E S M=N D:M SPK
K M Q
KBD W:S ! R !,W:600 G:'$T TIMO^C1GADV S SAVE=W F I=1:1 Q:SAVE?.CNPU I $E(SAVE,I)?1L S SAVE=$E(SAVE,1,I-1)_$C($A(SAVE,I)-32)_$E(SAVE,I+1,99)
K I Q
SPK W:S ! F I=1:1:^C1GADV(71100,"t",M,0) W !,^(I)
K I Q