20 PRINT "Please standby for a few seconds..."
60 GOTO 75
70 LOCATE RN%,CN%:PRINT "                                       ";:RETURN
72 RETURN
75 DIM LOOPS%(100)
76 X=0: Y=0
78 AUTOFLAG%=0:A=0
80 DIM X$(1),TYPE$(4),COMMAND$(1),DIMFLAG%(1),ATIMOUT%(1),NAMEE$(10):X$="":TYPE$="":COMMAND$="":DIMFLAG%=0:ATIMOUT%=0:C=0: NAMEE$="":DIM SWAPF%(1): RN%=0: CN%=0
85 X=0:Y=0:PI=0:Z=0:COUNTER=0:COUNTER0=0:COUNTER1=0:COUNTER2=0:COUNTER3=0:COUNTER4=0:COUNTER5=0:COUNTER6=0:A=0:WRONG5=0:WRONG4=0:WRONG3=0:WRONG2=0:WRONG=0:WRONG6=0:LIMIT=0
86 COMMAND$="":NAMEE$="":COUNTER2=0:AUTOFLAG%=0:I=0:LIMIT=0:A=0:DIM SNAM$(10):SNAM$=""
90 RANDM$="12345678":RAND2$="12":RANDT%=0:RANDN%=0: X$="": RUNSW%=0: PRSW%=0
99 DIM PP%(5,9), PW%(5), PX%(5), PY%(5)
100 DIM K1(185),K2(185),K3(185),K4(185),K5(185),G1(185),G2(185),G3(185),G4(185),G5(185),R1(185),R2(185),R3(185),R4(185),R5(185)
120 DIM E1(205),E2(205),E3(205)
140 DIM S1(300),S2(300),S3(300),S4(300),S5(300),S6(300),S7(300),H1(185),H2(185),B1(40)
155 I=0:I1=0:I2=0:I3=0:I4=0:I5=0:I6=0:DIM I99(1): I99=0
160 FRAMEX%=14:FRAMEY%=51:LEFTX%=0:LEFTY%=0
180 SCALE1X%=25:SCALE1Y%=34:SCALE2X%=28:SCALE2Y%=38:SCALE3X%=26:SCALE3Y%=38:SCALE4Y%=42:SCALE5Y%=40:BLANKX%=2:BLANKY%=34
200 K1%=0:K2%=0:K3%=0:K4%=0:K5%=0
220 G1%=0:G2%=0:G3%=0:G4%=0:G5%=0
226 FOR I=1 TO 5: FOR I1=1 TO 9: PPX(I,I1)=0:NEXT I1: NEXT I
231 PW%(1)=0:PW%(2)=0:PW%(3)=0:PW%(4)=0:PW%(5)=0
232 PX%(1)=0:PX%(2)=0:PX%(3)=0:PX%(4)=0:PX%(5)=0
233 PY%(1)=0:PY%(2)=0:PY%(3)=0:PY%(4)=0:PY%(5)=0
240 R1%=0:R2%=0:R3%=0:R4%=0:R5%=0
260 S1%=0:S2%=0:S3%=0:S4%=0:S5%=0:S6%=0:S7%=0
280 H1%=0:H2%=0
300 B1%=0: LFX%=0: LFY%=0: SWAPF%=0
320 E1%=0:E2%=0:E3%=0
360 FLIP=0:SWAPF%=0:CN%=0:RN%=0
380 K1%=VARPTR(K1(0)):K2%=VARPTR(K2(0)):K3%=VARPTR(K3(0)):K4%=VARPTR(K4(0)):K5%=VARPTR(K5(0))
400 H1%=VARPTR(H1(0)):H2%=VARPTR(H2(0))
420 E1%=VARPTR(E1(0)):E2%=VARPTR(E2(0)):E3%=VARPTR(E3(0))
440 G1%=VARPTR(G1(0)):G2%=VARPTR(G2(0)):G3%=VARPTR(G3(0)):G4%=VARPTR(G4(0)):G5%=VARPTR(G5(0))
460 R1%=VARPTR(R1(0)):R2%=VARPTR(R2(0)):R3%=VARPTR(R3(0)):R4%=VARPTR(R4(0)):R5%=VARPTR(R5(0))
480 S1%=VARPTR(S1(0)):S2%=VARPTR(S2(0)):S3%=VARPTR(S3(0)):S4%=VARPTR(S4(0)):S5%=VARPTR(S5(0)):S6%=VARPTR(S6(0)):S7%=VARPTR(S7(0))
500 B1%=VARPTR(B1(0))
520 DEF SEG=&H1FF4:BLOAD"flip.mem",0:DEF SEG=&H1FFF:BLOAD"flipd.mem",0
540 DEF SEG
560 BLOAD"k1",K1%:BLOAD"k2",K2%:BLOAD"k3",K3%:BLOAD"k4",K4%:BLOAD"k5",K5%
580 BLOAD"g1",G1%:BLOAD"g2",G2%:BLOAD"g3",G3%:BLOAD"g4",G4%:BLOAD"g5",G5%
600 BLOAD"r1",R1%:BLOAD"r2",R2%:BLOAD"r3",R3%:BLOAD"r4",R4%:BLOAD"r5",R5%
620 BLOAD"e1",E1%:BLOAD"e2",E2%:BLOAD"e3",E3%
640 BLOAD"s1",S1%:BLOAD"s2",S2%:BLOAD"s3",S3%:BLOAD"s4",S4%:BLOAD"s5",S5%:BLOAD"s6",S6%:BLOAD"s7",S7%
660 BLOAD"h1",H1%:BLOAD"h2",H2%
680 BLOAD"b1",B1%
2020 WIDTH 40:SCREEN 1:SCREEN 0:LOCATE  ,,1,6,7
2050 GOSUB 30140:GOTO 2085
2080 GOSUB 30000
2085 REM
2520 'LOCATE 23,1,0:PRINT "Please standby for a few seconds...";
2680 GOSUB 9800 : '    TO INITALIZE
2700 CLS
2710 SCREEN 1,0: COLOR 0,0: GOSUB 27500
2720 GOSUB 11040 : '    TO ACCEPT NAME
2740 GOSUB 9540 : '    INSTRUCTIONS
2760 GOSUB 3000  : '    FIRST COMMAND
2780 GOSUB 9540 : '    INSTRUCTIONS
2800 GOSUB 3860  : '    SECOND COMMAND
2820 GOSUB 9540 : '    INSTRUCTIONS
2840 GOSUB 4720  : '    THIRD COMMAND
2860 GOSUB 9540 : '    INSTRUCTIONS
2880 GOSUB 5640  : '    FOURTH COMMAND
2900 GOSUB 9540 : '    INSTRUCTIONS
2920 GOSUB 6580  : '    FIFTH COMMAND
2940 GOSUB 9540 : '    INSTRUCTIONS
2960 GOSUB 8300  : '    SIXTH COMMAND
2980 END
3000 '
3020 '    TO ACCEPT FIRST COMMAND AND
3040 '    MAKE SURE IT IS THE CORRECT
3060 '    ONE.  PROMPTS WILL BE DISPLAYED
3080 '    TO HELP THE USER.
3100 GOSUB 28000
3101 LIMIT=60000!
3120 LOCATE 23,6 : PRINT "WHAT INSTRUCTION WOULD YOU LIKE";
3140 LOCATE 24,6 : PRINT "THE COMPUTER TO PERFORM FIRST?";
3160 LOCATE 25,6 : PRINT "PRESS A NUMBER (1 THROUGH 7).";
3180 ATIMOUT%=0
3200 COMMAND$=INKEY$ : IF COMMAND$="" THEN 3200
3220 IF (VAL(COMMAND$)=3) OR (VAL(COMMAND$)=5) THEN 3300
3240 WRONG=WRONG+1
3260 IF WRONG=1 THEN GOSUB 28000:LOCATE 23,1:PRINT "JUST TO KEEP THINGS SIMPLE, LET'S BEGIN";:LOCATE 24,1:PRINT "WITH THE ANIMALS AT THE LEFT. PLEASE";:LOCATE 25,1:PRINT "CHOOSE ANOTHER INSTRUCTION.";:GOTO 3200
3280 IF WRONG>=2 THEN GOSUB 28000:LOCATE 23,1:PRINT "PLEASE BEGIN YOUR PROGRAM WITH AN";:LOCATE 24,1:PRINT "INSTRUCTION THAT POSITIONS THE SCALE";:LOCATE 25,1:PRINT "ALL THE WAY TO THE LEFT.";:GOTO 3200
3300 IF VAL(COMMAND$)=3 THEN 3420
3340 GOSUB 28000
3360 LOCATE 24,1 : PRINT "IT WOULDN'T MAKE SENSE TO STOP SINCE WE";
3380 LOCATE 25,1 : PRINT "HAVEN'T EVEN STARTED YET.  TRY AGAIN.  ";
3400 GOTO 3200
3420 '           COLOR STATEMENT
3440 GOSUB 28100
3480 LOCATE 16,1 : PRINT "VERY GOOD. HERE IS THE FIRST INSTRUCTION";
3500 LOCATE 17,1 : PRINT "IN YOUR PROGRAM.";
3540 LOCATE 18,8 : PRINT NAMEE$;" ZOO SORT PROGRAM";
3560 LOCATE 19,1 : PRINT "  (A) MOVE SCALE ALL THE WAY LEFT";
3600 LOCATE 21,1 : PRINT "NOTICE WE GAVE YOUR FIRST INSTRUCTION";
3620 LOCATE 22,1 : PRINT "A NAME, (A).";
3640 LOCATE 23,1 : PRINT "WHEN YOU ARE READY FOR THE COMPUTER TO";
3660 LOCATE 24,1 : PRINT "PERFORM IT, PRESS THE SPACE BAR";
3700 X$=INKEY$ : IF X$<>"" THEN 3780
3720 COUNTER1=COUNTER1+1
3740 IF COUNTER1=LIMIT THEN 2080
3760 GOTO 3700
3780 COUNTER1=0
3800 IF X$<>CHR$(32) THEN PLAY"t36;o1;l10;c8" : GOTO 3700
3820 GOSUB 27600
3840 RETURN
3860 '
3880 '  TO ACCEPT SECOND COMMAND AND
3900 '  VERIFY IT.
3920 GOSUB 28000
3940 LOCATE 23,6 : PRINT "WHAT INSTRUCTION WOULD YOU LIKE";
3960 LOCATE 24,6 : PRINT "THE COMPUTER TO PERFORM NEXT?";
3980 LOCATE 25,6 : PRINT "PRESS A NUMBER (1 THROUGH 7).";
4020 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 4080
4040 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
4060 GOTO 4020
4080 COUNTER2=0
4100 IF (VAL(COMMAND$)=2) OR (VAL(COMMAND$)=3) THEN 4200
4110 GOSUB 28000
4120 LOCATE 23,1 : PRINT "WE SHOULD FIND OUT WHICH OF THE FIRST";
4140 LOCATE 24,1 : PRINT "TWO ANIMALS IS THE HEAVIER. WHICH IN";
4160 LOCATE 25,1 : PRINT "STRUCTION WILL DO THAT? ENTER SELECTION";
4180 GOTO 4020
4200 IF VAL(COMMAND$)=2 THEN 4300
4220 GOSUB 28000
4240 LOCATE 24,1 : PRINT "WE ALREADY DID THAT. TRY AGAIN. PRESS A";
4260 LOCATE 25,1 : PRINT "NUMBER (1 THROUGH 7).";
4280 GOTO 4020
4300 GOSUB 28100
4340 LOCATE 16,1 : PRINT "O.K. NOW YOUR PROGRAM LOOKS LIKE THIS. ";
4380 LOCATE 17,9 : PRINT NAMEE$;" ZOO SORT PROGRAM";
4400 LOCATE 18,1 : PRINT "(A) MOVE SCALE all the way left";
4420 LOCATE 19,5 : PRINT "COMPARE";
4460 LOCATE 21,1 : PRINT "WHEN YOU ARE READY FOR THE COMPUTER TO ";
4480 LOCATE 22,1 : PRINT "PERFORM YOUR SECOND INSTRUCTION, PRESS ";
4500 LOCATE 23,1 : PRINT "THE SPACE BAR.";
4560 X$=INKEY$ : IF X$<>"" THEN 4640
4580 COUNTER2=COUNTER2+1
4600 IF COUNTER2=LIMIT THEN GOTO 2080
4620 GOTO 4560
4640 COUNTER2=0
4660 IF X$<>CHR$(32) THEN PLAY"t36;o1;l10;c8" : GOTO 4560
4680 GOSUB 27700 :FOR I=1 TO 750 : NEXT I
4700 RETURN
4720 '
4740 '          TO ACCEPT THIRD COMMAND
4760 '          AND VERFIY IT.
4780 GOSUB 28000
4800 LOCATE 23,1 : PRINT "NOW THAT YOU KNOW THAT THE LEFT ANIMAL";
4820 LOCATE 24,1 : PRINT "IS HEAVY, WHAT INSTRUCTION WOULD YOU";
4840 LOCATE 25,1 : PRINT "LIKE THE COMPUTER TO PERFORM NEXT?";
4860 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 4940
4880 COUNTER3=COUNTER3+1
4900 IF COUNTER3=LIMIT THEN 2080
4920 GOTO 4860
4940 COUNTER3=0
4960 IF VAL(COMMAND$)=4 THEN 5220
4980 WRONG3=WRONG3+1
5000 A= WRONG3 MOD 2
5010 GOSUB 28000
5020 IF A=0 THEN TYPE$="EVEN" ELSE TYPE$="ODD"
5040 IF TYPE$="EVEN" THEN 5140
5060 LOCATE 23,1 : PRINT "REMEMBER, WE WANT THE HEAVY ANIMALS TO ";
5080 LOCATE 24,1 : PRINT "END UP ON THE RIGHT.  TRY AGAIN.       ";
5120 GOTO 5180
5140 LOCATE 23,1 : PRINT "SINCE YOU WANT HEAVY ANIMALS TO MOVE TO";
5160 LOCATE 24,1 : PRINT "THE RIGHT, MAYBE YOU SHOULD TRY A SWAP.";
5180 LOCATE 25,1 : PRINT "PRESS A NUMBER (1 THROUGH 7).";
5200 GOTO 4860
5220 WRONG3=0
5240 GOSUB 28100
5280 LOCATE 16,1 : PRINT "GOOD. NOW YOUR PROGRAM LOOKS LIKE THIS:";
5300 LOCATE 17,9 : PRINT NAMEE$;" ZOO SORT PROGRAM";
5320 LOCATE 18,1 : PRINT "(A) MOVE SCALE ALL THE WAY LEFT        ";
5340 LOCATE 19,1 : PRINT "    COMPARE                            ";
5360 LOCATE 20,1 : PRINT "    IF LEFT HEAVY-SWAP & TURN ON 'FLAG'";
5380 RN%=21:CN%=1:GOSUB 70
5400 LOCATE 22,1 : PRINT "WHEN YOU ARE READY FOR THE COMPUTER TO ";
5420 LOCATE 23,1 : PRINT "PERFORM YOUR NEXT INSTRUCTION, PRESS   ";
5440 LOCATE 24,1 : PRINT "THE SPACE BAR.                         ";
5460 RN%=25:CN%=1:GOSUB 70
5480 X$=INKEY$ : IF X$<>"" THEN 5560
5500 COUNTER3=COUNTER3+1
5520 IF COUNTER3=LIMIT THEN 2080
5540 GOTO 5480
5560 COUNTER3=0
5580 IF X$<>CHR$(32) THEN PLAY"t36;o1;l10;c8" : GOTO 5480
5600 GOSUB 27800 :FOR I=1 TO 750 : NEXT I
5620 RETURN
5640 '
5660 '  ACCEPT FOURTH COMMAND AND VERIFY IT
5700 '
5720 LOCATE 23,1 : PRINT "NOW THAT THE FIRST TWO ANIMALS HAVE    ";
5740 LOCATE 24,1 : PRINT "BEEN COMPARED, WHAT WOULD YOU HAVE THE ";
5760 LOCATE 25,1 : PRINT "COMPUTER DO NEXT? ENTER SELECTION.     ";
5780 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 5860
5800 COUNTER4=COUNTER4+1
5820 IF COUNTER4=LIMIT THEN 2080 :'MENU
5840 GOTO 5780
5860 COUNTER4=0
5880 IF VAL(COMMAND$)=1 THEN 6140
5900 WRONG4=WRONG4+1
5920 A=WRONG4 MOD 2
5930 GOSUB 28000
5940 IF A=0 THEN TYPE$="EVEN" ELSE TYPE$="ODD"
5960 IF TYPE$="EVEN" THEN 6060
5980 LOCATE 23,1 : PRINT "SINCE WE HAVE FINISHED WEIGHING THE    ";
6000 LOCATE 24,1 : PRINT "FIRST TWO ANIMALS, YOU SHOULD NOW MOVE ";
6020 LOCATE 25,1 : PRINT "THE SCALE. TRY AGAIN. ENTER SELECTION  ";
6040 GOTO 5780
6060 LOCATE 23,1 : PRINT "YOU SHOULD INSTRUCT THE COMPUTER TO";
6080 LOCATE 24,1 : PRINT "MOVE THE SCALE SO WE CAN WEIGH THE NEXT";
6100 LOCATE 25,1 : PRINT "OF ANIMALS. TRY AGAIN.";
6120 GOTO 5780
6140 WRONG4=0
6160 GOSUB 28100
6180 LOCATE 15,1 : PRINT "NOW YOUR PROGRAM LOOKS LIKE THIS:";
6220 LOCATE 16,8 : PRINT NAMEE$;" ZOO SORT PROGRAM";
6240 LOCATE 17,1 : PRINT "(A) MOVE THE SCALE ALL THE WAY LEFT";
6260 LOCATE 18,4 : PRINT "COMPARE";
6262 IF I99 = 4 GOTO 8280
6280 LOCATE 19,4 : PRINT "IF LEFT HEAVY-SWAP & TURN ON 'FLAG'";
6300 LOCATE 20,4 : PRINT "MOVE SCALE ONE POSITION TO RIGHT";
6340 LOCATE 22,1 : PRINT "WHEN YOU ARE READY FOR THE COMPUTER TO";
6360 LOCATE 23,1 : PRINT "PERFORM YOUR NEWEST INSTRUCTION, PRESS ";
6380 LOCATE 24,1 : PRINT "THE SPACE BAR.";
6400 RN%=25:CN%=1:GOSUB 70
6420 X$=INKEY$ : IF X$<>"" THEN 6500
6440 COUNTER4=COUNTER4+1
6460 IF COUNTER4=LIMIT THEN 2080
6480 GOTO 6420
6500 COUNTER4=0
6520 IF X$<>CHR$(32) THEN PLAY"t36;o1;l10;c8" : GOTO 6420
6540 GOSUB 27900
6560 RETURN
6580 '
6600 '    ACCEPT FIFTH COMMAND AND VERIFY IT
6640 '
6660 LOCATE 23,1 : PRINT "NOW THAT THE SCALE IS POSITIONED UNDER";
6680 LOCATE 24,1 : PRINT "THE NEXT PAIR OF ANIMALS,WHICH INSTRUCT";
6700 LOCATE 25,1 : PRINT "ION SHOULD THE COMPUTER PERFORM NEXT?";
6720 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 6800
6740 COUNTER5=COUNTER5+1
6760 IF COUNTER5=LIMIT THEN 2080 : 'MENU
6780 GOTO 6720
6800 COUNTER5=0
6820 IF (VAL(COMMAND$)=2) OR (VAL(COMMAND$)=6) THEN 7080
6840 WRONG5=WRONG5+1
6860 A=WRONG5 MOD 2
6870 GOSUB 28000
6880 IF A=0 THEN TYPE$="EVEN" ELSE TYPE$="ODD"
6900 IF TYPE$="EVEN" THEN 7000
6920 LOCATE 23,1 : PRINT "WE NEED TO KNOW WHICH ANIMAL IS THE";
6940 LOCATE 24,1 : PRINT "HEAVIER.";
6960 LOCATE 25,1 : PRINT "TRY AGAIN. PRESS A NUMBER (1 THROUGH 7)";
6980 GOTO 6720
7000 LOCATE 23,1 : PRINT "YOU NEED AN INSTRUCTION THAT WILL TELL";
7020 LOCATE 24,1 : PRINT "US WHICH OF THESE TWO ANIMALS IS THE";
7040 LOCATE 25,1 : PRINT "HEAVIER. PRESS A NUMBER (1 THROUGH 7).";
7060 GOTO 6720
7080 WRONG5=0
7100 IF VAL(COMMAND$)=6 THEN 7220
7120 LOCATE 23,1 : PRINT "YOU ALREADY HAVE A COMPARE INSTRUCTION";
7140 LOCATE 24,1 : PRINT "IN YOUR PROGRAM. THERE IS AWAY TO USE  ";
7160 LOCATE 25,1 : PRINT "THAT SAME INSTRUCTION AGAIN.          ";
7180 GOTO 6720
7220 GOSUB 28100
7222 LOCATE 14,8 : PRINT NAMEE$;" ZOO SORT PROGRAM";
7240 LOCATE 15,2 : PRINT "(A) MOVE SCALE ALL THE WAY LEFT";
7280 LOCATE 16,1 : PRINT CHR$(26);"(B) COMPARE";
7300 LOCATE 17,4 : PRINT "IF LEFT HEAVY-SWAP & TURN ON FLAG";
7320 LOCATE 18,4 : PRINT "MOVE SCALE ONE POSITION TO RIGHT";
7340 LOCATE 19,4 : PRINT "IF LAST ANIMAL NOT COMPARED-RETURN";
7360 LOCATE 20,4 : PRINT "TO B";
7380 RN%=21:CN%=1:GOSUB 70
7400 LOCATE 22,1 : PRINT "AS YOU CAN SEE, THE NEXT INSTRUCTION";
7420 LOCATE 23,1 : PRINT "POINTER IS NOW POSITIONED AT THE COMPARE";
7440 LOCATE 24,1 : PRINT "INSTRUCTION. TO TRY IT  PRESS";
7460 LOCATE 25,1 : PRINT "THE SPACE BAR.                        ";
7480 X$=INKEY$ : IF X$<>"" THEN 7560
7500 COUNTER5=COUNTER5+1
7520 IF COUNTER5=LIMIT THEN 2080 : 'MENU
7540 GOTO 7480
7560 COUNTER5=0
7580 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 7480
7600 GOSUB 27700 :FOR I=1 TO 750 : NEXT I
7720 LOCATE 16,1 : PRINT " "; : LOCATE 17,1 : PRINT CHR$(26);
7740 RN%=22:CN%=1:GOSUB 70
7745 GOSUB 29200
7820  X$=INKEY$ : IF X$<>"" THEN 7900
7840 COUNTER5=COUNTER5+1
7860 IF COUNTER5=LIMIT THEN 2080 : 'MENU
7880 GOTO 7820
7900 COUNTER5=0
7920 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 7820
7940 GOSUB 27800: FOR I=1 TO 750 : NEXT I
7960 LOCATE 17,1 : PRINT " ";
7963 IF I99 = 4  THEN I99=5:GOTO 8110
7966 LOCATE 18,1 : PRINT CHR$(26);
7970 GOSUB 29200
7980 X$=INKEY$ : IF X$<>"" THEN 8060
8000 COUNTER5=COUNTER5+1
8020 IF COUNTER5=LIMIT THEN 2080 : 'MENU
8040 GOTO 7980
8060 COUNTER5=0
8080 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 7980
8100 GOSUB 27900: FOR I=1 TO 750 : NEXT I
8110 GOSUB 29200
8120 LOCATE 18,1 : PRINT " "; : LOCATE 19,1 : PRINT CHR$(26);
8140 X$=INKEY$ : IF X$<>"" THEN 8220
8160 COUNTER5=COUNTER5+1
8180 IF COUNTER5=LIMIT THEN 2080 : 'MENU
8200 GOTO 8140
8220 COUNTER5=0
8240 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 8140
8260 LOCATE 19,1 :PRINT " ";
8262 IF I99=5 THEN I99=4:GOTO 8280
8265 LOCATE 16,1 :PRINT CHR$(26);
8270 GOSUB 29200: GOTO 7480
8280 RETURN
8300 '
8320 '     TO ACCEPT SIXTH COMMAND
8340 '     AND VERIFY
8360 GOSUB 28000
8370 PLAY "t33mlo2l32co1l8c"
8380 LOCATE 23,1:PRINT "OOPS! IT LOOKS LIKE YOUR PROGRAM IS NOT";
8400 LOCATE 24,1:PRINT "QUITE COMPLETE. IT NEEDS AT LEAST ONE";
8420 LOCATE 25,1:PRINT "MORE INSTRUCTION.WHICH SHOULD IT BE?";
8440 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 8520
8460 COUNTER6=COUNTER6+1
8480 IF COUNTER6=LIMIT THEN 2080 : 'MENU
8500 GOTO 8440
8520 COUNTER6=0
8540 IF (VAL(COMMAND$)=5) OR (VAL(COMMAND$)=7) THEN 8800
8560 WRONG6=WRONG6+1
8580 A=WRONG6 MOD 2
8590 GOSUB 28000
8600 IF A=0 THEN TYPE$="EVEN" ELSE TYPE$="ODD"
8620 IF TYPE$="EVEN" THEN 8720
8640 LOCATE 23,1 : PRINT "YOU NEED AN INSTRUCTION THAT WILL CAUSE ";
8660 LOCATE 24,1 : PRINT "YOUR PROGRAM TO REPEAT FROM THE";
8680 LOCATE 25,1 : PRINT "BEGINNING. TRY AGAIN.";
8700 GOTO 8440
8720 LOCATE 23,1 : PRINT "CAN YOU FIND AN INSTRUCTION WHICH";
8740 LOCATE 24,1 : PRINT "WILL CAUSE THE COMPUTER TO GO TO POINT";
8760 LOCATE 25,1 : PRINT "(A) IN YOUR PROGRAM. TRY AGAIN.";
8780 GOTO 8440
8800 WRONG6=0
8820 IF VAL(COMMAND$)=7 THEN 8920
8840 GOSUB 28000
8860 LOCATE 24,1 : PRINT "BEFORE YOU USE THE `STOP', YOU NEED ONE";
8880 LOCATE 25,1 : PRINT "MORE INSTRUCTION. TRY AGAIN.";
8900 GOTO 8440
8920 GOSUB 28100
8940 LOCATE 14,8 : PRINT NAMEE$;" ZOO SORT PROGRAM";
8960 LOCATE 15,2 : PRINT "(A) MOVE SCALE ALL THE WAY LEFT    ";
8980 LOCATE 16,2 : PRINT "(B) COMPARE";
9000 LOCATE 17,2 : PRINT "IF LEFT HEAVY-SWAP & TURN ON FLAG      ";
9020 LOCATE 18,2 : PRINT "MOVE SCALE ONE POSITION TO RIGHT       ";
9040 LOCATE 19,2 : PRINT "IF LAST ANIMAL NOT COMPARED-RETURN TO B";
9060 LOCATE 20,2 : PRINT "IF FLAG IS ON-TURN IT OFF & RETURN TO A";
9080 LOCATE 21,2 : PRINT "STOP";
9100 LOCATE 22,1 : PRINT "NOTICE THAT WE ADDED ONE FINAL";
9120 LOCATE 23,1 : PRINT "INSTRUCTION TO YOUR PROGRAM SO IT WOULD";
9140 LOCATE 24,1 : PRINT "STOP WHEN THE SORT IS COMPLETE.";
9160 LOCATE 25,2 : PRINT "PRESS SPACE BAR TO CONTINUE";
9180 X$=INKEY$ : IF X$<>"" THEN 9260
9200 COUNTER6=COUNTER6+1
9220 IF COUNTER6=LIMIT THEN 2080 : 'MENU
9240 GOTO 9180
9260 COUNTER6=0
9280 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 9180
9290 GOSUB 28000
9300 LOCATE 22,1 : PRINT "DO YOU WISH TO EXECUTE YOUR PROGRAM:";
9320 LOCATE 23,1 : PRINT "- ONE INSTRUCTION AT A TIME-PRESS SPACE";
9340 LOCATE 24,19 : PRINT "OR";
9360 LOCATE 25,1 : PRINT "- AUTOMATICALLY - PRESS A";
9380 X$=INKEY$ : IF X$<>"" THEN 9460
9400 COUNTER6=COUNTER6+1
9420 IF COUNTER6=LIMIT THEN 2080 : 'MENU
9440 GOTO 9380
9460 COUNTER6=0
9480 IF X$="A" OR X$="a" THEN RUNSW%=2:GOTO 28800
9500 IF X$=CHR$(32) THEN RUNSW%=1:GOTO 28800
9520 GOTO 9290
9540 '
9560 '      TO DISPLAY INSTRUCTIONS
9580 GOSUB 28100
9600 LOCATE 14,1 : PRINT "INSTRUCTION TO CHOOSE FROM:";
9620 LOCATE 15,2 : PRINT "1. MOVE SCALE ONE POSITION TO RIGHT";
9640 LOCATE 16,2 : PRINT "2. COMPARE";
9660 LOCATE 17,2 : PRINT "3. MOVE SCALE ALL THE WAY LEFT";
9680 LOCATE 18,2 : PRINT "4. IF LEFT IS HEAVY-SWAP &TURN ON FLAG";
9700 LOCATE 19,2 : PRINT "5. STOP";
9720 LOCATE 20,2 : PRINT "6. IF LAST BOX NOT YET COMPARED RETURN";
9740 LOCATE 21,4 : PRINT "TO POINT  B";
9760 LOCATE 22,2 : PRINT "7. IF FLAG IS ON, RETURN TO POINT A";
9780 RETURN
9800 'INIT VAR
9820 DEF SEG:NAMEE$="":SNAM$=""
9840 X=0:Y=0:PI=0:Z=0:COUNTER=0:COUNTER0=0:COUNTER1=0:COUNTER2=0:COUNTER3=0:COUNTER4=0:COUNTER5=0:COUNTER6=0:A=0:WRONG5=0:WRONG4=0:WRONG3=0:WRONG2=0:WRONG=0:WRONG6=0:LIMIT=10000:SWAPF%=0
9860 X=0:Y=0:PI=0:Z=0:COUNTER=0:COUNTER0=0:COUNTER1=0:COUNTER2=0:COUNTER3=0:COUNTER4=0:COUNTER5=0:COUNTER6=0:A=0:WRONG5=0:WRONG4=0:WRONG3=0:WRONG2=0:WRONG=0:WRONG6=0
9880 X$="":TYPE$="":COMMAND$=""
9900 DEF SEG
9960 RETURN
9980 '
10920 'display cages
10940 '  gosub 22900
11040 GOSUB 27500
11060 GOSUB 28100 : LOCATE 15,5 : PRINT "Welcome to Zoo Sort, where you can";
11080 LOCATE 16,1:PRINT "create a program (a list of";
11100 LOCATE 17,1:PRINT "instructions) that will cause the ";
11120 LOCATE 18,1:PRINT "computer to sort the animals shown above";
11140 LOCATE 19,1:PRINT "in order by weight (light ones on the";
11160 LOCATE 20,1:PRINT "left-heavy ones on the right).
11180 LOCATE 21,5:PRINT "Since you will be creating the";
11200 LOCATE 22,1:PRINT "program, let's call it `YOUR' program.";
11220 LOCATE 23,1:PRINT "Please type in your first name and then";
11240 LOCATE 24,1:PRINT "press the SPACE BAR.";
11260 LOCATE 25,10:PRINT "NAME: ";SPACE$(10);:C=15:I1=0
11270 NAMEE$=""
11280 FOR I=1 TO 10
11300 GOSUB 30300:X$=INKEY$:IF X$="" THEN 11300
11302 IF X$=CHR$(13) THEN 11300
11303 IF I=1 AND X$=CHR$(32) THEN 11280
11304 IF X$=CHR$(32) THEN 11415
11305 IF (RIGHT$(X$,1)=CHR$(75) OR RIGHT$(X$,1)=CHR$(83)) AND LEFT$(X$,1)=CHR$(0) THEN GOTO 11450
11306 IF X$=CHR$(8) THEN 11450
11307 IF X$<"A" OR X$>"z" THEN 11300 ELSE IF X$>"Z" AND X$<"a" THEN 11300
11340 IF X$=CHR$(32) THEN 11415
11360 NAMEE$=NAMEE$+X$
11380 LOCATE 25,C+I:PRINT X$;
11400 NEXT I
11402 FOR I=1 TO 5
11404 A=MID$(NAMEE$,I,1)=MID$(NAMEE$,I+1,1)
11406 I1=I1+A
11408 NEXT
11410 IF I1=-5 THEN 11260
11415 SNAM$=NAMEE$
11420 NAMEE$=NAMEE$+"'s"
11430 RETURN
11450 IF I=1 THEN GOTO 11300 ELSE I=I-1:LOCATE 25,C+I:PRINT " ";:NAMEE$=LEFT$(NAMEE$,I-1):GOTO 11300
12000 COUNTER2=0:CLS:SCREEN 0,0,0:COLOR 7:LOCATE 1,1,0: 'beginning the Congrats/Wrap up section
12010 LOCATE 14,5 : PRINT "CONGRATULATIONS ";SNAM$;"!";
12020 LOCATE 15,1 : PRINT "Your sort program seems to work";
12030 LOCATE 17,1 : PRINT "Would you like to see it run automati- ";
12040 LOCATE 18,1 : PRINT "cally and a bit faster?                ";
12050 LOCATE 21,3 : PRINT "Enter:  (1) for Yes";
12060 LOCATE 22,11 : PRINT "(2) for No";
12070 LOCATE 23,1 : PRINT SPACE$(40);
12080 KEY OFF:LOCATE 25,3 : PRINT "Press (1) or (2).";
12090 COMMAND$=INKEY$:IF COMMAND$<>"" THEN 12120
12100 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
12110 GOTO 12090
12120 COUNTER2=0:AUTOFLAG%=0
12130 ON VAL(COMMAND$) GOTO 12150,12200
12140 COLOR 26:GOTO 12080
12150 AUTOFLAG%=1:CLS:COLOR 7:LOCATE 14,1
12160 PRINT "Good but first, let's see if you";
12170 LOCATE 16,1 : PRINT "understand why sorting is useful.";
12180 FOR I=1 TO 6000:NEXT
12190 GOTO 12230
12200 CLS:COLOR 7:LOCATE 13,1 : PRINT "O.K. Let's now review why sorting is   ";
12210 LOCATE 15,1 : PRINT "useful.";
12220 FOR I=1 TO 6000:NEXT
12230 CLS:LIMIT=6000
12240 LOCATE 6,1 : PRINT "Sorting information into alphabetical";
12250 LOCATE 7,1 : PRINT "order can make information easier to ";
12260 LOCATE 8,1 : PRINT "find. An example of this is:";
12270 LOCATE 11,1 : PRINT "1. A dictionary";
12280 LOCATE 13,1 : PRINT "2. A telephone book";
12290 LOCATE 15,1 : PRINT "3. An encyclopedia";
12300 LOCATE 17,1 : PRINT "4. All of the above";
12310 LOCATE 19,1 : PRINT SPACE$(40)
12320 LOCATE 20,1 : PRINT "Enter the number of your answer:        ";
12330 LOCATE 21,1 : PRINT SPACE$(40)
12340 LOCATE 25,1 : PRINT "  Press (1) or (2) or (3) or (4)";
12350 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 12380
12360 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
12370 GOTO 12350
12380 COUNTER2=0
12390 ON VAL(COMMAND$)GOTO 12490,12490,12490,12410
12400 COLOR 26:GOTO 12340
12410 COLOR 7:LOCATE 20,1:PRINT SPACE$(40)
12420 LOCATE 19,1:PRINT "Good. (4) is the answer we're after.";
12430 LOCATE 21,1:PRINT "Sorting information into known order";
12440 LOCATE 22,1:PRINT "makes the information easier to use";
12450 LOCATE 23,1:PRINT "and therefore more valuable.";
12460 LOCATE 25,1:PRINT "Now try this one.                  ";
12470 LOCATE 20,1 : PRINT SPACE$(40)
12480 FOR I=1 TO 4000:A=1+I:NEXT:GOTO 12520
12490 COLOR 7:LOCATE 20,1:PRINT "That's a good answer but not the best.";
12500 LOCATE 21,1:PRINT "Try again.";
12510 FOR I=1 TO 1000:NEXT:GOTO 12320
12520 LIMIT=6000:CLS:COLOR 7
12530 LOCATE 3,1 : PRINT SPACE$(40);
12540 LOCATE 6,1 : PRINT "Sometimes we sort information to make";
12550 LOCATE 7,1 : PRINT "it easier to determine where it should";
12560 LOCATE 8,1 : PRINT "go. An example of this is:";
12570 LOCATE 11,1: PRINT "1. Sorting mail by ZIP CODE";
12580 LOCATE 13,1: PRINT "2. Sorting hair by color ";
12590 LOCATE 15,1: PRINT "3. Sorting autos by size ";
12600 LOCATE 19,1: PRINT SPACE$(40);
12610 LOCATE 25,3: PRINT "Press (1) or (2) or (3)";
12620 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 12650
12630 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
12640 GOTO 12620
12650 COUNTER2=0
12660 ON VAL(COMMAND$) GOTO 12680,12730,12730
12670 COLOR 26:GOTO 12610
12680 LOCATE 25,1 : PRINT SPACE$(39);
12690 COLOR 7: LOCATE 19,1: PRINT "Right you are. Sorting by ZIP CODE";
12700 LOCATE 20,1:PRINT "makes delivery of the mail faster and";
12710 LOCATE 21,1:PRINT "less expensive.";
12720 FOR I=1 TO 4000:A=I+1:NEXT:GOTO 12750
12730 COLOR 7:LOCATE 19,1:PRINT "Not correct. Try again.";
12740 FOR I=1 TO 2000:NEXT:GOTO 12600
12750 CLS:COLOR 7:LIMIT=6000
12760 LOCATE 7,1 : PRINT "To create an agenda or schedule, we";
12770 LOCATE 8,1 : PRINT "sort or arrange events by:";
12780 LOCATE 11,1 : PRINT "1. Their size";
12790 LOCATE 13,1 : PRINT "2. Their cost";
12800 LOCATE 15,1 : PRINT "3. Time or date";
12810 LOCATE 19,1:PRINT SPACE$(40);
12820 LOCATE 23,1 : PRINT " Enter the number of your answer:";
12830 LOCATE 25,1: PRINT "  Press (1) or (2) or (3)";
12840 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 12870
12850 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
12860 GOTO 12840
12870 COUNTER2=0
12880 ON VAL(COMMAND$) GOTO 12940,12940,12900
12890 COLOR 26:GOTO 12830
12900 LOCATE 23,1:PRINT SPACE$(39);
12910 LOCATE 25,1:PRINT SPACE$(39);
12920 COLOR 7:LOCATE 20,1:PRINT "Correct. Here's one final question.";
12930 FOR I=1 TO 2000:NEXT:GOTO 12980
12940 COLOR 7:LOCATE 19,1:PRINT "Not correct. Try again.";
12950 LOCATE 20,1:PRINT SPACE$(40);
12960 LOCATE 23,1 : PRINT SPACE$(40);
12970 FOR I=1 TO 2000:NEXT:GOTO 12810
12980 CLS:COLOR 7:LIMIT=600
13040 LOCATE 6,1 : PRINT "How fast do you think computers can";
13050 LOCATE 7,1 : PRINT "sort information?";
13080 LOCATE 10,1 : PRINT SPACE$(40)
13090 LOCATE 11,1 : PRINT "1. About the same as people can        ";
13100 LOCATE 12,1 : PRINT SPACE$(40)
13110 LOCATE 13,1 : PRINT "2. Hundreds of times faster than people";
13120 LOCATE 14,1 : PRINT SPACE$(40)
13130 LOCATE 15,1 : PRINT "3. Millions of times faster than people";
13140 LOCATE 19,1 : PRINT SPACE$(40)
13150 LOCATE 20,1 : PRINT SPACE$(40)
13160 LOCATE 21,1 : PRINT SPACE$(40)
13170 LOCATE 22,1 : PRINT SPACE$(40)
13180 LOCATE 23,1 : PRINT " Enter the number of your answer:";
13190 LOCATE 24,1 : PRINT SPACE$(39);
13200 LOCATE 25,1 : PRINT "  Press (1) or (2) or (3)";
13210 COMMAND$=INKEY$ : IF COMMAND$<>"" THEN 13240
13220 COUNTER2=COUNTER2+1 : IF COUNTER2=LIMIT THEN GOTO 2080
13230 GOTO 13210
13240 COUNTER2=0
13250 ON VAL(COMMAND$) GOTO 13330,13330,13270
13260 COLOR 26:GOTO 13200
13270 LOCATE 19,1:PRINT SPACE$(39)
13280 LOCATE 23,1:PRINT SPACE$(39)
13290 LOCATE 25,1:PRINT SPACE$(39);
13300 LOCATE 20,1:PRINT "Right again, ";SNAM$;
13310 LOCATE 21,1:PRINT SPACE$(39)
13320 FOR I=1 TO 2000:NEXT:GOTO 13360
13330 COLOR 7:LOCATE 19,1:PRINT "Not correct. Try again.";
13340 LOCATE 20,1:PRINT SPACE$(40)
13350 FOR I=1 TO 2000:NEXT:COLOR 7:GOTO 13140
13360 CLS
13370 IF AUTOFLAG%=1 THEN GOSUB 13500:CLS
13380 FOR I=1 TO 2000:NEXT
13390 LOCATE 6,1 : PRINT "Sorting has always been one of the";
13400 LOCATE 7,1 : PRINT "major uses of computers.";
13410 LOCATE 10,1: PRINT "Thank you ";SNAM$;", for trying your";
13420 LOCATE 11,1: PRINT "hand at ZOO SORT. If there are others";
13430 LOCATE 12,1: PRINT "waiting to use the IBM Personal";
13440 LOCATE 13,1: PRINT "Computer, please give the next person";
13450 LOCATE 14,1: PRINT "a turn now.";
13460 LOCATE 15,1:PRINT SPACE$(40)
13470 FOR I=1 TO 2000:A=A+I:NEXT
13480 GOTO 2080
13500 'automotive routine
13520 SCREEN 1:COLOR 0,0
13540 DEF SEG=&H1FF4
13560 I99=3: PRSW%=1:RUNSW%=2: GOSUB 25600: GOSUB 23400: GOSUB 25000: GOSUB 20200
13580 GOSUB 28300: GOSUB 25200: SWAPF%=0
13591 'reentry point for loop
13592 'GOSUB 28300: FOR I6=1 TO 300: NEXT I6: GOSUB 28300
13595  IF (PW%(I99) < PW%(I99+1)) THEN GOTO 13670
13600 GOSUB 28300: GOSUB 24100
13610 GOSUB 28300: GOSUB 24380
13620 GOSUB 25800
13655 IF I99=1 THEN GOSUB 25500 ELSE GOSUB 25400
13660 GOTO 13675
13670 GOSUB 28300: GOSUB 24600
13672 GOSUB 28300: GOSUB 24880
13675 GOSUB 23400: GOSUB 25000: GOSUB 20500
13680 IF I99 = 4 THEN I99=5: GOTO 13720
13690 GOSUB 28300: PRSW%=2
13700 GOSUB 25100
13720 PRSW%=5: GOSUB 28300: FOR I6=1 TO 750: NEXT I6
13725 IF I99<5 THEN PRSW%=2 :GOTO 13591
13730 'IF SWAPF%=0 THEN GOTO 13800
13735 PRSW%=6: GOSUB 28300: FOR I6=1 TO 750: NEXT I6
13736 IF SWAPF%=0 THEN GOTO 13790
13737 PRSW%=1:GOSUB 28300:FOR I6=1 TO 750:NEXT I6
13740 GOSUB 25300
13760 SWAPF%=0
13770 'PRSW%=2
13780 GOTO 13591
13790 PRSW%=7:RUNSW%=2: GOSUB 28300: FOR I6=1 TO 750: NEXT I6
13800 RETURN
20000 'five simultaneous animals
20020 '
20040 CALL FLIP(PP%(1,I6),LEFTX%,LEFTY%,PY%(1),PX%(1))
20050 LEFTX%=LEFTX%+16
20060 CALL FLIP(PP%(2,I6),LEFTX%,LEFTY%,PY%(2),PX%(2))
20070 LEFTX%=LEFTX%+16
20080 CALL FLIP(PP%(3,I6),LEFTX%,LEFTY%,PY%(3),PX%(3))
20090 LEFTX%=LEFTX%+16
20100 CALL FLIP(PP%(4,I6),LEFTX%,LEFTY%,PY%(4),PX%(4))
20110 LEFTX%=LEFTX%+16
20120 CALL FLIP(PP%(5,I6),LEFTX%,LEFTY%,PY%(5),PX%(5))
20140 FOR I5=1 TO 100:NEXT I5
20160 RETURN
20200 'move all animals
20220 '
20240 FOR I6=1 TO 9: LEFTX%=0: LEFTY%=10
20250 GOSUB 20000: NEXT I6
20260 RETURN
20300 'two  simultaneous animals
20320  LEFTX%=(I99 - 1) * 16
20340 CALL FLIP(PP%(I99,I6),LEFTX%,LEFTY%,PY%(I99),PX%(I99))
20350 LEFTX%=LEFTX%+16
20360 CALL FLIP(PP%(I99+1,I6),LEFTX%,LEFTY%,PY%(I99+1),PX%(I99+1))
20380 FOR I5=1 TO 100:NEXT I5
20390 RETURN
20400 'show all animals
20420 '
20440 FOR I6=1 TO 1: LEFTX%=0: LEFTY%=10
20450 GOSUB 20000: NEXT I6
20460 RETURN
20500 'move two animals
20520 '
20540 FOR I6=1 TO 9: LEFTY%=10
20550 GOSUB 20300: NEXT I6
20560 RETURN
21440 'scale roll right
21460 'needs -leftx%-,-rightx%-
21480 CALL FLIP(S1%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
21500 FOR I5=1 TO 10:NEXT I5
21520 LEFTX%=LEFTX%-1
21540 CALL FLIP(B1%,LEFTX%,LEFTY%,BLANKY%,BLANKX%)
21560 LEFTX%=LEFTX%+2
21580 CALL FLIP(S6%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
21600 LEFTX%=LEFTX%-1
21610 SOUND -1,1 : SOUND 50,0
21620 FOR I5=1 TO 10:NEXT I5
21640 RETURN
21660 REM
21680 REM
21700 REM
21720 REM
21740 'scale roll left
21760 'needs -leftx%-,-rightx%-
21780 IF I6=1 THEN GOTO 21830
21800 CALL FLIP(S1%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
21820 FOR I5=1 TO 10:NEXT I5: GOTO 21860
21830 LEFTX%=LEFTX%-1
21835 CALL FLIP(B1%,LEFTX%,LEFTY%,BLANKY%,BLANKX%)
21840 LEFTX%=LEFTX%+3
21860 LEFTX%=LEFTX%+24
21880 CALL FLIP(B1%,LEFTX%,LEFTY%,BLANKY%,BLANKX%)
21890 IF I6 = 1 THEN GOSUB 23400
21900 LEFTX%=LEFTX%-25
21920 CALL FLIP(S6%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
21940 LEFTX%=LEFTX%+1
21960 FOR I5=1 TO 10:NEXT I5
21962 SOUND -1,1 : SOUND 50,0
21980 RETURN
22700 'blank a "moving" scale (34x25)
22720 'needs -leftx%-,-lefty%-
22740 CALL FLIP(S7%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
22760 RETURN
22780 REM
22800 'blank a "moving" scale (34x25)
22820 LEFTX%=LEFTX%+24
22840 CALL FLIP(S7%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
22860 LEFTX%=LEFTX%-24
22880 RETURN
22900 'action routine
22920 SCREEN 1:COLOR 0,0:CLS
22940 DEF SEG=&H1FF4
22945 X$=INKEY$:IF X$ <> "" THEN RETURN
22950 LINE (25,100)-(280,199),1,BF
22951 LINE (107,141)-(178,154),0,BF
22952 LINE (91,163)-(209,176),0,BF
22953 LINE (67,117)-(236,130),0,BF
22954 'PAINT (26,101),1,2
22955 LOCATE 16,10:PRINT "To Try Your Hand At";:LOCATE 19,15: PRINT "ZOO SORT";:LOCATE 22,13:PRINT "PRESS ANY KEY:";
22960 I99=3
22970 GOSUB 25600
22980 GOSUB 23400
22985 GOSUB 25000
22986 GOSUB 30300
22987 X$=INKEY$:IF X$ <> "" THEN RETURN
22989 GOSUB 20200: GOSUB 25200: SWAPF%=0
22990 X$=INKEY$:IF X$ <> "" THEN RETURN
22991 'reentry point for loop
22992 X$=INKEY$:IF X$ <> "" THEN RETURN
22993  GOSUB 25700:   IF RANDN% = 1 THEN GOTO 23070
22995 'IF (PW%(I99) < PW%(I99+1)) THEN GOTO 23070
22999 X$=INKEY$:IF X$ <> "" THEN RETURN
23000 GOSUB 24100
23005 X$=INKEY$:IF X$ <> "" THEN RETURN
23010 GOSUB 24380
23015 X$=INKEY$:IF X$ <> "" THEN RETURN
23020 GOSUB 25800
23025 X$=INKEY$:IF X$ <> "" THEN RETURN
23055 IF I99=1 THEN GOSUB 25500 ELSE GOSUB 25400
23057 X$=INKEY$:IF X$ <> "" THEN RETURN
23060 GOTO 23075
23070 GOSUB 24600
23071 X$=INKEY$:IF X$ <> "" THEN RETURN
23072 GOSUB 24880
23073 X$=INKEY$:IF X$ <> "" THEN RETURN
23075 GOSUB 23400: GOSUB 25000: GOSUB 20500
23076 X$=INKEY$:IF X$ <> "" THEN RETURN
23080 IF I99 = 4 THEN GOTO 23120
23090 X$=INKEY$:IF X$ <> "" THEN RETURN
23100 GOSUB 25100: GOTO 22991
23110 X$=INKEY$:IF X$ <> "" THEN RETURN
23120 IF SWAPF%=0 THEN GOTO 23200
23140 GOSUB 25300
23150 X$=INKEY$:IF X$ <> "" THEN RETURN
23160 SWAPF%=0
23180 GOTO 22991
23200 REM
23220 REM
23240 GOTO 22960
23260 RETURN
23300 LEFTX%=LEFTX%+16: RETURN
23400 'ground surface
23420 LINE (0,95) -(319,95),3
23440 LINE (4,74) -(7,95),3,B
23460 LINE (312,74) -(315,95),3,B
23480 RETURN
23500 ' left cage blanker 1
23510 LFX%=((I99 - 1)* 64)+ 0
23520  LINE (LFX%,0) -STEP (+63,+12),0,BF
23560 RETURN
23600 ' blank out two cages
23620 LFX%=((I99 - 1)* 64)+ 0
23640 LINE (LFX%,0) -STEP (+127,+72),0,BF
23660 RETURN
23700 ' right cage blanker 1
23710 LFX%=(I99 * 64)+ 0
23720 LINE (LFX%,0) -STEP (+63,+13),0,BF
23760 RETURN
23800 'ALL ANIMALS
23820 SCREEN 1:COLOR 0,0
23840 DEF SEG=&H1FF4
23860  LEFTX%=0: LEFTY%=10
23880 FOR I6=1 TO 5: GOSUB 23900: NEXT I6:
23885 'FOR I5=1 TO 1600: NEXT I5
23890 RETURN
23900 'each ANIMAL
23910 LFX%=((I99 - 1)* 16)+ 0
23920 CALL FLIP(PP%(I6),LEFTX%,LEFTY%,PY%(I6),PX%(I6))
23940 GOSUB 23300
23960 RETURN
24100 'left heavy and swap routine
24120 SCREEN 1:COLOR 0,0
24140 DEF SEG=&H1FF4
24160 'LEfTX%=((I99-1) * 16) + 1
24180 'LEFTY%=49
24220  CALL FLIP(S1%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
24240 LEFTX% = LEFTX%-0: LEFTY%=LEFTY% - 4
24260  FOR I5=1 TO  100:NEXT I5 :
24265 PLAY "t120o3l32mbmlep32ep32ep32gp32gp32gp32o4l8c"
24270 GOSUB 26500: GOSUB 27100
24280  CALL FLIP(S3%,LEFTX%,LEFTY%,SCALE2Y%,SCALE3X%)
24285 GOSUB 23500: GOSUB 25900
24300 FOR I5=1 TO  100:NEXT I5:
24320 LEFTX%=LEFTX%-1: LEFTY%=LEFTY%-4
24330 GOSUB 26600: GOSUB 27100
24340 CALL FLIP(S5%,LEFTX%,LEFTY%,SCALE4Y%,SCALE2X%)
24345 GOSUB 26700: GOSUB 26000
24360 FOR I5=1 TO  750:NEXT I5:
24370 RETURN
24380 CALL FLIP(S7%,LEFTX%,LEFTY%,SCALE4Y%,SCALE2X%)
24390 GOSUB 23600
24400 FOR I5=1 TO  200:NEXT I5:
24420 LFY% = 4:LFX%=((LEFTX%\2)+5):
24440 LOCATE  LFY%,LFX% : PRINT "SWAP!";
24460 FOR I5=1 TO  300:NEXT I5:
24480 LOCATE  LFY%,LFX% : PRINT "     ";
24500 RETURN
24600 ' right heavy and no swap
24620 SCREEN 1:COLOR 0,0
24640 DEF SEG=&H1FF4
24660 'LEFTX%=((I99-1) * 16) + 1
24680 'LEFTY%=49
24720  CALL FLIP(S1%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
24740 LEFTX% = LEFTX%-1: LEFTY%=LEFTY% - 4
24760  FOR I5=1 TO  100:NEXT I5 :
24765 PLAY "t120o3l32mbmlep32ep32ep32gp32gp32gp32o4l8c"
24770 GOSUB 26100: GOSUB 27200
24780  CALL FLIP(S2%,LEFTX%,LEFTY%,SCALE3Y%,SCALE3X%)
24790 GOSUB 23700: GOSUB 26300
24800 FOR I5=1 TO  100:NEXT I5:
24820 LEFTX%=LEFTX%-2: LEFTY%=LEFTY%-2
24830 GOSUB 26200: GOSUB 27200
24840 CALL FLIP(S4%,LEFTX%,LEFTY%,SCALE5Y%,SCALE2X%)
24850 GOSUB 26800: GOSUB 26400
24860 FOR I5=1 TO  750:NEXT I5:
24870 RETURN
24880 GOSUB 27300
24900 FOR I5=1 TO 200:NEXT I5
24920 LFY% = 11:LFX%=((LEFTX%\2)+4):
24940 LOCATE  LFY%,LFX% : PRINT "NO SWAP!";
24960 FOR I5=1 TO  300:NEXT I5:
24970 GOSUB 26900
24980 LOCATE  LFY%,LFX% : PRINT "        ";
24995 RETURN
25000 ' place scale on road
25010 LEFTY%=61: LEFTX%=((I99 -1)*16)+3
25020 CALL FLIP(S1%,LEFTX%,LEFTY%,SCALE1Y%,SCALE1X%)
25030 GOSUB 27400
25035 GOSUB 20400
25040 RETURN
25100 ' roll right 1 cage worth
25120 LEFTX%=((I99-1)*16)+3
25140 LEFTY%=61
25160 FOR I6=1 TO 16:GOSUB 21440
25180 LEFTX%=LEFTX%+1:NEXT I6
25185 I99=I99+1
25190 RETURN
25200 ' roll left 2 cages worth
25220 LEFTX%=35
25240 LEFTY%=61
25260 FOR I6=2 TO 33:GOSUB 21740
25280 LEFTX%=LEFTX%-1:NEXT I6
25285 I99=1
25290 RETURN
25300 ' roll left 3 cages worth
25320 LEFTX%=51
25340 LEFTY%=61
25360 FOR I6=1 TO 50:GOSUB 21740
25380 LEFTX%=LEFTX%-1:NEXT I6
25385 I99=1
25390 RETURN
25400 'left flag
25410 'LINE (12,94)-(12,76),1
25411 X=1
25420 'LINE (13,78)-(24,86),2,BF
25421 GOSUB 29900
25430 RETURN
25500 'right flag
25510 'LINE (294,94)-(294,76),1
25511 X=249
25520 'LINE (295,78)-(306,86),2,BF
25521 GOSUB 29900
25530 RETURN
25600 'set inital animal values
25610 PW%(1)=2:PW%(2)=1:PW%(3)=5:PW%(4)=4:PW%(5)=3
25620 PX%(1)=14:PX%(2)=14:PX%(3)=16:PX%(4)=14:PX%(5)=14
25630 PY%(1)=51:PY%(2)=51:PY%(3)=51:PY%(4)=51:PY%(5)=51
25640 PP%(1,1)=K5%:PP%(1,2)=K4%:PP%(1,3)=K3%
25642 PP%(1,4)=K2%:PP%(1,5)=K1%:PP%(1,6)=K2%
25644 PP%(1,7)=K3%:PP%(1,8)=K3%:PP%(1,9)=K5%
25646 PP%(2,1)=R1%:PP%(2,2)=R2%:PP%(2,3)=R3%
25648 PP%(2,4)=R4%:PP%(2,5)=R5%:PP%(2,6)=R4%
25650 PP%(2,7)=R3%:PP%(2,8)=R2%:PP%(2,9)=R1%
25652 PP%(3,1)=E1%:PP%(3,2)=E1%:PP%(3,3)=E2%
25654 PP%(3,4)=E2%:PP%(3,5)=E3%:PP%(3,6)=E2%
25656 PP%(3,7)=E2%:PP%(3,8)=E1%:PP%(3,9)=E1%
25658 PP%(4,1)=H2%:PP%(4,2)=H2%:PP%(4,3)=H2%
25660 PP%(4,4)=H1%:PP%(4,5)=H1%:PP%(4,6)=H1%
25662 PP%(4,7)=H2%:PP%(4,8)=H2%:PP%(4,9)=H2%
25664 PP%(5,1)=G1%:PP%(5,2)=G2%:PP%(5,3)=G3%
25666 PP%(5,4)=G4%:PP%(5,5)=G5%:PP%(5,6)=G4%
25668 PP%(5,7)=G3%:PP%(5,8)=G2%:PP%(5,9)=G1%
25699 RETURN
25700 'generate a random 1 or 0
25710  RANDM$ = TIME$
25720  RAND2$ = RIGHT$(RANDM$,2)
25730  RANDT% = VAL(RAND2$)
25740  RANDN% = RANDT% MOD 2
25745 RANDN%=0
25750 RETURN
25800 ' swap pointers
25820 FOR I6=1 TO 9:SWAP PP%(I99,I6),PP%(I99+1,I6): NEXT I6
25840 SWAP PW%(I99),PW%(I99+1)
25845 SWAP PX%(I99),PX%(I99+1)
25847 SWAP PY%(I99),PY%(I99+1)
25850 SWAPF%=1
25855 RETURN
25900 ' left cage down 1st
25910 LFX%=((I99 - 1)* 16) +0
25920 LFY%=13
25940 CALL FLIP(PP%(I99,1),LFX%,LFY%,PY%(I99),PX%(I99))
25960 RETURN
26000 ' left cage down 2nd
26010 LFX%=((I99 - 1)* 16) +0
26020 LFY%=16
26040 CALL FLIP(PP%(I99,1),LFX%,LFY%,PY%(I99),PX%(I99))
26060 RETURN
26100 ' left cage up 1st
26110 LFX%=((I99 - 1)* 16) +0
26120 LFY%=6
26140 CALL FLIP(PP%(I99,1),LFX%,LFY%,PY%(I99),PX%(I99))
26160 RETURN
26200 ' left cage up 2nd
26210 LFX%=((I99 - 1)* 16) +0
26220 LFY%=4
26240 CALL FLIP(PP%(I99,1),LFX%,LFY%,PY%(I99),PX%(I99))
26260 RETURN
26300 'right cage down 1st
26310 LFX%=(I99 * 16) +0
26320 LFY%=14
26340 CALL FLIP(PP%(I99+1,1),LFX%,LFY%,PY%(I99+1),PX%(I99+1))
26360 RETURN
26400 'right cage down 2nd
26410 LFX%=(I99 * 16) +0
26420 LFY%=17
26440 CALL FLIP(PP%(I99+1,1),LFX%,LFY%,PY%(I99+1),PX%(I99+1))
26460 RETURN
26500 'right cage up 1st
26510 LFX%=(I99 * 16) +0
26520 LFY%=6
26540 CALL FLIP(PP%(I99+1,1),LFX%,LFY%,PY%(I99+1),PX%(I99+1))
26560 RETURN
26600 'right cage up 2nd
26610 LFX%=(I99 * 16) +0
26620 LFY%=2
26640 CALL FLIP(PP%(I99+1,1),LFX%,LFY%,PY%(I99+1),PX%(I99+1))
26660 RETURN
26700 ' left cage blanker 2
26710 LFX%=((I99 - 1)* 64)+ 0
26720  LINE (LFX%,0) -STEP (+63,+15),0,BF
26760 RETURN
26800 'right cage blanker 2
26810 LFX%=(I99* 64)+ 0
26820  LINE (LFX%,0) -STEP (+63,+16),0,BF
26860 RETURN
26900 '  cage top blanker
26920  LINE (0,0) - (319,9),0,BF
26940 RETURN
27000 'left corner blanker
27010 LFX%=(I99* 64)+ 0
27020  LINE (LFX%,0) -STEP (+63,+16),0,BF
27040 RETURN
27100 ' right bottom blanker
27110 LFX%=((LEFTX%+SCALE3X%) * 4) -4
27120 LFY%=LEFTY%
27130 LINE (LFX%,LFY%) -STEP (+14,+5),0,BF
27140 RETURN
27200 '  left bottom blanker
27210 LFX%=(LEFTX%*4)-1
27220 LFY%=LEFTY%
27230 LINE (LFX%,LFY%) -STEP (-7,+5),0,BF
27240 RETURN
27300 'no swap blanker
27310 LFX%=(LEFTX% * 4) - 7
27320 LFY%=LEFTY%
27330 LINE (LFX%,LFY%) -STEP (+63,+39),0,BF
27340 LFX%=LFX%+64
27350 LFY%=LFY%+13
27360 LINE (LFX%,LFY%) -STEP (+63,+26),0,BF
27370 RETURN
27400 ' scale leading edge
27410 LFX%=((LEFTX%+SCALE1X%) * 4)
27420 LFY%=LEFTY%
27430 LINE (LFX%,LFY%) -STEP (+12,+9),0,BF
27440 RETURN
27500 'initial image
27510 DEF SEG=&H1FF4
27520 I99=3
27530 GOSUB 25600
27540 GOSUB 23400
27550 GOSUB 25000
27560 REM
27570 REM
27580 'DEF SEG
27590 RETURN
27600 'scale to left
27610 DEF SEG=&H1FF4
27620 GOSUB 20200
27630 GOSUB 25200
27640 SWAPF%=0
27650 REM
27660 REM
27670 REM
27680 'DEF SEG
27690 RETURN
27700 'compare
27710 DEF SEG=&H1FF4
27720 IF (PW%(I99) < PW%(I99+1)) THEN GOSUB 24600 ELSE GOSUB 24100
27730 REM
27740 REM
27750 REM
27760 REM
27770 REM
27780 'DEF SEG
27790 RETURN
27800 'swap or dont
27810 DEF SEG=&H1FF4
27820 IF (PW%(I99) < PW%(I99+1)) THEN GOTO 27860
27830 GOSUB 24380: GOSUB 25800
27840 IF I99=1 THEN GOSUB 25500 ELSE GOSUB 25400
27850 GOTO 27870
27860 GOSUB 24880
27870 GOSUB 23400: GOSUB 25000
27880 GOSUB 20500: 'def seg
27890 RETURN
27900 ' move to next box
27910 DEF SEG=&H1FF4
27920 GOSUB 25100: 'def seg
27930 RETURN
28000 ' blank out last 3 lines
28010 LINE (0,176) - (319,199),0,BF
28020 RETURN
28100 ' blank out last 11 lines
28110 LINE (0,104) - (319,199),0,BF
28120 RETURN
28200 LOCATE RN%,CN%:PRINT "                                       "; RETURN
28300 ' program
28320 LOCATE 14,8 : PRINT NAMEE$;" ZOO SORT PROGRAM";
28340 LOCATE 15,1 : PRINT " (A) MOVE SCALE ALL THE WAY LEFT    ";
28360 LOCATE 16,1 : PRINT " (B) COMPARE
28380 LOCATE 17,1 : PRINT " IF LEFT HEAVY-SWAP & TURN ON FLAG      ";
28400 LOCATE 18,1 : PRINT " MOVE SCALE ONE POSITION TO RIGHT       ";
28420 LOCATE 19,1 : PRINT " IF LAST ANIMAL NOT COMPARED-RETURN TO B";
28440 LOCATE 20,1 : PRINT " IF FLAG IS ON-TURN IT OFF & RETURN TO A";
28460 LOCATE 21,1 : PRINT " STOP";
28470 RN%=(PRSW% + 14)
28475 LOCATE RN%,1: PRINT CHR$(26);
28500 GOSUB 28000
28520 IF RUNSW% = 2 GOTO 28740
28540 LOCATE 23,1 : PRINT "ONE INSTRUCTION AT A TIME - PRESS SPACE.";
28560 LOCATE 24,11: PRINT "OR";
28580 LOCATE 25,1 : PRINT "AUTOMATICALLY - PRESS A.";
28600 COUNTER5=0
28620 X$=INKEY$ : IF X$<>"" THEN 28700
28640 COUNTER5=COUNTER5+1
28660 IF COUNTER5=LIMIT THEN GOTO 2080
28680 GOTO 28620
28700 COUNTER5=0
28710 IF (X$="a" OR X$="A") THEN RUNSW%=2: GOTO 28740
28720 IF X$<>CHR$(32) THEN PLAY"T36;O1;L10;C8" : GOTO 28620
28740 PRSW%=PRSW%+1
28760 RETURN
28800 'automotive routine
28820 SCREEN 1:COLOR 0,0
28840 DEF SEG=&H1FF4
28860 I99=4
28865 RN%=22:CN%=1:GOSUB 70
28870 GOTO 29030
28891 'reentry point for loop
28892 'GOSUB 28300: FOR I6=1 TO 300: NEXT I6: GOSUB 28300
28895  IF (PW%(I99) < PW%(I99+1)) THEN GOTO 28970
28900 GOSUB 28300: GOSUB 24100
28910 GOSUB 28300: GOSUB 24380
28920 GOSUB 25800
28955 IF I99=1 THEN GOSUB 25500 ELSE GOSUB 25400
28960 GOTO 28975
28970 GOSUB 28300: GOSUB 24600
28972 GOSUB 28300: GOSUB 24880
28975 GOSUB 23400: GOSUB 25000: GOSUB 20500
28980 IF I99 = 4 THEN I99=5: GOTO 29020
28990 GOSUB 28300: PRSW%=2
29000 GOSUB 25100
29020 PRSW%=5: GOSUB 28300: FOR I6=1 TO 750: NEXT I6
29025 IF I99<5 THEN PRSW%=2 :GOTO 28891
29030 'IF SWAPF%=0 THEN GOTO 29100
29035 PRSW%=6: GOSUB 28300: FOR I6=1 TO 750: NEXT I6
29036 IF SWAPF%=0 THEN GOTO 29090
29037 PRSW%=1:GOSUB 28300:FOR I6=1 TO 750:NEXT I6
29040 GOSUB 25300
29060 SWAPF%=0
29070 'PRSW%=2
29080 GOTO 28891
29090 PRSW%=7:RUNSW%=2: GOSUB 28300: FOR I6=1 TO 2000:A=A+I6: NEXT I6
29100 GOTO 12000
29200 GOSUB 28000: COUNTER5=0
29210 LOCATE 23,1 : PRINT "WHEN YOU ARE READY TO HAVE THE COMPUTER ";
29220 LOCATE 24,1 : PRINT "PERFORM THE NEXT INSTRUCTION, PRESS THE";
29230 LOCATE 25,1 : PRINT "SPACE BAR.";
29240 RETURN
29900 Y=-5  : X=X+7
29910 LINE (X+12,Y+72)-(X+52,Y+87),1,BF
29920 LINE (X+10,Y+72)-(X+10,Y+99),2
29930 LINE (X+11,Y+77)-(X+11,Y+99),2
29940 CIRCLE (X+10,Y+70),2,2
29950 PAINT (X+10,Y+70),2,2
29960 CIRCLE (X+11,Y+99),4,3,,,5/18
29970 PAINT (X+11,Y+99),4,3
29980 IF X < 50 THEN Y=4 ELSE Y=35
29990 LOCATE 10,Y   : PRINT "swap";
29999 RETURN
30000 BEEP:GOSUB 30100:BEEP:GOSUB 30100:BEEP
30010 CLS:SCREEN 1
30020 COLOR 9:OUT 980,2:OUT 981,43
30030 LINE (25,25)-(280,200),,B
30040 LOCATE  9,12,0:PRINT "Do You Still Want";:LOCATE 11,16:PRINT "To Play?";:LOCATE 17,14:PRINT "Press any key";:LOCATE 19,11:PRINT "To Start Over Again.";
30050 TIME$="00"
30060 TEMP$=INKEY$
30070 IF MID$(TIME$,7)>"05"THEN GOTO 30000
30080 IF X$=""THEN GOTO 30060
30090 GOTO 30130
30100 TIME$="00"
30110 IF MID$(TIME$,7)>"01" THEN RETURN
30120 GOTO 30110
30130 '            MAIN MENU
30140 CLS:KEY OFF : SCREEN 1,0 : COUNTER=0
30150 LOCATE 7,5:PRINT "main menu:";
30160 LOCATE 10,8 : PRINT "1. ZOO SORT";
30170 LOCATE 12,8 : PRINT "2. COMPUTER AID INSTRUCTION";
30180 LOCATE 17,5 : PRINT "ENTER SELECTION   [ ]";
30190 X$=INKEY$
30200 LOCATE 17,24 : PRINT " ";
30210 IF X$<>"" THEN 30260
30220 LOCATE 17,24 : PRINT CHR$(95);
30230 COUNTER=COUNTER+1
30240 LOCATE 17,24 : PRINT " ";
30250 GOTO 30190
30260 IF VAL(X$)=1 THEN RETURN
30270 IF VAL(X$)=2 THEN PRINT "CAI";
30280 PLAY"t36;o1;l10;c8" : GOTO 30140
30300 DEF SEG:POKE 106,0:DEF SEG=&H1FF4:RETURN
55000 KEY OFF:CLS
55001 WIDTH 40:DEF SEG=0:A=PEEK(&H410):POKE &H410, A OR &H30
55002 WIDTH 80:LOCATE  ,,1,12,13:KEY ON:REM coltomon.bas pgm.
55003 SCREEN 0,0,0:END
60000 KEY OFF:CLS:WIDTH 80:DEF SEG=0:A=PEEK(&H410):POKE &H410,(A AND &HCF) OR &H20
60001 WIDTH 40:SCREEN 1:SCREEN 0:LOCATE  ,,1,6,7
60002 KEY ON:KEY OFF:CLS:WIDTH 40 'mon to col.bas pgm.