Hold And Modify (HAM) is a graphics mode on the Amiga computer which allows you to get more colors from the hardware by using two bits from each pixel to control a "hold" and "modify" feature of the base colors. 6-bit HAM (HAM6) used 4 bits for base colors, while 8-bit HAM (HAM8) used 6.

The HAM feature was hacked by Jay Miner, who almost removed from the early model Amiga architecture due to it's slowness. It is fortunate to have survived since it was one of the first graphic modes on a personal computer to show photorealistic images.

It would be awesome if someone could write a really detailed description of how HAM works.

Sadly, my feeble brain can't fully comprehend how HAM works, but I'll have a go at explaining it, plus I do know of some more instances of its use.

HAM is generally implemented by drawing alternate scanlines with different palettes, and then switching around the palettes on the next frame (I think). So, this effectively doubles the number of colours that are drawn to the screen (albeit in an interlaced form, and presumably with a performance hit). But the benefits don't stop there - because the percieved colour for each pixel will now be the combination of two colours from the machine's total colorspace, thanks to the the wonders of optics, the visible palette is not doubled, but squared. (Think of how a full colour image can be created by overlaying three pieces of red, green and blue coloured film.) (yerricde informs me that the effective palette will be more limited than I have stated above because attempting to combine pairs of very diverse colours will result in noticeable flicker.)

Recent Game Boy Color games use HAM, although often in static cutscenes, as the screen and processing power of the machine is not brilliant. Shadow of The Beast on the Amiga used HAM, as did Eternal Champions on the Sega Mega Drive. Sonic 2 uses a variation of HAM to generate the "pseudo hi-res" split-screen two player mode. All the Sonic games use a similar trick to allow levels to show an above- and under-water section with different palettes (drawing the area above water with one palette, and then switching to an alternate palette at the point in the frame where the conveniently-horizontal waterline is hit).

HAM is a major headache for emulator writers, as the code used to implement it gives no indication of the (hardware-reliant) desired effect, plus I guess you'd have to emulate right down to the signal coming out of the machine. KGEN98 seems to have the option to emulate this successfully.

The classic Amiga could display 4096 different colors - 16 levels for each of the Red, Green, and Blue components. It takes 12 bits to represent such a color, but the Amiga couldn't handle more than 6 bits per pixel.

The standard modes used a table of 32 color registers, each of which could be set to any 12-bit value. Then each pixel would store a 5-bit value indicating its index in the color table. You could therefore display any 32 of the 4096 possible colors at the same time (unless you changed the color table values every few scanlines; such tricks could be used to give nice vertical-gradient backgrounds, etc).

HAM (Hold and Modify) mode was a clever trick that allowd the Amiga to display all 4096 colors on the screen at the same time. HAM defined 16 of the color-table registers as "base" colors, and used 6 bits per pixel. The first 2 bits specified the mode of operation. "00" meant to display one of the base colors, and the remaining 4 bits were the color-table index.

Modes of "10", "11", and "01" meant that this pixel's color would be the same as the color of the previously-drawn pixel, except that either the Red, Green, or Blue component would be changed to the value specified by the remaining 4 bits. So, with a black base color, a white pixel could be drawn as follows:

  00 0101  -  Base register #5 (for example), black: 0x000
  10 1111  -  Hold, Modify red to full intensity: 0xF00
  11 1111  -  Hold, Modify green to full intensity: 0xFF0
  01 1111  -  Hold, Modify blue to full intensity: 0xFFF

These intermediate pixels (red and yellow in this example) gave a characteristic color-fringing effect to HAM pictures, but the severity could be reduced with careful choice of the base-register colors.

There was another Amiga 6-bit mode called Extra Half-Bright, but it was rarely used. It was the same as 32-color mode, except the intensity of the color components would be reduced by half if the 6th bit was set.

Later Amiga models had a 24-bit color palette, and a HAM8 mode that used 64 base registers to display hundreds of thousands of colors.

Log in or register to write something here or to contact authors.