Skip to navigation

Title screen: SpawnSecretCode3D

Name: SpawnSecretCode3D [Show more] Type: Subroutine Category: Title screen Summary: Draw the landscape's secret code by spawning a set of large 3D text block objects
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTitleScreen calls SpawnSecretCode3D
.SpawnSecretCode3D LDA #%10000000 + 0 \ Set bit 7 of printTextIn3D so we print the landscape's STA printTextIn3D \ secret code in 3D text when we call Print2DigitBCD \ below JSR SpawnCharacter3D \ Call SpawnCharacter3D with A = #%10000000 + 0 to set \ the tile x-coordinate of the large 3D secret code text \ to zero LDA #%11000000 + 7 \ Call SpawnCharacter3D with A = #%11000000 + 7 to set JSR SpawnCharacter3D \ the tile z-coordinate of the large 3D secret code text \ to 7 \ \ So we draw the secret code in large 3D text blocks at \ tile coordinate (0, 7) on the landscape, so that's \ starting at the left edge of the landscape and seven \ tile rows from the front LSR playerIsOnTower \ If we got here legally (i.e. without crackers getting \ involved, then the ProcessActionKeys will have set \ playerIsOnTower to 6 when the player transferred into \ the robot on the Sentinel's tower, so this sets the \ value of playerIsOnTower to 3 LDX playerIsOnTower \ Set X = 3 to use as a loop in the following code \ \ If crackers have jumped straight here instead of \ playing the game properly, then X will not be 3 (it \ will probably be 64, as playerIsOnTower is initialised \ to 128 at the start of each level) \ \ The following code picks up where the CheckSecretCode \ routine ends, for when bit 7 of doNotPlayLandscape is \ set \ \ In this case, CheckSecretCode only iterates up to the \ point where the secret code is about to be generated, \ and then it stops, so we can finish the generation \ process here \ \ For this to work, we need to set X = 3 so we can \ generate the next four BCD numbers in the landscape's \ sequence of seed numbers, as these will give us the \ secret code \ \ If X is 64, then the secret code that is generated \ will be incorrect .dsec1 JSR GetNextSeedAsBCD \ Set A to the next number from the landscape's sequence \ of seed numbers, converted to a binary coded decimal \ (BCD) number CPX #4 \ If X >= 4, skip printing the BCD number, so that we BCS dsec2 \ skip printing the four correct secret code numbers if \ X starts the loop at 64 JSR Print2DigitBCD \ Draw the binary coded decimal (BCD) number in A in \ large 3D text .dsec2 DEX \ Decrement the loop counter BPL dsec1 \ Loop back until we have printed the four BCD numbers \ in the landscape's secret code STX playerIsOnTower \ Set playerIsOnTower = &FF to overwrite the correct \ value, to make it harder for crackers to work out why \ their secret codes aren't valid JSR GetNextSeedNumber \ Set A to the next number from the landscape's sequence \ of seed numbers LSR printTextIn3D \ Clear bit 7 of printTextIn3D to return to printing \ normal text RTS \ Return from the subroutine