I've just started with this asm tutorial, and decided to start modifying the first program. I successfully changed the colors, and enabled the 2nd missile and made 2 lines going in opposite directions. Then I decided to try cycling the background color by decrementing it every frame, and wrapping to $FF when it hits zero. I also took out the moving line. I added the following code near the beginning of the main loop, where the tutorial said you could put game logic.
ldx COLUBK
dex
bne SkipReset
ldx #$FF
SkipReset
txa
sta COLUBK
The background color starts at $FF, and *should* decrement by one every frame. However, instead it changes immediately to a light gray, and stays there. I slowed down the color changing by making it do 50 frames before it changed, and it seemed to change to gray on the first change. Here's the full code:
processor 6502
include vcs.h
org $F000
Start
sei
cld
ldx #$FF
tsx
lda #0
ClearMem
sta 0,X
dex
bne ClearMem
lda #255
sta COLUBK
MainLoop
lda #2
sta VSYNC
sta WSYNC
sta WSYNC
sta WSYNC
lda #43
sta TIM64T
lda #0
sta VSYNC
ldx COLUBK ;Here's the code I added
dex
bne SkipReset
ldx #$FF
SkipReset
txa
sta COLUBK ;End of added code
WaitForVblankEnd
lda INTIM
bne WaitForVblankEnd
ldy #191
sta WSYNC
sta VBLANK
ScanLoop
sta WSYNC
dey
bne ScanLoop
lda #2
sta WSYNC
sta VBLANK
ldx #30
OverScanWait
sta WSYNC
dex
bne OverScanWait
jmp MainLoop
org $FFFC
.word Start
.word Start