One of possible ways to implement filter(Not tested)
Code:
OutputValue=0
Select Case OldValue
Case 0
If Current=1 then OutputValue=-1
If Current=2 then OutputValue=1
Case 1
If Current=3 then OutputValue=-1
If Current=0 then OutputValue=1
Case 2
If Current=0 then OutputValue=-1
If Current=3 then OutputValue=1
Case 3
If Current=2 then OutputValue=-1
If Current=1 then OutputValue=1
EndSelect