nesdev.com
http://forums.nesdev.com/

NES ASM Determine sprite position reletive to tile grid
http://forums.nesdev.com/viewtopic.php?f=2&t=19095
Page 1 of 1

Author:  droc101 [ Thu Jul 11, 2019 5:12 am ]
Post subject:  NES ASM Determine sprite position reletive to tile grid

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.

Attachments:
File comment: my code
code.asm [7.75 KiB]
Downloaded 26 times

Author:  Dwedit [ Thu Jul 11, 2019 9:15 am ]
Post subject:  Re: NES ASM Determine sprite position reletive to tile grid

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.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/