Player Priority Stripes
- Type
- Graphics
- Category
- Player/missile priority demo
- Author
- David Small, Sandy Small and George Blank (editors)
- Published in
- The Creative Atari (Creative Computing Press, 1983), "Player-Missile Graphics", Program 19
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC
About the program
The Creative Atari (Creative Computing Press, 1983) gathered the Atari material from Creative Computing magazine, much of it by the book's editors David and Sandy Small and George Blank, together with new chapters. Its graphics tutorial works step by step from the TV picture up to player/missile graphics and character sets, with a short program at each step. In the player/missile chapter, the first programs leave out PM DMA altogether. They POKE a byte straight into a player's graphics register, and the player then appears as a stripe running the full height of the screen. Program 19 uses four such stripes to demonstrate priority: which of the players and the playfield shows in front when they overlap. It is a quick and colourful way to learn the priority table, and you don't need to set up any player memory.
What you need
Any Atari 8-bit with Atari BASIC. Run it from a screen with some text on it, such as the program listing, so that there is playfield for the players to pass over.
Typing it in
Plain ASCII, 30 lines. The REMs after each POKE name the colours: grey (4), orange (58), purple (90) and green (196).
How to use it
RUN it. Four coloured stripes slide across the screen, two left-to-right and two right-to-left. The screen shows the current priority code (1–15). Watch how the overlaps change: sometimes one player covers another, sometimes the text appears in front, and with some codes the overlap turns black. Press BREAK to stop. The stripes stay on screen until you press RESET, because nothing clears the graphics registers.
How it works
- 53261–53264 are GRAFP0–GRAFP3, the players' graphics data registers. With player DMA switched off, whatever byte you POKE there is drawn on every scan line, so 255 gives an 8-pixel-wide solid stripe.
- 704–707 are the OS shadows of the player colours, and 53248–53251 the horizontal positions (HPOSP0–3). Lines 230–290 move all four stripes at once.
- 623 is GPRIOR, the shadow of GTIA's PRIOR register. The four low bits choose the priority order. 1 puts all players in front of the playfield, 2 puts players 0–1 in front and players 2–3 behind, 4 puts the playfield in front of all players, and 8 puts playfields 0 and 1 in front of all players, with all players in front of playfields 2 and 3. The book warns that combining these values gives "odd" results with black overlaps, and this loop shows them all. Adding 16 makes the four missiles a fifth player, and adding 32 mixes colours where players overlap.
Variations to try
- Change line 200 to
FOR X=1 TO 8and step through only the four "legal" values by POKEing 1, 2, 4 and 8. - Add 32 to
Xin line 210 to see the overlap-colour mode. - Slow down the delay loop in line 280 to study each overlap.
Listing
20 REM DEMONSTRATES PRIORITY
30 POKE 623,2:REM P0 HIGHEST
40 REM POKE A 2 TO HAVE PLAYERS 2,3
50 REM HAVE LOWER PRIORITY THAN PLAYER 1
60 POKE 704,4:REM COLOR P0 GREY-LO
70 POKE 705,58:REM COLOR P1 ORANGE HI
80 POKE 706,90:REM COLOR P2 PURPLE-HI
90 POKE 707,196:REM COLOR P3 GREEN-LO
100 REM
110 POKE 53261,255:REM BITS P0
120 POKE 53262,255:REM BITS P1
130 POKE 53263,255:REM BITS P2
140 POKE 53264,255:REM BITS P3
150 PRINT "PLAYER 0 = GREY"
160 PRINT "PLAYER 1 = ORANGE"
170 PRINT "PLAYER 2 = PURPLE"
180 PRINT "PLAYER 3 = GREEN"
190 REM CYCLE THROUGH PRIORITIES
200 FOR X=1 TO 15
210 POKE 623,X
220 PRINT "PRIORITY CODE =";X
230 FOR T=36 TO 218 STEP 3
240 POKE 53248,20+T:REM PLAYER 0
250 POKE 53249,T:REM PLAYER 1
260 POKE 53250,218-T:REM PLAYER 2
270 POKE 53251,239-T:REM PLAYER 3
280 FOR Z=1 TO 15:NEXT Z
290 NEXT T
300 NEXT X
310 GOTO 200
Credits
- Program listing: Player Priority Stripes — program listing (The Creative Atari (Creative Computing Press, 1983), "Player-Missile Graphics", Program 19) — David Small, Sandy Small and George Blank (editors)
- Picture: Player stripes passing over and under the playfield as the priority code changes. — David Small, Sandy Small and George Blank (editors) (program); screenshot by the site
- The Creative Atari — Player-Missile Graphics (atariarchives.org) — David Small, Sandy Small and George Blank (editors)
