Skip to navigation

Cracker protection: SetPlayerIsOnTower

Name: SetPlayerIsOnTower [Show more] Type: Subroutine Category: Cracker protection Summary: Set up the playerIsOnTower value for checking the game is won, as part of the anti-cracker code
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.SetPlayerIsOnTower \ We now work out whether the player just transferred \ into a robot on the Sentinel's tower \ \ We do this by starting at object #X, which is the \ robot that the player just transferred into, and if \ it's on top of another object or stack of objects, we \ work our way down the stack, checking to see if the \ stack contains the Sentinel's tower \ \ The Sentinel's tower is always the first object to be \ spawned, and object numbers are allocated from 63 and \ down, so this means the tower is always object #63, or \ %111111, so that's what we look for while working \ through the object stack \ \ This forms part of the code to protect the game from \ crackers, as all we do with this information is to set \ playerIsOnTower to the object type of the tower (which \ is 6). This value is then used to generate the secret \ code for the completed landscape, so if crackers have \ jumped straight to the end of the level without \ setting playerIsOnTower to 6, then the wrong code will \ be generated in the SpawnSecretCode3D routine .ptow1 LDA objectFlags,X \ Set A to the object flags for object #X CMP #%01000000 \ If both bits 6 and 7 of the object flags for object #X BCC ptow2 \ are clear then object #X is not stacked on top of \ another object (so if we have looped back here from \ below, we have reached the bottom of the stack), so \ jump to ptow2 to stop looping through the object stack \ and go back to the ProcessActionKeys routine \ If we get here then object #X is stacked on top of \ another object, and the number of the object below \ object #X is in bits 0 to 5 of the object flags for \ object #X, which is currently in A AND #%00111111 \ Extract bits 0 to 5 of the object flags into A and X, TAX \ so X now contains the object number of the next object \ down in the stack EOR #%00111111 \ If the object number in A is not the Sentinel's tower BNE ptow1 \ (i.e. it is not 63, or %111111), then loop back to \ check the next object down in the stack \ If we get here then the player has just transferred \ into a robot on the Sentinel's tower LDA objectTypes,X \ Set playerIsOnTower = 6 (which is the object type of STA playerIsOnTower \ the Sentinel's tower, whose object number is in X) .ptow2 \ Fall through into part 2 of ProcessActionKeys to \ continue with the robot transfer