Friday, June 23, 2017

Image Rendering and Animation

Let's hope not all humans are that ugly  --  probably some Axacutian


This post will be about the compression algorithm used for the graphics and how it plays into the animation system of Supernova.
The images consist of a custom palette of 239 colors and divided up into sections that define its size and a pointer to the image data. An exception to this are the newspaper articles, seen in the intro of the game.


Those bitmap images have dimensions of 640x480 and only monochrome colors, instead of 256-colors palettized 320x200. The difference in their encoding can be seen here in the code. So, for the mode 0x11 images I mask the bits of a byte and depending if the bit is set 0 (Black) or 11 (63% White) is written. It is safe to use palette colors as the first 16 colors of the default palette, defined here, won't be overwritten by an image's custom palette.

Mode 0x13 images that make up the rest of the game's graphics are compressed in a run-length encoding (RLE) and are 320x200 256-color palettized. The following describes the structure of the file format


The image decoding part can be found here. It works more or less like this:
The encoded image is read into a variable 'input' byte by byte

        - If input < numRepeat, write the next value read input-times
        - If input < numZw, write the (input - numRepeat)th value of 'twin-value
          array' twice
        - Otherwise, write input value directly

The success of this simple way of compression depends on how monotonous the image is. The less color changes happen in a scanline the better the compression.

 

Sections, as already mentioned, describe an image section that most of the time shows objects in different states of interaction, like an opened or closed door, by redrawing only part of the base image (section 0).
As you can see in the video, sections 7, 8 and 9 are the frames for the animation of the 'slide door' to the airlock. And that's the whole trick. Well, a door sliding open in 3 frames is not that impressive, so I composed a video with 3 scenes from the game that meet your expectations a bit more when you hear the word 'animation'




No comments:

Post a Comment