|This article needs additional citations for verification. (April 2011)|
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.
Overview of Amiga Chip Set
The original Amiga chipset uses a planar display with a 12-bit RGB color space (4096 possible colors). In order to describe any arbitrary color in this color space 12 bits are needed (4 bits per color component). However, the chipset can only access up to 6 bits per pixel in a part of memory known as 'chip RAM'. All display modes use an indexed color system with a color palette, where each palette entry can be set to one of the available 4096 colors. As the original chipset only has 32 color registers other techniques must be used to express more than 32 on-screen colors.
A display mode known as Extra Half-Brite uses 5 bit planes to index entries from the 32 color palette, and an extra sixth bit plane to control whether the color should be displayed at full or half luminosity. This allows the sixth bit plane to indicate shadows. With judicious selection of the palette, 64 distinct colors may exist on screen, though this is still far fewer than the full 4096.
The original HAM mode allows all 4096 colors to be displayed using just six bitplanes. The color of each successive pixel on a scan line is defined as either a selection from a 16 color palette, or as a modification of the color of the previous pixel (palette entry zero if the first pixel on a scan line is a modified pixel). In the latter case, only one of the color components (red, green, or blue) may be modified per pixel. Two of the color components are 'held', and one component is 'modified', hence the name Hold-And-Modify.
HAM can be considered a lossy compression technique. Under HAM6 mode the playfield is encoded in half the memory normally required for a 12-bit color space. The greater overall color fidelity is achieved at the expense of horizontal chroma resolution. The image is 'decompressed' by display hardware in realtime as the graphics buffer is being displayed.
|“||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.||”|
Original Chip Set HAM mode (HAM6)
HAM6 mode was introduced with the Original Chip Set and was retained in the later Enhanced Chip Set and Advanced Graphics Architecture. HAM6 allows up to 4096 colors to be displayed simultaneously at resolutions from 320×200 to 360×576. HAM6 uses 6 bitplanes, meaning that the buffer employs 6 bits per pixel to encode color. In comparison, an unrestricted 4096 color display would normally be encoded in 12 bits per pixel and use twice as much memory and bandwidth.
HAM6 encoding operates as follows. An indexed palette of 16 arbitrary base colors is defined. Each pixel is represented by 6 bits, where 2 bits are used as decision-making "control" bits, and 4 bits are used as "data" bits. The resulting color for each pixel is determined by the bit settings. The two control bits allow for four possibilities:
- Set: Use the 4 bits of data to index a color from the 16 color palette. Use that color for this pixel.
- Modify Red: Hold the green and blue color components of the previous pixel. Use the 4 bits of data as the new red color component of this pixel.
- Modify Green: Hold the red and blue color components of the previous pixel. Use the 4 bits of data as the new green color component of this pixel.
- Modify Blue: Hold the red and green color components of the previous pixel. Use the 4 bits of data as the new blue color component of this pixel.
A similar mode, HAM5 is also available but not as flexible nor widely used.
Advanced Graphics Architecture HAM mode (HAM8)
With the release of the Advanced Graphics Architecture (AGA) in 1992, the original HAM mode was renamed "HAM6", and a new "HAM8" mode was introduced (the numbered suffix reflecting the bitplanes used by the respective HAM mode). With AGA, instead of 4 bits per color component, the Amiga now had up to 8 bits per color component, resulting in 16,777,216 possible colors (24-bit color space).
HAM8 operated in the same way as HAM6, using two "control" bits per pixel, but now with six bits of "data" per pixel instead of four. The set operation selects from a palette of 64 colors instead of 16. The modify operation modifies the six most significant bits of either the red, green or blue color component - the two least significant bits of the color cannot be altered by this operation.
Compared to HAM6, HAM8 can display many more on-screen colors. The maximum number of on-screen colors using HAM8 was widely reported to be 262,144 colors (18-bit color space), but the actual amount can in fact be greater (depending on the two least significant bits of each color component in the 64 color palette). In general, the perceived colour depth is roughly equivalent to a high color display. The vertical display resolutions for HAM8 are the same as for HAM6. The horizontal resolution can be 320 (360 with overscan) as before, doubled to 640 (720 with overscan) or even quadrupled to 1280 pixels (1440 with overscan). The AGA chipset also introduced even higher resolutions for the traditional planar display modes. The total number of pixels in a HAM8 image cannot exceed 829,440 (1440*576) using PAL modes but can exceed 1,310,720 (1280x1024) using third-party display hardware (Indivision AGA flicker-fixer).
Like the original HAM mode, a HAM8 screen cannot display any arbitrary color at any arbitrary position, since every pixel relies on either a limited palette or relies on up to two color components of the previous pixel. As with the original HAM mode, designers may also choose to 'slice' the display (see below) in order to circumvent some of these restrictions. A HAM7 mode is also available but not widely used.
Sliced HAM mode (SHAM)
Sliced HAM mode, also known as dynamic HAM mode uses the Amiga's standard HAM6 color mode, 6-bitplanes (4 bitplanes for the base colour palette of 16 colors and 2 bitplanes for modifying the base colors). It requires the use of the 'copper' coprocessor to increase the number of colors available on screen to the full 4096 palette by reprogramming the color registers every scanline. Slicing was common when using copper graphics in demos, image manipulation, and certain games. It is also possible to reprogram color registers at arbitrary points along individual scanlines, meaning that individual scanlines can be sliced in the same way.
SHAM expands the colour palette of the overall screen, each scan line can have a unique 16 colour base palette from 4096 possible colors. The advantage of SHAM mode is in having a more precise representation of the image's intended colors, since it would not be limited by the palette choices made for the previous scanline, thus helping to reduce HAM6 colour fringing that occurs more often when an image uses just a single 16 colour base palette for all scan lines.
Dynamic HiRes uses a similar palette changing technique. Where SHAM is limited to low resolution HAM modes, Dynamic HiRes uses the 4bitplane (16 colour) high resolution modes. Each scan line can have a unique 16 colour palette. Unlike the low resolution HAM6 modes, the hires screen modes of the original chipset have no ability to modify the base colors to get more than 16 colors per scan line.
The SHAM idea was deprecated when HAM8 was introduced, since even an unsliced HAM8 image has far more color resolution than a sliced HAM6 image. However, SHAM remains the best available HAM mode on those Amigas with the original chipset.
Modern graphics hardware does not have an Amiga-style copper, so in order to correctly display sliced HAM images, the Amiga hardware must be emulated. The programming required to do this can be computationally expensive, since to emulate a screen that is arbitrarily sliced, the only way to make certain that the emulation is correct is to emulate every bus cycle. However, if the goal is merely to display a SHAM image on a non-Amiga platform, the required color values may be pre-calculated based on the palette entries that are programmed via the copper-list, regardless of whether the palette is modified in the middle of a scanline.
Slicing an image no longer has any practical value on modern graphics hardware, since the color fidelity and bandwidth of modern hardware do not impose the limitations that slicing is designed to circumvent.
Limitations of HAM
HAM mode places restrictions on the value of adjacent pixels on each horizontal line of the playfield. In order to render two arbitrary colors adjacently, it may take up to two intermediary pixels to change to the intended color (if the red, green and blue components must all be modified). In the worst case this reduces the horizontal chroma resolution from 704 pixels to as low as 240 (for comparison, contemporary technologies LaserDisc and VHS had chroma resolutions of 40 at 0.4 MHz). This problem is particularly noticeable at areas of sharp contrast (strong horizontal image gradients), where an undesirable multi-hued artifact or "fringe" may appear. Various rendering techniques were used to minimize the impact of "fringing" and HAM displays were often designed to incorporate subtle horizontal color gradients, avoiding vertical edges and contrasts.
Additionally, HAM mode does not easily permit arbitrary animation of the display. For example, if an arbitrary portion of the playfield is to be moved to another on-screen position, the Hold-and-Modify values may have to be recomputed on all source and target lines in order to display the image correctly (an operation not well-suited to animation). Specifically, if the left-most edge of the animated object contains any 'modify' pixels, or if the image immediately to the right of the object contains any 'modify' pixels, then those Hold-and-Modify values must be recomputed. An attempt to move an object around the screen (such as with the use of the blitter) will create noticeable fringing at the left and right borders of that image, unless the graphics are specially designed to avoid this. In order to avoid recomputing Hold-and-Modify values and circumvent fringing, the programmer would have to ensure the left-most pixel of every blitter object and the left-most pixel of every line of a scrolling playfield is a 'set' pixel. The palette would have to be designed so that it incorporates every such left-most pixel. Alternatively, a HAM display can be animated by generating pixel values through procedural generation, though this is generally useful for synthetic images only, for example, the 'rainbow' effects used in demos.
Note, however, that Hold-and-Modify only applies to playfield pixels. 128 pixels of sprite data (in DMA mode) per scanline are still available for placement on top of the HAM playfield.
HAM is unique to the Amiga and its distinct chipsets. To allow rendering of legacy images encoded in HAM format software-based HAM emulators have been developed which do not require the original display hardware. Pre-4.0 versions of AmigaOS can use HAM mode in the presence of the native Amiga chipset. AmigaOS 4.0 and up, designed for radically different hardware, provides HAM emulation for use on modern chunky graphics hardware. Dedicated Amiga emulators running on non-native hardware are able to display HAM mode by emulation of the display hardware. However, since no other computer architecture used the HAM technique, viewing a HAM image on any other architecture requires programmatic interpretation of the image file. Faithful software-based decoding will produce identical results, setting aside variations in color fidelity between display setups.
When the Amiga was launched in 1985, HAM mode offered a significant advantage over competing systems. HAM allows display of all 4096 colors simultaneously, though with the aforementioned limitations. This pseudo-photorealistic display was unprecedented for a home computer of the time and allowed display of digitized photographs and rendered 3D images. In comparison the then IBM-PC standard EGA allowed 16 on-screen colors from a palette of 64. EGA's successor VGA released in 1987 with its flagship games mode, Mode 13h, allowed 256 on-screen colors from 262,144. HAM mode was frequently used to demonstrate the Amiga's ability in store displays and trade presentations, since competing hardware could not match the color depth. Due to the limitations described above HAM was mainly used for display of static images and developers largely avoided its use with games or applications requiring animation.
With the introduction of the Advanced Graphics Architecture a conventional planar image could have a palette of 256 colors with significantly higher color fidelity. Arguably, the original HAM mode with its limited color resolution became far less attractive to users of an AGA machine, though it was still included for backward compatibility. The new HAM8 mode was arguably far less useful to the AGA chipset than the HAM mode was to the original chipset, since a planar 256-color palette greatly increased the options to the artist without suffering from the drawbacks of HAM mode. A well-programmed sliced planar mode could prove to be more useful than HAM8. The original purpose of HAM, which was to allow more color resolution despite limited video buffer size and limited memory bandwidth, was no longer as relevant.
As modern computers are capable of high resolution truecolor displays there is no longer any need for display techniques like HAM. Planar graphics are now also obsolete for general purpose computing, since modern graphics hardware has enough memory bandwidth to used packed pixels.
Third-party HAM implementations
A device produced by Black Belt known as HAM-E was able to produce images with HAM8 color depth at low horizontal resolution from an Amiga with an Original Chipset.
The Amiga would be set up to produce high resolution images (640 pixels wide, 720 with overscan). This required the use of four bitplanes at 70 ns per pixel. The first few lines of the image encoded information to configure the HAM-E unit. Then each pair of pixels was encoded with information for the HAM-E unit, which converted the information into one 140 ns pixel (generating an image 320 pixels wide, or 360 with overscan, at a color depth of eight bitplanes). The quality of HAM-E was thus comparable to a low-resolution HAM8 image. The HAM-E technique exploited the fact that a high resolution image with four bitplanes delivers a third more memory bandwidth, and therefore a third more data, than a low resolution image with six bitplanes.
- Commodore-Amiga, Inc. (1991). Amiga Hardware Reference Manual. Amiga Technical Reference Series (Third ed.). Addison-Wesley. ISBN 0-201-56776-8.
- Standards and specs: The Interchange File Format (IFF) (See HAM and Cheese)
- Black Belt HAM-E
- Specification for the Advanced Amiga (AA) Chip Set, Commodore-Amiga