10 REM >ADVENTURE
20 REM THE LOST AMULET - a text adventure
30 REM for the BBC Microcomputer Model B
35 REM By CLAUDE AI 31/07/2026
40 MODE 7
50 PROCsetup
60 PROCtitle
70 REPEAT
80 PROCturn
90 UNTIL FINISHED%=1
92 PRINT
94 PRINT "Thanks for playing!"
96 END
100 DEF PROCsetup
110 DIM RM$(8),EXN(8),EXS(8),EXE(8),EXW(8)
120 DIM OBJ$(4),OBJLOC(4)
130 FOR I%=1 TO 8
140 READ RM$(I%)
150 NEXT I%
160 FOR I%=1 TO 8
170 READ EXN(I%),EXS(I%),EXE(I%),EXW(I%)
180 NEXT I%
190 FOR I%=1 TO 4
200 READ OBJ$(I%),OBJLOC(I%)
210 NEXT I%
220 ROOM%=1
230 DOORLOCKED%=1
240 FINISHED%=0
250 MOVES%=0
260 ENDPROC
300 DEF PROCtitle
310 CLS
320 PRINT "*** THE LOST AMULET ***"
330 PRINT
340 PRINT "A cave adventure for the BBC Microcomputer"
350 PRINT
360 PRINT "Find the Golden Amulet hidden deep in the caves"
370 PRINT "and bring it safely back out into the daylight."
380 PRINT
390 PRINT "Type HELP at any time for a list of commands."
400 PRINT
410 ENDPROC
500 DEF PROCturn
510 PROClook
520 REPEAT
530 INPUT "> "A$
540 UNTIL A$<>""
550 SP%=INSTR(A$," ")
560 IF SP%=0 THEN VERB$=A$ ELSE VERB$=LEFT$(A$,SP%-1)
570 IF SP%=0 THEN NOUN$="" ELSE NOUN$=MID$(A$,SP%+1)
580 VERB$=FNupper$(VERB$)
590 NOUN$=FNupper$(NOUN$)
600 IF VERB$="N" OR VERB$="NORTH" THEN PROCmove("N"):ENDPROC
605 IF VERB$="S" OR VERB$="SOUTH" THEN PROCmove("S"):ENDPROC
610 IF VERB$="E" OR VERB$="EAST" THEN PROCmove("E"):ENDPROC
615 IF VERB$="W" OR VERB$="WEST" THEN PROCmove("W"):ENDPROC
620 IF VERB$="LOOK" OR VERB$="L" THEN ENDPROC
625 IF VERB$="GET" OR VERB$="TAKE" THEN PROCget(NOUN$):ENDPROC
630 IF VERB$="DROP" THEN PROCdrop(NOUN$):ENDPROC
635 IF VERB$="INV" OR VERB$="INVENTORY" OR VERB$="I" THEN PROCinv:ENDPROC
640 IF VERB$="HELP" OR VERB$="?" THEN PROChelp:ENDPROC
642 IF VERB$="OUT" THEN PROCtryexit:ENDPROC
644 IF VERB$="QUIT" THEN PRINT "You abandon your quest and leave the cave forever.":FINISHED%=1:ENDPROC
646 PRINT "I don't understand '";A$;"'. Type HELP for a list of commands."
650 ENDPROC
700 DEF PROCmove(D$)
705 LOCAL T%
710 IF D$="N" THEN T%=EXN(ROOM%)
715 IF D$="S" THEN T%=EXS(ROOM%)
720 IF D$="E" THEN T%=EXE(ROOM%)
725 IF D$="W" THEN T%=EXW(ROOM%)
730 IF T%=0 THEN PRINT "You can't go that way.":ENDPROC
735 IF T%=8 AND DOORLOCKED%=1 THEN PROCtrygate:ENDPROC
740 IF T%=6 AND OBJLOC(2)<>0 THEN PRINT "It's pitch dark that way - you need a light source.":ENDPROC
745 ROOM%=T%
750 MOVES%=MOVES%+1
755 ENDPROC
820 DEF PROCtrygate
825 IF OBJLOC(1)<>0 THEN PRINT "The gate is locked fast. Perhaps a key would help.":ENDPROC
830 PRINT "You unlock the gate with the rusty key and step through."
835 DOORLOCKED%=0
840 ROOM%=8
845 MOVES%=MOVES%+1
850 ENDPROC
900 DEF PROClook
905 PRINT
910 PRINT RM$(ROOM%)
915 PROClistobjects
920 ENDPROC
925 DEF PROClistobjects
930 LOCAL I%,N%
935 N%=0
940 FOR I%=1 TO 4
945 IF OBJLOC(I%)=ROOM% THEN N%=N%+1
950 NEXT I%
955 IF N%=0 THEN ENDPROC
960 PRINT "You can see: ";
965 FOR I%=1 TO 4
970 IF OBJLOC(I%)=ROOM% THEN PRINT OBJ$(I%);" ";
975 NEXT I%
980 PRINT
985 ENDPROC
1100 DEF PROCget(N$)
1105 LOCAL I%,F%
1110 IF N$="" THEN PRINT "Get what?":ENDPROC
1115 F%=0
1120 FOR I%=1 TO 4
1125 IF OBJ$(I%)=N$ AND OBJLOC(I%)=ROOM% THEN F%=I%
1130 NEXT I%
1135 IF F%=0 THEN PRINT "I don't see that here.":ENDPROC
1140 IF FNcarried>=3 THEN PRINT "You are carrying as much as you can manage.":ENDPROC
1145 OBJLOC(F%)=0
1150 PRINT "You pick up the ";OBJ$(F%);"."
1155 ENDPROC
1300 DEF FNcarried
1305 LOCAL I%,C%
1310 C%=0
1315 FOR I%=1 TO 4
1320 IF OBJLOC(I%)=0 THEN C%=C%+1
1325 NEXT I%
1330 =C%
1400 DEF PROCdrop(N$)
1405 LOCAL I%,F%
1410 IF N$="" THEN PRINT "Drop what?":ENDPROC
1415 F%=0
1420 FOR I%=1 TO 4
1425 IF OBJ$(I%)=N$ AND OBJLOC(I%)=0 THEN F%=I%
1430 NEXT I%
1435 IF F%=0 THEN PRINT "You are not carrying that.":ENDPROC
1440 OBJLOC(F%)=ROOM%
1445 PRINT "You drop the ";OBJ$(F%);"."
1450 ENDPROC
1600 DEF PROCinv
1605 LOCAL I%,N%
1610 N%=0
1615 PRINT "You are carrying: ";
1620 FOR I%=1 TO 4
1625 IF OBJLOC(I%)=0 THEN PRINT OBJ$(I%);" ";:N%=N%+1
1630 NEXT I%
1635 IF N%=0 THEN PRINT "nothing";
1640 PRINT
1645 ENDPROC
1700 DEF PROChelp
1705 PRINT "Commands understood:"
1710 PRINT "  N S E W     - move in that direction"
1715 PRINT "  LOOK        - look around again"
1720 PRINT "  GET <item>  - pick up an item"
1725 PRINT "  DROP <item> - put down an item"
1730 PRINT "  INV         - list what you are carrying"
1735 PRINT "  OUT         - leave the cave (from the cave mouth)"
1737 PRINT "  QUIT        - give up and end the game"
1740 ENDPROC
1800 DEF PROCtryexit
1805 IF ROOM%<>1 THEN PRINT "You must return to the cave mouth before you can leave.":ENDPROC
1810 IF OBJLOC(3)<>0 THEN PRINT "You step outside, but without the Amulet your quest is unfinished.":FINISHED%=1:ENDPROC
1815 PRINT
1820 PRINT "You step out into the sunlight, the Golden Amulet held high!"
1825 PRINT "*** YOU HAVE WON! ***"
1830 PRINT "You escaped the caves in ";MOVES%;" moves."
1835 FINISHED%=1
1840 ENDPROC
2000 DEF FNupper$(A$)
2005 LOCAL I%,C%,B$
2010 B$=""
2015 FOR I%=1 TO LEN(A$)
2020 C%=ASC(MID$(A$,I%,1))
2025 IF C%>=97 AND C%<=122 THEN C%=C%-32
2030 B$=B$+CHR$(C%)
2035 NEXT I%
2040 =B$
9000 DATA "You are standing at the mouth of a dark cave. Daylight shines behind you to the south. A passage leads north into the darkness."
9010 DATA "You are in a winding passage. Tunnels lead north and east, and the cave mouth lies to the south."
9020 DATA "You are in a damp, dead-end cavern. Water drips steadily from the ceiling."
9030 DATA "You are in a small side chamber cut into the rock. A passage continues north."
9040 DATA "You are in a flooded dead-end tunnel. The water is icy cold. A passage leads east."
9050 DATA "Your torch lights up a rough-hewn chamber. Passages lead south, east and west."
9060 DATA "You stand before a rusted iron gate set into the rock. A passage leads west."
9070 DATA "You have entered a small treasure room. Ancient gold glints all around you."
9100 DATA 2,0,0,0
9110 DATA 3,1,4,0
9120 DATA 0,2,0,0
9130 DATA 6,0,0,2
9140 DATA 0,0,6,0
9150 DATA 0,4,7,5
9160 DATA 8,0,0,6
9170 DATA 0,7,0,0
9200 DATA "KEY",3
9210 DATA "TORCH",4
9220 DATA "AMULET",8
9230 DATA "SWORD",5
