Egghead.page Logo

Commodore 64 VIC-II Background Color Register Address

This article identifies the specific memory register within the VIC-II video chip responsible for setting the background color on the Commodore 64. It details the hexadecimal and decimal addresses used by programmers to modify the screen’s backdrop hue during operation.

The VIC-II Chip and Memory Mapping

The Commodore 64 relies on the MOS Technology VIC-II chip to generate its video output. This chip manages sprites, characters, and colors through a series of memory-mapped registers. These registers are accessible to the CPU via specific memory addresses, allowing software to control visual properties in real time. Among these controls, the background color is one of the most fundamental settings for defining the look of the screen.

Specific Register Address

The register that controls the global background color is located at hexadecimal address $D021. In decimal notation, this corresponds to memory location 53281. Writing a value to this address changes the color of the screen area behind the text and sprites. This register is part of the VIC-II’s I/O block, which resides in the upper region of the C64’s memory map.

Using the Register in BASIC

For users programming in Commodore 64 BASIC, modifying the background color is achieved using the POKE command. The syntax requires the decimal address followed by the desired color code. For example, the command POKE 53281, 6 sets the background color to pink. The value written to the register must be between 0 and 15, representing the sixteen available colors in the C64 palette. Values outside this range may result in undefined behavior or mirror effects depending on the hardware revision.

Color Values and Limitations

Each number from 0 to 15 corresponds to a specific color, such as black, white, red, or cyan. While this register controls the main background, other registers manage border color and character colors. The background color register affects the entire screen uniformly unless multicolor mode or specific raster interrupts are utilized to change the value mid-frame. Understanding this register is essential for developers creating games or demos that require dynamic screen color changes.