Page 1 of 1

NES ASM Determine sprite position reletive to tile grid

Posted: Thu Jul 11, 2019 5:12 am
by droc101
I have been trying to get a sprite position on the tile grid, but it isnt seeming to work. Can someone please help? I'll attach my code. So far I've only tried columns.

Re: NES ASM Determine sprite position reletive to tile grid

Posted: Thu Jul 11, 2019 9:15 am
by Dwedit
Simple formulas here...
(Sprite X - Camera X + 4) / 8
(Sprite Y - Camera Y + 4) / 8

Adding 4 is for rounding to nearest.
To divide by 8, shift right 3 times.
If you are talking about full 16x16 metatiles, use 16 instead of 8, and 8 instead of 4.

If you have no scrolling or no camera, your camera is zeroes.