Tricks with HAM images

Back in 1985 when the Amiga was first released, the HAM (Hold And Modify) screenmode was revolutionary. It allowed 4096 colours to be displayed simultaneously, meaning near true-colour images could be displayed while only using the amount of memory that a normal 64-colour screen would use.

HAM does have its disadvantages, though – while a regular bitplane image can be faded out very easily by simply fading the palette, this trick doesn’t work for HAM images.

Fading out a HAM image can be done, however, using the Blitter.

This AMOSPro program uses some “evil” trickery to fade a HAM image to black, using the Screen Copy command with blitter modes, peeks and pokes to shuffle bitplanes around between screens, and what amounts to a ShadeBOB routine over the entire screen.

Step by step, the theory of operation is something like this:

  • Logical OR the two control planes together to make a mask plane.  This mask plane is “0” wherever pixels use the base palette, and “1” wherever a direct R, G or B level is being specified.
  • Use the mask plane to perform binary subtraction on the four data planes, using another spare plane to hold carry data.
  • Check for overflow, and zero the image wherever overflow has occurred.

This is done simultaneously with fading out the palette, and the end result is quite a nice fade-out of a HAM image.

Download: Compiled HAM fading slideshow, including AMOSPro source code

3 thoughts on “Tricks with HAM images

      • Thank you. There’s a tech write up that you can also forward to EAB, if you like to ( https://dump.platon42.de/hameager/ ) and it shows that the blitter is very well capable of doing complex math operations (like with the fire cube, it’s an (a+b+c+d)/4 operation on four bits in 21 passes — still faster than doing it in chunky buffer and then using C2P on 68000).

        In Shuffling around the Christmas Tree ( https://www.pouet.net/prod.php?which=90358 ) (among the HAM magic happening here!), I use the blitter to calculate the sprite control words for the snow effect — the CPU would not have been fast enough for the >400 snow sprites.

        In Ramontic Getaway ( https://www.pouet.net/prod.php?which=91259 ) the blitter calculates the copper chunky 12 bit RGB values with saturation (!) from a 3×10 bit deep palette.

        I also have a routine that does signed overflow clipping for 16 bit audio data and conversion to 14 bit playback using the blitter.

        There is so much more possible with the blitter. Have a nice day and keep experimenting.

        Cheers

        Chris

Leave a Reply to Chris Hodges Cancel reply

Your email address will not be published. Required fields are marked *