Animation with page flipping
The designers of the Atari range have given us a
very flexible system. Graphics enthusiasts are particularly well
catered for, and if there is one way that computer graphics are an
improvement over pencil and paper it is in the ability to create a
There are several ways in which it is possible to
create movement, or at least the illusion of movement, with the
Atari. One method is page flipping. Put simply, page flipping
consists of drawing all your graphics screens in memory during
initialisation and then showing these screens one after another. Any
one of the screens can be displayed, and because it is already in
existence in memory there is absolutely no delay between pictures as
there would be if the screen had to be drawn each time.
Page flipping is possible because the Atari has
two pointers to screen memory. One of these pointers tells the Atari
to take its display information from a particular section of memory.
This is the pointer to 'read memory'. The other pointer tells the
Atari which area of memory is to be written to if anything is typed,
or a PLOT or DRAWTO command is issued. This is the pointer to 'write
memory'. Normally both of these pointers direct the Atari to the
same area of memory, so that whatever is written is simultaneously
displayed. It is possible however to change both of these pointers
from BASIC, so all that is necessary when setting up page flipping
is to set the pointer to 'write memory' so that each screen is drawn
in a selected area of memory.
When each screen is complete, reset the pointer to
another area of memory and draw the next screen. Carry on with this
until you have all your screens stored, then by setting the pointer
to 'read memory' with the same value that was used when one of the
previously saved screens was drawn, that screen will be instantly
displayed. So you can see, in this way it is possible to store a
series of screens, just like a series of frames in a film and by
displaying them in sequence, full screen animation can be achieved.
THREE BASIC STEPS
There are three basic steps to implementing page
1. Ensure that the screens are positioned in
memory so that they will not be overwritten by the program. Firstly
reserve an area of memory. To do this first find the top of
available memory by peeking location 106. Then POKE 106 with a value
lower than the initial value which fools the system into thinking
that the top of free memory is lower than it actually is. The
screens can be safely stored above this location. The amount of
memory which needs to be reserved depends on the number of screens
you wish to store and the graphics mode (see Table 1). The
higher resolution modes use a lot more memory for the screen
As an example the statement RAMTOP =
PEEK(106):POKE 106,RAMTOP-4 will reserve four 256 byte pages(1K) of
memory which is sufficient for one Graphics 0 screen.
2. Change the address of 'write memory' before the
screen is drawn. The pointer is contained in memory locations 88 and
89, usually it is only necessary to change the value in location 89.
If you have poked location 106 with RAMTOP-4 as in step 1, then the
command POKE 89,RAMTOP-4 will store the screen in that reserved area
3. Having stored a screen, to display it just
change the pointer to 'read memory'. This pointer is contained in
the fourth and fifth bytes of the display list. First find the start
of the display list with the statement DL = PEEK(560) +
256*PEEK(561). Then DL + 4 and DL + 5 will contain the pointer. You
will only usually need to alter the value in DL + 5. All that is now
needed is to poke DL + 5 with the same value that was poked into
location 89 when the screen was drawn, and the screen will appear.
In this case this is done with the command POKE DL + 5, RAMTOP - 4.
|0 and 1
|2 and 3
|8 to 11
The number of
screens which can be stored depends on the amount of RAM and
the length of the program but the maximum available with 32271
bytes of free RAM is shown in the table.
BRING ON BERT!
Now that I have described the general principle of
page flipping, I think it might be useful to see how it works in
Program 1 demonstrates animation by page flipping.
There are a total of eight screens which are displayed in a random
sequence. Because of the memory requirements of the higher
resolution modes the screens in this program are drawn using a
redefined character set in Antic mode 4, which gives the same
resolution as Graphics 7 but uses much less memory. In Graphics 7 it
is only possible to have a maximum of four screens, whereas with
Antic 4, which is essentially the same in terms of memory
requirement as Graphics 0, it is possible to have thirty-one screens
should you require them.
When the program is run it will prompt you to put
a cassette containing music into your Atari program recorder and
press PLAY. When initialisation is completed the music will play
through the television speaker, causing the screens which were
previously stored to flip, thus animating the picture. I have not
blanked out the screen during initialisation so that you can see
each screen as it is drawn. Initially you will only see the blocks
of characters which will be redefined later by the routine which
starts at line 335. The final screen is displayed while the
character set is redefined.
Before each screen is drawn the program GOSUBS's
to line 305. Lines 305 to 315 set up an Antic mode 4 screen. Line
320 sets aside an area of memory where the screen can be stored.
This is done as previously described, with a poke to location 106.
First it is poked with the initial value of RAMTOP (which is
ascertained in line 175) minus TX which is initially set to 4, and
then increased by 4 each time a screen is drawn. In this way we are
setting aside 4 pages each time a screen is drawn. Line 325 tells
the Atari to draw the screen in the area of memory we have just set
aside, by poking location 89 with RAMTOP-TX. Then, so that we can
see each screen as it is drawn, we also poke DL+5 with RAMTOP-TX
thus telling the Atari to display that same section of memory.
When all the screens are drawn and the character
set is redefined the program goes to the loop starting at line 140.
Lines 140 and 145 set the variable DANCE to a random multiple of 4,
within the range 4 to 36. Then DL + 5 is poked with the value RAMTOP-DANCE
in lines 155 and 160, telling the Atari to display those areas of
memory selected by the pokes to location 89 in line 325.
When the program is running you can see how rapid
is the transition between one screen and the next. Clearly page
flipping is a very powerful technique and with a little thought and
planning some dynamic screen displays can be created. One point to
remember is that if screen memory crosses a 4K boundary then the
screen display will be disturbed. This is only a problem with the
higher resolution graphics modes, but if you want to flip screens in
Graphics 8,9,10, or 11 then take a look at program 2, which flips
between two Graphics 8 screens. You will see
from the listing how the address of 'read memory' is also set at DL+
101 to point to the area of memory which is displayed in the bottom
half of the screen. When the screens are drawn, press START or
SELECT to flip between the two. To see how the screen is split,
change RAMTOP-48 in line 150 to RAMTOP-16, also change RAMTOP-16 in
line 155 to RAMTOP-48, Then the bottom halves of the screens will be
The information contained in this article has been
drawn from many sources including the following. If you need any
more information I recommend that you try to get copies of them.
PAGE FLIPPING by David Plotkin - Antic, January
TICTOCFLIP by Gene Levine - Antic, September 1985
PAGE FLIPPING ON THE ATARI by Clay Stuart -
COMPUTE!, June 1985
DISPLAY LISTS by Steve Pedler - PAGE 6, Issues
18,19 and 20
ANIMATION BY PAGE FLIPPING by David Plotkin -
COMPUTE!'s SECOND BOOK OF ATARI GRAPHICS
MAPPING THE ATARI (Compute! Books) by Ian Chadwick
I hope I have explained page flipping clearly and
accurately, and that you will have a go yourself. Of course
animation is not the only use for page flipping. Any program where
rapid switching between screens is required can benefit from the