.CheckObjVisibility SEC \ If bit 6 of samePanKeyPress is clear then the player BIT samePanKeyPress \ if not holding down the same pan key following the BPL cvis1 \ completion of a landscape pan, so jump to cvis1 to \ return from the subroutine with the C flag set \ If we get here then we have just completed a pan of \ the landscape view and the player is still holding \ down the same pan key STA currentObject \ Set currentObject to the object in A to pass to the \ GetObjVisibility routine so we check whether the LDA playerObject \ Set viewingObject to the object number of the player, STA viewingObject \ so any future view calculations are done from the \ aspect of the player rather than the enemy object TXA \ Store X and Y on the stack so they can be preserved PHA \ across the call to GetObjVisibility TYA PHA JSR GetObjVisibility \ Calculate whether any part of an object is visible \ on-screen and set the C flag as follows: \ \ * Clear = at least some of the object is visible \ on-screen \ \ * Set = the object is not visible on-screen \ \ If the object is visible, also set the following: \ \ * bufferColumns = the number of character columns \ in the screen buffer that the object spans \ \ * objYawOffset = the yaw offset of the left edge of \ the object from the left edge of the screen, in \ character columns PLA \ Retrieve X and Y from the stack so they can be TAY \ preserved PLA TAX .cvis1 RTS \ Return from the subroutineName: CheckObjVisibility [Show more] Type: Subroutine Category: Drawing objects Summary: Check whether an object is visible on-screen and should therefore not be changed if a pan operation is about to happenContext: See this subroutine in context in the source code References: This subroutine is called as follows: * AbortWhenVisible calls CheckObjVisibility * ExpendEnemyEnergy calls CheckObjVisibility * ScanForMeanieTree calls CheckObjVisibility * AbortWhenVisible calls via cvis1
Arguments: A The number of the object to check
Returns: C flag The object's visibility: * Clear = we are about to repeat a pan and at least some of the object is visible on-screen (so the object must not be updated or it could corrupt the landscape view) * Set = we are about to repeat a pan and the object is not visible on-screen, or we are not about to repeat a pan (so the object can be updated) bufferColumns If the object is visible, this is set to the number of character columns in the screen buffer that the object spans objYawOffset If the object is visible, this is set to the yaw offset of the left edge of the object from the left edge of the screen, in character columns currentObject If we are about to repeat a pan, this is set to the object number in A X X is preserved Y Y is preserved
Other entry points: cvis1 Contains an RTS
[X]
Subroutine GetObjVisibility (category: Gameplay)
Calculate whether any part of an object is visible on-screen, and if so, which character columns it spans on the screen
[X]
Variable currentObject in workspace Zero page
The number of the object we are currently processing
[X]
Entry point cvis1 in subroutine CheckObjVisibility (category: Drawing objects)
Contains an RTS
[X]
Variable playerObject in workspace Zero page
The number of the player object
[X]
Variable samePanKeyPress in workspace Main variable workspace
Records whether the same pan key is being held down after we have just finished panning the landscape view
[X]
Variable viewingObject in workspace Zero page
The number of the viewing object