The CGA modes of Ultima 2 & 3 are pretty horrible to look at. In fact, that was my primary motivation for starting this project 20ish years ago. But they were never really intended to be viewed that way. With CGA Composite, the alternating magenta-and-black pixels of the water tiles appear as a smooth, deep blue. Alternate them in the opposite order (black then magenta)? The hue becomes the red that’s used on the brick tiles in the towns and castles.
CGA Composite mode is the main feature that I originally had planned for the next release. And it’s still planned (in fact it’s done), but I just had a few detours along the way. Fortunately, I was able to reuse the algorithm I wrote for the Ultima 3 Upgrade with a bit of refactoring & shared code. That was a pretty massive time saver.
What is CGA Composite Mode?
Composite mode was a special video mode supported by CGA cards when hooked up to an older analog monitor, such as a television set. It created a color “smearing” effect, or artifacting, where the colors outputted would shift to a different hue depending on the position of the pixel. The shift was predictable and taken advantage of by developers to create more colors than were actually possible on the graphics hardware.
Short of using a real composite monitor, the cgacomp driver works by emulating and approximating the expected color output. And it does so using the original CGA graphics. The graphic data is first written to an intermediate buffer using CGA driver functions. Once the data is ready for display, the driver or the game code calls a “flush” function. The flush function then maps the CGA data to its composite counterpart and writes the to the real video buffer.
If you’re interested in more details, I’ve written about it on the project wiki.
Implementation Differences
Note that there are some caveats. Because there’s additional overhead involved, you may notice the game runs a bit sluggish on Dosbox if using the default cycles of 3000. So I recommend bumping it up to at least 10000 cycles.
The second caveat is the text. Ultima 2 uses built-in interrupt functions to output text to the video buffer. This operation completely bypasses the double-buffer & flush mechanism I have in place. The result is that the text has no artifacting – which makes it a bit more readable, but less authentic. This wasn’t the case in Ultima 3 because it used custom graphic data to output the text. (Note that some screens in the CGA driver, such as the main menu or zstats, are outputted using a text mode. This means they would never have artifacting, even in a properly rendered composite mode.)
As an alternative, Dosbox now has support for composite mode in the latest SVN builds. It’s also likely more performant than what I’ve written because it’s not constrained by the cycles setting. So please feel free to choose a configuration that’s right for you.
This is the last change coming in v2.1, and the work is pretty much wrapped up so look for the release soon!
One thought on “U2 Upgrade – CGA Composite Mode”