Skip to navigation

Sights: RemoveSights

Name: RemoveSights [Show more] Type: Subroutine Category: Sights Summary: Remove the sights from the screen
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * CheckForKeyPresses calls RemoveSights * DrawSights calls RemoveSights * DrawUpdatedObject calls RemoveSights
.RemoveSights LDX sightsByteCount \ If the sights pixel byte stash is empty then there are BEQ rems2 \ no pixel bytes to restore to the screen, so jump to \ rems2 to return from the subroutine DEX \ Decrement the size of the sights pixel byte stash to \ give us a loop counter to count through the bytes LDY #0 \ Set Y = 0 so the STA (sightsByteAddr),Y instruction \ below behaves like STA (sightsByteAddr) .rems1 LDA sightsByteAddrLo,X \ Set sightsByteAddr(1 0) to the address for the X-th STA sightsByteAddr \ entry in the sights pixel byte stash, which we get LDA sightsByteAddrHi,X \ from the sightsByteAddr(Hi Lo) tables STA sightsByteAddr+1 LDA sightsByte,X \ Copy the X-th pixel byte from the sights pixel byte STA (sightsByteAddr),Y \ stash to the address in sightsByteAddr(1 0), to \ restore this byte of screen memory to its original \ contents, thus removing the sights from this byte DEX \ Decrement the pixel byte counter BPL rems1 \ Loop back until we have restored every byte from the \ sights pixel byte stash into its original address in \ screen memory LDX #0 \ Reset the size of the sights pixel byte stash to zero STX sightsByteCount \ as we have just emptied it .rems2 RTS \ Return from the subroutine