Today I had a lot of client work so rather than dive into more complex parts of my game, I instead tinkered with setting up a custom character set for the C64 version.
Like many retro computers, the C64 allows you to reconfigure the default characterset (kind of like a font) to display special tile graphics in your game.
This is done by adding a character data array chars[]
filled with hex or binary that contains the actual bits for the character definitions that are being loaded into memory.
How it works is:
- First, the character data is loaded into memory at 49152 (0xC000) using
memcpy
- Then the RAM bank is configured to allow access to the character ROM area
- The VIC-II is told to use our custom character set at $2000
- Finally, the cursor character is set to use one of our custom characters
If you are following along at home compile with:
cl65 -t c64 -v -o chars.prg charset-c64.c && x64sc chars.prg
charset-c64.c
#include <stdio.h>
#include <peekpoke.h>
#include <string.h>
#include <conio.h>
// Custom character set data - 8x8 pixel patterns for each character
unsigned char chars[]={
0x5C,0x57,0xE9,0x59,0x39,0x1E,0x14,0x36,
0x10,0x28,0x28,0x44,0x7C,0x44,0xEE,0x00,
0xFC,0x42,0x42,0x7C,0x42,0x42,0xFC,0x00,
0x38,0x44,0x82,0x80,0x82,0x44,0x38,0x00,
0xFC,0x42,0x42,0x42,0x42,0x42,0xFC,0x00,
0xFE,0x42,0x48,0x78,0x48,0x42,0xFE,0x00,
0xFE,0x42,0x48,0x78,0x48,0x40,0xE0,0x00,
0x3C,0x42,0x80,0x8E,0x82,0x42,0x3C,0x00,
0xEE,0x44,0x7C,0x44,0x44,0x44,0xEE,0x00,
0xFE,0x10,0x10,0x10,0x10,0x10,0xFE,0x00,
0x7C,0x10,0x10,0x10,0x90,0x90,0x60,0x00,
0xEE,0x44,0x48,0x70,0x48,0x44,0xEE,0x00,
0xE0,0x40,0x40,0x40,0x42,0x42,0xFE,0x00,
0xEE,0x54,0x54,0x54,0x44,0x44,0xEE,0x00,
0xEE,0x64,0x54,0x54,0x4C,0x4C,0xE4,0x00,
0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x00,
0xFC,0x42,0x42,0x42,0x7C,0x40,0xE0,0x00,
0x38,0x44,0x82,0x82,0x92,0x4C,0x3A,0x00,
0xFC,0x42,0x42,0x42,0x7C,0x48,0xEE,0x00,
0x7C,0x82,0x80,0x7C,0x02,0x82,0x7C,0x00,
0xFE,0x92,0x10,0x10,0x10,0x10,0x38,0x00,
0xEE,0x44,0x44,0x44,0x44,0x44,0x38,0x00,
0xEE,0x44,0x44,0x28,0x28,0x28,0x10,0x00,
0xEE,0x44,0x44,0x54,0x54,0x6C,0x44,0x00,
0xEE,0x44,0x28,0x10,0x28,0x44,0xEE,0x00,
0xEE,0x44,0x28,0x28,0x10,0x10,0x38,0x00,
0xFE,0x84,0x08,0x10,0x20,0x42,0xFE,0x00,
0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,
0x0C,0x12,0x30,0x7C,0x30,0x62,0xFC,0x00,
0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,
0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,
0x00,0x10,0x30,0x7F,0x7F,0x30,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x00,0x00,0x18,0x00,
0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,
0xFE,0xD4,0xAA,0xD4,0xAA,0xD4,0xAA,0x00,
0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00,
0x00,0x00,0x70,0x5E,0x72,0x00,0x00,0x00,
0x08,0x94,0x48,0x2E,0x1A,0x24,0x6C,0x00,
0x06,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,
0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00,
0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00,
0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,
0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30,
0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,
0x00,0x03,0x06,0x0C,0x18,0x30,0x60,0x00,
0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x00,
0x30,0x50,0x90,0x10,0x10,0x10,0xFE,0x00,
0x7C,0x82,0x02,0x7C,0x80,0x82,0xFE,0x00,
0xFE,0x84,0x08,0x1C,0x82,0x82,0x7C,0x00,
0x0C,0x18,0x28,0x4A,0xFE,0x0A,0x1C,0x00,
0xFE,0x82,0xFC,0x02,0x82,0x82,0x7C,0x00,
0x7C,0x82,0x80,0xFC,0x82,0x82,0x7C,0x00,
0xFE,0x84,0x08,0x08,0x10,0x10,0x38,0x00,
0x7C,0x82,0x82,0x7C,0x82,0x82,0x7C,0x00,
0x7C,0x82,0x82,0x82,0x7C,0x04,0x78,0x00,
0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,
0x00,0x00,0x18,0x00,0x00,0x18,0x18,0x30,
0x00,0x7E,0x00,0x3C,0x00,0x18,0x00,0x00,
0xEF,0x8A,0x0C,0x00,0xFE,0xAA,0x80,0x00,
0x00,0x00,0x18,0x00,0x3C,0x00,0x7E,0x00,
0x00,0x3C,0x7E,0xFE,0x7A,0x7E,0xFE,0x7E,
0x00,0x3C,0x7E,0xFE,0x7A,0x7E,0xFE,0x7E,
0x08,0x1C,0x3E,0x7F,0x7F,0x1C,0x3E,0x00,
0x00,0x7E,0xDE,0xFE,0xFE,0xFE,0x7E,0x14,
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x00,0x00,0x00,0xE0,0xF0,0x38,0x18,0x18,
0x18,0x18,0x1C,0x0F,0x07,0x00,0x00,0x00,
0x18,0x18,0x38,0xF0,0xE0,0x00,0x00,0x00,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF,
0xC0,0xE0,0x70,0x38,0x1C,0x0E,0x07,0x03,
0x03,0x07,0x0E,0x1C,0x38,0x70,0xE0,0xC0,
0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0xFF,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,
0x08,0x18,0x99,0x7E,0x3C,0x3C,0x66,0x81,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,
0x36,0x7F,0x6B,0x63,0x2A,0x1C,0x08,0x00,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x00,0x00,0x00,0x07,0x0F,0x1C,0x18,0x18,
0xC3,0xE7,0x7E,0x3C,0x3C,0x7E,0xE7,0xC3,
0x00,0x3C,0x7E,0x66,0x66,0x7E,0x3C,0x00,
0x18,0x3C,0x72,0x62,0x24,0x18,0x3C,0x00,
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0x08,0x1C,0x3E,0x7F,0x3E,0x1C,0x08,0x00,
0x18,0x18,0x18,0xFF,0xFF,0x18,0x18,0x18,
0xC0,0xC0,0x30,0x30,0xC0,0xC0,0x30,0x30,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x00,0x0C,0x02,0x02,0x2C,0x7C,0xEC,0x00,
0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0xCC,0x87,0x30,0x66,0x08,0x93,0xC7,0x46,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x00,0x00,0x00,0x00,0xCC,0xCC,0x33,0x33,
0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x18,0x18,0x18,0x1F,0x1F,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x0F,0x0F,0x0F,0x0F,
0x18,0x18,0x18,0x1F,0x1F,0x00,0x00,0x00,
0x00,0x00,0x00,0xF8,0xF8,0x18,0x18,0x18,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
0x00,0x00,0x00,0x1F,0x1F,0x18,0x18,0x18,
0x18,0x18,0x18,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x18,0x18,0x18,
0x18,0x18,0x18,0xF8,0xF8,0x18,0x18,0x18,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,
0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,
0x0F,0x0F,0x0F,0x0F,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0xF8,0xF8,0x00,0x00,0x00,
0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,
0xF0,0xF0,0xF0,0xF0,0x0F,0x0F,0x0F,0x0F,
0xC3,0x99,0x91,0x91,0x9F,0x99,0xC3,0xFF,
0xE7,0xC3,0x99,0x81,0x99,0x99,0x99,0xFF,
0x83,0x99,0x99,0x83,0x99,0x99,0x83,0xFF,
0xC3,0x99,0x9F,0x9F,0x9F,0x99,0xC3,0xFF,
0x87,0x93,0x99,0x99,0x99,0x93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0,0xE0,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0x07,0x07,0xE7,0xE7,0xE7,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0xFF,0xFF,0xFF,0xE0,0xE0,0xE7,0xE7,0xE7,
0xE7,0xE7,0xE7,0x00,0x00,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0x00,0x00,0xE7,0xE7,0xE7,
0xE7,0xE7,0xE7,0x07,0x07,0xE7,0xE7,0xE7,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x0F,0x0F,0x0F,0x0F,
0xF0,0xF0,0xF0,0xF0,0xFF,0xFF,0xFF,0xFF,
0xE7,0xE7,0xE7,0x07,0x07,0xFF,0xFF,0xFF,
0x0F,0x0F,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,
0x0F,0x0F,0x0F,0x0F,0xF0,0xF0,0xF0,0xF0
};
unsigned int key,i,x,y;
// Initialize the PETSCII character set (0-255) in screen memory
void petscii() {
// Set the screen colours (green on black)
bgcolor(0);
bordercolor(0);
textcolor(5);
// Clear the screen
clrscr();
// Output each character to screen memory
for(i=51200;i<51200+256;i++) {
POKE(i,i-51200);
}
}
void main() {
// Load our custom character set into memory at $C000 (49152)
// This is where the VIC-II will look for character definitions
memcpy(49152,&chars,sizeof(chars));
// Configure the C64's memory layout for custom character set:
// 1. Set up RAM bank for character ROM access
// CIA2 port A (56576) controls RAM bank selection
// Mask with 252 (11111100) to select the correct bank for $C000
POKE(56576,PEEK(57576)&252);
// 2. Configure VIC-II to use our custom character set
// 53272 is the VIC-II control register for character ROM location
// Setting to 32 tells VIC-II to use character ROM at $2000 (8192)
// This points to our custom character set loaded at $C000
POKE(53272,32);
// 3. Set the cursor character to use our custom character set
// 648 is the cursor character location in memory
// Setting to 200 makes cursor use character code 200 from our set
POKE(648,200);
// Output the redefined PETSCII characters to screen memory
petscii();
// Wait for a key press before exiting
key=cgetc();
}
POKE(56576,PEEK(57576)&252)
:- This sets up the RAM bank for the C64
- 56576 is the CIA2 port A register (DDR)
- It's masking the current value with 252 (11111100) to set up the RAM bank for character ROM
POKE(53272,32)
:- This sets the character ROM location
- 53272 is the VIC-II control register
- Setting it to 32 tells the VIC-II to use the character ROM at $2000 (8192 decimal)
- This is where we're loading our custom character set
POKE(648,200)
:- This sets the cursor character
- 648 is the cursor character location in memory
- Setting it to 200 makes the cursor use character code 200 from our custom character set