Sunday, November 16, 2008

The Tandy Graphics Adapter (TGA)

 When I was a kid, we had a Tandy 1000SX.


I was obsessed with RPGs, particularly games like Ultima, and I wanted to recreate those kinds of worlds myself. That meant learning how to draw tile maps, scroll viewports, and animate sprites. I wanted to do them in “full” 16-color graphics, not the underwhelming four colors offered by the stock PC-compatible CGA. And I wanted them fast.

The Tandy Graphics Adapter was essentially an enhanced version of IBM’s earlier CGA standard. More specifically, it was the IBM PCjr’s graphics standard later adopted by Tandy. CGA was the baseline graphics hardware for early IBM PCs, but it was limited: in its most practical graphics mode you got 320x200 resolution with only four colors. The Tandy extended this to 16 colors at the same resolution, which at the time was a tremendous improvement.

The Tandy graphics mode was fairly approachable. The screen memory layout was unusual by modern standards, but not difficult. Where the CGA’s framebuffer was interleaved into two banks, the TGA’s 320x200 framebuffer was divided into four interleaved scanline banks, meaning line 0 would be followed in memory by line 4, then 8, and so on, while line 1 lived elsewhere with 5, 9, etc. Pixels were packed two to a byte instead of four as in CGA. It sounds strange, but after writing the offset math a few times it became second nature. Before long I was blitting tiles and drawing maps to the screen.

One thing I miss about that era of programming is that drawing a sprite to the screen required understanding, at least a little, how the machine itself actually worked.

No comments: