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

BG / Sprite misalignment

BG / Sprite misalignment
by on (#61959)
I was thinking, would it cause any problems if I were to just simply subtract 1 from my Y Scroll Position value when I go to write it to the hardware registers? I figure this would save me from having to subtract 1 from all of my sprite Y coordinates, which may allow me to optimize my sprite routine a bit.

The only side effect I can think of is the fact that the topmost scanline will occasionally show garbage, but then again, I somehow don't think that'll matter.

Plus, bumping the screen position down by one will align the MMC3 scanline IRQ properly too. :P

by on (#61960)
I usually don't consider subtracting 1 from the sprite coordinates a problem at all. In order to find the position of a sprite on the screen I have to subtract the camera's position from the object's position, so I simply clear the carry before this subtraction instead of seting it, which causes an extra unit to be subtracted, so I basically get the coordinate fixed for free. There are no extra calculations at all.

However, if you don't have vertical scrolling you might not need to make that subtraction (ObjectY - CameraY), so this solution might not look so attractive to you. Personally I'd never settle for visual glitches, even if they are likely to be hidden by the TV... In fact I'll go through extra effort to eliminate all kinds of glitches, no matter how small they are. But that's just me.

by on (#61962)
Oh, derp! I dunno why that didn't occur to me. Thanks. xP

by on (#61963)
Yeah, that's really clever. Nice thinking, tokumaru. :)