On the Atari 2600

I’m debugging fine sprite positioning now. When you position a sprite by banging the right bit at the right moment, you’re limited by the fact that the TIA refreshes 3 times faster than the 6502, so for each cycle of the 6502 the TIA draws 3 pixels on one line.

You have to loop to burn time till your desired horizontal sprite position, but the tightest loop is 5 cycles. So that means you can only coarse position a sprite at a 15 pixel resolution.

The 2600 has a sprite fine positioning capability. The idea is you set the coarse position by waiting the appropriate amount of time, then you calculate the fine adjustment and set that.

When do you do all this? One possibility is that you calculate your coarse and fine position “off screen” (I’m presently doing it in the Overscan)

and storing the coarse and fine adjustment in memory.

Then, during the Vertical Blank (on the second to last scanline) I loop the coarse correction and then set the fine adjustment.

The fine adjustment involves a division by 15. The 6502 has neither native divide or multiply. To simulate them you need to loop and perform an add or a subtract. Seems like you can combine these two things so that your div loop also gives you the appropriate delay (it makes sense if you think about it for a bit).

Anyway, for didactic purposes, I’m calculating them elsewhere and setting them during the VBlank. But its not working correctly - I’m not seeing any fine adjustment:

08

The emulator I’m using actually has a great debugger, though:

Have to do real life now, though. I’ll keep you posted on this debugging!

6 Likes