The control codes (my C64 handbook actually calls them ASCII codes) for color changing on the Commodore 64 are as follows:
Color Control Code Color number
BLACK $90 0
WHITE $05 1
RED $1C 2
CYAN $9F 3
PURPLE $9C 4
GREEN $1E 5
BLUE $1F 6
YELLOW $9E 7
ORANGE $81 8
BROWN $95 9
PINK $96 10
DARK GRAY $97 11
MEDIUM GRAY $98 12
LIGHT GREEN $99 13
LIGHT BLUE $9A 14
LIGHT GRAY $9B 15
So, the command PRINT CHR$(5)
for example changes the text color to white. But why are the colors so spread out in the code table? Internally, colors are assigned numbers from 0 (black) to 15 (light gray). The last seven colors from brown to light gray have subsequent codes starting from $95/149, but why has this not been done for all colors? For programming tasks like identifiying a color control code, translating from control codes to color numbers and vice versa this would have been much better.
I first thought that the ASCII standard might have defined places for these control characters, but I could not find color codes in the original ASCII.