.FinishLandscape SED \ Set the D flag to switch arithmetic to binary coded \ decimal (BCD), so the call to GetPlayerEnergyBCD and \ the following addition are all done in BCD JSR GetPlayerEnergyBCD \ Set A to the player's energy in BCD CLC \ Set (Y X) = landscapeNumber(Hi Lo) + A ADC landscapeNumberLo \ TAX \ This addition is done in BCD so the result is a new LDA landscapeNumberHi \ landscape number that's also in BCD (which we need to ADC #0 \ do as landscape numbers are in BCD) TAY CLD \ Clear the D flag to switch arithmetic to normal JSR InitialiseSeeds \ Initialise the seed number generator to generate the \ sequence of seed numbers for the landscape number in \ (Y X) and set maxNumberOfEnemies and the landscapeZero \ flag accordingly \ We set bit 7 of doNotPlayLandscape when the landscape \ was completed in the PerformHyperspace routine, so the \ following calls to GenerateLandscape and SpawnPlayer \ return normally, without previewing the landscape \ (GenerateLandscape) or starting the game (SpawnPlayer) JSR GenerateLandscape \ Call GenerateLandscape to generate the landscape JSR SpawnEnemies \ Calculate the number of enemies for this landscape, \ add them to the landscape and set the palette \ accordingly JSR SpawnPlayer \ Add the player and trees to the landscape LDA #&80 \ Call DrawTitleScreen with A = &80 to draw the screen JSR DrawTitleScreen \ showing the landscape's secret code LDX #5 \ Print text token 5: Print "SECRET ENTRY CODE" at JSR PrintTextToken \ (64, 768), "LANDSCAPE" at (192, 704), move cursor \ right JMP PrintLandscapeNum \ Print the four-digit landscape (0000 to 9999) and \ return from the subroutine using a tail callName: FinishLandscape [Show more] Type: Subroutine Category: Main game loop Summary: Add the player's energy to the landscape number to get the number of the next landscape and display that landscape's secret codeContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainGameLoop calls FinishLandscape
[X]
Subroutine DrawTitleScreen (category: Title screen)
Draw the title screen or the screen showing the secret code
[X]
Subroutine GenerateLandscape (category: Landscape)
Generate tile data for the landscape
[X]
Subroutine GetPlayerEnergyBCD (category: Maths (Arithmetic))
Fetch the player's energy in binary coded decimal (BCD)
[X]
Subroutine InitialiseSeeds (category: Landscape)
Initialise the seed number generator so it generates the sequence of seed numbers for a specific landscape number
[X]
Subroutine PrintLandscapeNum (category: Text)
Print the four-digit landscape number (0000 to 9999)
[X]
Subroutine PrintTextToken (category: Text)
Print a recursive text token
[X]
Subroutine SpawnEnemies (category: Landscape)
Calculate the number of enemies for this landscape, add them to the landscape and set the palette accordingly
[X]
Subroutine SpawnPlayer (category: Landscape)
Add the player object to the landscape, ideally placing it below all the enemies and in the bottom half of the landscape
[X]
Variable landscapeNumberHi in workspace Main variable workspace
The high byte of the four-digit binary coded decimal landscape number (0000 to 9999)
[X]
Variable landscapeNumberLo in workspace Main variable workspace
The low byte of the four-digit binary coded decimal landscape number (0000 to 9999)