Skip to navigation


3D geometry: SetObjectCoords (Part 1 of 11)

Name: SetObjectCoords (Part 1 of 11) [Show more] Type: Subroutine Category: 3D geometry Summary: Calculate the coordinates for an object's location Deep dive: 3D objects
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessLine (Part 5 of 7) calls SetObjectCoords * ProcessRunwayLine (Part 2 of 5) calls SetObjectCoords * UpdateBullets calls SetObjectCoords

Arguments: objectId The ID of the object to process (1 to 39) GG For bullets only (12, 13, 14 or 15), the point ID for the bullet's anchor point
Returns: objectStatus The object's status byte: bits 6 and 7 affected Flags Set according to the object's updated status byte isObject The object ID, i.e. a non-zero value so callers of this routine will know we just processed an object xObjectHi etc. Set to the object's coordinates, relative to the plane xPointHi etc. The object's anchor point: * For bullets, point GG is updated with the bullet's anchor point * For other objects, point objectId+216 is updated with the object's anchor point
.SetObjectCoords LDY objectId \ Set Y to the object ID STY isObject \ Store the object ID in isObject, so callers of this \ routine will know we just processed an object TYA \ Set N = 216 + object ID CLC \ ADC #216 \ so N is in the range 217 to 255 and is the point ID STA N \ that we use for storing the object's anchor point LDA #1 \ Set K = 1, so the CheckObjDistance routine returns STA K \ the correct 0 or 1 value when checking an object's \ distance, which is the default behaviour (we set K to \ 0 below for bullets only, as we always want them to \ remain visible at distance) \ We now check for some specific objects: \ \ * Object groups, i.e. trees (6, 7), hills (8, 9) \ * Bullets (12, 13, 14 or 15) \ * Feeding aliens (object group 30) \ * Flying aliens (31, 32 or 33) \ \ so we can pre-process them before moving on to the \ main processing routine in part 8 CPY #12 \ If the object ID < 12, jump to objc1 to check the next BCC objc1 \ range CPY #16 \ If the object ID >= 16, jump to objc1 to check the BCS objc1 \ next range