Page 1 of 1

Namtable woes

Posted: Tue Oct 16, 2018 8:41 am
by battagline
When I was looking through rainwarrior's ca65 template, setting up the nametable seemed pretty straight forward. He was using the x and y register and looping 960 times doing a STA on $2007. I was able to play around with that code and thought I understood it. But when I'm trying that in the game I'm working on, it seems to only be setting the left column of background tiles.

I'm calling this proc on reset:

Code: Select all

.proc load_background
    stx nametable_reg_x
    sty nametable_reg_y

    lda PPU_STATUS        ; PPU_STATUS = $2002
    lda #$20
    sta PPU_ADDR          ; PPU_ADDR = $2006
    lda #$00
    sta PPU_ADDR          ; PPU_ADDR = $2006
    ldx #32              ; start out at 0
    lda #2
    background_x_loop:
        ldy #30 

        background_y_loop:
            sta PPU_DATA      ; PPU_DATA = $2007
            dey
        bpl background_y_loop ; loop until y == -1
        dex
    bpl background_x_loop  ; loop until x == -1

    ldx nametable_reg_x
    ldy nametable_reg_y
    rts      
.endproc

Re: Namtable woes

Posted: Tue Oct 16, 2018 9:01 am
by dougeff
Are you sure PPU control $2000 is set to +1 mode and not +32 mode?

xxxx x0xx

This bit should be zero.

Re: Namtable woes

Posted: Tue Oct 16, 2018 9:07 am
by battagline
dougeff wrote:Are you sure PPU control $2000 is set to +1 mode and not +32 mode?

xxxx x0xx

This bit should be zero.
It was set to 0 because I'm writing to PPU Address $2000. Is that not right?

Thanks

Re: Namtable woes

Posted: Tue Oct 16, 2018 9:09 am
by battagline
dougeff wrote:Are you sure PPU control $2000 is set to +1 mode and not +32 mode?

xxxx x0xx

This bit should be zero.
Actually you were right. I was setting $2000 to #%10011100 earlier than I thought I was.

Thanks!