Program the Bouncing Ball, player missile graphics tutorial (EXAMPLE8.BAS)
Program the Bouncing Ball, player missile graphics tutorial by David Fox and Mitchell Waite, 38
Description
Program the Bouncing Ball, player missile graphics tutorial by David Fox and Mitchell Waite, 38
From the Antic disk of October 1984 (Vol. 3 No. 6).
From the Antic Software Archive at atarimagazines.com. The program remains the property of its author and publisher.
What is in this file
Atari BASIC program · 3.8 KB
- Dialect
- Atari BASIC
- Lines
- 106
- Variables
PLR0$,HIBYTE,X,LOBYTE,BLANK$,PLR(,HPLR(,VEL,ELASTIC,BOTTOM,XPOS,TIME,HORIZ,SNDFLAG,YPOS,FRMNO,FRAME$,FRAMEMEM$,FRMSIZE,BUFFER$,FRAMES,NUMPLRS,PLRFRMMEM,FRAMEMEM,TEMP,PMBASE,I,STARP,VVTP,OFFSET,J,BYTE
BASIC listing (106 lines)
10 REM *** BOUNCING BALL 1 PROGRAM ***
20 REM Example 8
30 REM
40 REM Program to demonstrate Player-Missile Graphics using string manipulation
50 REM Copyright (C) 1982 by David Fox and Mitchell Waite
60 REM
70 DIM PLR0$(128):GOTO 140:REM This MUST be the first variable in the program
80 REM
100 REM Hi/Lo Byte Calculation
110 HIBYTE=INT(X/256):REM Calculate High Byte
120 LOBYTE=X-HIBYTE*256:REM Calculate Low Byte
130 RETURN
140 REM Initialize
150 DIM BLANK$(128),PLR(3),HPLR(3)
160 BLANK$(1)=CHR$(0):BLANK$(128)=CHR$(0):BLANK$(2)=BLANK$:REM Fill with blanks
170 GRAPHICS 3:POKE 752,1:PRINT "One moment please...":REM Turn off cursor, print message
190 GOSUB 5000:REM Set up memory locations
220 GOSUB 7000:REM Set up Player area
230 GOSUB 9000:REM Point PLR0$ to Player 0 RAM
240 GOSUB 10000:REM Read frames into RAM
295 REM ┼
300 ? "↰ *** BOUNCING BALL DEMO ***"
305 REM ┼
310 VEL=70:ELASTIC=0.8
320 PRINT "Initial velocity: ";VEL:PRINT "Elasticity: ";ELASTIC;
330 REM
400 REM Main Animation Loop
410 BOTTOM=91:XPOS=40:TIME=0.5:HORIZ=0.75
420 GOSUB 700:REM Move Player off screen
430 IF ELASTIC<=0.1 THEN SNDFLAG=1
440 YPOS=BOTTOM-(VEL*TIME-16*TIME*TIME):FRMNO=1
450 IF YPOS>82 AND VEL>30 THEN FRMNO=2
460 IF YPOS>=BOTTOM THEN YPOS=BOTTOM:VEL=VEL*ELASTIC:TIME=0:FRMNO=1:IF VEL>14 THEN FRMNO=3
470 IF XPOS>220 OR YPOS<=1 THEN 600
480 POKE HPLR(0),XPOS
490 FRAME$=FRAMEMEM$((FRMNO-1)*FRMSIZE+1,FRMNO*FRMSIZE):REM Select correct frame
500 BUFFER$=BLANK$:REM Fill Buffer with blanks
510 BUFFER$(YPOS,YPOS+FRMSIZE-1)=FRAME$:REM Move current frame into buffer
520 PLR0$=BUFFER$:REM Move buffer into Player 0 RAM
530 XPOS=XPOS+HORIZ
540 IF YPOS=BOTTOM AND (VEL+SNDFLAG>0.5) THEN SOUND 1,250,10,14:SNDFLAG=0:SOUND 1,0,0,0
550 IF VEL>0.5 THEN TIME=TIME+0.15:GOTO 440
560 HORIZ=HORIZ-0.01:IF HORIZ>0 THEN FRMNO=1:GOTO 470
570 REM
600 REM Get Parameters for Ball
610 GOSUB 700
620 POKE 752,0:REM Turn on cursor
630 PRINT "↰Enter initial velocity: ";
640 TRAP 630:INPUT VEL
650 PRINT "Enter the ball's elasticity (a number":PRINT " from 0-1 [or more]): ";
660 INPUT ELASTIC
670 POKE 752,1:PRINT " ";:REM Turn off cursor
680 TRAP 40000:GOTO 400
690 REM
700 REM Move Player 0 to Left of Screen
710 POKE HPLR(0),0
730 RETURN
740 REM
5000 REM Set Up Memory Locations
5100 READ FRAMES,FRMSIZE,NUMPLRS
5120 PLRFRMMEM=FRAMES*FRMSIZE
5130 FRAMEMEM=PLRFRMMEM*NUMPLRS
5170 DIM BUFFER$(128),FRAME$(FRMSIZE),FRAMEMEM$(FRAMEMEM)
5360 RETURN
5370 REM
7000 REM Initialize Player-Missile Graphics
7010 TEMP=PEEK(106)-8:REM Set aside Player-Missile area
7020 POKE 54279,TEMP:REM Tell ANTIC where PM RAM is
7030 PMBASE=256*TEMP:REM Find PM Base address
7040 FOR I=0 TO 3
7050 PLR(I)=PMBASE+128*I+512:REM Set addresses of Players
7060 HPLR(I)=53248+I:REM Horizontal Player Position registers
7070 NEXT I
7080 POKE 559,42:REM Set PM 2 line resolution, Players enabled
7090 POKE 704,12*16+8:REM Color ball green
7100 POKE 53277,2:REM Enable Player display
7120 RETURN
7130 REM
9000 REM Point PLR0$ to Player 0 RAM
9010 STARP=PEEK(140)+PEEK(141)*256:REM Start of String Array area
9020 VVTP=PEEK(134)+PEEK(135)*256:REM Start of Variable Value Table
9030 OFFSET=PLR(0)-STARP:REM Calculate offset from String Array to Player 0
9040 X=OFFSET:GOSUB 110
9050 POKE VVTP+2,LOBYTE:REM Poke offset of string into Variable Value Table
9060 POKE VVTP+3,HIBYTE:REM This points the first string (PLR0$) to PLR(0)
9070 RETURN
9080 REM
10000 REM Read in Frame Data
10090 FOR J=1 TO PLRFRMMEM
10100 READ BYTE
10110 FRAMEMEM$(J,J)=CHR$(BYTE)
10120 NEXT J
10130 RETURN
10140 REM
20000 REM FRAME DATA
20030 REM
20040 REM Number of Frames, Frame Size, Number of Players
20050 REM . (Bouncing Ball)
20060 DATA 3,7,1
21000 REM Frame Data for Bouncing Ball
21010 REM Frame 1
21020 DATA 0,60,126,126,126,60,0
21030 REM Frame 2
21040 DATA 24,60,60,60,60,60,24
21050 REM Frame 3
21060 DATA 0,0,0,126,255,126,0
