1 REMark Santa's Dilemma by David Nowotnik from ZX Computing December 1986
10 REMark Santa's Dilemma
20 REMark by David Nowotnik
30 REMark October 1986
40 :
100 init: TITLE: INSTRUCTIONS
110 REPeat main_loop
120 SET_UP_SCREEN: GAME: END_MESSAGE
130 PRINT #0\"       Another game (y/n)?"
140 REPeat get_reply
150   z$=INKEY$(-1)
160   IF z$="y" OR z$="n" THEN EXIT get_reply
170 END REPeat get_reply
180 CLS #0
190 IF z$="n" THEN EXIT main_loop
200 END REPeat main_loop
210 CLS: STOP
220 :
230 DEFine PROCedure init
240 LOCal a,n,byt
250 REMark UDGs
260 a=RESPR(0)
270 IF a>261900 THEN a=RESPR(244)
280 POKE_L (PEEK_L (166756)+46),a
290 RESTORE 330
300 FOR n=0 TO 46
310   READ byt: POKE (a+N),byt
320 END FOR n
330 DATA 127,15
340 DATA 0,0,0,0,0,0,0,0,0
350 DATA 56,56,16,56,56,124,124,40,108
360 DATA 20,28,28,8,124,125,124,68,68
370 DATA 0,16,16,56,56,124,124,56,124
380 DATA 16,16,16,16,16,16,56,56,0
390 REMark WINDOWS
400 MODE 8
410 WINDOW 512,256,0,0
420 PAPER 0: CLS
430 WINDOW 406,230,44,0
440 BORDER 5,2
450 PAPER 7: CLS
460 CSIZE 0,0
470 WINDOW #0,406,24,44,230
480 BORDER #0,2,1
490 PAPER #0,0: INK #0,7: CLS #0
500 REMark VARIABLES
510 DIM screen$(32,22)
520 sany=8: sanx=2
530 DIM m(4,2),r(8,2)
540 FOR n=1 TO 4
550   READ m(n,1),m(n,2)
560 END FOR n
570 FOR n=1 TO 8
580   READ r(n,1),r(n,2)
590 END FOR n
600 tr=0
610 DATA 0,-1,1,0,-1,0,0,1
620 DATA -1,0,-1,-1,1,0,1,1
630 DATA -1,1,1,-1,0,1,0,-1
640 santa$=CHR$(128): r_deer$=CHR$(129)
650 tree_top$=CHR$(130): stump$=CHR$(131)
660 empty$=CHR$(0)
670 END DEFine init
680 :
690 DEFine PROCedure PRINT_TREE
700 INK 4: AT y,x: PRINT tree_top$;
710 INK 3: AT y+1,x: PRINT stump$;
720 screen$(x+1,y+1)=tree_top$
730 screen$(x+1,y+2)=stump$
740 END DEFine PRINT_TREE
750 :
760 DEFine PROCedure TITLE
770 LOCal i,x,y
780 FOR i=1 TO 50
790   REPeat title_loop_1
800     y=RND(20): x=RND(31)
810     IF screen$(x,y+1)<>tree_top$ THEN EXIT title_loop_1
820   END REPeat title_loop_1
830   PRINT_TREE x,y
840 END FOR i
850 CSIZE 3,1: OVER 1
860 AT 4,8: INK 2: PRINT "SANTA'S"
870 FLASH 1: AT 6,8: PRINT "DILEMMA"
880 FLASH 0: CSIZE 0,0: OVER 0
890 TUNE
900 END DEFine TITLE
910 :
920 DEFine PROCedure TUNE
930 RESTORE 1010
940 READ time: POKE_W 163886,time
950 REPeat tune_loop
960   REPeat delay
970     IF PEEK_W (163886)>time THEN EXIT delay
980   END REPeat delay
990   READ note,time
1000   SELect ON note
1010   =0: BEEP
1020   =255: EXIT tune_loop
1030   =REMAINDER: BEEP 10000,note
1040   END SELect
1050 END REPeat tune_loop
1060 DATA 330,18,368,0,371,11,405,0,409
1070 DATA 11,424,0,426,9,434,0,448,11,463
1080 DATA 0,469,12,481,0,485,15,517,0,522
1090 DATA 15,554,0,558,15,577,0,593,9,619
1100 DATA 0,630,9,649,0,654,7,665,0,671
1110 DATA 9,684,0,688,11,703,0,709,12,740
1120 DATA 0,751,12,776,0,787,12,811,0,840
1130 DATA 7,872,0,876,7,893,0,899,6,905
1140 DATA 0,915,7,926,0,932,9,945,0,949
1150 DATA 11,978,0,988,15,1016,0,1027,18,1051
1160 DATA 0,1060,15,1088,0,1099,9,1125,0,1136
1170 DATA 12,1166,0,1176,11,1233,0,1267
1180 DATA 255,1267
1190 END DEFine TUNE
1200 :
1210 DEFine PROCedure INSTRUCTIONS
1220 CLS: INK 1: AT 2,9
1230 PRINT "Santa's Dilemma"\\\
1240 PRINT "   It's Christmas Eve, and Santawants to get underway to"
1250 PRINT "deliver sackfulls of super microgames to all those lucky girls"
1260 PRINT "and boys whose parents have     bought them Spectrums, QLs, "
1270 PRINT "and other micros for Christmas."
1280 PRINT "  But someone has left his gatesopen, and all the reindeer have"
1290 PRINT "got out. You'll have to guide   Santa to help him get 6 reindeer";
1300 PRINT "back into the pen at the left ofthe screen."
1310 GET_A_KEY
1320 INK 1: CLS: AT 2,9
1330 PRINT "Santa's Dilemma"\\\
1340 PRINT "   You guide Santa by using the cursor  keys. The reindeer will"
1350 PRINT "move away from Santa when he    stands next to them."\\
1360 PRINT " You have to get 6 reindeer intothe pen as fast as possible. The"
1370 PRINT "number at the bottom of the     screen is the number of presents"
1380 PRINT "Santa has time to deliver. As   you want to disappoint as few"
1390 PRINT "children as possible, aim to    drive the six reindeer into the pen as quickly as you can."
1400 PRINT "          Good Luck!"
1410 GET_A_KEY
1420 END DEFine INSTRUCTIONS
1430 :
1440 DEFine PROCedure GET_A_KEY
1450 INK 2: AT 21,3
1460 PRINT "Press any key to continue"
1470 REPeat key_loop
1480   IF INKEY$(0)<>"" THEN EXIT key_loop
1490 END REPeat key_loop
1500 END DEFine GET_A_KEY
1510 :
1520 DEFine PROCedure SET_UP_SCREEN
1530 DIM screen$(32,22)
1540 CLS: PAPER 0
1550 FOR j=6,14
1560   FOR i=0 TO 5
1570     AT j,i: PRINT " "
1580     screen$(i+1,j+1)="W"
1590   END FOR i
1600 END FOR j
1610 FOR i=7,8,9,11,12,13
1620   AT i,5: PRINT " "
1630   screen$(6,i+1)="W"
1640 END FOR i
1650 PAPER 7
1660 FOR i=1 TO 50
1670   REPeat set_up_loop
1680     x=RND(31): y=RND(20)
1690     ll=(x>10 OR y<3 OR y>16)
1700     lk=(screen$(x+1,y+2)=empty$)
1710     IF ll AND lk THEN EXIT set_up_loop
1720   END REPeat set_up_loop
1730 PRINT_TREE x,y
1740 END FOR i
1750 INK 1
1760 FOR i=1 TO 10
1770   REPeat deer_loop
1780     x=RND(29)+1: y=RND(19)+1
1790     ll=(x>10 OR y<3 OR y>16)
1800     lk=(screen$(x+1,y+1)=empty$)
1810     IF ll AND lk THEN EXIT deer_loop
1820   END REPeat deer_loop
1830   AT y,x: PRINT r_deer$
1840   screen$(x+1,y+1)=r_deer$
1850 END FOR i
1860 INK 2: AT 8,2: PRINT santa$
1870 sanx=2: sany=8
1880 screen$(3,9)=santa$
1890 POKE_W 163886,0
1900 END DEFine SET_UP_SCREEN
1910 :
1920 DEFine PROCedure GAME
1930 LOCal b,x,y,x1,y1,move_santa,deer_collected
1940 deer_collected=0
1950 REPeat game_loop
1960 b=PEEK_W (163886): p=65000-b
1970 IF p>60000 THEN p=60000
1980 CURSOR #0,40,4: PRINT #0,"Presents = ";p;" "
1990 IF p<30000 THEN EXIT game_loop
2000 z=KEYROW(1): move_santa=0
2010 SELect ON z
2020 =2: move_santa=1
2030 =128: move_santa=2
2040 =4: move_santa=3
2050 =16: move_santa=4
2060 END SELect
2070 IF move_santa THEN
2080   INK 2: BEEP 50,20
2090   x=sanx+m(move_santa,2)
2100   y=sany+m(move_santa,1)
2110   IF y>-1 AND y<22 AND x>-1 AND x<32
2120     IF screen$(x+1,y+1)=empty$ THEN
2130       AT sany,sanx: PRINT " ";
2140       screen$(sanx+1,sany+1)=empty$
2150       sanx=x: sany=y
2160       AT sany,sanx: INK 2: PRINT santa$
2170     END IF
2180   END IF
2190 END IF
2200 FOR i=1 TO 8
2210   y=sany+r(i,1): x=sanx+r(i,2)
2220   IF y>-1 AND y<22 AND x>-1 AND x<32 THEN
2230     IF screen$(x+1,y+1)=r_deer$ THEN
2240       y1=y+r(i,1): x1=x+r(i,2)
2250       IF y1>-1 AND y1<22 AND x1>-1 AND x1<32 THEN
2260         IF screen$(x1+1,y1+1)=empty$ THEN
2270           INK 1
2280           AT y,x: PRINT " ";
2290           AT y1,x1: PRINT r_deer$;
2300           screen$(x+1,y+1)=empty$
2310           screen$(x1+1,y1+1)=r_deer$
2320           BEEP 50,5
2330         END IF
2340       END IF
2350     END IF
2360   END IF
2370 END FOR i
2380 IF screen$(6,11)=r_deer$ THEN
2390   INK 1: AT 10,5: PRINT " "
2400   screen$(6,11)=empty$
2410   AT deer_collected+7,0: PRINT r_deer$
2420   BEEP 100,2
2430   screen$(1,deer_collected+8)=r_deer$
2440   deer_collected=deer_collected+1
2450 END IF
2460 IF deer_collected=6 THEN EXIT game_loop
2470 END REPeat game_loop
2480 END DEFine GAME
2490 :
2500 DEFine PROCedure END_MESSAGE
2510 PAUSE 200: CLS: INK 0: CLS #0
2520 AT 4,4: PRINT "Santa can deliver ";p\" presents"
2530 AT 8,2
2540 SELect ON p
2550 =55000 TO 66000: PRINT "Well done! There won't be too many disappointments tonight.": TUNE
2560 =40000 TO 54999: PRINT "Not bad, but Santa will have to miss quite a few children.": TUNE
2570 =30000 TO 39999: PRINT "You've disappointed many"\" children tonight!"
2580 =REMAINDER: PRINT "Oh dear! You've failed to catch enough reindeer in time."
2590 END SELect
2600 IF p<40000 THEN
2610   FOR i=1 TO 20 STEP .25
2620     BEEP 1000,i
2630   END FOR i
2640   PAUSE 50: TUNE
2650 END IF
2660 END DEFine END_MESSAGE
