Skip to navigation

Cracker protection: AlterCrackerSeed

Name: AlterCrackerSeed [Show more] Type: Subroutine Category: Cracker protection Summary: Create an altered version of the anti-cracker seed-related data, 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
.AlterCrackerSeed LDX #7 \ Set X = 7, to add to the cracker seed when its last \ digit is 9, so we effectively add 700 to the \ landscape number LDA CrackerSeed+1-7,X \ Set T to the contents of CrackerSeed+1, which we set STA T \ in the SetCrackerSeed routine to the high byte of the \ binary coded decimal (BCD) landscape number \ \ So if the landscape number 0123, T contains 01 in BCD \ format AND #%00001111 \ Set A to the second digit in the BCD landscape number CMP #9 \ If the second digit in the BCD number is 9, skip the BEQ alts1 \ following instruction so that X stays set to 7 LDX #1 \ Otherwise set X = 1, for when the second digit is in \ the range 0 to 8, so we effectively add 100 to the \ landscape number .alts1 TXA \ Set alteredSeed = T + X CLC \ ADC T \ Note that this addition is not done in BCD mode, so we STA alteredSeed \ know that the following is true: \ \ alteredSeed > T \ \ so: \ \ alteredSeed > CrackerSeed+1 \ \ as the largest possible value of T is &99 when the \ value of X is the largest possible at 7, and: \ \ &99 + 7 = &A0 \ \ so the addition never overflows and the result in \ alteredSeed is greater than the original high byte in \ CrackerSeed+1 \ \ This fact is used in the CheckCrackerSeed routine to \ ensure that this part of the anti-cracker code has \ been run correctly \ Fall through into part 2 of CheckEnemyGaze to continue \ checking the enemy's gaze