-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamesys.ga
726 lines (648 loc) · 23.9 KB
/
gamesys.ga
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
; A simple "game" created to demonstrate a complex program written using
; glulx-assemble.
;
; This is the game system library; the game specific code is located in
; "mountain.ga". "GameSys" was created as a very simple demonstration of
; creating a moderately complex program using glulx-assemble. In its current
; form, GameSys lacks depth of implementation.
;
; Part of glulx-assemble
; Copyright (C) 2018 Gren Drake
; Released under the MIT license (see LICENSE.md)
.include "glk.ga"
.define MAJOR_VERSION 0
.define MINOR_VERSION 4
.define TRUE 1
.define FALSE 0
.define VERB_ONEWORD 0
.define VERB_TWOWORD 1
.define VERB_EITHER 2
.define NORTH 0
.define EAST 1
.define SOUTH 2
.define WEST 3
.define OBJ_PARENT 0
.define OBJ_CHILD 1
.define OBJ_SIBLING 2
.define OBJ_FLAGS 3
.define OBJ_FIRST_PROPERTY 16
.define OBJ_PROPERTY_SIZE 8
.define PROP_NAME 1000
.define PROP_DESCRIPTION 1001
.define PROP_NORTH 1002
.define PROP_EAST 1003
.define PROP_SOUTH 1004
.define PROP_WEST 1005
.define PROP_VOCAB 1006
.define PROP_BEFORE 1007
.define OF_STATIC 1
.define OF_CONCEAL 2
location: .zero 4
mainWindow: .zero 4
event: .zero 16
commandbuf: .zero 256
firstWord: .zero 4
secondWord: .zero 4
theNoun: .zero 4
itNoun: .zero 4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dropWord: .cstring "drop"
eWord: .cstring "e"
eastWord: .cstring "east"
examineWord: .cstring "examine"
getWord: .cstring "get"
goWord: .cstring "go"
helpWord: .cstring "help"
iWord: .cstring "i"
invWord: .cstring "inv"
inventoryWord: .cstring "inventory"
itWord: .cstring "it"
lWord: .cstring "l"
lookWord: .cstring "look"
meWord: .cstring "me"
nWord: .cstring "n"
northWord: .cstring "north"
playerWord: .cstring "player"
qWord: .cstring "q"
quitWord: .cstring "quit"
sWord: .cstring "s"
southWord: .cstring "south"
takeWord: .cstring "take"
versionWord: .cstring "version"
wWord: .cstring "w"
westWord: .cstring "west"
xWord: .cstring "x"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.define VOCAB_ENTRY_SIZE 12
vocabTable:
.word dropWord verbDrop VERB_TWOWORD
.word examineWord verbLook VERB_TWOWORD
.word getWord verbTake VERB_TWOWORD
.word goWord verbGo VERB_TWOWORD
.word helpWord verbHelp VERB_ONEWORD
.word iWord verbInventory VERB_ONEWORD
.word invWord verbInventory VERB_ONEWORD
.word inventoryWord verbInventory VERB_ONEWORD
.word lookWord verbLook VERB_EITHER
.word lWord verbLook VERB_EITHER
.word qWord verbQuit VERB_ONEWORD
.word quitWord verbQuit VERB_ONEWORD
.word takeWord verbTake VERB_TWOWORD
.word versionWord verbVersion VERB_ONEWORD
.word xWord verbLook VERB_TWOWORD
.word 0 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.define DIRECTION_ENTRY_SIZE 8
directionTable:
.word nWord PROP_NORTH
.word northWord PROP_NORTH
.word sWord PROP_SOUTH
.word southWord PROP_SOUTH
.word eWord PROP_EAST
.word eastWord PROP_EAST
.word wWord PROP_WEST
.word westWord PROP_WEST
.word 0 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
player_name: .encoded "(player)"
player_desc: .encoded "You look the same as always."
player_vocab: .word meWord playerWord 0
player:
.word 0 0 0 OF_CONCEAL ; parent child sibling flags
.word PROP_NAME player_name
.word PROP_DESCRIPTION player_desc
.word PROP_VOCAB player_vocab
.word 0 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getChild: .function forObject
aload forObject, OBJ_CHILD, sp
return sp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getParent: .function forObject
aload forObject, OBJ_PARENT, sp
return sp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getSibling: .function forObject
aload forObject, OBJ_SIBLING, sp
return sp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getProperty: .function forObject propId thisPropId propAddr
add forObject, OBJ_FIRST_PROPERTY, propAddr
getProperty_loop:
aload propAddr, 0, thisPropId
jz thisPropId, getProperty_notFound
jeq propId, thisPropId, getProperty_found
add propAddr, OBJ_PROPERTY_SIZE, propAddr
jump getProperty_loop
getProperty_found:
aload propAddr, 1, sp
return sp
getProperty_notFound:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getUnconcealedChild: .function forObject curChild
aload forObject, OBJ_CHILD, curChild
getUnconcealedChild_loop:
callfii objectHasFlag, curChild, OF_CONCEAL, sp
jz sp, getUnconcealedChild_found
jeq curChild, 0, getUnconcealedChild_failed
aload curChild, OBJ_SIBLING, curChild
jump getUnconcealedChild_loop
getUnconcealedChild_found:
return curChild
getUnconcealedChild_failed:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getUnconcealedSibling: .function forObject curChild
aload forObject, OBJ_SIBLING, curChild
getUnconcealedSibling_loop:
callfii objectHasFlag, curChild, OF_CONCEAL, sp
jz sp, getUnconcealedSibling_found
jeq curChild, 0, getUnconcealedSibling_failed
aload curChild, OBJ_SIBLING, curChild
jump getUnconcealedSibling_loop
getUnconcealedSibling_found:
return curChild
getUnconcealedSibling_failed:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objectContains: .function forParent maybeChild curChild
aload forParent, OBJ_CHILD, curChild
objectContains_loop:
jz curChild, objectContains_no
jeq curChild, maybeChild, objectContains_yes
aload curChild, OBJ_SIBLING, curChild
jump objectContains_loop
objectContains_yes:
return TRUE
objectContains_no:
return FALSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objectForVocab: .function vocabWord fromScope curChild subChild
objectForVocab_at:
callfi getChild, fromScope, curChild
objectForVocab_atLoop:
jz curChild, objectForVocab_cantSee
callfii wordInVocab, curChild, vocabWord, sp
jnz sp, objectForVocab_found
aload curChild, OBJ_CHILD, sp
jz sp, objectForVocab_noSubChild
callfii objectForVocab, vocabWord, curChild, subChild
jnz subChild, objectForVocab_foundSubChild
objectForVocab_noSubChild:
callfi getSibling, curChild, curChild
jump objectForVocab_atLoop
objectForVocab_foundSubChild:
return subChild
objectForVocab_found:
return curChild
objectForVocab_cantSee:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objectHasFlag: .function forObject flags oFlags
aload forObject, OBJ_FLAGS, oFlags
bitand flags, oFlags, sp
jeq sp, flags, objectHasFlag_yes
return FALSE
objectHasFlag_yes:
return TRUE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objListString: .encoded ", "
objectListFrom: .function theObject nextObject
jz theObject, objectListFrom_allDone
objectListFrom_loop:
callfi printObject, theObject, 0
callfi getUnconcealedSibling, theObject, nextObject
jz nextObject, objectListFrom_allDone
streamstr objListString
copy nextObject, theObject
jump objectListFrom_loop
objectListFrom_allDone:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objectMove: .function toMove toWhere curChild nextChild
callfi objectRemove, toMove, 0
astore toMove, OBJ_PARENT, toWhere
aload toWhere, OBJ_CHILD, curChild
jz curChild, objectMove_firstChild
objectMove_loop:
aload curChild, OBJ_SIBLING, nextChild
jz nextChild, objectMove_sibling
copy nextChild, curChild
jump objectMove_loop
objectMove_sibling:
astore curChild ,OBJ_SIBLING, toMove
return 0
objectMove_firstChild:
astore toWhere, OBJ_CHILD, toMove
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
objectRemove: .function toRemove curChild nextChild fromParent
aload toRemove, OBJ_PARENT, fromParent
jz fromParent, objectRemove_allDone ; already located nowhere
astore toRemove, OBJ_PARENT, 0
aload fromParent, OBJ_CHILD, curChild
jeq curChild, toRemove, objectRemove_firstChild
objectRemove_searchChildList:
aload curChild, OBJ_SIBLING, nextChild
jz nextChild, objectRemove_allDone ; broken object list / not a sibling
jeq nextChild, toRemove, objectRemove_removeHere
copy nextChild, curChild
jump objectRemove_searchChildList
objectRemove_removeHere:
aload toRemove, OBJ_SIBLING, sp
astore curChild, OBJ_SIBLING, sp
astore toRemove, OBJ_SIBLING, 0
return 0
objectRemove_firstChild:
aload toRemove, OBJ_SIBLING, sp
astore fromParent, OBJ_CHILD, sp
astore toRemove, OBJ_SIBLING, 0
return 0
objectRemove_allDone:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printCString: .function text pos here
copy 0, pos
printCString_loop:
aloadb text, pos, here
jeq here, 0, printCString_doneString
streamchar here
add pos, 1, pos
jump printCString_loop
printCString_doneString:
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printObject_unnamedStart: .encoded "(object local_"
printObject_unnamedEnd: .encoded ")"
printObject: .function forObject theName
callfii getProperty, forObject, PROP_NAME, theName
jz theName, printObject_unnamed
streamstr theName
return 0
printObject_unnamed:
streamstr printObject_unnamedStart
streamnum forObject
streamstr printObject_unnamedEnd
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setupGlk: .function
setiosys ioSysGlk, 0
copy 0, sp
copy wintypeTextBuffer, sp
copy 0, sp
copy 0, sp
copy 0, sp
glk $23, 5, &mainWindow
copy &mainWindow, sp
glk glkSetWindow, 1, 0
return TRUE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
strcmp: .function left right pos left_c right_c
copy 0, pos
strcmp_loop:
aloadb left ,pos, left_c
aloadb right ,pos, right_c
jlt left_c, right_c, strcmp_lessthan
jgt left_c, right_c, strcmp_greaterthan
add 1, pos ,pos
jne left_c, 0, strcmp_loop
return 0
strcmp_lessthan:
return -1
strcmp_greaterthan:
return 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wordInVocab: .function forObject wordAddr vocabList wordNo vocabWord
callfii getProperty, forObject, PROP_VOCAB, vocabList
jz vocabList, wordInVocab_no
wordInVocab_loop:
aload vocabList, wordNo, vocabWord
jz vocabWord, wordInVocab_no
callfii strcmp, wordAddr, vocabWord, sp
jz sp, wordInVocab_yes
add wordNo, 1, wordNo
jump wordInVocab_loop
wordInVocab_yes:
return TRUE
wordInVocab_no:
return FALSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
unexpectedEventString: .encoded "Received unexpected GLK event\n"
unknownCommandString: .encoded "Unknown command \""
unknownCommandEndString:.encoded "\".\n"
blankCommandString: .encoded "Huh?\n"
promptString: .encoded "\n> "
tooManyWordsString: .encoded "You used too many words for this game to understand.\n"
oneWordString: .encoded "That command only needs one word.\n"
twoWordString: .encoded "That command needs two words.\n"
; run the main program loop
start: .function local_0 local_1 local_2
callf setupGlk, 0
callf initialise, 0
callf verbVersion, 0
streamchar 10
callf verbLookAround, 0
start_mainLoopBegin:
streamstr promptString;
mzero 32, commandbuf
copy 0, sp
copy 255, sp
copy commandbuf, sp
copy &mainWindow, sp
glk glkRequestLineEvent, 4, 0
start_inputLoop:
copy event, sp
glk glkSelect, 1, 0
jeq &event, evtypeArrange, start_evWindowArrange
jeq &event, evtypeLineInput, start_evLineInput
streamstr unexpectedEventString
jump start_inputLoop
start_evWindowArrange:
jump start_inputLoop
start_evLineInput:
aload event, 1, local_0
jne local_0, &mainWindow, start_inputLoop
; commandbuf now contains a line of input from the main window.
; The line we have received in commandbuf is not null-terminated.
; We handle that first.
aload event, 2, local_0
astoreb commandbuf, local_0, 0
; Then squash to lower-case. (this does not use the newer unicode aware
; functions... oh well)
copy 0, local_0
start_inputCaseLoop:
aloadb commandbuf, local_0, local_1
jeq local_1, 0, start_endCaseLoop
copy local_1, sp
glk glkCharToLower, 1, local_1
astoreb commandbuf, local_0, local_1
add local_0, 1, local_0
jump start_inputCaseLoop
start_endCaseLoop:
; find and isolate the first two words of input
copy 0, &firstWord
copy 0, &secondWord
copy 0, local_0
start_findStartOfFirstWord:
aloadb commandbuf, local_0, local_1
jeq local_1, 0, start_endOfCommandString ; found end of string
jne local_1, ' ', start_foundStartOfFirstWord ; found the start of the word!
add local_0, 1, local_0
jump start_findStartOfFirstWord ; otherwise skip the space
start_foundStartOfFirstWord:
add local_0, commandbuf, &firstWord
start_findEndOfFirstWord:
add local_0, 1, local_0
aloadb commandbuf, local_0, local_1
jeq local_1, 0, start_foundEndOfFirstWord
jeq local_1, ' ', start_foundEndOfFirstWord
jump start_findEndOfFirstWord
start_foundEndOfFirstWord:
astoreb commandbuf, local_0, 0
jeq local_1, 0, start_endOfCommandString
add local_0, 1, local_0
start_findStartOfSecondWord:
aloadb commandbuf, local_0, local_1
jeq local_1, 0, start_endOfCommandString
jne local_1, ' ', start_foundStartOfSecondWord
add local_0, 1, local_0
jump start_findStartOfSecondWord
start_foundStartOfSecondWord:
add local_0, commandbuf, &secondWord
start_findEndOfSecondWord:
add local_0, 1, local_0
aloadb commandbuf, local_0, local_1
jeq local_1, 0, start_foundEndOfSecondWord
jeq local_1, ' ', start_foundEndOfSecondWord
jump start_findEndOfSecondWord
start_foundEndOfSecondWord:
astoreb commandbuf, local_0, 0
jump start_endOfCommandString
start_endOfCommandString:
jeq &firstWord, 0, start_emptyVerb
copy vocabTable, local_0
start_verbSearchLoop:
aload local_0, 0, local_1
jeq local_1, 0, start_badVerb
callfii strcmp, &firstWord, local_1, local_2
jeq local_2, 0, start_foundVerb
add local_0, VOCAB_ENTRY_SIZE, local_0
jump start_verbSearchLoop
start_emptyVerb:
streamstr blankCommandString
jump start_mainLoopBegin
start_badVerb:
streamstr unknownCommandString
callfi printCString, &firstWord, 0
streamstr unknownCommandEndString
jump start_mainLoopBegin
start_tooManyWords:
streamstr tooManyWordsString
jump start_mainLoopBegin
start_foundVerb:
copy 0, &theNoun
aload local_0, 2, local_1
jeq local_1, VERB_EITHER, start_commandGood
jeq local_1, VERB_ONEWORD, start_oneWordCommand
jnz &secondWord, start_commandGood
streamstr twoWordString
jump start_mainLoopBegin
start_oneWordCommand:
jz &secondWord, start_commandGood
streamstr oneWordString
jump start_mainLoopBegin
start_commandGood:
aload local_0, 1, local_0
jz &secondWord, start_skipFindNoun
callfii strcmp, &secondWord, itWord, sp
jz sp, start_handleIt
callfii objectForVocab, &secondWord, &location, &theNoun
jz &theNoun, start_skipFindNoun
callfii getProperty, &theNoun, PROP_BEFORE, local_2
jz local_2, start_skipFindNoun
start_findBeforeLoop:
aload local_2, 0, local_1
jz local_1, start_skipFindNoun
jeq local_1, local_0, start_runBefore
add local_2, 8, local_2
jump start_findBeforeLoop
noItWordString: .string "\"It\" currently does not refer to anything.\n"
start_handleIt:
jz &itNoun, start_noItWord
copy &itNoun, &theNoun
jump start_skipFindNoun
start_noItWord:
streamstr noItWordString
jump start_mainLoopBegin
start_runBefore:
aload local_2, 1, local_1
callf local_1, sp
jnz sp, start_mainLoopBegin
start_skipFindNoun:
jz &theNoun, start_dontSetIt
copy &theNoun, &itNoun
start_dontSetIt:
callf local_0, 0
jump start_mainLoopBegin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
droppedString: .encoded "Dropped.\n";
notHoldingThatString: .encoded "You aren't holding that.\n"
verbDrop: .function
jz &theNoun, verbDrop_notHolding
callfii objectContains, player, &theNoun, sp
jz sp, verbDrop_notHolding
aload player, OBJ_PARENT, sp
callfii objectMove, &theNoun, &location, 0
streamstr droppedString
return 0
verbDrop_notHolding:
streamstr notHoldingThatString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
badDirString: .encoded "Not a valid direction.\n"
cantGoString: .encoded "Can't go that way.\n"
verbGo: .function curDir dirWord target
copy directionTable, curDir
verbGo_loop:
aload curDir, 0, dirWord
jz dirWord, verbGo_badDir
callfii strcmp, &secondWord, dirWord, sp
jz sp, verbGo_foundDir
add curDir, DIRECTION_ENTRY_SIZE, curDir
jump verbGo_loop
verbGo_foundDir:
aload curDir, 1, curDir
callfii getProperty, &location, curDir, target
jz target, verbGo_cantGo
copy target, &location
callfii objectMove, player, target, 0
callf verbLookAround, 0
return 0
verbGo_cantGo:
streamstr cantGoString
return 0
verbGo_badDir:
streamstr badDirString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
verbHelp: .function
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
youAreHoldingString: .encoded "You are holding: "
holdingNothingString: .encoded "nothing.\n"
verbInventory: .function curChild
streamstr youAreHoldingString
callfi getChild, player, curChild
jz curChild, verbInventory_nothing
callfi objectListFrom, curChild, 0
streamstr endObjListString
return 0
verbInventory_nothing:
streamstr holdingNothingString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cantSeeThatString: .encoded "You can't see that here.\n"
nothingSpecialString: .encoded "You see nothing special about that.\n"
verbLook: .function tmp
jnz &secondWord, verbLook_at
callf verbLookAround, 0
return 0;
verbLook_at:
jz &theNoun, verbLook_cantSee
callfii getProperty, &theNoun, PROP_DESCRIPTION, tmp
jz tmp, verbLook_nodesc
streamstr tmp
streamchar 10
jump verbLook_done
verbLook_nodesc:
streamstr nothingSpecialString
verbLook_done:
return 0
verbLook_cantSee:
streamstr cantSeeThatString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
preNameString: .encoded "& "
postNameString: .encoded " &\n"
youCanSeeString: .encoded "\nYou can see here: "
nowhereLocationString: .encoded "& Nowhere &\nYou are nowhere!\n"
endObjListString: .encoded ".\n"
verbLookAround: .function curChild tmp
jz &location, verbLook_nowhere
streamstr preNameString
copy styleSubheader, sp
glk glkSetStyle, 1, 0
callfi printObject, &location, 0
copy styleNormal, sp
glk glkSetStyle, 1, 0
streamstr postNameString
callfii getProperty, &location, PROP_DESCRIPTION, tmp
jz tmp, verbLookAround_nodesc
streamstr tmp
streamchar 10
verbLookAround_nodesc:
callfi getUnconcealedChild, &location, curChild
jz curChild, verbLookAround_done
streamstr youCanSeeString
callfi objectListFrom, curChild, 0
streamstr endObjListString
verbLookAround_done:
return 0
verbLook_nowhere:
streamstr nowhereLocationString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
verbQuit: .function
glk glkExit, 0, 0
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
takenString: .encoded "Taken.\n";
cantTakeSelfString: .encoded "Can't take yourself.\n"
cantTakeThatString: .encoded "Can't take that.\n"
alreadyHoldingThatString: .encoded "Already holding that.\n"
verbTake: .function
jz &theNoun, verbTake_cantSee
jeq &theNoun, player, verbTake_cantTakeSelf
callfii objectHasFlag, &theNoun, OF_STATIC, sp
jnz sp, verbTake_cantTakeThat
callfii objectContains, player, &theNoun, sp
jnz sp, verbTake_alreadyHolding
callfii objectMove, &theNoun, player, 0
streamstr takenString
return 0
verbTake_alreadyHolding:
streamstr alreadyHoldingThatString
return 0
verbTake_cantTakeThat:
streamstr cantTakeThatString
return 0
verbTake_cantTakeSelf:
streamstr cantTakeSelfString
return 0
verbTake_cantSee:
streamstr cantSeeThatString
return 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
versionString: .encoded "glulx-assemble GameSys library version "
verbVersion: .function
copy styleHeader, sp
glk glkSetStyle, 1, 0
streamstr gamenameString
copy styleNormal, sp
glk glkSetStyle, 1, 0
streamchar 10
streamstr headlineString
streamchar 10
copy styleEmphasized, sp
glk glkSetStyle, 1, 0
streamstr versionString
streamnum MAJOR_VERSION
streamchar '.'
streamnum MINOR_VERSION
streamchar 10
copy styleNormal, sp
glk glkSetStyle, 1, 0
return 0