.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 subroutineName: RemoveSights [Show more] Type: Subroutine Category: Sights Summary: Remove the sights from the screenContext: 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
[X]
Label rems1 is local to this routine
[X]
Label rems2 is local to this routine
[X]
Variable sightsByte (category: Sights)
The sights pixel byte stash, which contains the screen pixel bytes behind the sights, so they can be restored to remove the sights
[X]
Variable sightsByteAddr in workspace Zero page
Storage for an address that loops through the pixel bytes in screen memory where the sights appear, so the sights can be drawn and removed using the contents of the sights pixel byte stash
[X]
Variable sightsByteAddrHi (category: Sights)
The screen addresses of the bytes in the sights pixel byte stash, to which they can be restored to remove the sights (high byte)
[X]
Variable sightsByteAddrLo (category: Sights)
The screen addresses of the bytes in the sights pixel byte stash, to which they can be restored to remove the sights (low byte)
[X]
Variable sightsByteCount in workspace Main variable workspace
The number of screen bytes in the sights pixel byte stash that contain the contents of the screen behind the sights (so they can be restored to remove the sights)