How “oldschool” graphics worked Part 1 – Commodore and Nintendo


Welcome! In this episode I’m gonna explain how old-school graphics worked. Let’s talk about some basic math real quick. Back in the early 1980s, your typical home computer had 16K of RAM, some had 32K, and if you really had money to burn, then you might have 64K. Now, let’s talk about screen memory. The video chip back then didn’t have its own bank of memory, so it had to share with the CPU. Back then a typical screen resolution was 320 x 200 pixels. And if you do the math, you’ll see there are 64,000 pixels on the screen. Now, let’s talk about color. If you just wanted 1-bit color, which is essentially black and white, then you would need 8 kilobytes of memory just to hold the screen information. Okay, so that takes a decent chunk of memory from all of these computers. But, it still leaves enough left over for your game code. Now, if you bump that up to 16 colors, suddenly you need 32K, which is more than many computers even had. By the time you get to 256 colors, you’ve eaten up all of the RAM, even in high-end computers, so now there’s no room left for any code. And doing a modern-style 24-bit “true color” would be impossible. So the engineers were pretty smart and they figured out ways to get more color out of these old machines without using up so much RAM, and there were essentially three different methods used for this and I’m going to cover them. Color cells, which were used by many systems such as Commodore and Nintendo; artifact coloring, used primarily on the Apple II and the Tandy Color Computer; CPU driven graphics, such as on the Atari 2600 and the Sinclair ZX81. Ok, so the first type of system we’re going to cover was arguably the most popular. Now what they did was they basically took the screen and shrunk it down into smaller sections and these sections were called cells or color cells. That way you could change the color of each specific cell. Let me illustrate how this works. Let’s pretend this is a black screen, and let’s zoom into the pixels. Now I’ve drawn this so that you can see imaginary lines where the pixels would be. Now, let’s put some example text on the screen. At this point the screen is essentially a 1-bit screen so pixels are either on or they’re off. So, how can we add color to this? Well, divide up the screen into areas that are 8 pixels wide and 8 pixels tall. Now, we’ll make these areas where you can define a foreground and a background color. So, I could turn this letter yellow, and this letter blue. And I could make the background blue. So, you can see how this certainly adds some color to an otherwise black and white display. And each color cell only requires 1 byte of memory to define the foreground and background colors. That means the whole screen only used 9 kilobytes, instead of 8 kilobytes for a traditional monochrome screen. So, that was a pretty good tradeoff. But, here’s where you start to run into problems. Let’s just say, for example, that you wanted to put a white line here. This would actually not be possible, because you can only have two colors per cell. So, you can see how this method was able to give computers 16 colors on screen at the same time, you just couldn’t always put the colors exactly where you wanted them to go. And you could imagine that this made artwork pretty challenging. Nevertheless, take a look at this piece of artwork done on the Commodore 64. It looks very colorful. And, to the layman, they may not even be aware of the color limitations of the computer. But, let’s zoom into this piece of art, and look at it a little bit closer. If I overlay some imaginary lines to show you where the color cells are, you’ll be able to see that, in fact, there are never more than 2 colors per cell. But, the artist has worked very hard to make his work line up with the edges of the cells to the point that it appears seamless. Knowing this should cause you to give these guys a little bit more respect for the work they do. And, if you were a player of the Nintendo Entertainment System, then keep in mind just about every game had to deal with this exact same issue. The color cells worked a little bit different than the Commodore 64, but it’s basically the same headache. So the engineers knew that these color limitations might be a problem, so they gave the software designers another option they could use. Let’s go back to our 2-color example. The C64 had a mode called “multi-color mode”. Now, what it did was literally made the pixels twice as wide, which cut the screen resolution in half. Small text looks really bad like this. But the machine rewards you for your sacrifice. You have traded in some resolution for some color. But, it still only consumes 9 kilobytes of RAM, just like the other system. Now, each color cell will allow you up to 4 colors. So, now, you could do something like this. And here’s an example of a piece of art done in multi-color mode. And again, I’ll zoom in and show you the fine detail, and you can see how the colors were used in this picture. You will still never see more than 4 colors used in a single cell. Most games for the Commodore 64 actually used this mode, since color was often more important than high resolution. And then there was one other tool the engineers gave us. It’s called a hardware sprite generator. Now let me show you how this works. I’m going to create a sprite on graph paper. This is actually how I learned to do this back in the early 1980s. Next, we have to convert this to binary data. So, let me show you how to break this down. Every pixel corresponds to a 0 or a 1. Now I’ve divided this up into three sections of 8 pixels each. So, let’s take the first 8 pixels. There’s nothing here, so we’ll write in a 0 for this section. Ok, the next section does have some pixels, and for simplicity I’ll use a calculator to convert from binary to decimal. So, we get 124. And the last section will also be a 0. Okay, so now to finish all the way down the paper. Ok, next I entered these numbers into the computer’s memory. And, I can turn the sprite on like this. Notice that I cannot type over the sprite, nor can I erase it using the keyboard. Even if I change the color of the text, it doesn’t matter. The sprite is independent from the rest of the screen, and it doesn’t even care about the color cells. I can modify a different register and change the color of the sprite. I can change a different register, and move the sprite somewhere else on the screen. Even a clear screen command won’t get rid of it. Sprites were heavily used in gaming. Different systems had different numbers of sprites. The Commodore 64 had 8 different sprites. Um, the Nintendo had 64 sprites, but, the sprites were very small, meaning you would usually need to use a lot more of them to accomplish the same goal. So, Mario here was actually made up of several different sprites, but they just do a good job of keeping them all together so it looks and behaves like one. All right, so this concludes part one. Stick around for part two, where I’m going to show you how Apple II graphics and some of the early CPU-driven graphics modes worked.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2019 Explore Mellieha. All rights reserved.