Prev: 52492 Up: Map Next: 52544
52515: 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 52515 LD A,E Fetch the controls.
52516 AND %00001000 Keep fire.
52518 BIT 0,E Jump to SwapControls_Right if left is not pressed.
52520 JR Z,SwapControls_Right
52522 SET 1,A Set the control for right.
Swap right with left.
SwapControls_Right 52524 BIT 1,E Jump to SwapControls_Up if right is not pressed.
52526 JR Z,SwapControls_Up
52528 SET 0,A Set the control for left.
Swap up with down.
SwapControls_Up 52530 BIT 2,E Jump to SwapControls_Down if up is not pressed.
52532 JR Z,SwapControls_Down
52534 SET 4,A Set the control for down.
Swap down with up.
SwapControls_Down 52536 BIT 4,E Jump to SwapControls_Store if down is not pressed.
52538 JR Z,SwapControls_Store
52540 SET 2,A Set the control for up.
Store the swapped controls.
SwapControls_Store 52542 LD E,A Set the controls and return.
52543 RET
View the equivalent code in;
Prev: 52492 Up: Map Next: 52544