Hold-And-Modify, usually abbreviated as HAM, is a display mode of the Commodore Amiga computer. It uses a highly unusual technique to express the color of pixels, allowing many more colors to appear on screen than would otherwise be possible. HAM mode was commonly used to display digitized photographs or video frames, bitmap art and occasionally animation. At the time of the Amiga's launch in 1985, this near-photorealistic display was unprecedented for a home computer and it was widely used to demonstrate the Amiga's graphical capability. However, HAM has significant technical limitations which prevent it from being used as a general purpose display mode.
Background
The original Amiga chipset uses a planar display with a 12-bit RGB color space that produces 4096 possible colors.
The bitmap of the playfield was held in a section of main memory known as chip RAM, which was shared between the display system and the main CPU. The display system usually used an indexed color system with a color palette.
The hardware contained 32 registers that could be set to any of the 4096 possible colors, and the image could access up to 32 values using 5 bits per pixel. The sixth available bit could be used by a display mode known as Extra Half-Brite which reduced the luminosity of that pixel by half, providing an easy way to produce shadowing effects.
Hold-And-Modify mode
The Amiga chipset was designed using a HSV (hue, saturation and luminance) color model, as was common for early home computers and games consoles which relied on television sets for display. HSV maps more directly to the YUV colorspace used by NTSC and PAL color TVs, requiring simpler conversion electronics compared to RGB encoding.
Color television, when transmitted over an RF or composite video link, uses a much reduced chroma bandwidth (encoded as two color-difference components, rather than hue + saturation) compared to the third component, luma. This substantially reduces the memory and bandwidth needed for a given perceived fidelity of display, by storing and transmitting the luminance at full resolution, but chrominance at a relatively lower resolution - a technique shared with image compression techniques like JPEG and MPEG, as well as in other HSV/YUV based video modes such as the YJK encoding of the V9958 MSX-Video chip (first used in the MSX2+).
The variant of HSV encoding used in the original form of HAM allowed for prioritising the update of luminance information over hue and particularly saturation, switching between the three components as needed, compared to the more regular interleaving of full-resolution luma () with individual half- or quarter-resolution chromas ( + ) as used by later digital video standards. This offered considerable efficiency benefits over RGB.
As the Amiga design migrated from a games console to a more general purpose home computer, the video chipset was itself changed from HSV to the modern RGB color model, seemingly negating much of the benefit of HAM mode. Amiga project lead Jay Miner relates:
The final form of Hold-And-Modify was, hardware-wise, functionally the same as the original HSV concept, but instead of operating on those three descriptive components (mostly prioritising the V component), it modifies one of the three RGB color channels. HAM can be considered a lossy compression technique, similar in operation and efficiency to JPEG minus the DCT stage; in HAM6 mode, an effective 4096-color (12-bit) playfield is encoded in half the memory that would normally be required - and HAM8 reduces this still further, to roughly 40%. There is a however a payoff for this simplistic compression: a greater overall color fidelity is achieved at the expense of horizontal artifacts, caused by the inability to set any single pixel to an arbitrary 12- (or 18, 24) bit value. At the extreme, it can take three pixels to change from one color to another, reducing the effective resolution at that point from a "320-pixel" to approximately "106-pixel" mode, and causing smears and shadows to spread along a scanline to the right of a high contrast feature if the 16 available palette registers prove insufficient.
"Decompression" of the HAM encoded color space is achieved in realtime by the display hardware, as the graphics buffer data is being displayed. Each encoded pixel acts as either a normal index to the color palette registers, or as a command to directly alter the value held in the output DAC (somewhat like updating just one-third of the active palette register), and is immediately acted on as such as it passes through the chipset.