.SpawnEnemies LDA landscapeZero \ If this is not landscape 0000, jump to popu1 to BNE popu1 \ calculate the number of enemies to spawn LDA #1 \ This is landscape 0000, so set A = 1 to use for the \ total number of enemies BNE popu2 \ Jump to popu2 to set numberOfEnemies to the value of A .popu1 JSR GetEnemyCount \ Set A to the enemy count for this landscape, which is \ derived from the top digit of the landscape number and \ the next number in the landscape's sequence of seed \ numbers, so it is always the same value for the same \ landscape number \ \ At this point A is in the range 1 to 8, with higher \ values for higher landscape numbers CMP maxNumberOfEnemies \ If A < maxNumberOfEnemies then skip the following BCC popu2 \ instruction LDA maxNumberOfEnemies \ Set A = maxNumberOfEnemies, so the number of enemies \ does not exceed the value of maxNumberOfEnemies that \ we set in the InitialiseSeeds routine \ \ So landscapes 0000 to 0009 have a maximum enemy count \ of 1, landscapes 0010 to 0019 have a maximum enemy \ count of 2, and so on up to landscapes 0070 and up, \ which have a maximum enemy count of 8 .popu2 STA numberOfEnemies \ Store the number of enemies for this landscape in \ numberOfEnemies JSR AddEnemiesToTiles \ Add the required number of enemies to the landscape, \ starting from the highest altitude and working down, \ with no more than one enemy on each contour \ We now update colours 2 and 3 in the first palette in \ colourPalettes according to the number of enemies LDA numberOfEnemies \ Set X = (numberOfEnemies - 1) mod 8 SEC \ SBC #1 \ The mod 8 is not strictly necessary as numberOfEnemies AND #7 \ is in the range 1 to 8, but doing this ensures we can TAX \ safely use X as an index into the landscapeColour \ tables LDA landscapeColour3,X \ Set colour 3 in the game palette to the X-th entry STA colourPalettes+3 \ from landscapeColour3 LDA landscapeColour2,X \ Set colour 2 in the game palette to the X-th entry STA colourPalettes+2 \ from landscapeColour2 RTS \ Return from the subroutineName: SpawnEnemies [Show more] Type: Subroutine Category: Landscape Summary: Calculate the number of enemies for this landscape, add them to the landscape and set the palette accordinglyContext: See this subroutine in context in the source code References: This subroutine is called as follows: * FinishLandscape calls SpawnEnemies * PreviewLandscape calls SpawnEnemies
[X]
Subroutine AddEnemiesToTiles (category: Landscape)
Add the required number of enemies to the landscape, starting from the highest altitude and working down, with one enemy per contour
[X]
Subroutine GetEnemyCount (category: Landscape)
Calculate the number of enemies for the current landscape
[X]
Variable colourPalettes (category: Graphics)
The logical colours for two mode 5 palettes
[X]
Variable landscapeColour2 (category: Landscape)
Physical colours for colour 2 in the game palette for the different numbers of enemies
[X]
Variable landscapeColour3 (category: Landscape)
Physical colours for colour 3 in the game palette for the different numbers of enemies
[X]
Variable landscapeZero in workspace Main variable workspace
A flag that is set depending on whether we are playing landscape 0000
[X]
Variable maxNumberOfEnemies in workspace Main variable workspace
The maximum number of enemies that can appear on the current landscape, which is calculated as follows
[X]
Variable numberOfEnemies in workspace Main variable workspace
The number of enemies in the current landscape, including the Sentinel (in the range 1 to 8)
[X]
Label popu1 is local to this routine
[X]
Label popu2 is local to this routine