Skip to navigation

Aviator on the BBC Micro

3D geometry: AddPointToObject

Name: AddPointToObject [Show more] Type: Subroutine Category: 3D geometry Summary: Add a point vector to an object's coordinates
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * CheckIfAlienIsHit (Part 2 of 2) calls AddPointToObject * FireGuns calls AddPointToObject * UpdateBullets calls AddPointToObject

This routine adds a point vector in (xPoint, yPoint, zPoint) to the object coordinates in (xObject, yObject, zObject), storing the result in the object coordinates. In other words, this moves an object by the xPoint vector. This is called MOBJ or UOBJ in the original source code.
Arguments: X The ID of the point vector to add to the object Y The ID of the object to update
.AddPointToObject LDA xObjectLo,Y \ Set object Y's x-coordinate to the following: CLC \ ADC xPointLo,X \ (xObjectHi+Y xObjectLo+Y) + (xPointHi+X xPointLo+X) STA xObjectLo,Y \ LDA xObjectHi,Y \ i.e. we add object Y's x-coordinate and point X's ADC xPointHi,X \ x-coordinate STA xObjectHi,Y LDA yObjectLo,Y \ Set object Y's y-coordinate to the following: CLC \ ADC yPointLo,X \ (yObjectHi+Y yObjectLo+Y) + (yPointHi+X yPointLo+X) STA yObjectLo,Y \ LDA yObjectHi,Y \ i.e. we add object Y's y-coordinate and point X's ADC yPointHi,X \ y-coordinate STA yObjectHi,Y LDA zObjectLo,Y \ Set object Y's z-coordinate to the following: CLC \ ADC zPointLo,X \ (zObjectHi+Y zObjectLo+Y) + (zPointHi+X zPointLo+X) STA zObjectLo,Y \ LDA zObjectHi,Y \ i.e. we add object Y's z-coordinate and point X's ADC zPointHi,X \ z-coordinate STA zObjectHi,Y RTS \ Return from the subroutine