HAM can be interpreted as a lossy compression technique, where 12 bit color information is stored in 6 bits of RAM (with reduced quality) and is decompressed through hardware in realtime while the graphics buffer is scanned and displayed.
HAM operates on horizontally sequential pixels on the same display line. The previous pixel's red, green and blue color components are examined. Two of the components are held, one component is modified. Alternatively, all three components can be changed at once, but the color selection is limited to one of 16 colors from the indexed color palette.
The original HAM mode is part of the Original Amiga chipset, available in the first Amigas. With the release of Amigas based on the Advanced Graphics Architecture chipset, HAM was upgraded. The original HAM was renamed "HAM6", and the new "HAM8" mode could display up to what was said to be 262,144 colors on-screen from a palette of 16,777,216, although the actual upper limit could be higher depending on screen resolution.
The Original Amiga chipset and Enhanced Chip Set support 16 distinct levels of red, green and blue color components, giving a grand total of 4,096 possible colors (16 * 16 * 16 = 4096). Each of the 3 components requires 4 bits to store it (16 = 24), so 12 bits are needed to store an entire color.
However, the original and enhanced chipsets only support up to 6 bits per pixel planar screen modes, and features only 32 color registers for the used color palette. Each entry in the palette could be set to one of the full range of 4096 colors. When drawing the screen itself, 5 bits per pixel would give an index into the color palette.
Another Amiga-specific screenmode, Extra Half-Brite, allowed 5 bits per pixel for an index into the 32 color palette and one extra bit to say if the color should be at full or half luminosity. However, this still only allows for 64 colors.
HAM allowed all 4,096 of the Amiga's colors to be displayed. It did so by using 6 bits per pixel; 2 bits were used as decision-making "control" bits, and 4 bits were used as "data" bits. The resulting color for a pixel would be the result of following the instruction of the control bits. The 2 control bits allow for four possibilities, which were as follows:
With the Advanced Graphics Architecture, the Amiga's graphics quality was improved. Instead of 4 bits per color component, the Amiga now had 8 bits per color component, which offered 16,777,216 possible colors. The 6 bits per pixel was raised to 8 bits per pixel, allowing for a 256 color palette in normal operation.
HAM8 worked in the same way as HAM6, using 2 "control" bits per pixel, but now there were 6 bits of "data" per pixel instead of 4. The set operation could now select from a palette of 64 colors instead of 16. The modify operation could modify the 6 most significant bits of either the red, green or blue color component - the 2 least significant bits of the color could not be altered by this operation.
HAM is still only an approximation of truecolor. It can take up to three pixels to change from one color to another, so representing a sharp change in color, such as when digitizing and displaying a photograph, can lead to noticeable multi-hued "fringes" appearing.
Furthermore, the HAM screenmode is difficult to use in games or any other application where the contents of the screen need to be modified. If a "set" pixel is scrolled horizontally off the left hand side of the display, it is no longer drawn; any subsequent "modify" pixels no longer have a base color to modify and start to show the wrong color. This effect makes it difficult to scroll the screen without showing this artifact. The same happens if a "set" pixel is drawn in the middle of a sequence of "modify" pixels, so drawing blitter objects on the screen is very difficult to do without messing up the display.
Hold and Modify came from a trip to see flight simulators in action and I had a kind of idea about a primitive type of virtual reality. NTSC on the chip meant you could hold the hue and change the luminance by only altering four bits. When we changed to RGB I said that wasn't needed any more as it wasn't useful and I asked the chip layout guy to take it off. He came back and said that this would either leave a big hole in the middle of the chip or take a three-month redesign and we couldn't do that. I didn't think anyone would use it. I was wrong again as that has really given the Amiga its edge in terms of the color palette.
Until update 4 HAM is not supported under AmigaOS version 4 on the AmigaOne. This can cause some incompatibilities with some software, later in AmigaOS 4.0 final update HAM6 and HAM8 were fully supported so old Applications can use this mode (like the famous Deluxe Paint from Electronic Arts).