After the increment happens, there's nothing stopping the decrement from happening too, so the value will appear to never change.
What is the desired behavior? Do you want the counter to go from $00 to $50 and back over and over? If so, you can't simply have the two operations one after the other, you need to keep track of which way the value is going (up or down), so you can either add or subtract 1, and you can check for the correct end condition (num = $50 or num = $00) before switching to the other mode.
Since the difference between the two modes here is basically how much the number changes (+1 or -1), you can keep track of the state using the delta itself. Something like this:
Code: Select all
init: ;should only run once
lda $00
sta value
lda $01
sta increment
update: ;should run every frame
clc
lda value
adc increment
sta value
bit increment
bmi negative
positive:
cmp #$50
bne done
lda #$ff
sta increment
bne done
negative:
cmp #$00
bne done
lda #$01
sta increment
done:
Whenever an entity in your program needs to assume different behaviors, you need to keep track of its state somehow. This is essential in a game, where characters can walk, jump, shoot, and so on, and each of these states is handled differently.