Skip to navigation

Lander on the Acorn Archimedes

Player: LandOnLaunchpad

Name: LandOnLaunchpad [Show more] Type: Subroutine Category: Player Summary: Check to see if the player has landed on the launchpad Deep dive: Collisions and bullets
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MoveAndDrawPlayer (Part 3 of 5) calls LandOnLaunchpad

We call this routine from MoveAndDrawPlayer when the player's altitude matches that of the launchpad, so this performs additional checks to see if the player just landed.
Returns: R1 The y-coordinate of the player's ship
.LandOnLaunchpad ADD R3, R11, #xPlayer \ Fetch the six words at xPlayer as follows: LDMIA R3, {R0-R5} \ \ (R0, R1, R2) = the player's coordinates \ from (xPlayer, yPlayer, zPlayer) \ \ (R3, R4, R5) = the player's velocity \ from (xVelocity, yVelocity, zVelocity) CMP R0, #LAUNCHPAD_SIZE \ If either of xPlayer or zPlayer is >= CMPLO R2, #LAUNCHPAD_SIZE \ LAUNCHPAD_SIZE then we are not over the BHS LoseLife \ launchpad, as the launchpad is defined as \ this part of the map: \ \ 0 <= x \ \ and: \ \ 0 <= z \ \ So we just crashed into the ground rather \ than the launchpad, so jump to LoseLife to \ process the crash CMP R3, #0 \ Set R3 = |R3| RSBMI R3, R3, #0 \ = |xVelocity| CMP R4, #0 \ Set R4 = |R4| RSBMI R4, R4, #0 \ = |yVelocity| CMP R5, #0 \ Set R5 = |R5| RSBMI R5, R5, #0 \ = |zVelocity| ADD R3, R3, R4 \ If R3 + R4 + R5 >= LANDING_SPEED, then: ADD R3, R3, R5 \ CMP R3, #LANDING_SPEED \ |xVelocity| + |yVelocity| + |zVelocity| MOVHS PC, R14 \ \ is greater than the safe landing speed, so \ we can't be performing a safe landing, so \ return from the subroutine \ If we get here then we have landed, as the \ altitude checks were made before this \ routine was called, we know we are above \ the launchpad, and our speed is slow \ enough to land \ \ So now we start refuelling MOV R1, #LAUNCHPAD_Y \ Set R1 to the y-coordinate of the player's \ ship as it sits on the launchpad (which is \ set to the launchpad altitude plus the \ height of the ship's undercarriage) LDR R3, [R11, #fuelLevel] \ Bump up the fuel level by 1/160 of a full ADD R3, R3, #&20 \ tank CMP R3, #&1400 STRLO R3, [R11, #fuelLevel] MOV R3, #0 \ Zero the player's velocity MOV R4, #0 MOV R5, #0 STR R3, [R11, #xVelocity] STR R4, [R11, #yVelocity] STR R5, [R11, #zVelocity] STR R1, [R11, #yPlayer] \ Set the y-coordinate of the player to the \ y-coordinate of the launchpad, so the \ player's ship is resting correctly on the \ pad MOV PC, R14 \ Return from the subroutine