\ The following loop iterates CNT2(1 0) times, i.e. &1DD \ or 477 times, and draws the background stars on the \ loading screen .PLL2 JSR DORND \ Set A and X to signed random numbers between -128 and \ 127, so let's say A = r3 TAX \ Set X = A \ = r3 JSR SQUA2 \ Set (A P) = A * A \ = r3^2 STA ZP+1 \ Set ZP+1 = A \ = r3^2 / 256 JSR DORND \ Set A and X to signed random numbers between -128 and \ 127, so let's say A = r4 STA YY \ Set YY = r4 JSR SQUA2 \ Set (A P) = A * A \ = r4^2 ADC ZP+1 \ Set A = A + r3^2 / 256 \ = r4^2 / 256 + r3^2 / 256 \ = (r3^2 + r4^2) / 256 CMP #&11 \ If A < 17, jump down to PLC2 to skip to the next pixel BCC PLC2 LDA YY \ Set A = r4 JSR PIX \ Draw a pixel at screen coordinate (X + 128, A + 128), \ where: \ \ X = r3 \ A = r4 \ \ So this is the same as plotting at (x, y) where: \ \ r3 = random number from -128 to 127 \ r4 = random number from -128 to 127 \ \ (r3^2 + r4^2) / 256 >= 17 \ \ x = r3 \ y = r4 \ \ which is what we want .PLC2 DEC CNT2 \ Decrement the counter in CNT2 (the low byte) BNE PLL2 \ Loop back to PLL2 until CNT2 = 0 DEC CNT2+1 \ Decrement the counter in CNT2+1 (the high byte) BNE PLL2 \ Loop back to PLL2 until CNT2+1 = 0 LDX MHCA \ Set the low byte of BLPTR(1 0) to the contents of MHCA STX BLPTR \ (which is &CA), so we now have BLPTR(1 0) = &03CA, \ which we will use in the IRQ1 handler (this has \ nothing to do with drawing Saturn, it's all part of \ the copy protection) LDX #&C6 \ Set the low byte of BLN(1 0) to &C6, so we now have STX BLN \ BLN(1 0) = &03C6, which we will use in the IRQ1 \ handler (this has nothing to do with drawing Saturn, \ it's all part of the copy protection)Name: PLL1 (Part 2 of 3) [Show more] Type: Subroutine Category: Drawing planets Summary: Draw Saturn on the loading screen (draw the stars) Deep dive: Drawing Saturn on the loading screenContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: No direct references to this subroutine in this source file
[X]
Variable CNT2 (category: Drawing planets)
A counter for use in drawing Saturn's background stars
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Variable MHCA (category: Copy protection)
Used to set one of the vectors in the copy protection code
[X]
Subroutine PIX (category: Drawing pixels)
Draw a single pixel at a specific coordinate
[X]
Label PLC2 is local to this routine
[X]
Label PLL2 is local to this routine
[X]
Subroutine SQUA2 (category: Maths (Arithmetic))
Calculate (A P) = A * A
[X]
Workspace ZP (category: Workspaces)
Important variables used by the loader