Dale’s Atari 800 Games › Stan Ockers
By Stan Ockers, in the ACE newsletter of December 1983 – January 1984.
Play Alphabet TrainString operations on the Atari can be used to move data around in memory at machine level speeds. I’ve used this method for movement in a game called ‘Alphabet Train’ which is designed to train preschoolers in the positional aspect of letters in the alphabet.
The train and truck in the program consist of strings of characters. Parts of these strings are mapped onto the screen area. Motion is produced by changing the portion of the string being mapped. Movement of the boat in last month’s program ‘Cannibals’ was done by using this method.
Another string is set aside as the player missile area. Vertical movement of players representing the grabber, pushers and selected letter is also done by using string operations.
The key to using these techniques is a table holding information about all variables. It is called the Variable Value Table and is built up as information is entered from the keyboard. Each time a new variable is encountered, eight bytes are set aside to hold the relavent information. For strings, this includes where to find the string, how long it is, and how much space was set aside when it was dimensioned.
The second and third of the eight bytes give the string location in the standard low byte, high byte order. This is not an absolute address, however, but is an offset from a particular spot in memory; the spot being the beginning of the area holding the string characters (STARP).
Since we want to ‘fool’ the Atari into thinking the string is located somewhere else, all that is necessary is to have the string dimensioned, (you can give it a DIM of 1). This will create the eight bytes. We must then know where the eight bytes are located so we can change them at will.
Locations 134 and 135 (decimal) hold a pointer to the variable value table (VVTP). If we arrange things so the first variables entered are ones upon which we want to operate, then we know the appropriate locations.
The first line entered (exclusive of REMs) should be a DIM statement with the string variables in the order we want them to appear in the table. Remember it is the order they are entered from the keyboard; so if we later decide we want another string and modify this first line, we must ‘LIST’ to disk or cassette and ‘ENTER’ the program again so the variable value table will be rebuilt just as if we were entering it from the keyboard for the first time.
A$ is the first variable found in the ‘Train’ program and is changed to point at the previously allocated Player Missile area. The offset is initially zero (it is at the start of the variable area), but is changed to the difference between the player part of the PM area and this position by poking numbers into the third and forth bytes of the eight representing variable A$ (VVTP + 2 & VVTP + 3). The size (5th and 6th) and dimesion (7th and 8th) are also changed to 512 bytes, the size of the player portion of the PM area, (see lines 350 - 390).
It should be possible to use the variable value table changing technique to move the character set into RAM but when I tried, it got all messed up so I just wrote a simple machine level user call to move one page. Since only 64 characters are available in Gr. 18 and require only 512 bytes, I used the unused portion at the beginning of the PM area and chose to have graphic symbols and capital letters.
PM images are assigned to strings with zero bytes at the ends so when vertical movement occurs, the previously drawn image will be wiped out. When a letter is selected, the grabber is lowered (Player #0), the letter blanked out from the train string and reconstructed as Player #1. It continues as player #1 until finally dropped on the truck where it is erased and entered into the proper truck string.
Vertical movement seems quite smooth although you might notice a slight jitter between the grabber and letter caused by successive string movements from Basic.
B$ is the second variable in the table and is changed in size to 261 bytes, (the size of the graphics 18 screen), and mapped over the screen area. Movement of images in this area is simply a matter of string manipulations. You are of course limited to multiples of a character size for movement but it doesn’t seem too unrealistic in the case of the train and truck.
It should be pointed out the characters assigned to strings are not the characters appearing on the screen unless they are put on using PRINT statements. This is because the ATASCII order of characters is not the same as the order they appear in ROM. In a PRINT statement, a number is assigned based on the ATASCII order, (the one you get with ASC), and a conversion is made to reflect the order the character appears in ROM. Since we are mapping directly onto the screen, no conversion is made and allowance must be made when we choose characters.
I anticipated problems with jerkyness because Basic is so slow. I especially worried about the truck and train because they take three seperate string operations for each motion. I think you will agree the worry was in vain and that movement using strings is a valuable technique which can be used in place of machine routines.
—Stan Ockers

The listing, “ALPHABET by Stan Ockers by Stan Ockers”, is on pages 6, 7 of the issue. The game page runs it line by line in an emulated Atari 800, just as typed in.
Where this copy came from: Typed-in copy from Atarimania (Alphabet_Train.zip), compared line by line with the December 1983 – January 1984 scan. The copy was the version Atari User printed in England in 1985: keyboard controls added, a longer word list with British words (TYRE, WICKET), a different title screen and header. Every changed line is put back as Stan printed it. The printed listing stops at line 2040, in the middle of the tune routine, so lines 2050-2070 come from the typed copy.
0 REM Printed on a Mannesmann Tally Spirit-80 printer with square dots
1 REM ******************************
2 REM *{inv}Atari Computer Enthusiasts{/inv} *
3 REM * {inv}3662 Vine Maple Dr{/inv} *
4 REM * {inv}EUGENE, OR 97405{/inv} *
5 REM * $12 YEAR *
6 REM * DEC 83/JAN 84
7 REM ******************************
100 REM ****************************
110 REM ** ALPHABET TRAIN **
120 REM ** STAN OCKERS 11/83 **
130 REM ****************************
140 REM
142 REM ** DEFINE STRINGS **
148 GRAPHICS 18:POSITION 5,5:? #6;"AlPhAbEt":POSITION 7,7:? #6;"tRaIn":POSITION 2,10:? #6;"INITIALIZING .."
150 DIM A$(1),SCR$(1),B$(12),TRN1$(180),TRN2$(180),TRN3$(180),TRK1$(28),TRK2$(28),TRK3$(28),W$(6)
160 DIM L$(10):L$(10)=CHR$(0):L$(1,1)=CHR$(0):L$(2)=L$:DIM BL$(10):BL$=L$
170 DIM P$(8):RESTORE 180:FOR J=1 TO 8:READ A:P$(J,J)=CHR$(A):NEXT J
180 DATA 1,3,7,255,255,7,3,1
190 DIM R$(8):RESTORE 200:FOR J=1 TO 8:READ A:R$(J,J)=CHR$(A):NEXT J
200 DATA 128,192,224,255,255,224,192,128
210 RESTORE 220:FOR J=1 TO 12:READ A:B$(J,J)=CHR$(A):NEXT J
220 DATA 24,36,66,129,129,129,129,129,129,129,66,0
230 TRN1$(180)=" ":RESTORE 232:FOR J=1 TO 24:READ A:TRN1$(J,J)=CHR$(A):NEXT J:TRN1$(25)=TRN1$
232 DATA 77,84,84,0,84,84,205,212,212,128,212,212,13,20,20,0,20,20,141,148,148,128,148,148
240 TRN2$(180)=" ":RESTORE 242:FOR J=1 TO 24:READ A:TRN2$(J,J)=CHR$(A):NEXT J:TRN2$(25)=TRN2$
242 DATA 0,32,32,32,32,32,0,96,96,96,96,96,0,160,160,160,160,160,0,224,224,224,224,224
250 TRN3$(180)=CHR$(0):TRN3$(1,1)=CHR$(0):TRN3$(2)=TRN3$:FOR J=10 TO 160 STEP 6:TRN3$(J,J)=CHR$(J/6+95):NEXT J
260 RESTORE 262:FOR J=1 TO 28:READ A:TRK1$(J,J)=CHR$(A):NEXT J
262 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,84,84,0,0,0,0,84,84,0,84,0,0
264 RESTORE 266:FOR J=1 TO 28:READ A:TRK2$(J,J)=CHR$(A):NEXT J
266 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,224,224,224,224,224,224,21,32,32,32,32,0
270 RESTORE 272:FOR J=1 TO 28:READ A:TRK3$(J,J)=CHR$(A):NEXT J
272 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,13,22,0,8,
278 REM ** SET ASIDE PM AREA **
280 GRAPHICS 7:POKE 106,PEEK(106)-5:PM=PEEK(106)+1:POKE 54279,PM:GRAPHICS 18:GOSUB 910
290 RESTORE 300:FOR J=704 TO 712:READ A:POKE J,A:NEXT J
300 DATA 32,255,18,82,50,255,34,52,57
310 POSITION 5,1:? #6;CHR$(142);CHR$(142);CHR$(142):POSITION 6,6:? #6;"--------------"
320 POSITION 0,10:? #6;"{inv}++++++++++++++++++++{/inv}";:REM ** ALL +'S IN INVERSE **
330 POKE 559,46:POKE 53277,3
340 REM ** MAP A$ ONTO PM AREA **
350 VVTP=PEEK(134)+PEEK(135)*256:STARP=ADR(A$)
380 OFFS=PM*256+512-STARP:HI=INT(OFFS/256):LO=OFFS-HI*256
390 POKE VVTP+2,LO:POKE VVTP+3,HI:POKE VVTP+5,2:POKE VVTP+6,0:POKE VVTP+7,2
392 REM ** MAP SCR$ ONTO SCREEN AREA **
400 SCR=PEEK(88)+256*PEEK(89):OFFS=SCR-STARP:HI=INT(OFFS/256):LO=OFFS-HI*256
420 POKE VVTP+10,LO:POKE VVTP+11,HI
430 POKE VVTP+12,5:POKE VVTP+13,1:POKE VVTP+14,5:POKE VVTP+15,1
440 Y=60:Z=80:X=50
450 A$(Y,Y+11)=B$:POKE 53248,Z:FOR J=1 TO 59:A$(J,J)=CHR$(24):NEXT J
460 A$(280,287)=P$:XP=64:POKE 53250,XP
470 A$(408,415)=R$:XR=158:POKE 53251,XR
478 REM ** TRUCK COMES IN FROM RIGHT **
480 FOR J=1 TO 15:XT=J:GOSUB 1050:SOUND 0,100,4,XT/2:FOR K=1 TO 20:NEXT K:NEXT J:POKE 77,0
488 REM ** PRINT WORD **
490 GOSUB 1010:POSITION 10-LEN(W$)/2,11:? #6;W$
498 REM ** LOOP TO MOVE TRAIN **
500 S=STICK(0):IF S=7 AND X>6 THEN X=X-1:DIR=-1
510 IF S=11 AND X<156 THEN X=X+1:DIR=1
520 IF S<15 THEN 560
530 IF INT(X/6)=X/6 THEN 560
540 IF DIR=-1 THEN X=X-1
550 IF DIR=1 THEN X=X+1
558 REM ** MOVE TRAIN **
560 SCR$(181,200)=TRN1$(X,X+19)
570 SCR$(161,180)=TRN2$(X,X+19)
578 REM ** SOUND IF TRAIN MOVING **
580 SCR$(141,160)=TRN3$(X,X+19)
590 IF X=SX THEN SOUND 0,0,0,0
600 IF X<>SX THEN SOUND 0,100,4,6:SX=X
610 IF STRIG(0)=1 THEN 500
618 REM ** PICK UP LETTER **
620 C=ASC(TRN3$(X+4)):IF C=0 THEN 500
630 FOR J=1 TO 11:Y=Y+1:A$(Y,Y+11)=B$:SOUND 0,(Y+100)*(Y/3=INT(Y/3)),10,6:FOR K=1 TO 20:NEXT K:NEXT J
640 CS=57344+256+8*X/6:FOR J=1 TO 8:L$(J+1,J+1)=CHR$(PEEK(CS+J-1)):NEXT J
650 A$(129+Y,139+Y)=L$:POKE 53249,Z
660 P=4+X:TRN3$(P,P)=CHR$(0):SCR$(141,160)=TRN3$(X,X+19)
670 FOR J=1 TO 50:Y=Y-1:A$(Y,Y+11)=B$:A$(129+Y,139+Y)=L$:SOUND 0,(Y+100)*(Y/3=INT(Y/3)),10,6:FOR K=1 TO 10
680 NEXT K:NEXT J:SOUND 0,0,0,0:FOR J=1 TO 8:XP=XP+1:POKE 53250,XP:NEXT J
688 REM ** IF LETTER NOT CORRECT DROP IT **
690 IF C-32<>ASC(W$(LTR+1)) THEN GOSUB 820
700 FOR J=1 TO 32+8*LTR:Z=Z+1:XP=XP+1:POKE 53250,XP:POKE 53249,Z
710 SOUND 0,Y+100*(XP/3=INT(XP/3)),10,6:NEXT J:LTR=LTR+1
720 FOR J=1 TO 15:Y=Y+1:A$(129+Y,139+Y)=L$:SOUND 0,Y+100,10,6:NEXT J:A$(129+Y,139+Y)=BL$
730 P=16+LTR:TRK3$(P,P)=CHR$(X/6+96):SCR$(67,80)=TRK3$(XT,XT+13):POSITION (Z-48)/8,1:? #6;CHR$(142)
740 FOR J=1 TO 30:SOUND 0,100+100*RND(0),8,(30-J)/3:NEXT J
750 XP=XP-1:POKE 53250,XP:SOUND 0,Y+100*(XP/3=INT(XP/3)),10,6:IF XP>64 THEN 750
760 Z=80:POKE 53249,Z:Y=Y-15
770 FOR J=1 TO 39:Y=Y+1:A$(Y,Y+11)=B$:SOUND 0,Y+100,10,6:NEXT J
780 SOUND 0,0,0,0:IF LTR<LEN(W$) THEN 500
788 REM ** WORD CORRECT - MOVE TRUCK OUT **
790 FOR J=15 TO 1 STEP -1:XT=J:GOSUB 1050:SOUND 0,100,4,XT/2:FOR K=1 TO 20:NEXT K:NEXT J
795 GOSUB 2040
800 POSITION 7,11:? #6;" ":FOR J=10 TO 160 STEP 6:TRN3$(J,J)=CHR$(J/6+95):NEXT J
810 LTR=0:FOR J=17 TO 22:TRK3$(J,J)=CHR$(0):NEXT J:POSITION 8,1:? #6;" ":GOTO 480
818 REM ** ROUTINE FOR PUTTING INCORRECT LETTER BACK **
820 FOR J=1 TO 14:SOUND 0,50+50*(XP/3=INT(XP/3)),10,6
830 Z=Z+1:XP=XP+1:XR=XR-4:POKE 53249,Z:POKE 53250,XP:POKE 53251,XR:NEXT J:SOUND 0,0,0,0
840 FOR J=1 TO 14:Z=Z-1:XP=XP-1:XR=XR-1:POKE 53249,Z:POKE 53250,XP:POKE 53251,XR:NEXT J
850 FOR J=1 TO 8:XP=XP-1:XR=XR+2:POKE 53250,XP:POKE 53251,XR:Y=Y+1:A$(129+Y,139+Y)=L$:A$(Y,Y+11)=B$:NEXT J
860 FOR J=1 TO 27:XR=XR+2:POKE 53251,XR:Y=Y+1:A$(129+Y,139+Y)=L$:A$(Y,Y+11)=B$:SOUND 0,Y+100,10,8:NEXT J
870 FOR J=1 TO 15:SOUND 0,Y+100,10,8:Y=Y+1:A$(Y,Y+11)=B$:A$(129+Y,139+Y)=L$:NEXT J:TRN3$(P,P)=CHR$(C)
880 FOR J=1 TO 30:SOUND 0,100+100*RND(0),8,(30-J)/3:NEXT J
890 SCR$(141,160)=TRN3$(X,X+19):A$(129+Y,139+Y)=BL$:FOR J=1 TO 11:Y=Y-1:A$(Y,Y+11)=B$:NEXT J
900 SOUND 0,0,0,0:GOTO 500
908 REM ** MACHINE LEVEL - MOVE CHARACTER SET **
910 POKE 756,PM
920 DIM MV$(23):RESTORE 930:FOR J=1 TO 23:READ A:MV$(J,J)=CHR$(A):NEXT J
930 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,160,0,177,203,145,205,136,208,249,96
940 CS=57344+512:NCS=PM*256:A=USR(ADR(MV$),CS,NCS)
950 FOR J=NCS TO NCS+7:POKE J,0:NEXT J
960 CS=57344+256:NCS=PM*256+256:A=USR(ADR(MV$),CS,NCS)
970 FOR J=NCS TO NCS+7:POKE J,255:NEXT J
980 NCS=PM*256:RESTORE 990:FOR J=160 TO 167:READ A:POKE NCS+J,A:NEXT J
990 DATA 0,0,60,102,219,219,102,60
1000 POKE 756,PM:RETURN
1008 REM ** PICK A WORD SUBROUTINE **
1010 RESTORE 1020:FOR J=1 TO INT(RND(0)*10)+1:READ W$:NEXT J:RETURN
1020 DATA DOG,CAT,BIRD,HAND,COW,HORSE,PET,FROG,FLY,ARM
1030 DATA HAIR,TOE,FINGER,LEG,FACE,EAR,MOUTH,BAT,WORK,PLAY
1040 DATA WAGON,BIKE,MILK,WATER,JUICE,BREAD,ANT,GOAT,GHOST,FLAT
1048 REM ** PRINT TRUCK SUBROUTINE **
1050 SCR$(107,120)=TRK1$(XT,XT+13):SCR$(87,100)=TRK2$(XT,XT+13):SCR$(67,80)=TRK3$(XT,XT+13):RETURN
2030 REM ** TUNE SUBROUTINE **
2032 DATA 91,6,121,1,91,2,121,1,91,2,81,1,72,8,91,8,68,6,68,1,91,4,81,4,72,8,0,4
2034 DATA 91,6,121,1,91,2,121,1,91,2,81,1,72,8,91,4,72,2,72,1,72,4,81,4,81,4,72,4,81,8
2040 RESTORE 2032:FOR J=1 TO 29:READ P,T:IF P=0 THEN FOR K=1 TO 20*T:NEXT K:GOTO 2070
2050 SOUND 0,P,10,8:SOUND 1,2*P,10,6:FOR L=1 TO 12*T
2060 NEXT L:SOUND 0,0,0,0:SOUND 1,0,0,0
2070 NEXT J:RETURN