.DropRocksFromTheSky LDR R4, [R11, #currentScore] \ Set R4 to the current score minus 800 SUBS R4, R4, #800 MOVMI PC, R14 \ If the result is negative then the current \ score is 800 or less, so return from the \ subroutine without dropping any rocks \ If we get here then the current score is \ greater than 800, so we randomly drop \ rocks from the sky STMFD R13!, {R14} \ Store the return address on the stack BL GetRandomNumbers \ Set R0 and R1 to random numbers MOV R0, R0, LSR #18 \ Scale R0 to the range 0 to 16383 CMP R0, R4 \ If R0 >= R4 then return from the LDMHSIA R13!, {PC} \ subroutine without dropping a rock, so the \ chances of a rock dropping from the sky on \ each iteration of the main loop increases \ with higher scores \ If we get here then we drop a rock from \ the sky, spawning the rock at coordinates \ (R0, R1, R2), which are set to ROCK_HEIGHT \ tiles above and PLAYER_FRONT_Z tiles \ forwards from the camera coordinates, \ which is very high in the sky above the \ ship's current position and one tile in \ front of the ship LDR R0, [R11, #xCamera] \ Set R0 = xCamera MVN R1, #ROCK_HEIGHT \ Set R1 = ~ROCK_HEIGHT \ = -(ROCK_HEIGHT + 1) LDR R2, [R11, #zCamera] \ Set R2 = zCamera - PLAYER_FRONT_Z SUB R2, R2, #PLAYER_FRONT_Z BL DropARockFromTheSky \ Drop a rock from the coordinates in \ (R0, R1, R2) by spawning it as a \ particle, albeit a very big particle with \ an associated 3D object LDMFD R13!, {PC} \ Return from the subroutineName: DropRocksFromTheSky [Show more] Type: Subroutine Category: Particles Summary: If the score is 800 or more, then randomly drop rocks from the sky by spawning them as particlesContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop calls DropRocksFromTheSky
[X]
Subroutine DropARockFromTheSky (category: Particles)
Drop a rock from the specified coordinates by spawning it as a particle, albeit a very big particle with an associated 3D object
[X]
Subroutine GetRandomNumbers (category: Maths (Arithmetic))
Generate pseudo-random numbers from the random number seeds
[X]
Configuration variable PLAYER_FRONT_Z = (TILES_Z - 5) * TILE_SIZE
The distance along the z-axis between the tile in front of the player and the camera, which is where we spawn explosions and falling rocks (set to six tiles forwards from the camera)
[X]
Configuration variable ROCK_HEIGHT = TILE_SIZE * 32
The height from which we drop rocks from the sky (32 tile sizes)
[X]
Configuration variable currentScore = &124
Our current score, which is displayed at the left end of the score bar
[X]
Configuration variable xCamera = &13C
The 3D x-coordinate of the camera position (though note that the camera position is actually at the back of the on-screen landscape, not the front)
[X]
Configuration variable zCamera = &144
The 3D z-coordinate of the camera position (though note that the camera position is actually at the back of the on-screen landscape, not the front, so the camera's z-coordinate is larger than it would be for a more traditional camera position; it is more like the camera's focal point than position, in a sense)