home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 85 / asm / source / zshell / secureit.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  11.5 KB  |  638 lines

  1. ; ------------------------------------------------------
  2. ; The source code contained below is the sole surviving,
  3. ; backed up copy of SecureIt-85's source code.  A hard-
  4. ; drive crash of my computer lost all other versions'
  5. ; source files.
  6. ;
  7. ; I have stopped programming in Z80 assembly, and have
  8. ; not looked at this code since well before the disk
  9. ; crash (early Jan, 98).  Therefore, I cannot provide
  10. ; much GOOD support for this source code, nor any other
  11. ; programs, really...
  12. ;-------------------------------------------------------
  13. ; I'm hereby releasing this source code to anybody who
  14. ; wishes to learn by it (if they can), borrow parts from
  15. ; it, or just plain regard it as a curiosity (for God
  16. ; knows what reason!)  However, I have two requests to
  17. ; make regarding its use:
  18. ;
  19. ; 1) Don't steal it.  If you borrow parts from it, make
  20. ; sure to mention it in the credits... If you port it to
  21. ; another platform, leave my name on it (though you can
  22. ; take off the e-mail & 'SeaHorse Software' part if you
  23. ; so desire).  If you steal it.. well.. shame on you...
  24. ;
  25. ; 2) Please don't expect that it is an example of great
  26. ; code.  It is probably not extremely well optimized,
  27. ; and certainly isn't well documented!!!  If you have
  28. ; questions, I certainly can try to help a little, but
  29. ; remember that it's been quite some time since I've
  30. ; really looked at this code...
  31. ;
  32. ; Beyond that, I leave this code in your hands... May
  33. ; it serve you well!
  34. ;
  35. ; - Michael Wyman, wyma0012@tc.umn.edu
  36. ;   March 4, 1998
  37. ; ------------------------------------------------------
  38.  
  39.  
  40.  
  41. ; ------------------------------------------------------
  42. ; Released 3/4/98 by Michael Wyman
  43. ;
  44. ; Note: The code in this file is not fully optimized.
  45. ; SecureIt-85 v4.0 and v5.0 (v5.0 only existed on MY
  46. ; calculator, and so exists only to this day... I lost
  47. ; the source to that completely!  Besides, it had been
  48. ; costumized for my ROM version and OS/7 w/ relocation.)
  49. ; were better optimized, and also smaller...
  50. ; ------------------------------------------------------
  51.  
  52. #include ti-85.h
  53.  
  54. .org 0
  55. MainScreen:
  56. .db "SecureIt-85 v3.0 (c)1996", 0
  57.  
  58.  
  59.  ld    de, (PROGRAM_ADDR)
  60.  ld    hl, randNum
  61.  add    hl, de
  62.  push    hl
  63.  ld    a, (hl)
  64.  ld    hl, Password
  65.  add    hl, de
  66.  ld    d, a
  67.  ld    b, 10
  68. FixPass:
  69.  ld    a, (hl)
  70.  sub    d
  71.  ld    (hl), a
  72.  inc    hl
  73.  djnz    FixPass
  74.  ld    a, d
  75.  ld    c, a
  76.  sla    c
  77.  sla    c
  78.  add    a, c
  79.  sla    c
  80.  sla    c
  81.  add    a, c
  82.  inc    a
  83.  pop    hl
  84.  ld    (hl), a
  85.  
  86. ;Disp Main Screen and Main Menu
  87.  
  88. MAIN:
  89.  CALL_(SetScreen)
  90.  ld    hl, $0f00
  91.  ld    ($8333), hl
  92.  ld    hl, MainSecond
  93.  ld    de, (PROGRAM_ADDR)
  94.  add    hl, de
  95.  ROM_CALL(D_ZM_STR)
  96.  ld    de, $1500
  97.  ld    ($8333), de
  98.  ROM_CALL(D_ZM_STR)
  99.  ld    de, $1b00
  100.  ld    ($8333), de
  101.  ROM_CALL(D_ZM_STR)
  102.  ld    de, $2100
  103.  ld    ($8333), de
  104.  ROM_CALL(D_ZM_STR)
  105.  ld    de, $2700
  106.  ld    ($8333), de
  107.  ROM_CALL(D_ZM_STR)
  108. MainKeyLoop:
  109.  CALL_(WaitKey)
  110.  cp    (K_EXIT)
  111.  jr    z, EXITNOW
  112.  cp    (K_F1)
  113.  JUMP_Z(PASSOFF)
  114.  cp    (K_F2)
  115.  jr    z, OFFNOW
  116.  cp    (K_F3)
  117.  jr    z, ChangePWJump
  118.  cp    (K_F5)
  119.  jr    z, Exit_Set
  120.  cp    (K_F4)
  121.  jr    nz, MainKeyLoop
  122.  ld    hl, ChangeOwner
  123.  ld    de, (PROGRAM_ADDR)
  124.  add    hl, de
  125.  jp    (hl)
  126.  
  127. ExitBytes:
  128. .db $0
  129. randNum:
  130. .db $0
  131. Exit_Set:
  132.  ld    de, ExitBytes
  133.  ld    hl, (PROGRAM_ADDR)
  134.  add    hl, de
  135.  bit    0, (hl)
  136.  jr    nz, TIOS
  137.  set    0, (hl)
  138.  ld    de, TIOS_String
  139.  jr    ChangeExit_String
  140. TIOS:
  141.  res    0, (hl)
  142.  ld    de, ZShell_String
  143. ChangeExit_String:
  144.  ld    hl, MainExit_String
  145.  ld    bc, (PROGRAM_ADDR)
  146.  add    hl, bc
  147.  ex    de, hl
  148.  add    hl, bc
  149.  ld    bc, $0006
  150.  ldir
  151.  CALL_(Return_Main)
  152.  
  153. ChangePWJump:
  154.  ld    hl, ChangePW
  155.  ld    de, (PROGRAM_ADDR)
  156.  add    hl, de
  157.  jp    (hl)
  158.  
  159. EXITNOW:
  160.  ld    de, (PROGRAM_ADDR)
  161.  ld    hl, randNum
  162.  add    hl, de
  163.  ld    a, (hl)
  164.  ld    hl, Password
  165.  add    hl, de
  166.  ld    d, a
  167.  ld    b, 10
  168. ScrewPass:
  169.  ld    a, (hl)
  170.  add    a, d
  171.  ld    (hl), a
  172.  inc    hl
  173.  djnz    ScrewPass
  174.  ld    hl, ZS_BITS
  175.  push    hl
  176.  ld    hl, ExitBytes
  177.  ld    de, (PROGRAM_ADDR)
  178.  add    hl, de
  179.  bit    0, (hl)
  180.  jr    z, EXIT
  181.  pop    hl
  182.  set    1, (hl)
  183.  push    hl
  184. EXIT:
  185.  pop    hl
  186.  set    0, (hl)
  187.  ret
  188. OFFNOW:
  189.  CALL_(Off)
  190.  CALL_(SetScreen)
  191.  CALL_(WaitKey)
  192.  jr    EXITNOW
  193.  
  194. PASSOFF:
  195.  CALL_(Off)
  196.  CALL_(SetScreen)
  197.  ld    hl, Dummyone
  198.  CALL_(GetPass)
  199.  or    a
  200.  jr    nz, PASSOFF
  201.  ld    de, Dummyone
  202.  ld    hl, Password
  203.  ld    b, $0a
  204.  CALL_(Compare)
  205.  or    a
  206.  jr    z, RightPass
  207.  ld    hl, $1800
  208.  ld    ($8333), hl
  209.  ld    hl, WrongPass
  210.  CALL_(DispMenu)
  211.  CALL_(WaitKey)
  212.  jr    PASSOFF
  213. RightPass:
  214.  CALL_(SetScreen)
  215.  CALL_(WaitKey)
  216.  ld    hl, EXITNOW
  217.  ld    de, (PROGRAM_ADDR)
  218.  add    hl, de
  219. Jumpit:
  220.  jp    (hl)
  221.  
  222. ChangePW:
  223.  CALL_(SetScreen)
  224.  ld    hl, Dummyone
  225.  CALL_(GetPass)
  226.  or    a
  227.  CALL_NZ(Return_Main)
  228.  ld    de, Dummyone
  229.  ld    hl, Password
  230.  ld    b, $0a
  231.  CALL_(Compare)
  232.  or    a
  233.  jr    z, BeginChange
  234.  CALL_(Return_Main)
  235. BeginChange:
  236.  ld    hl, $1100
  237.  ld    ($8333), hl
  238.  ld    hl, NewPrompt
  239.  CALL_(DispMenu)
  240.  ld    hl, Dummyone
  241.  push    hl
  242. Pressed1:
  243.  CALL_(GetWordStuff)
  244.  or    a
  245.  jr    nz, Pressed1
  246.  ld    hl, $1700
  247.  ld    ($8333), hl
  248.  ld    hl, RePrompt
  249.  CALL_(DispMenu)
  250.  ld    hl, Dummytwo
  251.  push    hl
  252. Pressed2:
  253.  CALL_(GetWordStuff)
  254.  or    a
  255.  jr    nz, Pressed2
  256.  pop    de
  257.  pop    hl
  258.  ld    b, $0a
  259.  CALL_(Compare)
  260.  or    a
  261.  jr    z, PWChanging
  262.  ld    hl, $1d00
  263.  ld    ($8333), hl
  264.  ld    hl, PWmissmatch
  265.  CALL_(DispMenu)
  266.  CALL_(WaitKey)
  267.  CALL_(Return_Main)
  268. PWChanging:
  269.  ld    hl, Password
  270.  ld    de, Dummytwo
  271.  ld    bc, (PROGRAM_ADDR)
  272.  add    hl, bc
  273.  ex    de, hl
  274.  add    hl, bc
  275.  ld    bc, $0a
  276.  ldir
  277.  ld    hl, $1d00
  278.  ld    ($8333), hl
  279.  ld    hl, PWChanged
  280.  CALL_(DispMenu)
  281.  CALL_(WaitKey)
  282.  
  283. Return:
  284.  CALL_(Return_Main)
  285.  
  286. ChangeOwner:
  287.  CALL_(SetScreen)
  288.  ld    hl, Dummyone
  289.  CALL_(GetPass)
  290.  or    a
  291.  CALL_NZ(Return_Main)
  292.  ld    hl, Dummyone
  293.  ld    de, Password
  294.  CALL_(Compare)
  295.  or    a
  296.  jr    z, ChangeOwner_
  297.  CALL_(Return_Main)
  298. ChangeOwner_:
  299.  CALL_(SetScreen)
  300.  ld    hl, $1100
  301.  ld    ($8333), hl
  302.  ld    hl, NewOwner
  303.  CALL_(DispMenu)
  304.  ld    hl, Owner
  305.  ld    de, (PROGRAM_ADDR)
  306.  add    hl, de
  307.  push    hl
  308.  ld    b, $15
  309.  CALL_(FillLoop)
  310.  pop    hl
  311.  ld    b, $15
  312. OwnerLoop:
  313.  push    hl
  314.  ld    hl, ($8333)
  315.  push    hl
  316.  ld    a, '_'
  317.  ROM_CALL(M_CHARPUT)
  318.  pop    hl
  319.  ld    ($8333), hl
  320.  pop    hl
  321.  CALL_(GetLetter)
  322.  or    a
  323.  jr    z, DoneOwn
  324.  cp    (K_ENTER)
  325.  jr    z, DoneOwn
  326.  ld    (hl), a
  327.  inc    hl
  328.  ROM_CALL(M_CHARPUT)
  329.  djnz    OwnerLoop
  330. DoneOwn:
  331.  CALL_(Return_Main)
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342. ;**************************SUBROUTINES******************************
  343.  
  344. ;Sets Screen in (cool) mode (i.e. Main Screen).
  345. SetScreen:
  346.  ROM_CALL(CLEARLCD)
  347.  ld    hl, $0700
  348.  ld    ($8333), hl
  349.  ld    hl, Registered_To
  350.  CALL_(DispMenu)
  351.  ld    hl, $fc00
  352.  ld    a, $ff
  353.  ld    b, $70
  354. Blacken:
  355.  ld    (hl), a
  356.  inc    hl
  357.  djnz    Blacken
  358.  ld    hl, $0018
  359.  ld    ($8333), hl
  360.  ld    hl, MainScreen
  361.  set    3, (IY+5)
  362.  res    1, (IY+5)
  363.  CALL_(DispMenu)
  364.  ld    hl, $fce0
  365.  ld    b, 16
  366.  ld    a, $ff
  367. DrawLine_1:
  368.  ld    (hl), a
  369.  inc    hl
  370.  djnz    DrawLine_1
  371.  ld    hl, $ff30
  372.  ld    b, $d0
  373. DrawLine_2:
  374.  ld    (hl), a
  375.  inc    hl
  376.  djnz    DrawLine_2
  377.  ld    hl, $3300
  378.  ld    ($8333), hl
  379.  ld    hl, Name
  380.  CALL_(DispMenu)
  381.  ld    hl, $3900
  382.  ld    ($8333), hl
  383.  ld    hl, Address
  384.  CALL_(DispMenu)
  385.  res    3, (IY+5)
  386.  set    1, (IY+5)
  387.  ret
  388.  
  389. ;Waits for Key input (returns ACC as keypress value, $0 if TimeOut)
  390. WaitKey:
  391.  push    hl
  392.  ld    de, 0
  393. WaitKey_Loop:
  394.  call    GET_KEY
  395.  or    a
  396.  jr    nz, WaitKey_Done
  397.  inc    de
  398.  ld    hl, $ffff
  399.  call    CP_HL_DE
  400.  jr    z, TimeOut_Set
  401.  jr    WaitKey_Loop
  402. TimeOut_Set:
  403.  ld    a, $0
  404. WaitKey_Done:
  405.  pop    hl
  406.  ret
  407.  
  408. ;Writes a zero terminated menutext string on the screen
  409. ;given $8333=x_cursor and $8334=y_cursor, and hl points 
  410. ;to the beginning of the string (relative to the beginning
  411. ;of the program).  
  412. DispMenu:
  413.  ld    de, (PROGRAM_ADDR)
  414.  add    hl, de
  415.  ROM_CALL(D_ZM_STR)
  416.  ret
  417.  
  418. ;Input password to dummy string (hl must point to dummy string,
  419. ;relatively).  If Key gotten is exit or timeout, loop quits with a value
  420. ;in accumulator.
  421. GetPass:
  422.  push    hl
  423.  ld    hl, $1100
  424.  ld    ($8333), hl
  425.  ld    hl, Prompt
  426.  CALL_(DispMenu)
  427.  pop    hl
  428. GetWordStuff:
  429.  ld    de, (PROGRAM_ADDR)
  430.  add    hl, de
  431.  ld    a, 0
  432.  ld    b, $0a
  433.  push    hl
  434.  CALL_(FillLoop)
  435.  pop    hl
  436.  ld    b, $0a
  437. Getkys:
  438.  CALL_(WaitKey)
  439.  or    a
  440.  jr    z, Exited
  441.  cp    (K_EXIT)
  442.  jr    z, Exited
  443.  cp    (K_ENTER)
  444.  jr    z, DoneNowPass
  445.  ld    (hl), a
  446.  inc    hl
  447.  djnz    Getkys
  448. DoneNowPass:
  449.  ld    a, $00
  450.  ret
  451. Exited:
  452.  ld    a, $0f
  453.  ret
  454.  
  455. ;Compares strings pointed to by relative addresses (hl) and (de) with
  456. ;each other (given their length in b).  Returns a value if they don't
  457. ;match, and $00 if to do match in register a.
  458. Compare:
  459.  push    bc
  460.  ld    bc, (PROGRAM_ADDR)
  461.  add    hl, bc
  462.  ex    de, hl
  463.  add    hl, bc
  464.  pop    bc
  465. CompareNow:
  466.  ld    a, (hl)
  467.  ld    c, a
  468.  ex    de, hl
  469.  ld    a, (hl)
  470.  ex    de, hl
  471.  cp    c
  472.  jr    nz, NotEqual
  473. NotDoneYet:
  474.  or    a
  475.  jr    z, DoneYet
  476.  inc    de
  477.  inc    hl
  478.  djnz    CompareNow
  479. DoneYet:
  480.  ld    a, $00
  481.  ret
  482. NotEqual:
  483.  ld    a, $0f
  484.  ret
  485.  
  486. ;Turns off the calculator.  When turned on, it has altered the
  487. ;accumulator.
  488. Off:
  489.  ld    a, $01
  490.  out    (3), a
  491.  res    0, (6)
  492.  HALT
  493.  ld    a, $0b
  494.  out    (3), a
  495.  set    0, (6)
  496.  ret
  497.  
  498. ;/ Note - Added 3/4/98
  499. ;/ Not the best way... May not turn off the calculator quite like TI-OS...
  500. ;/ A RAM Bit and ROM call might work best... Using interrupts built into the ROM...
  501.  
  502. ;Fills String pointed to by absolute (hl) with null's (must have
  503. ;length of string in b).
  504. FillLoop:
  505.  ld    a, 0
  506. FillLoop1:
  507.  ld    (hl), a
  508.  inc    hl
  509.  djnz    FillLoop1
  510.  ret
  511.  
  512. ;Returns to the main menu
  513. Return_Main:
  514.  ld    hl, MAIN
  515.  ld    de, (PROGRAM_ADDR)
  516.  add    hl, de
  517.  pop    de
  518.  push    hl
  519.  ret
  520.  
  521.  
  522. ;************************************************************************
  523. ;Gets letters after keypress.  **Note** From Magnus Hagander's Texanoid!!
  524. ;Both routine and letter table.  Slightly edited for purpose.
  525. GetLetter:
  526.    push hl
  527.    push bc
  528.    ld   hl,(PROGRAM_ADDR)
  529.    ld   de,LetterTable-1 ;Point to one before, since we always inc once
  530.    add  hl,de                   ;HL now points right
  531.  
  532. ConvertLoop:
  533.    push hl
  534.    CALL_(WaitKey)                 ;ACC holds key
  535.    pop  hl
  536.    or   a
  537.    jr   z, Shazam
  538.    cp   K_EXIT                  ;temp
  539.    jr    nz, NEXTCONVERT
  540.    ld    a, $0
  541.    jr   Shazam
  542.  
  543. NEXTCONVERT:
  544.    cp    K_ENTER
  545.    jr    z, Shazam
  546.    cp   0
  547.    jr   z,ConvertLoop
  548.  
  549.    push hl                      ;save away...
  550.    ld   b,a
  551.    ld   c,0
  552.  
  553. ConversionLoop:
  554.    inc  hl
  555.    djnz ConversionLoop          ;After this, we have the correct offset...
  556.    ld   a,(HL)
  557.    pop  hl
  558.    cp   255
  559.    jr   z,ConvertLoop           ;Invalid key
  560. Shazam:
  561.  
  562.    pop  bc
  563.    pop  hl
  564.  
  565.    ret                          ;Value is in acc
  566.  
  567.  
  568.  
  569.  
  570.  
  571. ;*********************************************************************
  572. ;***************************Strings and Data**************************
  573.  
  574. Prompt:
  575. .db "Enter Password:", 0
  576. Dummyone:
  577. .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  578. Dummytwo:
  579. .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  580. Password:
  581. .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  582.  
  583.  
  584. ;MainScreen:
  585. ;.db "     SecureIt-85     ", 0
  586. Registered_To:
  587. .db "Owner: "
  588. Owner:
  589. .db 'M', 'i', 'c', 'h', 'a', 'e', 'l', ' ', 'W', 'y', 'm', 'a', 'n', 0, 0, 0, 0, 0, 0, 0, 0, 0
  590. NewOwner:
  591. .db "New Owner: ", 0
  592. WrongPass:
  593. .db "Wrong PassWord!!", 0
  594. MainSecond:
  595. .db "F1-Lock Calc", 0
  596. .db "F2-Powerdown", 0
  597. .db "F3-Change Password", 0
  598. .db "F4-Change Owner", 0
  599. .db "F5-Exit to "
  600. MainExit_String:
  601. .db "ZShell", 0
  602. Name:
  603. .db " By: M. Wyman "
  604. .db "& SeaHorse Software", 0
  605. Address:
  606. .db " wyma0012@gold.tc.umn.edu", 0
  607. RePrompt:
  608. .db "Re"
  609. NewPrompt:
  610. .db "Enter New Password", 0
  611. PWChanged:
  612. .db "Password Changed", 0
  613. PWmissmatch:
  614. .db "Entry Error!!", 0
  615. ZShell_String:
  616. .db "ZShell"
  617. TIOS_String:
  618. .db "TI-OS", 0
  619.  
  620.  
  621. LetterTable:                                ; For converting keys into letters
  622.    .db 255,255,255,255
  623.    .db 255,255,255,255
  624.    .db 000,'X','T','O'
  625.    .db 'J','E','0',255
  626.    .db ' ','W','S','N'
  627.    .db 'I','D','9',255
  628.    .db 'Z','V','R','M'
  629.    .db 'H','C','8',255
  630.    .db 'Y','U','Q','L'
  631.    .db 'G','B','7',255
  632.    .db 255,255,'P','K'
  633.    .db 'F','A','6',255
  634.    .db '5','4','3','2'
  635.    .db '1','-',255,255
  636.  
  637. .end
  638. ;END of FILE