Atari Basic Programs
Listed below I have included some code sample from some simple Atari Basic programs I have written. When I get more time, I will add to this section explaining a little more about them.
Atari Basic Game
10 REM GAME STARTER
20 REM GM3.BAS, GAME1.LST, GAME1.BAS
30 REM 7/15/07
40 DIM M$(100),CH$(100),R$(13),G$(100)
65 GOSUB 2902:GRAPHICS 1:POKE 756,BEGIN/256
70 POKE 708,152:POKE 709,250:POKE 710,52:POKE 711,36
76 COLOR 8+160:PLOT 13,15
80 REM
100 POSITION 1,1:? #6;”SCORE:”;SC
102 DL=PEEK(560)+PEEK(561)*256:REM POKE DL+6,2:POKE DL+7,7:POKE DL+28,6:POKEDL+29,6:POKEDL+30,6
103 TX=PEEK(660)+PEEK(661)*256+1
105 DIM P(10)
126 GOSUB 1900
127 X=6:Y=5:RM=1
130 ST=PEEK(632):TR=PEEK(644)
131 PX=X:PY=Y
132 COLOR 4+32:PLOT X,Y
133 IF ST<15 THEN COLOR 32:PLOT X,Y
134 IF TR>0 THEN 140
135 REM
136 IF ST=7 THEN GOSUB 1020
137 IF ST=11 THEN GOSUB 1100
140 IF ST=7 THEN X=X+1:SAFE=0
150 IF ST=11 THEN X=X-1:SAFE=0
160 IF ST=13 THEN Y=Y+1:SAFE=0
165 IF ST=14 AND TR<1 AND BYLAD THEN COLOR 32:PLOT X,Y:Y=Y-3:X=X+1:COLOR 32:PLOT
X,Y:PX=X:PY=Y
170 IF ST=14 AND NOT (BYLAD) THEN Y=Y-1:SAFE=0
175 IF Y<3 THEN Y=3
180 LOCATE X,Y,CL:IF CL=170 AND NOT (BYLAD) THEN X=PX:Y=PY
185 LOCATE X,Y+1,C2
186 LOCATE X,Y-1,C3
187 LOCATE X,Y+1,C4
190 IF CL=168 THEN GOSUB 1000
195 IF C3<>1 THEN BYLAD=0
200 IF C3=1 THEN BYLAD=1
205 IF C4=1 AND ST=13 THEN COLOR 32:PLOT X,Y:Y=Y+2:COLOR 32:PLOT X,Y:PX=X:PY=Y
210 IF X=18 THEN RM=RM+1:GOSUB 2930
212 IF X<1 THEN RM=RM-1:GOSUB 2930:IF RM<1 THEN RM=1
215 IF C2=32 AND NOT (SAFE) THEN GOSUB 800
300 GOTO 130
800 PX=X:PY=Y:FOR A=0 TO 19
801 LOCATE X,Y+A+1,CC:IF CC=170 THEN SAFE=1:X=PX:Y=A+Y:RETURN
802 COLOR 36:PLOT X,Y+A
805 FOR S=1 TO 10:NEXT S
810 COLOR 32:PLOT X,Y+A
820 NEXT A
900 RETURN
910 A=0:PX=X:PY=Y:FOR A=Y TO Y-1 STEP -1
920 LOCATE X,A-1,CC
925 COLOR 36:PLOT X,A
930 FOR S=1 TO 10:NEXT S
940 COLOR 32:PLOT X,A
950 IF CC=138 THEN X=PX:Y=PY:RETURN
960 NEXT A
990 RETURN
1000 M$=”You take the object into possession”
1010 IF CL=168 THEN GOSUB 5000
1020 REM SHOOT RIGHT
1025 PX=X:PY=Y:COLOR 36:PLOT X,Y
1028 FOR A=X+1 TO X+20
1030 LOCATE A,Y,CC:IF CC=170 THEN X=PX-1:Y=PY:RETURN
1040 COLOR 13:PLOT A,Y
1050 FOR S=1 TO 10:NEXT S
1060 COLOR 32:PLOT A,Y
1080 NEXT A
1090 RETURN
1100 REM SHOOT LEFT
1110 PX=X:PY=Y:COLOR 36:PLOT X,Y
1120 FOR A=X-1 TO X-20 STEP -1
1130 LOCATE A,Y,CC:IF CC=170 THEN X=PX+1:Y=PY:RETURN
1140 COLOR 13:PLOT A,Y
1150 FOR S=1 TO 10:NEXT S
1160 COLOR 32:PLOT A,Y
1170 NEXT A
1890 RETURN
1900 RESTORE 2000
1905 POSITION 0,0:GOTO 2000
1910 READ M$:IF M$=”{control-P}” THEN RETURN
1920 FOR X=1 TO 20
1930 REM
1940 G$=M$(X,X)
1948 IF G$=”{escape escape}” THEN Y=Y+1
1950 IF G$=”*” THEN COLOR 138:PLOT X-1,Y
1955 IF G$=”+” THEN COLOR 2:PLOT X-1,Y
1956 IF G$=”-” THEN COLOR 1:PLOT X-1,Y
1960 NEXT X
1970 NEXT A
1975 ? #6;”{clear}”
2000 ? #6;”{inverse}**** ***********”
2010 ? #6;”{inverse}* *”
2020 ? #6;”{inverse}* *”
2030 ? #6;”{inverse}**************** *”
2040 ? #6;”{inverse}* *”
2050 ? #6;”{inverse}* *”
2060 ? #6;”{inverse}* **************”
2070 ? #6;”{inverse}* *”
2080 ? #6;”{inverse}* *”
2090 ? #6;”{inverse}**************** *”
2100 ? #6;”{inverse}* * *”
2110 ? #6;”{inverse}* * *”
2120 ? #6;”{inverse}**************** *”
2130 ? #6;”{inverse}* * *”
2140 ? #6;”{inverse}* + * *”
2150 ? #6;”{inverse}* * *”
2160 ? #6;”{inverse}*** {ctrl-A}*********** *”
2170 ? #6;”{inverse}* {ctrl-A} “
2180 ? #6;”{inverse}* “
2190 ? #6;”{inverse}*******************”
2200 DATA **************** *{escape escape}
2210 DATA {ctrl-P}
2900 RETURN
2901 REM REDEFINE CHARS
2902 RESTORE 2904
2903 FOR I=1 TO 32:READ A:CH$(I)=CHR$(A):NEXT I
2904 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,4,160,0
2905 DATA 177,203,145,205,136,208,249,230,204,230,206,202,208,240,96
2906 POKE 106,PEEK(106)-5:GRAPHICS 0:BEGIN=(PEEK(106)+1)*256:POKE 756,BEGIN/256
2907 A=USR(ADR(CH$),57344,BEGIN)
2908 RESTORE 2915
2909 REM
2910 READ A:IF A=-1 THEN RETURN
2911 FOR I=0 TO 7
2912 READ B:POKE BEGIN+A*8+I,B
2913 NEXT I
2914 GOTO 2910
2915 DATA 1,129,129,255,129,129,255,129,129
2916 DATA 2,3,5,9,16,16,16,16,0
2917 DATA 3,3,6,6,7,6,14,17,0
2918 DATA 4,136,126,29,28,20,35,64,0
2919 DATA 5,24,56,120,8,8,8,0,0
2920 DATA 6,56,56,124,124,254,16,16,0
2921 DATA 7,36,36,24,24,36,36,4,0
2922 DATA 8,120,254,248,254,62,31,255,0
2923 DATA 9,63,255,248,126,154,240,63,0
2924 DATA 10,255,66,255,66,255,66,255,0
2925 DATA 11,192,96,96,224,96,112,136,0
2926 DATA -1
2930 IF RM=1 THEN M=17:GOSUB 1975
2940 IF RM=2 THEN X=1:GOSUB 2995
2990 RETURN
2995 ? #6;”{clear}”
3000 ? #6;”{inverse}**** ***********”
3010 ? #6;”{inverse}* *”
3020 ? #6;”{inverse}* *”
3030 ? #6;”{inverse}**************** *”
3040 ? #6;”{inverse}* *”
3050 ? #6;”{inverse}* *”
3060 ? #6;”{inverse}*******************”
3070 ? #6;”{inverse}* *”
3080 ? #6;”{inverse}* *”
3090 ? #6;”{inverse}**************** *”
3100 ? #6;”{inverse}* * *”
3110 ? #6;”{inverse}* * *”
3120 ? #6;”{inverse}********{ctrl-A}**********”
3130 ? #6;”{inverse}* *{ctrl-A)* * *”
3140 ? #6;”{inverse}* *{ctrl-A}* * *”
3150 ? #6;”{inverse}* *{ctrl-A}* * *”
3160 ? #6;”{inverse}********{ctrl-A}******* *”
3170 ? #6;”{inverse} {ctrl-A} *”
3180 ? #6;”{inverse} *”
3190 ? #6;”{inverse}*******************”
4010 RETURN
5000 FOR I=1 TO LEN(M$)
5010 G=ASC(M$(I,I))
5020 IF G=32 THEN I=I+1
5030 POKE TX+I,ASC(M$(IK,I))
5040 NEXT I
9000 RETURN
Atari Basic Scrolling
1 REM HORIZONTAL SCROLLING DEMO
2 REM By J.S. Masters
3 REM
10 GOSUB 1000
20 GOTO 20
999 REM *** Initialization
1000 GRAPHICS 8:POKE 559,0:POKE 16,0:POKE 53774,0:RAMTOP=PEEK(106):POKE 708,200:POKE 710,40
1009 REM *** Redefine Characters ***
1010 START=RAMTOP-8:CH=256*START:FOR I=CH TO CH+47:READ A:POKE I,A:NEXT I:POKE 756,START
1020 DATA 0,0,0,0,0,0,0,0,1,3,7,15,31,63,127,255,128,192,224,240,248,252,254,255,255,255,255,255,255,255,255,255
1030 DATA 0,16,56,124,84,84,130,254,16,16,56,56,84,170,84,170
1039 REM *** New Display List ***
1040 TEMP=RAMTOP-20:DM=256*TEMP:FOR I=1536 TO 1538:POKE I,112:NEXT I
1050 FOR I=1539 TO 1572 STEP 3:POKE I,87:POKE I+1,0:POKE I+2,TEMP:TEMP=TEMP+1:NEXT I
1060 POKE 1575,65:POKE 1576,0:POKE 1577,6:POKE 560,0:POKE 561,6
1069 REM *** P-M Graphics
1070 POKE 54279,START:PM=256*START+1024:FOR I=PM+70 TO PM+76:READ A:POKE I,A:NEXT I
1080 POKE 53256,0:POKE 704,56:POKE 53248,90:POKE 623,4:POKE 559,58:POKE 53277,2
1090 DATA 224,124,254,255,254,124,224
1099 REM *** Draw Display ***
1100 BOTTOM=DM+2816:FOR X=0 TO 255:SOUND 0,X,10,8:READ Y,CHAR:OFFSET=DM+256*Y+X:POKE OFFSET,CHAR
1110 FOR I=OFFSET+256 TO BOTTOM+X STEP 256:POKE I,3:NEXT I:NEXT X:SOUND 0,0,0,0
1120 DATA 9,132,9,1,8,1,7,133,8,2,8,1,7,1,6,1,6,2,6,197,7,132,8,196,8,1,7,1,7,2,7,1,6,1,5,197,6,2,7,2
1130 DATA 8,2,9,2,9,133,9,1,8,1,8,2,9,2,9,1,8,1,7,132,7,1,7,2,7,1,6,1,5,133,5,1,4,1,4,2,5,2,5,1
1140 DATA 4,1,3,1,2,1,2,2,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,197,4,196,5,2,6,2,6,132,6,1,6,2,6,1,5,197
1150 DATA 5,1,4,133,4,1,4,2,4,1,4,2,5,2,6,2,7,2,8,2,9,2,9,196,9,1,9,2,9,196,10,2,10,1,9,1,8,1,7,1
1160 DATA 7,2,8,2,8,1,7,1,6,1,5,1,5,2,6,2,6,1,6,2,6,1,5,197,5,1,4,196,4,1,4,2,4,197,5,2,6,2,6,1,5,1
1170 DATA 4,1,3,1,3,2,3,1,2,1,2,2,2,1,2,2,3,2,3,1,3,2,4,2,5,2,6,2,6,133,6,1,6,2,6,1,6,2,7,2
1180 DATA 8,2,8,132,9,2,9,1,9,2,9,1,9,2,9,1,8,1,7,1,6,196,7,2,7,133,7,1,6,1,5,1,4,1,3,1,2,1,1,1
1190 DATA 1,2,2,2,3,2,4,2,4,196,5,2,5,132,6,2,7,2,8,2,9,2,9,1,9,2,10,2,10,1,10,2,10,1,9,133,9,1,9,2
1200 DATA 10,2,10,197,10,1,9,1,8,1,7,1,6,132,6,1,5,197,5,1,4,1,3,1,2,1,2,2,3,2,4,2,5,2,6,2,7,2,7,1
1210 DATA 6,1,5,1,4,1,4,2,5,2,6,2,7,2,8,2,9,2,10,2,10,1,10,2,10,1,9,1,8,1,8,2,8,197,8,1,7,1,6,1
1220 DATA 5,1,5,2,6,2,6,1,5,1,5,2,6,2,7,2,8,2,8,1,7,1,6,1,6,2,7,2,7,196,8,2,9,2,9,196,9,132,9,1
1230 DATA 8,1,7,1,7,2,8,2,8,1,7,1,6,1,5,1,5,2,6,2,7,2,8,2,9,2,9,132,9,1,8,1,7,133,8,2
1240 DATA 8,1,7,1,6,1,6,2,6,197,7,132,8,196,8,1,7,1,7,2,7,1,6,1,5,197,6,2,7,2,8,2,9,2
1249 REM ** VBI Routine ***
1250 FOR I=1578 TO 1637:READ A:POKE I,A:NEXT I:X=USR(1578)
1260 DATA 104,169,0,133,204,141,4,212,160,59,162,6,169,7,76,92
1270 DATA 228,198,203,165,203,141,4,212,16,31,169,7,133,203
1280 DATA 141,4,212,238,4,6,173,4,6,201,234,208,2,169,0,162
1290 DATA 0,157,4,6,232,232,232,224,39,208,246,76,98,228
1295 RETURN
1300 REM ML TAKE APART
1310 PLA
1320 LDA #0
1330 STA 204
1340 STA 54276
1350 LDY #59
1360 LDX #6
1370 LDA #7
1380 JMP 58460
1390 DEC 203
1400 LDA 203
1410 STA 54276
1420 BPL 31
1430 LDA #7
1440 STA 203
1450 STA 54276
1460 INC 1540
1500 LDA 1540
1510 CMP #234
1520 BNE 2
1530 LDA #0
1540 LDX #0
1550 STA 1540,X
1560 INX
1570 INX
1580 INX
1590 CPX #39
1600 REM BNE 246
1610 JMP 58466