This bit is cleared every VBlank, but it's not a very reliable method, because I've heard it's not always set when more than 8 sprites are detected on a scanline.
A good method I've found to ensure OAM cycling : While write to the OAM buffer, instead of advancing the index by 4, you have to advance of any number divisible per 4, but not per 8 (so 4, 12, 20, 28, etc...). So you'll also have the whole 64 sprites array to your disposition, but it'll never be set in the same order. Another advantage of this is that, scince you're starting to draw the first sprite with an index of zero, you'll always have the first sprite assigned to sprite zero, and this is usefull to do sprite zero hit, or to have a sprite that has always higher priority than others (for example when your player has multiple sprite-layers to have more colors on him).
The simple way to do that is simply to initialise your variable by a value of 4, then adding or substracting 8 to/from it every VBlank.
Insead of :
Code:
DrawSprite:
lda SpriteVPos
sta $200,X
lda SpriteTileIndex
sta $201,X
lda SpritePalette
sta $202,X
lda SpriteHPos
sta $203,X
inx
inx
inx
inx
rts
You have
Code:
DrawSprite:
lda SpriteVPos
sta $200,X
lda SpriteTileIndex
sta $201,X
lda SpritePalette
sta $202,X
lda SpriteHPos
sta $203,X
txa
clc
adc SpriteCyclingValue
tax
rts
SomewhereInNMI :
lda SpriteCyclingValue
ora #$04 ;Needed if the variable isn't setup at #$04 before the first NMI
clc
adc #$08 ;sec sbc #$08 should work as well
sta SpriteCyclingValue
rts
The disadventage of this is that you can't have sprites with higher priority than other exept the sprite zero, so you wont be able to do effects like in the Double Dragon series (the first one doen't have OAM cycling at all, and the last two have, but it looks pretty bad).
If you want to do so, I would recommand to compare the vertical position to all object, then write to OAM the ones with a higest position first, in a order that sould periodically change, then do this for all possible various vertical position ranges.
Of course, it's a method I've found, there is many others, and probabily betters.