Sprite pointers in 6502 (Commodore 64)

737 views Asked by At

So I'm trying to set my sprite pointers, but I can't seem to find out how to do it.

I know that if I want to set the pointer to be let's say $2000 I should set the pointer ($07F8) to #$80 since 40 * 80 = 2000. But what if I have my sprite binaries in the upper ram: $C000, I can't do that since that would be #$300 and that's to big.

2

There are 2 answers

0
the kamilz On BEST ANSWER

VIC-II can address only 16KB of memory. This is probably because C-64 (VIC-40) first designed 16KB RAM in mind, later Jack Tramiel dictated that it will be 64K.

So the main memory divided into 4 banks:

0000-3FFF (0)
4000-7FFF (1)
8000-BFFF (2)
C000-FFFF (3)

So when you set VIC-II to 3rd bank (that is C000-FFFF) $C000 becomes 0th sprite.

0
swpalmer On

See the entries for 2040-2047 ($07f8-$07ff) and 53248 ($d000) in Mapping the Commodore 64

It is an invaluable resource for programming the C64.

As the other answer has stated, you need to control the graphics bank of the VIC-II chip. The entry in Mapping the C64 for $DD00 explains it all:

Bits 0 and 1 of CIA #2 Port A have an extremely important function. As mentioned in the section on the VIC-II chip (53248, $D000), the video chip can address only 16K of memory at a time, and all graphics data must be stored in that 16K block in order to be displayed. Within this area, sprite graphics data may be placed in any of 256 groups of 64 bytes each. Character data can be stored in any of eight 2K blocks. Text screen memory may be in any of 16 IK areas, and bitmap screen memory may be in either of two 8K sections. When you turn the power on, the VIC-II uses the bottom 16K of memory for graphics. Unfortunately, this block of memory is also used extensively for other important purposes. Though some means of eliminating these conflicts are discussed above, in many situations you will want to change from the default 16K bank at the low end of memory. Bits 0 and 1 select the current 16K bank for video memory from the four possible choices using the following bit patterns: 00 (bit value of 0) Bank 3 (49152-65535, $C000-$FFFF) 01 (bit value of 1) Bank 2 (32768-49151, $8000-$BFFF) 10 (bit value of 2) Bank 1 (16384-32767, $4000-$7FFF) 11 (bit value of 3) Bank 0 (0-16383, $0-$3FFF)