Skip to navigation

Lander on the Acorn Archimedes

Main loop: StartNewGame

Name: StartNewGame [Show more] Type: Subroutine Category: Main loop Summary: Start a brand new game with a full set of lives and a newly generated set of objects
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GameOver calls StartNewGame
.StartNewGame \ We start by initialising the scores and \ printing them on the score bar LDR R0, [R11, #highScore] \ Set R0 to the current high score LDR R1, [R11, #currentScore] \ Set R1 to our current score CMP R1, R0 \ If R1 - R0 is positive, i.e. R1 >= R0, MOVPL R0, R1 \ then our latest score is higher than the \ high score, so set R0 to our latest score \ \ So R0 is set to the maximum of highScore \ and currentScore, which is the new high \ score STRHS R0, [R11, #highScore] \ If R1 >= R0 then we just updated the high \ score and the new high score is in R0, so \ store the new high score in highScore MOV R1, #35 \ Set (R1, R2) = (35, 1) so the following MOV R2, #1 \ call to PrintScoreInBothBanks prints the \ high score at column 35 on row 1 BL PrintScoreInBothBanks \ Print the high score in R0 at column 35 on \ row 1, at the right end of the score bar LDR R0, initialScore \ Initialise currentScore to the score that STR R0, [R11, #currentScore] \ we start each game with, which is set in \ initialScore \ We now initialise more game variables LDR R0, initialFuelLevel \ Initialise fuelLevel to the fuel level STR R0, [R11, #fuelLevel] \ that we start each game with, which is set \ in initialFuelLevel MOV R0, #&30000 \ Initialise gravity to &30000 STR R0, [R11, #gravity] MOV R0, #3 \ Initialise the number of lives to 3 STR R0, [R11, #remainingLives]