.FinishLandscape \ If we get here then we have successfully completed \ the landscape, so we display the secret code for the \ next landscape and go back to the title screen LDA #4 \ Set all four logical colours to physical colour 4 JSR SetColourPalette \ (blue), so this blanks the entire screen to blue \ In order to display the secret code for the next \ landscape we need to generate it, so we now reset the \ landscape seed generator, the tile visibility table \ and the object flags, to get ready for the generation \ process in the GetNextLandscape routine LDX #3 \ We now zero bits 8 to 40 of the five-byte linear \ feedback shift landscape register, so set a byte \ counter in X to count four bytes LDA #0 \ Set A = 0 so we can zero the four bytes STA soundEffect \ Set soundEffect = 0 to disable sound effect processing \ in the ProcessSound routine .flan1 STA seedNumberLFSR+1,X \ Zero byte X+1 of seedNumberLFSR(4 3 2 1 0) DEX \ Decrement the byte counter BPL flan1 \ Loop back until we have reset all four bytes JSR ResetTilesObjects \ Reset the tile visibility table and deallocate all \ object numbers JSR GetNextLandscape \ Add the player's energy to the landscape number to get \ the number of the next landscape and display that \ landscape's secret code as a title screen LDA #&87 \ Set the palette to the second set of colours from the JSR SetColourPalette \ colourPalettes table, which contains the fixed palette \ for the title screens (blue, black, red, yellow) LDA #10 \ Set soundCounter = 10 to count down while the next STA soundCounter \ sound is made LDA #66 \ Call the PlayMusic routine with A = 66 to play the JSR PlayMusic \ music for when the player finishes a landscape .flan2 JSR ProcessSound \ Process any sounds or music that are being made in the \ background LDA musicCounter \ Loop back to keep calling ProcessSound until bit 7 of BPL flan2 \ musicCounter is clear, so if any music is being \ played, we wait until it has finished LDX #6 \ Print text token 6: Print "PRESS ANY KEY" at (64, 100) JSR PrintTextToken JSR ReadKeyboard \ Enable the keyboard, flush the keyboard buffer and \ read a character from it (so this waits for a key \ press) .flan3 JMP MainTitleLoop \ Jump to MainTitleLoop to restart the game from the \ title screenName: FinishLandscape [Show more] Type: Subroutine Category: Main title loop Summary: Process the successful completion of a landscape by displaying the secret code for the next landscape and jumping to the title screen Deep dive: Program flow of the main title loopContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainGameLoop (Part 1 of 2) calls FinishLandscape * GetTileAltitudes calls via flan3
Other entry points: flan3 Jump to MainTitleLoop to restart the game
[X]
Subroutine GetNextLandscape (category: Main title loop)
Add the player's energy to the landscape number to get the number of the next landscape and display that landscape's secret code
[X]
Subroutine MainTitleLoop (category: Main title loop)
The main title loop: display the title screen, fetch the landscape number/code, preview the landscape and jump to the main game loop
[X]
Subroutine PlayMusic (category: Sound)
Play a piece of music
[X]
Subroutine PrintTextToken (category: Text)
Print a recursive text token
[X]
Subroutine ProcessSound (category: Sound)
Process any sound effects that have been configured so they play in the background (this is called regularly throughout gameplay)
[X]
Subroutine ReadKeyboard (category: Keyboard)
Enable the keyboard and read a character from it
[X]
Subroutine ResetTilesObjects (category: Main title Loop)
Reset the tile visibility table and deallocate all object numbers
[X]
Subroutine SetColourPalette (category: Graphics)
Set the logical colours for each of the four physical colours in screen mode 5
[X]
Label flan1 is local to this routine
[X]
Label flan2 is local to this routine
[X]
Variable musicCounter in workspace Main variable workspace
A counter for the music currently being made, which counts up in the ProcessMusic routine while the music is being played
[X]
Variable seedNumberLFSR in workspace Main variable workspace
A five-byte linear feedback shift register for
[X]
Variable soundCounter in workspace Main variable workspace
A counter for the sound currently being made, which counts down in the IRQHandler routine at a rate of 50 times a second
[X]
Variable soundEffect in workspace Main variable workspace
Determines how the current sound is processed by the ProcessSound routine