Castle Hexagon

Type
Game
Category
Graphic exploration puzzle
Author
Stan Ockers
Published in
ACE Newsletter (Atari Computer Enthusiasts, Eugene, Oregon), 1982; later on the BELLCOM public domain disks
Year
1982
Language
Atari BASIC (with machine-language DATA)
Requirements
Any 8-bit Atari with 16K+ and Atari BASIC; joystick in port 1
A hexagonal room drawn in green on purple: slanted doors on the left and right labelled TO ROOM # 6 and TO ROOM # 1, a striped chest in the middle, the mat at the bottom (TO ROOM # 3), CARRYING: CHAIN MAIL at the top and THIS IS ROOM # 2 KING'S…

About the program

Castle Hexagon is dated October 1982 in its REM header ("S.O. 10/82"). It's a graphic puzzle adventure without a text parser. The castle has 23 hexagonal rooms, each with doors on alternate walls, so every room leads to three others. Many passages are bricked up. Each room holds a chest, and each chest contains an item that belongs in some other room, such as the jade urn, the wooden stake or the iron horseshoe. Put the right item in the right room's chest and a sealed door somewhere opens. Your goal is the Book of Known. As the built-in instructions warn, every RUN shuffles the room names, so no two castles are the same.

What you need

Any Atari with Atari BASIC and 16K or more, and a joystick. Paper is useful too. The instructions say "the map should help", and making your own map of room numbers is half the game.

Typing it in

  • Control characters. As REM line 123 says, every character in the strings of lines 124–170 is a CTRL character except the X's. They're shown here as {CTRL-A}, {CTRL-O} and so on. To type one, hold CTRL and press the letter. Inside quotes, the Atari editor turns that straight into the graphics character. {CTRL-,} is CTRL plus comma. Once the new character set loads, these characters draw the walls, doors and chests.
  • Spaces restored. The copy reproduced here had squeezed double spaces in the door and chest pictures, which made them come out skewed. They have been put back, because each string must fill its DIM exactly. Lines 125, 127, 130 and 140 are each 48 characters (12 rows of 4) and contain two double spaces. Line 150 begins with five spaces (the empty row above a closed chest lid).
  • The room and item names in lines 180–188 are disguised. Each letter is shifted three places (MDGH#XUQ is "JADE URN"), so you can't read the solution from the listing. # stands for a space. Type them exactly.
  • Lines 52–69 are the music interrupt and its tunes. A typing slip there gives silence or a crash, so SAVE first.

How to play

Press START. Point the joystick up to put the cursor on the chest, left or right for the doors, and down for the mat, which leads back to the room you came from. Press fire to act. Firing at an open door takes you through it. The labels show which room each door leads to, and the current room's name and number are shown at the bottom. Firing at the chest swaps the item you're carrying (shown top right) for the one inside. When you leave an item in its proper room, a sound plays and a passage elsewhere is unblocked. Find the Book of Known to win. Then press START to replay the same castle or SELECT for a new one.

How it works

  • Map in a string. NXTRM$ lists the three neighbours of each room. A passage is identified by the sum of the two room numbers it joins, and T$ holds one "blocked" flag per sum. U$ says which passage a room's proper item unlocks.
  • Pictures from strings. Lines 1200–1250 print the door, chest and mat shapes from strings, W characters per row. The display list (lines 1100–1110) turns the middle of the screen into ANTIC mode 4, the four-colour character mode, using 26 characters redefined in lines 1020–1092.
  • Music by interrupt. A 75-byte vertical-blank routine in VBI$ plays pitch/duration lists stored in page 6. BASIC picks a tune by POKEing its offset into 1788.

Listing

10 REM ********************
20 REM ** CASTLE HEXAGON **
30 REM ** S.O. 10/82 **
40 REM ********************
45 GRAPHICS 18:POSITION 6,4:? #6;"C{inv}aS{/inv}tL{inv}E{/inv}":POSITION 6,6:? #6;"{inv}He{/inv}xA{inv}gO{/inv}n"
49 REM * Sound generation in VBI, Data in page 6 *
50 DIM VBI$(75):RESTORE 52:FOR J=1 TO 75:READ A:VBI$(J,J)=CHR$(A):NEXT J
52 DATA 174,252,6,240,67,173,244,6,240,32,206,244,6,208,57
54 DATA 189,0,6,141,0,210,10,234,234
56 DATA 141,2,210,232,189,0,6,240,30,141,248,6,232,142,252,6,208,30,206,248,6,16,25,169,0
58 DATA 141,0,210,141,2,210,173,243,6,141,244,6,208,9,141,252,6,141,0,210,141,2,210,76,98,228
60 RESTORE 62:FOR J=1536 TO 1749:READ A:POKE J,A:NEXT J
62 DATA 104,160,0,162,0,169,7,76,92,228
64 DATA 81,20,68,40,60,20,53,30,50,10,53,20,60,40,72,20,91,30,81,10,73,20,68,40,81,20,81,30,85,10,81,20,72,40
65 DATA 85,20,108,40,81,20,68,40,60,20,53,30,50,10,53,20,60,40,72,20,91,30,81,10,72,20,68,30,72,10,81,20,85,30
66 DATA 96,10,91,20,81,40,81,20,0,0,53,40,60,20,53,20,81,20,81,20,91,20,81,20,68,20,72,20,85,20,81,60,81,20
67 DATA 53,80,53,20,81,20,68,20,53,20,60,20,68,20,60,80,60,20,53,20,50,40,50,20,53,20,60,40,68,20,60,20,53,20
68 DATA 53,20,60,20,68,20,81,60,81,20,53,80,53,20,81,20,68,20,53,20,60,20,72,20,68,80,0,0,100,5,80,5,60,5,40,5
69 DATA 20,5,0,0,20,5,40,5,60,5,80,5,100,5,0,0,100,2,0,2,140,2,0,2,100,2,0,2,140,2,0,0
80 A=ADR(VBI$):B=INT(A/256):C=A-256*B:POKE 1538,C:POKE 1540,B:POKE 53761,174:POKE 53763,170:POKE 1779,5
82 A=USR(1536):POKE 1788,88
90 GOSUB 1000
100 DIM NXTRM$(69),BRD$(48),BLD$(48),LD$(48),RD$(48),P$(48),CC$(20),CO$(20),T$(43),PD$(8),RN$(23),H$(23),U$(23)
109 REM * H$-Room assoc. with chest contents, CB$-Color of background *
110 DIM OBJ$(23),Q$(322),R$(345),CRY$(14),CB$(23),M$(15),F$(37):RN$(23)=" ":RESTORE 112:FOR J=1 TO 23:READ A
111 H$(J,J)=CHR$(A):NEXT J:FOR J=1 TO 23:READ A:CB$(J)=CHR$(A):NEXT J
112 DATA 3,22,12,15,18,16,20,19,1,2,4,6,9,10,13,14,8,17,11,5,21,7,0
113 DATA 18,66,84,100,34,110,0,180,98,178,4,16,174,178,52,20,6,0,254,210,64,242,50
114 REM * Randomize room names *
115 FOR J=1 TO 23
116 R=INT(RND(0)*23):FOR K=1 TO J:IF R=ASC(RN$(K)) THEN 116
118 NEXT K:RN$(J,J)=CHR$(R):NEXT J:K=0
119 K=K+1:IF ASC(RN$(K))<>17 THEN 119
120 RN$(K,K)=RN$(18,18):RN$(18,18)=CHR$(17)
121 REM * Put objects in proper place *
122 FOR J=1 TO 23:K=ASC(H$(J)):OBJ$(J,J)=RN$(K+1,K+1):NEXT J:CRY=ASC(OB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L-G}{CTRL-H}{CTRL-B}{CTRL-B}  {CTRL-G}{CTRL-H}"
150 CC$="     {CTRL-W}{CTRL-Z}{CTRL-Z}{CTRL-Z}{CTRL-L}XXXX{CTRL-A}XXXX{CTRL-K}"
160 CO$="{CTRL-X}{CTRL-B}{CTRL-B}{CTRL-B}{CTRL-Y}{CTRL-W}{CTRL-Z}{CTRL-Z}{CTRL-Z}{CTRL-L}XXXX{CTRL-A}XXXX{CTRL-K}"
170 PD$="{CTRL-E}{CTRL-F}{CTRL-A}{CTRL-A}{CTRL-A}{CTRL-A}{CTRL-I}{CTRL-J}"
179 REM * Room names *
180 Q$="###MDGH#XUQ####ZRRGHQ#VWDNH##SHUIXPHG#RLO#JROGHQ#JREOHW##LURQ#FDOGURQ##ODFH#SLOORZV##UDZKLGH#ZKLS#"
181 Q$(99)="##FKLQD#GROO####SXUSOH#UREH###PDJLF#ZDQG##LURQ#KRUVHVKRH##FKDLQ#PDLO##FRSSHU#NHWWOH#"
182 Q$(183)="##VS\JODVV####VLOYHU#EULGOH#FRORUHG#EDOOV#ZRRG#FURVVERZ#ERRN#RI#NQRZQ###TXLOO#SHQ###EUDVV#EDODQFH#"
183 Q$(281)="#FDQGOHVWLFN###EDJ#RI#VDOW####SUD\HU#UXJ##"
185 R$="#FDVWOH#FU\SW##YDPSLUH*V#ODLU#SULQFHVV*V#EDWK##GLQLQJ#KDOO####ZLWFK*V#GHQ##TXHHQ*V#EHGURRP"
186 R$(91)="#GDUN#GXQJHRQ##KHLU*V#QXUVHU\#NLQJ*V#FKDPEHUVVRUFHUHU*V#GHQ#EODFNVPLWK#VKRS"
187 R$(166)="#NQLJKW*V#URRP##FDVWOH#NLWFKHQ##ZDWFKWRZHU####KRUVH#VWDEOH###MHVWHU*V#URRP##FDVWOH#DUPRU\#"
188 R$(256)="###############FDVWOH#OLEUDU\#DOFKHPLVW*V#ODE#FDVWOH#FKDSHO####VWRUHURRP###PRQN*V#TXDUWHUV"
200 T$(1)=CHR$(0):T$(43)=CHR$(0):T$(2)=T$:FLAG=0
209 REM * U$-Passage # blocked at certain room *
210 RESTORE 212:FOR J=1 TO 23:READ A:U$(J)=CHR$(A):NEXT J
212 DATA 0,0,0,23,0,0,0,0,12,0,0,18,31,0,0,0,16,0,39,35,42,0,37
213 REM * Set up passages blocked *
214 FOR J=1 TO 23:A=ASC(U$(J)):IF A=0 THEN NEXT J
216 T$(A,A)=CHR$(1):NEXT J:T$(38,38)=CHR$(1):T$(40,40)=CHR$(1):T$(43,43)=CHR$(1)
300 ?:? " {inv}PRESS START{/inv}";
302 IF PEEK(53279)<>6 THEN 302
304 ? CHR$(125):GOSUB 1100:GOSUB 1230
306 POSITION 6,0:? "carrying:":POSITION 2,19:? "this is room # ":CUX=19:CUY=11
310 RM=INT(RND(0)*8):PRRM=ASC(NXTRM$(RM*3+INT(RND(0)*3+1))):A=RM+PRRM:IF ASC(T$(A))>0 THEN 310
350 R1=ASC(NXTRM$(RM*3+1)):R2=ASC(NXTRM$(RM*3+2)):R3=ASC(NXTRM$(RM*3+3))
356 IF R1=PRRM THEN RTRM=R2:LTRM=R3
357 IF R2=PRRM THEN RTRM=R3:LTRM=R1
358 IF R3=PRRM THEN RTRM=R1:LTRM=R2
359 POKE 1779,1:POKE 1788,198
360 POKE 559,0:POKE 712,ASC(CB$(ASC(RN$(RM+1))+1)):POKE 710,48:POKE 77,0
361 POSITION 1,1:? "TO ROOM # ";LTRM;" ":POSITION 26,1:? "TO ROOM # ";RTRM;" "
362 POSITION 14,18:? "TO ROOM # ";PRRM;" ":POSITION 17,19:? RM;" "
364 LT=ASC(T$(RM+LTRM)):RT=ASC(T$(RM+RTRM)):GOSUB 1250
366 IF LT>0 THEN GOSUB 1215:GOTO 370
368 IF LT=0 THEN GOSUB 1210
370 IF RT>0 THEN GOSUB 1225:GOTO 382
372 IF RT=0 THEN GOSUB 1220
382 POKE 559,34:X=23:Y=19:Q=15*ASC(RN$(RM+1))+1:M$=R$(Q,Q+14):GOSUB 1500:POSITION 22,19:? " ";
383 IF OBJ$(RM+1,RM+1)=RN$(RM+1,RM+1) THEN POSITION 22,19:? CHR$(170)
384 X=24:Y=0:P=14*CRY+1:M$=Q$(P,P+13):GOSUB 1500
390 POKE 712,ASC(CB$(ASC(RN$(RM+1))+1)):POKE 710,48:POKE 77,0
392 POKE 209,18:POKE 208,14
400 S=STICK(0):IF STRIG(0)=0 THEN 410
402 IF S=14 THEN CUX=19:CUY=9
404 IF S=13 THEN CUX=19:CUY=16
406 IF S=7 THEN CUX=33:CUY=11
407 IF S=11 THEN CUX=6:CUY=11
410 LOCATE CUX,CUY,Z:POSITION CUX,CUY:? "*";:TR=STRIG(0)
430 IF TR=0 AND CUY=16 THEN TEMP=RM:RM=PRRM:PRRM=TEMP:GOTO 350
440 IF TR=0 AND LT=0 AND CUX=6 THEN LT=RM+LTRM:PRRM=RM:RM=LTRM:GOTO 350
450 IF TR=0 AND RT=0 AND CUX=33 THEN RT=RM+RTRM:PRRM=RM:RM=RTRM:GOTO 350
460 IF TR=0 AND CUY=9 THEN GOSUB 2000
470 IF FLAG=1 THEN FLAG=0:GOTO 360
480 IF FLAG=3 THEN POKE 1788,10:GOTO 600
490 POSITION CUX,CUY:? CHR$(Z);
500 GOTO 400
600 ? CHR$(125):POSITION 1,0:? "YOU FOUND THE BOOK congratulations!"
602 POSITION 2,19:? "{inv}start{/inv} to repeat {inv}select{/inv} for new game";
608 FOR J=0 TO 123:IF J>27 AND J<32 THEN NEXT J
610 F$(1)=CHR$(J):F$(37)=CHR$(J):F$(2)=F$:FOR K=3 TO 16:POSITION 1,K:? F$;
612 A=PEEK(53279):IF A=6 THEN GRAPHICS 0:POKE 756,START/256:GOTO 122
614 IF A=5 THEN GRAPHICS 0:POKE 756,START/256:?:? "Just a sec ...":GOTO 114
616 NEXT K:NEXT J:GOTO 608
999 REM * Change character set *
1000 DIM ZZ$(32):RESTORE 1010:FOR I=1 TO 32:READ A:ZZ$(I)=CHR$(A):NEXT I
1010 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,4,160,0
1012 DATA 177,203,145,205,136,208,249,230,204,230,206,202,208,240,96
1014 POKE 106,PEEK(106)-5:GRAPHICS 0:GOSUB 1800:START=(PEEK(106)+1)*256:POKE 756,START/256:POKE 752,1
1016 A=USR(ADR(ZZ$),57344,START):RESTORE 1020:FOR I=START+520 TO START+727:READ A:POKE I,A:NEXT I
1018 RETURN
1020 DATA 170,170,170,170,170,170,170,170,255,255,255,255,255,255,255,255,255,255,255,255,253,244,208,64
1030 DATA 253,244,208,64,0,0,0,0,0,0,0,0,1,6,26,106,1,6,26,106,170,170,170,170
1040 DATA 127,31,7,1,0,0,0,0,255,255,255,255,127,31,7,1,64,144,164,169,170,170,170,170
1050 DATA 0,0,0,0,64,144,164,169,170,170,168,168,160,160,128,128,170,171,170,174,170,186,170,234
1060 DATA 191,239,251,254,190,46,10,2,191,47,11,2,0,0,0,0,191,239,251,254,190,238,250,254
1070 DATA 0,0,0,0,128,224,248,254,128,224,248,254,190,238,250,254,254,251,239,191,190,184,160,128
1080 DATA 254,248,224,128,0,0,0,0,254,251,239,191,190,187,175,191,0,0,0,0,2,11,47,191
1090 DATA 2,11,47,191,190,187,175,191,2,2,10,10,42,42,170,170,255,127,63,31,15,7,3,1
1092 DATA 64,192,208,240,244,252,253,255,170,170,170,170,170,170,170,170
1099 REM * Change display list *
1100 DL=PEEK(560)+256*PEEK(561):POKE DL+3,70:POKE DL+6,7:POKE DL+25,6:POKE DL+26,7
1110 FOR J=0 TO 3:POKE DL+27+J,PEEK(DL+29+J):NEXT J:FOR J=8 TO 23:POKE DL+J,4:NEXT J:RETURN
1199 REM * Draw figures using strings *
1200 FOR J=0 TO H:L=W*J:POSITION X,Y+J:? P$(L+1,L+W):NEXT J:RETURN
1210 P$=LD$:H=11:W=4:X=4:Y=4:GOSUB 1200:RETURN
1215 P$=BLD$:H=11:W=4:X=4:Y=4:GOSUB 1200:RETURN
1220 P$=RD$:H=11:W=4:X=32:Y=4:GOSUB 1200:RETURN
1225 P$=BRD$:H=11:W=4:X=32:Y=4:GOSUB 1200:RETURN
1230 P$=CC$:H=3:W=5:X=17:Y=7:GOSUB 1200:RETURN
1240 P$=CO$:H=3:W=5:X=17:Y=7:GOSUB 1200:RETURN
1250 P$=PD$:H=0:W=8:X=16:Y=16:GOSUB 1200:RETURN
1500 POSITION X,Y:FOR J=1 TO LEN(M$):? CHR$(ASC(M$(J))-3);:FOR K=1 TO 3:NEXT K:NEXT J:RETURN
1800 ? "{inv}Castle{/inv} {inv}Hexagon{/inv} gets its name from":? "its six sided rooms with doors at"
1810 ? "alternate walls. Rumor says an":? "ancient manuscript of wisdom called"
1820 ? "the '{inv}Book{/inv} {inv}of{/inv} {inv}Known{/inv}' lies hidden in":? "one of the castle's many rooms"
1830 ? "Your job is to find this treasure.":? " Each room has a chest containing"
1840 ? "an item associated with another":? "room. You can only carry one item"
1850 ? "at a time. Position the cursor on":? "the chest and push '{inv}fire{/inv}'. Many"
1860 ? "doors have been bricked over but":? "some will magically open when the"
1870 ? "chest contains the proper item.":? "Position the cursor on the desired"
1872 ? "door and push '{inv}fire{/inv}' to move between":? "rooms. The 'mat' in the middle"
1874 ? "represents the room you just came":? "from. Just remember you are facing"
1876 ? "into the room, (the map should help).":? " A final warning ... it's not"
1878 ? "easy and if you re-run the program":? "all the rooms get switched around!";
1890 RETURN
1999 REM * Exchange chest contents *
2000 GOSUB 1240:TEMP=CRY:K=ASC(OBJ$(RM+1)):P=14*K+1:CRY=K
2010 OBJ$(RM+1,RM+1)=CHR$(TEMP):X=24:Y=0:M$=Q$(P,P+13):GOSUB 1500:POKE 1788,174:FOR J=1 TO 100:NEXT J
2020 POKE 1788,186:GOSUB 1230
2025 IF CRY=17 THEN FLAG=3
2030 IF TEMP=ASC(RN$(RM+1)) THEN GOSUB 2500
2040 RETURN
2499 REM * Clear passage *
2500 FOR J=1 TO 100:NEXT J:POKE 1788,10:FLAG=0:A=ASC(U$(RM+1)):IF A=0 THEN RETURN
2510 T$(A,A)=CHR$(0):FLAG=1:RETURN

Credits