Quantcast
Channel: nesdev.org
Viewing all articles
Browse latest Browse all 785

First Tile appears in first two rows of background when attributes are added

$
0
0
Hi, I'm new to programming the NES, and have a question. I'm loading my background from another assembly file, and it loads and displays correctly when I haven't added attributes. However, whenever I add them, two rows show up at the top that are nothing but background tile 0. I'm using NESASM3 for my assembler.

Here is my code:

Code:

  .inesprg 1    .ineschr 1     .inesmap 0    .inesmir 1    ;;;;;;;;;;;;;;;  .bank 0  .org $C000   .rsset $0000bgLowByte   .rs 1bgHighByte  .rs 1  RESET:  SEI           CLD            LDX #$40  STX $4017     LDX #$FF  TXS            INX            STX $2000     STX $2001     STX $4010   vblankwait1:       BIT $2002  BPL vblankwait1  clrmem:  LDA #$00  STA $0000, x    STA $0100, x  STA $0400, x  STA $0500, x  STA $0600, x  STA $0700, x  LDA #$FE  STA $0300, x  INX  BNE clrmem   vblankwait2:     BIT $2002  BPL vblankwait2  lda #%10010000  sta $2000  lda #%00011000  sta $2001  lda #%00000000  sta $2000  lda #%00000000  sta $2001loadPalette:    lda #$3f  sta $2006  lda #$00  sta $2006   ;first palette  lda #$0f    sta $2007  lda #$11  sta $2007  lda #$10  sta $2007  lda #$30  sta $2007  ;second  lda #$0f  sta $2007  lda #$06  sta $2007  lda #$16  sta $2007  lda $26  sta $2007  setBackgroundColor:  lda $2002  lda $3f  sta $2006  lda $00  sta $2006  lda $01  sta $2007drawBackgroundTiles:  ldy #$00  ldx #$00  lda $2002  lda #$20  sta $2006  lda #$00  sta $2006    lda #LOW(background)  sta bgLowByte  lda #HIGH(background)  sta bgHighByte    bgLoop:  lda [bgLowByte], y  sta $2007  iny  cpy #$00  bne bgLoop    inc bgHighByte  inx  cpx #$04  bne bgLooploadAttributes:  lda $2002  lda #$23  sta $2006  lda #$C0  sta $2006    ldx #$00attrLoop:  lda bgAttr, x  sta $2007  inx  cpx #$40  bne attrLoop    resetPPU:  lda #%10010000  sta $2000  lda #%00011110  sta $2001  Foreverloop:  JMP Foreverloop    NMI:  lda #$00  lda $2003  lda #$02  lda $4014  RTI ;;;;;;;;;;;;;;  .bank 1  .org $E000  background:  .include "test8bg.asm"bgAttr:  .include "test8attrib.asm"    .org $FFFA      .dw NMI                          .dw RESET                        .dw 0          ;;;;;;;;;;;;;;    .bank 2  .org $0000  .incbin "mario.chr"  
What's causing this, and how can I prevent it from happening?

Statistics: Posted by sneed_generator — Wed Feb 21, 2024 7:57 pm — Replies 0 — Views 7



Viewing all articles
Browse latest Browse all 785

Trending Articles