kristofer sweger Home
ANSIPLUS Home


Selecting and Defining Colors

The SETCOLOR.exe utility program provides extensive control over colors for your running system. With this program, the user can view the current colors, select colors for use, create and apply named color schemes, edit the color palette, set the border color, and save and load color definitions. Changes made with SETCOLOR.exe are in effect only as long as your system is running. To change the colors for system startup, use the NEWAPLUS.exe program. SETCOLOR.exe is executed by a command of the form:

SETCOLOR <keyword> [<keyword> ... ]

where each <keyword> selects a foreground or background color or other option. If no <keyword> is supplied, you are presented with a menu of choices:

From the command line, colors may be selected by name or code number, where codes 0-15 identify the 16 palette colors, 128-143 select foreground colors, and 192-207 select background colors. The relationship between color names and code numbers is depicted in the following table:

Color Names and Code Numbers
Color Name
Color Code
Foreground Code
Background Code
BLACK
0
128
192
DKGRAY
8
136
200
GRAY
7
135
199
WHITE
15
143
207
DKRED
1
129
193
RED 9 137 201
BROWN
3
131
195
YELLOW
11
139
203
GREEN
2
130
194
LTGREEN
10
138
202
CYAN
6
134
198
LTCYAN
14
142
206
BLUE
4
132
196
LTBLUE
12
140
204
MAGENTA or PURPLE
5
133
197
LTMAGENTA or PINK
13
141
205

In 256 color modes, you may also use 256-511 to select the foreground, 512-767 to select the background, or 0-255 after the BORDER keyword to select the border color.

Several modifying keywords can assist the color selection:

DARK, DIM or NORMAL Low intensity colors
LIGHT, BRIGHT or INTENSE High intensity colors
FOREGROUND or FGD Foreground following
BACKGROUND, BGD, or ON Background following
REVERSE Swap the current foreground and background
BORDER Border color selection following
DEFAULT Select the current colors as the default colors

If named colors or color codes 0-15 are specified without the foreground or background keywords, then the first color is assumed to be the foreground and the second the background. Keywords may also be shortened; the first partial match will be used. Several examples may help to clarify these rules:

SETCOLOR bgd blue Sets the background to dark blue
SETCOLOR light cyan blue default Default colors are light cyan foreground and blue background
SETCOLOR 7,0 Gray foreground, black background
SETCOLOR bright green on blue High intensity green foreground, dark blue background
SETCOLOR border cyan Set the border color to cyan
SETCOLOR reverse Reverses (swaps) the current foreground and background colors
SETCOLOR rev Reverses foreground and background

Any unmatched keywords are checked against user-defined color schemes in a file named SETCOLOR.sch. This editable ASCII text file, which should be placed in the same directory as the SETCOLOR.exe program, contains any number of named color schemes of the user’s choice. User supplied color schemes are entered into the file with a text editor, with each line entered in the form:

<name> = <keyword> [<keyword> ... ]

where <name> is the name of the user supplied color scheme, and <keyword> is any valid SETCOLOR program keyword or other option. The follwing table shows the color scheme for each line of the SETCOLOR.sch file included with ANSIPLUS as a sample:

Sample Color Schemes File
evening = light cyan blue border 17
night = light blue black border 17
dawn = yellow cyan border 35
daylight = light blue white border 17
sun = bright red yellow border 46
sky = blue light blue border 17
forest = black green border 24
earth = yellow brown border 38
regal = pink purple border 21
candycane = dark red pink border white
bw = gray black border dkgray

A user color scheme may be specifically selected on the SETCOLOR command line by preceding its name with the keyword SCHEME, for example:

SETCOLOR SCHEME JOE Selects a color scheme named JOE

The SETCOLOR program also includes keyword options to reset, edit, load and save the current color configuration. These include:

RESET Install defaults as the current colors
IBM or OEM Install the OEM VGA/EGA palette as the current colors
PALETTE Edit the color definitions for the 16-color palette
SAVEFILE <filename> Save the current 16-color definitions in a file
SAVE256 <filename> Save the 256 VGA DAC color definitions in a file
LOADFILE <filename> Load a color definition file
SAVECURRENT <file> Save the 16 current colors as an executable program
SAVEDEFAULT <file> Save the 16 default colors as an executable program
SAVEPROGRAM <file> Save both the current and default colors as a program

The SAVEFILE, SAVE256 and LOADFILE keywords generate and load color definition files. The color definition files created by SAVEFILE contain 36 lines: 32 lines define the red, green and blue intensities for colors 0 to 15, both current and default, and the other four define the current and default foreground, background and border colors. Files created by SAVE256 contain 512 lines: 256 for the default DACs and 256 for the current DACs. The table to the right is a sample of lines from a SAVEFILE color definition file.

Users are free to edit color definition files to create their own colors, to delete any lines from them, or to put the lines in any order except that all default color definitions must precede all current color definitions in the file. If no file name is given for a LOADFILE, SAVEFILE or SAVE256 request, the file name SETCOLOR.def in the current directory will be used. LOADFILE checks the system PATH for color definition files to be loaded, so any commonly used color files can reside in a directory on the PATH.

 
Sample Color Definition File
Default = 142,196
DBorder = 0,81,162
DColor 2 = 16,162,81
DColor 3 = 113,65,16
DColor 4 = 0,0,105
DColor 5 = 97,0,97
Current = 135,192
Border = 0,0,0
Color 2 = 0,170,0
Color 3 = 0,170,170
Color 4 = 0,0,170
Color 5 = 170,0,170

The SAVECURRENT, SAVEDEFAULT, and SAVEPROGRAM keyword options create executable ".com" files that can be called later by name to install colors. These programs can also be edited by the ANSICOM.exe utility program.

To provide additional user control over 16-color programs, such as DBASE III or DOS 5.0 EDIT.com, that set their own palettes or border colors but do not restore the palette on completion, or to simply force a color scheme on a program that defines its own, ANSIPLUS can lock the color palette, preventing a program from loading the PAL/DAC and border color registers by BIOS calls. This feature is controlled by two SETCOLOR options:

LOCKPAL Enable locked color palette, ignore BIOS calls defining colors
UNLOCKPAL Disable locked color palette, allow programs to define colors

Palette locking should only be used when all other means of control fail. It is intended to be invoked as part of batch files that execute applications to be controlled, locking the palette before the program runs, and unlocking it after it completes. The feature should never be enabled all of the time because it will keep well behaved programs from making color changes too.

The SETCOLOR program also controls ANSIPLUS VGA monochrome monitor emulation. Two keywords enable or disable this feature:

MONOCHROME Begins VGA monochrome monitor emulation
COLOR Ends VGA monochrome monitor emulation and restores colors

And finally, SETCOLOR provides three reporting options:
 

SHOW Displays the 16 current colors in a band across the screen
HELP Gives a brief description of how to use the SETCOLOR program
SCHEME HELP Lists the available color schemes in file SETCOLOR.sch

© Copyright 2000-2007, Kristofer Sweger. All rights reserved.
Rev. 10/16/07