6510 Assembly programming for the Commodore 64

The C64 is one of the most popular computers of all time, although limited to just 64k, it rivalled its competitors with hardware sprites and scrolling,

its 6510 CPU is a 6502 with built in IO ports... the is no programming difference
C64 C128
Cpu 1mhz 6510 (6502 base) 1mhz 8580
Ram 64k 128k
Tiles 1024
Sprites 8 per line (24x21 px) 8 per line (24x21 px)
Resolution 320x200 / 160x200 320x200 / 160x200
Colors 4 per 8x8 tile from 16 4 per 8x8 tile from 16
Sound chip SID SID

Text Graphics
The characters shown onscreen are selected by the bytes in the memory range $0400-$07FF,  the colors of the tiles are selected per 8x8 square, from the registers at $D800-$DBE7... only the Low nibble of this area is used.

Bitmap Graphics
There are two modes for Bitmap graphics on the C64 

Normal mode is 320x200... it has 2 colors per 8x8 tile, the "Bitmap data" is typically located between $2000-$3FFF, this is a 1 bpp bitmap, each tile will get its background color from the low nibble of $D020, and it:s foreground color from the low nibble of $D800-$DBE7
Bits Detail Address
0 Text Screen Mem - Low nibble $0400-$07FF ----CCCC
1 Text Screen Mem - High nibble $0400-$07FF CCCC----

Multicolor Mode is 160x200 , it has 4 colors per 4x8 tile, but setting those colors is more tricky...  again it uses a bitmap screen at $2000-$3FFF, but is 2bpp... it uses a 160x200, 2 bits for each pixel choose a color from 1 of 4 locations

Bits Detail Address
00 Background Color $D021
01 Text Screen Mem - Low nibble $0400-$07FF ----CCCC
10 Text Screen Mem - High nibble $0400-$07FF CCCC----
11 Color Memory - Low Nibble $D800-$DBE7 ----CCCC

The Border Color is defined by $D021

Palette

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

Sprites

Address Purpose Bits Meaning
$07F8-$07FF Sprite pointers (default)  SSSSSSSS  s*64=memory address
$D000 Sprite #0 X-coordinate XXXXXXXX (only bits #0-#7).
$D001 Sprite #0 Y-coordinate YYYYYYYY
$D002 Sprite #1 X-coordinate XXXXXXXX (only bits #0-#7).
$D003 Sprite #1 Y-coordinate YYYYYYYY
$D004 Sprite #2 X-coordinate XXXXXXXX (only bits #0-#7).
$D005 Sprite #2 Y-coordinate YYYYYYYY
$D006 Sprite #3 X-coordinate XXXXXXXX (only bits #0-#7).
$D007 Sprite #3 Y-coordinate YYYYYYYY
$D008 Sprite #4 X-coordinate XXXXXXXX (only bits #0-#7).
$D009 Sprite #4 Y-coordinate YYYYYYYY
$D00A Sprite #5 X-coordinate XXXXXXXX (only bits #0-#7).
$D00B Sprite #5 Y-coordinate YYYYYYYY
$D00C Sprite #6 X-coordinate XXXXXXXX (only bits #0-#7).
$D00D Sprite #6 Y-coordinate YYYYYYYY
$D00E Sprite #7 X-coordinate XXXXXXXX (only bits #0-#7).
$D00F Sprite #7 Y-coordinate YYYYYYYY
$D010 Sprite #0-#7 X-coordinates 76543210 (bit #8)
$D015 Sprite enable register 76543210 1=on
$D017 Sprite double height register 76543210
$D01B Sprite priority register 76543210
$D01C Sprite multicolor mode register 76543210 0=2 color 1=4color
$D01D Sprite double width register 76543210
$D01E Sprite-sprite collision register 76543210
$D01F Sprite-background collision reg 76543210
$D025 Sprite extra color #1 ----CCCC
$D026 Sprite extra color #2 ----CCCC
$D027 Sprite #0 color ----CCCC
$D028 Sprite #1 color ----CCCC
$D029 Sprite #2 color ----CCCC
$D02A Sprite #3 color ----CCCC
$D02B Sprite #4 color ----CCCC
$D02C Sprite #5 color ----CCCC
$D02D Sprite #6 color ----CCCC
$D02E Sprite #7 color ----CCCC

Sprite pointers are a single byte... multiplying the sprite pointer by 64 will give the address of the sprite *within the 16k bank of Vram* (so must be in the range $0000-$3FFF)