Skip to navigation

Particles: BounceParticle

Name: BounceParticle [Show more] Type: Subroutine Category: Particles Summary: Bounce a particle off the ground Deep dive: Particles and particle clouds
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MoveAndDrawParticles (Part 1 of 4) calls BounceParticle

Arguments: (R0, R1, R2) Particle coordinates (R3, R4, R5) Particle velocity R7 Particle flags R9 The altitude of the landscape directly below the particle
.BounceParticle MOV R1, R9 \ Set R1 to R9, so (R0, R1, R2) now contains \ the coordinates of the point on the \ landscape directly below the particle CMP R9, #SEA_LEVEL \ If the particle is above the sea, jump to BEQ SplashParticleIntoSea \ SplashParticleIntoSea to splash the \ particle into the sea, returning from the \ subroutine using a tail call TST R7, #&00080000 \ If bit 19 of the particle flags is clear, BEQ DeleteParticleData \ jump to DeleteParticleData to delete the \ particle without bouncing or exploding TST R7, #&01000000 \ If bit 24 of the particle flags is set, BNE AddSmallExplosionToBuffer \ jump to AddSmallExplosionToBuffer to \ destroy the particle in a small explosion MOV R3, R3, ASR #1 \ Otherwise we bounce the particle off the MOV R4, R4, ASR #1 \ ground by setting the particle's velocity MOV R5, R5, ASR #1 \ vector to half its previous speed, and in RSB R4, R4, #0 \ the opposite direction in the y-axis MOV PC, R14 \ Return from the subroutine