Classic Computer Magazine Archive HI-RES VOL. 1, NO. 1 / NOVEMBER 1983 / PAGE 44

Hi-Res Banner Magic

Program by: Dan Horn
Article by: Pat Henderson


A machine language assist can help you squeeze 200 colors onto your monitor, while this banner program lets you create your own specialty screens.

When you were looking at an Atari to purchase, a salesman probably showed you one of those fantastic demo programs that all Atari dealerships have. One of those demos has a particularly interesting title screen. The Atari logo is flashed on the screen with many colors scrolling through it. If you know the program, it probably caught your eye the same as it did mine. But how did they get all those colors on the screen at once? Well, the short Basic program below, unravels the mystery of Scrolling Colors with a little machine-language assist.

Scrolling Colors puts almost 200 colors on the screen at the same time. Yet in Basic, the Atari screen can show only up to five colors at one time (unless you are using player/missile graphics). To create more than five, you need to call on machine language.

Handling more than five colors on the screen at once and scrolling them, requires some fancy work with the monitor. We want to change colors on every scan line of the screen, and to do this we set up what is called an Interrupt. An Interrupt is almost exactly what it sounds like; it interrupts the microprocessor (the brain of the computer), and tells it where to go in memory for its next instruction. The Interrupt stores a value which is the location in memory that points to our machine language routine. We place this Interrupt a few scan lines down from the top of the screen. When the computer is drawing on the screen, and it hits the Interrupt, the Interrupt gives control to our scrolling colors routine. When the routine has drawn the last scan line at the bottom of the screen, it then returns control to the computer which in turn starts drawing at the top of the screen until it hits the interrupt again and restarts the entire process.

Decrementing Color

But how does our machine-language routine actually change colors on every scan line? Once the Interrupt is activated (line 500), the program branches to the machine-language routine and remains there until you reset the computer. The machine-language routine itself (line 507) loads a color value from 0-255 into a memory location called a color register. This register tells the monitor to draw with a certain color. Because the computer works at a much greater speed than the monitor, our machine-language routine contains an instruction that puts the computer into a state of limbo to allow the monitor to finish drawing the current scan line. This is called Wait for Synchronization.

When the monitor has finished that line, the routine changes the value in the color register decrementing it from 255 to zero, and draws the next scan line with a new color. You will notice that the scrolling colors are only drawn in the letters. This is because the letters have their own color register. The background too has its own register, as does the border.

Looking at both listings, this is a description of what each line does:

Line
1
20-48
500
501
503
504
505-508


509
Jumps to Line 504
Draws letters on screen (both listings).
Enables the Interrupt.
Sound intro to drawing. Also line 502 in Listing 2.
Halts the program.
Sets graphics mode 19 and the drawing color.
Sets up the Interrupt and the machine-language routine.
Line 506 reads in the data from Line 507. The numbers in
Line 507 correspond to actual machine-language instructions.
Return to draw the letters.

As you can see in Listings 1 and 2, the program does not Print letters on the screen, it draws them using Plot and Drawto statements. Plot and Drawto are very easy to use when you know what you want to put on the screen.

The screen is divided into 40 columns (0-39) by 24 rows (0-23)(Fig. 1). Columns run vertically and rows horizontally. If you want to illuminate a single block on the screen, use the statement PLOT (column, row). To illuminate a block in the middle of the screen, for example, you would use PLOT (20,12). If you want to draw a line, use Plot and Drawto statements together. You must tell the computer where to start the line and where to stop the line. A Plot is used to tell it where to start, and a Drawto is used to tell it where to stop. If we wanted to draw a line across the top of the screen, we might use PLOT (0,0) and a DRAWTO (39,0). If you desired a line drawn from the upper left corner of the screen to the lower right use: PLOT (0,0) and DRAWTO (39,23). The computer draws the closest thing to a line that it can. To continue the same line to the lower left corner use DRAWTO (0,23). Let's say we wanted to draw an "A" in the middle of the screen. We would use PLOT (13,16) and then DRAWTO (20,9), then a DRAWTO (27,16) to get the left side and right side. To put the crossbar in the middle, use a PLOT (16,14) to start it and a DRAWTO (25,14) to finish it.

hiresbanner.jpg
Fig. 1. Hi-Res Banner

Graphics Mode 19

Our Hi-Res banner program uses graphics mode 19 and color 3 (medium blue) to create the screen. (Don't change the drawing color or the program won't work.) Graphics Mode 19 is the same as Graphics Mode 3 except for the absence of the text window at the bottom of the screen. In Mode 19, as in Mode 3, the computer uses larger graphics blocks and has fewer places to access with Plot and Drawto statements; thus we need less time to set up our banner.

If you used Graphics Mode 24 (same as Graphics Mode 8 minus the text window), you would have to access many more places on the screen, but the resolution of your drawing would be that much higher.

As you can see in Fig. 1, the grid shows how Graphics Mode 3 sets up the screen. Lines 20-50 of Listing 1 draw the letters. If you want to create your own banner screen, change these lines to draw letters you want. There is enough space to use lines 2-499 to put in Plot and Drawto statements of your own. Use the graph in Fig. 1 to design what you want on the screen.

If you will look at Listing 2, you will notice that lines 20-46 are different from the same lines in Listing 1. By altering these lines I recreated a close facsimile to the Hi-Res logo on the cover of this magazine. I drew out the logo on a grid and then plotted my lines from that.

By typing both listings, you will also notice that when the program in Listing 2 is executed, the letters do not appear before the scrolling colors are activated. This is because the background is the same color as the letters (Line 504), so they are "invisible." When the scrolling colors are "turned-on," the letters seem to "pop" onto the screen.

Once you get the feel for the Plot and Drawto statements, you should be able to create some great banner screens. If you have any problems with either of these statements, consult your Atari Basic Manual.

Pat Henderson and Dan Horn are technical toilers at Adventure International in Longwood, Florida.

Listing 1: HIREBAN1.BAS Download
Listing 2: HIREBAN2.BAS Download