Date: Wed, 1 Mar 1995 09:08:29 -0700 From: ron@apple.com (Ron Hochsprung) Subject: Item #237: Open Firmware core - Multi-color Text P1275 Open Firmware Working Group Proposal -- Proposal #237 Ver Title: Multi-color text Author: Ron Hochsprung Date: Mar 1, 1195 Ed/Tech: Technical Synopsis: add multi-color text support to Open Firmware Doc & Version: IEEE Std 1275-1994 Problem: new clients require this support Proposal: Open Firmware Proposal Title: Multi-color text Authors: Mitch Bradley, Ron Hochsprung Date: Mar. 1, 1995 Revision: 3 Scope/Documents Affected: Core standard (next revision) Motivation: Support multiple colors for text, according to ISO 6429-1983, which defines the 16-color set used by PCs and the escape sequences to select colors. These capabilities are required by the ARC spec and the PR*P spec. References: [1] IEEE Std 1275-1994, [2] ISO 6429-1983, [3] PowerPC Binding Goals: compatibility with both existing FCode drivers and existing systems. Proposal: Add the following to the next revision or followon to IEEE 1275. In the meantime, publish it through whatever means are available to us, and include it as a requirement for future ISA bindings. Section: Introduction IEEE Std 1275-1994 defines the behavior of the Terminal Emulator Support Package (see Annex B of [1]). Annex B assumes that the Terminal Emulator Support Package implements certain escape sequences from the set defined by ANSI X3.64. The extension described here corresponds to ISO 6429-1983, as defined by [2]. An implementation of Open Firmware for PowerPC [3] is required to support additional graphic renditions (via the SGR - Select Graphic Rendition - ESC[#m) beyond those specified in Annex B. The extended model adds new FCodes that represent the current values of the BACKGROUND-COLOR and FOREGROUND-COLOR that are used by the Terminal Emulator for displaying text. These values are considered indices into a "color table" for the display buffer. This extension defines the values for the first 16 color entries. Note: these FCodes enable a display driver for a card that does not directly implement an 8-bit display buffer (e.g., a 24-bit-only frame buffer) to work with the color extensions. These drivers need access to the Terminal Emulator's color indices so that they can emulate the extended color behavior of DRAW-CHARACTER, etc. that they must have overridden. The SGR parameters specify changes to the color and intensity of the foreground and background indices that will be subsequently used by the Terminal Emulator. The ISO 6429-1983 standard provides parameter values to independently control the color of foreground (30-37) and background (40-47). The intensity is set separately (1-2), and must be issued before the color control; 1 -> color, 2 -> color+8. The expanded model of the Terminal Emulator is that there is a "current" background and foreground color (index), the first 16 of which are defined for use by this extension, corresponding to the first 16 entries of the color table. In positive image mode, pixels corresponding to a font (logo) bit set (1) will be set to the foreground color; pixels corresponding to a font (logo) bit clear (0) will be set to the background color. When in negative image mode, the roles of foreground and background are reversed. An FCode display driver that supports this extension declares so by defining a new property (ISO6249-1983-COLORS) that indicates the support of these additional methods. Likewise, an Open Firmware implementation declares its support of this extension by publishing the property within a /packages/terminal-emulator node. Section: Requirements A system that implements the multi-color text extension shall implement the following, as FCode Functions, if the Device Interface is implemented, and as User Interface commands if the FCode Debugging command group of the User Interface is present. New terminal emulator values: foreground-color ( -- color-index ) F 0x168 value, indicates how to paint color characters The set of permissible values for color-index, and their meanings, is given in Table 2. foreground-color is set by the terminal emulator package and used by display device drivers and the fb8 support package. background-color ( -- color-index ) F 0x169 value, indicates how to paint color text backgound The set of permissible values for color-index, and their meanings, is given in Table 2. background-color is set by the terminal emulator package and used by display device drivers and the fb8 support package. Section: Terminal Emulator Package The "/packages" node shall have a child node named "terminal-emulator". That terminal-emulator package shall have the following property: "iso6429-1983-colors" S Standard 'property-name' to indicate color text capability 'prop-encoded-array': None; presence or absence of the property conveys the information. The presence of this property indicates that the system implements the multi-color text extension. Specifically, it implies that the terminal emulator support package responds to the color-setting variants of the Select Graphics Rendition escape sequence as defined by ISO 6429-1983, that the foreground-color and background-color values are implemented, and that the fb8 support package responds to those values. Absence of this property within a device node named /packages/terminal-emulator indicates that the terminal emulator and fb8 support packages do not support multi-color text. Absence of a device node named /package/terminal-emulator indicates that the terminal emulator and fb8 support packages do not support multi-color text. Note: the iso6429-1983-colors property is intended for the use of client programs that need to determine whether or not the firmware is capable of displaying multi-color text. In addition to the iso6429-1983-colors property in /packages/terminal-emulator, a client program should also look for the iso6429-1983-colors property in the package corresponding to the console output device, because the fact that the firmware system supports multi-color text does not necessarily imply that the individual display device driver does. This specification does not require the presence of open and close methods in the /packages/terminal-emulator. Therefore, it is not necessarily possible to open that node (e.g. with open-package). When initialized, the terminal emulator package shall set the initial state of the following values as follows: inverse? false inverse-screen? false foreground-color 0 background-color 15 The terminal emulator package shall respond to the numeric parameters for the select graphics rendition escape sequence shown in table 1 by setting foreground-color, background-color and inverse? to values corresponding to the interpretation column. Appropriate values for foreground-color and background-color are given in Table 1. "positive image" corresponds to inverse?=true, and "negative image" to inverse?=false. Index Red Green Blue Color 0 0 0 0 Black 1 0 0 2/3 Blue 2 0 2/3 0 Green 3 0 2/3 2/3 Cyan 4 2/3 0 0 Red 5 2/3 0 2/3 Magenta 6 2/3 1/3 0 Brown 7 2/3 2/3 2/3 White 8 1/3 1/3 1/3 Gray 9 1/3 1/3 1 Light Blue 10 1/3 1 1/3 Light Green 11 1/3 1 1 Light Cyan 12 1 1/3 1/3 Light Red 13 1 1/3 1 Light Magenta 14 1 1 1/3 Yellow 15 1 1 1 Bright White Table 1. Color Table Values The 'default rendition' shall be black foreground (i.e. foreground-color=0), bright (bold) white background (background-color=15) and positive image (i.e. inverse?=false). The Terminal Emulator shall interpret the parameters of the Select Graphic Rendition (ESC[#m) sequence as follows: parameter 0 affects foreground-color, background-color, and inverse?. parameters 1 and 2 affect either foreground-color or background-color, depending on the following parameter. parameters 30-37 affect foreground-color. parameters 40-47 affect backgrond-color. parameters 7 and 27 affect inverse?. Param Interpretation 0 default rendition 1 bold (increased intensity) 2 faint (decreased intensity) 7 negative image 27 positive image 30 black foreground 31 red foreground 32 green foreground 33 yellow foreground 34 blue foreground 35 magenta foreground 36 cyan foreground 37 white foreground 40 black background 41 red background 42 green background 43 yellow background 44 blue background 45 magenta background 46 cyan background 47 white background Table 2. SGR Parameters Section: fb8 support package A system that implements multi-color text shall implement the following additional semantics for the fb8 support package. If the package corresponding to the device instance that executed fb8-install has a property named "iso6429-1983-colors", the operations of the fb8 support package shall be performed according to the specifications given below for "multi-color mode"; otherwise they shall be performed as specified in IEEE 1275-1994. Definitions: effective background index the value of background-color if inverse? is false, otherwise the value of foreground-color effective foreground index the value of foreground-color if inverse? is false, otherwise the value of background-color Section: Drawing operations in multi-color mode fb8 operations that move portions of the text window to (possibly) different locations within the text window shall preserve the exiting color indices of the moved regions. fb8 operations that set portions of the text background to a solid color shall set the pixels of the affected regions to the effective background index. fb8-draw-character and fb8-draw-logo shall set the display pixels corresponding to "zero" bits in the logo or character bitmap image to the effective background color, and display pixels corresponding to "one" bits in the logo or character bitmap image to the effective foreground color. fb8-invert-screen and fb8-toggle-cursor shall modify the pixels of the display regions that they affect as follows: Existing color index New color index effective foreground color effective background color effective background color effective foreground color other unchanged Section: Other "display" packages Definition: multi-color display package: A package whose "device_type" is "display" that implements the multi-color text extension. A multi-color display package shall implement the following property: "iso6429-1983-colors" S Standard 'property-name' to indicate color text capability 'prop-encoded-array': None; presence or absence of the property conveys the information. The presence of this property within a package whose "device_type" is "display" indicates that the package implements the multi-color text extension. Specifically, it implies that the package displays text according to the values of foreground-color and background-color if the system implements those values. Absence of this property within a display package implies that the package does not implement the multi-color text extension. A multi-color display package shall implement the following methods: set-colors ( adr index #indices -- ) This method allows the setting of a number of consecutive colors, starting at the 'index' color, for '#indices' number of entries. 'adr' is the address of a table of packed R-G-B components. get-colors ( adr index #indices -- ) This method allows the reading of a number of consecutive colors, starting at the 'index' color, for '#indices' number of colors. 'adr' is the address of a table that will be filled in with packed R-G-B components. color! ( r g b index -- ) This method allows the setting of a single color value, specified by 'index'. 'r', 'g' and 'b' are the values to be placed into the Red, Green and Blue components, respectively. color@ ( index -- r g b ) This method allows the reading of the color components of a single color value, specified by 'index'. 'r', 'g' and 'b' are the values of the Red, Green and Blue components, respectively. The following additional requirements apply to multi-color display packages: The package shall determine whether or not the system implements foreground-color. If not, the package shall implement its drawing operations in a manner consistent with the requirements of IEEE Std 1275-1994, including the use of inverse? and inverse-screen? to determine foreground and background colors. If so, the package shall implement its drawing operations so that foreground and background colors are determined by the effective foreground and background indices as defined for the fb8 support package in multi-color mode, with meanings of those indices as given in Table 1. Note: The preferred method for an FCode Program to determine the presence or absence of foreground-color is as follows: h# 168 get-token drop ['] fcode-error = ( absent? ) Note: In order to use the fb8 support package to assist in implementing the multi-color drawing operations, a display package must setup its color translation mechanism so the correspondence between pixel values in the frame buffer memory and displayed colors is as given in Table 1. This does not necessarily imply that a multi-color display package must use the fb8 support package, nor does it require that the display hardware must use color indices 0-15 directly. The fundamental requirement is that the effective color indices 0..15 (as communicated to the display package by the values foreground-color, background-color, and inverse?) must cause to the drawing operations to generate the colors given by Table 1. The mechanism for doing this is the individual driver's responsibility. The fb8 support package is simply a convenient implementation tool for devices that conform to the widely-used hardware model of an 8-bit-per-pixel frame buffer with a color lookup table. [ P1275 Item #237 -- Received: Wed Mar 1 09:10:41 PST 1995 ]