.nWq LDA nmiCounter ; Set the random number seeds to a fairly random state CLC ; that's based on the NMI counter (which increments ADC RAND ; every VBlank, so will be pretty random) STA RAND LDA nmiCounter STA RAND+1 LDY NOSTM ; Set Y to the current number of stardust particles, so ; we can use it as a counter through all the stardust .SAL4 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 JSR DORND ; Set A and X to random numbers ORA #8 ; Set A so that it's at least 8 STA SZ,Y ; Store A in the Y-th particle's z_hi coordinate at ; SZ+Y, so the particle appears in front of us STA ZZ ; Set ZZ to the particle's z_hi coordinate JSR DORND ; Set A and X to random numbers ORA #16 ; Set A so that it's at least 16 AND #%11111000 ; Zero bits 0 to 2 of A so that it's a multiple of 8 STA SX,Y ; Store A in the Y-th particle's x_hi coordinate at ; SX+Y, so the particle appears in front of us JSR DORND ; Set A and X to random numbers STA SY,Y ; Store A in the Y-th particle's y_hi coordinate at ; SY+Y, so the particle appears in front of us STA SXL,Y ; Store A in the low bytes of the Y-th particle's three STA SYL,Y ; coordinates STA SZL,Y DEY ; Decrement the counter to point to the next particle of ; stardust BNE SAL4 ; Loop back to SAL4 until we have randomised all the ; stardust particles ; Fall through into WPSHPS to hide ships from the screenName: nWq [Show more] Type: Subroutine Category: Stardust Summary: Create a random cloud of stardustContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DEATH calls nWq
Create a random cloud of stardust containing the correct number of dust particles, i.e. NOSTM of them, which is 3 in witchspace and 20 (#NOST) in normal space. Also hides ships from the screen. This is called by the DEATH routine when it displays our untimely demise.
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Label SAL4 is local to this routine
[X]
Macro SETUP_PPU_FOR_ICON_BAR (category: PPU)
If the PPU has started drawing the icon bar, configure the PPU to use nametable 0 and pattern table 0
[X]
Variable nmiCounter in workspace WP
A counter that increments every VBlank at the start of the NMI handler