BASIC Boink
- Type
- Demo
- Category
- Player-missile and DLI demo
- Author
- Larry Nocella
- Published in
- Antic, February 1988 (Vol. 6, No. 10), Tech Tips
- Year
- 1988
- Language
- Atari BASIC (with a machine-language DLI in DATA)
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC
About the program
"Boink" demos, with a ball or an Atari Fuji logo bouncing about the screen, were a favourite way of showing off a computer's graphics in the 1980s. Larry Nocella, of the Jersey Atari Computer Society, wrote this one for Antic's Tech Tips page. A row of six Fuji logos goes back and forth on each half of the screen, each in its own colour and moving on its own, with a "boink" when some of them turn. That's twelve moving objects on a machine with only four players, and all from a 56-line BASIC program.
Typing it in
It's all plain text. The machine-language part is the 104 numbers in DATA lines 470–500, which are POKEd into page 6. A wrong number there will crash the machine rather than give an error, so SAVE before you RUN and check the DATA twice. Lines 520–530 are the left and right halves of the Fuji shape.
How to use it
RUN it and watch. The program clears player-missile memory slowly in BASIC first, so give it a few seconds before anything appears. Nocella suggested pressing BREAK while it runs. BASIC stops, but the interrupt routine keeps going. The Fujis are no longer turned round at the edges, so they slide across the whole screen forever, even while you LIST or type. Press RESET to stop them.
How it works
- Two players per Fuji. Each logo is 16 pixels wide, made of player 0 plus player 1 (the left and right halves from lines 520 and 530) side by side. A second Fuji is made from players 2 and 3. Lines 140–210 copy the shape into player memory six times, 15 scan lines apart.
- The display list interrupt. Line 250 sets the DLI bit (adding 128 to mode 2, which gives 130) on six lines of the GRAPHICS 0 display list. Line 340 points the DLI vector (512–513) at page 6, and
POKE 54286,192switches DLIs on. Each time the TV beam reaches one of those lines, the routine at 1536 runs. It sets the player colour registers (53266–53269) for that band, using two colours from a table plus each colour +6 for the second half of each logo, moves its X position one step left or right according to a direction flag, and writes the positions into the horizontal-position registers (53248–53251). So each band of the screen gets its own Fujis with their own colour, position and direction. The positions are kept in page 6 from 1678 and 1708, the direction flags from 1671 and 1701, and the colours from 1665 and 1694. - BASIC as referee. The interrupt only moves the Fujis. The BASIC loop at 390–450 PEEKs each position and flips the direction byte when a Fuji passes its limits (
LMAX/RMAX), playing a sound with GOSUB 34 or 36. BASIC is much slower than the interrupt, so the Fujis turn round at slightly different moments each time, and the pattern keeps changing. Nocella pointed out that he could have put the limits in the DLI, but then the pattern would never vary.
Variations to try
- Change the colours in DATA line 290 (pairs of values for the left and right sets).
- Widen or narrow the bounce limits in lines 70–80.
- Change the Fuji shape in lines 520–530 to any 8×8 design for each half.
Listing
10 REM BASIC BOINK
20 REM BY LARRY NOCELLA
30 REM (c)1987, ANTIC PUBLISHING
32 GOTO 40
34 FOR S=80 TO 0 STEP -10:SOUND 0,S,10,10:NEXT S:RETURN
36 FOR S=45 TO 0 STEP -5:SOUND 0,S,10,10:NEXT S:RETURN
40 KEEP=PEEK(106)-16:POKE 54279,KEEP:GRAPHICS 0:POKE 752,1
50 POKE 710,0:POKE 559,46:POKE 53277,3:ST=24:EN=109:IC=15:ZXOK=PEEK(559)
60 POKE 559,0:POKE 623,1
70 LMAX1=120:RMAX1=180
80 LMAX2=54:RMAX2=114
90 POSITION 0,1:? "BASIC BOINK BY LARRY NOCELLA"
100 REM CLEAR P/M AREA
110 PMB=KEEP*256:POKE 712,6
120 FOR LOOP=PMB+512 TO PMB+1024:POKE LOOP,0:NEXT LOOP
130 REM PLAYERS
140 FOR LOOP=ST TO EN STEP IC
150 RESTORE 520:FOR ZX=1 TO 8:READ A
160 POKE PMB+512+LOOP+ZX,A
170 POKE PMB+768+LOOP+ZX,A:NEXT ZX
180 RESTORE 530:FOR ZX=1 TO 8:READ A
190 POKE PMB+640+LOOP+ZX,A
200 POKE PMB+896+LOOP+ZX,A:NEXT ZX
210 NEXT LOOP:POKE 712,4
220 REM DLI
230 RESTORE 470:FOR I=1 TO 104:READ Z:POKE 1535+I,Z:NEXT I
240 START=PEEK(560)+PEEK(561)*256
250 POKE START+6,130:POKE START+9,130:POKE START+12,130:POKE START+16,130:POKE START+20,130
260 POKE START+24,130:POKE 1664,0
270 REM COLORS
280 RESTORE 290:FOR I=0 TO 5:READ Q,Z:POKE 1665+I,Q:POKE 1694+I,Z:NEXT I
290 DATA 8,100,68,214,54,114,166,24,88,194,228,146
300 REM X-COORDINATE
310 FOR I=0 TO 5:POKE 1678+I,160:POKE 1708+I,80:NEXT I
320 REM DIRECTION (1=L 0=R)
330 FOR I=0 TO 5:POKE 1671+I,0:POKE 1701+I,1:NEXT I
340 POKE 512,0:POKE 513,6
350 POKE 54286,192:POKE 712,2
360 FOR I=0 TO 5:Q1=INT(RND(1)*40):Q2=INT(RND(1)*40)
370 POKE 1678+I,PEEK(1678+I)+Q1:POKE 1708+I,PEEK(1708+I)+Q2:NEXT I:POKE 559,ZXOK
380 REM BOINK
390 FOR I=0 TO 5:ZX=PEEK(1678+I)
400 NX=PEEK(1708+I)
410 IF ZX<LMAX1 THEN POKE 1671+I,0:GOTO 430
420 IF ZX>RMAX1 THEN POKE 1671+I,1:GOSUB 36
430 IF NX<LMAX2 THEN POKE 1701+I,0:GOSUB 34:GOTO 450
440 IF NX>RMAX2 THEN POKE 1701+I,1
450 NEXT I:GOTO 390
460 REM ML COLORER/MOVER
470 DATA 72,138,72,152,72,174,128,6,189,129,6,141,18,208,24,216,105,6,141,19,208,189,158,6,141,20,208,24
480 DATA 216,105,6,141,21,208,189,135,6,240,6,222,142,6,184,80,3,254,142,6,189,142,6,141,0,208,216,24
490 DATA 105,8,141,1,208,189,165,6,240,6,222,172,6,184,80,3,254,172,6,189,172,6,141,2,208,24,216,105
500 DATA 8,141,3,208,232,224,6,208,2,162,0,142,128,6,104,168,104,170,104,64
510 REM PLAYER DATA (L/R)
520 DATA 13,13,13,13,13,29,57,113
530 DATA 176,176,176,176,176,184,156,142
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: BOINK.BAS.
Credits
- Program listing: BASIC Boink — program listing (Antic, February 1988 (Vol. 6, No. 10), Tech Tips) — Larry Nocella
- Picture: Twelve Fujis from four players: a display list interrupt recolours and repositions them for each band of the screen. — Larry Nocella (program); screenshot by the site
- Antic, February 1988 - Vol. 6 No. 10 — article: graphics demo by Larry Nocella — Larry Nocella, 1988
- Antic Software Archive — February 1988 - Vol. 6 No. 10 disk: BOINK.BAS — AtariMagazines.com (Kevin Savetz), 1988
