3
Applications and Education
Castle Quest
Timothy G. Baldwin
This entrancing, well-designed game offers you the best of both worlds. It has the drama, variety, and mystery of a good adventure game combined with the fast-paced excitement of an arcade game. Your job is to rid the kingdom of the three evil wizards. All this would be easy if the wizards weren't so zealously guardsed by servants whose names reflect their personalities: bat-wingers, blinkers, chokers, crushers, and stompers.

You are in love with the Princess Dilayna and have asked her father the King for her hand in marriage. Her father does not particularly like you. He challenges you to demonstrate your worthiness by capturing the three evil wizards that have been ravaging the kingdom for years. They each live in their own castle protected by their servants—the bat-wingers, the blinkers, the chokers, the stompers, and the crushers. The castle rooms are rumored to be deadly, the untouchable walls, fast-moving enemies, and no exits. You reluctantly accept the King's challenge.

Fortunately, a friendly magician gives you a cloak that makes the wearer invisible. But the cloak's power works only for a limited time in each room. Once the time is up, you are instantly destroyed. The magician also gives you a magic spell that temporarily freezes all servants in a room. But you must use this spell with care: it will consume a portion of the cloak's power each time it is used.

Armed with these aids, you leave on your quest. The King wishes you good luck—or did he say good riddance?

The Three Wizards

The object of "Castle Quest" is to capture the three wizards. To reach each wizard, you must pass through the ten rooms of his castle. The rooms are inhabited by the wizard's servants, who move about quickly in an unpredictable manner. The higher numbered rooms in each castle have more servants (up to 32). The servants move progressively faster as you complete more rooms.

You have three lives to capture the first wizard. Capturing a wizard earns you three additional lives. Touching a servant or a room wall or failing to exit a room within the allotted time will cause loss of a life. You cannot exit a room until you capture both door keys in that room by touching them. One key is invisible until the other key is touched.

Once both keys are captured, the room's exit appears—unless you are in a castle's tenth room. In this case, the wizard appears, and you must capture him before you can escape. Also, once you capture the first key, your presence becomes known to the wizard, and he causes room wall segments to move to block your escape. You must move quickly to avoid destruction.

Secret Passages

A counter at the top of the screen signals the amount of "cloak time" remaining. Pressing the joystick fire button will temporarily freeze the action, permitting you to move safely past a tight corner, but you lose 50 units of cloak time each time you use the freeze option. The room number and the number of your remaining lives are displayed at the top left of the screen. Your score—a measure of your ability to elude the many dangers involved—is displayed at the top right of the screen.

Room patterns, key locations, servant locations, and wizard placement are randomly generated, so be prepared to touch keys partially embedded in walls, move through weird mazes, etc. Sometimes a secret passageway is created at the bottom or in a room's right wall. You may use these passageways for a quick, easy escape.


Castle Quest
10 REM {5 SPACES}MEMORY SAVER{14 SPACES}
20 C0=0:C1=1:C2=2:C3=3:C4=4:C5=5:C6=6:C7=7:C8=8:C9=9:C10=10:C15=15:C16=16:C256=256:RAMTOP=PEEK(106):MISSION=C1
30 REM   INITIALIZATION ROUTINE{7 SPACES}
40 GOSUB 1080:GOSUB 770:GRAPHICS C16:? "{CLEAR}":POKE 752,C1:SETCOLOR C2,C0,C0:GOSUB 310
50 T1=C8:GOSUB 1150:T1=C16:GOSUB 1150:G=C0:L=C3:Q=C0:C=C0:X1=C0:SCORE=C0
60 GOSUB 320
70 REM {4 SPACES}ROOM SETUP ROUTINE{9 SPACES}
80 GOSUB 970:GOSUB 450:GOSUB 1340:GOSUB 1500:POKE 1568,C1:POKE 77,0:POKE 53248,60:POKE 53249,W1
90 IF C=C10 THEN GOSUB 340
100 X=USR(1767):FOR I=C0 TO 100:NEXT I:POKE 1568,F
110 REM {6 SPACES}MAIN PROGRAM LOOP{8 SPACES}
120 G=G-C1:IF (PEEK(1566)<>C0) OR (G<C0) THEN 400
130 IF PEEK(203)>204 THEN 520
140 POSITION 23-(G>999)-(G>99)-(G>C9),C0:? CHR$(B);G;CHR$(B):IF G<100 THEN SETCOLOR C2,C4,C0
150 X=PEEK(53260):IF (X-X1)>=C2 THEN POKE 53250,W2:POKE 53249,C0:IF PEEK(706)<>N THEN GOSUB 380:POKE 706,N
160 IF X-X1>=C4 THEN POKE 53251,W3:POKE 53250,C0
170 IF X>=C6 THEN GOSUB 260
180 IF STRIG(C0)=C0 THEN POKE 1568,C1:G=G-50:FOR I=0 TO 250:NEXT I:POKE 1568,F
190 CHBASE=RAMTOP-C8-C8*(INT(G/2)=G/2):POKE 756,CHBASE
200 IF PEEK(706)=N THEN IF RND(C0)>0.95 THEN PLOT INT(RND(C0)*38),INT(RND(C0)*22):GOSUB 240
210 IF STICK(C0)<>15 THEN SOUND C2,100,C6,C8:SOUND C2,C0,C0,C0
220 GOTO 120
230 REM {3 SPACES}"SHOOTING" SOUND ROUTINE{3 SPACES}
240 FOR I=C0 TO 30:SOUND C0,I,C0,C15:NEXT I:SOUND C0,C0,C0,C0:RETURN 
250 REM  ROOM EXIT OPENING ROUTINE{4 SPACES}
260 IF C=C10 THEN IF X<>14 THEN RETURN 
270 FOR I=C0 TO C5:POKE SC+C10*40+I*40-C1,C0:NEXT I:POKE 53278,255:FOR I=C15 TO C0 STEP -C1:SOUND C0,C10,C10,I
280 SOUND C1,11,C10,I+C1:SOUND C2,12,C10,I+C2:SOUND 3,13,10,I+3:NEXT I:FOR I=0 TO 3:SOUND I,C0,C0,C0:NEXT I
290 POKE 53251,C0:POKE 53250,C0:POKE 53278,255:RETURN 
300 REM   USER INFORMATION ROUTINES{3 SPACES}
310 POSITION C10+C1,C10:? "Wait for game setup":RETURN 
320 C=C+C1:POSITION C10,C10:? "Get ready for Room ";C:C=C-C1:RETURN 
330 REM  WIZARD PLOTTING ROUTINE{6 SPACES}
340 PL=(RAMTOP-9)*256:PL=PL+52+INT(RND(C0)*151):RESTORE 350:FOR I=C0 TO 11:READ Z:POKE PL+I,Z:NEXT I
350 DATA 102,36,126,90,126,126,66,90,60,60,36,102
360 W3=70+INT(RND(C0)*130):POKE 707,P:RETURN 
370 REM  "KEY TOUCHING" SOUND ROUTINE 
380 SOUND C2,20,C10,C10:SOUND C1,80,C10,C10:FOR I=0 TO 30:NEXT I:SOUND C1,C0,C0,C0:SOUND C2,C0,C0,C0:RETURN 
390 REM   USER FAILS TO ESCAPE ROOM{3 SPACES}{8 SPACES}  ROUTINE{21 SPACES}
400 FOR I=C0 TO C3:POKE 53248+I,C1:NEXT I:POKE 1568,C1:? "{CLEAR}":SETCOLOR C2,C0,C0:IF Q THEN RETURN 
410 POKE DL+C15,C7:POSITION C4,C10:IF Q THEN RETURN 
420 POKE 756,224:? "TOUGH LUCK!":FOR I=C0 TO 200:SOUND C0,C6,100,C8:NEXT I:SOUND C0,C0,C0,C0:T2=C1
430 POKE DL+C15,C2:L=L-C1:? "{CLEAR}":C=C-1:GOSUB 320:C=C+1:GOTO 80+500*(L<=C0)
440 REM DETERMINE NEXT ROOM'S{9 SPACES}{8 SPACES}CHARACTERISTICS ROUTINE{7 SPACES}
450 A=INT(C16*RND(C0))*C16+C6:M=INT(C16*RND(C0))*C16+C2:N=INT(C16*RND(C0))*C16+C4:P=INT(C16*RND(C0))*C16+C8
460 B=33+C-C6*(C>5):C=C+C1:D=C2+C2*(C>C1)+C4*(C>C3)+C8*(C>C6)+C16*(C>C9)
470 E=INT(RND(0)*5+7):POKE 1763,E
480 F=C2+(C>C9)+C2*(MISSION-C1)
490 G=100+C*50:COLOR B:POKE 1578,31:POKE 1566,C0:POKE 756,RAMTOP-C8:POKE 53278,255:X1=C0
500 SETCOLOR 2,C7*(C=7)+C2*(C=8)+C1*(C=9)+C3*(C=10),C0:RETURN 
510 REM  USER ESCAPES FROM A ROOM{5 SPACES}{8 SPACES} ROUTINE{22 SPACES}
520 Q=C1:GOSUB 400:GOSUB 410:POKE 756,224:? "{3 SPACES}ATTABOY!":Q=C0
530 FOR I=C0 TO C5:SOUND C0,C10,50,C8:POKE 705,C10:POKE 706,C10:POKE 710,C10:POKE 712,C10:FOR J=C0 TO 50:NEXT J
540 SOUND C0,C10,100,C8:POKE 705,C0:POKE 706,C0:POKE 710,C0:POKE 712,C0:FOR J=C0 TO 50:NEXT J:NEXT I
550 SOUND C0,C0,C0,C0:POKE DL+C15,C2:? "{CLEAR}":GOSUB 320:SCORE=SCORE+MISSION*INT((G*C)/C10)
560 IF C=C10 THEN GOTO 580+110*(MISSION=C3)
570 GOTO 80
580 REM {3 SPACES}END A QUEST ROUTINE{8 SPACES}
590 ? "{CLEAR}":POKE DL+C9,C6:POKE DL+11,C6:POKE DL+13,C6:POKE DL+15,C6:POKE 707,C0:IF L<=C0 THEN 660
600 POSITION C2,C4:? "congratulations!":POSITION 26,C5:? "YOU HAVE":POSITION C3,C7:? "COMPLETED YOUR"
610 POSITION 27,C8:? "QUEST":C=C0:L=L+C3
620 POSITION C5,15:? "Press START  to continue":POSITION C5,17:? "Press SYSTEM RESET  to quit"
630 POSITION C5,19:? "SCORE: ";SCORE
640 POKE 53279,C8:IF PEEK(53279)<>C6 THEN 640
650 ? "{CLEAR}":POKE DL+C9,C2:POKE DL+11,C2:POKE DL+13,C2:POKE DL+15,C2:MISSION=MISSION+(L>C0)*C1:GOTO 60+620*(L<=C0)
660 POSITION C7,C4:? "SORRY!":POSITION 24,C5:? "you blew it.":POSITION C2,C7:? "quests completed ";MISSION-C1
670 GOTO 620
680 RUN 
690 REM USER WINS THE GAME ROUTINE!{3 SPACES}
700 GRAPHICS 2:SETCOLOR C2,C0,C0:POSITION C6,C4:? #6;"YOU WON!":? "Press SYSTEM RESET and then 'RUN' to";
710 POKE 752,1:? :? "begin a new game."
720 POSITION C1,C7:? #6;"final score ";SCORE
730 FOR I=255 TO C0 STEP -C1:SOUND C0,I,10,10:POKE 712,I:POKE 710,I:NEXT I
740 GOTO 740
750 POKE 1568,C1:RUN 
760 REM PUT A VERTICAL BLANK INTERRUPT{8 SPACES} ROUTINE IN PAGE 6 OF MEMORY  
770 RESTORE 790:FOR I=1536 TO 1536+247:READ A:POKE I,A:NEXT I
780 RETURN 
790 DATA 173,4,208,201,4,240,2,208,22,173,99,228,141,36,2
800 DATA 173,100,228,141,37,2,141,30,6,141,30,208,76,98,228
810 DATA 0,162,2,202,240,42,138,72,173,10,210,41,7,10,170
820 DATA 189,0,1,133,206,133,208,232,189,0,1,133,207,133,209
830 DATA 32,148,6,165,207,157,0,1,202,165,206,157,0,1,104
840 DATA 170,208,211,162,5,173,120,2,202,240,197,24,106,176,249
850 DATA 72,224,2,240,8,224,1,208,13,230,203,208,2,198,203
860 DATA 165,203,141,0,208,208,32,169,0,224,4,240,8,168,145
870 DATA 204,230,204,76,134,6,160,7,145,204,198,204,160,0,185
880 DATA 240,6,145,204,200,192,8,208,246,104,76,83,6,160,0
890 DATA 152,145,206,173,10,210,41,1,208,15,169,56,141,201,6
900 DATA 169,233,141,204,6,141,210,6,208,13,169,24,141,201,6
910 DATA 169,105,141,204,6,141,210,6,173,10,210,41,1,208,2
920 DATA 169,40,141,205,6,216,0,165,206,0,0,133,206,165,207,0
930 DATA 0,133,207,177,206,240,8,165,208,133,206,165,209,133,207
940 DATA 169,11,145,206,96,104,168,162,6,169,7,76,92,228,60
950 DATA 126,90,126,90,102,126,60
960 REM SETUP PLAYER-MISSILE  GRAPH- {9 SPACES}ICS ROUTINE{18 SPACES}
970 POKE 559,62:POKE 54279,RAMTOP-C16:POKE 53248,C1:POKE 53277,C3
980 PL=RAMTOP-12:Y=PEEK(88):Z=PEEK(89):POKE 88,C0:POKE 89,PL:POKE 106,PL+C3:? "{CLEAR}":POKE 88,Y:POKE 89,Z
990 POKE 106,PL+12:PL=PL*C256+120:IF C=C0 OR C=C10 THEN Z=(RAMTOP-C9)*C256:FOR I=Z TO Z+255:POKE I,C0:NEXT I
1000 FOR I=C0 TO C7:POKE PL+I,PEEK(1776+I):NEXT I
1010 POKE 203,60:POKE 204,PL-INT(PL/C256)*C256:POKE 205,INT(PL/C256)
1020 PL=(RAMTOP-11)*C256:PL=PL+52+INT(RND(C0)*151):RESTORE 1030:FOR I=C0 TO C7:READ Z:POKE PL+I,Z:NEXT I
1030 DATA 0,6,15,249,255,166,160,0
1040 W1=70+INT(RND(C0)*130):PL=(RAMTOP-C10)*C256:PL=PL+52+INT(RND(C0)*151):RESTORE 1030:FOR I=C0 TO C7
1050 READ Z:POKE PL+I,Z:NEXT I:W2=70+INT(RND(C0)*130):POKE 705,M:IF T2=C1 THEN C=C-C1:T2=C0
1060 POKE 53249,C0:POKE 53250,C0:RETURN 
1070 REM {4 SPACES}TITLE PAGE ROUTINE{7 SPACES}
1080 GRAPHICS 18:SETCOLOR C2,C0,C0:POKE 708,202:POSITION C5,C2:? #C6;"CASTLE":POSITION C9,C4:? #C6;"QUEST"
1090 DL=PEEK(560)+C256*PEEK(561):POKE DL+13,C2
1100 POSITION C3,C8:? #C6;"How many rooms can you survive?"
1110 FOR I=C0 TO C3:POKE 708,C0:SOUND C0,60,C10,C8:FOR J=C0 TO 100:NEXT J:SOUND C0,160,C10,C8:POKE 708,202
1120 FOR J=C0 TO 100:NEXT J:NEXT I
1130 SOUND C0,C0,C0,C0:RETURN 
1140 REM SETUP SPECIAL CHARACTER SETS {9 SPACES}ROUTINE{22 SPACES}
1150 RESTORE 1160:CL=(RAMTOP-T1)*C256:FOR I=CL+C8 TO CL+95:READ A:POKE I,A:NEXT I
1160 DATA 204,51,204,51,204,51,204,51,102,153,102,153,102,153,102,153
1170 DATA 136,34,136,34,136,34,136,34,68,17,68,17,68,17,68,17
1180 DATA 36,146,73,36,146,73,36,146,255,255,255,255,255,255,255,255
1190 DATA 195,102,60,24,24,0,0,0
1200 DATA 255,255,195,195,195,195,255,255
1210 DATA 255,255,0,0,0,0,255,255
1220 DATA 24,24,60,24,255,199,199,255
1230 DATA 24,255,0,0,0,0,0,0
1240 FOR I=128 TO 224:POKE CL+I,PEEK(57344+I):NEXT I
1250 DL=PEEK(560)+C256*PEEK(561):IF T1=C16 THEN RESTORE 1260:FOR I=CL+56 TO CL+95:READ A:POKE I,A:NEXT I
1260 DATA 0,0,0,24,24,60,102,195
1270 DATA 0,0,60,60,60,60,0,0
1280 DATA 0,0,255,255,255,255,0,0
1290 DATA 60,24,24,24,60,60,0,0
1300 DATA 24,24,24,24,24,24,24,255
1310 IF T1=C16 THEN FOR I=CL TO CL+C7:POKE I,C0:NEXT I
1320 RETURN 
1330 REM   RANDOM ROOM MAZE GENERATOR {9 SPACES}  ROUTINE{20 SPACES}
1340 ? "{CLEAR}":POKE 752,C1
1350 PLOT C0,C0:DRAWTO 39,C0:DRAWTO 39,23:DRAWTO C0,23:DRAWTO C0,C0
1360 X=C10:Y=C0:Z=C7:GOSUB 1400:X=C15:Y=C5:Z=13:GOSUB 1400:X=C10:Y=C16:Z=C7:GOSUB 1400
1370 IF RND(C0)<0.5 THEN PLOT RND(C0)*31+C8,11:DRAWTO RND(C0)*31+C8,11
1380 POSITION C6,C0:? C:POKE 704,A:POKE 705,M
1390 POSITION C9,C0:? L:POSITION 30,C0:? SCORE:RETURN 
1400 ON INT(RND(C0)*C8+C1) GOSUB 1410,1420,1430,1440,1450,1460,1470,1480
1410 RETURN 
1420 PLOT X,Y:DRAWTO X,Y+Z:RETURN 
1430 X=X+C10:GOSUB 1420:RETURN 
1440 X=X+20:GOSUB 1420:RETURN 
1450 GOSUB 1420:GOSUB 1430:RETURN 
1460 GOSUB 1430:GOSUB 1430:RETURN 
1470 GOSUB 1420:GOSUB 1460:RETURN 
1480 POP :GOTO 1360
1490 REM WIZARD'S SERVANTS PLOTTING{3 SPACES}{9 SPACES}AND ADDRESS CALCULATION ROUT-{9 SPACES}INE. ADDRESSES KEPT IN STACK 
1500 SC=PEEK(88)+C256*PEEK(89):FOR I=C0 TO D-C1:IF INT(RND(C0)*C4)>C2 THEN 1520
1510 H=SC+40+INT(RND(C0)*279):GOTO 1530
1520 H=SC+680+INT(RND(C0)*239)
1530 HI=INT(H/C256):LO=H-HI*C256:POKE C256+I*C2,LO:POKE H,E
1540 POKE C256+I*C2+C1,HI:NEXT I:IF D=32 THEN RETURN 
1550 FOR I=(D-C1) TO 31:POKE C256+I*C2+C1,254:NEXT I:RETURN 

Listing. Castle Quest.
Download (Saved BASIC) / Download (Listed BASIC)


Return to Table of Contents | Previous Section | Next Section