Let's say I want to draw a 8x8 sprite so that it exactly covers a 8x8 BG tile. Is there an easy way to calculate the X- and Y-coordinates of the sprite if I know the nametable address? The scroll register is 0.
X coordinate: (((address << 3) & 0xF8) - camera_x) % 256
Y coordinate: (((address >> 2) & 0xF8) - (camera_y + 1)) % 240
A simplification is possible if your scroll position is (0, 0), as you mentioned:
X coordinate: (address << 3) & 0xF8
Y coordinate: ((address >> 2) & 0xF8) - 1
Translation of these expressions from C to 6502 assembly code is an exercise for the reader.
Thanks a lot! These formulas works like a charm!