C64 graphics – a quick reference
The VIC is the chip in a c64 that handle all graphics.
Whereas the CPU sees all of the memory, the VIC only sees 1/4. We call that a VIC bank or graphics bank. Default is $0000 to $3fff – you need to actively change it using the two bits in $dd00 if you want something else. Any of the indexes talked about below are relative to the start of the bank.
Depending on the graphics mode (character and bitmap), the VIC registers define different things. (These registers are located at the addresses $d000 to $d02f). Default is character mode.
If so;
The screen and font are set by the same register ($d018 – screen is bit 4-7 and font is bit 1-3):
- Screen is a $03e8 byte big area that can be set to any of the $0400 aligned indexes in the current VIC bank (so 0 is $0000, 1 is $0400, 2 is $0800 and so on – in the lowest bank $0000 is rather theoretical). Default is 1, ie $0400.
- Font is a $0800 area that can be set to any $0800 aligned address. Default is $1000 (which is a shadow of the char ROM that really resides at $d000)The last 8 address of the area allocated to screen is used for pointers to the sprite memory.
A sprite is an independently movable object that is 24*21 pixels, which means 3 * 21 = 63 bytes of memory, and they hence fit nicely inside a 64/$40 byte block. A sprite data shall hence be located at an even 64/$40 location.
With bank set to 0 and screen to $0400, this means that you find the sprite pointers at $07f8. A sprite pointer is the index of the “slot” containing the content that is to be interpreted as sprites; 0 is $0000, 1 is $0040 and so on.
I’d say it’s bad practice to set the pointer and the address hard and not calculate one of them. Use something like “LDA #spritemem/64” where “spritemem” is the address where the sprite data is stored.
One thing to understand is that if you change VIC bank, all data for all graphics change and point to new places. But also, if you change the pointer to the current screen, the pointers to sprites also change and hence both screen and sprite content changes.
It’s a bit complex to learn, but it’s super powerful once you get a hang of it
> “I’d say it’s bad practice to set the pointer and the address hard and not calculate one of them. Use something like “LDA #spritemem/64” where “spritemem” is the address where the sprite data is stored.
One thing to understand is that if you change VIC bank, all data for all graphics change and point to new places. But also, if you change the pointer to the current screen, the pointers to sprites also change and hence both screen and sprite content changes.”
Would be better with an example of some kind. But point taken.