Petit Computer Wiki
Advertisement

V1

Indications are, COLSET in SmileBasic V1 is identical to that in V2.

V2

COLSET is a command which alters which colours are available to the graphics system. It has three parameters. The first is a string, and should be "BG", "SP", or "GRP" (anything else results in Illegal function call (COLSET) error). The second is a number, which is rounded down to an integer, and the rounded value should be between 0 and 255 inclusive (anything else results in Out of range (COLSET) error).  The third is a string of six hexadecimal characters (upper and lowercase are both permitted). Any string of fewer than 6 characters generates an Illegal function call error, as will a string of 6 characters which are not all hexadecimal values. Some strings longer than 6 characters will also give an Illegal function call error, but others will cause the system to entirely stop responding (precisely which ones, under which circumstances, is not clear).

The first pair of hexadecimal digits refers to an intensity of red, the second pair to an intensity of green, and the third pair to an intensity of blue. Though there is 8 bits of accuracy in a pair of hexadecimal digits, the red and blue values are only stored to 5 bits of accuracy, and green is stored to 6 bits of accuracy. So, for example, if "03" is used in COLSET, then COLREAD on the colour will give a result of 0, but if "08" is used, COLREAD will give the value 8.

The following tables give the relationship between values written using COLSET, and values read using COLREAD.

For R or B values:

COLREAD 08162533414958 6674829099107115123 132140148156165173181189 197206214222230239247255
COLSET 0 to 78 to 1516 to 2324 to 3132 to 3940 to 4748 to 5556 to 63 64 to 7172 to 7980 to 8788 to 9596 to 103104 to 111112 to 119120 to 127 128 to 135136 to 143144 to 151152 to 159160 to 167168 to 175176 to 183184 to 191 192 to 199200 to 207208 to 215216 to 223224 to 231232 to 239240 to 247248 to 255

The above table can be summarized as follows. For any value on the bottom row, round it down to the nearest multiple of 8, multiply by 255/248, then round to the nearest integer. For G values, there is a similar table, except the steps are to round down to the nearest multiple of 4, multiply by 255/252, then round to the nearest integer.

(This kind of conversion happens when you wish to quantize a range of values to a smaller set: the set of values 0 to 255 is divided into equal partitions, and each partition is given an integer number spaced as evenly as possible so the lowest is 0 and the highest is 255. Consider the smaller example of the range from 0 to 7, partitioned into 4 sets. Each set will be two numbers: {0, 1}, {2, 3}, {4, 5}, {6, 7}. The lowest number is 0, the highest is 7, there are 4 partitions, so the most regular way to associate numbers with the partitions is 0, 2, 5, 7. So, 0 to 1 becomes 0, 2 to 3 becomes 2, 4 to 5 becomes 5, and 6 to 7 becomes 7.)

V3

No information on SmileBasic V3.

Advertisement