When you .rs 1, you are naming a number. When you "= $0001" you are also naming a number.
EM_ENEMY_1_STATE is a number. PLAYER_STATUS_WALK is a number. They are the same type of thing, even if you have defined them differently.
The 6502 can use numbers 2 ways. As an address, or as an "immediate" value. If you want to use the number as an immediate value, you precede it with a '#' symbol. If you want to use the number as an address, you don't.
Code: Select all
lda PLAYER_STATUS_WALK;Use $0001 as an address. So A gets the value from address $0001
lda #PLAYER_STATUS_WALK;Use $0001 as an immediate value. So A gets the value 1.
lda EM_ENEMY_1_STATE;Use... whatever number this ends up getting as an address. So A gets the value from that address.
lda #EM_ENEMY_1_STATE;Use... whatever number this ends up getting as an immediate value. So A gets whatever value that number is.
The assembler doesn't know that when you use ".rs" you want variables and when you use "= $????" you want constants, so if you want "PLAYER_STATUS_WALK" to be used as a constant you have to precede it with a '#'.
If you want EM_ENEMY_1_STATE to be used as a variable you must NOT precede it with a '#'.
The '#' is the only thing that makes a difference. (At least for what you've posted.)
Edit: So the reason EM_ENEMY_1_STATE ends up as zero in the first example is because at RAM location PLAYER_STATUS_WALK ($0001) was the value #$00 when you loaded it, and then this value (#$00) was stored to EM_ENEMY_1_STATE