I have a really long subroutine handling enemy animation and AI at once. This fragment moves enemies.
For some reason anywhere I try to use y register when addressing (INC EnemyRam + 3, y, STX EnemyRam + 3, y etc.) I get an error. I have to do it like this and it's completely redundant:
DEC Mob8Steps - 1, x
LDA Mob8Direction - 1, x
CMP #Mob_Dir_South
BNE +
TYA
TAX
INC EnemyRam, x
JMP AnimateEnemyUpdateRegisters
+
CMP #Mob_Dir_North
BNE +
TYA
TAX
DEC EnemyRam, x
JMP AnimateEnemyUpdateRegisters
+
CMP #Mob_Dir_East
BNE +
TYA
TAX
INC EnemyRam + 3, x
JMP AnimateEnemyUpdateRegisters
+
;;;west
TYA
TAX
DEC EnemyRam + 3, x
JMP AnimateEnemyUpdateRegisters
What's wrong?
Code:
MoveEnemy:
DEC Mob8Steps - 1, x
LDA Mob8Direction - 1, x
CMP #Mob_Dir_South
BNE +
INC EnemyRam, y
RTS
+
CMP #Mob_Dir_North
BNE +
DEC EnemyRam, y
RTS
+
CMP #Mob_Dir_East
BNE +
INC EnemyRam + 3, y
RTS
+
;;;west
DEC EnemyRam + 3, y
RTS
DEC Mob8Steps - 1, x
LDA Mob8Direction - 1, x
CMP #Mob_Dir_South
BNE +
INC EnemyRam, y
RTS
+
CMP #Mob_Dir_North
BNE +
DEC EnemyRam, y
RTS
+
CMP #Mob_Dir_East
BNE +
INC EnemyRam + 3, y
RTS
+
;;;west
DEC EnemyRam + 3, y
RTS
For some reason anywhere I try to use y register when addressing (INC EnemyRam + 3, y, STX EnemyRam + 3, y etc.) I get an error. I have to do it like this and it's completely redundant:
Code:
DEC Mob8Steps - 1, x
LDA Mob8Direction - 1, x
CMP #Mob_Dir_South
BNE +
TYA
TAX
INC EnemyRam, x
JMP AnimateEnemyUpdateRegisters
+
CMP #Mob_Dir_North
BNE +
TYA
TAX
DEC EnemyRam, x
JMP AnimateEnemyUpdateRegisters
+
CMP #Mob_Dir_East
BNE +
TYA
TAX
INC EnemyRam + 3, x
JMP AnimateEnemyUpdateRegisters
+
;;;west
TYA
TAX
DEC EnemyRam + 3, x
JMP AnimateEnemyUpdateRegisters
What's wrong?