Things gets a bit tougher on the Commodore 64, because this excellent piece of hardware did not come with Basic equipped with sprite commands. Nor has it a sprite editor or a machine code monitor. However, if we have access to a Commodore 128, sprites can be edited when in C128 mode, and then used in C64 mode. If we want, we can also use the machine code monitor in C128 mode and then execute the program in C64 mode. I am going to display a sprite without using the C128 mode.

The bit pattern at D015 gets and sets what sprites are enabled, just as it does on the Commodore 128, but on the Commodore 128 we also have Basic commands for this. This means that the first sprite (sprite 0) is activated using:

POKE 53269, 1

Still, you might not see anything on the screen. You can position the sprite (sprite 0) by writing the desired X coordinate in D000 and the desired Y coordinate in D001. This will position it at 100, 100:

POKE 53248, 100
POKE 53249, 100

The 0, 0 position is just above and to the left of the visible area, so if it is located at its home position, the sprite is still invisible. Also, the sprite might be empty. Run this program to make the sprite (still sprite 0) totally filled with pixels and displayed in red color. Note that the first line of code (10) tells the Commodore 64 that we want to use 02C0 to 02D7 (704 to 727) for sprite 0 data.

10 POKE 2040, 11
20 FOR I=0 TO 62
30 POKE 704+I, 255
50 POKE 53287, 2

Your screen should now look something like this:

When taking this further, it is nice to have a Commodore 64 memory map available.

Leave a Reply

Your email address will not be published. Required fields are marked *