Selects a graphics palette for CGA.
#include <graph.h>
short __far _selectpalette( short number );
number | Palette number |
The _selectpalette function works only under the video modes _MRES4COLOR, _MRESNOCOLOR, and _ORESCOLOR. A CGA palette consists of a selectable background color (Color 0) and three set colors. Under the _MRES4COLOR mode, the number argument selects one of the four predefined palettes shown in Table R.6.
Table R.6 _MRES4COLOR Palette Colors
Color Index, | ||||
Palette Number | Color 1 | Color 2 | Color 3 | |
0 | Green | Red | Brown | |
1 | Cyan | Magenta | White | |
2 | Light green | Light red | Yellow | |
3 | Light cyan | Light magenta | Bright white |
The _MRESNOCOLOR video mode is used with black-and-white displays, producing palettes consisting of various shades of gray. It will also produce color when used with a color display. The number of palettes available depends upon whether a CGA or EGA hardware package is employed. Under a CGA configuration, only the palettes shown in Table R.7 are available. Note that although four palette numbers are listed, palettes 0 and 1 are identical, as are palettes 2 and 3.
Table R.7 _MRESNOCOLOR Mode CGA Palette Colors
Color Index, | ||||
Palette Number | Color 1 | Color 2 | Color 3 | |
0 | Blue | Red | White | |
1 | Blue | Red | White | |
2 | Light blue | Light red | Bright white | |
3 | Light blue | Light red | Bright white |
Under the EGA configuration, the three palettes shown in Table R.8 are available in the _MRESNOCOLOR video mode. Note that although four palette numbers are listed, palettes 1 and 3 are identical.
Table R.8 _MRESNOCOLOR Mode EGA Palette Colors
Color Index, | ||||
Palette Number | Color 1 | Color 2 | Color 3 | |
0 | Green | Red | Brown | |
1 | Cyan | Magenta | White | |
2 | Light green | Light red | Yellow | |
3 | Cyan | Magenta | White |
You can use the _ORESCOLOR high resolution video mode for the Olivetti graphics adapters found in most Olivetti computers and in the AT&T 6300 series computers. In _ORESCOLOR mode, an argument number in the range 0–15 selects one of the colors listed in Table R.9. The background color is always black in this mode.
Table R.9 _ORESCOLOR Mode Colors
Index | Color | Index | Color |
0 | Black | 8 | Dark Grey |
1 | Blue | 9 | Light Blue |
2 | Green | 10 | Light Green |
3 | Cyan | 11 | Light Cyan |
4 | Red | 12 | Light Red |
5 | Magenta | 13 | Light Magenta |
6 | Brown | 14 | Yellow |
7 | White | 15 | Bright White |
The function returns the value of the previous palette. There is no error return.
Standards:None
16-Bit:DOS
32-Bit:None
_getvideoconfig, _remappalette, _setbkcolor, _setvideomode
/* SELPAL.C: This program changes the current CGA palette. */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <graph.h>
long bkcolor[8] = { _BLACK, _BLUE, _GREEN, _CYAN,
_RED, _MAGENTA, _BROWN, _WHITE };
char *bkname [] = { "BLACK", "BLUE", "GREEN", "CYAN",
"RED", "MAGENTA", "BROWN", "WHITE" };
void main( void )
{
int i, j, k;
if ( !_setvideomode( _MRES4COLOR ) )
{
printf( "No palettes available" );
exit( 1 );
}
for( i = 0; i < 4; i++ ) /* Palette loop */
{
_selectpalette( i );
for( k = 0; k < 8; k++ ) /* Background color loop */
{
_clearscreen( _GCLEARSCREEN );
_setbkcolor( bkcolor[k] );
_settextposition( 1, 1 );
printf( "Background: %s\tPalette: %d", bkname[k], i );
for( j = 1; j < 4; j++ ) /* Foreground color loop */
{
_setcolor( j );
_ellipse( _GFILLINTERIOR, 100, j * 30, 220, 80 + (j * 30) );
}
_getch();
}
}
_setvideomode( _DEFAULTMODE );
exit( 0 );
}