VIC-20-PEEK-AND-POKE-COLOR-COMPLEXITY -------------------------------------------------------------------------------------------------- TOOL: COMMODORE VIC-20 - BASIC 2 Language: BASIC Extra: - Author: Misel Zivanovic Note: (C) 29th DEC 2025 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- As we already all should know by now, I am a Commodore C128 guy and know that C64 is pretty much the same in regard to colors. Well, i thought VIC-20 with BASIC 2, same as C64 should not be any different. And that is where i got stuck and also that is where i made a decision to create this little doc for all new Commodore VIC-20 users! Easy-Peasy to change the BORDER- AND SCREEN-COLOR, right! As mentioned both are having BASIC 2.0 Commodore C64: hex $d020, POKE 53280,x = BORDER COLOR hex $d021, POKE 53281,x = SCREEN COLOR {BACKGROUND} Commodore VIC-20: hex $900f, POKE 36879,x = WHAT? Exactly! One address for everything and it is divided in low and high nibble, respectively in BORDER and SCREEN {BACKGROUND} COLOR values. Usually one nibble is half byte, bits 0-3, max. value decimal 15 {bits 0, 1, 2, 3 = 1+2+4+8}, however, here only first 3 bits {0-2} are used for colors which is then ranging from 0 to 7 or 8 colors! Bit number 3 is used to reverse the displaying of the colors {bit 3 off = reverse {inverse}, bit 3 on = normal} Now the remaining 4 bits, namely bit 4, 5, 6, 7 are responsible for screen {background color}. Bit 4 has a value of 16 and that is then our first background {white} color. {0 is black} Perhaps you would now type 17 for the next color and see how nothing would happen! Or better said, it would, however you wouldn't change the SCREEN COLOR! It would effect the BORDER COLOR! Why is that so? Because you touched the first bit {0} which has a value of 1! Adding one to 16 or bit 4 + 1 {bit 0} = 17 In other words, you must avoid impacting the bits 0-2 when you want to change the SCREEN {BACKGROUND} COLORS. How do you do that? Easy, just add a value of bit 4 {16} to get the next {BACKGROUND} COLOR. Example: {not inverse} {BLACK BORDER} {WHITE BACKGROUND} POKE 36879, 8 {normal view} + 0 + 16 To change the BACKGROUND COLOR to RED: {not inverse} {BLACK BORDER} {RED BACKGROUND} POKE 36879, 8 {normal view} + 0 + 32 To change the BACKGROUND COLOR to GREEN: {not inverse} {BLACK BORDER} {GREEN BACKGROUND} POKE 36879, 8 {normal view} + 0 + 80 To change the BACKGROUND COLOR to BLACK: {not inverse} {BLACK BORDER} {BLACK BACKGROUND} POKE 36879, 8 {normal view} + 0 + 0 Or POKE 36879,8 Sure, you don't have to right this way: POKE 36879,8+0+32 because POKE 36879,40 will do the same! POKE 36879,8+A+(B*16) would probably be the smartest solution. A=0-7 {BORDER COLOR} B=0-15 {SCREEN/BACKGROUND COLOR} IMPORTANT TO KNOW: There are 16 colors for the BACKGROUND available, but only 8 for the BORDER COLOR! *************************************************************************************************** What have we not touched yet? You are correct! We managed to change the BORDER and BACKGROUND COLORS... What about CHARACTERS COLORS! C64 is using POKE 646,x and C128 is using POKE 241,x to choose another color for the characters. In addition to that, both are having also a COLOR MAP section where the characters color also can be changed. VIC-20 has the same register to quickly change the character colors as the C64! However, what it also has, is the COLOR MAP, not the 'normal one! It is a dynamic COLOR MAP changing its memory location in dependance of the available memory! Default location, up to 8 KB memory, is $9600, dec 38400, which means POKE 38400,3 will change the color of any character being in that SCREEN memory location {default $1e00, dec 7680} IMPORTANT NOTICE: Beyond 8KB memory {RAM} VIC-20 is moving the COLOR MAP address to $9400, dec 37888. And SCREEN MEMORY is moved to $1000 to $11ff or dec 4096 to 4607. Good to know that when you add VIC-20 Memory Cartridge from MEMORY BLOCK 1 {8KB Slots} {NOTE: Slot 0 is just 3KB and won't impact the default settings} Now the whole truth! Commodore C64 POKE 646,x is almost the same on VIC-20, or better said it is partly the same. POKE 646, x {0 - 7} is the same as when used on C64. But already the POKE 646,8 is a different universe. That bit, namely bit 3, is activating the multicolor low resolution screen! --------------------------------------------------------------------------------------------------- |-----------------------| |VIC-20 COLOR LISTING | |-----------------------| | 00 - Black | | 01 - White | | 02 - Red | | 03 - Cyan | LOW - NIBBLE {00-07}, Bits 0-2 | 04 - Magenta | | 05 - Green | | 06 - Blue | | 07 - Yellow | ------------------- | Bit 3 = INVERSE ON/OFF | 08 - Orange | | 09 - Light Orange | | 10 - Pink | | 11 - Light Cyan | HIGH - NIBBLE {00-15}, Bits 4-7 | 12 - Light Magenta | Even if Bit 4 is a dec value of 16, to set a black screen you need to use Bit 0 | 13 - Light Green | to do so! = POKE 36879,8 will set BORDER & SCREEN to be both black! | 14 - Light Blue | | 15 - Light Yellow | |-----------------------| More in the next lesson!