Prev: EC8E Up: Map Next: ED35
ECAB: Check Password
Used by the routine at InitialiseGame.
CheckPassword ECAB LD HL,$0A23 Write 0A23 to *REPDEL/*REPPER.
ECAE LD ($5C09),HL
ECB1 CALL ClearScreen Call ClearScreen.
Set the attributes for the code entry messaging.
ECB4 LD HL,$5900 HL=5900 (attribute buffer location).
ECB7 LD B,$40 B=40 (counter; two full rows).
CheckPassword_GreenLoop ECB9 LD (HL),$04 Write 04 (INK: GREEN, PAPER: BLACK ) to *HL.
ECBB INC L Increment L by one.
ECBC 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.
ECBE EXX Switch to the shadow registers.
ECBF LD DE,$4800 DE'=4800 (screen buffer location).
ECC2 EXX Switch back to the normal registers.
ECC3 LD B,$40 B=40 (counter; two full rows).
ECC5 LD HL,$EE14 HL=Messaging_CodeEntry.
ECC8 CALL Print_Loop Call Print_Loop.
ECCB CALL $EC6E Call EC6E.
ECCE CP $0D Jump to CheckPassword_Input if A is not equal to 0D ("ENTER").
ECD0 JR NZ,CheckPassword_Input
The player pressed the "ENTER" key to skip entering a code.
StartGame ECD2 LD HL,$0101 Write 01 to *REPDEL and 01 to *REPPER.
ECD5 LD ($5C09),HL
ECD8 JP GameInitialisation Jump to GameInitialisation.
The player is entering a password to access a later level.
CheckPassword_Input ECDB LD DE,$782E DE=782E.
ECDE LD (DE),A Write A to *DE.
ECDF EXX Switch to the shadow registers.
ECE0 LD E,$20 E'=20.
ECE2 EXX Switch back to the normal registers.
ECE3 LD HL,$E9A0 HL=Messaging_Blank.
ECE6 LD B,$20 B=20.
ECE8 CALL Print_Loop Call Print_Loop.
ECEB LD B,$04 B=04.
ECED LD HL,$EEB4 HL=Messaging_CodeLetterPosition.
Updates the number suffix in the messaging.
NumberSuffix ECF0 EXX Switch to the shadow registers.
ECF1 LD E,$09 E'=09.
ECF3 EXX Switch back to the normal registers.
ECF4 PUSH BC Stash BC on the stack.
ECF5 LD B,$03 B=03 (counter; length of number suffix messaging).
ECF7 CALL Print_Loop Call Print_Loop.
ECFA POP BC Restore BC from the stack.
ECFB PUSH HL Stash HL on the stack.
ECFC CALL $EC6E Call EC6E.
ECFF POP HL Restore HL from the stack.
ED00 INC E Increment E by one.
ED01 LD (DE),A Write A to *DE.
ED02 DJNZ NumberSuffix Decrease counter by one and loop back to NumberSuffix until counter is zero.
Test if any of the passwords match the input.
ED04 LD C,$07 C=07 (counter; there are seven passwords).
ED06 LD HL,$EEC0 HL=Messaging_Passwords.
CheckPassword_Loop ED09 LD E,$2E Reset the user input held by DE back to the start of the string (782E).
ED0B LD B,$05 B=05 (counter; length of a password string).
CheckLetter_Loop ED0D LD A,(DE) Fetch a letter of the user-entered password string.
ED0E INC E Increment the user-entered input pointer by one.
ED0F CP (HL) Jump to NextPassword if A is not equal to *HL.
ED10 JR NZ,NextPassword
There's a match, move onto the next letter of this password.
ED12 INC HL Increment HL by one.
ED13 DJNZ CheckLetter_Loop Decrease counter by one and loop back to CheckLetter_Loop until counter is zero.
Success! This password is a match!
ED15 LD A,$07 A=07 (maximum levels).
The position in the password list counts down from 07 so this negatively correlates with the level number.
ED17 SUB C A-=C.
ED18 LD ($7820),A Write A to *CurrentLevel.
ED1B JR StartGame Jump to StartGame.
This password didn't match, move onto the next one.
NextPassword ED1D INC HL Increment HL by one.
ED1E DJNZ NextPassword Decrease counter by one and loop back to NextPassword until counter is zero.
Are we out of passwords to check yet?
ED20 DEC C Decrease C by one.
ED21 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.
ED23 EXX Switch to the shadow registers.
ED24 LD E,$00 E'=00.
ED26 EXX Switch back to the normal registers.
ED27 LD HL,$EE54 HL=Messaging_Mistake.
ED2A LD B,$20 B=20 (counter; length of mistake string).
ED2C CALL Print_Loop Call Print_Loop.
ED2F CALL PauseLong Debounce using PauseLong.
ED32 JP CheckPassword Jump to CheckPassword.
Prev: EC8E Up: Map Next: ED35