On this pic, my sprite is walking toward left on the center of the screen. Everything is fine
Code:
attrib = 00000000
On this one, it's walking toward right. See what happens ?
Code:
attrib = 01000000
Also, if it touch the screen's edge, something similar happens...
Can you tell me what search I have to do to solve this bug (or those bugs)
ps: I'm not using DMA on this demo
Well, if you touch the edge of the screen, I'm assuming the sprites coordinates go from being greater than or equal to 0 to being less than 0, in which case they should disappear. Say you have a sprite's X coord at 255. Since sprites are drawn from left to right, it will start drawing at pixel 255. By that point, all previous pixels will have been rendered, and it will be too late to render the rest of the sprite's pixels.
There's something strange about your pictures. The glitches are not an entire pixel tall/wide, which is very strange. Perhaps you could explain more when exactly this glitch occurs, or perhaps upload a demo?
Quote:
The glitches are not an entire pixel tall/wide, which is very strange.
I've tried FCE Ultra Extended Debugger and jNes and the artifact is still there...
Quote:
Perhaps you could explain more when exactly this glitch occurs, or perhaps upload a demo?
I've upload the .nes file on my server :
http://209.169.188.15/LoadSprite.nes
ps : I didn't fix other bugs in that demo because I'm trying to figure that one first. ex: the horizontal flip
Ah, the sprites are double-sized! =) That explains the weird spacing. It doesn't seem anything related to hardware, and is more likely to be a software bug, in the code you wrote. You should try sprite DMA before anything else, though.
EDIT: I haven't really debugged anything yet, but I can tell you have done something wrong during initialization, because weird things happen to the sprite on software resets (in some emulators it disappears, in other it turns black). This means you are not initializing RAM properly.
EDIT 2: Apparently, the sprite displacement happens because you are doing arithmetic without initializing the carry flag. I see that at some point you have the instructions "LDA #$01" and "CMP $000F", apparently to decide which side the sprite is facing. Some time later an "SBC #$08" instruction is executed, but you didn't initialize the carry, it was left as whatever it was after that CMP, which can be 0 or 1 depending on the contents of the variable at $0F.
So, in order to fix your problem, put a SEC before subtractions and a CLC before additions. As a general rule, the carry must be set to a known state before additions or subtractions.
EDIT 3: Same thing happens when the sprite approaches the edge of the screen. You are probably comparing something to the X coordinate of the sprite and forgetting to initialize the carry afterwards. I'm looking at your variables and the sprite breaks up as soon as the X coordinate wraps from 0 to 255. So yeah, just review all your additions and subtractions and this problem should go away.
Ah Yes, you're right. Works perfectly now!
I didn't even know about that carry flag, thx for teaching me that one!