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:
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?
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:
Code:
lda $2002 ; read PPU status to reset the high/low latch
lda #$20
sta $2006 ; write the high byte of $2000 address
sta pattern
ldy #$00
sty $2006 ; write the low byte of $2000 address
lda #<background
sta base
lda #>background
sta base+1
ldx #$04
* lda (base),y ; load data from address (background + the value in x)
sta $2007 ; write to PPU
iny
bne - ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
dex
beq +
inc base+1
inc pattern
lda pattern
sta $2006
sty $2006
jmp -
lda #$20
sta $2006 ; write the high byte of $2000 address
sta pattern
ldy #$00
sty $2006 ; write the low byte of $2000 address
lda #<background
sta base
lda #>background
sta base+1
ldx #$04
* lda (base),y ; load data from address (background + the value in x)
sta $2007 ; write to PPU
iny
bne - ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
dex
beq +
inc base+1
inc pattern
lda pattern
sta $2006
sty $2006
jmp -
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?