Skip to navigation

Aviator on the BBC Micro

3D geometry: NextObjectGroup

Name: NextObjectGroup [Show more] Type: Subroutine Category: 3D geometry Summary: Cycle to the next object group
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessLine (Part 7 of 7) calls NextObjectGroup * SetObjectCoords (Part 9 of 11) calls NextObjectGroup

If the object ID passed to the routine is 6, 7, 8 or 9, then this object is part of an object group, in which case this routine increments the value in objectGroup for this object, so: * Object 6 increments objectGroup+0 through 0 to 7 and round again * Object 7 increments objectGroup+1 through 8 to 15 and round again * Object 8 increments objectGroup+2 through 16 to 23 and round again * Object 9 increments objectGroup+3 through 24 to 31 and round again
Arguments: Y The Object ID to move on to the next set of coordinates
Returns: C flag The result of the operation: * Set if this object ID is 6, 7, 8 or 9 * Clear otherwise
.NextObjectGroup CPY #6 \ If Y < 6, jump to nobj1 to return from the subroutine BCC nobj1 \ with the C flag clear CPY #10 \ If Y >= 10, jump to nobj1 to return from the BCS nobj1 \ subroutine with the C flag clear \ If we get here then Y = 6, 7, 8 or 9 LDA objectGroup-6,Y \ Increment the value in objectGroup for this object CLC \ from 0-7, adding in the value from groupStart (which ADC #1 \ contains the start value for each group, i.e. 0, 8, AND #7 \ 16 and 24) ORA groupStart-6,Y STA objectGroup-6,Y SEC \ Set the C flag RTS \ Return from the subroutine .nobj1 CLC \ Clear the C flag RTS \ Return from the subroutine