Skip to navigation

Aviator on the BBC Micro

3D geometry: AddTempToPoint (Part 1 of 2)

Name: AddTempToPoint (Part 1 of 2) [Show more] Type: Subroutine Category: 3D geometry Summary: Add the xTemp1 vector to a point, store the result in another point, and set the result to hidden if it overflows
Set point X to the sum of the xTemp1 vector and point Y. In other words, add the following: (xTemp1 yTemp1 zTemp1) + point Y's coordinate in (xPoint, yPoint, zPoint) and store the results in point X's coordinate in (xPoint, yPoint, zPoint). We also set showLine to "hidden" if the addition overflows in any of the axes. Arguments: X The ID of the point in which to store the result Y The ID of the point to add to the xTemp1 vector Returns: showLine If the calculation overflows, then the coordinate does not fit within the boundaries of Aviator's 3D world, so bit 6 is set to indicate that the line containing this point should not be shown
.AddTempToPoint LDA xTemp1Lo \ Set point X's x-coordinate to the following: CLC \ ADC xPointLo,Y \ (xTemp1Hi xTemp1Lo) + (xPointHi+Y xPointLo+Y) STA xPointLo,X \ LDA xTemp1Hi \ i.e. we add xTemp1 and point Y's x-coordinate ADC xPointHi,Y STA xPointHi,X PHP \ Store the flags for the x-axis addition on the stack, \ so we can check them in part 2 CLC \ Set point X's y-coordinate to the following: LDA yTemp1Lo \ ADC yPointLo,Y \ (yTemp1Hi yTemp1Lo) + (yPointHi+Y yPointLo+Y) STA yPointLo,X \ LDA yTemp1Hi \ i.e. we add yTemp1 and point Y's y-coordinate ADC yPointHi,Y STA yPointHi,X PHP \ Store the flags for the y-axis addition on the stack, \ so we can check them in part 2 CLC \ Set point X's z-coordinate to the following: LDA zTemp1Lo \ ADC zPointLo,Y \ (zTemp1Hi zTemp1Lo) + (zPointHi+Y zPointLo+Y) STA zPointLo,X \ LDA zTemp1Hi \ i.e. we add zTemp1 and point Y's z-coordinate ADC zPointHi,Y STA zPointHi,X JMP addv1 \ Jump to part 2 to set showLine according to the \ overflow flag from each of the results (so if any axes \ overflow, we hide the line containing the point) NOP \ This instruction is not used; perhaps at one point the \ JMP above was a JSR instruction, and this was an RTS?