Skip to navigation

Aviator on the BBC Micro

Visibility: ProcessLine (Part 5 of 7)

Name: ProcessLine (Part 5 of 7) [Show more] Type: Subroutine Category: Visibility Summary: Calculate the object's coordinates and visibility Deep dive: Visibility checks
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.plin8 \ By the time we get here, Y contains the last entry \ from objectPoints for this multi-point object (so it \ contains the object ID), and any previous points from \ the objectPoints entry are on the stack TAY \ Store the object ID in objectId STY objectId CMP #16 \ If the object ID >= 16, jump to plin9 to skip the BCS plin9 \ following CMP #12 \ If the object ID >= 12, then the object ID is in the BCS plin6 \ range 12 to 15, which means it's a bullet line, so \ jump up to plin6 to work out its visibility .plin9 LDA objectStatus,Y \ Fetch the object's status byte AND #%01000000 \ If bit 6 of the object's status byte is set then we BNE plin10 \ have already set this object's coordinates in this \ iteration of the main loop, so skip the following JSR SetObjectCoords \ Calculate the object's coordinates and visibilty, \ updating the object's status byte with the results \ and setting isObject to the object ID .plin10 LDY objectId \ Fetch the object ID from objectId LDA objectStatus,Y \ If bit 7 of the object's status byte is set, then the BMI plin13 \ object is visible, so jump to plin13 to set the anchor \ point and work our way through the points on the stack .plin11 LDA #%10000000 \ Set showLine to say that the line is not in view STA showLine .plin12 PLA \ Pull numbers off the stack until we reach the first CMP pointId \ number that we put on, which will match pointId, so BNE plin12 \ by the time we are done we have removed all the IDs \ we added to the stack during the routine RTS \ Return from the subroutine .plin13 TYA \ Set objectAnchorPoint = object ID + 216 CLC \ ADC #216 \ so it contains the point ID associated with the anchor STA objectAnchorPoint \ point of this object