\ If we get here then the particle is a \ rock, so we need to check whether it has \ hit the player's ship STMFD R13!, {R0-R2} \ Store the rock coordinates in (R0, R1, R2) \ on the stack so we can retrieve them below LDR R14, [R11, #playingGame] \ If playingGame = 0 then this is the crash CMP R14, #0 \ animation, so jump to dpar3 to draw the BEQ dpar3 \ rock, skipping the call to lose a life (as \ the EQ condition is true, which does not \ match BLO) CMP R0, #0 \ Set R0 = |R0| RSBMI R0, R0, #0 \ = |rock x-coordinate| SUBS R2, R2, #LANDSCAPE_Z_MID \ Set R2 = |R2 - LANDSCAPE_Z_MID| RSBMI R2, R2, #0 \ = |rock z-coordinate - 15 tiles| \ \ Because the player's ship is always at \ x-coordinate 0 and the z-coordinate at \ the mid-point of the landscape, this works \ out the rock's coordinate relative to the \ ship (for the x- and z-coordinates) \ \ The rock object is one tile in size along \ each axis, so we can do a check against \ the file size to see if we are being hit \ by the rock CMP R0, #TILE_SIZE \ If either of R0 or R2 is bigger than one CMPLO R2, #TILE_SIZE \ tile size, jump to dpar3 as the rock is BHS dpar3 \ missing us, skipping the call to lose a \ life (as the HS condition is true, which \ does not match BLO) \ The rock is overlapping the player in \ either the x- or z-coordinate, so now we \ need to check its altitude LDR R0, [R11, #yCamera] \ Set R1 = |R1 + yCamera - yPlayer| ADD R1, R1, R0 \ LDR R0, [R11, #yPlayer] \ So R1 contains the y-coordinate of the SUBS R1, R1, R0 \ rock relative to the player, which we can RSBMI R1, R1, #0 \ also test against the tile size to check \ for a collision CMP R1, #TILE_SIZE \ If R1 < TILE_SIZE then the LO condition \ will be true, which will send us to \ LoseLifeFromParticleLoop below to lose a \ life, as the rock has hit us .dpar3 LDMFD R13!, {R0-R2} \ Retrieve the rock coordinates that we \ stored above into (R0, R1, R2) BLO LoseLifeFromParticleLoop \ Jump to LoseLifeFromParticleLoop if the LO \ condition is true, which will only be the \ case if we reached the CMP just before \ dpar3 and R1 < TILE_SIZE LDR R14, objectRockAddr \ Store the address of the rock's object STR R14, [R11, #objectData] \ blueprint in objectData to pass to the \ DrawObject routine ADD R3, R11, #rotationMatrix \ Set R3 to the address of the rock's \ rotation matrix, to pass to DrawObject BL DrawObject \ Draw the rock into the graphics buffers B dpar1 \ Loop back to dpar1 to process the next \ particle in the particle data bufferName: MoveAndDrawParticles (Part 3 of 4) [Show more] Type: Subroutine Category: Particles Summary: Process rocks by checking for collisions and drawing them as 3D objects Deep dive: Drawing 3D objects Particles and particle clouds Collisions and bulletsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine DrawObject (Part 1 of 5) (category: 3D objects)
Draw a 3D object and its shadow
[X]
Configuration variable LANDSCAPE_Z_MID = LANDSCAPE_Z - CAMERA_PLAYER_Z
The z-coordinate of the mid-point of the landscape depth (i.e. the player)
[X]
Subroutine LoseLifeFromParticleLoop (category: Main loop)
Lose a life when a crash is detected in the particle processing loop
[X]
Configuration variable TILE_SIZE = &01000000
The length of one side of a square landscape tile in 3D coordinates
[X]
Entry point dpar1 in subroutine MoveAndDrawParticles (Part 1 of 4) (category: Particles)
The start of the main particle-processing loop
[X]
Label dpar3 is local to this routine
[X]
Configuration variable objectData = &110
The address of the blueprint for the object currently being drawn
[X]
Variable objectRockAddr (category: 3D objects)
The address of the object blueprint for a rock
[X]
Configuration variable playingGame = &130
A flag to determine whether the game is being player, or whether this is the crash animation
[X]
Configuration variable rotationMatrix = &30
The rotation matrix of the object currently being drawn (i.e. the matrix formed from the object's three orientation vectors)
[X]
Configuration variable yCamera = &140
The 3D y-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 yPlayer = &98
The y-coordinate of the player's ship