-
Notifications
You must be signed in to change notification settings - Fork 12
/
output.zap
366 lines (315 loc) · 7.04 KB
/
output.zap
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
.SEGMENT "0"
.FUNCT CHANGE-FONT:ANY:1:1,F
EQUAL? F,3 \?CCL3
ZERO? FONT3-FLAG /?CCL6
FONT 3
RSTACK
?CCL6: FONT 1
RSTACK
?CCL3: EQUAL? F,4 \FALSE
ZERO? FWC-FLAG /?CCL11
FONT 4
RSTACK
?CCL11: FONT 1
RSTACK
.FUNCT GPOS:ANY:2:2,C,F
EQUAL? F,1 \?CCL3
RETURN C
?CCL3: SUB C,1
MUL STACK,F
ADD STACK,1
RSTACK
.FUNCT MAKE-WINDOW:ANY:5:6,N,YL,XL,YS,XS,B,?TMP1
ASSIGNED? 'B /?CND1
SET 'B,15
?CND1: CALL GPOS,YL,CHRV >?TMP1
CALL GPOS,XL,CHRH
WINPOS N,?TMP1,STACK
MUL YS,CHRV >?TMP1
MUL XS,CHRH
WINSIZE N,?TMP1,STACK
WINATTR N,B
RETURN N
.FUNCT GCURSET:ANY:2:2,YL,XL,?TMP1
ZERO? CURRENT-SCREEN \?CND1
ICALL2 SELECT-SCREEN,COMMAND-WINDOW
?CND1: CALL GPOS,YL,CHRV >?TMP1
CALL GPOS,XL,CHRH
CURSET ?TMP1,STACK
RTRUE
.FUNCT WPRINTCHR:ANY:1:1,CHR
FSET? CHR,IN-PARTY \?CCL3
CALL2 WPRINTD,CHR
RSTACK
?CCL3: PRINTI "[Error: "
ICALL2 WPRINTD,CHR
PRINTC 93
RTRUE
.FUNCT PICK-ONE:ANY:1:1,TBL,LENGTH,CNT,RND,MSG,RFROB
GET TBL,0 >LENGTH
GET TBL,1 >CNT
DEC 'LENGTH
ADD TBL,2 >TBL
MUL CNT,2
ADD TBL,STACK >RFROB
SUB LENGTH,CNT
RANDOM STACK >RND
GET RFROB,RND >MSG
GET RFROB,1
PUT RFROB,RND,STACK
PUT RFROB,1,MSG
INC 'CNT
EQUAL? CNT,LENGTH \?CND1
SET 'CNT,0
?CND1: PUT TBL,0,CNT
RETURN MSG
.FUNCT SETUP-WINDOWS:ANY:0:0,PW,PH,OFF,GOOD?,?TMP1
SET 'PW,BASE-PICTURE-WIDTH
SET 'PH,BASE-PICTURE-HEIGHT
SET 'OFF,6
CALL1 APPLE2?
ZERO? STACK /?CTR2
ZERO? BASE-PICTURE-HEIGHT \?CCL3
?CTR2: PICINF 2,PICINF-TBL /?PRD8
PUSH 0
JUMP ?PRD9
?PRD8: PUSH 1
?PRD9: SET 'GOOD?,STACK
ZERO? GOOD? /?CND1
GET PICINF-TBL,0 >PH
GET PICINF-TBL,1 >PW
SET 'BASE-PICTURE-WIDTH,PW
SET 'BASE-PICTURE-HEIGHT,PH
JUMP ?CND1
?CCL3: SET 'GOOD?,TRUE-VALUE
?CND1: ZERO? GOOD? /?CCL12
CALL1 APPLE2?
ZERO? STACK \?CTR14
EQUAL? INTERPRETER,INT-PC \?CCL15
?CTR14: SET 'OFF,3
JUMP ?CND13
?CCL15: ZERO? BORDER-FLAG \?CND13
SET 'OFF,5
?CND13: ADD PW,CHRH
DIV STACK,CHRH
ADD OFF,STACK >TEXT-WINDOW-LEFT
JUMP ?CND10
?CCL12: SET 'TEXT-WINDOW-LEFT,INIT-TEXT-LEFT
?CND10: SUB COMMAND-START-LINE,TOP-SCREEN-LINE
SUB STACK,1 >?TMP1
SUB SCREEN-WIDTH,TEXT-WINDOW-LEFT
ICALL MAKE-WINDOW,TEXT-WINDOW,TOP-SCREEN-LINE,TEXT-WINDOW-LEFT,?TMP1,STACK
EQUAL? INTERPRETER,INT-PC \?CND19
MARGIN 4,0,TEXT-WINDOW
?CND19: ZERO? BORDER-FLAG /?CCL23
SUB COMMAND-START-LINE,3
MUL STACK,CHRV >GRAPHIC-WINDOW-Y
SUB TEXT-WINDOW-LEFT,3
MUL STACK,CHRH >GRAPHIC-WINDOW-X
JUMP ?CND21
?CCL23: SUB COMMAND-START-LINE,2
MUL STACK,CHRV >GRAPHIC-WINDOW-Y
SUB TEXT-WINDOW-LEFT,2
MUL STACK,CHRH >GRAPHIC-WINDOW-X
?CND21: ZERO? BORDER-FLAG /?CCL26
SUB COMMAND-START-LINE,3 >?TMP1
SUB TEXT-WINDOW-LEFT,3
ICALL MAKE-WINDOW,GRAPHICS-WINDOW,TOP-SCREEN-LINE,TOP-SCREEN-LINE,?TMP1,STACK,11
JUMP ?CND24
?CCL26: SUB COMMAND-START-LINE,2 >?TMP1
SUB TEXT-WINDOW-LEFT,2
ICALL MAKE-WINDOW,GRAPHICS-WINDOW,TOP-SCREEN-LINE,TOP-SCREEN-LINE,?TMP1,STACK,11
?CND24: ZERO? BLACK-PICTURE-BORDER /FALSE
SCREEN GRAPHICS-WINDOW
COLOR 9,2
CLEAR GRAPHICS-WINDOW
RTRUE
.FUNCT WPRINTTAG:ANY:0:0
GRTR? TAG-NAME-LENGTH,0 \?CCL3
ADD NAME-TBL,2
PRINTT STACK,TAG-NAME-LENGTH
RTRUE
?CCL3: CALL2 PRINT-DESC,TAG
RSTACK
.FUNCT WPRINTD:ANY:1:2,OBJ,A
CALL2 PRINT-DESC,OBJ
RSTACK
.FUNCT WCENTER:ANY:1:1,STR,WID,SWID
CALL2 TEXT-WIDTH,STR >WID
SUB SCREEN-WIDTH,TEXT-WINDOW-LEFT
MUL STACK,CHRH >SWID
LESS? WID,SWID \?CCL3
SUB SWID,WID
DIV STACK,2
ADD 1,STACK >SWID
JUMP ?CND1
?CCL3: SET 'SWID,1
?CND1: CURGET CURGET-TABLE
GET CURGET-TABLE,0
CURSET STACK,SWID
GET CENTER-TABLE,0
PRINTT CENTER-TABLE+2,STACK
RTRUE
.FUNCT GRAPHIC-STAMP:ANY:2:4,PIC,WHERE,V,H,CURH,CURW,TOP,LEFT,NEWH,NEWW
GET PICINF-TBL,0 >CURH
GET PICINF-TBL,1 >CURW
SUB GRAPHIC-WINDOW-Y,CURH
DIV STACK,2
ADD STACK,1 >TOP
SUB GRAPHIC-WINDOW-X,CURW
DIV STACK,2
ADD STACK,1 >LEFT
ZERO? WHERE \?CCL3
ASSIGNED? 'V \?CCL3
ASSIGNED? 'H \?CCL3
ADD TOP,V >TOP
ADD LEFT,H >LEFT
JUMP ?CND1
?CCL3: GRTR? WHERE,0 \?CCL8
PICINF WHERE,PICINF-TBL /?BOGUS9
?BOGUS9: GET PICINF-TBL,1
ADD STACK,LEFT >LEFT
GET PICINF-TBL,0
ADD STACK,TOP >TOP
JUMP ?CND1
?CCL8: PICINF PIC,PICINF-TBL /?BOGUS10
?BOGUS10: GET PICINF-TBL,0 >NEWH
GET PICINF-TBL,1 >NEWW
BAND WHERE,STAMP-RIGHT
ZERO? STACK /?CND11
SUB CURW,NEWW
ADD LEFT,STACK >LEFT
?CND11: BAND WHERE,STAMP-BOTTOM
ZERO? STACK /?CND1
SUB CURH,NEWH
ADD TOP,STACK >TOP
?CND1: DISPLAY PIC,TOP,LEFT
RTRUE
.FUNCT GRAPHIC:ANY:0:3,STR,STAMP,WHERE,?TMP1
ZERO? GRAPHICS-FLAG /TRUE
EQUAL? STR,CURRENT-GRAPHIC /TRUE
ZERO? STR \?CCL7
ZERO? STAMP \?CCL7
SET 'STR,CURRENT-GRAPHIC
EQUAL? STR,-1 \?CCL12
ICALL1 CAVERN-GRAPHIC
JUMP ?CND5
?CCL12: SET 'STAMP,CURRENT-STAMP
SET 'WHERE,CURRENT-STAMP-LOC
JUMP ?CND5
?CCL7: ZERO? STR /?CND5
SET 'CURRENT-GRAPHIC,STR
?CND5: SCREEN GRAPHICS-WINDOW
ZERO? STR /?CND14
CLEAR GRAPHICS-WINDOW
?CND14: ZERO? STR /?CND16
EQUAL? STR,-1 /?CND16
GRTR? STR,0 \?CCL22
LESS? STR,255 \?CCL22
PICINF STR,PICINF-TBL \?CND16
GET PICINF-TBL,0
SUB GRAPHIC-WINDOW-Y,STACK
DIV STACK,2
ADD STACK,1 >?TMP1
GET PICINF-TBL,1
SUB GRAPHIC-WINDOW-X,STACK
DIV STACK,2
ADD STACK,1
DISPLAY STR,?TMP1,STACK
JUMP ?CND16
?CCL22: PRINT STR
?CND16: ZERO? STAMP /?CCL29
SET 'CURRENT-STAMP,STAMP
SET 'CURRENT-STAMP-LOC,WHERE
GRTR? STAMP,255 \?CCL32
PRINT STAMP
JUMP ?CND27
?CCL32: PICINF CURRENT-GRAPHIC,PICINF-TBL \?CND27
ICALL GRAPHIC-STAMP,STAMP,WHERE
JUMP ?CND27
?CCL29: SET 'CURRENT-STAMP,FALSE-VALUE
?CND27: SCREEN TEXT-WINDOW
RTRUE
.FUNCT SELECT-SCREEN:ANY:1:1,N
SCREEN N
SET 'CURRENT-SCREEN,N
RETURN CURRENT-SCREEN
.FUNCT I/WE:ANY:0:2,N,CAPS?
ASSIGNED? 'N /?CND1
SET 'N,1
?CND1: GRTR? PARTY-MAX,N \?CCL5
ZERO? CAPS? /?CCL8
RETURN STR?1
?CCL8: RETURN STR?2
?CCL5: RETURN STR?3
.FUNCT I-WAS/WE-WERE:ANY:0:1,N
ASSIGNED? 'N /?CND1
SET 'N,1
?CND1: GRTR? PARTY-MAX,N \?CCL5
RETURN STR?4
?CCL5: RETURN STR?5
.FUNCT I/EACH:ANY:0:1,N
ASSIGNED? 'N /?CND1
SET 'N,1
?CND1: GRTR? PARTY-MAX,N \?CCL5
RETURN STR?6
?CCL5: RETURN STR?3
.FUNCT MY/OUR:ANY:0:1,N
ASSIGNED? 'N /?CND1
SET 'N,1
?CND1: GRTR? PARTY-MAX,N \?CCL5
RETURN STR?7
?CCL5: RETURN STR?8
.FUNCT ME/US:ANY:0:1,N
ASSIGNED? 'N /?CND1
SET 'N,1
?CND1: GRTR? PARTY-MAX,N \?CCL5
RETURN STR?9
?CCL5: RETURN STR?10
.FUNCT PRINT-DESC:ANY:1:2,OBJ,CMD?
EQUAL? OBJ,TAG-OBJECT,TAG \?CCL3
ZERO? TAG-NAME-LENGTH /?CCL3
ADD NAME-TBL,2
PRINTT STACK,TAG-NAME-LENGTH
RTRUE
?CCL3: ZERO? CMD? \?CCL7
GETP OBJ,P?SDESC
PRINT STACK
RTRUE
?CCL7: CALL2 GET-DESC,OBJ
PRINT STACK
RTRUE
.FUNCT GET-DESC:ANY:1:1,OBJ,STR
LESS? SCREEN-WIDTH,8-WIDTH \?CCL3
GETP OBJ,P?8DESC >STR
ZERO? STR /?CCL3
RETURN STR
?CCL3: LESS? SCREEN-WIDTH,12-WIDTH \?CCL7
GETP OBJ,P?12DESC >STR
ZERO? STR /?CCL7
RETURN STR
?CCL7: GETP OBJ,P?SDESC
RSTACK
.FUNCT PRINT-COMMAND:ANY:1:1,CMD
CALL2 GET-COMMAND,CMD
PRINT STACK
RTRUE
.FUNCT GET-COMMAND:ANY:1:1,CMD,STR
LESS? COMMAND-WIDTH,12 \?CCL3
GET CMD,COMMAND-ASTR >STR
ZERO? STR /?CCL3
RETURN STR
?CCL3: GET CMD,COMMAND-FULL
RSTACK
.FUNCT SINGLE-MOVE-GRAPHIC:ANY:1:1,G
SET 'SAVED-GRAPHIC,CURRENT-GRAPHIC
SET 'SAVED-GRAPHIC-ROOM,HERE
ICALL2 GRAPHIC,G
CALL QUEUE,I-CLEAR-SINGLE-MOVE-GRAPHIC,1
RSTACK
.FUNCT ANONF-1:ANY:0:0
EQUAL? HERE,SAVED-GRAPHIC-ROOM \FALSE
CALL2 GRAPHIC,SAVED-GRAPHIC
RSTACK
.ENDSEG
.ENDI