--- title: "Quest" id: 64772 type: "computer_media" slug: "quest" url: "http://localhost/computer_media/quest/" markdown_url: "http://localhost/computer_media/quest.md" published_at: "2026-03-08T00:27:13+00:00" modified_at: "2026-03-30T21:44:52+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/03/Quest.png" excerpt: "A full 42-location pirate treasure hunt where the map is encoded in a compact DATA table and a roaming antagonist can snatch your hard-won loot." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 64715 title: "Miscellaneous Programs" type: "computer_media" url: "http://localhost/computer_media/miscellaneous-programs/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/03/Quest.png" media_type_tags: "Game" --- # Quest QUEST is a text-based cave exploration and treasure-hunting adventure game. The player navigates a network of 42 locations encoded in a compact DATA table, searching for a pirate’s hidden treasure while avoiding a roaming Pirate antagonist. Movement is controlled by single-letter compass directions (N, S, E, W, U, D) with the input handler examining only the first character of any typed response. The map data encodes directional exits, random-movement probabilities, and special flags directly into a two-dimensional array, with values above 500 indicating pause-and-retry loops and values in the 100–299 range triggering conditional branching based on whether the treasure is carried. *** ## Program Structure 1. **Lines 100–210:** Introduction and story text. 2. **Lines 300–310:** Read symbolic constants (V0=0, V1=1, V2=2, V3=3, M9=42, T1=23, T2=12, SITE=8400) from DATA using Spectrum math expressions. 3. **Lines 500–570:** Allocate and populate the `m(6,42)` map array and `w(42)` visited-rooms array from DATA, with integrity checking via subroutine 9500. 4. **Lines 900–920:** Print control instructions, then enter initial setup. 5. **Lines 1000–1090:** Reset game state: move counter, treasure location, pirate counter, visited array. 6. **Lines 1400–1500:** Main game loop calling movement (6000), treasure-found (2000), and pirate (4000) subroutines. 7. **Lines 1700–1792:** End-game scoring, play-again prompt. 8. **Lines 2000–2430:** Treasure-found logic with accept/leave choice. 9. **Lines 3000–3050:** Score calculation. 10. **Lines 4000–4210:** Pirate antagonist logic. 11. **Lines 5000–5145:** Generic first-character input sorter. 12. **Lines 6000–6800:** Movement engine with special-value decoding. 13. **Lines 7000–7500:** Direction input and score-on-demand handler. 14. **Lines 8000–8600:** Location description dispatcher and treasure/pirate-note printing. 15. **Lines 9011–9421:** Individual room description PRINT statements, each ending with `GO TO site` (i.e., `GO TO 8400`). 16. **Lines 9450–9490:** Map DATA (7 values per room: room index + 6 exits). 17. **Lines 9500–9610:** Error handler and invalid-direction handler. ## Symbolic Constant Idiom Rather than embedding bare numeric literals, the program reads frequently used small integers from a DATA statement using Spectrum built-in math: | Variable | Expression in DATA | Value | Role | | --- | --- | --- | --- | | `V1` | `SGN PI` | 1 | Used as 1 throughout | | `V0` | `NOT PI` | 0 | Used as 0 / false | | `V2` | `2` | 2 | Used as 2 | | `V3` | `INT PI` | 3 | Used as 3 | | `M9` | `42` | 42 | Number of rooms | | `T1` | `23` | 23 | Initial treasure room | | `T2` | `12` | 12 | Pirate’s home room | | `SITE` | `8400` | 8400 | Post-description jump target | In the DATA lines themselves (9450 onwards), the symbolic names `V1`, `V2`, `V3`, `V0` appear as literals—they are not evaluated at DATA-read time. The DATA loader at lines 520–570 reads a raw numeric value into `m` and uses `GO SUB 9500` if the room index doesn’t match. The actual DATA values for exits use plain integers including negative values like `-V2` (i.e., -2) which serve as a sentinel meaning “no exit” or “loop”. ## Map Encoding and Movement Engine Each room occupies 7 DATA values: the room number for integrity checking, then six directional exits (N, E, U, D, W, S). Exit values are interpreted by the movement engine (lines 6130–6730) according to ranges: - **-2:** Sentinel; triggers a conditional re-read from another map cell (used for random/special rooms). - **≥500:** Subtract 500, PAUSE 100, and loop — implementing a “wait and retry” effect (lines 6220–6270). - **100–199:** Subtract 100; if treasure is carried (`t=-1`), add 1 to destination (alternate exit when holding treasure) (lines 6300–6360). - **200–299:** Subtract 200; if treasure is carried, add `p` (pirate’s room) to destination (lines 6370–6390). - **Any other positive integer:** Direct room number (line 6320). After moving, if the first exit of the new room is `-2`, a probabilistic random-exit system is invoked (lines 6660–6700) using `m(4,n)` and `m(2,n)` as probability thresholds against `100*RND`, selecting among exits `m(6,n)`, `m(5,n)`, and `m(3,n)`. This implements the maze rooms where all directions seem the same. ## Location Description Dispatcher The subroutine at line 8000 uses arithmetic to compute a `GO TO` target rather than a long IF-THEN chain. The room number `n` is decomposed as `i = INT(n/5)` and `j = n - 5*i + 1`, then dispatches via `GO TO 8200 + (ABS(i)*10)` to a table of computed jumps (lines 8200–8290), each of which does `GO TO 9000 + (row_offset) + (j*10)`. This gives each room its own 10-line slot in the 9000–9490 range. Every room description ends with `GO TO site` (`GO TO 8400`), which handles optional treasure/pirate messages before returning. ## Input Handler Subroutine 5000 implements a generic first-character matcher. The caller sets `a$` to a string of valid characters and `q$` to the user’s input. The loop compares `q$(1)` against each character of `a$` and returns the 1-based index in `a1`. If not found, `a1 = LEN a$ + 1`. For direction input (line 7120), `a$="NEUDWSPneudwsp"`; lowercase aliases are folded by subtracting 7 at line 7145, producing indices 1–7 for the six directions plus P(score). ## Pirate Antagonist The pirate logic (lines 4000–4210) activates only when the treasure is being carried (`t=-1`). A counter `p1` increments each move (line 4090) and by an extra 1 every fourth room (line 4100, when `n=V3=3`… though this appears to trigger only when the player is in room 3, which may be a design quirk). When `p1≥15` (line 4120), the pirate strikes: the treasure is returned to room 12 (`T2`) and the player’s pirate-proximity counter resets via `p=V1`. Room 16 gets special handling at line 4070 (sets `p=160`), likely representing a long corridor where the pirate can close quickly. ## Scoring The score subroutine (3000) accumulates: +5 if the treasure was successfully taken (`T=-1`), +10 if the player is in room 1 (the exit), plus the sum of all `w(j)` (visited-room flags, each set to 1 when first entered at line 6530). The final score adds 10 at line 1760 (`s+10`). Maximum exploration score is 42 (all rooms visited). ## Source Code ``` 100 REM SETUP 120 PRINT TAB 13;"QUEST" 140 PRINT '"One day while walking thru the woods you come across a cave enterance covered with brush." 180 PRINT '"People say that many years ago apirate hid his treasure some- where in these woods, but no onehas ever found it." 210 PRINT '"For all I know it may still be here." 300 READ V1,V0,V2,V3,M9,T1,T2,SITE 310 DATA SGN PI,NOT PI,2,INT PI,42,23,12,8400 500 DIM w(m9): DIM m(6,m9) 520 FOR i=V1 TO m9: READ m 540 IF i<>m THEN GO SUB 9500 570 FOR j=V1 TO 6: READ m(j,i): NEXT j: NEXT i 900 PRINT '"Only the first letter of any answer is looked at. You can still type the whole word" 920 GO SUB 7500 1000 REM RESET 1010 LET n=5: LET m0=V0 1030 LET t=t1: LET m6=m0 1060 LET p=m0: LET p1=p 1070 DIM w(m9) 1090 PRINT 1120 GO SUB 8000 1400 REM MAIN LOOP 1420 LET m0=m0+V1 1440 GO SUB 6000 1460 GO SUB 2000 1480 GO SUB 4000 1500 IF T>V0 THEN GO TO 1400 1510 IF n<>5 THEN GO TO 1400 1700 REM FINAL SCORE 1710 GO SUB 3000 1720 PRINT '"Congratulations! You got the Treasure out in ";m0; 1750 PRINT " moves"'"and you got "; 1760 PRINT s+10;" points!" 1765 INPUT "Want to hunt again? ";q$ 1770 LET a$="YNyn" 1780 GO SUB 5000 1785 IF a1>V2 THEN LET a1=a1-V2 1790 IF a1=V1 THEN GO TO 1000 1791 IF a1=V2 THEN STOP 1792 IF a1=V3 THEN GO TO 1760 2000 REM FOUND? 2100 IF t<>n THEN RETURN 2110 IF tm0 THEN RETURN 2200 INPUT "Do you want to take it with you? ";q$ 2210 LET a$="YNyn" 2230 GO SUB 5000 2233 IF a1>V2 THEN LET a1=a1-V2 2235 IF a1=V1 THEN GO TO 2300 2240 IF a1=V2 THEN GO TO 2400 2250 PRINT "Well...." 2260 GO TO 2200 2300 LET t=-V1 2320 PRINT '"OK, lets get out of here!": RETURN 2400 PRINT '"We'll leave it here and you can explore some more." 2430 LET m6=m0: RETURN 3000 REM SCORE 3020 LET s=V0 3030 IF T=-V1 THEN LET s=s+5 3040 IF p=V1 THEN LET s=s+10 3050 FOR j=V2 TO m9: LET s=s+w(j): NEXT j: RETURN 4000 REM BAD GUY 4020 IF n=T2 THEN RETURN 4030 IF p=V1 THEN RETURN 4040 IF T1=T2 THEN RETURN 4050 IF T<>-V1 THEN RETURN 4070 IF n=16 THEN LET p=160 4090 IF p1>V0 THEN LET p1=p1+V1 4100 IF n=V3 THEN LET p1=p1+V1 4120 IF p1<15 THEN RETURN 4130 PRINT '"Suddenly the Pirate leaps out ofthe dark and grabs the treasure from you!" 4140 PRINT "AVAST You RAT!, he shouts, you found my treasure did you?" 4150 PRINT "Well, I'll hide it better this time! and he disapears into the darkness with the treasure" 4210 LET p=V1: LET t=t2: RETURN 5000 REM INPUT SORT 5002 IF q$="" THEN LET q$="i" 5005 FOR A=V1 TO LEN a$ 5010 IF q$(V1)=a$(a) THEN LET a1=a: RETURN 5030 NEXT a 5040 LET a1=LEN a$+V1 5145 RETURN 6000 REM MOVES 6030 LET n9=n: LET n8=V0 6070 GO SUB 7000 6090 IF n=V1 THEN GO TO 6120 6100 LET n0=n 6110 LET a0=a1 6120 PRINT 6130 LET i=m(a1,n) 6200 IF i=-V2 THEN LET i=n9 6220 IF i<500 THEN GO TO 6300 6240 LET i=i-500 6250 PAUSE 100 6270 GO TO 6200 6300 IF INT (i/100)=V1 THEN GO TO 6340 6310 IF INT (i/100)=V2 THEN GO TO 6370 6320 LET n=i 6330 GO TO 6400 6350 LET n=i-100 6355 IF t=-V1 THEN LET n=n+V1 6360 GO TO 6400 6380 LET n=i-200 6390 IF t=-V1 THEN LET n=n+p 6400 IF n<>V1 THEN GO TO 6500 6420 FOR j=V1 TO 6: LET m(j,n)=V2: NEXT j 6450 LET m(7-a0,n)=n0 6510 IF n8<>V2 THEN GO SUB 8000 6530 LET w(n)=V1 6540 LET n8=n 6600 IF m(V1,n)<>-V2 THEN RETURN 6660 LET i=m(6,n) 6670 LET j=-V1 6680 IF m(4,n)>INT (100*RND) THEN LET i=m(5,n) 6700 IF m(V2,n)>INT (100*RND) THEN LET i=m(V3,n) 6730 GO TO 6200 6800 RETURN 7000 REM DIRECTION 7110 INPUT "WHICH WAY SHALL I GO? ";q$ 7120 LET a$="NEUDWSPneudwsp" 7140 GO SUB 5000 7145 IF a1>7 THEN LET a1=a1-7 7150 IF a1>=8 THEN GO TO 9600 7300 IF a1<7 THEN RETURN 7320 GO SUB 3000 7330 PRINT "Your score = ";s;" points" 7350 GO TO 7100 7400 RETURN 7500 PRINT '"TYPE N,S,E,W,U OR D FOR NORTH, SOUTH, EAST, WEST ,UP OR DOWN. TYPE P FOR YOUR SCORE": RETURN 8000 REM LOCATION 8020 POKE 23692,9 8050 LET i=INT (n/5) 8060 LET j=n-5*i+V1 8100 GO TO 8200+((ABS i)*10) 8200 GO TO 9000+(j*10) 8210 GO TO 9050+(j*10) 8220 GO TO 9100+(j*10) 8230 GO TO 9150+(j*10) 8240 GO TO 9200+(j*10) 8250 GO TO 9250+(j*10) 8260 GO TO 9300+(j*10) 8270 GO TO 9350+(j*10) 8280 GO TO 9400+(j*10) 8290 GO TO 9450+(j*10) 8400 IF t<>n THEN GO TO 8500 8410 PRINT '"The treasure is here!" 8500 IF t<>t2 THEN RETURN 8510 IF t1=t2 THEN RETURN 8520 IF t1<>n THEN RETURN 8530 PRINT '"A note on the wall says that","Pirates never leave their","treasure twice in the same place" 8600 RETURN 9011 PRINT "This is a dead end.": GO TO site 9021 PRINT "That direction goes nowhere.": GO TO site 9031 PRINT "A tunnel goes North-South."'"There is an opening to the West.": GO TO site 9041 PRINT "You're totterring on the brink of a pit.": GO TO site 9051 PRINT "You've found the cave enterance.Go South to enter.": GO TO site 9061 PRINT "This is the home of the Gnome- King. Fortunately, he's gone forthe day.": GO TO site 9071 PRINT "Run the Gnome-King is here.","You'd better get out right now.": GO TO site 9081 PRINT "You are lost in the woods.": GO TO site 9091 PRINT "Where am I, it's gotten dark here?": GO TO site 9101 PRINT "You're not going to get far, that is rock you are trying to dig thro.": GO TO site 9111 PRINT "You're at the bottom of a pit. A little stream flows over the the rocks here.": GO TO site 9121 PRINT "This is a dead end.": GO TO site 9131 PRINT "This is a wide spot. There is a sooty patch where somebody has rested a torch against the wall.There are Jagged rocks above you": GO TO site 9141 PRINT "High on the canyon wall above you is scratched the message 'Kilroy was here'": GO TO site 9151 PRINT "You're not a bird. you can't fly": GO TO site 9161 PRINT "A small tunnel in this low","chamber goes east, and you can walk to the South or the West. There is light to the North.": GO TO site 9171 PRINT "It's a tight squeese. You can't get past the treasure.": GO TO site 9181 PRINT "I don't think you can find the cave.": GO TO site 9191 PRINT "You're at the top of a climb. Below you a message says","Kilroy was here": GO TO site 9201 PRINT "You're at the North side of a chasm too wide to jump over.","Ringing echoes from below are the only indication of it's","depth.": GO TO site 9211 PRINT "Ahead a sign says";TAB 8;"WELCOME TO XANADU","Below you, Alph, the sacred","river flows through caverns measureless to man, down to a sunless sea.": GO TO site 9221 GO TO site 9231 PRINT "This ledge overlooks the","guillotine room.": GO TO site 9241 PRINT "QUITE! I here the Giant there! You had better go back fast.": GO TO site 9251 PRINT "Now you've done it, this is the giant's cavern. You better not be here when he returns.": GO TO site 9261 PRINT "This is the QUEST RESEARCH and DEVELOPMENT AREA."''"NO VISITORS ALLOWED. You must leave now.": GO TO site 9271 PRINT "You've found the Crystal Palace.The walls resonate with awesume music.": GO TO site 9281 GO TO site 9291 PRINT "You're stuck at the top of a giant stalactite. You could","slide down but you cann't climb back up.": GO TO site 9301 PRINT "There is a book in this little grotto called Jane's Fighting Ships, dated 1763.": GO TO site 9311 PRINT "You're in the Guillotine room. A sharp rock balances","precariously on the ledge above you": GO TO site 9321 PRINT "You're in a chute, scrambling down the rocks! No way to stop! Hang On!": GO TO site 9331 PRINT "The tight tunnel turns a corner.": GO TO site 9341 PRINT "You're in a little twisty maze.": GO TO site 9351 PRINT "You're in a little twisting maze": GO TO site 9361 PRINT "You're in a twist1ng little maze": GO TO site 9371 PRINT "You're in a twisty little maze.": GO TO site 9381 PRINT "This is a prehistoric dwelling. The walls have drawings of","bison done in red clay. The","floor is strewn with the remainsof some rituals (bones).","A small tunnel goes thru the floor.": GO TO site 9391 PRINT "You're in a black hole. The force of gravity is overwhelming.": GO TO site 9401 PRINT "You're in the Labyrinthe.": GO TO site 9411 PRINT "It's very dark in the Labyrinthe": GO TO site 9421 PRINT "You're in the Ashram. Incense isheavy in the air, and all","directions seem the same.": GO TO site 9450 DATA V1,V0,V0,V0,V0,V0,V0,V2,-V2,101,-V2,V0,V0,V0 9452 DATA V3,33,V2,V1,10,106,4,4,V3,30,V2,11,V2,V1 9454 DATA 5,8,8,15,10,8,16,6,16,V3,V2,10,V2,V2 9456 DATA 7,-V2,101,-V2,V0,V0,V0,8,18,18,15,10,18,9 9458 DATA 9,-V2,33,5,V1,V0,-V2,10,-V2,101,-V2,V0,V0,V0 9460 DATA 11,V1,13,4,V2,V1,V2,12,36,V2,V1,V2,V1,V2 9462 DATA 13,V2,37,V2,V1,11,14,14,13,V1,19,V2,31,31 9464 DATA 15,-V2,101,-V2,V0,V0,V0,16,5,33,V2,10,V1,106 9466 DATA 17,-V2,101,-V2,V0,V0,V0,18,-V2,101,8,V0,V0,V0 9468 DATA 19,224,V2,V2,14,V1,42,20,226,V1,V2,V2,25,V2 9470 DATA 21,V1,226,V2,V2,38,25,22,-V2,33,13,50,29,30 9472 DATA 23,V2,V1,V2,31,V2,V2,24,-V2,101,19,V0,V0,V0 9474 DATA 25,21,20,V2,V2,V1,19,26,-V2,65,-V2,50,11,14 9476 DATA 27,V2,40,V2,V2,21,20,28,-V2,60,221,50,14,19 9478 DATA 29,V2,42,V2,13,V1,V1,30,34,34,V2,V1,4,V2 9480 DATA 31,14,14,23,V2,V1,V2,32,-V2,101,516,V0,V0,V0 9482 DATA 33,V2,V1,V2,V1,116,3,34,V1,35,V2,V1,30,30 9484 DATA 35,V2,V1,V2,37,34,36,36,35,V2,V1,37,34,12 9486 DATA 37,V2,V1,35,V2,13,V2,38,V2,21,V2,116,V1,V2 9488 DATA 39,V2,40,V2,32,21,26,40,40,40,V2,V2,40,41 9490 DATA 41,40,40,40,V2,40,39,42,28,28,28,28,28,28 9500 PRINT '"DATABASE PROBLEM ";i,n: STOP 9600 PRINT '"WHICH WAY DO YOU WANT TO GO?" 9605 GO SUB 7500: GO SUB 8000 9610 GO TO 7100 9700 SAVE "Quest" LINE PI ```