Chambers

Developer(s): M. Bristow
Date: 1984
Type: Program
Platform(s): TS 2068
Tags: Game

In Chambers you are the apprentice of the sorcerer Sly, locked in the cellar of his tower and set the task of escaping through an exit on the fifth floor, collecting one of each valuable object on the way. Each room is drawn in perspective with its doorways; you move with the cursor keys 5 to 8, press m to see a map of the floor (a limited number of times), i to list what you carry, and 0 to try an invisible door, which may open a trap door instead. Rooms hold objects such as a dagger, spear, lantern, cross and magic key, and hazards including vampire bats, blue mist and vanishing rooms. At the end the program gives an assessment of your intelligence.

Chambers was published in the Software File section of Your Computer, December 1984, credited to M. Bristow of Alderney, Channel Islands. The REM lines of this copy name the magazine, and its title screen calls it “CHAMBER – An Adventure Game”.

Program Analysis

Line 10 sets up the arrays and line 20 builds the five floors of 11 × 11 rooms at random: x() and y() hold the walls between rooms, p() the objects and t() the hazards. The magazine’s own notes divide the program as follows: 30–90 draw the current room, 96–98 check for objects, vanishing rooms and bats, 100–140 read the keys, 150–190 move the player and check for the exit, 200–290 end the game, 300–380 handle invisible doors, 400–490 draw the map, 500–590 describe objects and hazards, 700–710 list the items carried, 800–850 and 900–940 are the vanishing room and vampire bats, and 9000–9300 set up the user-defined graphics and data. Building the maze takes about two minutes.

Notable Techniques

  • Movement is computed with Boolean expressions, LET kx=(a$="8" AND x(l,x+1,y)=1)-(a$="5" AND x(l,x,y)=1), so a key only moves the player when there is a doorway.
  • Four-dimensional maze data packed into three-dimensional arrays indexed by level, row and column.

This copy came from a Larken disk; it is plain Spectrum-compatible BASIC and needed only the disk save and menu lines removed. The original tape SAVE and VERIFY line (9999) is kept. Tested in ZEsarUX: the opening room and the map.

Image Gallery

Source Code

    1 REM        CHAMBERS                       ''''''''''''''''''''          
    2 REM  An Adventure program          taken from the magazine         "Your Computer"(Dec.'84)   
    3 REM 
   10 CLEAR : RANDOMIZE : GO SUB 9000: LET life=5: DIM p$(704): DIM j(5): DIM k(5): DIM i$(20,9): LET nu=1: LET x=5: LET y=5: DIM x(5,11,11): DIM y(5,11,11): DIM p(5,11,11): DIM t(5,11,11)
   20 FOR l=1 TO 5: LET k(l)=ABS (8-l): BORDER l: FOR m=1 TO 11: FOR n=1 TO 11: LET x(l,m,n)=INT (RND*2): LET y(l,m,n)=INT (RND*2): LET p(l,m,n)=INT (RND*8): LET t(l,m,n)=INT (RND>.6)*INT (RND*17+1): NEXT n: NEXT m: NEXT l
   25 FOR l=1 TO 5
   30 LET xs=0: LET ys=6: LET ky=1: LET kx=0: LET a$="6": BRIGHT 1
   40 BORDER p(l,x,y): PAPER p(l,x,y): CLS : INK 9: PRINT #0;AT 1,1;"level ";l
   50 DRAW 255,0: DRAW 0,175: DRAW -255,0: DRAW 0,-175: DRAW 30,24: PLOT 255,0: DRAW -30,24: PLOT 255,175: DRAW -30,-24: PLOT 0,175: DRAW 30,-24: FOR n=3 TO 18: PRINT AT n,4;"::::::::::::::::::::::::::::::::::::::::::::::::": NEXT n
   55 IF t(l,x,y)>1 THEN PRINT OVER 1;AT 10,15;CHR$ (145+t(l,x,y))
   60 IF y(l,x,y)=1 THEN PLOT 88,152: DRAW -16,16: DRAW 112,0: DRAW -16,-16: FOR n=1 TO 3: PRINT AT n,11;"::::::::::::::::::::": NEXT n
   70 IF y(l,x,y+1)=1 THEN PLOT 88,23: DRAW -16,-16: DRAW 112,0: DRAW -16,16: FOR n=17 TO 20: PRINT AT n,11;"::::::::::::::::::::": NEXT n
   80 IF x(l,x,y)=1 THEN PLOT 31,56: DRAW -24,-16: PLOT 0,96: DRAW 24,-16: FOR n=7 TO 14: PRINT AT n,1;"::::::::": NEXT n
   90 IF x(l,x+1,y)=1 THEN PLOT 224,56: DRAW 24,-16: DRAW 0,96: DRAW -24,-16: FOR n=7 TO 14: PRINT AT n,27;"::::::::": NEXT n
   95 LET ys=ys-ky: LET xs=xs-kx: PRINT AT 10-ys-ky,15-xs-kx;"::";AT 10-ys,15-xs; OVER 1;"b": BEEP .01,-5: IF ys<>0 OR xs<>0 THEN GO TO 95
   96 IF (t(l,x,y)>0 AND l>1) OR t(l,x,y)>1 THEN GO SUB 500: IF t(l,x,y)=1 THEN LET l=l-1: GO TO 30
   97 IF t(l,x,y)=16 THEN GO SUB 800
   98 IF t(l,x,y)=17 THEN GO SUB 900: IF life=0 THEN PRINT AT 18,0;#0;AT 0,0;"Sorry you have been wounded too many times. You are dead!": GO TO 260
  100 LET a$=INKEY$
  110 LET kx=(a$="8" AND x(l,x+1,y)=1)-(a$="5" AND x(l,x,y)=1): LET ky=(a$="6" AND y(l,x,y+1)=1)-(a$="7" AND y(l,x,y)=1)
  120 IF a$="0" THEN GO TO 300
  130 IF a$="m" THEN GO TO 400
  135 IF a$="i" THEN GO TO 700
  140 IF (kx=0 AND ky=0) THEN GO TO 100
  150 LET ys=0: LET xs=0
  160 LET xs=xs+kx: LET ys=ys+ky: PRINT AT 10+ys-ky,15+xs-kx;"::";AT 10+ys,15+xs; OVER 1;"b"
  170 BEEP .01,-5: IF 8-ABS ys>0 AND 13-ABS xs>0 THEN GO TO 160
  180 LET x=x+kx: LET y=y+ky: IF x>0 AND x<11 AND y>0 AND y<11 THEN GO TO 40
  190 PRINT #0; FLASH 1;AT 0,0;"You have found one of the exits. Press a key for the next level.";AT 1,12;("to get out of maze." AND l=5): PAUSE 0: LET x=5: LET y=5: NEXT l
  200 CLS : PRINT AT 1,10;"WELL DONE"'"You have managed to escape from the fifth level alive."
  210 LET c=1: PRINT AT 4,0: FOR n=2 TO 14: IF i$(n)<>t$(n) THEN PRINT AT 4,0;"But you did not have all the    items required by the sorcerer.  You remain an apprentice until          next time": LET c=0
  220 NEXT n
  230 IF c=1 THEN PRINT AT 4,0;"You have got all the items. The  sorcerer is pleased with you     and has made you his partner."
  240 PRINT #0;AT 0,0;"Would you like to see the items you found?   (Y/N)"
  245 LET a$=INKEY$
  250 IF a$="y" THEN CLS : PRINT AT 1,5;"You are carrying:-": FOR n=2 TO 14: PRINT AT n,10;CHR$ (145+n);" - ";i$(n): NEXT n
  255 IF a$<>"y" AND a$<>"n" THEN GO TO 245
  260 PRINT OVER 1;"        Another go ? (Y/N)"
  270 LET a$=INKEY$: IF a$="y" THEN RUN 
  280 IF a$<>"n" THEN GO TO 270
  290 STOP 
  300 IF i$(14)<>t$(14) THEN PRINT #0;AT 0,0;"No key?-Secret doors stay locked";("You decompose on the floor" AND l=2);("You fall through the floor" AND l>1): LET t(l,x,y)=1: PAUSE 0: GO TO (l<>1)*86+10
  310 PRINT #0;AT 0,0; FLASH 1;"    Open the secret door...         Using cursor keys (5-8)"
  320 LET a$=INKEY$
  330 IF a$="5" THEN LET x(l,x,y)=1
  340 IF a$="8" THEN LET x(l,x+1,y)=1
  350 IF a$="7" THEN LET y(l,x,y)=1
  360 IF a$="6" THEN LET y(l,x,y+1)=1
  370 IF a$<>"5" AND a$<>"6" AND a$<>"7" AND a$<>"8" THEN GO TO 320
  380 PRINT #0;AT 1,0;"The key rusts as the door opens.": LET i$(14)="rusty key": GO TO 60
  400 IF k(l)=0 THEN PRINT #0;AT 0,0;"...You have run out of maps!!!": GO TO 100
  405 LET k(l)=k(l)-1: PAPER 0: BORDER 0: INK 7: CLS : DRAW 168,0: DRAW 0,168: DRAW -168,0: DRAW 0,-168: FOR n=1 TO 15: PRINT AT n,21; INK 4;CHR$ (145+n);"-";t$(n): NEXT n: PRINT AT 18,24;"b-You!";AT 0,0; PAPER 6; INK 0;"You have ";k(l);" map";("s" AND k(l)<>1);" left on level ";l
  410 PRINT INK 0;AT 2*y,2*x-1;"b"
  430 FOR m=0 TO 10: PLOT 16*m+4,4: DRAW 0,160: PLOT 4,16*m+4: DRAW 160,0: NEXT m
  440 FOR n=1 TO 11: FOR m=1 TO 11: IF m<11 THEN PLOT 16*m,180-16*n: DRAW OVER y(l,m,n);-8,0
  445 IF t(l,n,m)>0 AND m<11 AND n<11 AND (t(l,n,m)<>1 OR l<>1) THEN PRINT INK 0;AT 2*m,2*n-1;CHR$ (145+t(l,n,m))
  450 IF n<11 THEN PLOT 16*m-12,176-16*n: DRAW OVER x(l,m,n);0,-8
  460 NEXT m: NEXT n
  470 INK 9: FOR m=4 TO 164: OVER 1: PLOT 4,m: DRAW 160,0
  480 IF INKEY$="" THEN NEXT m: GO TO 470
  490 OVER 0: PAUSE 0: GO TO 40
  500 FOR n=9 TO 11: PRINT AT n,14;"   ": NEXT n
  530 FOR n=15 TO 1 STEP -1: BEEP .01,n: NEXT n
  540 LET t=t(l,x,y): PRINT AT 10,15;CHR$ (145+t);#0;AT 0,0;"You have come across a ";t$(t): IF t>1 AND i$(t)=t$(t) AND t<16 THEN PRINT #0;AT 1,0;"But it breaks up in your hands!!"
  550 IF t=1 THEN FOR n=7 TO 13: PRINT AT n,12;"       ": NEXT n: PLOT 96,119: DRAW 55,0: DRAW 0,-55: DRAW -55,0: DRAW 0,55: DRAW 54,-54: DRAW -54,0: DRAW 54,54: FOR n=8 TO 12: PRINT BRIGHT 0;AT n,13; INK p(l-1,x,y);"::::::::::": NEXT n: PRINT #0;"You fall into thechamber below.": PAUSE 0
  560 IF t=15 THEN PRINT #0;AT 1,0;("It is evaporateed by the lantern" AND i$(6)=t$(6)): IF i$(6)<>t$(6) THEN PRINT #0;AT 1,0;"It absorbs all your possessions": PRINT AT 0,0; OVER 1; PAPER 5; INK 1; FLASH 1;p$: DIM i$(20,9):
  590 LET i$(t)=(t$(t) AND t>1 AND t<16): LET t(l,x,y)=(t(l,x,y)=1)+(t(l,x,y) AND t(l,x,y)>15): RETURN 
  700 CLS : PRINT AT 1,5;"You are carrying:-": FOR n=2 TO 14: IF i$(n)=t$(n) OR i$(n)="rusty key" THEN PRINT AT n,10;CHR$ (145+n);" - a ";i$(n)
  710 NEXT n: PAUSE 0: GO TO 30
  800 PRINT AT 0,0; PAPER 7; INK 0; OVER 1; FLASH 1;p$
  810 LET t=0: FOR n=1 TO 14: IF i$(n)=t$(n) THEN LET t=n
  820 NEXT n
  830 IF i$(6)=t$(6) THEN LET t=6
  840 IF t>1 THEN PRINT #0;AT 1,0;"room.You've lost your ";i$(t): LET i$(t)="  ": PAUSE 0: RETURN 
  850 PRINT #0;AT 1,0;"room.Luckily nothing vanished.": PAUSE 0: RETURN 
  900 PRINT #0;AT 1,0;"Bat.  Press a key to attack it.": PAUSE 0: PRINT #0;AT 0,0;"                                                                "
  910 FOR m=0 TO 7: PRINT AT 10,15;"S";AT 10,15;("Q" AND m/2=INT (m/2)): BORDER m: FOR n=20 TO 1 STEP -1: BEEP .005,n+m: NEXT n: NEXT m
  920 IF i$(10)=t$(10) THEN PRINT AT 10,15;" ";#0;AT 0,0;"You have killed the vampire bat with your cross.": LET t(l,x,y)=0: RETURN 
  930 LET life=life-1: IF life>0 THEN PRINT #0;AT 0,0;"You are wounded.   You have ";life;"    "'"lif";(CHR$ 8+"v" AND life<>1);"e";("s" AND life<>1);" left.Escape while you can": RETURN 
  940 RETURN 
 9000 RESTORE 9000: FOR n=USR "a" TO USR "s"+7: READ a: POKE n,a: NEXT n
 9010 DATA 153,102,102,153,153,102,102,153
 9015 DATA 48,176,152,116,20,112,136,134,255,129,189,189,189,189,129,255
 9020 DATA 1,2,4,8,208,160,208,128,32,48,240,104,40,4,2,1,127,119,119,65,119,54,54,28,56,56,68,130,130,130,68,56
 9030 DATA 16,56,124,254,68,68,68,124,0,120,127,121,121,127,120,120,14,49,65,66,140,48,112,96,0,60,126,255,189,66,60,0
 9040 DATA 24,24,126,126,24,24,24,24,0,126,132,132,66,66,33,126,35,10,84,40,112,232,64
 9050 DATA 3,7,6,8,16,32,64,128,00,64,160,191,165,68,0,0,0,146,84,0,198,0,84,146,0
 9060 DATA 0,0,0,0,0,0,0,0,3,110,126,56,112,96,224,128
 9090 DIM t$(20,9): RESTORE 9100: FOR n=1 TO 17: READ a$: LET t$(n)=a$: NEXT n
 9100 DATA "trap door","sword","hatchet","shield","gold ring","lantern","drink","whip","gold coin","cross","scroll"
 9200 DATA "dagger","spear","magic key","blue mist","vanishing","vampire"
 9210 CLS : PRINT AT 1,12;"CHAMBER";AT 2,7;"An Adventure Game"
 9220 PRINT AT 10,5;"Please wait while the";AT 11,5;"sorcerer prepares your";AT 12,5;"task. - Good Luck."
 9300 RETURN 
 9992 REM  removed (LKDOS-only)
 9998 REM  removed (LKDOS-only)
 9999 CLEAR : SAVE "chambers" LINE 10: PRINT AT 10,10;"V E R I F Y": VERIFY "": RUN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.