This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

NES ASM Determine sprite position reletive to tile grid

NES ASM Determine sprite position reletive to tile grid
by on (#240727)
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
by on (#240731)
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.