A simple .BMP image to C64 character data converter for Windows

by Phil @ Retroleum

Latest  version v1.00: http://www.retroleum.co.uk/files/utils/c64_charset_converter.zip

Allows images drawn with standard PC paint programs to be converted into
raw Commodore 64 character set data (hi-res and/or multicolour).

Input: A 256 colour mode, uncompressed, Windows format .BMP image
file. The image is scanned in 8x8 pixel blocks from left to right, top to bottom
(so the character patterns need to be aligned on an 8x8 grid).

Output: Raw binary charset data, 8 bytes per character (And optionally
an additional file containing each character's unique colour code,
one byte per character).


* This is for converting character mode data (which have only one unique
  colour per tile, in the range 0-7) and NOT bitmap mode tiles.

* No colour scaling is done, the converter assumes the image has been
  drawn with the C64's palette and limitations in mind.

* "Extended colour mode" is not supported.


1) "Hi-res only" - If this option is ticked, the conversion is in simple hi-res mode,
IE: each source pixel (IE: colour index byte from the .bmp file) produces
a single bit in the C64 char.  You need to select the the colour index (in
the source image) which is required to be treated as background. Colour
indexes 0-15 can be selected from the drop-down list or any value from 0-255
can be manually entered. Any pixel that does not match this index is
treated as a binary 1 for the character definition. Naturally each hi-res
character block can have only one unique colour (colours 0-15).
When this option is NOT selected, the program looks at each block and
based on the pattern, decides whether it is a hi-res or multicolour mode
character (multicolour mode is chosen if the character contains only
double-width pixels). When a character is determined to be multicolour
the two common multicolour register values (as well as background) come
into play. As the converter scans the image:

Source pixels that match the background value are written as a sprite bitpair 00b.
Source pixels that match multicolour 0 are written as a bitpair 01b
Source pixels that match multicolour 1 are written as a bitpair 10b.
Any other colour index is treated as the character's unique colour
and written as a bitpair 11b.

Hi-res and multicolour characters can be mixed in the source image
but remember that only colours 0-7 can be used for the unique colour
for either as bit 3 of the attribute selects multicolour on/off on the C64.

00 - Black
01 - White
02 - Red
03 - Cyan
04 - Magenta
05 - Green
06 - Blue
07 - Yellow

2) "Save colours" - If desired, each character's unique colour
(IE: that used for the non-backround pixels of each) can be saved.
This is only useful if the source image has the C64's original
colours in indexes 0-15. (The converter sets bit 3 of of each
colour's byte the colour file when a character is determined to
be multicolour).

3) "Skip duplicates" - This skips any character definition in the source
image that had already been written to the destination file. When
"save colours" is selected, a character is taken to be different to
one with the same bit pattern if its colour in the source image is
different. If "save colours" is not selected, the colour of the
characters are not taken into account.


The converter works from the palette index values of the source image (0-255)
and is oblivious to the actual colours in the .bmp's palette. Therefore, the
source image does not actually need to have the original C64 colours in
indexes 0-15 (these are suggested by the drop-down menus for when the C64
colours in the correct order HAVE been used in the source image).


00 - Black
01 - White
02 - Red
03 - Cyan
04 - Magenta
05 - Green
06 - Blue
07 - Yellow
08 - Orange
09 - Brown
10 - Pink
11 - Grey 1 (darkest)
12 - Grey 2
13 - Light Green
14 - Light Blue"
15 - Grey 3 (lightest)

If desired, the higher colour indexes (16-255) can be used in the source image EG: for
background, multicolour0 and multicolour1 to avoid any ambiguity when the converter
selects multicolour bitpairs.

For flexibility, the converter does NOT give an error if colours 08-15 are used
as the unique colour of a character when "hi-res only" is not selected.

See test images for examples.