Skip to navigation

Keyboard: CheckForSamePanKey

Name: CheckForSamePanKey [Show more] Type: Subroutine Category: Keyboard Summary: Check to see whether the same pan key is being held down compared to the last time we checked
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawLandscapeView (Part 2 of 3) calls CheckForSamePanKey * ProcessGameplay calls CheckForSamePanKey

Returns: Z flag Determines whether the same pan key is being held down compared to the last time we checked: * Z flag will be set if the same pan key is being held down (so a BEQ branch will be taken) * Z flag will be clear otherwise (so a BNE branch will be taken)
.CheckForSamePanKey SEI \ Disable interrupts so the key logger doesn't get \ updated while we check it for pan key presses LDY #3 \ Scan the keyboard for the first four game keys ("S", JSR ScanForGameKeys \ "D", "L" and ",", for pan left, right up and down) LDA latestPanKeyPress \ Set A to the key logger value of the latest pan key \ press, which will either be a current key press or the \ value from the last pan key press to be made CMP keyLogger \ Compare with the key logger entry for "S" and "D" \ (pan left and right) BEQ cpan1 \ If the key logger entry is unchanged from the previous \ pan key press in latestPanKeyPress, then the same pan \ key is being held down, so jump to cpan1 with the \ Z flag set accordingly CMP keyLogger+2 \ Compare with the key logger entry for "L" and "," \ (pan up and down), so the Z flag will be set if the \ same pan key is being held down .cpan1 CLI \ Re-enable interrupts RTS \ Return from the subroutine