Prev: CD0C Up: Map Next: CD40
CD23: Swap Controls
Used by the routine at TurnSheriff.
Swaps left with right, and up with down, so that the controls match a rotated view. Fire is kept.
Input
E The controls
Output
E The swapped controls
Keep fire, then swap left with right.
SwapControls CD23 LD A,E Fetch the controls.
CD24 AND %00001000 Keep fire.
CD26 BIT 0,E Jump to SwapControls_Right if left is not pressed.
CD28 JR Z,SwapControls_Right
CD2A SET 1,A Set the control for right.
Swap right with left.
SwapControls_Right CD2C BIT 1,E Jump to SwapControls_Up if right is not pressed.
CD2E JR Z,SwapControls_Up
CD30 SET 0,A Set the control for left.
Swap up with down.
SwapControls_Up CD32 BIT 2,E Jump to SwapControls_Down if up is not pressed.
CD34 JR Z,SwapControls_Down
CD36 SET 4,A Set the control for down.
Swap down with up.
SwapControls_Down CD38 BIT 4,E Jump to SwapControls_Store if down is not pressed.
CD3A JR Z,SwapControls_Store
CD3C SET 2,A Set the control for up.
Store the swapped controls.
SwapControls_Store CD3E LD E,A Set the controls and return.
CD3F RET
View the equivalent code in;
Prev: CD0C Up: Map Next: CD40