An image, to illustrate what I am talking about:
I am also not sure what the solid blue rectangle is doing at the top. Perhaps it is related, but I have only been doing NES programming for about three days so have no clue. The hollow blue square is a sprite that is being drawn as expected, the yellow filled square and the rest of the green grid are the background. As far as I understand my code, the green grid should be aligned with the top of the screen, instead of that empty black space that is occupying its position. As you can see it is running on Nestopia. I also ran it on nesDS (a NES emulator for the Nintendo DS) and it gave the same problem, except the grid was not pushed down as far.
My background drawing code:
lda $2002 ; read PPU status to reset the high/low latch
sta $2006 ; write the high byte of $2000 address
sty $2006 ; write the low byte of $2000 address
* lda (base),y ; load data from address (background + the value in x)
sta $2007 ; write to PPU
bne - ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
I am using the Ophis assembler. I am not sure how common its syntax is, so *'s are anonymous labels, - references the nearest previous label, + the next nearest label. Example programs that I have assembled and run (though with a different assembler) have been able to display backgrounds aligned correctly. Is there anything obviously wrong with my code? Should I include some other code? Has anybody come across this before?