Someone on the Nesdev IRC Channel said : "Don't spin around $2002, because it is unrealabe and there is a chance to miss a frame"

Someone else said : "My code is very fishy!" :

****************************************************

Here is my warm up routine :

****************************************************

Here is my vblank wait routine :

****************************************************

So, is it really fishy?! Or will I miss any frame?!

Someone else said : "My code is very fishy!" :

****************************************************

Here is my warm up routine :

**Code:**

LDX #$04 ; 4 Times vblank period will come and go

warmup_loop: ; Do loop until vblank starts

BIT $2002 ; It is not vblank period / 7th bit of $2002 is 0 / BIT, Clear the negative sign

BPL warmup_loop ; The result is Plus / BPL, Continue the loop!

; Vblank period has just started / 7th bit of $2002 is 1 / BIT, Set the negative sign / The result is Negative / BPL, Don't continue the loop!

vbend_loop: ; Do loop until current vblank ends

BIT $2002 ; It is vblank period / 7th bit of $2002 is 1 / BIT, Set the negative sign

BMI vbend_loop ; The result is Negative / BMI, Continue the loop!

; Vblank period has just ended / 7th bit of $2002 is 0 / BIT, Clear the negative sign / The result is Plus / BMI, Don't continue the loop!

DEX

BNE warmup_loop

warmup_loop: ; Do loop until vblank starts

BIT $2002 ; It is not vblank period / 7th bit of $2002 is 0 / BIT, Clear the negative sign

BPL warmup_loop ; The result is Plus / BPL, Continue the loop!

; Vblank period has just started / 7th bit of $2002 is 1 / BIT, Set the negative sign / The result is Negative / BPL, Don't continue the loop!

vbend_loop: ; Do loop until current vblank ends

BIT $2002 ; It is vblank period / 7th bit of $2002 is 1 / BIT, Set the negative sign

BMI vbend_loop ; The result is Negative / BMI, Continue the loop!

; Vblank period has just ended / 7th bit of $2002 is 0 / BIT, Clear the negative sign / The result is Plus / BMI, Don't continue the loop!

DEX

BNE warmup_loop

****************************************************

Here is my vblank wait routine :

**Code:**

vblank_wait: ; Do loop until current vblank ends

BIT $2002 ; It is vblank period by sheer chance! / 7th bit of $2002 is 1 / BIT, Set the negative sign

BMI vblank_wait ; The result is Negative / BMI, Continue the loop!

; Vblank period has just ended / 7th bit of $2002 is 0 / BIT, Clear the negative sign / The result is Plus / BMI, Don't continue the loop!

vbstart_loop: ; Do loop until a new vblank starts

BIT $2002 ; It is not vblank period / 7th bit of $2002 is 0 / BIT, Clear the negative sign

BPL vbstart_loop ; The result is Plus / BPL, Continue the loop!

; Vblank period has just started / 7th bit of $2002 is 1 / BIT, Set the negative sign / The result is Negative / BPL, Don't continue the loop!

RTS ; Now the screen can be updated!

BIT $2002 ; It is vblank period by sheer chance! / 7th bit of $2002 is 1 / BIT, Set the negative sign

BMI vblank_wait ; The result is Negative / BMI, Continue the loop!

; Vblank period has just ended / 7th bit of $2002 is 0 / BIT, Clear the negative sign / The result is Plus / BMI, Don't continue the loop!

vbstart_loop: ; Do loop until a new vblank starts

BIT $2002 ; It is not vblank period / 7th bit of $2002 is 0 / BIT, Clear the negative sign

BPL vbstart_loop ; The result is Plus / BPL, Continue the loop!

; Vblank period has just started / 7th bit of $2002 is 1 / BIT, Set the negative sign / The result is Negative / BPL, Don't continue the loop!

RTS ; Now the screen can be updated!

****************************************************

So, is it really fishy?! Or will I miss any frame?!