• No results found

Basically a scroller moves a text from right to left across the screen, past the "eye" of the observer. You could program something like this in just a few minutes in text mode. Take a character string and a pointer indicating the current position of the left screen edge within the string. Then, write 80 characters 70 times per second starting from this current position, perhaps onto a particular screen line. Then increment the pointer by one position. This moves the window (currently visible text section) through the string in the direction of reading. You now have your scroller.

Programming a scroller in graphic mode is somewhat more complicated. Although the principle is the same, the programmer has no BIOS routines available for character output in Mode X or very limited BIOS routines available in Mode 13h. Everything is therefore the programmer's responsibility (which actually can be an advantage for display speed).

Another important difference from a text-mode scroller is duplicating the forward motion of the screen contents. You can display a new character string at the new starting position in text mode. However, the speed factor is much more critical in graphic mode, so you no longer have the luxury of assembling each character from the font information.

There is a much simpler way to do this, however. With this basic scroller form, the text only moves and no longer changes once it's on the screen. You can therefore simply copy it graphically one position further by shifting columns 4-319 four pixels to the left and adding the new "text" in the "empty" columns 316-319. These four-pixel steps make effective use of the advantages of Mode X, and provide a simple way to copy four-byte blocks in Write-Mode 1.

To shift a number not exactly divisible by four (three for example), you would have to copy contents from plane to plane, which is possible only by accessing individual pixels. Copying from one offset to another without switching planes however can be used on four pixels at a time, significantly increasing the speed.

Font for scroller text

All you need to do now is display a four-pixel wide strip of new text at the right edge of the screen. Where does the data to be displayed (the font) come from? A simple solution of course is to use the VGA-ROM font, but this provides neither color nor elaborate graphic designs. Designing your own font is not for everyone but is essential for visual presentations.

Some programmers write their own editor for this purpose which includes features of a paint program and the ability to generate fonts. However, the effort required to do this usually outweighs its usefulness. Why spend time writing an editor when the demo for which you are creating the font can be finished in half the time? Also, public domain or shareware paint programs are capable of drawing basic objects such as lines, circles, section-copying, etc.

In fact, public domain, shareware or commercial paint programs are the better alternative for another reason. Saving a complete alphabet in a single image also saves valuable hard drive space since the image can be saved in compact GIF format.

How you design the characters themselves is up to you. If you're artistically inclined you can always create a new font. Another option is to modify or edit an existing font. Remember, the characters must meet the requirements for further processing when you're finished. The routine that appends the new columns is based on blocks of four so the characters must be arranged similarly. Both the x-coordinate and the character width must be divisible by four while also allowing for varying character widths. This also lets you use proportional fonts.

After you've properly arranged all the characters, comes the hard part: Entering all the character positions. The character output procedure uses these positions to access the font by reading their location in video memory and their width from the table.

To create the table, just take paper and pencil, with a paint program that continuously displays the cursor position. Be careful however, because some paint programs start counting coordinates at 1, so the upper left

corner of the screen has coordinates (1,1). Although perhaps convenient for the program's developers, it conforms neither to mathematical reality nor to the conventions of your computer. The coordinates must always conform to a 0-based system. You can always subtract 1 if necessary (this applies also when positioning in blocks of four). Based on the coordinates of the upper left corner, the offset in video memory is calculated according to our previously derived formula:

Offset:= Y*80 + X div 4

You must enter this value into the table for each letter. The plane is always 0 because that was the requirement for using the fast write mode. To determine the width, first measure the letter in pixels (either in your head or with the length function in the paint program) and round it up to the next integer multiple of four. This will give you the width in blocks of four, which is essential to the process. Enter this value into the table as well.

Once you're finished with the table, you must still transfer it to the program. The ASCII sequence should be retained to keep the programming as simple as possible. For example you could make a table from ASCII code 32 (space) to 96 (accent grave

`

) and assign a width of zero to unused characters (i.e., ASCII character 64 - @).

Of course you could also include the lower case letters (97-122) or the entire ASCII set if you like, because you can have a small graphic for each character. Normally however, uppercase letters, numbers, and a few special characters are enough.

The term "graphic effect" has assumed an entirely new meaning in the last few years. We used to consider a simple static image created with a paint program as a "graphic effect". Today graphics and graphic effects now include animation, moving sprites or other types of visual movement. These graphics effect are usually processed by the CPU. However, we'll talk about effects which can be handled independently by the VGA; whereby the CPU only gives the command to initiate the process

Basics

All the effects we'll talk about in this chapter can also be generated in some way using the CPU. However, this involves shifting large amounts of data within video RAM. It's very slow to move data this way. DMA can accelerate these movements only slightly (direct CPU access may actually be faster on most computers). In any case, accessing video memory usually ends up with a bottleneck at the data bus.

Fast access to video memory is limited on the earlier ISA-bus since even the fastest CPU's are constrained by the 8 MHz bus speed needed for 'downward' compatibility. Also, if an extra Hercules card is installed, it switches the 16-bit VGA card down to 8 bits which again doubles the access time.

Even current bus systems that use a 16-bit or even 32-bit data bus at a speed of 33 MHz can still create a "traffic jam" for the data. This is because strict protocols must be maintained, several wait states are often added and some VGAs are unable to keep up and add wait states of their own.

So, there must be another way to bring the type of effects to the screen that we see in countless demos. These demos display dazzling effects and yet still manage to play sound and perform the calculations for three- dimensional objects. All this is possible if we use the built-in capabilities of the graphic card.

PC graphic cards do not yet have programmable controllers, processors, etc., designed specifically for graphic effects (like the Amiga), where the CPU performs

only control and supervisory tasks. VGA cards do, however, have many registers and combinations of register contents that if you look closely, you'll discover possibilities never considered by early designers of VGA.

However, there's no substitute for actually experimenting with the register contents. Providing you don't change the timing registers of the CRTC, your experiments cannot damage or destroy any hardware. The worst that could happen is the image or effect is distorted or doesn't appear.

Split-screen And