Classic Computer Magazine Archive COMPUTE! ISSUE 144 / SEPTEMBER 1992 / PAGE A31

Numbers and pictures. (explanation of images on computer screens)
by Rhett Anderson

My mother is the ultimate computer illiterate. Not only is she innocent of how computers operate and what you can do with one, but she also has no detectable interest in learning. Aside from a few games of Centipede ten years ago and a solitary question about how pictures make their way onto the screen, her disinterest has been complete.

Her question was a good one, but the answer I gave was poor. "It's all just numbers," I said. "Numbers," she said. "I see." After ten years of moving graphics around the screen, I hope I can now give her a better answer.

My mother wasn't interested in how text got onto the screen. To her, text was an appropriate thing to be on a computer screen; the image of the flying bird that prompted her question wasn't. If she had thought about it differently, though, she would have realized that, whether it was the letter A or a bird, the computer was just putting dots up onto the screen.

At that time, the graphics on most computers weren't bitmapped. Bitmapped graphics took up too much valuable RAM. Instead, there was a character set in ROM. During every video frame (typically 1/6o second), the computer's video processor would read a map in RAM that said what letter went into each character cell. For each character cell, the video processor would retrieve the proper picture of the letter from the character set ROM and display it. (Actually, it's a bit more complicated than that, since each character is drawn a row at a time.)

Here's a closer look at how character graphics work. Each character is defined in an 8 x 8 grid. Take a look at the accompanying diagram. Each letter is made up of 64 squares (known as pixels). Some of these pixels are on, and some are off--together they form an image. In memory, the off pixels are stored as 0s, and the on pixels as 1s. Each row of pixels in each character takes up eight bits (or one byte). An on pixel in the rightmost column is represented by the decimal value 1, the next by 2, the next by 4, and so on, until the leftmost pixel, which is represented by 128, is reached. Add up the values, and you'll get the value stored in ROM. The video controller takes this number and shifts it to the right as it goes across the screen. If a binary 1 rolls out of the byte, a pixel is displayed. If a binary 0 rolls out, the pixel is turned off.

In some computers (such as the 8-bit Commodore and Atari machines), the video chip could be told to look at RAM (writable memory) instead of ROM (read-only memory) for the character definitions. With the character definitions in RAM, programs could display arbitrary graphics. Programmers could redefine the way each character looked. This could even be done dynamically to create animation.

Character-based graphics are still used in Nintendos and other videogame machines. But the Amiga uses a straightforward memory-mapped model. Instead of having a character map, the Amiga simply pulls data out of memory and displays it, bit by bit, on the screen. Let's take the simplest case first: a two-color screen.

The Amiga has a DMA (Direct Memory Access) channel for each bitplane. A simple microprocessor called the copper executes a program called the copper list 60 times a second. The copper list dictates when bitplane DMA will begin and end. Instructions in the copper list tell what areas of memory will be used as display memory for the bitplanes. Each bitplane has its own pointer.

As the display is drawn, the DMA channel reads data f rom memory--a word (two bytes) at a time--into a shift register. The video processor (on the chip named Denise) shifts these bits out of the word register one bit at a time and places them on the screen. In a single bitplane, the translation is trivial--0 bits are displayed as color 0; 1 bits, as color 1.

Color lookup is a little more complicated in the case of two or more bitplanes. DMA is taking place for each of the active bitplanes. As each pixel is drawn, a bit is shifted out of each of the shift registers. These bits are combined to form a number that is used as a color index. The bits coming out of bitplane 0 have a weight of 1, those out of bitplane 1 have a weight of 2, those out of bitplane 2 have a weight of 4, and so on. To get color 5, for instance, bitplanes 1 and 2 would have to be set to 1 bits, while all other bits would have to be 0. HAM and Extra-Halfbrite modes are special cases that don't follow this rule.

When you think about it, then, all images that you see on your computer screen are just numbers. The video hardware decides how to turn the numbers into images.