6502 Assembly programming for the Vic 20

The predecessor to the C64, the Vic-20 is an early 8 bit system, based around character graphics, it's far more limited than the C64, but still capable of some decent results, and is far better than the ZX-81 of the time.

Due to it's memory limitations, we won't be using the Vic-20 as much as some other systems, but there's still plenty of impressive stuff this early machine can do!
We'll be covering the Atari 5200 console, and Atari 800 home computer in these tutorials.

Cpu 1 mhz 6502
Ram 5k 
Resolution 176*184
Sound 3 tone + 1 noise
Screen Colors
border and background color are set by memory address $900F... it's format is BBBISSS
Bits 0-2 (S) set the Screen background
Bit 3 sets Inverted or Normal mode - effectively this is usually on (so add 8 to all values)

Colors are defined as 0-F, as shown in the chart below

0 1 2 3 4 5 6 7
8 9 A B C D E F


Background colors
border and background color are set by memory address $900F... it's format is BBBISSS
Bits 0-2 (S) set the Screen background
Bit 3 sets Inverted or Normal mode - effectively this is usually on (so add 8 to all values)
Bits 4-7 set background color

The effective options are:

Border
 Background    Black     White     Red     Cyan     Purple     Green     Blue     Yellow  
Black 08 09 0A 0B 0C 0D 0E 0F
White 18 19 1A 1B 1C 1D 1E 1F
Red 28 29 2A 2B 2C 2D 2E 2F
Cyan 38 39 3A 3B 3C 3D 3E 3F
Purple 48 49 4A 4B 4C 4D 4E 4F
Green 58 59 5A 5B 5C 5D 5E 5F
Blue 68 69 6A 6B 6C 6D 6E 6F
Yellow 78 79 7A 7B 7C 7D 7E 7F
Orange 88 89 8A 8B 8C 8D 8E 8F
Light Orange 98 99 9A 9B 9C 9D 9E 9F
Pink A8 A9 AA AB AC AD AE AF
Light Cyan B8 B9 BA BB BC BD BE BF
Light Purple C8 C9 CA CB CC CD CE CF
Light Green D8 D9 DA DB DC DD DE DF
Light Blue E8 E9 EA EB EC ED EE EF
Light Yellow F8 F9 FA FB FC FD FE FF

Bitmap Graphics
The Vic-20 has no bitmap graphics! however it can use a custom character set, so we can effectively fake 8x8 'tiles' using this option
the low nibble of $9005 defines the position of the characters, though some options are unusable, here are the options, and where in memory the characters will be read.
the high nibble is used to define the video address, so should not be altered... it's default value is $F , but you can read it in, and OR in your new character source

Low
   Nibble   
Character
Source
%0000 $8000
%0001 $8400
%0010 $8800
%0011 $8C00
%1000 $0000
%1100 $1000
%1101 $1400
%1110 $1800
%1111 $1C00

Color Map
The color map contains one byte per character, and defines the foreground color... the character colors is defined from $9600 onwards