Without resorting to creating sprites, the standard Commodore 64 BASIC programme has access to a standard character set, consisting of the basic alphanumeric characters, and a shifted set of extended graphics. These are all very well and good, but they're not very exciting. You can draw boxes and lines and maybe even a pyramid or two, but no cosmic space invaders or jiggling breasts, which, let's face it, is what we really want. What we need to be able to do is fiddle around with the character set and make our own font.

With the help of some graph paper, some bitwise mathematics and the all powerful POKE command, the following code will read a block of numerical DATA representing your new characters, and place it into the portion of memory that the Commodore 64 uses to store it's default character set. You can, therefore, run this code at the beginning of your application to turn the letter A into an alien spaceship, B into a smiley face, or whatever your heart desires. But first, you're going to have to work out what your new characters are going to look like, and from that, work out what the numerical representation of these characters are.

Designing your new character set

In order to create a new character, you need to sketch it out first on a grid. As I'm sure you are aware, everything on a computer (or even a television) screen is made up of tiny squares, called pixels. These pixels are either lit or unlit, and the pattern thy form makes up the image you see. Each Commodore 64 character is a fixed size, eight pixels tall by eight pixels wide, so you need to draw a grid that is eight by eight, sixty-four boxes in total. You should number the boxes along the top 1, 2, 4, 8, 16, 32, 64 and 128. You should end up with something that looks a little like this:

  001|002|004|008|016|032|064|128
 .-------------------------------.
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 '-------------------------------'
Into this grid, you should shade in the boxes you need to in order to make your new character. Let's make a smiley face:
  001|002|004|008|016|032|064|128
 .-------------------------------.
 |   |   |XXX|   |   |XXX|   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |
 |---+---+---+---+---+---+---+---|
 |   |XXX|   |   |   |   |XXX|   |
 |---+---+---+---+---+---+---+---|
 |   |XXX|   |   |   |   |XXX|   |
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |
 |---+---+---+---+---+---+---+---|
 |   |   |   |XXX|XXX|   |   |   |
 '-------------------------------'
Okay, so the ASCII art ain't too hot, but you get the idea. Now, in order to work out what numerical values we need to POKE into memory, we're going to use the numbers at the top of our grid to do a bit of math. For each row, read across the line, and add up the numbers corresponding to the shaded squares, and make a note of the total at the end of the row. You should end up with something like this:
  001|002|004|008|016|032|064|128
 .-------------------------------.
 |   |   |XXX|   |   |XXX|   |   |  004 + 032 = 036
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |  004 + 032 = 036
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |  004 + 032 = 036
 |---+---+---+---+---+---+---+---|
 |   |   |   |   |   |   |   |   |            = 000 
 |---+---+---+---+---+---+---+---|
 |   |XXX|   |   |   |   |XXX|   |  002 + 064 = 066
 |---+---+---+---+---+---+---+---|
 |   |XXX|   |   |   |   |XXX|   |  002 + 064 = 066
 |---+---+---+---+---+---+---+---|
 |   |   |XXX|   |   |XXX|   |   |  004 + 032 = 036
 |---+---+---+---+---+---+---+---|
 |   |   |   |XXX|XXX|   |   |   |  008 + 016 = 024
 '-------------------------------'
You should now have eight numbers, one for each row. It's these numbers that make up your character, and it's these that get POKEd into memory. To make these numbers work with the following code, just add the command DATA in front of your eight numbers, and separate them by commas, and replace the example values in lines 300 onwards.

The source code

I've included example DATA for the letters A through I, starting from line 300. If you have defined more or less characters than nine, you will need to change the value of CC on line 220 to match the number of characters you have. The starting value of one on the same line means that the DATA will start overwriting characters from A onwards - if you want to start later in the alphabet, just change this value. One other thing to note: on line number 100, the ♥ symbol represents the shift-clear screen command, which should look like an inverted heart when you type it.

000 REM ** USER DEFINED GRAPHICS **
001 REM ** BY SHANE JOLLY **
100 PRINT "♥": PRINT TAB(12)"PLEASE WAIT..."
110 PRINT CHR$(142)
120 POKE 52, 48: POKE 56, 48
130 POKE UG=12288;CG=53248
140 POKE 56334, PEEK(56334) AND 254
150 POKE 1, PEEK(1) AND 251
160 FOR K=1 TO 2047
170 POKE UG+K, PEEK(CG+K)
180 NEXT
190 POKE 1, PEEK(1) OR 4
200 POKE 56334, PEEK(6334) OR 1
210 POKE 53272, (PEEK(53272) AND 240)+12
220 FOR CC=1 TO 9
230 FOR J=0 TO 7
240 READ A: POKE UG+8*CC+J, A
250 NEXT J
260 NEXT CC
270 FOR N=65 TO 90
280 PRINT CHR$(N);" ";
290 NEXT N
300 DATA 000, 016, 040, 068, 124, 068, 068, 000
310 DATA 000, 120, 072, 124, 068, 068, 124, 000
320 DATA 000, 124, 068, 064, 064, 068, 124, 000
330 DATA 000, 120, 068, 068, 068, 068, 120, 000
340 DATA 000, 124, 068, 112, 112, 068, 124, 000
350 DATA 000, 124, 068, 112, 064, 064, 064, 000
360 DATA 000, 124, 068, 064, 064, 078, 124, 000
370 DATA 000, 068, 068, 124, 124, 068, 068, 000
380 DATA 000, 056, 016, 016, 016, 016, 056, 000

Phew! That's a lot of boring numbers to type out. If you were feeling very clever indeed, you could write some kind of editor that would output the numbers for you. The real fun comes now. Use the standard RUN command to set the programme in motion, twiddle your thumbs whilst the Commodore fiddles with it's memory, then see how your characters look on-screen.

Copyright notice

I found the code that changes the character set stuck in an old notebook of mine, a relic years ago when I owned my first Commodore 64. It looks like it was torn from a magazine, which probably means that it came from Commodore Format, a brilliant Commodore magazine that ended it's run around 1996. The code is evidently by a man named "Shane Jolly", who doesn't seem to claim any copyright to his work. Assuming I am correct in my assumption that the snippet came from Commodore Format, then any copyright would be held by Future Publishing.

Log in or register to write something here or to contact authors.