.PLANET LDA #GREEN \ Send a #SETCOL GREEN command to the I/O processor to JSR DOCOL \ switch to stripe 3-1-3-1, which is cyan/yellow in the \ space view LDA INWK+8 \ Set A = z_sign (the highest byte in the planet/sun's \ coordinates) \BMI PL2 \ This instruction is commented out in the original \ source. It would remove the planet from the screen \ when it's behind us CMP #48 \ If A >= 48 then the planet/sun is too far away to be BCS PL2 \ seen, so jump to PL2 to remove it from the screen, \ returning from the subroutine using a tail call ORA INWK+7 \ Set A to 0 if both z_sign and z_hi are 0 BEQ PL2 \ If both z_sign and z_hi are 0, then the planet/sun is \ too close to be shown, so jump to PL2 to remove it \ from the screen, returning from the subroutine using a \ tail call JSR PROJ \ Project the planet/sun onto the screen, returning the \ centre's coordinates in K3(1 0) and K4(1 0) BCS PL2 \ If the C flag is set by PROJ then the planet/sun is \ not visible on-screen, so jump to PL2 to remove it \ from the screen, returning from the subroutine using \ a tail call LDA #96 \ Set (A P+1 P) = (0 96 0) = 24576 STA P+1 \ LDA #0 \ This represents the planet/sun's radius at a distance STA P \ of z = 1 JSR DVID3B2 \ Call DVID3B2 to calculate: \ \ K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo) \ = (0 96 0) / z \ = 24576 / z \ \ so K now contains the planet/sun's radius, reduced by \ the actual distance to the planet/sun. We know that \ K+3 and K+2 will be 0, as the number we are dividing, \ (0 96 0), fits into the two bottom bytes, so the \ result is actually in K(1 0) LDA K+1 \ If the high byte of the reduced radius is zero, jump BEQ PL82 \ to PL82, as K contains the radius on its own LDA #248 \ Otherwise set K = 248, to round up the radius in STA K \ K(1 0) to the nearest integer (if we consider the low \ byte to be the fractional part) .PL82 LDA TYPE \ If the planet/sun's type has bit 0 clear, then it's LSR A \ either 128 or 130, which is a planet (the sun has type BCC PL9 \ 129, which has bit 0 set). So jump to PL9 to draw the \ planet with radius K, returning from the subroutine \ using a tail call JMP SUN \ Otherwise jump to SUN to draw the sun with radius K, \ returning from the subroutine using a tail callName: PLANET [Show more] Type: Subroutine Category: Drawing planets Summary: Draw the planet or sunContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * LL9 (Part 1 of 12) calls PLANET
Arguments: INWK The planet or sun's ship data block
[X]
Subroutine DOCOL (category: Text)
Set the text colour by sending a #SETCOL command to the I/O processor
[X]
Subroutine DVID3B2 (category: Maths (Arithmetic))
Calculate K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)
[X]
Configuration variable GREEN = %10101111
Four mode 1 pixels of colour 3, 1, 3, 1 (cyan/yellow)
[X]
Subroutine PL2 (category: Drawing planets)
Remove the planet or sun from the screen
[X]
Label PL82 is local to this routine
[X]
Subroutine PL9 (Part 1 of 3) (category: Drawing planets)
Draw the planet, with either an equator and meridian, or a crater
[X]
Subroutine PROJ (category: Maths (Geometry))
Project the current ship or planet onto the screen
[X]
Subroutine SUN (Part 1 of 4) (category: Drawing suns)
Draw the sun: Set up all the variables needed to draw the sun