Many retro computing enthusiasts, especially those inspired by channels like “The 8-Bit Guy,” delve into the fascinating world of Commodore 64 programming. One intriguing aspect is customizing the character set, allowing you to replace standard characters with your own creations. Let’s break down a fundamental BASIC program for character redefinition and understand the underlying logic.
The following BASIC code snippet is designed to modify the Commodore 64 character set:
0 REM tells the VIC to use 7168 as the start of the character set
10 POKE 36869, 255
11 REM and the rest is redefining my characters!
12 REM first, the smiley-face from the 8-bit guy's Commodore History video
20 POKE 7168, 126
30 POKE 7169, 129
40 POKE 7170, 165
50 POKE 7171, 129
60 POKE 7172, 165
70 POKE 7173, 153
80 POKE 7174, 129
90 POKE 7175, 126
100 REM next, a skate (my profile icon on most forums lol)
110 POKE 7176, 192
120 POKE 7177, 192
130 POKE 7178, 224
140 POKE 7179, 254
150 POKE 7180, 255
160 POKE 7181, 255
170 POKE 7182, 195
180 POKE 7183, 126
This program aims to replace the ‘@’ symbol with a smiley face and the ‘A’ symbol with a skate icon. The key questions that arise are: How does POKE 36869, 255
initiate the character set change and where is the character RAM located when using the full 32K of memory?
Line 10, POKE 36869, 255
, is crucial for switching to the custom character set. Address 36869 (or $9005 in hexadecimal) controls the video interface chip (VIC-II) memory mapping. Specifically, bit 0 of this address determines which character ROM is used. When you POKE 36869, 255
, you are setting all bits to 1. In binary, 255 is 11111111
. The important part is bit 0 being set to 1. This setting instructs the VIC-II to use the character set located in RAM starting at memory address 7168 ($1C00). It doesn’t directly “give it 7168,” but rather it configures the VIC-II to look at memory location 7168 for character data instead of the built-in ROM. Numbers like 240 or 242, when POKEd into 36869, likely clear bit 0, thus selecting the standard ROM character set. These numbers aren’t random; they are bit patterns that control hardware functions.
Regarding the location of character RAM in a 32K expanded system, the principle remains the same. Even with 32K RAM, the VIC-II is still configured via memory mapping. The character RAM, when switched to the user-defined set using POKE 36869, 255
, will still begin at 7168 ($1C00). The extra RAM in a 32K system is typically mapped to different memory regions, not directly affecting the base address of the character RAM when you’ve configured the VIC-II to use the RAM-based character set. The blinking smiley cursor you observed in the 7100-8100 range further confirms that the character RAM is indeed in that vicinity, regardless of the total RAM installed.
The subsequent POKE
commands from line 20 onwards (e.g., POKE 7168, 126
) are defining the actual pixel data for your custom characters. Each character is defined by 8 bytes, starting from the base address (7168 in this case). Therefore, POKE 7168, 126
defines the first byte of the first custom character (which replaces ‘@’ because ‘@’ is the first character in the upper range when you switch character sets this way). Each byte represents a row of pixels for the character, with bits corresponding to pixels being on or off.
In conclusion, modifying the Commodore 64 character set involves understanding memory mapping and the VIC-II chip’s control registers. Inspired by figures like The 8-Bit Guy, exploring these low-level programming aspects reveals the ingenuity of early home computer systems and provides a rewarding journey into retro computing.