Page 1 of 1
PPUADDR ($2006) 2x write
Posted: Sun Jul 23, 2006 4:27 pm
by okcomputer
in the following code:
Code: Select all
; load palette into $3f00
load_palette:
lda #$3f
ldx #$00
sta $2006
sta $2006
* lda palette, x
sta $2007
inx
cpx #$20
bne -
rts
when writing twice to $2006, on the first write A = #$3f. On the second write does A = #$00? I forgot how this works.
Thank You
matthew
answer
Posted: Sun Jul 23, 2006 5:35 pm
by lord_Chile
Code: Select all
; load palette into $3f00
load_palette:
lda #$3f A=#$3F
ldx #$00 X=#$00 ; A=#$3F
i imagine that you did read $2002 in order to reset 1st/2nd write latch
for using with $2005 and $2006.
sta $2006 store #$3F in $2006.
sta $2006 store #$3F in $2006.
Then you will write to palette starting at $3F3F.
If you want write to $3F00, i recommend changue the last
sta $2006 into stx $2006.
* lda palette, x
sta $2007
inx
cpx #$20
bne -
rts
start address for first entry of palette is $3F00.
registers like A, etc dont changue automatically or reset to 0.
If you lda #$03, it remains in 3 until you changue A.
Posted: Sun Jul 23, 2006 6:59 pm
by Memblers
It looks like the second write was intended to be STX $2006. Since X is zero.
These are the worst kind of typo bugs.. the ones that assemble without error.
Posted: Sun Jul 23, 2006 11:06 pm
by blargg
Especially because in this case setting VADDR to $3F3F will cause your palette to be shifted by just one entry, making you think the error must be something subtle in your loop.
Posted: Mon Jul 24, 2006 12:10 am
by Bregalad
Oh, yeah, such bugs are terrible to found out, because your code look just like its supposed to look, and it assemble without error.
Other common terrible errors are to put a pha, but no pla later, which assemble without errors, but causing your programm to crash at some point under some circunstences.
Also, writing lda Blahblah,X instead of lda Blahblah,Y or the other way arround is also a common damn error. You figure out that you load the wrong data, but don't know why and your code looks just as it is supposed to.