• Please review our updated Terms and Rules here

Composite colors in QuickBasic

yevrowl

Experienced Member
Joined
Jun 26, 2022
Messages
96
Location
Kiev
About to put together another logic game with colored blocks for Composite CGA.

Please advise how to assign 16 (at least 8) colors.

P. S. Is it possible to also call up the 160 × 100 (200) × 16 color mode?
 
It's definitely possible to do composite color from QB, because that's just standard CGA modes with the colorburst enabled; it's off by default in SCREEN mode 2, but you can turn it on by clearing bit 2 in the mode register. Past that, it's just 640x200 graphics mode but every four B&W pixels is one color pixel.

It should be possible to set 160x100 mode by reconfiguring the registers, same as from any other language, but I imagine you'd need to do pixel manipulations by directly PEEKing/POKEing screen memory. But then, that's the most efficient way to do video anyway, rather than relying on the BIOS routines...
 
Here comes a demonstration of the 16 colors of composite CGA. Taken from the 1984 book Graphics for the IBM PC by the geniuses Michael Abrash and Dan Illowsky:

Code:
100 REM Program to demonstrate color generation in
110 REM hi-res mode by artifacting.
120 REM
121 REM By Michael Abrash and Dan Illowsky, 1984
122 REM
124 REM Set screen to hi-res mode
130 SCREEN 2:KEY OFF:CLS
140 REM Enable color burst so TV will display color
150 OUT &H3D8,26
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
360 LOCATE 24,27:PRINT "PRESS ANY KEY TO CONTINUE";
370 A$=INKEY$:IF A$="" THEN 370
380 SCREEN 0,1:WIDTH 80:KEY ON 'Reset screen
390 END
 
Back
Top