• Please review our updated Terms and Rules here

CGA composite emulator's accuracy

carlos12

Experienced Member
Joined
May 10, 2020
Messages
183
Location
Madrid, Spain
I've been doing some tests on 640x200 CGA composite mode (which transforms on 160x200x16 colors). I've been using a program written by Michael Abrash and Dan Illowsky, published on their 1984 book Graphics for the IBM PC. I just added a few lines of code to test changing the foreground color in order to navigate all the color palettes.

While trying the 15 palettes, I found one that matched my graphical needs almost completely, using fore color 6. The problem es that on DosBox 0.74-3 it looks too good to be true. So I also tried on DosBox-X, 86Box and PcEm. Unfortunately, it only looks this good on DosBox 0.74, so I guess that it draws the composite colors wrong when not using the default set. Could someone confirm this is this way? I attached a capture of the same program running on DosBox 0.74 and DosBox-X.

The program I used to display all the palettes is this one:
Code:
100 REM Program to demonstrate color generation in 
110 REM hi-res mode by artifacting.
120 REM Set screen to hi-res mode
130 SCREEN 2:KEY OFF:CLS
135 LET NCOLOR=1
140 REM Enable color burst so TV will display color
150 OUT &H3D8,26
154 REM Select foreground color
155 OUT &H3D9,NCOLOR
160 REM Label column that color numbers will go in
170 LOCATE 1,38:PRINT "COLOR #"
180 REM Draw using each of the 16 colors in turn
190 FOR I=0 TO 15
200	REM Set point at which to begin drawing colored area
210	PRESET (120,I*8+16)
220	REM Draw columns 100 to 250
230	FOR K=100 TO 250 STEP 4
240		REM Draw set of 4 pixels, producing one
250		REM artifacted colored pixel. Color is based
260		REM on the 4-bit pattern in I
270		FOR L=3 TO 0 STEP -1
280			REM Draw one column in white, if bit is 1, or
290			REM in black, if bit is 0
300                     LINE -STEP(0,7),SGN(I AND 2^L):PRESET STEP(1,-7)
310             NEXT L
320     NEXT K
330     REM Label color number
340     LOCATE I+3,40:PRINT I
350 NEXT I
354 LOCATE 22,27:PRINT "FOREGROUND COLOR: ",NCOLOR
360 LOCATE 24,27:PRINT "PRESS ANY KEY TO CONTINUE";
370 A$=INKEY$:IF A$="" THEN 370
374 IF NCOLOR=16 THEN GOTO 380
375 NCOLOR = NCOLOR+1:OUT &H3D9,NCOLOR:GOTO 354
380 SCREEN 0,1:WIDTH 80:KEY ON 'Reset screen
390 END

composite-color-6.png
 
A couple of things to keep in mind there...

First, composite CGA emulation in DOSBox 0.74-3 is not perfect. There's already code that improves the accuracy (https://www.vogons.org/viewtopic.php?p=677941#p677941), but mainline DOSBox hasn't incorporated it, and I'm not sure about DOSBox-X either.

Second, there's a distinction between two revisions of IBM's CGA ("early"/"old" vs. "late"/"new"). Composite color output is somewhat different between the two, since the later revision appeared around the same time as the 5155 - IBM tweaked the composite output stage to make it look passable on monochrome, but the difference is apparent in color as well. In PCem/86box you select the CGA model in the "configure" dialog, and in DOSBox patched as above you press Alt+F11.
Here's what your palette should really look like in both versions:

Early revision:
16rows_color6-early_out.png

Late revision:
16rows_color6-late_out.png

The default palette (color 15) gives much closer results between the two CGA revisions. That's one reason that most of the non-default palettes aren't all that useful in practice... unless you're willing to prepare two different sets of graphic assets (see the final version of 8088 MPH). ;)
 
Last edited:
Thank you! Just what I needed. I wonder where the programmers of DosBox 0.74 got that palette, which corresponds neither the old nor the new CGAs... It's a pity is not real as IMO is a really terrific selection of colors.

By comparing the DosBox-X capture with yours, I see it's far more accurate than 0.74, although not completely identical.
 
Yep, looks like DOSBox-X isn't accurate either and is extremely blocky to boot. I should try to see what it would take to adapt the improvement patch for -X...

BTW, speaking about blockiness,
640x200 CGA composite mode (which transforms on 160x200x16 colors)

160x200 isn't really a useful way of looking at it, and it isn't really true either: if you look at this CGA screenshot next to an actual 160x200 one, the first one clearly has a lot more horizontal detail. Because of the nature of composite, the horizontal resolution isn't really fixed and can vary with the colors you're using.. 160x200 is more like the very minimum.

I only mention this because I've seen lots of artwork (*cough*Planet X3*cough*) that could really use the extra detail this mode can provide, but the artists simply think in terms of a fixed 160x200 grid and end up in blockity blockville. :)
 
160x200 isn't really a useful way of looking at it, and it isn't really true either: if you look at this CGA screenshot next to an actual 160x200 one, the first one clearly has a lot more horizontal detail. Because of the nature of composite, the horizontal resolution isn't really fixed and can vary with the colors you're using.. 160x200 is more like the very minimum.

Yes, your're right. I have no better way to describe it: to me composite artifacts look like more analog, more natural than non-artifacted low resolution (PCjr/Tandy), which looks like more digital, in the sense on being more blocky, as you say, and also the color choice is more rigid, based on the pure math of color combinations. It's curious that the emulators (except DosBox-X), albeit not accurate, try to simulate that analogness (in the absence of a better word...). I personally see the composite artifacts in general, and CGA composite in particular, a most fascinating subject.

I only mention this because I've seen lots of artwork (*cough*Planet X3*cough*) that could really use the extra detail this mode can provide, but the artists simply think in terms of a fixed 160x200 grid and end up in blockity blockville.

Haha :D
 
Last edited:
Back
Top