Converting an animated GIF to multicolor C64 sprites

Recently I stumbled upon a nice little GitHub project that converts animated GIFs to Commodore 64 sprites. That tool converts to high resolution sprites, so I wrote a .NET tool that converts to multicolor sprites.

As described by C64-Wiki, in multicolor sprites the bits are grouped in pairs, and since each such multicolor pixel is defined by two bits of data rather than one, each pixel can do one of four things:

Thus each color corresponds to a specific delegate that takes the bit position of the pixel and returns a value to add to the byte that the pixel belongs to:

public static IDictionary<C64Colors, Func<int, int>> ToByteAdds(this ColorsString colorsString) =>
    new Dictionary<C64Colors, Func<int, int>>
    {
        {colorsString.Value[0].ToC64Color(), x => 0},
        {colorsString.Value[1].ToC64Color(), x => (int)Math.Pow(2, 6 - x)},
        {colorsString.Value[2].ToC64Color(), x => (int)Math.Pow(2, 7 - x) + (int)Math.Pow(2, 6 - x)},
        {colorsString.Value[3].ToC64Color(), x => (int)Math.Pow(2, 7 - x)}
    };

In this method, colorsString is a four characters string of hex numbers defining the color in each of the registers $d020, $d025, $d026, $d027.

Party Parrots

Party parrots in Slack are animated drawings of Sirocco the kakapo parrot. I converted some of the lovely parrots on http://cultofthepartyparrot.com/ and let these little fellas slide in to the screen.

The result was pretty funny:

The repo contains a simple C64 demo so you can go try it out yourself!