NES ASM Determine sprite position reletive to tile grid

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
droc101
Posts: 1
Joined: Thu Jul 11, 2019 5:06 am

NES ASM Determine sprite position reletive to tile grid

Post by droc101 » Thu Jul 11, 2019 5:12 am

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
code.asm
my code
(7.75 KiB) Downloaded 170 times

User avatar
Dwedit
Posts: 4300
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: NES ASM Determine sprite position reletive to tile grid

Post by Dwedit » Thu Jul 11, 2019 9:15 am

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.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

Post Reply