Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Integer BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Sample code== The following is a version of Breakout written in the 1977 version of Integer BASIC for the Apple II, which was listed in the Apple II Mini Manual.{{sfn|Mini|1977|pp=65-67}} There are a number of known bugs in this version.<ref name="breakout">{{cite web|title=Breakout, Annotated|url=https://github.com/cmosher01/Apple-II-Source/blob/master/docs/breakout.md|website=GitHub|date=16 August 2021}}</ref> The program starts by setting the display to {{code|TEXT}} and then {{code|CALL -936}} to clear the screen. Lines 20 through 27, and the associated subroutines at line 100 and 200, are the color selection code Wozniak demonstrated for Jobs. Line 30 sets up the text window with {{code|POKE 32,20}}{{efn|Meaning the text starts at line 20 of 24 lines on the screen, leaving four lines of text at the bottom.}} and then uses a series of {{code|COLOR}} and {{code|VLIN}} statements to draw the playfield and the score display in the text window. The entire main loop runs from line 40 through 90 with associated subroutines. Another large amount of code near the end of the program is concerned with printing the final score. Other notes of interest include the {{code|#}} (not-equal) comparisons on line 20, the production of a high-pitch sound using a string of {{code|PEEK}}s on line 65 compared to a lower-pitched tone using a loop on line 70, and the mix of graphics and text on a single display.{{efn|For a list of the various CALLs, PEEKs and POKEs that performed common operations on the Apple II, see [https://mirrors.apple2.org.za/ground.icaen.uiowa.edu/Collections/1WSW/MEGA.PEEKS.AND.POKES.html Peeks, Pokes, Calls And Programming Notes], Charles Turley, 15 December 1996.}} <syntaxhighlight lang="bbcbasic"> 5 TEXT: CALL -936: VTAB 4: TAB 10: PRINT "*** BREAKOUT GAME ***": PRINT 7 PRINT " OBJECT IS TO DESTROY ALL BRICKS WITH 5 BALLS": FOR N=1 TO 7000: NEXT N 10 DIM A$(20),B$(20): GR: PRINT: INPUT "HI, WHAT'S YOUR NAME? ",A$:A=1:B=13:C=9:D=6:E=15: PRINT "STANDARD COLORS,"; A$; 20 INPUT "? ",B$: IF B$#"N" AND B$#"NO" THEN 30: FOR I=0 TO 39: COLOR=I/2*(I<32): VLIN 0,39 AT I 25 NEXT I: POKE 34,20: PRINT: PRINT: PRINT: FOR I=0 TO 15: VTAB 21+I MOD 2: TAB I+I+1: PRINT I;: NEXT I: POKE 34,22: VTAB 24: PRINT: PRINT "BACKGROUND"; 27 GOSUB 100: A=E: PRINT "EVEN BRICK";: GOSUB 100: B=E: PRINT "ODD BRICK";: GOSUB 100: C=E: PRINT "PADDLE";: GOSUB 100: D=E : PRINT "BALL";: GOSUB 100 30 POKE34,20:COLOR=A:FORI=0TO39:VLIN0,39ATI:NEXTI:FOR I=20TO34STEP2:TAB I+1:PRINT I/2-9;:COLOR=B:VLIN 0,39 AT I:COLOR=C:FOR J=I MOD 4 TO 39 STEP4 35 VLIN J,J+1 AT I: NEXT J,I: TAB 5: PRINT "SCORE = 0": PRINT: PRINT: POKE 34,21: S=0: P=S: L=S: X=19: Y=19: X=19 40 COLOR=A:PLOTX,Y/3:X=19:Y=RND(120):V=-1:W=RND(5)-2:L=L+1:IFL>5THEN140:TAB6:PRINT"BALL #";L:PRINT:FORI=1TO100:GOSUB200:NEXTI:M=1:N=0 50 J=Y+W: IF J>=0 AND J<120 THEN 60: W=-W: J=Y: FOR I=1 TO 6: K=PEEK(-16336): NEXT I 55 IF PEEK(-16287)>127 THEN SW=1-SW 60 I=X+V: IF I<0 THEN 400: GOSUB 200: COLOR=A: K=J/3: IF I>39 THEN 70: IF SCRN(I,K)=A THEN 90: IF I THEN 120: N=N+1: V=(N>9)+1: W=(K-P)*2-5:M=1 65 Z = PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336): GOTO 90 70 FOR I=1 TO 6: M=PEEK(-16336): NEXT I: I=X: M=0 80 V=-V 90 PLOT X,Y/3: COLOR=E: PLOT I,K: X=I: Y=J: GOTO 50 99 PRINT "INVALID. REENTER"; 100 INPUT " COLOR (0 TO 15)",E: IF E<0 OR E>15 THEN 99: RETURN 120 IF M THEN V=ABS(V): VLIN K/2*2,K/2*2+1 AT I: S=S+I/2-9: VTAB 21: TAB 13: PRINT S 123 Q = PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336) 124 IF S<720 THEN 80 130 PRINT "CONGRATULATIONS, YOU WIN.": GOTO 150 140 PRINT "YOUR SCORE OF ";S;" IS ";: GOTO 141+S/100 141 PRINT "TERRIBLE!": GOTO 150 142 PRINT "LOUSY.": GOTO 150 143 PRINT "POOR.": GOTO 150 144 PRINT "FAIR.": GOTO 150 145 PRINT "GOOD.": GOTO 150 146 PRINT "VERY GOOD.": GOTO 150 147 PRINT "EXCELLENT.": GOTO 150 148 PRINT "NEARLY PERFECT." 150 PRINT "SAME COLORS";: GOTO 20 200 IF SW THEN 220: Q=(PDL(0)-5)/6: IF Q<0 THEN Q=0 205 IF Q>=34 THEN Q=34: COLOR=D: VLIN Q,Q+5 AT 0: COLOR=A: IF P>Q THEN 210: IF Q THEN VLIN 0,Q-1 AT 0: P=Q: RETURN 210 IF P=Q THEN RETURN: IF Q#34 THEN VLIN Q+6,39 AT 0: P=Q: RETURN 220 Q=(Y-5)/3+RND(3)*SGN(W)*(X<10 AND V<0): IF Q<0 THEN Q=0: GOTO 205 400 FOR I=1 TO 80: Q=PEEK(-16336): NEXT I: GOTO 40 </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)