10 ' PYRAMID4
20 MODE 1:BORDER 0:PAPER 0
25 IF PEEK(&BE80)=0 THEN A=6:B=7:C=3:D=0:E=4:F=1
30 IF PEEK(&BE80)=1 THEN A=6:B=3:C=2:D=2:E=12:F=1
35 FOR i=0 TO 3:INK i,0:NEXT i
40 MEMORY &3FFF
50 LOAD"Pyramid4.cmp"
60 FOR i=0 TO 3:INK i,0:NEXT i
70 POKE &A634,&C8:POKE &A635,0:POKE &A636,0:CALL &A60B
80 POKE &C7F1,&C9:CALL &C7D0
90 CALL &A60B

95 IF PEEK(&BE80)=0 THEN PEN 3:PAPER 2:LOCATE 9,6:PRINT CHR$(150):LOCATE 9,7:PRINT CHR$(151):LOCATE 9,8:PRINT CHR$(147):LOCATE 12,6:PRINT CHR$(32):LOCATE 13,6:PRINT CHR$(148):LOCATE 13,8:PRINT CHR$(145)

96 IF PEEK(&BE80)=1 THEN PEN 3:PAPER 2:LOCATE 9,6:PRINT CHR$(150):LOCATE 9,7:PRINT CHR$(147):LOCATE 9,8:PRINT CHR$(146):LOCATE 12,6:PRINT CHR$(146):LOCATE 13,6:PRINT CHR$(156):LOCATE 13,8:PRINT CHR$(145)

99 PAPER 0
100 WINDOW #1,25,36,4,19
110 INK 0,0:INK 1,3:INK 2,15:INK 3,24
120 PEN #1,3:PRINT #1:PRINT #1,"An old wall":PRINT #1,"with its":PRINT #1,"stones":PRINT #1,"engraved"
125 PRINT #1,"with a":PRINT #1,"puzzle that":PRINT #1,"only a":PRINT #1,"clever":PRINT #1,"mind can":PRINT #1,"solve."

130 LOCATE 13,20:PEN 2:PRINT"WHAT WILL YOU DO ?"
150 PEN 3:LOCATE 4,22:PRINT "1-EAST        2-Examine wall"
160 PEN 2:LOCATE 4,23:PRINT "3-Rub the wall vigorously"
170 PEN 3:LOCATE 4,24:PRINT "Press button: 4-5-6-7-8-9"

200 k$=INKEY$
210 IF k$="4" THEN A=A+1:SOUND 1,100:GOTO 300
220 IF k$="7" THEN B=B+1:SOUND 1,120:GOTO 400
230 IF k$="8" THEN C=C+1:SOUND 1,140:GOTO 500
240 IF k$="5" THEN D=D+1:SOUND 1,160:GOTO 600
250 IF k$="9" THEN E=E+1:SOUND 1,180:GOTO 700
255 IF k$="6" THEN F=F+1:SOUND 1,220:GOTO 800
260 IF k$="1" THEN RUN"Pyramid5.bas"
270 IF k$="2" THEN GOTO 1400
280 IF k$="3" THEN GOTO 1600
290 IF k$<"1" OR k$>"9" THEN GOTO 200

300 IF A>15 THEN A=1
320 PEN 3:PAPER 2:LOCATE 9,6:PRINT CHR$(144+A)
330 GOTO 1000

400 IF B>15 THEN B=1
410 PEN 3:PAPER 2:LOCATE 9,7:PRINT CHR$(144+B)
420 GOTO 1000

500 IF C>15 THEN C=1
520 PEN 3:PAPER 2:LOCATE 9,8:PRINT CHR$(144+C)
530 GOTO 1000

600 IF D>15 THEN D=1
620 PEN 3:PAPER 2:LOCATE 12,6:PRINT CHR$(144+D)
630 GOTO 1000

700 IF E>15 THEN E=1
720 PEN 3:PAPER 2:LOCATE 13,6:PRINT CHR$(144+E)
730 GOTO 1000

800 IF F>15 THEN F=1
820 PEN 3:PAPER 2:LOCATE 13,8:PRINT CHR$(144+F)
830 GOTO 1000

1000 IF F=1 AND A=6 AND B=3 AND C=2 AND D=2 AND E=12 THEN GOTO 1100
1001 IF F=1 AND A=6 AND B=3 AND C=2 AND D=6 AND E=12 THEN GOTO 1100
1002 IF F=1 AND A=6 AND B=3 AND C=2 AND D=10 AND E=12 THEN GOTO 1100
1003 IF F=1 AND A=6 AND B=3 AND C=3 AND D=2 AND E=12 THEN GOTO 1100
1004 IF F=1 AND A=6 AND B=3 AND C=3 AND D=6 AND E=12 THEN GOTO 1100
1005 IF F=1 AND A=6 AND B=3 AND C=3 AND D=10 AND E=12 THEN GOTO 1100
1006 IF F=1 AND A=6 AND B=3 AND C=10 AND D=2 AND E=12 THEN GOTO 1100
1007 IF F=1 AND A=6 AND B=3 AND C=10 AND D=6 AND E=12 THEN GOTO 1100
1008 IF F=1 AND A=6 AND B=3 AND C=10 AND D=10 AND E=12 THEN GOTO 1100

1010 IF F=5 AND A=6 AND B=3 AND C=2 AND D=2 AND E=12 THEN GOTO 1100
1011 IF F=5 AND A=6 AND B=3 AND C=2 AND D=6 AND E=12 THEN GOTO 1100
1012 IF F=5 AND A=6 AND B=3 AND C=2 AND D=10 AND E=12 THEN GOTO 1100
1013 IF F=5 AND A=6 AND B=3 AND C=3 AND D=2 AND E=12 THEN GOTO 1100
1014 IF F=5 AND A=6 AND B=3 AND C=3 AND D=6 AND E=12 THEN GOTO 1100
1015 IF F=5 AND A=6 AND B=3 AND C=3 AND D=10 AND E=12 THEN GOTO 1100
1016 IF F=5 AND A=6 AND B=3 AND C=10 AND D=2 AND E=12 THEN GOTO 1100
1017 IF F=5 AND A=6 AND B=3 AND C=10 AND D=6 AND E=12 THEN GOTO 1100
1018 IF F=5 AND A=6 AND B=3 AND C=10 AND D=10 AND E=12 THEN GOTO 1100

1090 GOTO 200

1100 SOUND 1,300:SOUND 1,250:SOUND 1,200:SOUND 1,150:SOUND 1,100
1110 SOUND 1,50:SOUND 1,300:SOUND 1,250:SOUND 1,200:SOUND 1,150:SOUND 1,100:SOUND 1,50
1120 FOR i=1 TO 1000:NEXT i
1130 IF PEEK(&BE80)=1 THEN GOTO 1300
1140 MODE 1:INK 0,0:INK 1,6:INK 2,15:INK 3,24:PAPER 0:POKE &BE80,1
1150 PEN 3:PRINT:PRINT"Incredible!"
1160 PEN 2:PRINT:PRINT"You just proved your mental":PRINT"calculation level surpasses":PRINT"that of an average first grader."
1170 PEN 1:PRINT:PRINT"As a reward, the floor opens":PRINT"with a mysterious rumble..."
1180 PEN 3:PRINT:PRINT"And, surprise, a key shaped like":PRINT"an Ankh appears!"
1190 PEN 2:PRINT:PRINT"You pick it up, proud as if you":PRINT"just invented mathematics.":PEN 1:PRINT:PRINT"Bravo, desert Einstein!"
1195 PEN 3:LOCATE 15,25:INPUT" ENTER  ",en$
1197 POKE &BE80,1:GOTO 60

1300 MODE 1:INK 0,0:INK 1,6:INK 2,15:INK 3,24:PAPER 0
1310 PEN 3:PRINT:PRINT"Well done..."
1320 PEN 2:PRINT:PRINT"Once again, you solved the":PRINT"same puzzle..."
1330 PEN 1:PRINT:PRINT"         What a performance!"
1340 PEN 3:PRINT:PRINT"You must enjoy reviewing your":PRINT"addition tables, huh?"
1350 PEN 2:PRINT:PRINT"Well, let's be honest: it's":PRINT"useless since you already got":PRINT"the key, but if it makes you":PRINT"happy, then so be it!"
1360 PEN 1:PRINT:PRINT"Keep going, mental calculation champ!"
1370 PEN 3:LOCATE 15,25:INPUT" ENTER  ",en$
1380 GOTO 60   

1400 MODE 1:INK 0,0:INK 1,6:INK 2,15:INK 3,24:PAPER 0
1410 IF PEEK(&BE80)=1 THEN GOTO 1500
1420 PEN 3:PRINT:PRINT"Ancient Egyptians had a":PRINT"reputation for being great":PRINT"mathematicians..."
1430 PEN 2:PRINT:PRINT"Yet seeing this operation, you":PRINT"think maybe they skipped":PRINT"some lessons."
1440 PEN 1:PRINT:PRINT"    Carved in stone: 6+1=12."
1450 PEN 3:PRINT:PRINT"Hmm... either they invented a":PRINT"numeric system never known":PRINT"or someone really messed up."
1460 PEN 2:PRINT:PRINT"Under the operation, six buttons":PRINT"await your curious fingers."
1470 PEN 3:PRINT:PRINT"Here you face a puzzle that will":PRINT"require as much thought as":PRINT"your first-grade memories!"
1480 LOCATE 15,25:INPUT" ENTER  ",en$
1490 GOTO 60

1500 MODE 1:INK 0,0:INK 1,6:INK 2,15:INK 3,24:PAPER 0
1510 PEN 3:PRINT:PRINT"You proudly contemplate the wall:"
1520 PEN 1:PRINT:PRINT"               5+7=12."
1530 PEN 2:PRINT:PRINT"A simple equation, but a true":PRINT"work of art in your eyes."
1540 PEN 3:PRINT:PRINT"It's beautiful like a sunrise over":PRINT"an abacus."
1550 PEN 2:PRINT:PRINT"You don't touch anything, of course,":PRINT"for fear your masterpiece would go":PRINT"into error mode."
1560 PEN 1:PRINT:PRINT"Yes, really, what harmony..."
1570 PEN 3:PRINT:PRINT"You could almost frame this wall":PRINT"and sell it to a mathematics museum!"
1580 LOCATE 15,25:INPUT" ENTER  ",en$
1590 GOTO 60

1600 MODE 1:INK 0,0:INK 1,6:INK 2,15:INK 3,24:PAPER 0
1610 PEN 3:PRINT:PRINT"You start rubbing frenetically,":PRINT"worthy of an Olympic cleaning":PRINT"contest."
1620 PEN 2:PRINT:PRINT"Dust flies, arms burn, and for":PRINT"a moment, you almost feel useful."
1630 PEN 1:PRINT:PRINT"But no..."
1640 PEN 3:PRINT:PRINT"It's still the same old wall,":PRINT"as sealed as a safe."
1650 PEN 2:PRINT:PRINT"Rubbing like crazy won't erase":PRINT"the addition... this is not":PRINT"a restaurant, the waiter won't come!"
1660 PEN 3:LOCATE 15,25:INPUT" ENTER  ",en$
1670 GOTO 60
