.ApplyEnemyTactics TSX \ Store the stack pointer in gameplayStack, so we can STX gameplayStack \ return back to the ProcessGameplay routine from deep \ within the tactics routines if required LDX enemyObject \ Set X to the object number of the enemy to which we \ are thinking of applying tactics in this iteration of \ the gameplay loop (so object #X is the object that we \ are considering) LDA objectTypes,X \ Set A to the type of object #X CMP #1 \ If we are considering applying tactics to a sentry (an BEQ etac1 \ object of type 1) then jump to etac1 to apply tactics CMP #5 \ If we are not applying tactics to the Sentinel (an BNE MoveOnToNextEnemy \ object of type 5), then enemyObject is neither a \ sentry nor the Sentinel \ \ We only apply tactics to the Sentinel and sentries, \ so we don't need to apply tactics to this object \ \ So jump to MoveOnToNextEnemy to stop applying tactics \ to this enemy and set things up so we move on to the \ next enemy in the next iteration of the gameplay loop .etac1 STA titleObjectToDraw \ If we get here then we are applying tactics to the \ Sentinel or a sentry, so set titleObjectToDraw to the \ corresponding object type so if the enemy causes the \ player to lose, then the game over screen will show \ that enemy type to indicate that it was responsible \ for the player's demise LDA objectFlags,X \ Set A to the object flags for object #X (which is the \ object that we are applying tactics to) BPL ApplyTactics \ If bit 7 of the object flags is clear then this object \ number is allocated to a valid object, so jump to \ ApplyTactics to apply tactics to the object and return \ from the subroutine using a tail call \ If we get here then bit 7 of the enemy object's flags \ is clear, so the enemy has been removed from the \ landscape at some point JSR ExpendEnemyEnergy \ Drain one unit of energy from the enemy and expend it \ onto the landscape by spawning a tree, if possible \ \ This ensures that if an enemy has absorbed energy from \ somewhere, it always dissipates back into the \ landscape it when it gets the chance \ \ If we can't spawn a tree because we are about to pan \ the screen and the tree would spawn in a position that \ would be visible on-screen, then the routine does not \ expend energy or spawn a tree, and instead it gives up \ and aborts applying tactics for this gameplay loop \ \ If we successfully spawned a tree then the object \ number of the tree is in X BCS MoveOnToNextEnemy \ If the call to ExpendEnemyEnergy returned with the C \ flag set, then either the enemy didn't have any energy \ to expend or we couldn't spawn a tree, so jump to \ MoveOnToNextEnemy to stop applying tactics to this \ enemy and set things up so we move on to the next \ enemy in the next iteration of the gameplay loop JMP tact25 \ Otherwise jump to tact25 with X set to the object \ number of the tree to update it on-screen with a \ dithered effect and return from the subroutine using \ a tail callName: ApplyEnemyTactics [Show more] Type: Subroutine Category: Gameplay Summary: Apply tactics to an enemy object, setting things up so the next call applies tactics to the next enemy objectContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessGameplay calls ApplyEnemyTactics
Arguments: enemyObject The object number of the enemy to which we apply tactics (0 to 7)
[X]
Subroutine ApplyTactics (Part 1 of 8) (category: Gameplay)
Apply tactics to the Sentinel or a sentry
[X]
Subroutine ExpendEnemyEnergy (category: Gameplay)
Drain one unit of energy from an enemy and expend it onto the landscape by spawning a tree, if possible
[X]
Subroutine MoveOnToNextEnemy (category: Gameplay)
Update enemyObject so the next time we consider applying enemy tactics, we apply them to the next enemy, looping from 7 to 0
[X]
Variable enemyObject in workspace Zero page
The object number of the enemy to which we are applying tactics in this iteration around the main loop (0-7)
[X]
Label etac1 is local to this routine
[X]
Variable gameplayStack in workspace Main variable workspace
The value of the stack pointer at the start of the ApplyEnemyTactics routine, so we can return back to the ProcessGameplay routine from deep within the tactics routines if required
[X]
Variable objectFlags in workspace Stack variables
Object flags for up to 64 objects
[X]
Variable objectTypes (category: 3D objects)
The object types table for up to 64 objects
[X]
Entry point tact25 in subroutine ApplyTactics (Part 8 of 8) (category: Gameplay)
Dither the updated object #X onto the screen, with bit 7 of drawLandscape determining whether the object is drawn on its own (bit 7 set) or with the surrounding landscape (bit 7 clear)
[X]
Variable titleObjectToDraw in workspace Main variable workspace
The object we are drawing in the DrawTitleView routine