In order to transform the current facing value to the new facing value without affecting the movement direction, you only need four different EOR operands (#$30, #$60, #$C0, #$90) for clockwise or counterclockwise. The trick is in calculating the desired operand as efficiently as possible. Are you more interested in fastest execution or smallest code footprint? Because the solutions will probably end up evolving differently. One intermediate possibility might look like:
Code:
rotcw:
lda status
lsr
lsr
lsr
lsr
tax
lda cwtable-2,x
bne rotzzz
rotccw:
lda status
lsr
lsr
lsr
lsr
tax
lda ccwtable-1,x
rotzzz:
eor status
sta status
rts
ccwtable:
dcb $30,$60,0,$C0,0,0,0,$90
cwtable:
dcb $30,0,$60,0,0,0,$C0
[UNTESTED!]
I truncated and slightly overlapped the tables to save space, but this will blindly provide nonsense values for invalid inputs ... garbage in, garbage out.
I know someone here can do better, perhaps much better, but I'm just throwing this out there as an example. If status happens to reside at address $30 or address $30xx, I know how to save two more bytes of ccwtable!
_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some
VTL02C on it and see how it grows on you!
Mike B.
(about me) (learning how to github)