The ABC Game
In this installment, we’ll finish off the “ABC/123” program package for the ZX81/TS1000, started in the last issue. This time we’ll add an addition trainer (menu options 4-6), and a machine-coded arcade game (option 7).
The Machine Code
Start by entering the rest of the machine-code into the 0 REM statement at the beginning of the program. This time, we’ll add almost 3K, so take your time and (preferably) save to tape after every screen. As before, use the hex-string loader (or a more sophisticated one of your own devise) to enter the eight screens of code (Table 2). Be sure to check the checksum at the end of each screen, and correct any discrepancies before proceeding to the next screen.
This sub-program was actually written in BASIC, and was then compiled into machine-code using the Bob Berch Compiler (still available from G. Russell Electronics). Since not all of the run-time package is used, and the program and variables are relocated from the default values, duplicating my compilation would be a little tricky. For this reason, we’re publishing the object code instead of making you hassle with re-compiling the original source code.
After you finish entering the hex code, save the program to tape. You can then test the game by entering SLOW mode, then entering LET L=USR 18760.
TABLE 2: HEX-CODE FOR ABC/123, PART 2 START = 18760 21010022F453211A0022F65321010022 F85321604922FA531125002AF45319E5 2AF453CDF747C053CDDF48F453CDFA4A 2AFC5322FC53CD0E492AFE53E52AFC53 D1CD2347CD8248120013702AFC53CDB9 48CD8248078084702AFC53CDB948CD82 48800380702AFC53CDB948CD82488180 82702AFC53CDB948CD8248070084703E 76D7CD0E492AFE53E5210000D1CD2347 21010022F45321050022F65321010022 F85321F04922FA532AFC53CDB948CD82 4800000070CDDF48F453CD0E49210B00 E52A0054D1CD2347CD824800838A8300 00000000000000000000000000000000 00000000000000000000008180702A02 54CD2847CD8248808200703E76D7CD88 4A21010022F4531105002A0454CD4247 EB211E001922F65321010022F853216C 4A22FA53CDDF48F453CDB24A1189002A 0654CDB547E5211700D1CD0B49CD0E49 CHECKSUM = 30585 START = 19080 ED5BFC532A06541911A600CDB547E521 1700D1CD0B491189002A0654CDB547E5 219700D1CD0B49CD0E49ED5BFC532A06 541911A600CDB547E5210000D1CD0B49 1189002A0654CDB547E5211700D1CD0B 49CD0E491102002AF453CD4647CDAA48 884A1101002A085419220854C3B24ACD 0E49CD2A0A210500E5210000D1CD2347 CD82488888887021260022F453213F00 22F65321010022F85321274B22FA532A F453CD2847CDDF48F453CD8248888888 888870211E00CDB948CD82488888703E 76D721010022F45321030022F6532101 0022F85321624B22FA53CD8248887021 1F00CDB948CD824888703E76D7CDDF48 F453210000E5211E00D1CD2347CD8248 1770211D00CDB948CD8248878A047021 1E00CDB948CD82488A70211D00CDB948 CD824885970570211D00CDB948CD8248 979797703E76D721010022F453210A00 CHECKSUM = 31264 START = 19400 22F65321010022F85321D74B22FA5321 0000E5210800D1CD2347CD82489780B8 B5A6A8AA80A7B7AEA9ACAA809770CD8E 0B211500E5210300D1CD2347CD82481D 14272A26322A371A0021DA24DF32343B 2A703E76D7210100220A54210A00220C 54210100220E5421354C221054CD1B48 CD9D47111A00CD4647EB2101001922FC 532AFC53CDFB47C053221254CD1B48CD 9D47111A00CD4647EB21010019220054 2A0054CDFB47C053E52AFC53CDF747C0 532A1254E52A0054CDF747C053CDDF48 0A54210000E5210800D1CD2347CD8248 00000000000000000000000000000000 703E76D7CDDF48F453211500E5210300 D1CD2347CD8248312A3B2A310F001D00 102A26383E1100162500102D26372911 703E76D7CD2F49220454111D002A0454 CDD147E51125002A0454CDD047EBE1CD F047CDAA48DC4C111C002A0454CDB547 CHECKSUM = 27671 START = 19720 EB213200CD4A47EB212602CDB5472204 5421020022F453211A0022F653210200 22F85321314D22FA53211300E5110200 2AF45319D1CD23472AF453CDFB47C053 11800019CD28473E76D7CDDF48F45321 010022F45321190022F65321020022F8 53216F4D22FA53211500E51101002AF4 5319D1CD2347CD824800702AF453CDFB 47C05311800019CD28473E76D7CDDF48 F45321100022F45321150022F6532101 0022F85321B24D22FA532AF453E52100 00D1CD2347CD82488580703E76D7CDDF 48F45321000022FC53210D0022005421 0000221454210C002216542101002218 54210100220854219700220254210000 22FE53210C40CD1249E5210D40CD1249 EB210001CD4A47EBE11911A800192206 54CD8149CD054A112400CD2F49CDB947 E5111A002A0054CDD147EBE1CDE547CD AD48464E1101002A0054192200541121 CHECKSUM = 27600 START = 20040 00CD2F49CDB947E51101002A0054CDD0 47EBE1CDE547CDAD486F4E1101002A00 54CDB547220054111D00CD2F49CDB947 CDAA48C14E1101002A085419220854ED 5B04542A0854CDD147CDAA48BE4E2100 002208541101002A1654CDB547221654 210200E52A1654D1CD95482A1654CDBC 47CDAA487F51C31C4E2A1454CDAA4883 4F210C0022F45321150022F653210100 22F85321E14E22FA53CDDC4A2AF453E5 1102002A005419D1CD2347CD82488870 3E76D7CDDF48F4532101002214542A00 54CDFB47C053221A54210000E52A0054 CDF747C053ED5B1A5421800019220254 21140022F453210C0022F65321FFFF22 F85321404F22FA53CDDC4A2AF453E511 02002A005419D1CD23472A0254CD2847 1102002A005419CDB948CD824800703E 76D7CDDF48F4532A1A54CDBC47CDAA48 9350210100221454C31C4E1125002A00 CHECKSUM = 29408 START = 20360 5419ED5B1A54CDB947221C54210B0022 F453ED5B1C54210600CDB54722F65321 FFFF22F85321B34F22FA53CDDC4A2AF4 53E51102002A005419D1CD23472A0254 CD28471102002A005419CDB948CD8248 88703E76D7CDDF48F4532A1C54CDAD48 F04F21880022025421060022F453210B 0022F65321010022F85321085022FA53 CDDC4A2AF453E51102002A005419D1CD 2347CD824800701102002A005419CDB9 482A0254CD28473E76D7CDDF48F4532A 1C54CDBC47CDAA481C4ECDCD49110100 2AFC531922FC53CD8149ED5BFC532A06 5419CD1249118000CDD147E5ED5BFC53 2A065419110100CDB547CD1249118000 CDD147EBE1CDE547CDAA48A250111A00 2AFC53CDB947CDAA4891522100002214 54219700220254C31C4ECD054A211100 221C541101002A005419ED5BFC53CDB5 47CD9D47110400CDD147CDAD48CD5021 CHECKSUM = 31181 START = 20680 0700221C5421000022F4532A1C5422F6 5321010022F85321E55022FA532AF453 22FE531101002AFE53CDB547E52AFE53 CDBC47EBE119E52AFC53D1CD2347CD82 48000000703E76D7CD81491102002AF4 53CD4647CDAD4838512AFE53E5110100 2AFC5319D1CD2347CD824817703E76D7 CDDF48F453210100E5210800D1CD2347 CD824827372E292C2A002E3800273734 302A3370210300E5210900D1CD2347CD 8248B7B4A7B4B980ABAAB1B180B4ABAB 703E76D7C3A051CD054A210700E5210A 00D1CD2347CD8248B4BAB980B4AB80B5 B4BCAAB7703E76D721010022F4532114 0022F65321010022F85321B85122FA53 1101002AFE5319E52AFC53D1CD2347CD 8248808080703E76D7210100220A5421 1400220C54210100220E5421E9512210 54CDDF480A541101002AFE5319E52AFC 53D1CD2347CD8248898089703E76D721 CHECKSUM = 32241 START = 21000 0100220A54211400220C54210100220E 54211F52221054CDDF480A541101002A FE5319E52AFC53D1CD2347CD82480780 84703E76D7210100220A54211400220C 54210100220E54215552221054CDDF48 0A54CDDF48F4532AFE53E52AFC53D1CD 2347CD8248001800702AFC53CDB948CD 8248130013702AFC53CDB948CD824806 0717703E76D7CD0E49CD054A2A165422 0A54210B00220C54210100220E5421AC 5222105421010022F45321050022F653 21010022F85321C45222FA53210000E5 211A00D1CD2347CD8248131712149714 70210000E5211A00D1CD2347CD824812 151316171670210000E5211A00D1CD23 47CD8248120013001700703E76D7CDDF 48F453210200E52A0A54D1CD9848CDDF 480A54210000E5210900D1CD2347CD82 48B7B4A7B4B980B7AAABBAAAB1AAA970 210300E5210600D1CD2347CD8248322E CHECKSUM = 27525 START = 21320 38382E343300262828343235312E382D 2A29703E76D7ED5B0454218A02CDB547 E5ED5B1654210A00CD4A47E5ED5B0854 210A00CD4A47ED5B0454CD4247EBE1CD B547110A00CD4247EB21030019EBE1CD 4A4722FC53211400E5210A00D1CD2347 CD8248382834372A001400702AFC53CD 42483E76D7CD0E492F003C002B003F00 3D002A0030003B0027002E0034000000 2D003E00000036003A00320037002800 330039003500260029002C0015001400 0100B85102001100130088006400156F 41001500140001005552280001000C00 010038001100007600010C00EC251C1C CHECKSUM = 13801 **********************************
The Basic
Now you’ve just got a little work left, that is to enter the BASIC lines of Listing 3. Since all of the key subroutines were already installed last time, adding the driver for the Alpha Space Bridge game (starting at line 4000) and the Addition drills BASIC (starting at line 2000) won’t take you very long.
Finally, you may delete the hex loader/editor (lines 7000-7370) to save a little space and loading time. Save the finished program to tape; you’re done!
2000 REM [illegible]
2010 LET Y$="U"
2020 LET D=0
2030 FOR N=N1 TO 10
2040 LET E=VAL S$(N)
2050 LET F=VAL T$(N)
2060 LET T=E+F
2070 PRINT AT 0,0;N
2080 IF F$<"6" THEN PRINT AT N4,
0;X$( TO N2*E)
2090 LET M$=S$(N)
2100 LET R=N3
2110 LET C=25
2120 GOSUB N2
2130 LET M$="+ "+T$(N)
2140 LET R=8
2150 LET C=17
2160 GOSUB N2
2170 IF F$<"6" THEN PRINT AT 9,0
;X$(TO N2*F)
2180 PRINT AT 13,17;"▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒";AT 16,21;
2190 IF USR BT THEN REM <>0 ?
2200 GOSUB 20
2210 RAND USR REV
2220 LET M$=A$
2230 LET R=16
2240 LET C=25
2250 GOSUB N2
2260 RAND USR REV
2270 IF T<=9 THEN GOTO 2360
2280 IF A$<>"1" THEN GOTO 2370
2290 GOSUB 20
2310 RAND USR REV
2320 LET M$=M$+A$
2330 LET C=21
2340 GOSUB N2
2350 RAND USR REV
2360 IF VAL M$=T THEN GOTO 2420
2370 GOSUB 600
2380 LET LEN=30
2390 GOSUB PA
2400 GOSUB 700
2410 GOTO 2180
2420 GOSUB 500
2430 LET LEN=25
2440 GOSUB PA
2450 GOSUB 150
2460 GOSUB 850
2470 NEXT N
2475 GOSUB 800
2480 GOSUB 300
2490 GOSUB 920
2500 GOSUB 150
2510 IF SC<8 THEN GOTO 1330
2520 IF F$<>"4" THEN GOTO 2560
2530 IF ST=FI THEN GOTO 8800
2540 LET ST=ST+N1
2550 GOTO 1440
2560 IF F$="6" THEN GOTO 8800
2570 LET F$="6"
2580 GOTO 1440
4000 REM [illegible]
4005 SLOW
4010 LET SC=USR 18760
4015 IF SC<26 THEN GOTO 4070
4020 IF NOT HIGH THEN LET HI=SC
4030 IF SC<=HIGH THEN GOTO 4060
4040 LET HIGH=SC
4050 PRINT AT 16,0;"YOU GOT THE
HIGH SCORE, ";N$
4060 PRINT AT 15,8;"HIGH SCORE="
;HIGH
4070 LET LEN=100
4080 GOSUB PA
4090 GOSUB 800
4100 PRINT AT 3,8;
4110 IF USR BT THEN REM <>0PLAY
4120 PRINT AT 8,6;
4130 IF USR BT THEN REM <>0AGAIN
?
4140 IF INKEY$="" THEN GOTO 4140
4150 IF INKEY$="Y" THEN GOTO 400
0
4160 GOSUB 150
Simple Addition
Options 4, 5 and 6 will now be active, and form the second sub-program within ABC/123. Again, several levels within the options provide flexibility and a gradual increase in difficulty. This sub-program displays a pair of large digits (from 0 to 9), and prompts for their sum with a question mark. The format is vertical, with a line below the numbers, just as the student will encounter such problems in school.
Keyboard response is, unfortunately, a little slow; it takes a deliberative keypress to “register.” To help counteract this, the screen flashes when the computer recognizes a valid keypress. Encourage the student to hold the key until the screen flashes.
If a single-digit answer is required (e.g. 5+3=8), then any wrong keypress will result in the infamous “sad face.” If a two digit answer is required (e.g. 8+4=12), the “1” is recognized as the only valid first keypress, and the program waits for the second digit. (The total of two single-digit numbers will of course never exceed 18.)
You might notice that the number zero is included in the number line, and in the problems. This reflects my disagreement with other teaching methods (including Sesame Street), which studiously ignore the zero. Zero is an important number, and the earlier that the student recognizes its significance, the less trouble he will have later when dealing with multiple digits, and (much later) with negative numbers.
The overall format is much like the ABC portion of the program, as is the training emphasis. As before, a score of seven or more robots advances to the next level, whereas less will cause that level to be re-done.
4: Addition Drill
This option is used to drill sums involving specific numbers. When you select this, you are asked which number to start drilling. If you select “1,” for example, it will drill 1+0, 1+1, 1+2, … 1+9. The second number is in random sequence, to prevent “cheating” by simply scanning across the top row of keys. Each number from 0-9 appears only once, for a total of 10 problems per “set.”
After you enter a “Drill which?” number, you are asked “Last Number to Drill?”. To continue the example, if you enter “1” for “Drill which number?” and “3” for “Last number?”, then the drill will advance to “2” when “1” has been adequately completed, and then to “3” before ending off.
To the left of each number, a row of inverse stars is shown, corresponding to that number. If the pupil gets stuck, he can simply count the stars to get the correct answer. This is to help convey the concept of addition as the totalling of two sets of identical items.
Subtraction is not catered to in this program. However, if you study how the addition portion works, you shouldn’t have much difficulty implementing a similar subtraction drill.
5: Scramble1
This is similar to option 4, except that all numbers 0-9 are “fair game,” and are used in ten additions problems. The problems are randomly generated, but each number appears twice; once in the top position, once in the lower position.
Successful completion of ADDITION SCRAMBLE I (seven or more robots) automatically advances to ADDITION SCRAMBLE II.
6: Scramble2
This is like option 5, except that the “stars” that allow counting the total, are not displayed. Mastery of this level makes the pupil ready to go on to two-digit addition, as available on many existing “maths drills” programs.
7: Alpha Space Bridge
The last sub-program is a game called “Alpha-Space Bridge.” Robbie the Robot starts out at the left end of his “space bridge,” and has to cross it to his power station, so that he can refuel. The bridge hasn’t been completed yet, which is where you (or rather, your pupil) comes in. Nothing but the merest framework exists (shown as the alphabetic letters A-Z). At the bottom of the screen are the “bricks” that have to be installed in the bridge (the inverse letters A-Z). The problem is that they’re all mixed up, so you have to flit back and forth in your flying saucer, picking up the right bricks with your “beamer” and installing them in the proper place on the bridge.
Only three keys are used to play the game: the “5” and “8” keys (with the arrows on them) to fly back and forth, and the “1” key to activate the “beamer.” The beamer will pick up whichever brick your saucer is positioned over, and bring it into the “cargo hold.” You then have to install it by flying directly below where it should go, and again energizing the beamer. If you try to install the brick in the wrong place, it will simply bounce back down.
Robbie is something of a simpleton, and can’t tell if the part of the bridge he’s about to step on has been completed. However, he senses whenever you install a brick, and automatically takes a step after each installation. The bridge will break, and Robbie will take a dive (ending the game) if he is standing on more than one unfilled space. He therefore trusts your pupil to have bricks installed where he is about to step.
Meanwhile, Robbie’s energy level (shown as a fuel gauge in the lower left corner) ticks inexorably away. If he runs out of juice before making it to the power station, his eyes start to flash ominously before he self-destructs. End of game, try again. If he makes it across before his fuel runs out, he makes contact with the power station and his gauge fills up again, while his antennae flash happily.
The final score depends on how much fuel he had remaining on reaching his destination, and on the skill level selected. The skill level is specified at the outset of each game; higher numbers are more difficult. The skill level selects the overall pace of the game, and also (more importantly) the rate at which Robbie’s energy depletes. Though the scoring is weighted to reward higher skill levels, it has been carefully balanced so that a younger child can successfully compete with an older friend or sibling who selects a higher skill level. At the end of each game, the highest score thus far is displayed.
This game is especially suited for children who have outgrown the earlier ABC drills. Tell them the basic scenario, but let them discover the “quirks” themselves. It won’t be long before your pupil realizes that he only needs to install every OTHER brick at first, filling in the rest at his leisure. As he gets more proficient, he’ll learn to plan in advance which bricks he picks up, minimizing useless flying around. It also won’t take him long to realize that, once a brick is picked up, it cannot be put back and must be installed in the proper location. He’ll be amused with the graphics, especially when Robbie falls to his demise because of “contractor error.”
Mods
If you’re adept at BASIC programming, you’ll have little trouble adapting the program however you see fit. The program starts with the initialization and Parent/Teacher section at line 9000. From there it goes to the appropriate sub-program; 1000 is the start of the character recognition program, 2000 is the addition program, and 4000 is the Alpha-Space Bridge game. A system of flags is used to keep track of the various sub-levels. Variables are used to store the various USR addresses for the screen utilities, and to store the commonly used numbers 1-5 to economize memory. The “big letters” are done, as mentioned earlier, using Greg Harder‘s “SW-LO-RES,” published in SWN 3:1. It was modified only slightly to refer to the self-contained character patterns instead of the ROM patterns.
Even if you’re not into BASIC hacking, there are a few simple changes you can make to modify the program. To change the scoring, edit line 320 and change the “10” to another number. This number divided by 5 gives the number of seconds (average) corresponding to one robot in the score/reward at the end of the drills. So, to make the scoring more generous, change this to, say, 20. This will especially be necessary if you are using the Oliger video upgrade. To make the scoring more difficult, decrease the number to perhaps 5 (1 robot = 1 second).
If you don’t like my happy/sad faces, change them by modifying the PRINT statements in subroutines 500 and 600. If you make them wider than 7 spaces, you’ll also have to change the number of spaces printed by the “erase face” subroutine at line 730.
To change the scoring criterion for advancing to the next level (currently set at 7), change the number in lines 1320 (character trainer) and line 2510 (addition trainer).
If you don’t want the program to print the problem number in the upper left corner, delete lines 1040 (character trainer) and/or line 2510 (addition trainer).
To save the program to another medium (fast-load tape, disc, etc.), change the SAVE command in line 9990 appropriately.
There is about 3K of unused space in 16K, so you have plenty of room to add your own touches, perhaps even other sub-programs.
I found it very rewarding to see my little friends using and enjoying this program; their smiles made it worth the effort. I’m sure that your little friends will likewise reward you for your efforts in typing it in, and perhaps developing your own applications for the SWN Program Contest.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.