From C64-Wiki
Jump to: navigation, search
Disambiguation The title of this article is ambiguous. Other definitions are listed on Sprite (Disambiguation).



Sprite developing help (German; Reihe = line and Bitwert = bit value).

Sprite graphics[edit]

Data for a high resolution sprite

The "pattern" or "design" of both multicolor and high-res sprites always fits in to a "grid" of 24 bits in width, and 21 bits in height; a total of 504 bits, which in turn fit into 63 bytes. These 63 bytes are stored in RAM within the current VIC bank, beginning at an address divisible by 64; i.e. 0, 64, 128, 192, 256, etc.


Each byte contains eight bits (7-0), which have this values: 128, 64, 32, 16, 8, 4, 2 and 1. If a value is used, a pixel (bit) is set (also look to the example picture on the rigt side). For setting all pixels the sum of values is 255. For different pixel patterns the values must sum together - like 170 for setting bit 1 (value 2), 3 (value 8), 5 (value 32) and 7 (value 128) . A sprite data block is setup like:

Byte 1 Byte 2 Byte 3
Byte 4 Byte 5 Byte 6
... ... ...
... ... ...
Byte 61 Byte 62 Byte 63

High resolution sprite pattern[edit]


Since a bit can assume one of two states, each pixel in a high resolution sprite can do one of two things:


Multicolor sprite pattern[edit]


  • Pixels with a bit pair of "00" appear transparent, like "0" bits do in high resolution mode.
  • Pixels with a bit pair of "01" will have the color specified in address 53285/$D025.
  • Pixels with a bit pair of "11" will have the color specified in address 53286/$D026.
  • Pixels with a bit pair of "10" will have the color specified assigned to the sprite in question in the range 53287–53294/$D027–D02E.



The construction of sprites by hand is very hard, so that you should use a sprite editor. In some BASIC expansions like Super Expander 64, Supergrafik, Simons' BASIC or in BASIC 7.0 exists tools, other helps and more commands for developing and programming sprites easier. For example the BASIC command SPRDEF in BASIC 7 of a C128 or in Super Expander 64 runs the sprite editor.

Programming sprites in BASIC[edit]

By programming sprites in a BASIC program, the sprite datas should also put into DATA lines and read into the RAM with a FOR-NEXT loop and the BASIC commands READ and POKE - for example:

10 SZ = 12288: REM Sprite block 192
30 DATA 255, 128, 16: REM 1st data line
...(insert in this line 19 other DATA lines with 3 data values!)
50 DATA 255, 128, 16: REM 21st data line



Sprite enable[edit]



For a few sprite options like dis-/enable (53269/$D015) , x and y size (53277/$D01D; 53271/$D017) and background sprite priority (53275/$D01B) or collision registers (53278/$D01E; 53279/$D01F) the VIC-II used only one register for all sprites. In that kind for each sprite that used this option (enable bit for sprite #7-#0) the bit values must be sum together.

Sprite number: #7 #6 #5 #4 #3 #2 #1 #0
Bit value: 128 64 32 16 8 4 2 1



  • all sprites on - you set the sum of bit values of 255: POKE 53269,255
  • only sprite #0 (bit value 1) on: POKE 53269,1
  • only sprite #0 (bit value 1) and #1 (bit value 2) on: POKE 53269,3
  • only sprite #3 (bit value 8) and #5 (bit value 32) on: POKE 53269,40
  • all sprites off you set the value of 0: POKE 53269,0

Sprite pointers[edit]

Sprite Sprite pointer
#0 2040 / $07F8
#1 2041 / $07F9
#2 2042 / $07FA
#3 2043 / $07FB
#4 2044 / $07FC
#5 2045 / $07FD
#6 2046 / $07FE
#7 2047 / $07FF



Sprite locations[edit]

Sprite x coordinate y coordinate
#0 53248/$D000 53249/$D001
#1 53250/$D002 53251/$D003
#2 53252/$D004 53253/$D005
#3 53254/$D006 53255/$D007
#4 53256/$D008 53257/$D009
#5 53258/$D00A 53259/$D00B
#6 53260/$D00C 53261/$D00D
#7 53262/$D00E 53263/$D00F




  • Sprite #5 should be positioned at X=300 (256+44).
  • The other sprites should stay on your actual x position.
10 POKE 53258,44                :REM X POSITION SPRITE #5 = 44
LDA #44
STA $D00A       ; X position sprite #5 set on 44

LDA $D010       ; load X-MSB
ORA #%00100000  ; set extra bit for sprite #5
STA $D010       ; write X-MSB register

High resolution or multicolor mode[edit]


Color settings[edit]

All 16 sprite color on a C64.
Sprite Color register (normal/uni-color)
#0 53287/$D027
#1 53288/$D028
#2 53289/$D029
#3 53290/$D02A
#4 53291/$D02B
#5 53292/$D02C
#6 53293/$D02D
#7 53294/$D02E



Bit couple Color
 %00 transparency
 %10 Sprite color register (normal/uni color; $D027-$D02E)
 %01 Multicolor register #0 ($D025)
 %11 Multicolor register #1 ($D026)


Bit         | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | (for a standard or normal/uni-color sprite)
Bit         | 7 + 6 | 5 + 4 | 3 + 2 | 1 + 0 | (for multicolor sprite)
Bit values  |128|064|032|016|008|004|002|001|
1. Example  |   |   |   |   |   |   |   |   | (background color), value 0
2. Example  |   | X |   | X |   | X |   | X | (multicolor 0), value 85
3. Example  | X |   | X |   | X |   | X |   | (sprite normal/uni-color), value 170
4. Example  | X | X | X | X | X | X | X | X | (multicolor 1), value 255
            This example sprites and data values demonstrate a sprite line!  

5. Example  | X | X |   | X |   |   | X |   | data value 146
            All color options mixed into a sprite line

Double height and/or width[edit]

Sprite examples for standard height, 2*Y, 2*X and double size.




10 POKE 53277,15  :REM SPRITE #0-#3 double size in x position (1+2+4+8=15)  / sprite #4-#7 standard
LDA #%00001111
STA $D01D       ; Sprite #0-#3 double size in x position / sprite #4-#7 standard

Sprite priority[edit]

The sprite-sprite piority is fix! Here sprite 0 (white color) is always in the front of all other sprites. By using different colors a 3D effect is showing.



Bit=0, sprite runs right.
Bit=1, sprite runs left.


Sprite #7 should appear in the front - all other sprites #0 bis #6 aren't changed.

LDA $D01B       ; read priority register  
AND #%01111111  ; disable Bit7, Bit #0-#6 aren't changed
STA $D01B       ; write priority register

Collision detection[edit]


Polling for collisions[edit]




Interrupt on collision[edit]



Animation of sprites[edit]

Sprite Animation.png   Sprite Animation.gif
This animation contains 8 single images (sprites) - the sprite animation at the side.
  • For a sprite animation are required two matched images (sprites).
  • The sprite blocks should insert in the play order into the RAM.
  • The sprite data pointer will increased until the end of the animation is reached and then set on the start value.


POKE 2040,13: POKE 53248,255: POKE 53249, 100: POKE 53287,1

Enables sprite #0 with random shape in white color.

PRINT PEEK (53278): PRINT PEEK (53279)

Reading out the sprite collisions bits.

This BASIC program demonstrate a few sprite options of three sprites (multicolor and standard/uni-color). The REM-lines are only used for remarks (also with the REM command the BASIC lines are too long!). The variable V contains the start adress of VIC-II.

 1 PRINT CHR$(147): V=53248: POKE V+33,0: REM clear screen
 2 FOR X=12800 TO 12927: POKE X,0: NEXT X: REM Clear RAM for sprites

10 FOR X=12800 TO 12881: READ Y: POKE X,Y: NEXT X: REM sprite generation
11 POKE 2040,200: POKE 2041,201: POKE 2042,201: POKE V+21,7
12 POKE V+28,6: POKE V+37,15: POKE V+38,2: REM multicolor for sprite 1&2
13 POKE V+39,7: POKE V+40,8: POKE V+41,6: REM sprite color sprite 0&1&2
15 POKE V+23,7: POKE V+29,7: POKE V+16,1: REM sprite properties height, width, x position
16 POKE V+1,133: POKE V+2,170: POKE V+5,115: REM x/y positions

19 REM moving and changing colors
20 FOR X=200 TO 1 STEP -1: POKE V,X: Z=Z+0.61: POKE V+3,Z
21 POKE V+4,(201-X)/2: NEXT X
22 POKE V+16,0: POKE V,255: M=PEEK(V+4)
23 FOR X=255 TO 170 STEP -1: POKE V,X: Z=Z+0.66: POKE V+3,Z
24 POKE V+4,M+(256-X)/1.2: NEXT X
25 FOR X=0 TO 5: FOR Y=1 TO 255: POKE V+37+X,Y: NEXT Y,X
26 POKE V+38,2: POKE V+39,7: POKE V+41,6
27 FOR Y=1 TO 65: POKE V+40,Y: POKE V+37,Y+10
28 FOR Z=0 TO 15: POKE V+39,Y: NEXT Z, Y

29 REM waiting, deleting sprite 0 and fade off 
30 FOR X=0 TO 3000: NEXT X
31 FOR X=0 TO 32: POKE 12832+X,0: POKE 12832-X,0
32 FOR Y=0 TO 100: NEXT Y,X: POKE V+21,0

39 REM SPRITE C64-WIKI.DE (unicolor; sprite 0)
40 DATA 239,81,85,139,81,20,137,81,28,137,81,89,137,213,89,142,85,93,138   
41 DATA 95,85,138,91,85,238,91,85,0,0,0,0,0,0,0,0,0
42 DATA 0,199,0,0,231,0,0,164,0,0,180,0,0,151,0,0,180,0,0,164,0,0,231,0,0,199,0

44 REM multicolor sprite lines (sprite 1&2)
45 DATA 0,255,255,255,170,85,170,170,85,170,85,170,85,85,170,85,255,255,255


WP-W11.png Wikipedia: Sprite_(computer_graphics)