home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Ti / Magazine / Prog / teampass.asm < prev   
Encoding:
Assembly Source File  |  2000-01-23  |  3.0 KB  |  138 lines

  1.     include    "DoorsOS.h"    ; nÈcessaire pour tout programme DoorsOS
  2.     include    "graphlib.h"    ; on utilisera graphlib
  3.     include    "userlib.h"    ; et userlib
  4.     xdef    _main        ; dÈfinition de _main
  5.  
  6.     xdef    _ti89        ; compiler pour Ti89
  7.     xdef    _ti92plus    ; et pour Ti92+
  8.  
  9. ;**************************************************
  10. ; _main : le programme commence ici
  11. ;**************************************************
  12. _main:        
  13.  
  14. ; Affichage du menu et choix des options :
  15. ; On efface l'Ècran et on affiche trois chaÓnes de caractËres
  16.     jsr    graphlib::clr_scr
  17.  
  18.     WriteStr #0,#20,#4,f1
  19.     WriteStr #0,#30,#4,f2
  20.     WriteStr #0,#40,#4,f3
  21.  
  22. ; Boucle de test de la touche
  23. loop:
  24.     jsr    userlib::idle_loop    ; on rÈcupËre le code de la touche pressÈe
  25.     cmp.w    #268,d0    ; si la touche est F1
  26.     beq    F1
  27.     cmp.w    #269,d0    ; si la touche est F2
  28.     beq    F2
  29.     cmp.w    #270,d0    ; si la touche est F3
  30.     beq    ESC
  31.     cmp.w    #264,d0    ; ou si la touche est ESC
  32.     beq    ESC
  33.     bra    loop        ; sinon, rÈ-attend l'appui d'une touche
  34.  
  35.  
  36. ;**************************************************
  37. ; [F1] ProtÈger la TI
  38. ;**************************************************
  39. F1:
  40.     trap    #4    ; eteindre la Ti
  41.  
  42.     bsr    check_pass
  43.     
  44.     tst.w    d0    ; le password entrÈ est-il correct ?
  45.     bne    F1    ; non -> on eteint la Ti
  46.     rts        ; sinon on quitte le programme avec un rts
  47.  
  48. ;**************************************************
  49. ;  [F2] Changer le password
  50. ;**************************************************
  51. F2:    bsr    check_pass
  52.  
  53.     tst.w    d0    ; le password entrÈ est-il correct ?
  54.     bne    _main    ; non -> on retourne au menu
  55.  
  56.     jsr    graphlib::clr_scr
  57.     lea    enternew(pc),a0
  58.     jsr    graphlib::bigbox
  59.  
  60.     WriteStr #5,#20,#4,newpass
  61.     moveq    #10,d3        ; max char = 10
  62.     moveq    #5,d1        ; x = 5
  63.     moveq    #35,d2        ; y = 30
  64.     jsr    userlib::InputStr
  65.  
  66.     tst.w    d0
  67.     beq    _main
  68.  
  69.     lea    pass(pc),a1
  70.     subq.w    #1,d0
  71. \copy    move.b    (a0)+,(a1)+
  72.     dbra    d0,\copy
  73.     clr.b    (a1)
  74.     bra    _main
  75.  
  76. ;**************************************************
  77. ; [F3] ou [ESC] : fin du programme
  78. ;**************************************************
  79. ESC:
  80.     rts
  81.  
  82. ;**************************************************
  83. ; CHECK_PASS
  84. ;**************************************************
  85. check_pass:
  86.     movem.l    d1-d7/a0-a6,-(a7)
  87.  
  88.     move.l    $40078,old_ON
  89.     move.l    #ON_desactive,$40078
  90.  
  91.     jsr    graphlib::clr_scr
  92.     lea    enterpass(pc),a0
  93.     jsr    graphlib::bigbox
  94.     
  95.     WriteStr #5,#20,#4,enterpass
  96.     moveq    #10,d3        ; max char = 10
  97.     moveq    #5,d1        ; x = 5
  98.     moveq    #35,d2        ; y = 30
  99.     jsr    userlib::InputStr
  100.  
  101.     tst.w    d0
  102.     beq    \fail
  103.  
  104.     move.l    a0,-(a7)
  105.     pea    pass(pc)
  106.     jsr    doorsos::strcmp
  107.     addq.l    #8,a7
  108. \fin
  109.     move.l    old_ON,$40078
  110.  
  111.     movem.l    (a7)+,d1-d7/a0-a6
  112.     rts
  113. \fail
  114.     moveq    #1,d0
  115.     bra    \fin
  116.  
  117. ON_desactive:
  118.     rte
  119.  
  120. ;**************************************************
  121. ; Variables
  122. ;**************************************************
  123.  
  124. old_ON        dc.l    0
  125.  
  126. pass        dc.b    "palmtops",0,0,0  ; 10 caracteres + le zero de fin
  127.  
  128. newpass    dc.b    "Quel nouveau password ?",0
  129. enterpass    dc.b    "Entrez le password",0
  130. enternew    dc.b    "Entrez le nouveau password",0
  131.  
  132. f1    dc.b    "[F1] ProtÈger la TI",0
  133. f2    dc.b    "[F2] Changer le password",0
  134. f3    dc.b    "[F3] Quitter",0
  135.  
  136.  
  137.     end
  138.