home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
MS.ZIP
/
ARC2_2.CHP
< prev
next >
Wrap
Text File
|
1993-06-15
|
11KB
|
307 lines
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 7
#HS,1,4,80,25,11,1
#C4,R5
~Y~I
~W~IIBM PC Palettes and Modes~Y~I
For PC video systems, a palette is a group of colors that can be displayed
on the screen. Each adaptor has its own set of modes that it will support.
Every mode has a different palette or set of palettes available. Figure 2.1,
which appears on the next screen, shows the modes that are available on all
of the most common PC video adaptors, the resolution of each mode, the
number of colors each mode can display, and which adaptors support the
particular mode.
#WN
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 8
#HS,1,4,80,25,11,1
#C4,R4
~Y~I
~W~IFigure 2.1~Y~I
PC graphics modes
~R~IMode Number Colors Resolution Adaptor
~Y~I 4,5 4 320 x 200 CGA, EGA, VGA, SVGA
6 2 640 x 200 CGA, EGA, VGA, SVGA
13 16 320 x 200 EGA, VGA, SVGA
14 16 640 x 200 EGA, VGA, SVGA
15 2 640 x 350 EGA, VGA, SVGA
16 16 640 x 350 EGA, VGA, SVGA
17 2 640 x 480 VGA, SVGA
18 16 640 x 480 VGA, SVGA
19 256 320 x 200 VGA, SVGA
#WN
#EL,9
#C4,R9
4,5 4 320 x 200 CGA, ~W~I~FEGA, VGA, SVGA~Y~I~N
#EL,10
#C4,R10
6 2 640 x 200 CGA, ~W~I~FEGA, VGA, SVGA~Y~I~N
#BO,4,18,78,22,7,1,0,3,15,5
Notice that the CGA modes are supported by all of the higher resolution
adaptors. The EGA modes are supported by the VGA. VGA modes are only
supported by VGA and SuperVGA.
#EL,9
#C4,R9
4,5 4 320 x 200 CGA, EGA, VGA, SVGA
#EL,10
#C4,R10
6 2 640 x 200 CGA, EGA, VGA, SVGA
#BO,4,19,78,22,7,1,0,2,15,5
There are additional non-standard modes available on the SVGA that are
not shown in this Figure.
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 9
#HS,1,4,80,25,11,1
#C4,R8
~Y~I
In four color mode, the CGA adaptor has three built-in color palettes. This
is shown in Figure 2.2 on the next screen.
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 10
#HS,1,4,80,25,11,1
#C4,R5
~W~IFigure 2.2~Y~I
CGA Palettes
~R~IMode 4, Palette 0 Color number Color~Y~I
0 Background Color
1 Green
2 Red
3 Yellow/Brown
~R~IMode 4, Palette 1 Color number Color~Y~I
0 Background Color
1 Cyan
2 Magenta
3 White
~R~IMode 5 Color number Color~Y~I
0 Background Color
1 Cyan
2 Red
3 White
#WN
#BO,2,7,23,23,7,1,0,15,15,5
As shown in
Figure 2.2, there
are four colors
on each palette.
If a pixel's two
bits are set to 00,
the background
color is chosen.
The background
color may be any
of the 16 colors
available on the
CGA. A list of the
colors is shown in
Figure 2.3.
#BO,55,4,77,24,7,1,0,19,15,5
The other three
colors are
determined by which
pallet is chosen.
Each palette has its
own predetermined
set of three colors
(not counting the
background color)
that are available,
Under the BGI, the
palette can be
changed using the
function
setpalette(). As you
can see from
Figure 2.2, there
are three palettes
available.
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 11
#HS,1,4,80,25,11,1
#C4,R5
~W~IFigure 2.3~Y~I
Colors available on the CGA
~R~I Numeric Value Color~Y~I
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Brown
7 Light Grey
8 Dark Grey
9 Light Blue
10 Light Green
11 Light Cyan
12 Light Red
13 Light Magenta
14 Yellow
15 White
#WN
#BO,2,10,23,20,7,1,0,9,15,5
As stated on the
last page, any of
these can be used
as the background
color. The other
three colors are
determined by which
palette is
currently selected.
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 12
#HS,1,4,80,25,11,1
#C4,R5
~Y~I
The EGA and VGA adaptors are much less limited in the number of colors they
can use. EGA adaptors can display up to 16 colors at once, while standard
VGA compatible adaptors will handle up to 256 colors at a time. Both EGA and
VGA use palettes, but in a much different way that on the CGA.
#WN
An EGA palette is actually a collection of 16 palette registers. Each
|register| may contain a value that specifies any one of 64 possible colors.
EGA pixels in video RAM ~R~Idon't hold color values ~Y~Ias they do on the CGA, they
contain a register number. The register specifies the color value.
#WN
#BO,4,17,78,21,7,1,0,3,15,5
This scheme enables the EGA adaptor to display 64 colors, rather than
just 4 as the CGA does. At the time that EGA adaptors were popular, 64
colors seemed like a lot.
#C4,R17
When the adaptor displays the colors for each pixel, it first reads the
register number from the bit planes in video RAM, then goes to the register
and gets the color value. Figure 2.4, on the next page, illustrates the
process of turning an EGA pixel value into a color value.
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 13
#HS,1,4,80,25,11,1
#C1,R3
~Y~I
~W~IFigure 2.4~Y~I
Converting An EGA Pixel Value To A Color
~W~IPixel Value Palette Registers~Y~I
┌─────┐ ~W~IContain Color Values~Y~I
Bit Plane 0 │ 0 │ ┌────────┐
│ │ 0 │ 010010 │ 0000
Bit Plane 1 │ 0 │ Selects Palette ├────────┤
│ │ ─────────┐ Register 1 │ 110101 │ 0001
Bit Plane 2 │ 1 │ │ ├────────┤
│ │ │ 2 │ 000000 │ 0010
Bit Plane 3 │ 1 │ │ ├────────┤
└─────┘ └────────────» 3 │ 001001 │ 0011
├────────┤
4 │ 000010 │ 0100
├────────┤
5 │ 111111 │ 0101
. ├────────┤
. │ │
. │ │
#WN
#BO,4,18,78,23,7,1,0,4,15,5
As you can see, a pixel value in memory actually contains a register
number. The register number that the pixel value selects contains a
color number. The color number in the palette register is used to
paint a dot onto the screen.
#EF
#QT,T,arc2_2_1
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 14
#HS,1,4,80,25,11,1
#C4,R5
~Y~I
Life in the VGA world is even more complex. A VGA adaptor uses ~R~I16 palette
registers,~Y~I just like the EGA. However, the VGA also uses a set of ~C~I256 DAC
~Y~I(Digital to Analog Converter) ~C~Icolor registers. ~Y~IThe information in the pixel
in the bit planes in video RAM specifies a palette register. The pallet
register in turn selects a DAC color register, which specifies a color. This
"layered" approach gives the VGA the ability to display hundreds of colors.
~SFigure 2.5, on the next page, illustrates the process of turning a VGA
pixel value into a color value.~s
#WP
%
#EF
#T15,1,Chapter 2 Computer Video Systems Pg. 15
#HS,1,4,80,25,11,1
#C1,R3
~Y~I
~W~IFigure 2.5~Y~I
Converting A VGA Pixel Value To A Color
~W~IPixel Value Palette Registers Contain~Y~I
┌─────┐ ~W~IDAC Register Numbers~Y~I
Bit Plane 0 │ 0 │ ┌────────┐
│ │ 0 │ 010010 │
Bit Plane 1 │ 0 │ Selects Palette ├────────┤
│ │ ─────────┐ Register 1 │ 110101 │
Bit Plane 2 │ 1 │ │ ├────────┤
│ │ │ 2 │ 000000 │
Bit Plane 3 │ 1 │ │ ├────────┤
└─────┘ └────────────» 3 │ 000010 │ ───┐
. ├────────┤ │
~W~IDAC Registers Hold~Y~I . │ │ │
~W~IColor Values~Y~I . │ │ │
┌────────────────────────────────┘
0 1 2 V
┌──────────┬──────────┬──────────┬────────
│ 01011101 │ 00010001 │ 11010010 │
└──────────┴──────────┴──────────┴────────
#WN
#BO,4,18,78,21,7,1,0,2,15,5
Like the EGA, a pixel value in memory actually contains a palette
register number.
#BO,4,10,78,13,7,1,0,2,15,5
The palette register contains a video DAC register number. The DAC
register contains the color number.
#EF
#QT,T,arc2_2_2
#WP
#X