The color palette can unequivocally identify a computer with a certain aesthetics, think of the vivid but few colors found in the ZX spectrum or the characteristic “1970 type” of colors found in the Atari. Looking beyond those systems we can find artificial palettes like the ones from MSX and ST or realistic type palettes found in the Amiga and SNES. In short, the color palette gives the computer a certain personality.
Choosing a color palette is a big commitment.
Later on, VGA broke that commitment offering a “true color” palette, where you can choose between an universe of 16M colors. But VGA is far beyond the limits of what we would want for an 8 bit computer like Compy, also the memory and CPU speed would make impossible to use that amount of colors.
The approach used by Chroni has the best of both worlds. Let’s choose from a big palette but restrict to a few colors so the CPU and memory can handle those graphics.
64K Global Palette
How many colors can be displayed depends on the Digital to Analog Converter (DAC) used in the computer. Older computers have limited colors because just a few bits were used per RGB channel, and today computers can use many more bits per RGB channel thus giving more color options. For example, using 2 bits per RGB channel allows to have 2³ colors = 8 colors, but using 8 bits per channels allows to have 8³ color = 16M colors.
Chroni is designed to be used through emulation or through FPGA devices. Through emulation we have “true color” (16M), but using FPGA the available devices are more restricted. Of course, we can build our own resistor ladder DAC but if we look at the off the shelf options available, most VGA connectors use RGB 565, which is 5 bits for Red, 6 bits for Green and 5 bits for Blue thus giving 2¹⁶ = 64K colors, more than enough for an 8 bit computer.
In Chroni you define a base palette of 256 colors, but each color is an RGB565 entry, so you pick a subset of a 64K colorspace for your game or program. Using this method you can match any of the existing 8-bit computer palettes and also you can use a palette that didn’t exist on any of those computers.
The computer is not committed to a specific palette, but your program is, so you can define the style of how you want your game to look like. Take a look on this site about how a color palette can define the aesthetics of a movie.
Once you define your 256 color palette, which colors will be used in 4 color mode? or 16 color mode? If a palette entry is a 16 bit value, you won’t be able to easily change a color by writing one byte, you would need to write 2 bytes. Also, switching colors on the fly would require several writes, and that is bad for scanline interrupts, the time available is just too small.
A subpalette is an array of indexes into the main palette. So if you are using a 4 color mode, your subpalette is a 4 byte array with indexes to the main palette. This is very similar of what the Atari had using 4 register for colors, but the big difference is that the 256 color palette in the Atari was fixed, instead Chroni has a user defined 256 color palette.
Spectrum : 16 color fixed palette Atari : 4 color subpalette -> 128 colors fixed palette Chroni : 4 color subpalette -> 256 colors -> RGB565
Sub Palette pointers (attributes)
Now, you can use an entire subpalette for your whole screen but that would restrict you to use up to X color in the whole screen. Of course, scanline interrupts allows you to modify that palette, but what if you want different palletes in one scanline?
Chroni tries to avoid having the CPU to read o write too much into VRAM, so it uses a similar method that was used in the Spectrum, C64 and NES to add more attributes to a certain part of the screen, so you can just make Chroni to point to different subpalettes for one char, one tile or a set of pixels on the screen. The display data will contain the color index for each pixel, using 2 bits for 4 color displays or 16 bits for 16 color displays, another byte is a value that specifies which subpalette is being used for those 4 or 16 colors.
In this abstract example we have 5 tiles, each with 16 colors each. The colors are taken from one of 16 subpalettes available, and each subpalette is an index into the global 256 color palette.
16 color tile -> 16 color subpalette 1 -> 16 color tile -> 16 color subpalette 5 -> 16 color tile -> 16 color subpalette 3 -> 256 color -> RGB565 16 color tile -> 16 color subpalette 2 -> 16 color tile -> 16 color subpalette 9 ->
For now, think that you can create displays with multiple subpalettes without the need of scanline interrupts, and without the need to use the CPU to modify any value. This method will be explained in detail in the Chroni Display Lists post.
Following is an example of the same app using different global palettes