Dmuse: Color and upper-ASCII codes

From CCARH Wiki
Revision as of 07:50, 4 October 2010 by Wbh (talk | contribs) (Created page with '== The Representation of Color in Dmuse Text Files == The design of the Dmuse screen has its origins in the old PC screen. The old PC screen, which was character based, used t…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Representation of Color in Dmuse Text Files

The design of the Dmuse screen has its origins in the old PC screen. The old PC screen, which was character based, used two bytes to represent each character cell on the screen: one byte for the character, and one for the color attributes. The color attribute byte had two parts: color of the foreground -- that is, the color of the letters, themselves, and the color of the background -- that is, the field on which the letters appeared. The Dmuse screen uses this system to represent characters and their color attributes.


The ability to use different color combinations for characters has proven quite useful. The eye is quick to distinguish color, and this makes it easy to flag or highlight certain areas of the screen. But there needs to be a mechanism for coding this information for storage in a file. Otherwise there would be no advantage in using colors, since this information would simply go away when the window was saved. The most direct way to store window data would be to store each cell: character and attribute. But this has two very large disadvantages. One, it is very wasteful, since most text is written in a "default" combination, e.g., white on black. Second, it make the file very difficult to read by other programs, since only every other byte contains a valid character. The alternaive used by Dmuse is to insert an excape code each time the color attribute in a line changes. Since these changes to not happen very often, the extra bytes do not add up to a lot of extra storage. And since the escape codes come in blocks, they do not interfere with the characters, at least not on a massive scale.


The excape codes used by Dmuse actually derive from the escape codes used by the old (c. 1965) HP 2640 Smart Terminal, on which the first Ibycus systems were based 9see the History of Dmuse). Dmuse supports 16 different color combinations, which can be accessed by means of the four function keys, F5, F6, F7, F8, used with the four combinations <unaltered>, <shft>, <ctrl>, and <ctrl><shft>. By convention, F5 is assigned the default combination, usually white on black. Here are the 16 escape codes used by Dmuse to flag these comgination changes in a file. <esc> here refers to the ascii byte 27 (hex 0x1b).

<center.

Combination Escape Code
Combination 0: <esc>&d@ (default)
Combination 1: <esc>&dA F6
Combination 2: <esc>&dB F7
Combination 3: <esc>&dC F8
Combination 4: <esc>&dD <shft>F5
Combination 5: <esc>&dE <shft>F6
Combination 6: <esc>&dF <shft>F7
Combination 7: <esc>&dG <shft>F8
Combination 8: <esc>&dH <ctrl>F5
Combination 9: <esc>&dI <ctrl>F6
Combination 10: <esc>&dJ <ctrl>F7
Combination 11: <esc>&dK <ctrl>F8
Combination 12: <esc>&dL <ctrl><shft>F5
Combination 13: <esc>&dM <ctrl><shft>F6
Combination 14: <esc>&dN <ctrl><shft&gl;F7
Combination 15; <esc>&dO <ctrl><shft&gl;F8

So if you looked at a file created by Dmuse, and you saw this: "?&dAThis combination is black on red.?&d@" (using ? to represent the escape byte, 0x1b), you would know that the text "This combination is black on red." was highlighted with color combination 1, and that the two blocks "?&dA" and "?&d@" were not part of the text and would not have been seen on the Dmuse screen.


The Use of Non-standard ASCII Codes in Dmuse Files

Byte values range from 0 to 255. For purposes of representing text in Western European alphabets, only a subset of these values is agreed upon by everyone to have a standard meaning. For reasons now lost to most of us, this is called standard ASCII. The subset includes the values 32 to 126, and a few additional values such as 27 (= escape), 13 (= carriage return), 10 (= line-feed), and 9 (= Tab).

When text files are used to represent data that is meant to be read by multiple programs running on a variety of computer platforms, it is absolutely essential taht ONLY standard ASCII be used. But it would be a shame to limit screen applications such as Dmuse to the 100 or so standard ASCII characters. Dmuse, for example, can display each of the letters, a,e,i,o,u, A,E,I,O,U, with the acute accent, the grave, the circumflex, and the umlaut or dieresis. Since Dmuse can put only one character in a cell, that't 10 x 4 = 40 additional screen characters. Another example: Dmuse can draw lines and boxes with both single and double lines. Tables and diagrams made with these characters have many useful applications. It takes 40 special characters to do this. So Dmuse does make use of almost all of the 256 byte values, even though only 100 of these values have a standard meaning.

This means that text files generated by Dmuse can have non-standard ASCII bytes in them. These bytes have a clear and sensible meaning to Dmuse, but other programs will interpret them differently with what may look like nonsensible results. There is no problem so long as files generated by Dmuse for general export (MuseData files, for example) contain bytes only from the standard ASCII set. Files intended for use by Dmuse alone are not subject to this limitation. Here is a list of the byte codes used by Dmuse.

Byte Code Character description
0 0x00 (no character)
1 0x01 musical sharp
2 0x02 musical flat
3 0x03 musical natural
4 0x04 centered diamond
5 0x05 top of the large open parenthesis
6 0x06 bottom of the large open parenthesis
7 0x07 large centered dot
8 0x08 top of the large close parenthesis
9 0x09 vertical dotted line (the Tab character)
10 0x0a (line-feed, no character)
11 0x0b copyright
12 0x0c bottom of the large close parenthesis
13 0x0d carriage return
14 0x0e small arrow pointing right
15 0x0f sun burst
16 0x10 large arrow head pointing right
17 0x11 large arrow head pointing left
18 0x12 start of small square root character
19 0x13 top of square root character
20 0x14 paragraph
21 0x15 double s sign
22 0x16 vertical part of large square root
23 0x17 start of large square root
24 0x18 small arrow pointing up
25 0x19 small arrow pointing down
26 0x1a plus or minus
27 0x1b (secape, no character)
28 0x1c small arrow pointing left
29 0x1d arrow both ways (chemistry)
30 0x1e large arrow head pointing up
31 0x1f large arrow head pointing down
32-126 (standard ASCII)
128 0x7f house