.MoveSightsUpDown LDX playerObject \ Set Y to the current pitch angle of the player LDY objectPitchAngle,X LDX keyLogger+2 \ Set X to the key logger entry for "L" and "," (pan \ up, pan down), which are used to move the sights BMI sadr3 \ If there is no key press in the key logger entry, jump \ to sadr3 to return from the subroutine \ If we get here then "L" or "," is being pressed, which \ will put 2 or 3 into the key logger respectively CPX #2 \ If X = 3 then "," is being pressed, so jump to siud2 BNE siud2 \ to process moving the sights down \ If we get here then X = 2, so "L" is being pressed, \ which is the key for moving the sights up LDA ySights \ Increment ySights to move the sights up CLC ADC #1 CMP #160 \ If ySights < 160 then skip the following, as the BCC siud1 \ sights have not moved off the top edge of the screen CPY highestPitchAngle \ If the player's pitch angle is already equal to the BEQ sadr3 \ the pitch angle of the highest gaze allowed, then jump \ to sadr3 to return from the subroutine without moving \ the sights, as we can't move them any higher SEC \ Subtract 64 from A to move the sights down by 64, as SBC #64 \ we are about to pan the screen up STX panKeyBeingPressed \ Set panKeyBeingPressed to the key logger entry for "L" \ to pretend that the "L" key is being pressed to pan \ the screen as well as move the sights \ \ This will pan up by scrolling the screen down .siud1 STA ySights \ Update the y-coordinate of the sights to the updated \ value in A AND #%00000111 \ If the y-coordinate is not a multiple of eight then BNE SetSightsAddress \ the sights are still within the same character row, so \ jump to SetSightsAddress with X = 2 to update the \ address variables for the sights JMP siud4 \ Otherwise jump to sisd4 to increment X to 4 before \ falling into SetSightsAddress to set the address \ variables for the sights .siud2 \ If we get here then X = 3, so "," is being pressed, \ which is the key for moving the sights down LDA ySights \ Decrement ySights to move the sights down SEC SBC #1 CMP #32 \ If ySights >= 32 then skip the following, as the BCS siud3 \ sights have not moved off the bottom edge of the \ screen CPY lowestPitchAngle \ If the player's pitch angle is already equal to the BEQ sadr3 \ the pitch angle of the lowest gaze allowed, then jump \ to sadr3 to return from the subroutine without moving \ the sights, as we can't move them any lower CLC \ Add 64 to A to move the sights up by 64, as we are ADC #64 \ about to pan the screen up STX panKeyBeingPressed \ Set panKeyBeingPressed to the key logger entry for "," \ to pretend that the "," key is being pressed to pan \ the screen as well as move the sights \ \ This will pan down by scrolling the screen up .siud3 STA ySights \ Update the y-coordinate of the sights to the updated \ value in A AND #%00000111 \ If the y-coordinate is not one less than a multiple of CMP #%00000111 \ eight then the sights are still within the current BNE SetSightsAddress \ character row, so jump to SetSightsAddress with X = 3 \ to update the address variables for the sights \ Otherwise increment X to 5 before falling into \ SetSightsAddress to set the address variables for the \ sights .siud4 INX \ Increment X by 2, so: INX \ \ * X = 4 if "L" was pressed to move the sights up and \ this moved the sights into the character row above \ \ * X = 5 if "," was pressed to move the sights down \ and this moved the sights into the character row \ below \ Fall into SetSightsAddress to set the address \ variables for the sightsName: MoveSightsUpDown [Show more] Type: Subroutine Category: Sights Summary: Check for the up/down keys and move the sights accordingly, panning up or down if they go past the screen edgesContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MoveSights calls MoveSightsUpDown
[X]
Subroutine SetSightsAddress (category: Sights)
Update the address variables for the sights when they move into a new character block or row
[X]
Variable highestPitchAngle (category: Sights)
The pitch angle of the highest point that the player can look at with the sights
[X]
Variable keyLogger in workspace Main variable workspace
The four-byte key logger for logging game key presses
[X]
Variable lowestPitchAngle (category: Sights)
The pitch angle of the lowest point that the player can look at with the sights
[X]
Variable objectPitchAngle in workspace Stack variables
The pitch angle for each object (i.e. the vertical direction in which they are facing)
[X]
Variable panKeyBeingPressed in workspace Zero page
The direction in which the player is currently panning
[X]
Variable playerObject in workspace Zero page
The number of the player object
[X]
Entry point sadr3 in subroutine SetSightsAddress (category: Sights)
Contains an RTS
[X]
Label siud1 is local to this routine
[X]
Label siud2 is local to this routine
[X]
Label siud3 is local to this routine
[X]
Label siud4 is local to this routine
[X]
Variable ySights in workspace Main variable workspace
The pixel y-coordinate of the sights on-screen