Image displays using cathode ray tubes (CRT) or the more modern flat panel displays (LCD) work by repeatedly reading out "frames" from digital memory - the framebuffer - using a controller. This is required since the display technology itself cannot store a picture a sufficiently long time for the human eye to perceive a stable picture. The picture is therefore "refreshed" periodically by reading out the framebuffer. Historically the controller for getting the data out of the framebuffer and feeding the display is called a cathode ray tube controller (CRTC). [On the first IBM PCs this has been done using a Motorola MC6845 chip (back then, this chip has been used widely for other display applications as well). Todays VGA cards still have an MC6845 compatible CRTC embedded in their chip sets.]
The organization of the framebuffer, that is how the picture information is stored in the memory and accessed by the host CPU depends on the implementation and programming of the CRTC. picoTK relies on simple frame- buffer layouts, depending on the color depth. The supported color depths are 1, 4 and 8 bits per pixel (bpp). This equals to 1 out of 2, 16 or 256 possible colors per pixel. There is a separate driver for each of these color depths. The number of pixels and the color depth determines the size of the frame- buffer memory, see the following table:
Mode size/bytes 320x240x2 9600 320x240x16 38400 640x480x16 153600
The framebuffer is displayed left to right, up to down. The most left pixel (either 1,4 or 8 consecutive bits) occupies the most significant bit positions in the framebuffer byte. In case of 8bpp one byte simply represents one pixel. The "pixel values" - representing distinct colors - reach from 0 to 1, 0 to 15 and 0 to 255 for 1, 4 and 8 bpp modes respectively. The actual assignment of pixel values to colors depends on how the hardware works.
base+0 base+1 base+39 Line 0 | 76543210 | 76543210 | ... | 76543210 | base+40 base+41 base+79 Line 1 | 76543210 | 76543210 | ... | 76543210 | ... base+9560 base+9561 base+9599 Line 239 | 76543210 | 76543210 | ... | 76543210 |