Prev: 60558 Up: Map Next: 60725
60587: Check Password
Used by the routine at InitialiseGame.
CheckPassword 60587 LD HL,2595 Write 2595 to *REPDEL/*REPPER.
60590 LD (23561),HL
60593 CALL ClearScreen Call ClearScreen.
Set the attributes for the code entry messaging.
60596 LD HL,22784 HL=22784 (attribute buffer location).
60599 LD B,64 B=64 (counter; two full rows).
CheckPassword_GreenLoop 60601 LD (HL),4 Write 4 (INK: GREEN, PAPER: BLACK ) to *HL.
60603 INC L Increment L by one.
60604 DJNZ CheckPassword_GreenLoop Decrease counter by one and loop back to CheckPassword_GreenLoop until counter is zero.
Print "KEY IN 1ST CHARACTER OF CODE" to the screen.
60606 EXX Switch to the shadow registers.
60607 LD DE,18432 DE'=18432 (screen buffer location).
60610 EXX Switch back to the normal registers.
60611 LD B,64 B=64 (counter; two full rows).
60613 LD HL,60948 HL=Messaging_CodeEntry.
60616 CALL Print_Loop Call Print_Loop.
60619 CALL 60526 Call 60526.
60622 CP 13 Jump to CheckPassword_Input if A is not equal to 13 ("ENTER").
60624 JR NZ,CheckPassword_Input
The player pressed the "ENTER" key to skip entering a code.
StartGame 60626 LD HL,257 Write 1 to *REPDEL and 1 to *REPPER.
60629 LD (23561),HL
60632 JP GameInitialisation Jump to GameInitialisation.
The player is entering a password to access a later level.
CheckPassword_Input 60635 LD DE,30766 DE=30766.
60638 LD (DE),A Write A to *DE.
60639 EXX Switch to the shadow registers.
60640 LD E,32 E'=32.
60642 EXX Switch back to the normal registers.
60643 LD HL,59808 HL=Messaging_Blank.
60646 LD B,32 B=32.
60648 CALL Print_Loop Call Print_Loop.
60651 LD B,4 B=4.
60653 LD HL,61108 HL=Messaging_CodeLetterPosition.
Updates the number suffix in the messaging.
NumberSuffix 60656 EXX Switch to the shadow registers.
60657 LD E,9 E'=9.
60659 EXX Switch back to the normal registers.
60660 PUSH BC Stash BC on the stack.
60661 LD B,3 B=3 (counter; length of number suffix messaging).
60663 CALL Print_Loop Call Print_Loop.
60666 POP BC Restore BC from the stack.
60667 PUSH HL Stash HL on the stack.
60668 CALL 60526 Call 60526.
60671 POP HL Restore HL from the stack.
60672 INC E Increment E by one.
60673 LD (DE),A Write A to *DE.
60674 DJNZ NumberSuffix Decrease counter by one and loop back to NumberSuffix until counter is zero.
Test if any of the passwords match the input.
60676 LD C,7 C=7 (counter; there are seven passwords).
60678 LD HL,61120 HL=Messaging_Passwords.
CheckPassword_Loop 60681 LD E,46 Reset the user input held by DE back to the start of the string (30766).
60683 LD B,5 B=5 (counter; length of a password string).
CheckLetter_Loop 60685 LD A,(DE) Fetch a letter of the user-entered password string.
60686 INC E Increment the user-entered input pointer by one.
60687 CP (HL) Jump to NextPassword if A is not equal to *HL.
60688 JR NZ,NextPassword
There's a match, move onto the next letter of this password.
60690 INC HL Increment HL by one.
60691 DJNZ CheckLetter_Loop Decrease counter by one and loop back to CheckLetter_Loop until counter is zero.
Success! This password is a match!
60693 LD A,7 A=7 (maximum levels).
The position in the password list counts down from 7 so this negatively correlates with the level number.
60695 SUB C A-=C.
60696 LD (30752),A Write A to *CurrentLevel.
60699 JR StartGame Jump to StartGame.
This password didn't match, move onto the next one.
NextPassword 60701 INC HL Increment HL by one.
60702 DJNZ NextPassword Decrease counter by one and loop back to NextPassword until counter is zero.
Are we out of passwords to check yet?
60704 DEC C Decrease C by one.
60705 JR NZ,CheckPassword_Loop Jump to CheckPassword_Loop until C is zero.
All passwords have been checked, let the player know their password was entered incorrectly.
60707 EXX Switch to the shadow registers.
60708 LD E,0 E'=0.
60710 EXX Switch back to the normal registers.
60711 LD HL,61012 HL=Messaging_Mistake.
60714 LD B,32 B=32 (counter; length of mistake string).
60716 CALL Print_Loop Call Print_Loop.
60719 CALL PauseLong Debounce using PauseLong.
60722 JP CheckPassword Jump to CheckPassword.
Prev: 60558 Up: Map Next: 60725