Okay here's the code: (I'm learning to program asm for the NES)
code:
lda #$3F ; these 4 lines tell $2006 that we
sta $2006 ; want the stuff we load $2007 with
lda #$00 ; to start at memory location $3F00
sta $2006 ; . Note that since we can only store a byte at a time we store twice
; to get the whole address in there.
ldx #$00 ; load X with 0.
loadpal: ; note that labels are followed by a ':' and aren't tabbed in.
lda ourpal, x ; load A with pallete value at location ourpal + x.
sta $2007 ; store the next pallete value into $2007 which will put it in
; the right place for us.
inx ; you've never seen this instruction before but it stands for INcrement X.
; it adds 1 to X.
cpx #32 ; ComPare X with 32 which is how many pallete values we need to load.
;bne loadpal ; bne stands for Branch on Not Equal, so this will branch to
; loadpalif X wasn't equal to 32. If X is 32, then the loop will stop and
; were done loading the pallete.
Pretty much I understand everything, but I don't understand how the value 3F00 stored in memory address 2006 tells the NES that the stuff stored in 2007 needs to start at memory location 3F00. There is no reference to the 2006 memory location after the first four lines of code. Oh and FYI the ourpal label is referenced somewhere else and not needed for this question. It simply loads the pallete file.
Are there any good online manuals on 6502 asm and more specifically NES asm programming? The tutorial I'm learning is a 25 day "course" and although it covers a lot, I want to go into more detail.
Also are there any good guides in reverse engineering NES roms (nes asm hacking)? I specifically want to learn how you insert your modified asm code back into the NES rom. I understand how you can extract the asm code from the debugger, but injecting the new code into the nes rom is what I'm unsure about.
code:
lda #$3F ; these 4 lines tell $2006 that we
sta $2006 ; want the stuff we load $2007 with
lda #$00 ; to start at memory location $3F00
sta $2006 ; . Note that since we can only store a byte at a time we store twice
; to get the whole address in there.
ldx #$00 ; load X with 0.
loadpal: ; note that labels are followed by a ':' and aren't tabbed in.
lda ourpal, x ; load A with pallete value at location ourpal + x.
sta $2007 ; store the next pallete value into $2007 which will put it in
; the right place for us.
inx ; you've never seen this instruction before but it stands for INcrement X.
; it adds 1 to X.
cpx #32 ; ComPare X with 32 which is how many pallete values we need to load.
;bne loadpal ; bne stands for Branch on Not Equal, so this will branch to
; loadpalif X wasn't equal to 32. If X is 32, then the loop will stop and
; were done loading the pallete.
Pretty much I understand everything, but I don't understand how the value 3F00 stored in memory address 2006 tells the NES that the stuff stored in 2007 needs to start at memory location 3F00. There is no reference to the 2006 memory location after the first four lines of code. Oh and FYI the ourpal label is referenced somewhere else and not needed for this question. It simply loads the pallete file.
Are there any good online manuals on 6502 asm and more specifically NES asm programming? The tutorial I'm learning is a 25 day "course" and although it covers a lot, I want to go into more detail.
Also are there any good guides in reverse engineering NES roms (nes asm hacking)? I specifically want to learn how you insert your modified asm code back into the NES rom. I understand how you can extract the asm code from the debugger, but injecting the new code into the nes rom is what I'm unsure about.