Plus Minus

Type
Education
Category
Early arithmetic for young children
Author
Walter Bulawa and Carol Bulawa
Published in
Antic, October 1984 (Vol. 3, No. 6)
Year
1984
Language
Atari BASIC
Requirements
Any Atari 8-bit, Atari BASIC
A GRAPHICS 2 problem on a black screen: 12 above minus 9, each followed by a row of small blue picture characters, a red line under them and a question mark for the answer

About the program

When a teacher says "Andrew has four blocks and Jennifer gives him two more", the child pictures the blocks and counts on. Walter and Carol Bulawa wrote Plus Minus to give that kind of visual support to a child who has just met addition and subtraction. They wrote it for their own five-year-old son, having owned their Atari since early 1983. Antic printed it in its October 1984 "computer learning" issue. It runs on any Atari.

Each problem is set out in a column: a number, a plus or minus sign and a second number. Beside each number is a row of that many little pictures, such as a car or a flower. No number in a problem is ever below zero or above 14. The child types the answer. There's no need to press RETURN, and the digits can even be typed in either order for a two-digit answer. A correct answer gets "CORRECT", and the right number of pictures slides in from the right beside it. A wrong key gets a falling tone, and the child simply tries again. The program doesn't move on until the problem is solved.

What you need

Atari BASIC. The child needs only the number keys.

Typing it in

The listing uses inverse video in 25 places ({inv}…{/inv}, Atari key), mainly in the strings of picture characters and the title. Lines from 8000 on redefine eleven characters as the pictures. Antic asked readers to check the program with TYPO and to SAVE a backup copy.

How to use it

RUN, press START at the title screen, and hand the keyboard to your child.

How it works

  • Never negative. Lines 100–180 first pick the top number A and the answer C at random (0–14). The middle number B is then the difference, and the sign is chosen to fit: subtraction if C is smaller than A, addition if it is larger. This guarantees a sensible problem without any retries.
  • Pictures in four colours. CHNEW$ holds each of the eleven pictures in four forms: upper case, inverse upper case, lower case and inverse lower case. In GRAPHICS 2 those four forms of one character appear in four different colours, so line 208 picks both a picture and a colour with one random index.
  • Answer checking. Lines 338–370 compare each key with the characters of the answer string still unmatched, blanking out each match. That is why the digits of an answer like 12 can be typed in either order.
  • Numbers are converted with STR$ so their length can be used to right-align them in the column.

Changes from the published listing

One change, so the program also runs under Altirra BASIC, the free replacement BASIC built into many emulators. Altirra BASIC adds a command called CP, so it rejected the published lines that use that word as the start of a variable name. The variable is renamed everywhere in the program. The new name is the same length, so the memory layout is unchanged and the program behaves exactly as published on genuine Atari BASIC. If you type it in from the magazine, the original names work fine on a real Atari.

Published Now Lines
CPOS KPOS 460, 464, 466

Listing

1 REM PLUS(+) MINUS(-)
2 REM BY WALTER BULAWA
3 REM ANTIC MAGAZINE
5 GOSUB 8000
10 GOSUB 10000:REM INITIALIZATION
20 GOSUB 9000
100 REM **SELECT UPPER NUMBER
110 A=INT(15*RND(0))
140 REM **SELECT ANSWER
144 C=INT(15*RND(0))
160 REM **CALCULATE MIDDLE NUMBER
166 IF C>A THEN 180
170 B=A-C:S=2
172 GOTO 190
180 B=C-A:S=1
190 REM **MAKE STRINGS OF A,B,C VALS
192 A$=STR$(A):B$=STR$(B):C$=STR$(C)
194 LA=LEN(A$):LB=LEN(B$):LC=LEN(C$)
200 REM **SELECT OBJECT TO DISPLAY
208 II=INT(4*NOBJS*RND(0))+3
210 ICHAR=ASC(CHNEW$(II,II))
220 REM **PRINT PROBLEM TO SCREEN
222 FOR I=5 TO 9 STEP 2:POSITION 1,I:? #6;"   ":POSITION 5,I:? #6;BLANKS$:NEXT I
224 POSITION 5,10:? #6;BLANKS$
230 POSITION 3-LA+1,5:? #6;A$
231 REM ** DISPLAY OBJECTS NEAR VALUE
232 IF A<=0 THEN 240
233 POSITION 5,5:FOR I=1 TO A:? #6;CHR$(ICHAR);:SOUND 0,20,12,6:FOR D=1 TO 50:NEXT D:SOUND 0,0,0,0:NEXT I
240 POSITION 3-LB+1,7:? #6;B$
242 IF B<=0 THEN 260
243 POSITION 5,7:FOR I=1 TO B:? #6;CHR$(ICHAR);:SOUND 0,20,12,6:FOR D=1 TO 50:NEXT D:SOUND 0,0,0,0:NEXT I
260 POSITION 1,7:? #6;SIGN$(S,S)
280 POSITION 11,1:? #6;"?"
300 REM ** GET ANSWER FROM KEYBOARD
305 D$=C$:NC=0
310 OPEN #1,4,0,"K:":GOSUB 20000
330 GET #1,I:X$=CHR$(I)
332 CLOSE #1
338 REM ** SEE IF INPUT MATCHES ANSWER STRING INTEGERS
339 IF X$=" " THEN 354
340 FOR I=1 TO LC
344 IF X$(1,1)=D$(I,I) THEN NC=NC+1:POP :GOTO 360
350 NEXT I
352 REM ** NO MATCH - WRONG INPUT
354 FOR I=50 TO 200:SOUND 0,I,14,6:NEXT I:SOUND 0,0,0,0
356 GOTO 310
359 REM ** DISPLAY CORRECT INPUT
360 D$(I,I)=" ":POSITION 3-LC+I,9:? #6;X$
370 IF NC<LC THEN 310
400 REM ** CORRECT ANSWER FOUND
425 POSITION 8,1:? #6;"correct"
450 FOR I=1 TO 10:FOR N=200 TO 50 STEP -4:SOUND 0,N,10,6:NEXT N:SETCOLOR 1,I*4,6:NEXT I:SOUND 0,0,0,0
453 SETCOLOR 1,12,10
454 IF C=0 THEN 480
456 REM ** MOVE IN OBJECTS FROM RIGHT
458 D$(1,1)=CHR$(ICHAR):D$(2,2)=" "
460 FOR I=1 TO C:KPOS=5+I-1
461 II=NOBJS*4+2+I
462 D2$(1,1)=CHNEW$(II,II):D2$(2,2)=" "
464 FOR N=18 TO KPOS STEP -1
466 POSITION N,9:? #6;D$:POSITION N,10:? #6;D2$:SOUND 1,10*N,10,4:FOR J=1 TO (KPOS-4)*3+15
467 NEXT J:NEXT N
468 SOUND 1,0,0,0
469 FOR N=1 TO 50:NEXT N:FOR N=50 TO 0 STEP -2:SOUND 0,40,10,N/4:NEXT N:SOUND 0,O,O,O
470 NEXT I
480 FOR I=1 TO 1000:NEXT I
485 POSITION 8,1:? #6;"       "
490 GOTO 100
500 END
8000 REM TITLE PAGE
8010 GRAPHICS 2+16
8050 ? #6;"+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+"
8060 FOR I=2 TO 8 STEP 2
8070 ? #6;"{inv}-{/inv}                 {inv}-{/inv}"
8080 ? #6;"+                 +"
8090 NEXT I
8100 POSITION 0,8:? #6;"+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+{inv}-{/inv}+"
8110 POSITION 4,2:? #6;"PLUS +"
8120 POSITION 9,5:? #6;"{inv}MINUS{/inv} {inv}-{/inv}"
8130 POSITION 4,10:? #6;"{inv}press start{/inv}"
8200 REM MUSIC*SCHOOL DAYS**
8205 POKE 53279,8:GOSUB 20000
8210 RESTORE 8400
8250 READ X:IF X=-1 THEN FOR J=1 TO 200:NEXT J:GOTO 8210
8260 IF PEEK(53279)=6 THEN SOUND 2,0,0,0:GRAPHICS 2+16:POSITION 4,5:? #6;"PLEASE WAIT":GOSUB 20000:RETURN
8300 SOUND 2,X,10,8:FOR J=1 TO 20:NEXT J:GOTO 8250
8400 DATA 60,60,60,0,0,72,72,72,0,0,81,81,81,0,0,91,91,91,0,0,81,81,0,91,91,108,108,0,96,96,91,91,0,0,0
8500 DATA 121,121,121,0,-1
8999 RETURN
9000 REM MORE INITIALIZATION
9010 GRAPHICS 2+16
9020 POKE 756,CHBASE/256
9040 COLOR 33:PLOT 4,2:DRAWTO 4,11
9044 COLOR 35:PLOT 1,8:DRAWTO 3,8
9099 RETURN
10000 DIM SIGN$(2),A$(2),B$(2),C$(2),D$(2),X$(1),CHNEW$(60),D2$(2)
10002 DIM BLANKS$(15)
10010 FOR I=1 TO 15:BLANKS$(I,I)=CHR$(0):NEXT I
10012 SIGN$="+-"
10014 CHNEW$="!#ABXDYFGHIJK{inv}ABXDYFGHIJK{/inv}abxdyfghijk{inv}abxdyfghijk{/inv}$%&'()*,./:;<="
10020 MEMTOP=PEEK(106)*256
10030 CHBASE=MEMTOP-2048
10040 REM ** GET ORIGINAL CHARS
10042 FOR I=0 TO 511:POKE CHBASE+I,PEEK(57344+I):NEXT I
10050 REM ** DEFINE NEW CHARACTERS
10060 NOBJS=11
10062 RESTORE 10102
10064 FOR I=1 TO NOBJS+2:CHADD=CHBASE+(ASC(CHNEW$(I,I))-32)*8
10066 FOR J=0 TO 7:READ N:POKE CHADD+J,N:NEXT J:NEXT I
10079 REM ** DEFINE MINI-NUMBER SET
10080 FOR I=1 TO 14:II=4*NOBJS+2+I:CHADD=CHBASE+(ASC(CHNEW$(II,II))-32)*8
10082 FOR J=0 TO 7:READ N:POKE CHADD+J,N:NEXT J:NEXT I
10102 DATA 20,20,20,20,20,20,20,20
10103 DATA 0,0,255,255,0,0,0,0
10104 DATA 60,36,36,126,90,126,36,0
10105 DATA 36,66,90,126,126,90,66,0
10106 DATA 56,108,124,16,24,16,24,0
10107 DATA 0,16,56,124,124,254,8,0
10108 DATA 24,24,60,126,126,106,110,0
10109 DATA 0,254,138,142,138,142,254,254
10110 DATA 0,4,9,127,16,8,4,0
10111 DATA 2,114,254,188,254,114,2,0
10113 DATA 24,24,94,24,24,88,120,0
10114 DATA 0,102,0,24,66,60,0,0
10115 DATA 32,96,33,62,62,34,34,0
10150 DATA 0,8,8,8,8,8,8,0
10152 DATA 0,24,36,4,8,16,60,0
10154 DATA 0,24,36,12,4,36,24,0
10156 DATA 0,36,36,60,4,4,4,0
10158 DATA 0,60,32,56,4,4,56,0
10160 DATA 0,24,32,32,60,36,60,0
10162 DATA 0,60,4,8,16,32,32,0
10164 DATA 0,60,36,60,36,36,60,0
10166 DATA 0,60,36,60,4,4,4,0
10168 DATA 0,94,82,82,82,82,94,0
10170 DATA 0,36,36,36,36,36,36,0
10172 DATA 0,76,82,66,68,72,94,0
10174 DATA 0,76,82,70,66,82,76,0
10176 DATA 0,82,82,94,66,66,66,0
10200 RETURN
19000 REM DISABLE BREAK KEY
20000 DSBL=PEEK(16)-128:IF DSBL<0 THEN RETURN
20010 POKE 16,DSBL:POKE 53774,DSBL:RETURN

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: PLSMINUS.BAS.

Credits