Classic Computer Magazine Archive COMPUTE! ISSUE 17 / OCTOBER 1981 / PAGE 30

Floating Color
Floating Screen

If you are writing software for the VIC — either professionally or for your own use — you should include a line in your program which locates the screen and color memories. As it comes from the factory, the VIC screen memory is located at addresses 7680 to 8191. Memory expansion modules are going to be available soon which can add 3 or 8 or 16K to the VIC. The 3K expansion will fill a hole from addresses 1024 to 4095, and will not affect the locations of color or screen memory. Adding an 8 or 16K memory expansion will, however, move these important memories.

What this means is that any programs which manipulate color or screen data (such as the direct POKEs to screen memory used in many games) will not work correctly when the larger two memory expansion modules are added to the VIC. To prevent problems later — to make your programs find VIC's floating screen and color memories — you should add the following formulae which will provide the true addresses:

S (starting address of screen memory)
  S = 4 * (PEEK(36866) AND 128) + 64 * (PEEK(36869) AND 120)
C (starting address of color memory)
C = 37888 + 4 *(PEEK(36866) AND 128)

To use these formulae in your programs, you should enter the two lines above as program lines at the start of your program. (10 S = 4 * (PEEK...etc.) Then, whenever you are working with these memories, simply POKE to S + X or C + X. In other words, use the S and the C instead of a numerical address. For example, to POKE to the tenth screen location, you would POKE S + 10.

Adding a 3K (3072 additional RAM bytes for your use) expansion module will not change any of the normal, expected locations of screen or color memories. It simply fills in a currently empty space from addresses 1024 to 4095. This results in BASIC programs starting at address 1024 (as they do in PETs) instead of the normal VIC starting point, 4096. (See Table 1.) However, adding an 8 or 16K of additional memory floats the screen down to 4096 (from 7680). BASIC RAM floats to a starting address of 4608. And, since one of the bits which governs where screen memory starts also controls color memory, it moves too.

Character Memories

The starting address of the character set memory does not float, so you need not check for it in programs. However, the ability to define alternative character sets is valuable. There are sixteen possible locations in VIC for the start of character set memories. Of these, eight can be used (the others are not allowed). Here's the formula to change the character memory location:

POKE 36869, PEEK(36869) AND 15 OR (X*16)

X will be a number from 0 to 15. Here are the starting locations in memory for several values of X:

X = 0 (32768) this is the normal "default" starting location.

X = 1 (33792) where the upper case reverse characters normally are.

X = 2 (34816) normally the lowercase, unreversed characters.

X = 3 (35840) normally lower case reversed.

X = 4 to 11 (cannot be used).

X = 12 (4096) normally the start of available BASIC RAM.

X = 13 (5020) normally within BASIC RAM.

X = 14 (6144) normally within BASIC RAM.

X = 15 (7168) normally within BASIC RAM.

These last four values of X are where you would usually want to put any specially written character set you've invented.

Table 1. General VIC Map
0–1023 — Operating System and BASIC Overhead
1024–4095 — Empty memory (3K Expansion area)
4096–7679 — BASIC RAM memory
7680–8191 — Screen Memory
8192–32767 — 24K Additional expansion RAM area