Screen Flipping


Michael Kirtley

Here's another way to rapidly "flip" screens.

This useful subroutine can be appended to your own BASIC programs. It lends them a cleaner, more professional look. The screen-flipping routine can be used to include a page or two of documentation with your program or to switch to a menu instantly. Another intriguing use would be to flip rapidly between several screens to create animation.

When you first run the program, there will be a brief pause as the Atari writes screen two. Then you will see screen one being written. I intentionally left this in to contrast between writing a screen and flipping to a previously written one. This effect can be eliminated by POKEing 559 with a 0 to turn off the video display until the screen has been written. Another advantage in using this POKE is a significant increase in execution speed. You can try this by adding the following lines to the program:

130 R=PEEK(559):POKE 559,0 
180 POKE 559,R

Another embellishment to the program would be to write screen one and show it to the user. While the user is viewing screen one, the computer could be writing screens two, three, etc.

A small "beep" sound subroutine placed just before the POKEs on lines 220 and 230 will give a crisper effect upon flipping screens. I've found the following routine to be a good one for this purpose.

250 SOUND 0,100,10,15:FOR X=1 TO 20:NEXT X 
260 SOUND 0,0,0,0:RETURN

Now let's look at how the program works.

Lines 100-120: Initialize variables. Locations 560 and 561 hold the low and high bytes of the address of the display list. Location 749 is the high byte of the top of memory pointer. Location 89 is the high byte of the lowest address of screen memory.

Line 140: Tell the Atari where to write screen two. Before writing screen two, clear the screen.

Line 150: Write screen two. You can substitute your own application here.

Line 160: Tell the Atari where to write screen one.

Line 170: Write screen one.

Line 190: GET a keyboard response from the user.

Line 200: GOTO whichever screen the user selects.

Line 210: Go back and get another keyboard response if the user picks a screen we don't have.

Line 220: POKE the location of screen one into the correct place in the display list (DL + 5). This is where the Atari looks to find where the current screen is located.

Line 230: POKE the location of screen two into the display list.

Additional screens can be added (depending on memory size and the application program) by stepping down four 256-byte pages from the location of the previous screen. In graphics mode 0 there are 24 lines with 40 one-byte characters each, for a total of 960 bytes. This is a little less than four pages (1024 bytes). Therefore, if


To make room for screen two, you must step down five pages from MEMTOP to avoid garbage on the screen. To add additional screens, initialize as above, then POKE 89 with the new screen and POKE 106 with the new screen + 4. You will now be able to write the new screen. To view the screen, just POKE DL + 5 with the new screen.

Now enter the program and run it. Press 1 for screen one and 2 for screen two.

Screen Flipping

Download P192L1.BAS (Saved BASIC)
Download / View P192L1.LST (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section