Skip to navigation

Lander on the Acorn Archimedes

Particles: AddSparkParticleToBuffer

Name: AddSparkParticleToBuffer [Show more] Type: Subroutine Category: Particles Summary: Add a spark particle to the particle data buffer that fades from white-hot to red over time
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * AddExplosionToBuffer calls AddSparkParticleToBuffer * AddSparkCloudToBuffer calls AddSparkParticleToBuffer

Arguments: (R0, R1, R2) Particle coordinates Deep dive: Particles and particle clouds
.AddSparkParticleToBuffer STMFD R13!, {R8, R14} \ Store R8 and the return address on the \ stack, so the call to the particle adding \ routine below can return properly MOV R7, #&001D0000 \ Set bits 16, 18, 19 and 20 of the particle \ flags, so that's: \ \ * Bit 16 set = colour fades white to red \ * Bit 18 set = splash on impact with sea \ * Bit 19 set = bounce on ground \ * Bit 20 set = apply gravity to particle MOV R9, #29 \ Set the random element of the particle's \ lifespan to the range 0 to 2^(32 - 29), \ i.e. 0 to 8 MOV R8, #8 \ Set the random element of the particle's \ velocity to the range +/- 2^(32 - 8), \ i.e. -&1000000 to +&1000000 MOV R6, #8 \ Set the particle's lifespan counter to 8 \ iterations of the main loop B AddStaticParticleToBuffer \ Add a particle to the particle data buffer \ that starts off static, and with a random \ element being added to its velocity and \ lifespan counter, returning from the \ subroutine using a tail call