Fine Scrolling Demo (De Re Atari)
- Type
- Demo
- Category
- Hardware scrolling demonstration
- Author
- Chris Crawford (Section 6 of De Re Atari)
- Published in
- De Re Atari: A Guide to Effective Programming (Atari Program Exchange, APX-90008, 1982), Section 6, "Scrolling"
- Year
- 1982
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC
About the program
De Re Atari ("All About Atari") was written by Atari's Software Development Support Group as a training manual for professional programmers. Early versions went to registered developers in 1981, and the 1982 edition was sold through the Atari Program Exchange as APX-90008. Its scrolling chapter, by Chris Crawford, explains that coarse scrolling moves the display a whole character at a time by changing the address in a display-list LMS instruction. Fine scrolling moves it by single scan lines or colour clocks through two ANTIC registers. This little program shows the fine part on its own, very slowly, so that you can watch exactly what happens.
What you need
Any Atari 8-bit with Atari BASIC.
Typing it in
Plain ASCII, 17 lines. The REM comments can go. Line 10 deliberately LISTs the program, so that there is some text on screen to scroll.
How to use it
RUN it. The program lists itself, and then two lines near the top of the screen start to creep up and sideways, one step at a time, again and again. Press BREAK to stop, and type GRAPHICS 0 to restore the screen.
The text explains the oddities you'll see. The lines below the scrolled area are pushed to the right, because a horizontally scrolled line makes ANTIC fetch 48 bytes instead of 40. The scroll also snaps back each time round, because the program never does the matching coarse scroll. In a real program the screen data is laid out so that both problems disappear.
How it works
- Line 20 finds the display list through SDLSTL/SDLSTH (560/561).
- Lines 30 and 40 change two mode-2 (text) instructions to 50. That is 2 + 16 (horizontal scroll enable) + 32 (vertical scroll enable).
- HSCROL (54276) and VSCROL (54277) then shift those lines. Lines 50–80 step the vertical scroll through 0–7 scan lines, the height of a text row. Lines 90–120 step the horizontal scroll through 0–3 colour clocks.
- Fine scrolling covers at most 16 scan lines or 16 colour clocks. To scroll further, you reset the fine scroll register and move the LMS address one character (a coarse scroll).
Variations to try
- Shorten the delay in line 200 to see how smooth the movement becomes.
- Extend the X loop to
FOR X=0 TO 15to see the full horizontal range. - Add a coarse scroll: when Y wraps back to 0, add 40 to the LMS address bytes (
DLIST+4/DLIST+5).
Listing
1 HSCROL=54276
2 VSCROL=54277
10 GRAPHICS 0:LIST
20 DLIST=PEEK(560)+256*PEEK(561)
30 POKE DLIST+10,50:REM Enable both scrolls
40 POKE DLIST+11,50:REM Do it for two mode lines
50 FOR Y=0 TO 7
60 POKE VSCROL,Y:REM Vertical scroll
70 GOSUB 200:REM Delay
80 NEXT Y
90 FOR X=0 TO 3
100 POKE HSCROL,X:REM Horizontal scroll
110 GOSUB 200:REM Delay
120 NEXT X
130 GOTO 40
200 FOR J=1 TO 200
210 NEXT J:RETURN
Credits
- Program listing: Fine Scrolling Demo (De Re Atari) — program listing (De Re Atari: A Guide to Effective Programming (Atari Program Exchange, APX-90008, 1982), Section 6, "Scrolling") — Chris Crawford (Section 6 of De Re Atari)
- Picture: Mid-scroll: the lines below the scrolled pair are pushed right, the side effect the book describes. — Chris Crawford (Section 6 of De Re Atari) (program); screenshot by the site
- De Re Atari — Section 6: Scrolling (atariarchives.org) — Chris Crawford (Section 6 of De Re Atari)
- De Re Atari — preface (section authors) — AtariArchives.org
- comp.sys.atari.8bit FAQ (De Re Atari editions: C060070 1981 developer versions, APX-90008 1982) — Michael Current (comp.sys.atari.8bit FAQ), 1981
