2

Colors by Page Flipping

titlebar.gif

Robert W. Myers


"Colors by Page Flipping" allows you to mix colors to produce new ones.

Have you ever wanted more colors than are provided on your Atari? This program uses four colors in Graphics mode 2, and mixes them two at a time to produce a total of ten different colors.


Blending Colors

All this color, like almost everything on the TV screen, is really an illusion. The blending of colors takes place because the displays are changed back and forth so fast that our eyes cannot keep up with the changes. Therefore, we see only one color, which is a mixture of the colors in all the different displays. You can mix more than two colors at a time, but as the number of displays increases, the amount of flicker on the screen increases too. The practical limit is four displays mixing at once.

This mixing is done by using multiple screen RAM areas and changing the Load Memory Scan (LMS) bytes in the display list during the Vertical Blank Interrupt (VBI). I realize that this sounds like a very complicated thing to do, but it's not.


Understanding the Display List

The Display List is a program for the ANTIC chip, the microprocessor that controls the TV screen so that the 6502 is free to spend more of its time doing computational chores. The Display List is in RAM, and the first byte of the Display List can be found at PEEK (560) + 256*PEEK (561).

Usually you will find that the first three bytes are the code that causes the black area at the top of the screen (to insure that nothing is lost due to overscan of the TV). The next byte is the LMS byte which sets the D6 bit (64 decimal). Added to this 64 is the ANTIC graphics mode number, which is given in the table.

The LMS is a three-byte instruction. The 64 + mode # is the first byte; the second and third bytes are the address of the beginning of screen RAM.

This address is what we are interested in here. Rapidly changing it allows us to switch from one picture to another and back. We cannot do this address swapping from BASIC; it is far too slow. The LMS bytes are changed by a short machine language routine that is run 60 times a second while the picture is blanked out as it returns to the top of the screen to begin the next frame. This is Vertical Blank Interrupt.

The routine loads the LMS bytes with the address of the first (normal) screen RAM, then it does an exclusive-OR with one of the memory locations. This causes the memory location to toggle between 0 and 1. This 0 or 1 is used to determine whether a branch will be taken or not. If the branch is taken, the next instruction is JMP $E462, which puts the interrupt back in normal operation. If the branch is not taken, the LMS bytes are changed to the address of the other (alternate) screen RAM. Then comes the JMP $E462.


Using VBI

The VBI is amazingly easy to use. All you do is write your routine that is to run during the interrupt. Then you write a machine language program that puts the high byte of your routine's address into the X-register, the low byte into the Y-register, and the number 7 into the accumulator. Finally, you JSR $E45C. This second machine language program is at lines 160, 170, and 180 of my program.

After setting up your VBI to change the LMS, you print or plot and move one set of your screen RAM to the other (alternate) location that you have specified to the LMS. This technique should be usable with any multicolor display mode or any combination of display modes, not only to mix colors, but also to mix text and graphics, to display mixed resolutions, etc.


ANTIC Graphics Mode Numbers
BASIC mode 0 1 2 3 4 5 6 7 8
ANTIC mode 2 6 7 8 9 10 11 13 15


Mixing Colors

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

Return to Table of Contents | Previous Section | Next Section