The IBM 5153’s True CGA Palette and Coloration Output

In the event you used a PC all through any a part of the DOS period, then until you have been the monochrome kind, you are most likely accustomed to the default set of 16 colours. CGA represented them as RGBI: one bit every for Red, Green, Blue and Intensity. These have been the one colours that (digital) CGA was able to, however later requirements retained them as defaults for textual content mode and for 4/16-color graphics.
These later requirements mapped them to increased bit-depth RGB, and ensuing palette of the 16 CGA colours is what most of us are accustomed to. However is it a very good match for the output of IBM’s unique CGA monitor, the 5153 Private Laptop Coloration Show?
If it was, I would not be typing this up, so let’s discover out what the deal is.
The Normal (Canonical) CGA Palette
That is the widespread mapping of CGA’s 16 RGBI colours to RGB – it displays how they’re rendered on virtually all post-CGA methods, and by present PC emulators. The baseline customary today is 24-bit RGB (8 bits per channel), so the widespread model has a variety of 0..255 for every element, proven right here as hex triplets:
00: #000000 |
01: #0000AA |
02: #00AA00 |
03: #00AAAA |
04: #AA0000 |
05: #AA00AA |
06: #AA5500 |
07: #AAAAAA |
08: #555555 |
09: #5555FF |
10: #55FF55 |
11: #55FFFF |
12: #FF5555 |
13: #FF55FF |
14: #FFFF55 |
15: #FFFFFF |
The “Canonical” RGBI-to-rgb24 CGA palette
The concept is fairly simple. CGA coloration numbers are 4-bit values: I, R, G and B (most to least important). This palette assigns a stage of 2/3 to the unique R,G,B alerts, and treats I as extra white, by including 1/3 to all three channels. The exception is coloration #6: CGA modifies it from a dim yellow to brown, utilizing a circuit within the monitor to detect the bit mixture ‘0110’ and tone down its G element. The above palette represents that by reducing the G stage from 2/3 to 1/3.
However here is the catch: this palette does not essentially mirror the looks of a CGA monitor just like the 5153. Nothing within the RGBI coloration mannequin requires this exact mapping, and IBM’s CGA specs do not explicitly outline one in any respect. Somewhat, it is derived from how EGA (and VGA) rendered these 16 colours for backward compatibility.
EGA moved from 4-bit RGBI to 6-bit RGB (2 bits per coloration channel). Every element might take 4 discrete ranges, 0 to three. That is the place the canonical CGA palette will get its “0, 1/3, 2/3, 3/3” quantization from: the 16 CGA-derived colours needed to be represented by this “rule of thirds”. VGA took it additional to 18-bit RGB (6 bpc), and ‘truecolor’ gave us 24-bit (8 bpc), so the identical values have been normalized to the upper bit depths.
This palette actually is canonical – in spite of everything, it is primarily based on IBM’s personal technique of translating CGA colours to later RGB requirements. However I’ve had my 5153 for some time now, and it is fairly clear that these colours do not do a terrific job of representing its precise CGA output, it doesn’t matter what the knobs are set to.
A Extra Correct Mannequin?
A greater illustration can be troublesome with out some exhausting information. Luckily an unofficial supply exists: electronics engineer and CRT fanatic Dr. Hugo Holden has made some very informative investigations into the IBM 5153’s innards, and certainly one of them concerned measuring the voltages that drive the gun amplifiers for every RGBI coloration.
These ranges have been measured with the distinction management on the most place; see later for why that is vital. Right here is the related information, reproduced from the unique doc:
IBM 5153 CGA Monitor Coloration Processing | |||||||||
---|---|---|---|---|---|---|---|---|---|
Drive stage: Volts peak above black stage to gun amplifiers | |||||||||
Regular: | Coloration Quantity | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
R | 0 | 0 | 0 | 0 | 1.00 | 1.00 | 1.00 | 1.00 | |
G | 0 | 0 | 1.00 | 1.00 | 0 | 0 | 0.64* | 1.00 | |
B | 0 | 1.00 | 0 | 1.00 | 0 | 1.00 | 0 | 1.00 | |
Intensified: | Coloration Quantity | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
R | 0.40 | 0.40 | 0.40 | 0.40 | 1.12 | 1.24 | 1.24 | 1.30 | |
G | 0.40 | 0.40 | 1.12 | 1.24 | 0.40 | 0.40 | 1.24 | 1.30 | |
B | 0.40 | 1.12 | 0.40 | 1.24 | 0.40 | 1.24 | 0.40 | 1.30 |
* = stage decreased by Q206
These values deviate from what the canonical CGA-to-RGB palette would possibly lead you to count on:
- There isn’t any quantization of voltage ranges to a ‘rule of thirds’ (0, 1/3, 2/3, 1)
- For coloration #6, the “brown repair” (transistor Q206) applies a inexperienced discount of solely 36%, not 50%
- Depth does not add a uniform worth to all three channels
- For the intensified colours, the utmost stage moreover relies on the rely(!) of main coloration elements
These are direct penalties of IBM’s circuit design, which Hugo Holden’s referenced write-up explains in a lot higher element. All in all, this provides us a significantly better start line if we need to enhance our mannequin of the 5153’s coloration output.
By taking the measured voltage vary of 0 to 1.30 (above black stage) and normalizing it to the RGB24 vary of 0..255, we get this:
00: #000000 |
01: #0000C4 |
02: #00C400 |
03: #00C4C4 |
04: #C40000 |
05: #C400C4 |
06: #C47E00 |
07: #C4C4C4 |
08: #4E4E4E |
09: #4E4EDC |
10: #4EDC4E |
11: #4EF3F3 |
12: #DC4E4E |
13: #F34EF3 |
14: #F3F34E |
15: #FFFFFF |
A revised CGA palette for the IBM 5153, primarily based on gun drive stage measurements
At this level, you would possibly elevate an vital query: Maintain it! A linear conversion of voltages to RGB ranges?! Who stated you might try this? What about gamma correction? In any case, the switch perform of a CRT just isn’t a linear input-to-output mapping; it is best approximated by an influence legislation, AKA the gamma perform. The above translation cannot be legitimate – until the IBM 5153 CRT has the identical gamma perform because the show displaying our RGB colours (most likely not a CRT in any respect). And the way possible is that?
Fairly possible, really. No matter show kind, nearly all present video methods are standardized for a gamma worth of two.2; for historic causes this was chosen to mirror the gamma switch perform inherent in cathode ray tube know-how. This worth doesn’t fluctuate a lot throughout correctly adjusted CRT screens, modulo minor corrections for viewing situations (the nominal worth is someplace between 2.25 and a couple of.5).
So though IBM by no means revealed a gamma worth for the 5153 (to my data), we will make an informed guess that it is shut sufficient, so this revised palette is kind of legitimate. However extra importantly, it actually is an effective match for the 5153’s seen output… as I’ll try to indicate under.
Let’s Examine
This is a digicam nonetheless of the 16 CGA colours as proven on my IBM 5153 (with the distinction knob on the most place), proper subsequent to our two CGA-to-RGB palettes: the ‘canonical’ one, and the revised one primarily based on Holden’s voltage measurements.
The picture was white-balanced in order that coloration #7 is gray – apparently the colour correction is not 100% excellent (e.g. inexperienced and magenta), but it surely’s nearly as good as I might get it with out introducing different errors. Getting older electronics can have an effect on the voltage bias on the three gun amplifiers and make them drift barely out of adjustment, so it is not too surprising.
The picture remains to be shut sufficient to the perceptual consequence when trying on the monitor, so it’s best to be capable of decide which palette is extra like the actual factor:


On first look the revised palette appears to have one fast level in its favor: the distinction between the conventional (0-7) and intensified (8-15) colours. The revised model has much less of a brightness distinction between the 2 teams, fairly like within the picture. However that distinction is exactly what the 5153’s distinction knob modifies (see under), so it is not an impartial variable. Our new palette is just primarily based on measurements made with that knob at most.
Alternatively, there are different features which make the revised palette a greater match:
- The higher distinction between crimson (4) and brown (6) – within the canonical palette they’re usually exhausting to differentiate.
- The brightness ranges aren’t so uniform throughout the intensified colours.
- Specifically, there’s extra separation between colours 10 and 11, between 12 and 13, and between 14 and 15.
…And Let’s Distinction
The 5153 has an attention-grabbing little quirk in comparison with typical CRT screens. Its brightness management behaves just about as you’d count on, modifying the degrees uniformly by making use of a set DC offset to the video alerts. However the distinction management does one thing a little bit extra uncommon.
Distinction in most CRTs adjusts the amplifier’s static AC acquire, to manage the distinction between black stage and most brightness throughout your entire picture. However right here, it impacts solely the non-intensified colours: each time the depth sign is excessive, the distinction pot is successfully bypassed and acquire just isn’t attenuated.
In different phrases, distinction is utilized dynamically throughout the raster relying on the contents of the picture. Turning the knob down makes the conventional colours (0-7) dimmer, however the intensified colours (8-15) are fully unaffected:



To simulate this oddity when mapping the RGBI colours to RGB, it is not sufficient to use a static ranges adjustment to your entire palette: you’d should tune the values for colours 0-7 solely. It is a bit ineffective to present exact RGB values right here as a result of they fluctuate easily throughout the vary of the adjustment, however all 3 coloration elements should be decreased proportionally, to protect hues. I say “decreased” as a result of our revised palette has the distinction knob at most, so from right here you may solely go down.
Another factor I’ve seen is that the distinction management has a delicate impact on coloration #6 (brown). At max, it appears shut sufficient to the one in our new palette; however while you begin dialing down the distinction, its hue adjustments barely and turns into a bit much less reddish and extra greenish. This modification is not sustained: it appears to occur round a selected level a little bit under most distinction, however then it stays like that the remainder of the way in which down. Could possibly be a quirk of circuitry design coupled with the particular remedy of coloration #6 for chroma correction, or possibly simply one other little symptom of age.
Sure, However Why does it Even Matter?
The profit right here is not very apparent – we’re splitting hairs about one explicit monitor, and a CGA one at that. 99% of the time, viewers aren’t going to note or care so long as the palette is kinda-sorta within the ballpark, and even then they’re going to most likely want it wasn’t. So the place’s the sensible worth in all this OCD coloration nitpicking?
OK then: think about you are engaged on a little bit mission with the IBM 5153 as a potential goal. You are doing the visuals in your fashionable PC, so that you simulate CGA utilizing the 16 canonical colours. Now, think about you are making an attempt to make a easy coloration gradient in textual content mode. In time-honored ANSI artwork custom, you employ the half-shade (“▒”) character and tweak the foreground and background colours till all of it appears good and easy. However then you definitely examine the consequence in your 5153, and it appears like stripy vomit:

Working with the canonical palette (high) leads you to count on a satisfactory coloration ramp, decreasing in brightness from left to proper. However on the 5153, the variations in coloration relationships mess up the perceptual impact, so that you get ugly discontinuities (heart). The revised 5153 palette (backside) would have proven you one thing a lot nearer to the actual factor; at which level you’d most likely need to make a greater gradient, however that is a complete different can of worms.
Even with the revised palette, the RGB rendering nonetheless deviates from what we see on the CRT display. That is partly all the way down to the digicam settings, however this monitor is not fairly carried out with its surprises.
Dithering and Coloration Mixing Oddities
Wanting on the idealized RGB rendering vs. the 5153’s precise output, you may naturally discover that the actual monitor blends pixels steadily within the horizontal route; there are not any sharp edges. However that is not all: the dithered “colours” you get with the alternating-dot trick are darker than anticipated – regardless that the true, strong colours are usually not.
In the event you generate the identical coloration ramp in 80-column mode as an alternative of 40, you improve the decision from 320 to 640 dots per line. The smaller dots mix collectively much more easily, so the dither patterns are just about invisible. However the darkening impact is stronger, too:

5153 coloration mixing with alternate dot patterns exhibits a darkening impact: 40 vs. 80 columns
These blended colours that have been darkened in 40-column mode are darker nonetheless at 80 columns. In the meantime the strong colours are nonetheless unaffected. Within the sharp RGB rendering, each resolutions have the identical obvious brightness – however on the 5153, finer dithering appears to amplify the darkening impact.
By taking a look at additional examples we will begin to discern a sure logic:
- Colours generated by mixing pixels collectively are darker on the 5153, vs. the straightforward crisp rendering on a contemporary show.
- Positive patterns (with horizontally-shorter dots) are darkened greater than coarse patterns composed of longer dots.
- The larger the distinction between the 2 dot colours, the stronger the darkening impact.
With two totally different dot-pattern chars (0xB0 ░ and 0xB1 ▒), we will illustrate the impact on pixel sequences of various lengths:
The reason for all that is more than likely the bandwidth of the CRT gun amplifier – which determines how briskly it may modulate the voltages on the CRT cathodes. These voltages management the colour being displayed because the beam scans, so the time they take to vary defines the sharpness of the horizontal boundaries between pixels, and the utmost decision that may be clearly displayed. We are able to see that the IBM 5153’s video amplifier is not terribly high-bandwidth, at the very least not in spite of everything these years, because it has bother reaching full separation at 640 H-dots (80 columns).
That is what blurs the dot edges; however why do additionally they seem darker? That relies on the gun voltage’s rise and fall instances. If it rises extra slowly than it falls, whole output for repeated oscillations is decreased. Or presumably the rise/
Since this solely happens when colours really change between pixels, we will see why shorter dot stretches are darkened to a higher diploma, making the impact stronger for finer patterns. Additionally: as a result of the bandwidth limitation lengthens rise/
Listed here are a few take a look at patterns I made to see how numerous coloration mixtures are affected. In the event you examine the 40 and 80 column variations of every display (say in two browser tabs), you may see it:
Possibly this kind of factor merely occurs when screens get outdated. I’ve had buddies take a look at this on their very own 5153s, to confirm that mine is not simply making an attempt to be particular, and the outcomes have been just about the identical. Whether or not or not they’d higher decision after they have been new, it is most likely protected sufficient to count on the typical 5153 to be like this in the present day.
Tying it All Collectively
If that is the case, how can we simulate the fuzzy edges and the darkening impact in a plain RGB rendering?
One technique that appears to work is making use of horizontal movement blur to behave as a low-pass filter – however with out performing any gamma correction. In virtually another state of affairs, that’s a paddlin’. But when my above hunch is appropriate, we may very well have a very good motive to try this right here: in the actual monitor, the voltage swings are smoothed out on the amps, earlier than the tube de-linearizes the colour area. By mixing pixel values as in the event that they have been linear and displaying them as sRGB, we simulate simply that.
By massaging the above examples this manner, we get:




Ahhh, significantly better! (Duke Nukem voice and flushing water sound are non-obligatory.) There are nonetheless a couple of mismatches, however actually if I take into account all of the components that would (and doubtless did) introduce errors between the 5153’s video circuits and the images on my PC, even getting considerably shut in any respect is satisfying sufficient. This offers me a fairly good indication of what a given picture will appear to be on the 5153, and that is higher than none in any respect.
What About Different CGA Displays?
This bears repeating: all of this actually solely applies to the IBM 5153. Since nothing about CGA’s specs mandates this actual interpretation of the RGBI alerts, different CGA CRTs do not essentially comply with all of it that intently, particularly with these particular little twists (brown, depth, distinction). In actuality, a few of them are totally different sufficient. Let’s begin with IBM’s different CGA-
-
5154 Enhanced Coloration Show: that is the unique EGA monitor, and as already famous, EGA gave us the “canonical” CGA palette by adapting these 16 colours to its 6-
bit RGB coloration mannequin. Nonetheless the 5154 also can deal with RGBI video immediately, both from a CGA card or from EGA in 200-line (15.7 KHz) mode. You would possibly suppose that its RGBI sign processing would comply with the 5153’s, however no: the 4 enter bits are internally translated to the 6-bit RGB mannequin, giving precisely the identical 16 values we get with native EGA video; this mapping is carried out by a ROM chip within the enter stage. So on the 5154, even true CGA video yields the 16 EGA-like canonical colours.
-
4863 PCjr Coloration Show: this was manufactured by Mitsubishi, not by Tatung just like the 5153, and the one schematic I can discover makes it look reasonably totally different internally (too dangerous it is not very readable). Though I do not personal this one, sufficient images exist to indicate that the brown coloration behaves about the identical as on the 5153, however I can not make certain about the remaining.
-
5515 12″ Coloration Show (for the IBM JX): images of this one inform us that there isn’t any brown as such, and coloration #6 is clearly proven as darkish yellow, so evidently it does not have the “chroma correction” circuitry. You possibly can see three of those on the high here. That is the third variation (at the very least!) on the CGA coloration set simply from IBM themselves.
-
There’s additionally the 5145 PC Convertible Coloration Show, from a unique producer but once more, this time in Korea (most likely Samsung, which additionally made the 5154). However this one appears to be the rarest of IBM’s consumer-market CGA CRTs, and information/
schematics/ images are simply as scarce.
As for non-IBM ones, they’re in all places – I’ve a later Samsung/Samtron monitor the place brown is extraordinarily near crimson, and others have stated the identical about Tandy fashions; Philips/
Ethical of the story: there isn’t any such factor because the One True CGA-to-RGB Palette, not when the blokes who invented the usual could not determine on one. The canonical mapping is not a very dangerous mannequin for “generic” CGA shows, however to characterize the output of a specific monitor, you must take note of its traits. The revised 5153 palette (and different tweaks described right here) appear to do the trick for this one.