Skip to navigation

Aviator on the BBC Micro

Visibility: ProcessLine (Part 1 of 7)

Name: ProcessLine (Part 1 of 7) [Show more] Type: Subroutine Category: Visibility Summary: Process a line, rotating and transforming it to the correct coordinates and calculating its visibility Deep dive: Visibility checks
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ShowOrHideLine calls ProcessLine * UpdateLinesToShow calls ProcessLine * ProcessLinesToHide calls via ProcessLine-1

Arguments: lineId The line ID of the line to process HH Determines whether we check against the line's maximum visible distance during the visibility checks: * 0 = check the line's distance against the maximum visible distance in maxLineDistance * Non-zero = skip the distance check
Returns: showLine Whether this line is visible: * 0 = line is visible * Non-zero = line is not visible
Other entry points: ProcessLine-1 Contains an RTS
.ProcessLine LDA #0 \ Set showLine = 0 as a starting point for the return STA showLine \ value (so we start out by assuming the line is \ visible, and change this if we find that it isn't) STA isObject \ Set isObject = 0, which we will set to a non-zero \ object ID below if we end up processing an object LDX lineId \ Set X = lineId, so X contains the ID of the line we \ want to check for visibility LDY lineEndPointId,X \ Set M to the point ID of the line's end point STY M LDY lineStartPointId,X \ Set L to the point ID for the line's start point STY L CPX #12 \ If lineId >= 12, then this is not the horizon or a BCS plin2 \ runway line, so jump to plin2 to process the line CPX #0 \ If lineId is not zero, then this is not the horizon, BNE plin1 \ so it must be a runway line, so jump to plin1 to \ process it \ If we get here then lineId is 0, so this is the \ horizon JSR ProcessHorizonLine \ Process the horizon and set showLine accordingly RTS \ Return from the subroutine