.MainLoop MOV R0, #129 \ Call OS_Byte 129 to read the keyboard with MOV R1, #0 \ the time limit in R1 and R2 (so that's MOV R2, #0 \ with no time limit as R1 and R2 are zero), SWI OS_Byte \ returning the result in R2 TEQ R2, #&1B \ If R2 = &1B then an escape condition BEQ EndGame \ occurred during the keyboard scan (in \ other words, Escape was pressed), so jump \ to EndGame to acknowledge the escape \ condition and quit the game BL MoveAndDrawPlayer \ Move the player's ship and draw it into \ the graphics buffers \ We now set up the rotation matrix for the \ rocks, using the main loop counter to \ generate rotation angles that change along \ with the main loop (so the rocks spin at a \ nice steady speed) LDR R0, [R11, #mainLoopCount] \ Set R0 = mainLoopCount << 24 MOV R0, R0, LSL #24 MOV R1, R0, LSL #1 \ Set R1 = mainLoopCount << 25 BL CalculateRotationMatrix \ Calculate the rotation matrix from the \ "angles" given in R0 and R1, which we can \ apply to any rocks we draw in the \ MoveAndDrawParticles routine (as rocks are \ only rotating 3D objects apart from the \ player, and the player calculates its own \ rotation matrix) BL DropRocksFromTheSky \ If the score is 800 or more, then randomly \ drop rocks from the sky BL MoveAndDrawParticles \ Move and draw all the particles, such as \ smoke clouds and bullets, into the \ graphics buffers BL DrawObjects \ Draw all the objects, such as trees and \ buildings, into the graphics buffers BL AddTerminatorsToBuffers \ Add terminators to the ends of the \ graphics buffers so we know when to stop \ drawing BL DrawLandscapeAndBuffers \ Draw the landscape and the contents of the \ graphics buffers BL PrintCurrentScore \ Print the number of remaining bullets at \ the left end of the score bar BL DrawFuelLevel \ Draw the fuel bar BL SwitchScreenBank \ Switch screen banks and clear the newly \ hidden screen bank to black LDR R14, [R11, #mainLoopCount] \ Increment the main loop counter ADD R14, R14, #1 STR R14, [R11, #mainLoopCount] B MainLoop \ Loop back to repeat the main loopName: MainLoop [Show more] Type: Subroutine Category: Main loop Summary: The main game loop Deep dive: The main game loopContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine AddTerminatorsToBuffers (category: Graphics buffers)
Add terminators to the ends of the graphics buffers so we know when to stop drawing
[X]
Subroutine CalculateRotationMatrix (category: Maths (Geometry))
Calculate the rotation matrix
[X]
Subroutine DrawFuelLevel (category: Score bar)
Draw the bar at the top of the screen showing the current fuel level
[X]
Subroutine DrawLandscapeAndBuffers (Part 1 of 4) (category: Landscape)
Draw the landscape and the contents of the graphics buffers, from the back of the screen to the front
[X]
Subroutine DrawObjects (Part 1 of 3) (category: 3D objects)
Draw all the objects in the visible portion of the object map, starting by working our way through the map looking for objects
[X]
Subroutine DropRocksFromTheSky (category: Particles)
If the score is 800 or more, then randomly drop rocks from the sky by spawning them as particles
[X]
Subroutine EndGame (category: Main loop)
Finish the game
[X]
Subroutine MainLoop (category: Main loop)
The main game loop
[X]
Subroutine MoveAndDrawParticles (Part 1 of 4) (category: Particles)
Process particle movement and draw the particles into the graphics buffers, starting with the movement of particles
[X]
Subroutine MoveAndDrawPlayer (Part 1 of 5) (category: Player)
Process player movement and draw the player's ship into the graphics buffers, starting with reading the mouse position
[X]
Configuration variable OS_Byte = &06
General-purpose operating system calls
[X]
Subroutine PrintCurrentScore (category: Score bar)
Print the current score at the left end of the score bar
[X]
Subroutine SwitchScreenBank (category: Drawing the screen)
Switch screen banks and clear the newly hidden screen bank to black
[X]
Configuration variable mainLoopCount = &118
The main loop counter