C64 Character Set Graphics

The Commodore 64 computer is a 64K machine. That means it has the ability to handle up to 64,000 bits of information at a time. On power up, the machine reserves an area in memory known as screen memory that exists between locations 1024 through 2023. If you examine a C64 screen when it is first turned on you will see the startup message splashed across the type and the READY prompt flashing. This means you that Basic has been loaded into memory. Now examine the edge at the top left of the screen. If you could zoom into one character space you would discover that it is actually made up of pixels that are set up in a grid 8 rows across and 8 rows down. Within this area is where the text and other screen graphics can reside.  This is known as the standard character set. A character set is a section in memory that reserves a place where all characters that you can type in, including some color codes, and other things in memory. This is known as the PET ASCii character set. It is often shortened to ASCII (pronounced ASK-EE) phonetically.

The cool thing here is that you are not limited to just using the built in characters and text already built into your machine. Thanks to some amazing engineers at Commodore, they created a segment in memory that allows you to relocate your own graphics. Now in order to do this you do have to move the characters from ROM memory into RAM memory. ROM will not allow you to write to it, so it is very typical to have the computer copy the data contained in that area (containing the C64 character set) into RAM where you can easily overwrite the data that exists there.

Understanding C64 Screen Areas

Now before we begin to alter our own graphics recall that the screen exists between an area in memory that ranges from 1024 through 2023. Each 8×8 block is tracked to these locations sequentially. So the top left screen starts at 1024. The next space over moves into 1025 and continues counting all the way across and down until the last row is occupied at 2023. In Basic if you type in a command such as POKE 1500,1 you will see a character occupy that exact memory area. There is also a separate area reserved for color ram memory. This ranges from 55296 through 56296. Counting at the top left would begin at 55296 and the next space would be 55297 until you count across and all the way down to the bottom right corner at 56296.

Since the Commodore 64 by default loads in a standard character mode, as mentioned your limitation of what can be displayed has restrictions. However, games would never have been made popular without the ability to alter the design of a character set. This means changing an A into a happy face, etc. The point is to line up characters side by side to create pictures and whole maps for player navigation.  Look at many of the popular titles such as Double Dragon, Batman, Robocop, and so on. They contain amazing graphics because they are redefined (or changed into a close representation of the environment) created by the programmer.

In order for this to be accomplished you have to overwrite the data in RAM with the character ROM data. This process is especially slow in Basic, and many programmers have opted to utilize machine language subroutines to speed up the task.

C64 Characters Copied to RAM

The character data is arranged in an 8 x 8 matrix made up of dots (or binary bits). Each dot (bit) can be turned on or off. The Commodore 64 is pulling the character data from ROM currently, until a program has the new data copied into RAM. At that point, it is accessible and can be overwritten to prepare the programmer for design of their own special characters.

If you could take a close peek at the character ROM data you would see that it is made up of individual bits of information. A character set can contain up to 2K (or 2,048 bits of memory), broken down into 8 bytes for each character, and up to 256 (0-255) characters can be modified, once that information is safely in RAM. Below is a simple program written in BASIC that copies a character set from ROM to RAM as found in the book The Commodore 64 Programmer’s Reference Guide.

Please follow and like us: