Image on a Commodore 64

Letís take your favorite image, and convert it into a C64 high-res image. C64 have multiple graphic modes, here we will modify the character map, then use this map to draw the picture on the screen.

Step 1

We assume that you have set up the C64 development environment. If not, follow step from 1..7 from the "Snake for Commodore 64"

Step 2

We need an image to convert from. There are multiple options; Download an images or draw one yourself.

Optional: There is an image editor for Linux called GIMP, which allows you to manipulate and draw images. It can be installed by;

sudo apt-get install gimp

Step 3

The program the will be used to convert the image into a representation as a C program that could be compiled with C-64 is called Python. Python is a scripting language that have a wide range of libraries, among them Python Image Library (PIL) which allow us to manipulate image.

Copy the following source into an editor (gedit) and save it as image.py

Step 4

Run the program by typing the following;

python image.py yourfile.png

This will write out how many characters you have used to realize your image. If itís 257, then we are in a bit of trouble, since we have to reuse characters to approximate the image.

The script created two files img.h and charmap.h.

img.h contains the definition of the image, while charmap.h contains the definition of the characters used

Step 5

Copy the following C-code into a text file, and save the file as "image.c"

Step 6

Type the following to build it as a C-64 program

cc65 -O -t c64 image.c

ca65 image.s

ld65 -t c64 -o image image.o lib/c64.lib

Then to see the result;

x64 image

Conclusion

There are a large amount of possibilities to improve this program; For instance we could modify it to use colors, we reuse characters smarter.

Donít you just want to make a slideshow with your favorite pictures, on your c64!

For an interactive video guide, contact us post@retrotard.com