Hello again,
Im working on the Sound test Demo by Snow Bro. I came across some thing that i could have passed up but couldnt until i completly understood it. heres the Code:
After reading this i came to find out that it setsup "REG :" at locations #$20C0,2100,2140,2180. Each time the code loops it adds with a carry #$40 to low byte of 20CO until it stops at #$24.
What my Question is what is the INC ADDR_HI doing after the first loop? Because adding #$80 (Second loop adds #$40 again, i think) to C0 would generate a carry not branching it and incrementing ADDR_HI (20) making 21 i think.
How can you increment to 21 while there still is a carry and a value of a 100 in the low byte. Wouldnt that just add 21 + 100. What happens to the low byte after not branching???
Thanks in Advance,
EL
Im working on the Sound test Demo by Snow Bro. I came across some thing that i could have passed up but couldnt until i completly understood it. heres the Code:
Code:
end_text:
lda #$20
sta ADDR_HI
lda #$C0
sta ADDR_LO
ldy #$20
-
lda ADDR_HI
sta $2006
lda ADDR_LO
sta $2006
lda #$12 ; "R"
sta $2007
lda #$05 ; "E"
sta $2007
lda #$07 ; "G"
sta $2007
lda #$00 ; " "
sta $2007
sty $2007
lda #$2A ; ":"
sta $2007
lda ADDR_LO
clc
adc #$40
sta ADDR_LO
bcc +
inc ADDR_HI ;<-- This is what is nagging at my brain.
+
iny
cpy #$24
bne -
rts
lda #$20
sta ADDR_HI
lda #$C0
sta ADDR_LO
ldy #$20
-
lda ADDR_HI
sta $2006
lda ADDR_LO
sta $2006
lda #$12 ; "R"
sta $2007
lda #$05 ; "E"
sta $2007
lda #$07 ; "G"
sta $2007
lda #$00 ; " "
sta $2007
sty $2007
lda #$2A ; ":"
sta $2007
lda ADDR_LO
clc
adc #$40
sta ADDR_LO
bcc +
inc ADDR_HI ;<-- This is what is nagging at my brain.
+
iny
cpy #$24
bne -
rts
After reading this i came to find out that it setsup "REG :" at locations #$20C0,2100,2140,2180. Each time the code loops it adds with a carry #$40 to low byte of 20CO until it stops at #$24.
What my Question is what is the INC ADDR_HI doing after the first loop? Because adding #$80 (Second loop adds #$40 again, i think) to C0 would generate a carry not branching it and incrementing ADDR_HI (20) making 21 i think.
How can you increment to 21 while there still is a carry and a value of a 100 in the low byte. Wouldnt that just add 21 + 100. What happens to the low byte after not branching???
Thanks in Advance,
EL