XDEF Password XREF __SEG_END_SSTACK,pw_required,byte_out,disp,Keypad,display_string,pressed_num,password,pw_set,pw_reset,pw_check,PORT_S,await_key_release,await_key_press,entered_password,pw_correct Variables: Section pw_char_index ds.b 1 pw_char ds.b 1 Constants: Section Code: Section Password: ;push register and accumulator values for retention PSHA PSHB PSHD PSHX PSHY ;setting password for the 1st time LDAA pw_set CMPA #$00 BEQ PasswordInit ;user has elected to change the password LDAA pw_reset CMPA #$FF LBEQ PasswordReset ;user has selected something requiring auth LDAA pw_check CMPA #$FF LBEQ PasswordCheck LBRA Return PasswordInit: ;MOVB #$FF, ;inital prompt movb #'S',disp movb #'e',disp+1 movb #'t',disp+2 movb #' ',disp+3 movb #'p',disp+4 movb #'a',disp+5 movb #'s',disp+6 movb #'s',disp+7 movb #'w',disp+8 movb #'o',disp+9 movb #'r',disp+10 movb #'d',disp+11 movb #':',disp+12 movb #' ',disp+13 movb #' ',disp+14 movb #' ',disp+15 ;next line movb #'_',disp+16 movb #'_',disp+17 movb #'_',disp+18 movb #'_',disp+19 movb #'_',disp+20 movb #'_',disp+21 movb #'_',disp+22 movb #'_',disp+23 movb #' ',disp+24 movb #' ',disp+25 movb #' ',disp+26 movb #' ',disp+27 movb #' ',disp+28 movb #' ',disp+29 movb #' ',disp+30 movb #' ',disp+31 movb #0,disp+32 ;string terminator, acts like '\0' ;print the prompt string LDD #disp ;both of these steps are necessary to jsr display_string ;print to the LCD screen ;AWAIT KEYPRESS movb #$FF,await_key_press ;READ EACH CHARACTER MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+16 ;change the display to acknowledge input MOVB pressed_num,password ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+17 ;change the display to acknowledge input MOVB pressed_num,password+1 ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+18 ;change the display to acknowledge input MOVB pressed_num,password+2 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+19 ;change the display to acknowledge input MOVB pressed_num,password+3 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+20 ;change the display to acknowledge input MOVB pressed_num,password+4 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+21 ;change the display to acknowledge input MOVB pressed_num,password+5 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+22 ;change the display to acknowledge input MOVB pressed_num,password+6 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+23 ;change the display to acknowledge input MOVB pressed_num,password+7 ;store the read value into the password LDD #disp jsr display_string ;mark the password as set MOVB #$FF,pw_set LBRA Return PasswordReset: ;MOVB #$FF, ;inital prompt movb #'C',disp movb #'u',disp+1 movb #'r',disp+2 movb #'r',disp+3 movb #'e',disp+4 movb #'n',disp+5 movb #'t',disp+6 movb #' ',disp+7 movb #'p',disp+8 movb #'a',disp+9 movb #'s',disp+10 movb #'s',disp+11 movb #'w',disp+12 movb #'d',disp+13 movb #'.',disp+14 movb #':',disp+15 ;next line movb #'_',disp+16 movb #'_',disp+17 movb #'_',disp+18 movb #'_',disp+19 movb #'_',disp+20 movb #'_',disp+21 movb #'_',disp+22 movb #'_',disp+23 movb #' ',disp+24 movb #' ',disp+25 movb #' ',disp+26 movb #' ',disp+27 movb #' ',disp+28 movb #' ',disp+29 movb #' ',disp+30 movb #' ',disp+31 movb #0,disp+32 ;string terminator, acts like '\0' ;print the prompt string LDD #disp ;both of these steps are necessary to jsr display_string ;print to the LCD screen ;AWAIT KEYPRESS movb #$FF,await_key_press ;READ EACH CHARACTER MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+16 ;change the display to acknowledge input MOVB pressed_num,entered_password ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+17 ;change the display to acknowledge input MOVB pressed_num,entered_password+1 ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+18 ;change the display to acknowledge input MOVB pressed_num,entered_password+2 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+19 ;change the display to acknowledge input MOVB pressed_num,entered_password+3 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+20 ;change the display to acknowledge input MOVB pressed_num,entered_password+4 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+21 ;change the display to acknowledge input MOVB pressed_num,entered_password+5 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+22 ;change the display to acknowledge input MOVB pressed_num,entered_password+6 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+23 ;change the display to acknowledge input MOVB pressed_num,entered_password+7 ;store the read value into the password LDD #disp jsr display_string ;check if the password is correct LDX #password LDY #entered_password ;read the current password character and compare it to the new password character ;this resets if the password is incorrect ;1. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;2. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;3. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;4. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;5. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;6. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;7. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset INX INY ;8. LDAA 0,X LDAB 0,Y CBA LBNE PasswordReset ;inital prompt movb #'N',disp movb #'e',disp+1 movb #'w',disp+2 movb #' ',disp+3 movb #'p',disp+4 movb #'a',disp+5 movb #'s',disp+6 movb #'s',disp+7 movb #'w',disp+8 movb #'o',disp+9 movb #'r',disp+10 movb #'d',disp+11 movb #':',disp+12 movb #' ',disp+13 movb #' ',disp+14 movb #' ',disp+15 ;next line movb #'_',disp+16 movb #'_',disp+17 movb #'_',disp+18 movb #'_',disp+19 movb #'_',disp+20 movb #'_',disp+21 movb #'_',disp+22 movb #'_',disp+23 movb #' ',disp+24 movb #' ',disp+25 movb #' ',disp+26 movb #' ',disp+27 movb #' ',disp+28 movb #' ',disp+29 movb #' ',disp+30 movb #' ',disp+31 movb #0,disp+32 ;string terminator, acts like '\0' ;print the prompt string LDD #disp ;both of these steps are necessary to jsr display_string ;print to the LCD screen ;AWAIT KEYPRESS movb #$FF,await_key_press ;READ EACH CHARACTER MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+16 ;change the display to acknowledge input MOVB pressed_num,password ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+17 ;change the display to acknowledge input MOVB pressed_num,password+1 ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+18 ;change the display to acknowledge input MOVB pressed_num,password+2 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+19 ;change the display to acknowledge input MOVB pressed_num,password+3 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+20 ;change the display to acknowledge input MOVB pressed_num,password+4 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+21 ;change the display to acknowledge input MOVB pressed_num,password+5 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+22 ;change the display to acknowledge input MOVB pressed_num,password+6 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+23 ;change the display to acknowledge input MOVB pressed_num,password+7 ;store the read value into the password LDD #disp jsr display_string ;password has been reset MOVB #$00,pw_reset LBRA Return PasswordCheck: ;MOVB #$FF, ;inital prompt movb #'E',disp movb #'n',disp+1 movb #'t',disp+2 movb #'e',disp+3 movb #'r',disp+4 movb #' ',disp+5 movb #'p',disp+6 movb #'a',disp+7 movb #'s',disp+8 movb #'s',disp+9 movb #'w',disp+10 movb #'o',disp+11 movb #'r',disp+12 movb #'d',disp+13 movb #':',disp+14 movb #' ',disp+15 ;next line movb #'_',disp+16 movb #'_',disp+17 movb #'_',disp+18 movb #'_',disp+19 movb #'_',disp+20 movb #'_',disp+21 movb #'_',disp+22 movb #'_',disp+23 movb #' ',disp+24 movb #' ',disp+25 movb #' ',disp+26 movb #' ',disp+27 movb #' ',disp+28 movb #' ',disp+29 movb #' ',disp+30 movb #' ',disp+31 movb #0,disp+32 ;string terminator, acts like '\0' ;print the prompt string LDD #disp ;both of these steps are necessary to jsr display_string ;print to the LCD screen ;AWAIT KEYPRESS movb #$FF,await_key_press ;READ EACH CHARACTER MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+16 ;change the display to acknowledge input MOVB pressed_num,entered_password ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+17 ;change the display to acknowledge input MOVB pressed_num,entered_password+1 ;store the read value into the password LDD #disp jsr display_string ;LBRA Return MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+18 ;change the display to acknowledge input MOVB pressed_num,entered_password+2 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+19 ;change the display to acknowledge input MOVB pressed_num,entered_password+3 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+20 ;change the display to acknowledge input MOVB pressed_num,entered_password+4 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+21 ;change the display to acknowledge input MOVB pressed_num,entered_password+5 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+22 ;change the display to acknowledge input MOVB pressed_num,entered_password+6 ;store the read value into the password LDD #disp jsr display_string MOVB #$FF,await_key_release jsr Keypad ;read a keypress movb #'*',disp+23 ;change the display to acknowledge input MOVB pressed_num,entered_password+7 ;store the read value into the password LDD #disp jsr display_string ;check if the password is correct LDX #password LDY #entered_password ;read the current password character and compare it to the new password character ;this resets if the password is incorrect ;1. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;2. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;3. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;4. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;5. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;6. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;7. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck INX INY ;8. LDAA 0,X LDAB 0,Y CBA LBNE PasswordCheck CLR pw_required BRA Return Return: ;here, set the pressed number to something impossible so that ;the password input doesn't spill into other code MOVB #$FF,pressed_num ;set the pressed_num to something impossible ;restore registers and accumulators PULY PULX PULD PULB PULA RTS