Math Wizardry I

Math Wizardry I is a two-part educational program covering tens-and-units addition and subtraction for young children, presenting ten questions per session and tracking a running score out of 20. Each part walks students through place-value reasoning step by step: the units digit is requested first, then the tens digit, with animated carry-ten and take-ten-across sequences displayed when borrowing or carrying is required. The program uses POKE to swap UDG character tables at runtime (storing and restoring the UDG pointer at system variable addresses 23675–23676) so that multiple custom sprite sets can coexist. An ON ERR handler at line 9991–9994 provides a soft error-recovery loop, and the subtraction module offers two selectable school methods (decomposition labeled “a” and equal addition labeled “b”) for the borrow operation. UDG data for characters a–l is loaded via READ/POKE USR at initialization, defining tank, explosion, and decorative graphic sprites used in the animated score display.


Program Analysis

Overall Structure

The listing contains two largely independent programs concatenated together. The first covers tens-and-units addition (lines 1–9994 of the first block) and the second covers tens-and-units subtraction (lines 1–9993 of the second block). Both share the same subroutine layout conventions: single-key input at line 1010, ENTER-to-continue at line 1060, digit-only input at line 1110, and the main question loop starting at line 25/30.

Initialization Routines

Both programs start at line 9900 with screen setup (paper/ink/border colors, a blank-line string stored in e$ or b$). Line 9910 uses INPUT "" (subtraction) or a plain INPUT (addition) as a pause. Line 9925 in the addition program computes prog (the BASIC program start address via PEEK 23635+256*PEEK 23636), then derives pr, u1, u2 for UDG switching, and saves the original UDG pointer in ou1/ou2. The subtraction program’s line 9925 instead performs a RESTORE followed by READ/POKE loops to install 12 UDG definitions (characters a–l) from inline DATA at lines 720–780.

UDG Pointer Switching

The addition program maintains two UDG sets and switches between them at runtime by directly POKEing system variable addresses 23675 and 23676 (the UDG pointer). Subroutine 2270 installs the alternate set (POKE 23675,u1: POKE 23676,u2) and subroutine 2260 restores the original (POKE 23675,ou1: POKE 23676,ou2). This technique allows the decorative header graphics and the question-area underline characters to coexist without conflict. Line 2140 dispatches into a computed GO TO 2145+s*5 table (lines 2150–2250) to selectively redraw portions of the title graphic as score increases.

Question Loop Logic (Addition)

Lines 25–470 form the main question loop. Ten questions are posed (FOR q=1 TO 10). For each question:

  1. A two-digit answer a (20–99) is chosen; it is split into addends x and y (line 40–60).
  2. Digit variables xu, yu, xt, yt are extracted via VAL x$(n) (lines 70–90).
  3. If mode c$="1" (no carry) is selected and a carry would occur (xu+yu>9), the question is regenerated (line 100).
  4. The units digit is requested first (line 135/140), then the tens digit (line 320/330), awarding up to 2 points per question (r).

Carry-Ten Animation

When xu+yu>9, an animated sequence at line 230 prints “carry ten,” then slides the text “10 ” across the screen columns 22 down to 14 using a nested delay loop, visually moving the carry into the tens column. The \m UDG character is used as an underline/overline marker printed with OVER 1 to avoid overwriting the digits beneath.

Question Loop Logic (Subtraction)

The subtraction loop (lines 25–470 of the second block) similarly asks for units then tens. Two difficulty modes are available: mode d=0 excludes questions requiring borrowing (line 113 rejects them), while d=1 allows borrowing. Additionally, the student selects school method m$="a" (decomposition) or m$="b" (equal addition) at line 9960, and the correction display at lines 270–276 branches on m$ to show the appropriate working.

Input Subroutines

LinePurpose
1010–1040Single-key input: flushes keyboard, waits for a keypress, stores in i$
1060–1090ENTER-to-continue prompt; loops until CODE i$=13
1110–1130Digit-only input: rejects any key with code outside 48–57

Scoring and End Sequence (Addition)

The running total s accumulates r points (0–2) per question, giving a maximum of 20. After question 10, lines 480–560 print a grade message. If s>15, a fanfare loop plays (line 575) and the program branches to line 850 for an animated scrolling sequence driven by RANDOMIZE USR (prog+19) — a machine-code call embedded in the BASIC program itself at a fixed offset from prog. The same call appears at line 880. A similar but simpler fanfare and tank-crossing animation appears in the subtraction module at lines 820–858, stepping a tank UDG sprite across row 1 proportional to the score.

Error Handling

Both programs use a multi-line ON ERR recovery block (lines 9990–9993/9994). The pattern is: ON ERR RESET to clear the error state, PAUSE 100 as a delay, then ON ERR GO TO 9990/9991 to loop on further errors, and finally ON ERR CONTINUE to resume normal execution. Line 4 of the addition program installs an initial ON ERR GO TO 9991 handler before the title screen runs.

Notable Idioms and Techniques

  • String-as-boolean: (" " AND t$="0")+(t$ AND t$<>"0") — prints a space for a zero tens digit or the digit itself otherwise, avoiding a leading zero in the answer display.
  • "\m" AND xu+yu>9 — evaluates to the UDG string only when a carry occurred, otherwise the empty string; used to conditionally print the carry mark without an explicit IF.
  • VAL "number" in GO SUB and GO TO targets (e.g., GO TO VAL "40" patterns implied by the structure) is a memory-saving technique.
  • The blank 32-space string e$/b$ is used pervasively for screen clearing via PRINT AT n,0;e$, avoiding full CLS calls that would flash the screen.
  • Line 410 uses t$''''e$;e$ — four apostrophes inside a PRINT statement to emit multiple newlines before printing the blank strings, clearing several rows efficiently.

Potential Anomalies

  • In the addition program, line 25 initializes only s=0, but r is not initialized until line 35. Because line 35 is inside the FOR q loop, this is not a bug in practice.
  • The subtraction program’s line 25 sets both s=0 and r=0, but line 35 immediately resets r=0 and c=0 at the start of each question, so the line 25 assignment of r is redundant.
  • Line 860 is referenced by a GO TO 860 at line 855 of the subtraction block but does not exist in the listing — this is a deliberate technique to exit the loop cleanly.
  • The RANDOMIZE USR (prog+7) and RANDOMIZE USR (prog+19) calls in the addition program invoke machine code at computed offsets within the BASIC area; the actual byte content of that code is not visible in the listing but is embedded in the REM statements at lines 1 and 3.

Content

Appears On

Related Products

Teaches young children the processes involved in solving addition and subtraction problems. Moving displays lead the user through the step...

Related Articles

Related Content

Image Gallery

Math Wizardry I

Source Code

    1 REM 01H!@ GO SUB VAL <>!_O$@PI PRINT LET FREE \:: PRINT w GO SUB POINT y RETURN  POKE LET FREE DEF FN wPI GO SUB R STICK RETURN W BRIGHT !`PFVAL w LOAD DATA $>WSGN  STOP <>890
    3 REM ?\* COPY \  USR LPRINT LIST SAVE DRAW RETURN COPY <<<;K CLS COPY COPY x0 COPY COPY COPY COPY COPY ?? DRAW F COPY COPY RETURN ?$do\*? COPY \c\c COPY COPY COPY COPY II COPY COPY COPY COPY 
    4 ON ERR GO TO 9991
    5 BEEP .4,35: GO TO 9900
   10 REM RESET  J J Warren     1983       tens and units addition    
   25 LET s=0
   30 FOR q=1 TO 10: FOR n=8 TO 21: PRINT AT n,0;e$: NEXT n
   35 LET r=0: LET c=0: PRINT AT 9,0; PAPER 5;"Question ";q
   40 LET a=INT (RND*80+20): LET a$=STR$ a
   50 LET x=INT (RND*(a-20)+10): LET x$=STR$ x
   60 LET y=(a-x): LET y$=STR$ y
   70 LET t$=a$(1): LET u$=a$(2)
   80 LET xt=VAL x$(1): LET xu=VAL x$(2)
   90 LET yt=VAL y$(1): LET yu=VAL y$(2)
  100 IF c$="1" AND xu+yu>9 THEN GO TO 40
  120 GO SUB 2270: PRINT AT 12,14;x;AT 13,13;"+";y;AT 14,14;"\l\l";AT 15,15;"?";AT 16,14;"\l\l": GO SUB 2260
  130 GO SUB 1110
  135 PRINT AT 15,15;" "
  140 IF i$=u$ THEN LET r=r+1: PRINT AT 15,15;u$: BEEP .2,30: GO SUB 2270: PRINT AT 14,14; OVER 1;"\m" AND xu+yu>9: GO SUB 2260: GO TO 320
  150 BEEP 1,-5: PRINT AT 9,23;"Units"
  155 PRINT AT 18,20; PAPER 6;i$;" was wrong."
  160 FOR n=130 TO 190: PLOT n,76: PLOT n,68: NEXT n
  170 PAUSE 50: GO SUB 2270: PRINT AT 12,25;xu;AT 13,24;"+";yu;AT 14,24;"\l\l";AT 16,24;"\l\l": GO SUB 2260
  180 OVER 1: PLOT 130,76: DRAW 60,0: PLOT 130,68: DRAW 60,0: OVER 0
  190 PRINT AT 15,25;"?": GO SUB 1110
  195 PRINT AT 18,20;e$
  200 IF i$<>u$ THEN BEEP 1,-5: PRINT AT 15,25;" ";AT 18,20; PAPER 6;i$;" was wrong.": GO SUB 1060: PRINT AT 18,20;"            ";AT 15,25;u$;AT 15,24;"1" AND xu+yu>9: GO TO 230
  210 BEEP .5,30: PRINT AT 15,25;u$
  220 IF xu+yu>9 THEN PRINT AT 15,24;"?": GO SUB 1110: BEEP .5,-5+(35 AND i$="1"): IF i$<>"1" THEN PRINT AT 15,24;" ";AT 18,20; PAPER 6;i$;" was wrong.": GO SUB 1060: PRINT AT 18,0;e$
  230 IF xu+yu>9 THEN PRINT AT 15,24;"1": GO SUB 1060: PRINT AT 18,17;"carry ten": PAUSE 15: FOR n=22 TO 14 STEP -1: PRINT AT 15,n;"10 ": FOR d=1 TO 15: NEXT d: NEXT n: PAUSE 20: GO SUB 2270: PRINT AT 15,14;"  ";AT 14,14; OVER 1;"\m": GO SUB 2260
  280 FOR d=1 TO 200: NEXT d: PRINT AT 18,0;e$
  300 FOR n=25 TO 15 STEP -1: PRINT AT 15,n+1;" ";AT 15,n;u$: PAUSE 10: NEXT n
  310 PRINT AT 9,0;e$: FOR n=0 TO 4: PRINT AT 12+n,24;"  ": NEXT n: PAUSE 25
  320 PRINT AT 15,14;"?"
  330 GO SUB 1110
  340 IF i$=t$ THEN LET r=r+1: GO SUB 2270: PRINT AT 15,14;(" " AND t$="0")+(t$ AND t$<>"0"); OVER 1;AT 14,14;"\m" AND xu+yu>9: GO SUB 2260: BEEP .2,30: GO TO 450
  350 BEEP 1,-5
  355 PRINT AT 17,0; PAPER 6;i$;" was wrong."
  360 FOR n=102 TO 40 STEP -1: PLOT n,76: PLOT n,68: NEXT n
  370 GO SUB 2270: PRINT AT 9,0;" Tens       ";AT 12,3;xt;AT 13,2;"+";;yt;AT 14,2;"\l\l";AT 15,14;" ";AT 16,2;"\l\l": GO SUB 2260
  380 FOR n=102 TO 40 STEP -1: OVER 1: PLOT n,76: PLOT n,68: OVER 0: NEXT n
  385 IF xu+yu>9 THEN GO SUB 2270: PRINT OVER 1;AT 14,3;"\m": GO SUB 2260
  388 IF (xu+yu>9) AND (VAL i$=VAL t$-1) THEN PRINT PAPER 6;AT 19,0;"You carried ten from the units  column."
  390 PRINT AT 15,3;"?": GO SUB 1110
  395 PRINT AT 17,0;e$
  400 BEEP .5,-5+(35 AND i$=t$): IF i$<>t$ THEN PRINT AT 15,3;" ";AT 17,0; PAPER 6;i$;" was wrong.": FOR d=1 TO 200: NEXT d: PRINT AT 17,0;e$
  405 IF (xu+yu>9) AND (VAL i$=VAL t$-1) THEN PRINT PAPER 6;AT 19,0;"You carried ten from the units  column.": GO SUB 1060: PRINT AT 19,0;e$;e$
  410 PRINT AT 15,3;t$''''e$;e$: FOR d=1 TO 200: NEXT d: FOR n=3 TO 13: PRINT AT 15,n;" ";t$: PAUSE 10: NEXT n
  430 PRINT AT 9,0;e$: FOR n=0 TO 4: PRINT AT 12+n,2;"  ": NEXT n
  440 IF xu+yu>9 THEN GO SUB 2270: PRINT OVER 1;AT 14,14;"\m": GO SUB 2260
  450 LET s=s+r: IF r=2 THEN PRINT AT 18,9;"Well done."
  455 GO SUB 2110: PRINT AT 9,20;s;" out of ";q*2;AT 11,14;" "
  460 GO SUB 1050
  470 NEXT q
  480 GO SUB 2270: LET a$=("                      \i\j\k       " AND s>15)+(e$ AND s<16)+"\e\f     \g\h     \g\f    \g\j\k         "
  485 IF s>15 THEN PRINT AT 3,22; PAPER 5; OVER 1;"\i\j\k"
  490 INK 7: FOR n=8 TO 21: PRINT AT n,0;e$: NEXT n: PRINT AT 19,0;a$: INK 0: RANDOMIZE USR (prog+7)
  495 IF s>15 THEN PRINT AT 3,22; PAPER 5; OVER 1;"\i\j\k"
  500 GO SUB 2260: PRINT AT 9,0;: IF s=20 THEN PRINT "Excellent.": GO TO 560
  510 IF s>17 THEN PRINT "Very good.": GO TO 560
  520 IF s>14 THEN PRINT "Well done.": GO TO 560
  530 IF s>12 THEN PRINT "Good.": GO TO 560
  540 IF s>8 THEN PRINT "If there is something that you  do not understand, ask for help.": GO TO 560
  550 PRINT "You need to ask for help before you have another try."
  560 PRINT ''"Your score was ";("only " AND (s>0 AND s<=8));s;" out of 20."
  570 IF s<12 THEN GO TO 610
  575 FOR m=1 TO 5: FOR n=10 TO 30 STEP 2: BEEP .6/n,n: NEXT n: NEXT m
  580 GO TO 850
  590 IF INKEY$="y" THEN CLS : GO TO 9940
  600 CLS : ON ERR RESET : STOP 
  610 PRINT AT 20,0;"Do you want another go?"'"Type y or n.": GO SUB 1010: IF i$<>"y" AND i$<>"n" THEN GO TO 610
  620 CLS : IF i$="y" THEN GO TO 9940
  630 ON ERR RESET : STOP 
  855 PRINT AT 17,0;"Do you want another go?"'"Type y or n"
  865 IF s>15 THEN GO SUB 2270: PRINT AT 3,22; PAPER 5; OVER 1;"\i\j\k": GO SUB 2260
  880 RANDOMIZE USR (prog+19)
  890 IF INKEY$="y" OR INKEY$="n" THEN GO TO 590
  900 GO TO 880
 1010 IF INKEY$<>"" THEN GO TO 1010
 1020 IF INKEY$="" THEN GO TO 1020
 1030 LET i$=INKEY$
 1040 RETURN 
 1060 PRINT AT 21,4;"Press ENTER to continue."
 1070 GO SUB 1010
 1080 IF CODE i$<>13 THEN GO TO 1060
 1090 PRINT AT 21,0;e$: RETURN 
 1110 GO SUB 1010
 1120 IF CODE i$<48 OR CODE i$>57 THEN GO TO 1110
 1130 RETURN 
 2140 POKE 23675,u1: POKE 23676,u2: GO TO 2145+s*5
 2150 GO TO e
 2160 PRINT AT 0,0; PAPER 5;e$;e$;e$;e$; PAPER 4;e$;e$;e$;e$; PAPER 6;AT 2,28;"\d\d\d\d";AT 3,28;"\c\d\d\d";AT 1,28; PAPER 5; INK 2;"\a\::\::\b": GO TO e
 2170 PRINT PAPER 5; INK 4;AT 4,8;"\b        \a";AT 5,9;"\b      \a";AT 6,9; PAPER 4; INK 1;"\a\::\::\::\::\::\::\b";AT 7,8;"\a\::\::\::\::\::\::\::\::\b": GO TO e
 2180 PRINT PAPER 0; INK 3;AT 1,7;"\d";AT 2,7;"\d";AT 1,18;"\d";AT 2,18;"\d"; INK 0;AT 3,7;"\::";AT 3,18;"\::": GO TO e
 2190 PLOT 64,159: DRAW 79,0,1.3: PLOT 31,144: DRAW 24,15,1.2: PLOT 152,159: DRAW 24,-15,1.2: GO TO e
 2200 LET c=145: PLOT 72,c: DRAW o,9: PLOT 80,c: DRAW o,5: PLOT 88,c: DRAW 0,3: PLOT 96,c: DRAW 0,2: PLOT 111,c: DRAW 0,2: PLOT 119,c: DRAW o,3: PLOT 127,c: DRAW o,5: PLOT 135,c: DRAW o,9: GO TO e
 2210 PLOT 0,144: DRAW 223,0: GO TO e
 2220 PRINT PAPER 5;AT 2,1;"\a\::\b";AT 3,1; PAPER 6;"\d\c\d": PLOT 0,144: DRAW 55,0: GO TO e
 2230 PRINT PAPER 5;AT 3,22;"\i\j\k": PLOT 176,144: DRAW 24,0: GO TO e
 2240 PRINT AT 7,1; PAPER 5;"\d\c\d\d"; PAPER 4; INK 2;AT 6,1;"\a\::\::\b": GO TO e
 2250 PRINT AT 6,23;"\d\d\d\c"; PAPER 4; INK 2;AT 5,23;"\a\::\::\b": GO TO e
 2260 POKE 23675,ou1: POKE 23676,ou2: RETURN 
 2270 POKE 23675,u1: POKE 23676,u2: RETURN 
 9900 PAPER 1: INK 0: CLS : PAPER 7: LET e$="                                ": BORDER 4: PRINT PAPER 2; INK 7;e$;"    \::\::\:: \::\::\:: \::   \::\::\:: \::\::\:: \::\::\::         \::   \:: \:: \::   \:: \:: \:: \:: \::           \::   \::\::\:: \::   \::\::\:: \::\::\:: \::           \::\::\:: \:: \:: \::\::\:: \::   \:: \:: \::\::\::     "; INK 0;e$;"     "; PAPER 7;" Educational Software "; PAPER 2;"     ";e$
 9910 INPUT PAPER 1: PRINT AT 12,3; PAPER 6;" Tens and units addition. "
 9920 PRINT AT 16,0; PAPER 2;e$;e$;e$;e$;AT 17,5; PAPER 7;"  \* 1983 J J Warren  ";AT 18,5;"   BSc ARCS Cert Ed  "
 9925 LET e=2260: LET prog=PEEK 23635+256*PEEK 23636: LET pr=prog+102: LET u1=(pr/256-INT (pr/256))*256: LET u2=INT (pr/256): LET ou1=PEEK 23675: LET ou2=PEEK 23676
 9930 LET o=0: RANDOMIZE : GO SUB 1060
 9940 BORDER 7: CLS : PRINT AT 4,0;"Press 1 for simple sums."''"Press 2 for sums with carry ten."
 9950 GO SUB 1110: LET c$=i$: IF c$<>"1" AND c$<>"2" THEN GO TO 9950
 9990 CLS : GO TO 10
 9991 ON ERR RESET 
 9992 PAUSE 100
 9993 ON ERR GO TO 9991
 9994 ON ERR CONTINUE 
    1 ON ERR GO TO 9990
    5 BEEP .5,20: GO TO 9900
   10 REM RESET  J J Warren     1982       tens and units subtraction 
   20 GO TO 710
   25 LET s=0: LET r=0
   30 FOR q=1 TO 10: FOR n=6 TO 21: PRINT AT n,0;b$: NEXT n
   35 LET r=0: LET c=0: PRINT AT 7,0; PAPER 5;"Question ";q
   40 LET x=INT (RND*79+20): LET x$=STR$ x
   50 LET y=INT (RND*(x-1)+1): LET y$=STR$ y
   60 LET a$=STR$ (x-y)
   70 IF LEN a$=1 THEN LET t$="0": LET u$=a$
   80 IF LEN a$=2 THEN LET t$=a$(1): LET u$=a$(2)
   90 LET xt=VAL x$(1): LET xu=VAL x$(2)
  100 IF LEN y$=1 THEN LET yt=0: LET yu=y
  110 IF LEN y$=2 THEN LET yt=VAL y$(1): LET yu=VAL y$(2)
  113 IF yu>xu AND d=0 THEN GO TO 40
  115 REM print subtraction sum  
  120 PRINT AT 12,14;x;AT 13,13;"-";(" " AND y<10);y;AT 14,14;"\a\a";AT 15,15;"?"
  130 GO SUB 1110
  135 PRINT AT 15,15;" "
  140 IF i$=u$ THEN LET r=r+1: PRINT AT 15,15;u$: BEEP .5,30: GO SUB 810: GO TO 320
  145 REM correct units          
  150 BEEP 1,-5: PRINT AT 9,23;"Units"
  160 FOR n=130 TO 190: PLOT n,76: PLOT n,68: NEXT n
  170 PAUSE 50: PRINT AT 12,25;xu;AT 13,24;"-";yu;AT 14,24;"\a\a"
  180 GO SUB 1060
  190 OVER 1: PLOT 130,76: DRAW 60,0: PLOT 130,68: DRAW 60,0: OVER 0
  200 IF xu>=yu THEN GO TO 290
  210 PRINT AT 18,15;"Take ten across."
  220 PRINT AT 12,15; PAPER 7;xu;AT 13,15;yu
  230 FOR d=1 TO 150: NEXT d
  240 FOR n=14 TO 24: PRINT AT 11,n;"10": PAUSE 10: PRINT AT 11,n;"  ": NEXT n
  250 PRINT AT 12,24;"1"
  260 FOR d=1 TO 150: NEXT d
  270 IF m$="a" THEN PRINT AT 8,0;b$;AT 18,0;b$;AT 11,2;"this leaves ";xt-1; OVER 1;AT 12,14;"\b": LET c=1
  275 IF m$="b" THEN PRINT AT 18,0;b$;AT 13,14; BRIGHT 1; OVER 1;"\g": LET c=1
  280 GO SUB 1060
  290 PRINT AT 9,0;b$;AT 11,2;"           ";AT 15,25;u$: GO SUB 1060
  300 FOR n=25 TO 15 STEP -1: PRINT AT 15,n+1;" ";AT 15,n;u$: PAUSE 10: NEXT n
  310 FOR n=0 TO 2: PRINT AT 12+n,24;"  ": NEXT n: PAUSE 25
  315 REM accept tens            
  320 PRINT AT 15,14;"?"
  330 GO SUB 1110
  340 IF i$=t$ THEN LET r=r+1: PRINT AT 15,14;(" " AND t$="0")+(t$ AND t$<>"0"): BEEP .5,30: GO SUB 810: GO TO 450
  345 REM correct tens           
  350 BEEP 1,-5
  360 FOR n=102 TO 40 STEP -1: PLOT n,76: PLOT n,68: NEXT n
  370 PRINT AT 9,1;"Tens";AT 12,3;xt;AT 13,2;"-";;yt;AT 14,2;"\a\a";AT 15,14;" "
  375 IF m$="a" THEN IF yu>xu THEN PRINT AT 12,3; PAPER 6;xt-1
  376 IF m$="b" THEN IF yu>xu THEN PRINT AT 13,3; PAPER 6;yt+1
  380 FOR n=102 TO 40 STEP -1: OVER 1: PLOT n,76: PLOT n,68: OVER 0: NEXT n
  390 IF yu>xu THEN PRINT AT 18,0; PAPER 6;"You used ten when subtracting   the units."
  400 GO SUB 1060
  410 PRINT AT 18,0;b$+b$;AT 15,3;t$: GO SUB 1060
  420 FOR n=3 TO 13: PRINT AT 15,n;" ";AT 15,n+1;t$: PAUSE 10: NEXT n
  430 PRINT AT 9,0;b$: FOR n=0 TO 2: PRINT AT 12+n,2;"  ": NEXT n
  440 IF t$="0" THEN PRINT AT 15,14;" "
  450 LET s=s+r: IF r=2 THEN PRINT AT 18,9;"Well done."
  455 PRINT AT 7,20;s;" out of ";q*2;AT 11,14;" ": IF m$="a" AND c=1 THEN PRINT OVER 1;AT 12,14;"\b"
  456 IF m$="b" AND c=1 THEN PRINT AT 13,14; OVER 1;"\g"
  460 GO SUB 1050
  470 NEXT q
  480 REM print score            
  490 FOR n=6 TO 21: PRINT AT n,0;b$: NEXT n: PRINT AT 8,0;
  500 IF s=20 THEN PRINT "Excellent.": GO TO 820
  510 IF s>17 THEN PRINT "Very good.": GO TO 560
  520 IF s>14 THEN PRINT "Well done.": GO TO 560
  530 IF s>12 THEN PRINT "Good.": GO TO 560
  540 IF s>8 THEN PRINT "You need more practice. Ask for help if there is something that you do not understand.": GO TO 560
  550 PRINT "You need to ask for help before you have another try."
  560 PRINT ''"Your score was ";("only " AND (s>0 AND s<=8));s;" out of 20."
  565 GO SUB 1060: GO TO 820
  570 IF s<=8 THEN ON ERR RESET : STOP 
  590 PRINT AT 20,0;"Do you want another go?"'"Type y or n."
  600 GO SUB 1010
  610 IF i$="y" THEN GO TO 9930
  620 IF i$<>"n" THEN GO TO 600
  630 CLS : ON ERR RESET : STOP 
  700 REM initialisation        
  720 DATA "a",0,0,0,0,255,0,0,0
  725 DATA "b",1,2,4,8,16,32,64,128
  730 DATA "c",0,60,60,60,60,60,60,60
  735 DATA "d",255,0,0,0,0,0,0,0
  740 DATA "e",0,16,46,65,134,100,24,0
  745 DATA "f",0,0,0,255,19,19,31,127
  750 DATA "g",128,128,128,0,0,0,0,0
  755 DATA "h",0,0,0,0,6,79,255,255
  760 DATA "i",0,120,120,120,48,48,252,254
  765 DATA "j",127,127,127,127,237,210,18,12
  770 DATA "k",255,255,255,255,219,165,36,24
  775 DATA "l",254,254,252,252,182,75,73,48
  785 LET p$="    \e   \e   \e   \e   \e   \e   \e   \e   \e   \e   \e"
  790 CLS : PRINT '"\f\h\i"'"\j\k\l"'; PAPER 4;"    "; PAPER 7;" \c \c \c \c \c \c \c \c \c  "; PAPER 4;"        "; PAPER 1;b$;b$
  795 GO TO 25
  800 REM tank crossing          
  810 PRINT AT 3,3+s+r; OVER 1;"\d": RETURN 
  820 FOR n=0 TO 8: FOR m=3 TO 7 STEP .7: BEEP 0.02,m*m: NEXT m: NEXT n
  830 FOR n=0 TO s: PRINT AT 1,n;" \f\h\i";AT 2,n;" \j\k\l": IF n/3=INT (n/3) THEN PRINT AT 0,n+3;"\e"
  835 PAUSE 5: NEXT n
  840 IF s<20 THEN GO TO 570
  845 FOR n=21 TO 25: PRINT AT 1,n;" \f\h\i";AT 2,n;" \j\k\l": IF n/3=INT (n/3) THEN PRINT AT 0,n+3;"\e"
  846 PAUSE 10: NEXT n: PRINT AT 18,0;"    Press ENTER to finish."
  850 FOR n=2 TO 5: PRINT AT 0,0;p$(n TO n+28): PAUSE 10: NEXT n
  855 IF CODE INKEY$=13 THEN CLS : GO TO 860
  858 GO TO 850
  880 GO TO 570
 1000 REM single key input       
 1010 IF INKEY$<>"" THEN GO TO 1010
 1020 IF INKEY$="" THEN GO TO 1020
 1030 LET i$=INKEY$
 1040 RETURN 
 1050 REM press ENTER to continue
 1060 PRINT AT 21,4;"Press ENTER to continue."
 1070 GO SUB 1010
 1080 IF CODE i$<>13 THEN GO TO 1060
 1090 PRINT AT 21,0;b$: RETURN 
 1100 REM single digit input     
 1110 GO SUB 1010
 1120 IF CODE i$<48 OR CODE i$>57 THEN GO TO 1110
 1130 RETURN 
 9900 PAPER 1: INK 0: CLS : BORDER 4: LET b$="                                ": PRINT PAPER 2; INK 7;b$;"    \::\::\:: \::\::\:: \::   \::\::\:: \::\::\:: \::\::\::         \::   \:: \:: \::   \:: \:: \:: \:: \::           \::   \::\::\:: \::   \::\::\:: \::\::\:: \::           \::\::\:: \:: \:: \::\::\:: \::   \:: \:: \::\::\::     "; INK 0;b$;"     "; PAPER 7;" Educational Software "; PAPER 2;"     ";b$
 9910 INPUT "": PRINT AT 12,2; PAPER 6;" Tens and units subtraction."
 9920 PRINT AT 16,0; PAPER 2;b$+b$+b$+b$;AT 17,6; PAPER 7;" \* 1982 J J Warren  ";AT 18,6;"  BSc ARCS Cert Ed  "
 9925 LET m$="a": RESTORE : FOR n=1 TO 12: READ s$: FOR m=0 TO 7: READ a: POKE USR s$+m,a: NEXT m: NEXT n: PAPER 7: INK 0: GO SUB 1060
 9930 BORDER 7: CLS : PRINT ''''"Type 0 if you want simple sums."'''"Type 1 for sums which involve   taking ten from the tens"'"column.": GO SUB 1010: IF i$<>"0" AND i$<>"1" THEN GO TO 9930
 9940 LET d=VAL i$: IF d=0 THEN CLS : GO TO 10
 9950 CLS : PRINT AT 4,0;"a   5","b"'"     62","     62"'"    -15","    -15"'"     \a\a","     \a\a"'"     47","     47";AT 6,21; OVER 1;"\g": PLOT 40,127: DRAW 7,7
 9960 PRINT AT 12,0;"Choose the method that you use  at school by typing a or b.": GO SUB 1010: IF i$="a" OR i$="b" THEN LET m$=i$: CLS : GO TO 10
 9970 GO TO 9960
 9990 ON ERR RESET 
 9991 PAUSE 100
 9992 ON ERR GO TO 9990
 9993 ON ERR CONTINUE 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top