.objc9 \ By this point we have pre-processed any special \ objects, so now to process it \ We now translate the base location of the object, \ in (xObject, yObject, zObject), by subtracting the \ current plane coordinates (xPlane, altitude, zPlane) \ to give the vector from the plane's location to the \ object's location LDX GG \ Set X to the value of GG: \ \ * For bullets, this is the value of GG that is \ passed to the routine, i.e. 98 \ \ * For other objects, this is 216 + object ID, so \ points 216 to 255 contain the calculated \ coordinates for objects 0 to 39 \ \ So in the following, we set the coordinates of the \ point whose ID is in GG, i.e. point GG \ We do the following calculation with 24-bit values, \ so we can do the visibility checks. This means we \ calculate: \ \ xPoint = xObject - xPlane \ yPoint = yObject - yPlane \ zPoint = zObject - zPlane \ \ but in each case, the values have three bytes. To take \ the x-axis calculation: \ \ xPoint is (A xPointHi xPointLo) \ xObject is (0 xObjectHi xObjectLo) \ xPlane is (xPlaneTop xPlaneHi xPlaneLo) \ \ and we pass the top byte of the result, in A, to the \ CheckObjDistance routine, so it can be used in the \ visibility check (a high value in A means the object \ is a very long way away) SEC \ Set the x-coordinate of point GG: LDA xObjectLo,Y \ SBC xPlaneLo \ xPoint = xObject - xPlane STA xPointLo,X \ \ starting with the low bytes LDA xObjectHi,Y \ And then the high bytes SBC xPlaneHi STA xPointHi,X STA T \ Set T = xPointHi to pass to CheckObjDistance LDA #0 \ And then the top bytes SBC xPlaneTop JSR CheckObjDistance \ Check whether the object is close enough to be visible \ in the direction of the x-axis BNE objc10 \ If it is too far away to be visible, jump to objc10 to \ either move on to the next object in the group, or \ tidy up and return from the subroutine SEC \ Set the y-coordinate of point GG: LDA yObjectLo,Y \ SBC yPlaneLo \ yPoint = yObject - yPlane STA yPointLo,X \ \ starting with the low bytes LDA yObjectHi,Y \ And then the high bytes SBC yPlaneHi STA yPointHi,X STA T \ Set T = yPointHi to pass to CheckObjDistance LDA #0 \ And then the top bytes SBC yPlaneTop JSR CheckObjDistance \ Check whether the object is close enough to be visible \ in the direction of the y-axis BNE objc10 \ If it is too far away to be visible, jump to objc10 to \ either move on to the next object in the group, or \ tidy up and return from the subroutine SEC \ Set the z-coordinate of point GG: LDA zObjectLo,Y \ SBC zPlaneLo \ zPoint = zObject - zPlane STA zPointLo,X \ \ starting with the low bytes LDA zObjectHi,Y \ And then the high bytes SBC zPlaneHi STA zPointHi,X STA T \ Set T = zPointHi to pass to CheckObjDistance LDA #0 \ And then the top bytes SBC zPlaneTop JSR CheckObjDistance \ Check whether the object is close enough to be visible \ in the direction of the z-axis BNE objc10 \ If it is too far away to be visible, jump to objc10 to \ either move on to the next object in the group, or \ tidy up and return from the subroutine LDA #0 \ Set the matrix number so the call to SetPointCoords STA matrixNumber \ uses matrix 1 in the calculation, which will rotate \ the point by the plane's pitch, roll and yaw angles, \ transforming it from the outside world's frame of \ reference to the plane's frame of reference JSR SetPointCoords \ Rotate the coordinates for point GG: \ \ * For bullets, this is point 98 \ \ * For other objects, this is 216 + object ID, so \ points 216 to 255 will contain the calculated \ coordinates for objects 0 to 39 \ \ and update the coordinates in (xPoint, yPoint, zPoint) LDY objectId \ Fetch the object ID into Y LDA showLine \ If showLine is non-zero, which means the line is not BNE objc12 \ visible, jump to objc12 to return from the subroutine \ without setting bit 7 of the object's status byte LDA #%11000000 \ Set A = %11000000 to set bits 6 and 7 of the object's \ status byte, to denote that the object has had its \ coordinates calculated, and that it is visible BNE objc13 \ Jump to objc13 to set the object's status byte and \ return from the subroutine (this BNE is effectively a \ JMP as A is never zero)Name: SetObjectCoords (Part 8 of 11) [Show more] Type: Subroutine Category: 3D geometry Summary: Process the object Deep dive: 3D objectsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine CheckObjDistance (category: Visibility)
Check whether an object is within the visible distance for that object, along just one axis
[X]
Subroutine SetPointCoords (category: 3D geometry)
Calculate the coordinates for a point
[X]
Variable matrixNumber in workspace Main variable workspace
The matrix used in matrix operations
[X]
Label objc10 in subroutine SetObjectCoords (Part 9 of 11)
[X]
Label objc12 in subroutine SetObjectCoords (Part 11 of 11)
[X]
Label objc13 in subroutine SetObjectCoords (Part 11 of 11)
[X]
Variable objectId in workspace Main variable workspace
Temporary storage for an object ID (0 to 39)
[X]
Variable showLine in workspace Main variable workspace
Determines whether a line is visible
[X]
Variable xObjectHi (category: 3D geometry)
High byte of the x-coordinate for an object
[X]
Variable xObjectLo (category: 3D geometry)
Low byte of the x-coordinate for an object
[X]
Variable xPlaneHi in workspace Main variable workspace
Plane longitude/x-coordinate (high byte)
[X]
Variable xPlaneLo in workspace Main variable workspace
Plane longitude/x-coordinate (low byte)
[X]
Variable xPlaneTop in workspace Main variable workspace
The top byte of the plane's location, which is the byte above the high byte in xPlaneHi
[X]
Variable xPointHi (category: 3D geometry)
High byte of the x-coordinate for a point
[X]
Variable xPointLo in workspace Main variable workspace
The low byte of the x-coordinate for the point with ID X is at xPointLo,X
[X]
Variable yObjectHi (category: 3D geometry)
High byte of the y-coordinate for an object
[X]
Variable yObjectLo (category: 3D geometry)
Low byte of the y-coordinate for an object
[X]
Variable yPlaneHi in workspace Main variable workspace
Plane altitude/y-coordinate (high byte)
[X]
Variable yPlaneLo in workspace Main variable workspace
Plane altitude/y-coordinate (low byte)
[X]
Variable yPlaneTop in workspace Main variable workspace
The top byte of the plane's location, which is the byte above the high byte in yPlaneHi
[X]
Variable yPointHi in workspace Main variable workspace
The high byte of the y-coordinate for the point with ID X is at yPointHi,X
[X]
Variable yPointLo in workspace Main variable workspace
The low byte of the y-coordinate for the point with ID X is at yPointLo,X
[X]
Variable zObjectHi (category: 3D geometry)
High byte of the z-coordinate for an object
[X]
Variable zObjectLo (category: 3D geometry)
Low byte of the z-coordinate for an object
[X]
Variable zPlaneHi in workspace Main variable workspace
Plane latitude/z-coordinate (high byte)
[X]
Variable zPlaneLo in workspace Main variable workspace
Plane latitude/z-coordinate (low byte)
[X]
Variable zPlaneTop in workspace Main variable workspace
The top byte of the plane's location, which is the byte above the high byte in zPlaneHi
[X]
Variable zPointHi (category: 3D geometry)
High byte of the z-coordinate for a point
[X]
Variable zPointLo in workspace Main variable workspace
The low byte of the z-coordinate for the point with ID X is at zPointLo,X