RetroBox – Video Display Controller (VDC)

September 20, 2008

Last time I wrote about the RetroBox, I talked about its internal components, and how they are connected. One of the more complex components is the VDC, or Video Display Controller, which is responsible for displaying things on the screen, and today I will go into more detail about this.

retrobox_vdc_borders

Have a look at the above figure. It shows the RetroBox screen layout – a 320×200 pixel area, surrounded by borders. You can control the color of the borders (by modifying color #0 in the color palette), but you won’t be able to display any art there; only the actual screen area (320×200) can display individual pixels.

If you look at the memory map from the last entry, you’ll see an entry named "Video RAM Address", which is located at address $1004. This means that if you set the contents of that address to a memory location, the VDC will read that location to determine the color of individual pixels on the screen. Consider the following example:

move.l $20000,$1004
move.b 1,$20000 

The first line will set the Video RAM Address to $20000 (just a arbitrary memory location which we’ve decided to use for the screen) and the second line will set the first pixels value to 1, which means the second palette index.

retrobox_vdc_components

Now, being able to modify the screen is all we really need – we could make entire games using this. However, the RetroBox VDC have some built-in functionality to make it easier to do certain things. First, it’s got built-in support for Sprites, which are small bitmaps which can be positioned independently and will be displayed on top of the screen, making them ideal to use for things which move around, like the player, the enemies, bullets etc. You can have up to 64 sprites on the screen at the same time, and they can be in sizes up to 128×128 pixels. Any pixel with a color index of 0 will not be drawn, thus enabling transparent regions for your sprites.

In addition, there are 4 single color overlays and one full-color overlay. The single color overlays are 320×200 in size, covering the entire screen and with fixed position. All the pixels in a single color overlay are the same color, but different overlays may have different colors. The full-color overlay is like a second screen, displayed on top of everything else, with the only difference that pixels with a color index of 0 will not be displayed, making it possible to have parts of the other components showing through. The full-color overlay can be very useful for things like the user interface, which you want to show on top of the rest of the stuff.

retrobox_vdc_layers

When the VDC updates the displayed image, it starts by drawing the Screen, followed by the Sprites (starting with sprite #0, then #1 all the way to #63). Then it draws the 4 single color overlays in order, and finally the full-color overlay.

retrobox_vdc_final

These different layers combine into the final image, which is displayed on the RetroBox screen. Having separate layers like this, means that it’s often not necessary to redraw that much stuff from frame to frame – usually, all you need to do is move the sprites around and update some UI information in the overlay. You could even change the Video RAM Address to scroll the background, while still having sprites and UI rendered correctly on top.

I hope this have given you some insight to how the RetroBox displays graphics, and how most aspects of it can be controlled by manipulating the reserved RAM locations.

Leave a Reply