-
Notifications
You must be signed in to change notification settings - Fork 48
/
prog_examples_basic_mega.h
1454 lines (1429 loc) · 44.7 KB
/
prog_examples_basic_mega.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// -----------------------------------------------------------------------------
// Altair 8800 Simulator
//
// This file contains copies of a number of BASIC examples found in various
// places on the net, created by various authors.
//
// While the Altair 8800 simulator code itself is released under GPLv3,
// the contents of this file are excluded from that license for obvious reasons.
// -----------------------------------------------------------------------------
// [this gets included from prog_examples.cpp]
#define PROGMEM_LATE __attribute__ (( __section__(".fini1") ))
const char PROGMEM_LATE craps_bas[] =
"100 REM NAME--CRAPS\r"
"110 REM\r"
"120 REM DESCRIPTIONS--A SESSION AT THE CRAPS TABLE.\r"
"130 REM\r"
"140 REM SOURCE--UNKNOWN\r"
"150 REM\r"
"160 REM INSTRUCTIONS--TYPE \"RUN\" AND FOLLOW INSTRUCTIONS.\r"
"170 REM\r"
"180 REM\r"
"190 REM * * * * * * MAIN PROGRAM * * * * * * * * * *\r"
"200 REM\r"
"210 REM RANDOMIZE - COMMAND NOT IN 4K BASIC\r"
"220 PRINT\r"
"230 PRINT \"WELCOME TO THE DIGITAL CRAPS TABLE.\"\r"
"240 PRINT \"DO YOU WANT INSTRUCTIONS (0=NO 1=YES) \";\r"
"250 INPUT Z0\r"
"260 IF Z0=0 THEN 350\r"
"270 IF Z0=1 THEN 300\r"
"280 PRINT \"INCORRECT ANSWER. PLEASE TYPE '1' OR '0'\";\r"
"290 GOTO 250\r"
"300 PRINT \" ON THE FIRST THROW 2'S,3'S AND 12'S LOSE, 7'S AND 11'S\"\r"
"310 PRINT \" WIN. ON LATER THROWS 7'S AND 11'S LOSE, THE ORIGINAL\"\r"
"320 PRINT \" NUMBER WINS, AND ANY OTHER RESULT CAUSES ANOTHER THROW.\"\r"
"330 PRINT \" BETS MAY RANGE FROM .01 TO 10000, TYPE '-1' TO FIND THE\"\r"
"340 PRINT \" STATE OF YOUR WINNINGS OR LOSSES, AND A '0' TO QUIT.\"\r"
"350 PRINT\r"
"360 PRINT\r"
"370 PRINT\r"
"380 PRINT \" HOW MUCH DO YOU BET\";\r"
"390 INPUT B1\r"
"400 IF B1<0 THEN 840\r"
"410 IF B1=0 THEN 960\r"
"420 IF B1<5 THEN 940\r"
"430 IF B1>10000 THEN 820\r"
"440 LET T7=0\r"
"450 LET D1=INT(6*RND(1))+1\r"
"460 LET D2=INT(6*RND(1))+1\r"
"470 PRINT D1;D2;\r"
"480 LET T=D1+D2\r"
"490 IF T7>0 THEN 520\r"
"500 IF T=12 THEN 750\r"
"510 IF T=2 THEN 770\r"
"520 IF T=8 THEN 560\r"
"530 IF T=11 THEN 560\r"
"540 PRINT \" A\";T;\r"
"550 GOTO 570\r"
"560 PRINT \" AN\";T;\r"
"570 IF T7>0 THEN 630\r"
"580 IF T=3 THEN 780\r"
"590 IF T=7 THEN 710\r"
"600 IF T=11 THEN 710\r"
"610 LET D9=T\r"
"620 GOTO 680\r"
"630 IF T=7 THEN 780\r"
"640 IF T=11 THEN 780\r"
"650 IF T=D9 THEN 710\r"
"660 PRINT\r"
"670 GOTO 450\r"
"680 PRINT \" YOUR NUMBER IS \" T\r"
"690 LET T7=1\r"
"700 GOTO 450\r"
"710 PRINT \" YOU WIN\"\r"
"720 LET W=W+B1\r"
"730 PRINT \" YOU WIN\" B1;\"DOLLARS\"\r"
"740 GOTO 370\r"
"750 PRINT \" BOXCARS.....\";\r"
"760 GOTO 780\r"
"770 PRINT \" SNAKES EYES.....\";\r"
"780 LET W=W-B1\r"
"790 PRINT \" YOU LOSE\"\r"
"800 PRINT \" YOU LOSE\" B1; \"DOLLARS\"\r"
"810 GOTO 370\r"
"820 PRINT \" ARE YOU KIDDING ME? TRY A LITTLE LESS\"\r"
"830 GOTO 370\r"
"840 PRINT\r"
"850 IF W>=0 THEN 920\r"
"860 PRINT\" YOU ARE BEHIND\";-W;\"DOLLARS--TRY SOME MORE (1=YES 0=NO) \";\r"
"870 INPUT H0\r"
"880 IF H0=0 THEN 960\r"
"890 IF H0=1 THEN 370\r"
"900 PRINT\"INCORRECT ANSWER. PLEASE TYPE '1' OR '0'\";\r"
"910 GOTO 870\r"
"920 PRINT \" YOU ARE AHEAD\"W;\" DOLLARS--HOW ABOUT A LITTLE MORE\";\r"
"930 GOTO 870\r"
"940 PRINT \" YOU ARE A CHEAPSKATE--BUT I'LL PLAY\"\r"
"950 GOTO 440\r"
"960 PRINT\r"
"970 PRINT\r"
"980 PRINT\r"
"990 PRINT\r"
"1000 IF W>=0 THEN 1040\r"
"1010 PRINT\" YOU LOST\";-W;\"DOLLARS./. TOUGH LIFE\"\r"
"1020 PRINT \" LET THIS BE A LESSON\"\r"
"1030 STOP\r"
"1040 PRINT \" YOU WON \" W; \"DOLLARS...WILL SEND CHECK IMMEDIATELY\"\r"
"1050 END\r";
const char PROGMEM_LATE primes_bas[] =
"100 PRINT \"Interface Age Prime-Number Benchmark Program\"\r"
"110 FOR N=1 TO 200\r"
"120 FOR K=2 TO 100\r"
"130 M=N/K\r"
"140 L=INT(M)\r"
"150 IF L=0 THEN 200\r"
"160 IF L=1 THEN 190\r"
"170 IF M>L THEN 190\r"
"180 IF M=L THEN 210\r"
"190 NEXT K\r"
"200 PRINT N\r"
"210 NEXT N\r"
"220 PRINT\r"
"230 PRINT\r"
"240 PRINT \"Done\"\r"
"250 END\r";
const char PROGMEM_LATE primes_sieve_bas[] =
"100 REM NAME--SIEVE\r"
"110 REM\r"
"120 REM DISCRIPTION--DEMONSTRATES SIEVE METHOD OF FINDING PRIMES.\r"
"130 REM\r"
"140 REM SOURCE--UNKNOWN\r"
"150 REM\r"
"160 REM INSTRUCTIONS--TYPE \"RUN\" AND FOLLOW INSTRUCTIONS.\r"
"170 REM\r"
"180 REM\r"
"190 REM * * * * * * MAIN PROGRAM * * * * * * * *\r"
"200 REM\r"
"210 READ E\r"
"220 PRINT\r"
"230 PRINT\r"
"240 PRINT \"SIEVING BY \" E\r"
"250 PRINT\r"
"260 FOR N=2 TO 56\r"
"270 IF N=2 THEN 350\r"
"280 IF N/2>INT(N/2) THEN 310\r"
"290 PRINT \" * \";\r"
"300 GO TO 400\r"
"310 IF N<8 THEN 350\r"
"320 FOR F= 3 TO E STEP 2\r"
"330 IF N=F*INT(N/F) THEN 390\r"
"340 NEXT F\r"
"350 IF N>9 THEN 370\r"
"360 PRINT \" \";\r"
"370 PRINT N;\r"
"380 GO TO 400\r"
"390 PRINT \" * \";\r"
"400 NEXT N\r"
"410 IF E < 7 THEN 210\r"
"420 DATA 2,3,5,7\r"
"430 END\r";
const char PROGMEM_LATE nim_bas[] =
"100 REM NAME--NIM\r"
"110 REM\r"
"120 REM DESCRIPTION--PLAYS THE ANCIENT GAME OF NIM.\r"
"130 REM\r"
"140 REM SOURCE--UNKNOWN\r"
"150 REM\r"
"160 REM INSTRUCTIONS--TYPE \"RUN\" AND FOLLOW INSTRUCTIONS.\r"
"170 REM\r"
"180 REM\r"
"190 REM * * * * * * MAIN PROGRAM * * * * * * * * *\r"
"200 REM\r"
"210 PRINT \" THIS IS THE ANCIENT GAME OF NIM.\"\r"
"220 PRINT\r"
"230 PRINT \"IT IS PLAYED WITH THREE PILES OF STICKS.\"\r"
"240 PRINT \"YOU MAY REMOVE AS MANY STICKS AS YOU WISH, \";\r"
"250 PRINT \"BUT FROM ONE PILE ONLY.\"\r"
"260 PRINT \"THEN IT IS MY TURN TO DO THE SAME.\"\r"
"270 PRINT \"THE OBJECT OF THE GAME IS TO TAKE THE LAST STICK.\"\r"
"280 PRINT \"WHEN IT IS YOUR MOVE, I'LL ASK 'WHICH PILE, HOW MANY'.\"\r"
"290 PRINT \"TO REMOVE, FROM PILE 2, 5 STICKS, SIMPLY TYPE: 2,5\"\r"
"300 PRINT \"THEN PUSH 'RETURN' --- THIS IS VERY IMPORTANT.\"\r"
"310 PRINT\r"
"320 PRINT \"THIS IS THE ORIGINAL ARRANGEMENT:\"\r"
"330 PRINT\r"
"225 DIM B(12):DIM N(3)\r"
"340 FOR I=1 TO 3:READ N(I):NEXT I\r"
"350 FOR I=1 TO 12:READ B(I):NEXT I\r"
"360 DATA 15,14,13, 1,1,1,1, 1,1,1,0, 1,1,0,1\r"
"370 PRINT \"PILE 1 :\" N(1)\r"
"380 PRINT \"PILE 2 :\" N(2)\r"
"390 PRINT \"PILE 3 :\" N(3)\r"
"400 PRINT\r"
"410 PRINT\r"
"420 PRINT\r"
"430 PRINT \"WHICH PILE, HOW MANY\";\r"
"440 INPUT P,X\r"
"450 PRINT\r"
"460 IF P < 1 THEN 520\r"
"470 IF P > 3 THEN 520\r"
"480 IF X < 1 THEN 520\r"
"490 IF N(P) < X THEN 520\r"
"500 LET N(P) = N(P) - X\r"
"510 GOTO 550\r"
"520 PRINT \"ILLEGAL MOVE\"\r"
"530 PRINT\r"
"540 GOTO 430\r"
"550 IF N(1)+N(2)+N(3) > 0 THEN 580\r"
"560 PRINT \"CONGRATULATIONS! YOU WIN! *****\"\r"
"570 GOTO 950\r"
"580 GOSUB 600\r"
"590 GOTO 670\r"
"600 LET Y = N(P)\r"
"610 FOR I = 1 TO 4\r"
"620 LET Z = INT(Y/2)\r"
"630 LET B((P-1)*4+5-I) = Y-2*Z\r"
"640 LET Y = Z\r"
"650 NEXT I\r"
"660 RETURN\r"
"670 LET J9 = 0\r"
"680 FOR J = 4 TO 1 STEP -1\r"
"690 LET S = B(J)+B(4+J)+B(8+J)\r"
"700 IF S < 2 THEN 720\r"
"710 LET S = S-2\r"
"720 IF S = 0 THEN 740\r"
"730 LET J9 = J\r"
"740 LET S(J) = S\r"
"750 NEXT J\r"
"760 IF J9 = 0 THEN 860\r"
"770 FOR P = 1 TO 3\r"
"780 IF B((P-1)*4+J9) = 1 THEN 800\r"
"790 NEXT P\r"
"800 LET X = 0\r"
"810 FOR J = J9 TO 4\r"
"820 LET Y = S(J)*(2*B((P-1)*4+J)-1)\r"
"830 LET X = 2*X+Y\r"
"840 NEXT J\r"
"850 GOTO 890\r"
"860 LET P = INT(3*RND(1)+1)\r"
"870 IF N(P) = 0 THEN 860\r"
"880 LET X = 1\r"
"890 LET N(P) = N(P) - X\r"
"900 GOSUB 600\r"
"910 PRINT \"MY MOVE: \";P;\",\";X\r"
"920 PRINT\r"
"930 IF N(1)+N(2)+N(3) > 0 THEN 370\r"
"940 PRINT \"I WIN.\"\r"
"950 PRINT\r"
"960 PRINT \"WOULD YOU LIKE TO PLAY AGAIN (1=YES 0=NO)\";\r"
"970 INPUT A0\r"
"980 IF A0=1 THEN 1020\r"
"990 IF A0=0 THEN 1050\r"
"1000 PRINT \"PLEASE TYPE '1' OR '0': \";\r"
"1010 GOTO 970\r"
"1020 PRINT\r"
"1030 RESTORE\r"
"1040 GOTO 340\r"
"1050 PRINT \"THANKS FOR THE GAME *****\"\r"
"1060 END\r";
const char PROGMEM_LATE rock_paper_scissors_bas[] =
"1 PRINT \"THIS PROGRAM ALLOWS YOU TO PLAY THE OLD GAME OF\"\r"
"2 PRINT \"ROCKS, PAPER, AND SISSORS AGAINST THE COMPUTER.\"\r"
"6 PRINT \"HOW MANY GAMES DO YOU WANT \";:INPUT Q\r"
"8 IF Q<11 THEN 11\r"
"9 PRINT \"SORRY, BUT WE AREN'T ALLOWED TO PLAY THAT MANY.\":GOTO 6\r"
"11 FOR G=1 TO Q\r"
"15 PRINT:PRINT \"GAME NUMBER\"G\r"
"20 X=INT(RND(1)*3+1)\r"
"25 PRINT \"3=ROCK...2=SISSORS...1=PAPER\"\r"
"30 PRINT \"1....2....3....WHAT'S YOUR CHOICE \";:INPUT K\r"
"32 IF (K-1)*(K-2)*(K-3)<>0 THEN PRINT \"INVALID\":GOTO 25\r"
"35 PRINT \"THIS IS MY CHOICE...\"\r"
"41 IF X=1 THEN 50\r"
"42 IF X=2 THEN 60\r"
"43 IF X=3 THEN 70\r"
"50 PRINT \"...PAPER\":GOTO 80\r"
"60 PRINT \"...SISSORS\":GOTO 80\r"
"70 PRINT \"...ROCK\"\r"
"80 IF X=K THEN 155\r"
"85 IF X>K THEN 125\r"
"90 IF X=1 THEN 105\r"
"95 PRINT \"YOU WIN!!\":H=H+1:GOTO 160\r"
"105 IF K=3 THEN 115\r"
"110 GOTO 95\r"
"115 PRINT \"WOW! I WIN!!\":C=C+1:GOTO 160\r"
"125 IF K<>1 THEN 115\r"
"140 IF X<>3 THEN 115\r"
"141 GOTO 95\r"
"155 PRINT \"TIE GAME, NO WINNER.\"\r"
"160 NEXT G\r"
"170 PRINT:PRINT \"HERE IS THE FINAL SCORE:\"\r"
"175 PRINT \"I HAVE WON\"C\"GAME(S).\"\r"
"180 PRINT \"YOU HAVE WON\"H\"GAME(S).\"\r"
"185 PRINT \"AND\"G-1-(C+H)\"GAME(S) ENDED IN A TIE.\"\r"
"190 PRINT:PRINT \"THANKS FOR PLAYING!!\"\r"
"200 END\r";
const char PROGMEM_LATE tic_tac_toe_bas[] =
"1 DATA 2,3,4,9,1,5,8,7,6 \r"
"2 DATA 2,3,4,9,1,5,8,7,6,2,9,8,3,1,7 \r"
"3 DATA 4,5,6,2,1,6,4,1,8 \r"
"4 DATA 0,1,-1,1,-1,1,-1,1,-1 \r"
"5 DIM A(9) \r"
"6 DIM B(9) \r"
"7 DIM C(24)\r"
"8 DIM D(24)\r"
"9 DIM F(9) \r"
"10 FOR I=1 TO 9 \r"
"11 READ A(I)\r"
"12 NEXT I \r"
"13 FOR I=1 TO 24\r"
"14 READ C(I)\r"
"15 NEXT I \r"
"16 FOR I=1 TO 9 \r"
"17 READ F(I)\r"
"18 NEXT I \r"
"19 PRINT \"TIC-TAC-TOE\"\r"
"20 PRINT\r"
"21 PRINT \"THE MOVE POSITIONS ARE:\"\r"
"22 PRINT\r"
"23 PRINT \"1 2 3\"\r"
"24 PRINT \"4 5 6\"\r"
"25 PRINT \"7 8 9\"\r"
"26 GOSUB 133\r"
"27 GOSUB 133\r"
"32 LET E=0\r"
"33 LET G=2\r"
"34 LET K=0\r"
"35 FOR I=1 TO 9 \r"
"36 LET B(I)=0 \r"
"37 NEXT I \r"
"38 FOR I=1 TO 24\r"
"39 LET D(I)=0 \r"
"40 NEXT I \r"
"41 PRINT\r"
"42 PRINT\r"
"43 PRINT \"--BEGIN GAME--\" \r"
"44 PRINT \"YOU WILL BE 'X', I WILL BE 'O'\" \r"
"47 PRINT \"TYPE 0 IF YOU WANT ME TO GO FIRST\"; \r"
"48 INPUT I\r"
"49 IF I=0 THEN 65 \r"
"50 LET L=-1 \r"
"51 PRINT \"YOUR MOVE\"; \r"
"52 INPUT I\r"
"53 PRINT\r"
"54 PRINT\r"
"55 LET H=INT(ABS(I))\r"
"56 IF H<>I THEN 50\r"
"57 IF H < 1 THEN 50 \r"
"58 IF H>9 THEN 50 \r"
"59 LET H=A(H) \r"
"60 IF B(H) <> 0 THEN 50 \r"
"61 IF K=1 THEN 64 \r"
"62 LET G=F(H) \r"
"63 LET K=1\r"
"64 GOSUB 111\r"
"65 LET L=1\r"
"66 FOR I=1 TO 22 STEP 3 \r"
"67 IF D(I) + D(I+1) + D(I+2) = -3 THEN 92 \r"
"68 NEXT I \r"
"69 FOR I=1 TO 22 STEP 3 \r"
"70 IF D(I) + D(I+1) + D(I+2) = 2 THEN 90\r"
"71 NEXT I \r"
"72 FOR I=1 TO 22 STEP 3 \r"
"73 IF D(I) + D(I+1) + D(I+2) = -2 THEN 106\r"
"74 NEXT I \r"
"75 IF E=1 THEN 77 \r"
"76 IF G = -1 THEN 78\r"
"77 IF B(1)=0 THEN 100 \r"
"78 IF G <> 0 THEN 82\r"
"79 FOR I=2 TO 8 STEP 2\r"
"80 IF B(I)=0 THEN 101 \r"
"81 NEXT I \r"
"82 IF H>=8 THEN 86 \r"
"83 FOR I=H+1 TO 8 \r"
"84 IF B(I)=0 THEN 101 \r"
"85 NEXT I \r"
"86 FOR I=2 TO 9 \r"
"87 IF B(I)=0 THEN 101 \r"
"88 NEXT I \r"
"89 GO TO 98 \r"
"90 PRINT \"I WIN\"\r"
"91 GOTO 900 \r"
"92 PRINT \"YOU ARE NOT ALLOWED TO WIN\" \r"
"93 FOR I=1 TO 9 \r"
"94 LET B(I)=1 \r"
"95 NEXT I \r"
"96 GOSUB 117\r"
"97 GOTO 900 \r"
"98 PRINT \"DRAW\" \r"
"99 GOTO 900 \r"
"100 LET I=1\r"
"101 LET H=I\r"
"102 GOSUB 111\r"
"103 LET E=1\r"
"104 GOSUB 117\r"
"105 GO TO 50 \r"
"106 FOR J=I TO I+2 \r"
"107 IF D(J)=0 THEN 109 \r"
"108 NEXT J \r"
"109 LET I=C(J) \r"
"110 GO TO 101\r"
"111 LET B(H)=L \r"
"112 FOR M=1 TO 24\r"
"113 IF C(M) <> H THEN 115\r"
"114 LET D(M)=L \r"
"115 NEXT M \r"
"116 RETURN \r"
"117 FOR N=1 TO 9 \r"
"118 IF B(N)=0 THEN 200 \r"
"119 NEXT N \r"
"120 IF N<100 THEN 98 \r"
"121 FOR N=1 TO 9 STEP 3\r"
"122 FOR O= 0 TO 2\r"
"123 IF B(A(O+N))=0 THEN 127\r"
"124 IF B(A(O+N))=1 THEN 129\r"
"125 PRINT \"X \";\r"
"126 GO TO 130\r"
"127 PRINT \"- \";\r"
"128 GO TO 130\r"
"129 PRINT \"O \";\r"
"130 NEXT O \r"
"131 PRINT\r"
"132 NEXT N \r"
"133 PRINT\r"
"136 RETURN \r"
"137 STOP \r"
"200 LET N=1000 \r"
"210 GOTO 119 \r"
"900 GOTO 910\r"
"910 PRINT \"TRY AGAIN (IF SO TYPE 0)\";\r"
"920 INPUT I\r"
"930 IF I<>0 THEN 999 \r"
"940 GOTO 27\r"
"999 END\r";
const char PROGMEM_LATE hamurabi_bas[] =
"10 REM ORIGINAL HAMURABI IN IMSAI 4K BASIC\r"
"20 REM FROM REVISION REWRITTEN 12/11/77\r"
"310 PRINT \"HAMURABI - \";\r"
"320 PRINT \"WHERE YOU GOVERN THE \";\r"
"321 PRINT \"ANCIENT KINGDOM OF SUMERIA.\"\r"
"330 PRINT \"THE OBJECT IS TO FIGURE \";\r"
"331 PRINT \"OUT HOW THE GAME WORKS!!\"\r"
"340 PRINT \"(IF YOU WANT TO QUIT, \";\r"
"341 PRINT \"SELL ALL YOUR LAND.)\"\r"
"400 LET A1 = 100\r"
"410 LET A2 = 5\r"
"420 LET A3 = 0\r"
"430 LET B1 = 2800\r"
"440 LET B2 = 200\r"
"450 LET B3 = 3\r"
"460 LET B4 = 3000\r"
"470 LET C1 = 1000\r"
"480 LET J = 1\r"
"1010 PRINT\r"
"1020 PRINT \"HAMURABI, I BEG TO REPORT \";\r"
"1021 PRINT \"THAT LAST YEAR \"\r"
"1040 PRINT A3;\"PEOPLE STARVED AND \";A2;\r"
"1041 PRINT \"PEOPLE CAME TO THE CITY.\"\r"
"1050 IF J > 0 THEN GOTO 1100\r"
"1060 LET A1 = A1-INT(A1/2)\r"
"1070 PRINT \"THE PLAGUE KILLED \";\r"
"1071 PRINT \"HALF THE PEOPLE.\"\r"
"1100 PRINT \"THE POPULATION IS NOW \";A1\r"
"1120 PRINT \"WE HARVESTED \";B4;\"BUSHELS \";\r"
"1121 PRINT \"AT \";B3;\"BUSHELS PER ACRE.\"\r"
"1130 PRINT \"RATS DESTROYED \";\r"
"1131 PRINT B2;\" BUSHELS LEAVING \";B1;\r"
"1140 PRINT \"BUSHELS IN\"\r"
"1141 PRINT \"THE STOREHOUSES.\"\r"
"1160 PRINT \"THE CITY OWNS \";C1;\r"
"1161 PRINT \"ACRES OF LAND.\"\r"
"1170 LET C2 = 17+INT(6*RND(1))\r"
"1180 PRINT \"LAND IS WORTH \";C2;\"BUSHELS \";\r"
"1181 PRINT \"PER ACRE.\"\r"
"1210 PRINT \"HAMURABI . . .\"\r"
"1310 PRINT\r"
"1320 PRINT \"BUY HOW MANY ACRES\";\r"
"1330 INPUT I\r"
"1335 PRINT\r"
"1340 LET I = INT(ABS(I))\r"
"1350 IF I = 0 THEN GOTO 1510\r"
"1360 LET J = I*C2\r"
"1370 IF J <= B1 THEN GOTO 1400\r"
"1380 GOSUB 9000\r"
"1390 GOTO 1310\r"
"1400 LET B1 = B1-J\r"
"1410 LET C1 = C1+I\r"
"1510 PRINT \"SELL HOW MANY ACRES\";\r"
"1520 INPUT I\r"
"1525 PRINT\r"
"1530 LET I = (ABS(I))\r"
"1540 IF I = 0 THEN GOTO 1710\r"
"1550 IF I < C1 THEN GOTO 1600\r"
"1560 IF I = C1 THEN END\r"
"1570 GOSUB 9000\r"
"1580 GOTO 1510\r"
"1600 LET C1 = C1-I\r"
"1610 LET B1 = B1+C2*I\r"
"1710 PRINT \"HOW MANY BUSHELS SHALL \";\r"
"1711 PRINT \"WE DISTRIBUTE AS FOOD? \";\r"
"1720 INPUT I\r"
"1725 PRINT\r"
"1730 LET I = INT(ABS(I))\r"
"1740 IF I <= B1 THEN GOTO 1770\r"
"1750 GOSUB 9000\r"
"1760 GOTO 1710\r"
"1770 LET B1 = B1-I\r"
"1780 LET A3 = A1-INT(I/20)\r"
"1790 LET A2 = 0\r"
"1800 IF A3 >= 0 THEN GOTO 1910\r"
"1810 LET A2 = -A3/2\r"
"1820 LET A3 = 0\r"
"1910 PRINT \"HOW MANY ACRES SHALL \";\r"
"1911 PRINT \"WE PLANT? \";\r"
"1920 INPUT I\r"
"1925 PRINT\r"
"1930 LET I = INT(ABS(I))\r"
"1935 IF I > C1 THEN GOTO 1960\r"
"1940 LET J = INT(I/2)\r"
"1950 IF J <= B1 THEN GOTO 1980\r"
"1960 GOSUB 9000\r"
"1970 GOTO 1910\r"
"1980 IF I > 10*A1 THEN GOTO 1960\r"
"1990 LET B1 = B1-J\r"
"2010 LET B3 = INT(5*RND(1))+1\r"
"2020 LET B4 = B3*I\r"
"2030 LET B2 = INT((B1+B4)*0.07*RND(1))\r"
"2040 LET B1 = B1-B2+B4\r"
"2050 LET J = INT(10*RND(1))\r"
"2060 LET A2 = INT(A2+(5-B3)*B1/600+1)\r"
"2070 IF A2 <= 50 THEN GOTO 2100\r"
"2080 LET A2 = 50\r"
"2100 LET A1 = A1+A2-A3\r"
"2110 GOTO 1010\r"
"9000 REM***ERROR ROUTINE\r"
"9010 PRINT \"HAMURABI, THINK AGAIN - \";\r"
"9011 PRINT \"YOU ONLY HAVE \"\r"
"9020 PRINT A1;\"PEOPLE,\";C1;\"ACRES, AND \";\r"
"9030 PRINT B1;\"BUSHELS IN STOREHOUSES.\"\r"
"9040 RETURN\r";
const char PROGMEM_LATE histogram_bas[] =
"100 REM NAME--HISTGRAM\r"
"110 REM\r"
"120 REM DESCRIPTION--PLOTS A HISTOGRAM OF SCORES ON A TEST.\r"
"130 REM\r"
"140 REM SOURCE--RONALD FAGIN'67\r"
"150 REM\r"
"160 REM INSTRUCTIONS--D IS THE INCREMENT BETWEEN SCORES. THUS\r"
"170 REM IF ALL SCORES ARE A MULTIPLE OF 5, D IS 5. IN A TYPICAL \r"
"180 REM TEST WHERE ANY INTEGRAL SCORE CAN BE ATTAINED, D IS 1. IT \r"
"190 REM IS ASSUMED IN THIS PROGRAM THAT NO MORE THAN 50 PEOPLE ATTAIN\r"
"200 REM ANY GIVEN SCORE. GIVE AS DATA STARTING IN LINE 1000 FIRST D,\r"
"210 REM THEN THE NUMBER OF PEOPLE WHO TOOK THE TEST, THEN\r"
"220 REM THE SCORES, ONE AT A TIME. \r"
"230 REM\r"
"240 REM\r"
"250 REM * * * * * * * MAIN PROGRAM * * * * * * * *\r"
"260 REM\r"
"270 DIM A(30)\r"
"280 READ D,N\r"
"290 FOR I=1 TO N:READ A(I):NEXT I\r"
"300 LET L=A(1):LET R=A(1)\r"
"310 FOR I=2 TO N\r"
"320 IF A(I)>L THEN 340\r"
"330 LET L=A(I)\r"
"340 IF A(I)<R THEN 360\r"
"350 LET R=A(I)\r"
"360 NEXT I\r"
"370 PRINT \"SCORE\",\"NUMBER OF PEOPLE\"\r"
"380 PRINT\r"
"390 FOR I=L TO R STEP D\r"
"400 LET S=0\r"
"410 PRINT I,\r"
"420 FOR J=1 TO N\r"
"430 IF A(J)<>I THEN 450\r"
"440 LET S=S+1\r"
"450 NEXT J\r"
"460 FOR J=1 TO S\r"
"470 PRINT \"*\";\r"
"480 NEXT J\r"
"490 PRINT\r"
"500 NEXT I\r"
"1000 DATA 2,10, 88,94,96,98,86,88,84,96,88,84\r"
"2000 END\r";
const char PROGMEM_LATE power_bas[] =
"10 REM RECURSIVE INTEGERAL POWER\r"
"20 PRINT \"ENTER A NUMBER TO RAISE TO A POWER:\";\r"
"30 INPUT X\r"
"40 PRINT \"ENTER A POWER (INTEGER > 0):\";\r"
"50 INPUT Y\r"
"60 A=1\r"
"70 GOSUB 100\r"
"80 PRINT \"ANSWER=\"A\r"
"90 END\r"
"100 REM POWER ROUTINE\r"
"110 A=A*X\r"
"120 Y=Y-1\r"
"130 IF Y > 0 THEN GOSUB 100\r"
"140 RETURN\r";
const char PROGMEM_LATE sin_bas[] =
"10 PRINT \"Y = SIN X\"\r"
"20 PRINT\r"
"30 LET L=20\r"
"40 LET M=L+(66-L)/2\r"
"50 PRINT \" X Y\"\r"
"60 FOR X1=-66 TO 66 STEP 2\r"
"70 LET X=.1*X1\r"
"80 LET Y=SIN(X)\r"
"90 LET Y2=10*Y+M\r"
"100 IF X1=0 THEN 210\r"
"110 IF Y2<L THEN 250\r"
"120 IF Y2>66 THEN 250\r"
"130 IF Y2<M THEN 190\r"
"140 IF Y2=M THEN 170\r"
"150 PRINT X;\r"
"151 PRINT TAB(6);Y;\r"
"152 PRINT TAB(M);\"!\";TAB(Y2);\"*\"\r"
"160 GOTO 220\r"
"170 PRINT X;\r"
"171 PRINT TAB(6);Y;\r"
"172 PRINT TAB(Y2);\"*\";TAB(M);\"!\"\r"
"180 GOTO 220\r"
"190 PRINT X;\r"
"191 PRINT TAB(6);Y;\r"
"192 PRINT TAB(Y2);\"*\";TAB(M);\"!\"\r"
"200 GOTO 220\r"
"210 PRINT X;\r"
"211 PRINT TAB(6);Y;\r"
"212 PRINT TAB(Y2);\"*\";TAB(67);\"---Y\"\r"
"220 NEXT X1\r"
"230 PRINT TAB(M);\"X\"\r"
"240 GOTO 260\r"
"250 PRINT \"------------------ T O W I D E --------------------\"\r"
"260 END\r";
const char PROGMEM_LATE snoopy_bas[] =
"100 REM PORT FROM BP-80 SYSTEM (NO CHANGES)\r"
"110 DIM L(80)\r"
"120 FOR T=1 TO 63\r"
"130 LET L(T)=0\r"
"140 NEXT T\r"
"150 LET M=0\r"
"160 READ K,K1\r"
"170 IF K<0 THEN 260\r"
"180 IF K=1000 THEN 1180\r"
"190 IF K=999 THEN 1200\r"
"200 IF K<M THEN 220\r"
"210 LET M=K1\r"
"220 FOR Y=K TO K1\r"
"230 LET L(Y)=1\r"
"240 NEXT Y\r"
"250 GOTO 160\r"
"260 FOR I=1 TO 63 STEP 3\r"
"270 IF I>M THEN 320\r"
"280 IF L(I)=1 THEN 350\r"
"290 IF L(I+1)=1 THEN 460\r"
"300 IF L(I+2)=1 THEN 510\r"
"310 PRINT \" \";\r"
"320 NEXT I\r"
"330 PRINT\r"
"340 GOTO 120\r"
"350 IF L(I+1)=1 THEN 390\r"
"360 IF L(I+2)=1 THEN 440\r"
"370 PRINT\"* \";\r"
"380 GOTO 320\r"
"390 IF L(I+2)=1 THEN 420\r"
"400 PRINT \"** \";\r"
"410 GOTO 320\r"
"420 PRINT \"***\";\r"
"430 GOTO 320\r"
"440 PRINT \"* *\";\r"
"450 GOTO 320\r"
"460 IF L(I+2)=1 THEN 420\r"
"470 PRINT \" * \";\r"
"480 GOTO 320\r"
"490 PRINT \" **\";\r"
"500 GOTO 320\r"
"510 PRINT \" *\";\r"
"520 GOTO 320\r"
"530 DATA 999,0\r"
"540 DATA 40,51,-1,0\r"
"550 DATA 37,51,53,53,-1,-1\r"
"560 DATA 34,49,56,56,-1,-1\r"
"570 DATA 32,47,57,57,-1,-1\r"
"580 DATA 30,45,58,58,-1,-1\r"
"590 DATA 28,43,59,59,-1,-1\r"
"600 DATA 27,41,60,60,-1,-1\r"
"610 DATA 25,39,60,60,-1,-1\r"
"620 DATA 24,37,60,60,-1,-1\r"
"630 DATA 24,35,59,59,-1,-1\r"
"640 DATA 25,32,43,45,58,61,-1,-1\r"
"650 DATA 26,29,41,41,45,45,57,57,62,62,-1,-1\r"
"660 DATA 32,32,40,40,46,46,53,56,-1,-1\r"
"670 DATA 32,32,40,40,46,46,52,52,56,56,-1,-1\r"
"680 DATA 23,23,31,31,39,39,46,46,56,56,-1,-1\r"
"690 DATA 22,22,25,25,30,30,39,39,46,46,56,56,-1,-1\r"
"700 DATA 22,22,26,28,38,38,46,46,56,56,-1,-1\r"
"710 DATA 22,22,27,27,38,38,46,46,56,56,-1,-1\r"
"720 DATA 19,22,28,28,33,35,38,38,45,45,57,57,-1,-1\r"
"730 DATA 15,15,23,23,28,28,32,32,35,35,39,39,44,44,58,58,-1,-1\r"
"740 DATA 13,13,23,23,29,29,32,32,36,36,38,38,44,44,59,59,-1,-1\r"
"750 DATA 12,12,22,22,29,29,32,32,37,39,44,44,60,60,-1,-1\r"
"760 DATA 3,5,11,11,20,23,29,29,32,32,44,44,60,60,-1,-1\r"
"770 DATA 2,2,6,6,10,10,20,23,28,28,32,32,45,45,60,60,-1,-1\r"
"780 DATA 2,2,7,7,20,23,27,27,32,32,46,46,59,59,-1,-1\r"
"790 DATA 2,2,7,7,21,26,31,31,47,47,58,58,-1,-1\r"
"800 DATA 2,4,31,31,51,56,-1,-1\r"
"810 DATA 2,2,31,31,50,55,-1,-1\r"
"820 DATA 2,4,30,30,50,52,54,55,-1,-1\r"
"830 DATA 2,2,8,9,30,30,51,54,-1,-1\r"
"840 DATA 2,4,7,7,10,10,29,29,-1,-1\r"
"850 DATA 3,3,6,6,12,12,27,27,-1,-1\r"
"860 DATA 5,5,15,15,26,26,-1,-1\r"
"870 DATA 17,17,23,23,-1,-1\r"
"880 DATA 18,18,23,23,-1,-1\r"
"890 DATA 16,16,24,24,29,29,31,31,-1,-1\r"
"900 DATA 16,16,24,27,32,32,-1,-1\r"
"910 DATA 17,17,32,32,-1,-1\r"
"920 DATA 18,18,31,31,-1,-1\r"
"930 DATA 20,30,-1,-1\r"
"940 DATA 47,47,-1,-1\r"
"950 DATA 46,46,50,50,-1,-1\r"
"960 DATA 45,45,52,52,-1,-1\r"
"970 DATA 44,44,54,54,-1,-1\r"
"980 DATA 44,44,56,56,-1,-1\r"
"990 DATA 43,43,57,57,-1,-1\r"
"1000 DATA 42,42,58,58,-1,-1\r"
"1010 DATA 42,42,59,59,-1,-1\r"
"1020 DATA 42,42,59,59,-1,-1\r"
"1030 DATA 41,41,60,60,-1,-1\r"
"1040 DATA 41,41,60,60,-1,-1\r"
"1050 DATA 42,42,60,60,-1,-1\r"
"1060 DATA 42,42,60,60,-1,-1\r"
"1070 DATA 42,42,60,60,-1,-1\r"
"1080 DATA 43,42,60,60,-1,-1\r"
"1090 DATA 43,43,60,60,-1,-1\r"
"1100 DATA 44,44,59,59,-1,-1\r"
"1110 DATA 45,45,59,59,-1,-1\r"
"1120 DATA 47,47,58,58,-1,-1\r"
"1130 DATA 48,48,57,57,-1,-1\r"
"1140 DATA 50,50,56,56,-1,-1\r"
"1150 DATA 52,52,55,55,-1,-1\r"
"1160 DATA 1000,0\r"
"1170 DATA 1000,0\r"
"1180 PRINT \"************WE HOPE YOU LIKE IT**************\"\r"
"1190 STOP\r"
"1200 PRINT \"A PICTURE OF SNOOPY FROM BP-80 SYSTEM\"\r"
"1210 PRINT \r"
"1220 GOTO 160\r"
"1230 END\r";
const char PROGMEM_LATE birthday_bas[] =
"100 REM BIRTHDAY UPDATED 5-5-77 TO \"MITS\" BY D. NIXON \r"
"110 DIM Z$(12),L(12),N(60),Y$(7) \r"
"120 DIM G$(12),H$(32) \r"
"130 FOR I=1 TO 12:READ Z$(I):NEXT\r"
"140 FOR I=1 TO 12:READ L(I):NEXT \r"
"150 FOR I=1 TO 7:READ Y$(I): NEXT\r"
"160 FOR I=1 TO 12:READ G$(I):NEXT\r"
"170 FOR I=1 TO 32:READ H$(I):NEXT\r"
"180 DATA JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST: \r"
"190 DATA SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER:\r"
"200 DATA 31,28,31,30,31,30,31,31,30,31,30,31:\r"
"210 DATA THURS,FRI,SATUR,SUN,MON,TUES,WEDNES:\r"
"220 DATA THE MOON,THE SUN,THE EARTH,THE PLANET MERCURY,VENUS,MARS: \r"
"230 DATA JUPITER,SATURN,THE PLANET URANUS,THE PLANET NEPTUNE:\r"
"240 DATA THE PLANET PLUTO,PEANUT BUTTER: \r"
"250 DATA JUXTAROTATION,CONTRAPOSITION,CONTRASTING PHASES,TRANSPOSITION: \r"
"260 DATA SATISFIED,HAPPY,INTERESTING,TOLERANT: \r"
"270 DATA OFTEN,OCCASIONALLY,SOMETIMES: \r"
"280 DATA TEND TO BE,ARE,ARE INCLINED TO BE: \r"
"290 DATA SHORT OF PATIENCE,UNEASY,AT ODDS: \r"
"300 DATA OTHERS.,CLOSE FRIENDS.,YOUNGER PEOPLE.,THOSE IN AUTHORITY.: \r"
"310 DATA \": BEWARE OF \",\" AVOID \" \r"
"320 DATA APPLE PIE,BEING ALONE,DARK PLACES,STRANGERS,UNUSUAL SITUATIONS: \r"
"330 DATA BE TAKING A TRIP YOU HAVE NOT MADE BEFORE.\r"
"340 DATA BE MEETING SOMEONE YOU WILL KNOW FOR THE REST OF YOUR LIFE. \r"
"350 DATA MAKE SEVERAL IMPORTANT DECISIONS INVOLVING OTHERS.\r"
"360 DATA BECOME ILL IF YOU DO NOT LESSEN YOUR UNUSUAL ACTIVITIES. \r"
"370 PRINT \"TYPE IN TODAY'S DATE NUMERICALLY: MO,DAY,YEAR\"; \r"
"380 INPUT X1,Y1,Z1 \r"
"390 IF Z1>99 GOTO 410 \r"
"400 Z1=Z1+1900 \r"
"410 XF=X1:YF=Y1:ZF=Z1:GOSUB 1220:U=ND\r"
"420 PRINT \"TODAY IS \";Y$(U-7*INT(U/7)+1);\"DAY (I HOPE)\" \r"
"430 PRINT \r"
"440 PRINT \"HI, I'M A MICROPROCESSOR.\" \r"
"450 PRINT \"TELL ME YOUR NAME\"; \r"
"460 INPUT N$ \r"
"470 I=INSTR(N$,\" \")-1 \r"
"480 IF I<0 THEN 580 \r"
"490 K$=LEFT$(N$,I) \r"
"500 PRINT \"ARE YOU USUALLY CALLED \";K$;\r"
"510 INPUT A$ \r"
"520 GOSUB 1140 \r"
"530 ON NA GOTO 540,560,510\r"
"540 PRINT \"WHAT DO YOU LIKE TO BE CALLED\"; \r"
"550 INPUT K$ \r"
"560 PRINT \"SO YOUR FULL NAME IS \";N$;\", BUT YOU\" \r"
"570 PRINT \"LIKE TO BE CALLED \";K$;\".\" \r"
"580 PRINT \"HOW OLD ARE YOU, \";K$; \r"
"590 INPUT A\r"
"600 A=INT(A) \r"
"610 IF INT((A-5)/95)=0 GOTO 640 \r"
"620 PRINT \"COME ON, \";K$;\", YOU'RE PULLING MY LEG.\"\r"
"630 GOTO 580 \r"
"640 PRINT \"SO YOU ARE\";A;\"YEARS OLD.\" \r"
"650 PRINT \"DO YOU KNOW, OFF HAND, HOW MANY DAYS OLD YOU ARE\"; \r"
"660 INPUT A$ \r"
"670 GOSUB 1140 \r"
"680 ON NA GOTO 720,690,660\r"
"690 PRINT \"OK, SMARTY, HOW MANY?\" \r"
"700 PRINT \"SORRY, \";K$;\", YOU'LL HAVE TO BE FASTER THAN THAT!\" \r"
"710 GOTO 1600 \r"
"720 PRINT \"OK, I'LL TELL YOU.\" \r"
"730 PRINT \"IN WHAT MONTH WERE YOU BORN\"; \r"
"740 INPUT M$ \r"
"750 FOR X=1 TO 12 \r"
"760 IF M$=Z$(X) GOTO 800 \r"
"770 NEXT X \r"
"780 PRINT K$;\", YOU MAY BE NICE BUT YOU CAN'T SPELL.\" \r"
"790 GOTO 730 \r"
"800 PRINT \"ON WHAT DAY\"; \r"
"810 INPUT Y\r"
"820 Z=Z1-A \r"
"830 IF INT((Y-1)/L(X))=0 GOTO 870 \r"
"840 IF (X-1)*(Y-28)*(Z-4*INT(Z/4)+1)=1 GOTO 870 \r"
"850 PRINT \"COME ON, \";N$;\", YOU'RE GIVING ME A HARD TIME.\" \r"
"860 GOTO 800 \r"
"870 REM\r"
"880 XF=X1:YF=Y1:ZF=Z:GOSUB 1220:W=ND \r"
"890 XF=X:YF=Y:ZF=Z:GOSUB 1220:V=ND \r"
"900 IF W=> V GOTO 920 \r"
"910 Z=Z-1 \r"
"920 IF ABS(W-V)>30 GOTO 990 \r"
"930 ON SGN(W-V)+2 GOTO 940,980,960\r"
"940 PRINT \"YOU HAVE A BIRTHDAY COMING UP IN ONLY\";V-W;\"DAYS!\" \r"
"950 GOTO 990\r"
"960 PRINT \"YOUR BIRTHDAY WAS ONLY\";W-V;\"DAYS AGO. CONGRATULATIONS!\"\r"
"970 GOTO 990 \r"
"980 PRINT \"HAPPY BIRTHDAY, DEAR \";K$;\", HAPPY BIRTHDAY TO YOU.\"\r"
"990 XF=X:YF=Y:ZF=Z:GOSUB 1220:V=ND \r"
"1000 PRINT \"YOU WERE BORN ON \";Y$(V-7*INT(V/7)+1);\"DAY, \";Z$(X);Y;\",\";Z \r"
"1010 PRINT \"WHICH MAKES YOU\";U-V;\"DAYS OLD.\"\r"
"1020 PRINT \"YOU WERE BORN ON THE DAY\";V;\"AD, AND ON JAN. 1, 2000\" \r"
"1030 PRINT \"YOU WILL BE\";730480!-V;\"DAYS OLD.\" \r"
"1040 PRINT \"HOW ABOUT THAT!\" \r"
"1050 PRINT \r"
"1060 GOSUB 1350 \r"
"1070 PRINT \"WELL, \";N$; \r"
"1080 IF N$=K$ GOTO 1100 \r"
"1090 PRINT \" (ALIAS \";K$;\")\"\r"
"1100 PRINT \" IT HAS BEEN NICE CHATTING WITH YOU. DO COME AGAIN.\"\r"
"1110 PRINT \"GOOD BYE\" \r"
"1120 GOTO 1600 \r"
"1130 REM SUBROUTINE FOR YES NO REQUEST \r"
"1140 NA=1\r"
"1150 IF A$=\"NO\" GOTO 1210\r"
"1160 IF A$=\"N0\" GOTO 1210\r"
"1170 NA=2\r"
"1180 IF A$=\"YES\" GOTO 1210 \r"
"1190 NA=3\r"
"1200 PRINT \"A SIMPLE YES OR NO WILL DO! \"\r"
"1210 RETURN \r"
"1220 REM SUBROUTINE TO SOLVE FOR NUMBER OF DAYS \r"
"1230 ND=YF-1 \r"
"1240 FOR I1=1 TO XF-1 \r"
"1250 ND=ND+L(I1) \r"
"1260 NEXT I1 \r"
"1270 I1=INT(ZF/100) \r"
"1280 IF ZF<>4*INT(ZF/4) GOTO 1330\r"
"1290 IF ZF/100=I1 GOTO 1330 \r"
"1300 IF ND>59 GOTO 1330 \r"
"1310 IF XF=3 GOTO 1330 \r"
"1320 ND=ND-1 \r"
"1330 ND=ND+36524!*I1+INT(365.25*(ZF-100*I1)) \r"
"1340 RETURN \r"
"1350 REM GENERATE RANDOM HOROSCOPE \r"
"1360 R1=INT(12*RND(1))+1\r"
"1370 R2 = INT(12*RND(1))+1 \r"
"1380 IF R1=R2 GOTO 1370 \r"
"1390 R=1\r"
"1400 X=4:GOSUB 1570 \r"
"1410 PRINT \"YOU WERE BORN UNDER THE \";H$(NR);\" OF \";G$(R1) \r"
"1420 X=4:GOSUB 1570 \r"
"1430 PRINT \"AND \";G$(R2);\". YOU ARE A BASICALLY \";H$(NR) \r"
"1440 X=3:GOSUB 1570 \r"
"1450 PRINT \"PERSON BUT \";H$(NR);\r"
"1460 GOSUB 1570 \r"
"1470 PRINT \" YOU \";H$(NR) \r"
"1480 GOSUB 1570:N1=NR:X=4:GOSUB 1570:N2=NR:X=2:GOSUB 1570 \r"
"1490 PRINT H$(N1);\" WITH \";H$(N2);H$(NR)\r"
"1500 X=5:GOSUB 1570 \r"
"1510 PRINT H$(NR);\" FOR THE NEXT WEEK. I PREDICT YOU WILL SOON\" \r"
"1520 X=4:GOSUB 1570 \r"
"1530 PRINT H$(NR) \r"
"1540 PRINT \r"
"1550 RETURN \r"
"1560 REM SUBROUTINE TO SELECT RANDOM WORDS \r"
"1570 NR=INT(X*RND(1))+R \r"
"1580 R=R+X \r"
"1590 RETURN \r"
"1600 END\r";
const char PROGMEM_LATE mastermind_bas[] =
"2 PRINT TAB(30);\"MASTERMIND\"\r"
"4 PRINT TAB(15);\"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\"\r"
"6 PRINT: PRINT: PRINT\r"
"10 REM\r"
"20 REM MASTERMIND II\r"
"30 REM STEVE NORTH\r"
"40 REM CREATIVE COMPUTING\r"
"50 REM PO BOX 789-M MORRISTOWN NEW JERSEY 07960\r"
"60 REM\r"
"70 REM\r"
"80 INPUT \"NUMBER OF COLORS\";C9\r"
"90 IF C9>8 THEN PRINT \"NO MORE THAN 8, PLEASE!\":GOTO 80\r"
"100 INPUT \"NUMBER OF POSITIONS\";P9\r"
"110 INPUT \"NUMBER OF ROUNDS\";R9\r"
"120 P=C9^P9\r"
"130 PRINT \"TOTAL POSSIBILITIES =\";P\r"
"140 H=0:C=0\r"
"150 DIM Q(P9),S(10,2),S$(10),A$(P9),G$(P9),I(P),H$(P9)\r"
"160 L$=\"BWRGOYPT\"\r"
"170 PRINT\r"
"180 PRINT\r"
"190 PRINT \"COLOR LETTER\"\r"
"200 PRINT \"===== ======\"\r"
"210 FOR X=1 TO C9\r"
"220 READ X$\r"
"230 PRINT X$;TAB(13);MID$(L$,X,1)\r"
"240 NEXT X\r"
"250 PRINT\r"
"260 FOR R=1 TO R9\r"
"270 PRINT \r"
"280 PRINT \"ROUND NUMBER\";R;\"----\"\r"
"290 PRINT\r"
"300 PRINT \"GUESS MY COMBINATION.\":PRINT\r"
"310 REM GET A COMBINATION\r"
"320 A=INT(P*RND(1)+1)\r"
"330 GOSUB 3000\r"
"340 FOR X=1 TO A\r"
"350 GOSUB 3500\r"
"360 NEXT X\r"
"370 FOR M=1 TO 10\r"
"380 PRINT \"MOVE # \";M;\" GUESS \";:INPUT X$\r"
"390 IF X$=\"BOARD\" THEN 2000\r"
"400 IF X$=\"QUIT\" THEN 2500\r"
"410 IF LEN(X$)<>P9 THEN PRINT \"BAD NUMBER OF POSITIONS.\":GOTO 380\r"
"420 REM UNPACK X$ INTO G$(1-P9)\r"
"430 FOR X=1 TO P9\r"
"440 FOR Y=1 TO C9\r"
"450 IF MID$(X$,X,1)=MID$(L$,Y,1) THEN 480\r"
"460 NEXT Y\r"
"470 PRINT \"'\"; MID$(X$,X,1); \"' IS UNRECOGNIZED.\":GOTO 380\r"
"480 G$(X)=MID$(X$,X,1)\r"
"490 NEXT X\r"
"500 REM NOW WE CONVERT Q(1-P9) INTO A$(1-P9) [ACTUAL GUESS]\r"
"510 GOSUB 4000\r"
"520 REM AND GET NUMBER OF BLACKS AND WHITES\r"
"530 GOSUB 4500\r"
"540 IF B=P9 THEN 630\r"
"550 REM TELL HUMAN RESULTS\r"
"560 PRINT \"YOU HAVE \";B;\" BLACKS AND \";W;\" WHITES.\"\r"
"570 REM SAVE ALL THIS STUFF FOR BOARD PRINTOUT LATER\r"
"580 S$(M)=X$\r"
"590 S(M,1)=B\r"
"600 S(M,2)=W\r"
"610 NEXT M\r"
"620 PRINT \"YOU RAN OUT OF MOVES! THAT'S ALL YOU GET!\":GOTO 640\r"
"622 GOSUB 4000\r"
"623 PRINT \"THE ACTUAL COMBINATION WAS: \";\r"
"624 FOR X=1 TO P9\r"
"625 PRINT A$(X);\r"
"626 NEXT X\r"
"627 PRINT\r"
"630 PRINT \"YOU GUESSED IT IN \";M;\" MOVES!\"\r"
"640 H=H+M\r"
"650 GOSUB 5000\r"
"660 REM\r"
"670 REM NOW COMPUTER GUESSES\r"
"680 REM\r"
"690 FOR X=1 TO P\r"
"700 I(X)=1\r"
"710 NEXT X\r"