VT340 Default Color Map

March 11, 2025 · View on GitHub

The pixels on the screen are kept in memory as color indices which map to the actual color to display. By default, the colormap looks like this:

IndexHLSRGBText attributeDEC name
0000000Screen BackgroundBlack
104959202079Blue
21204671791313Red
32404959207920Green
4604959792079Magenta
53004959207979Cyan
61804959797920Yellow
70460464646Foreground TextGray 50%
80260262626Bold+Blink FGGray 25%
904628333359Blue*
101204238592626Red*
112404628335933Green*
12604628593359Magenta*
133004628335959Cyan*
141804628595933Yellow*
150790797979Bold ForegroundGray 75%
    * These colors are less saturated than colors 1 through 6.

Unlike modern systems, on the VT340, the RGB values range from 0 to 100 percent in decimal, not 00 to FF in hex. Another difference is that a Hue angle of 0 degrees is blue on the VT340, not red.

The colors for each index are not fixed and can be selected from a palette of 4096 by sending a ReGIS escape sequence. E.g., to change the foreground text color to "dark orchid" (Hue 40°, Lightness 50%, Saturation 60%), set color index 7: ␛P0pS(M7(AH40L50s60))␛\ .

Displaying images also changes the color map which can mess up text legibility. (See Resetting the colormap.)

Documentation differs

Click to see minor differences with the VT340 documentation

    Note that the above table contains the actual values retrieved from a VT340+ after doing a factory reset of the settings. Almost all values have slightly lower lightness or saturation than what is printed in the manual. Most significantly, the foreground color (7) is listed as 53% (#878787) in the manual, but in reality it is 46% (#757575). Perhaps in an earlier firmware revision it did match the manual. At some point, it seems it was decided, for every color except the foreground, to subtract 1 from the percent saturation and subtract 0 or 1 from the lightness.

    Here is the HLS side of table 2-3 VT340 Default Color Map from the VT340 Graphics Programming manual (2nd ed.), with the delta of how it changed in the actual hardware.

    Index	 H   	  L	    S
    0      	 0   	  0         0
    1      	 0   	 50 -1     60 -1
    2      	120  	 46        70 -1
    3      	240  	 50 -1     60 -1
    4      	 60  	 50 -1     60 -1
    5      	300  	 50 -1     60 -1
    6      	180  	 50 -1     60 -1
    7      	 0   	 53 -6      0
    8      	 0   	 26         0
    9      	 0   	 46        29 -1
    10     	120  	 43 -1     39 -1
    11     	240  	 46        29 -1
    12     	 60  	 46        29 -1
    13     	300  	 46        29 -1
    14     	180  	 46        29 -1
    15     	 0   	 80 -1      0
    

Connection between text attributes and colormap

Although the VT340 supports text colors, it is not "ANSI color". Instead, it represents some text attributes by using four specific colors in the colormap: 0, 7, 8, and 15.

StyleColor IndexUsed as color forVT340 Default
Background0Background screenBlack
Foreground7Normal textMedium gray
Bright15Bold textLight gray
Dim8Bold+Blinking textDark gray
    Although color number 8 appears to be for "dim" text, the VT340 does not actually handle Graphic Rendition 2 (ANSI dim). Perhaps the feature was removed to make room for blinking?

For example, sending the ANSI escape sequence for bold text, ␛[1m, uses color number 15 as the foreground instead of 7.

AttributesForegroundBackgroundEscape Sequence
Normal70␛[0m
Bold150␛[1m
Reverse07␛[7m
Reverse Bold015␛[1;7m
Blink (off)70␛[5m
" (on)07"
    Note that the Underline character attribute (`␛[5m`) is not mentioned in this table because the VT340 renders it as an actual underline, not via color.

Character attributes that are defined as indices in the colormap can be set to any desired color by changing the color the index refers to, but doing so will change all text on the screen with that attribute. (But, compare: faketextcolor.md.)

To change all bold text to "goldenrod" (Hue 180°, Lightness 65%, Saturation 60%), set color index 15: ␛P0pS(M15(AH180L65S60))␛\ .

Click to see DEC's undocumented sixel colormap kludge

    Although not documented anywhere, DEC appears to have attempted to mitigate the problem of illegible text by making sixel's access to the colormap indirect: the specific color index numbers used in a sixel bitmap are ignored and instead only the order they are defined matters. The first sixel color is assigned to index 1, not 0, thus a bitmap can have up to six colors and not affect the text. The seventh color in the image changes the foreground (index 7) and only an image which needs all 16 colors will wrap all the way back to index 0 and modify the background.

    This is, of course, a hideous kludge, but it almost never matters since one typically uses ReGIS for direct access to the colormap.

The VT340's Bold+Blink rendering is peculiar (15/0 alternating with 8/7). (See Character attributes in combination below.)

Resetting the colormap

Since displaying sixel images with 7 or more colors can make text unreadable, it would be good if one could reset the colormap without being able to see what is on the screen. The simplest way is to use the builtin Color Set-up by pressing these keys on a VT340 keyboard:

    Set-Up Prev Screen Do Set-Up

For more details, please see: colorreset.md.

Character attributes in combination

For the most part, the use of colors behave as one would expect when attributes are used in combination. The one perhaps surprising design choice is how the VT340 renders Bold+Blinking text.

For normal text, The Blink attribute is displayed as normal text (7 on 0) alternating with reversed normal text (0 on 7) once a second. However, for Bold text, Blink does not look the same as Bold text (15 on 0) alternating with Reverse Bold text (0 on 15). Instead, it shows Bold text (15 on 0) alternating with Blink+Bold text (8 on 7). This is the only time that hackerb9 has found the VT340 using color number 8 for text attributes.

Extending the table from above, we get:

AttributesForegroundBackgroundEscape Sequence
Normal70␛[0m
Bold150␛[1m
Reverse07␛[7m
Reverse Bold015␛[1;7m
Blink (off)70␛[5m
" (on)07"
Bold Blink (off)150␛[1;5m
" (on)87"
Reverse Bold Blink (off)015␛[1;5;7m
" (on)78"

Inverse colors

The VT340 has a concept of "inverse" colors in at least one sense: when the cursor is on top of sixel data, it flashes between normal and some other color picked from the palette. To find the inverse index number, xor the normal index number with 7. That flips the low three bits but keeps the high bit of the nybble.

INVERSE COLOR PAIRS: XOR 7
	0--7		 8--15
	1--6		 9--14
	2--5		10--13
	3--4		11--12

Note that this mapping works somewhat like the way that text attributes are already inverted during Blink and Reverse (as above). Both Blink and Reverse swap foreground text color 7 with background color 0. When blinking, bold text color 15 is switched with its inverse, color 8. However, this analogy is not perfect: reversed, bold text color 15 is swapped with background color 0, not 8 as would be expected.

Todo: Does the ReGIS graphics cursor invert the colors in the same way? What about ReGIS logical NOT operator?

Inverse when using the default VT340 colormap

One benefit of keeping the high bit is that inverting a color will not change the saturation when using the default colormap. Colors 8 to 15 are lower saturation versions of colors 0 to 7.

The default colormap also makes the relationship between a color and its inverse simple to describe in terms of Hue, Saturation, and Lightness:

  • If Saturation is 0 (gray), then the Lightness Percent is offset by around 50 percentile points.

  • If Saturation is >0 (color), then the Hue Angle is rotated by 180 degrees.

Interactively choosing screen colors for text

Built-in color chooser

The VT340 includes in its firmware a Color Set-up screen which allows one to recall the saved color map, save the color map, or adjust the RGB values of any of the 16 colors in the palette. Set color #0 for background and #7 for text foreground.

rgb.sh script for text colors

An easier way to pick text colors is to use the rgb.sh script to interactively choose colors from a list for Background, Foreground, Bold, and Blink. Once favorite colors are known, it can be used non-interactively via arguments: rgb.sh 12 14 55 41.

The script was originally written for the VT241 and is a bit clunky. Unlike the VT340's built-in Color Set-up, rgb.sh does not show a preview of the color choices, only names such as "Cornflower Blue", "Goldenrod", or "Turquoise". Additionally, only certain color names (RGBCMYKW) are recognized, all others must be chosen by number.

VT340 Emulation Question

Which, if any, VT340 emulators can run rgb.sh? Emulators typically do not use the colormap to represent text attributes. Additionally, they would need to support ReGIS graphics for setting individual colors in the palette.