password.dbg 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. XDEF Password
  2. 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
  3. Variables: Section
  4. pw_char_index ds.b 1
  5. pw_char ds.b 1
  6. Constants: Section
  7. Code: Section
  8. Password:
  9. ;push register and accumulator values for retention
  10. PSHA
  11. PSHB
  12. PSHD
  13. PSHX
  14. PSHY
  15. ;setting password for the 1st time
  16. LDAA pw_set
  17. CMPA #$00
  18. BEQ PasswordInit
  19. ;user has elected to change the password
  20. LDAA pw_reset
  21. CMPA #$FF
  22. LBEQ PasswordReset
  23. ;user has selected something requiring auth
  24. LDAA pw_check
  25. CMPA #$FF
  26. LBEQ PasswordCheck
  27. LBRA Return
  28. PasswordInit:
  29. ;MOVB #$FF,
  30. ;inital prompt
  31. movb #'S',disp
  32. movb #'e',disp+1
  33. movb #'t',disp+2
  34. movb #' ',disp+3
  35. movb #'p',disp+4
  36. movb #'a',disp+5
  37. movb #'s',disp+6
  38. movb #'s',disp+7
  39. movb #'w',disp+8
  40. movb #'o',disp+9
  41. movb #'r',disp+10
  42. movb #'d',disp+11
  43. movb #':',disp+12
  44. movb #' ',disp+13
  45. movb #' ',disp+14
  46. movb #' ',disp+15
  47. ;next line
  48. movb #'_',disp+16
  49. movb #'_',disp+17
  50. movb #'_',disp+18
  51. movb #'_',disp+19
  52. movb #'_',disp+20
  53. movb #'_',disp+21
  54. movb #'_',disp+22
  55. movb #'_',disp+23
  56. movb #' ',disp+24
  57. movb #' ',disp+25
  58. movb #' ',disp+26
  59. movb #' ',disp+27
  60. movb #' ',disp+28
  61. movb #' ',disp+29
  62. movb #' ',disp+30
  63. movb #' ',disp+31
  64. movb #0,disp+32 ;string terminator, acts like '\0'
  65. ;print the prompt string
  66. LDD #disp ;both of these steps are necessary to
  67. jsr display_string ;print to the LCD screen
  68. ;AWAIT KEYPRESS
  69. movb #$FF,await_key_press
  70. ;READ EACH CHARACTER
  71. MOVB #$FF,await_key_release
  72. jsr Keypad ;read a keypress
  73. movb #'*',disp+16 ;change the display to acknowledge input
  74. MOVB pressed_num,password ;store the read value into the password
  75. LDD #disp
  76. jsr display_string
  77. ;LBRA Return
  78. MOVB #$FF,await_key_release
  79. jsr Keypad ;read a keypress
  80. movb #'*',disp+17 ;change the display to acknowledge input
  81. MOVB pressed_num,password+1 ;store the read value into the password
  82. LDD #disp
  83. jsr display_string
  84. ;LBRA Return
  85. MOVB #$FF,await_key_release
  86. jsr Keypad ;read a keypress
  87. movb #'*',disp+18 ;change the display to acknowledge input
  88. MOVB pressed_num,password+2 ;store the read value into the password
  89. LDD #disp
  90. jsr display_string
  91. MOVB #$FF,await_key_release
  92. jsr Keypad ;read a keypress
  93. movb #'*',disp+19 ;change the display to acknowledge input
  94. MOVB pressed_num,password+3 ;store the read value into the password
  95. LDD #disp
  96. jsr display_string
  97. MOVB #$FF,await_key_release
  98. jsr Keypad ;read a keypress
  99. movb #'*',disp+20 ;change the display to acknowledge input
  100. MOVB pressed_num,password+4 ;store the read value into the password
  101. LDD #disp
  102. jsr display_string
  103. MOVB #$FF,await_key_release
  104. jsr Keypad ;read a keypress
  105. movb #'*',disp+21 ;change the display to acknowledge input
  106. MOVB pressed_num,password+5 ;store the read value into the password
  107. LDD #disp
  108. jsr display_string
  109. MOVB #$FF,await_key_release
  110. jsr Keypad ;read a keypress
  111. movb #'*',disp+22 ;change the display to acknowledge input
  112. MOVB pressed_num,password+6 ;store the read value into the password
  113. LDD #disp
  114. jsr display_string
  115. MOVB #$FF,await_key_release
  116. jsr Keypad ;read a keypress
  117. movb #'*',disp+23 ;change the display to acknowledge input
  118. MOVB pressed_num,password+7 ;store the read value into the password
  119. LDD #disp
  120. jsr display_string
  121. ;mark the password as set
  122. MOVB #$FF,pw_set
  123. LBRA Return
  124. PasswordReset:
  125. ;MOVB #$FF,
  126. ;inital prompt
  127. movb #'C',disp
  128. movb #'u',disp+1
  129. movb #'r',disp+2
  130. movb #'r',disp+3
  131. movb #'e',disp+4
  132. movb #'n',disp+5
  133. movb #'t',disp+6
  134. movb #' ',disp+7
  135. movb #'p',disp+8
  136. movb #'a',disp+9
  137. movb #'s',disp+10
  138. movb #'s',disp+11
  139. movb #'w',disp+12
  140. movb #'d',disp+13
  141. movb #'.',disp+14
  142. movb #':',disp+15
  143. ;next line
  144. movb #'_',disp+16
  145. movb #'_',disp+17
  146. movb #'_',disp+18
  147. movb #'_',disp+19
  148. movb #'_',disp+20
  149. movb #'_',disp+21
  150. movb #'_',disp+22
  151. movb #'_',disp+23
  152. movb #' ',disp+24
  153. movb #' ',disp+25
  154. movb #' ',disp+26
  155. movb #' ',disp+27
  156. movb #' ',disp+28
  157. movb #' ',disp+29
  158. movb #' ',disp+30
  159. movb #' ',disp+31
  160. movb #0,disp+32 ;string terminator, acts like '\0'
  161. ;print the prompt string
  162. LDD #disp ;both of these steps are necessary to
  163. jsr display_string ;print to the LCD screen
  164. ;AWAIT KEYPRESS
  165. movb #$FF,await_key_press
  166. ;READ EACH CHARACTER
  167. MOVB #$FF,await_key_release
  168. jsr Keypad ;read a keypress
  169. movb #'*',disp+16 ;change the display to acknowledge input
  170. MOVB pressed_num,entered_password ;store the read value into the password
  171. LDD #disp
  172. jsr display_string
  173. ;LBRA Return
  174. MOVB #$FF,await_key_release
  175. jsr Keypad ;read a keypress
  176. movb #'*',disp+17 ;change the display to acknowledge input
  177. MOVB pressed_num,entered_password+1 ;store the read value into the password
  178. LDD #disp
  179. jsr display_string
  180. ;LBRA Return
  181. MOVB #$FF,await_key_release
  182. jsr Keypad ;read a keypress
  183. movb #'*',disp+18 ;change the display to acknowledge input
  184. MOVB pressed_num,entered_password+2 ;store the read value into the password
  185. LDD #disp
  186. jsr display_string
  187. MOVB #$FF,await_key_release
  188. jsr Keypad ;read a keypress
  189. movb #'*',disp+19 ;change the display to acknowledge input
  190. MOVB pressed_num,entered_password+3 ;store the read value into the password
  191. LDD #disp
  192. jsr display_string
  193. MOVB #$FF,await_key_release
  194. jsr Keypad ;read a keypress
  195. movb #'*',disp+20 ;change the display to acknowledge input
  196. MOVB pressed_num,entered_password+4 ;store the read value into the password
  197. LDD #disp
  198. jsr display_string
  199. MOVB #$FF,await_key_release
  200. jsr Keypad ;read a keypress
  201. movb #'*',disp+21 ;change the display to acknowledge input
  202. MOVB pressed_num,entered_password+5 ;store the read value into the password
  203. LDD #disp
  204. jsr display_string
  205. MOVB #$FF,await_key_release
  206. jsr Keypad ;read a keypress
  207. movb #'*',disp+22 ;change the display to acknowledge input
  208. MOVB pressed_num,entered_password+6 ;store the read value into the password
  209. LDD #disp
  210. jsr display_string
  211. MOVB #$FF,await_key_release
  212. jsr Keypad ;read a keypress
  213. movb #'*',disp+23 ;change the display to acknowledge input
  214. MOVB pressed_num,entered_password+7 ;store the read value into the password
  215. LDD #disp
  216. jsr display_string
  217. ;check if the password is correct
  218. LDX #password
  219. LDY #entered_password
  220. ;read the current password character and compare it to the new password character
  221. ;this resets if the password is incorrect
  222. ;1.
  223. LDAA 0,X
  224. LDAB 0,Y
  225. CBA
  226. LBNE PasswordReset
  227. INX
  228. INY
  229. ;2.
  230. LDAA 0,X
  231. LDAB 0,Y
  232. CBA
  233. LBNE PasswordReset
  234. INX
  235. INY
  236. ;3.
  237. LDAA 0,X
  238. LDAB 0,Y
  239. CBA
  240. LBNE PasswordReset
  241. INX
  242. INY
  243. ;4.
  244. LDAA 0,X
  245. LDAB 0,Y
  246. CBA
  247. LBNE PasswordReset
  248. INX
  249. INY
  250. ;5.
  251. LDAA 0,X
  252. LDAB 0,Y
  253. CBA
  254. LBNE PasswordReset
  255. INX
  256. INY
  257. ;6.
  258. LDAA 0,X
  259. LDAB 0,Y
  260. CBA
  261. LBNE PasswordReset
  262. INX
  263. INY
  264. ;7.
  265. LDAA 0,X
  266. LDAB 0,Y
  267. CBA
  268. LBNE PasswordReset
  269. INX
  270. INY
  271. ;8.
  272. LDAA 0,X
  273. LDAB 0,Y
  274. CBA
  275. LBNE PasswordReset
  276. ;inital prompt
  277. movb #'N',disp
  278. movb #'e',disp+1
  279. movb #'w',disp+2
  280. movb #' ',disp+3
  281. movb #'p',disp+4
  282. movb #'a',disp+5
  283. movb #'s',disp+6
  284. movb #'s',disp+7
  285. movb #'w',disp+8
  286. movb #'o',disp+9
  287. movb #'r',disp+10
  288. movb #'d',disp+11
  289. movb #':',disp+12
  290. movb #' ',disp+13
  291. movb #' ',disp+14
  292. movb #' ',disp+15
  293. ;next line
  294. movb #'_',disp+16
  295. movb #'_',disp+17
  296. movb #'_',disp+18
  297. movb #'_',disp+19
  298. movb #'_',disp+20
  299. movb #'_',disp+21
  300. movb #'_',disp+22
  301. movb #'_',disp+23
  302. movb #' ',disp+24
  303. movb #' ',disp+25
  304. movb #' ',disp+26
  305. movb #' ',disp+27
  306. movb #' ',disp+28
  307. movb #' ',disp+29
  308. movb #' ',disp+30
  309. movb #' ',disp+31
  310. movb #0,disp+32 ;string terminator, acts like '\0'
  311. ;print the prompt string
  312. LDD #disp ;both of these steps are necessary to
  313. jsr display_string ;print to the LCD screen
  314. ;AWAIT KEYPRESS
  315. movb #$FF,await_key_press
  316. ;READ EACH CHARACTER
  317. MOVB #$FF,await_key_release
  318. jsr Keypad ;read a keypress
  319. movb #'*',disp+16 ;change the display to acknowledge input
  320. MOVB pressed_num,password ;store the read value into the password
  321. LDD #disp
  322. jsr display_string
  323. ;LBRA Return
  324. MOVB #$FF,await_key_release
  325. jsr Keypad ;read a keypress
  326. movb #'*',disp+17 ;change the display to acknowledge input
  327. MOVB pressed_num,password+1 ;store the read value into the password
  328. LDD #disp
  329. jsr display_string
  330. ;LBRA Return
  331. MOVB #$FF,await_key_release
  332. jsr Keypad ;read a keypress
  333. movb #'*',disp+18 ;change the display to acknowledge input
  334. MOVB pressed_num,password+2 ;store the read value into the password
  335. LDD #disp
  336. jsr display_string
  337. MOVB #$FF,await_key_release
  338. jsr Keypad ;read a keypress
  339. movb #'*',disp+19 ;change the display to acknowledge input
  340. MOVB pressed_num,password+3 ;store the read value into the password
  341. LDD #disp
  342. jsr display_string
  343. MOVB #$FF,await_key_release
  344. jsr Keypad ;read a keypress
  345. movb #'*',disp+20 ;change the display to acknowledge input
  346. MOVB pressed_num,password+4 ;store the read value into the password
  347. LDD #disp
  348. jsr display_string
  349. MOVB #$FF,await_key_release
  350. jsr Keypad ;read a keypress
  351. movb #'*',disp+21 ;change the display to acknowledge input
  352. MOVB pressed_num,password+5 ;store the read value into the password
  353. LDD #disp
  354. jsr display_string
  355. MOVB #$FF,await_key_release
  356. jsr Keypad ;read a keypress
  357. movb #'*',disp+22 ;change the display to acknowledge input
  358. MOVB pressed_num,password+6 ;store the read value into the password
  359. LDD #disp
  360. jsr display_string
  361. MOVB #$FF,await_key_release
  362. jsr Keypad ;read a keypress
  363. movb #'*',disp+23 ;change the display to acknowledge input
  364. MOVB pressed_num,password+7 ;store the read value into the password
  365. LDD #disp
  366. jsr display_string
  367. ;password has been reset
  368. MOVB #$00,pw_reset
  369. LBRA Return
  370. PasswordCheck:
  371. ;MOVB #$FF,
  372. ;inital prompt
  373. movb #'E',disp
  374. movb #'n',disp+1
  375. movb #'t',disp+2
  376. movb #'e',disp+3
  377. movb #'r',disp+4
  378. movb #' ',disp+5
  379. movb #'p',disp+6
  380. movb #'a',disp+7
  381. movb #'s',disp+8
  382. movb #'s',disp+9
  383. movb #'w',disp+10
  384. movb #'o',disp+11
  385. movb #'r',disp+12
  386. movb #'d',disp+13
  387. movb #':',disp+14
  388. movb #' ',disp+15
  389. ;next line
  390. movb #'_',disp+16
  391. movb #'_',disp+17
  392. movb #'_',disp+18
  393. movb #'_',disp+19
  394. movb #'_',disp+20
  395. movb #'_',disp+21
  396. movb #'_',disp+22
  397. movb #'_',disp+23
  398. movb #' ',disp+24
  399. movb #' ',disp+25
  400. movb #' ',disp+26
  401. movb #' ',disp+27
  402. movb #' ',disp+28
  403. movb #' ',disp+29
  404. movb #' ',disp+30
  405. movb #' ',disp+31
  406. movb #0,disp+32 ;string terminator, acts like '\0'
  407. ;print the prompt string
  408. LDD #disp ;both of these steps are necessary to
  409. jsr display_string ;print to the LCD screen
  410. ;AWAIT KEYPRESS
  411. movb #$FF,await_key_press
  412. ;READ EACH CHARACTER
  413. MOVB #$FF,await_key_release
  414. jsr Keypad ;read a keypress
  415. movb #'*',disp+16 ;change the display to acknowledge input
  416. MOVB pressed_num,entered_password ;store the read value into the password
  417. LDD #disp
  418. jsr display_string
  419. ;LBRA Return
  420. MOVB #$FF,await_key_release
  421. jsr Keypad ;read a keypress
  422. movb #'*',disp+17 ;change the display to acknowledge input
  423. MOVB pressed_num,entered_password+1 ;store the read value into the password
  424. LDD #disp
  425. jsr display_string
  426. ;LBRA Return
  427. MOVB #$FF,await_key_release
  428. jsr Keypad ;read a keypress
  429. movb #'*',disp+18 ;change the display to acknowledge input
  430. MOVB pressed_num,entered_password+2 ;store the read value into the password
  431. LDD #disp
  432. jsr display_string
  433. MOVB #$FF,await_key_release
  434. jsr Keypad ;read a keypress
  435. movb #'*',disp+19 ;change the display to acknowledge input
  436. MOVB pressed_num,entered_password+3 ;store the read value into the password
  437. LDD #disp
  438. jsr display_string
  439. MOVB #$FF,await_key_release
  440. jsr Keypad ;read a keypress
  441. movb #'*',disp+20 ;change the display to acknowledge input
  442. MOVB pressed_num,entered_password+4 ;store the read value into the password
  443. LDD #disp
  444. jsr display_string
  445. MOVB #$FF,await_key_release
  446. jsr Keypad ;read a keypress
  447. movb #'*',disp+21 ;change the display to acknowledge input
  448. MOVB pressed_num,entered_password+5 ;store the read value into the password
  449. LDD #disp
  450. jsr display_string
  451. MOVB #$FF,await_key_release
  452. jsr Keypad ;read a keypress
  453. movb #'*',disp+22 ;change the display to acknowledge input
  454. MOVB pressed_num,entered_password+6 ;store the read value into the password
  455. LDD #disp
  456. jsr display_string
  457. MOVB #$FF,await_key_release
  458. jsr Keypad ;read a keypress
  459. movb #'*',disp+23 ;change the display to acknowledge input
  460. MOVB pressed_num,entered_password+7 ;store the read value into the password
  461. LDD #disp
  462. jsr display_string
  463. ;check if the password is correct
  464. LDX #password
  465. LDY #entered_password
  466. ;read the current password character and compare it to the new password character
  467. ;this resets if the password is incorrect
  468. ;1.
  469. LDAA 0,X
  470. LDAB 0,Y
  471. CBA
  472. LBNE PasswordCheck
  473. INX
  474. INY
  475. ;2.
  476. LDAA 0,X
  477. LDAB 0,Y
  478. CBA
  479. LBNE PasswordCheck
  480. INX
  481. INY
  482. ;3.
  483. LDAA 0,X
  484. LDAB 0,Y
  485. CBA
  486. LBNE PasswordCheck
  487. INX
  488. INY
  489. ;4.
  490. LDAA 0,X
  491. LDAB 0,Y
  492. CBA
  493. LBNE PasswordCheck
  494. INX
  495. INY
  496. ;5.
  497. LDAA 0,X
  498. LDAB 0,Y
  499. CBA
  500. LBNE PasswordCheck
  501. INX
  502. INY
  503. ;6.
  504. LDAA 0,X
  505. LDAB 0,Y
  506. CBA
  507. LBNE PasswordCheck
  508. INX
  509. INY
  510. ;7.
  511. LDAA 0,X
  512. LDAB 0,Y
  513. CBA
  514. LBNE PasswordCheck
  515. INX
  516. INY
  517. ;8.
  518. LDAA 0,X
  519. LDAB 0,Y
  520. CBA
  521. LBNE PasswordCheck
  522. CLR pw_required
  523. BRA Return
  524. Return:
  525. ;here, set the pressed number to something impossible so that
  526. ;the password input doesn't spill into other code
  527. MOVB #$FF,pressed_num ;set the pressed_num to something impossible
  528. ;restore registers and accumulators
  529. PULY
  530. PULX
  531. PULD
  532. PULB
  533. PULA
  534. RTS