Skip to navigation


3D objects: SetObjectDetails

Name: SetObjectDetails [Show more] Type: Subroutine Category: 3D objects Summary: Set an object's visibility, scale and type
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * BuildRoadSign calls SetObjectDetails

Arguments: A The object's pitch angle, as returned by GetObjPitchAngle C flag If the C flag is set, hide the object scaleUp The scale up factor, as returned by GetObjPitchAngle scaleDown The scale down factor, as returned by GetObjPitchAngle
.SetObjectDetails LDY objectNumber \ Set Y to the number of the object BCS HideObject \ If the C flag is set, jump to HideObject to hide the \ object and return from the subroutine using a tail \ call SEC \ Set A = A - 1 SBC #1 BMI HideObject \ If the result is negative, jump to HideObject to hide \ the object and return from the subroutine using a tail \ call STA objectPitchAngle,Y \ Store the object's pitch angle in objectPitchAngle \ We now set the object's scaleUp value (i.e. its size) \ to the following: \ \ scaleUp / 2 ^ (scaleDown - 10) \ \ where scaleUp and scaleDown were set by the call to \ GetObjPitchAngle LDA scaleDown \ Set X = scaleDown - 9 SEC SBC #9 TAX LDA scaleUp \ Set A = scaleUp DEX \ Set X = X - 1 \ = scaleDown - 10 BEQ sobj3 \ If X = 0, jump to sobj3 to set the object's scaleUp \ to A BPL sobj2 \ If X > 0, jump to sobj3 to set the object's scaleUp \ to A << X \ Otherwise X < 0, so we calculate A >> X to set as the \ object's scaleUp .sobj1 LSR A \ Set A = A >> 1 INX \ Increment the shift counter in X BNE sobj1 \ Loop back to sobj1 until we have shifted by X places BEQ sobj3 \ Jump to sobj3 (this BEQ is effectively a JMP as we \ just passed through a BNE) .sobj2 ASL A \ Set A = A << 1 DEX \ Decrement the shift counter in X BNE sobj2 \ Loop back to sobj2 until we have shifted by X places .sobj3 STA objectSize,Y \ Set the object's size to the scaled value of scaleUp LDA objectStatus,Y \ Set A to the object's status byte AND #%01110000 \ Clear bit 7 to make the object visible, and set bits ORA objectType \ 0-3 to the object type JMP SetObjectStatus \ Jump to SetObjectStatus to store the updated object \ status byte, returning from the subroutine using a \ tail call