Skip to navigation

Main title loop: FinishLandscape

Name: 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 loop
Context: 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
.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 screen