home *** CD-ROM | disk | FTP | other *** search
- ; ------------------------------------------------------
- ; The source code contained below is the sole surviving,
- ; backed up copy of SecureIt-85's source code. A hard-
- ; drive crash of my computer lost all other versions'
- ; source files.
- ;
- ; I have stopped programming in Z80 assembly, and have
- ; not looked at this code since well before the disk
- ; crash (early Jan, 98). Therefore, I cannot provide
- ; much GOOD support for this source code, nor any other
- ; programs, really...
- ;-------------------------------------------------------
- ; I'm hereby releasing this source code to anybody who
- ; wishes to learn by it (if they can), borrow parts from
- ; it, or just plain regard it as a curiosity (for God
- ; knows what reason!) However, I have two requests to
- ; make regarding its use:
- ;
- ; 1) Don't steal it. If you borrow parts from it, make
- ; sure to mention it in the credits... If you port it to
- ; another platform, leave my name on it (though you can
- ; take off the e-mail & 'SeaHorse Software' part if you
- ; so desire). If you steal it.. well.. shame on you...
- ;
- ; 2) Please don't expect that it is an example of great
- ; code. It is probably not extremely well optimized,
- ; and certainly isn't well documented!!! If you have
- ; questions, I certainly can try to help a little, but
- ; remember that it's been quite some time since I've
- ; really looked at this code...
- ;
- ; Beyond that, I leave this code in your hands... May
- ; it serve you well!
- ;
- ; - Michael Wyman, wyma0012@tc.umn.edu
- ; March 4, 1998
- ; ------------------------------------------------------
-
-
-
- ; ------------------------------------------------------
- ; Released 3/4/98 by Michael Wyman
- ;
- ; Note: The code in this file is not fully optimized.
- ; SecureIt-85 v4.0 and v5.0 (v5.0 only existed on MY
- ; calculator, and so exists only to this day... I lost
- ; the source to that completely! Besides, it had been
- ; costumized for my ROM version and OS/7 w/ relocation.)
- ; were better optimized, and also smaller...
- ; ------------------------------------------------------
-
- #include ti-85.h
-
- .org 0
- MainScreen:
- .db "SecureIt-85 v3.0 (c)1996", 0
-
-
- ld de, (PROGRAM_ADDR)
- ld hl, randNum
- add hl, de
- push hl
- ld a, (hl)
- ld hl, Password
- add hl, de
- ld d, a
- ld b, 10
- FixPass:
- ld a, (hl)
- sub d
- ld (hl), a
- inc hl
- djnz FixPass
- ld a, d
- ld c, a
- sla c
- sla c
- add a, c
- sla c
- sla c
- add a, c
- inc a
- pop hl
- ld (hl), a
-
- ;Disp Main Screen and Main Menu
-
- MAIN:
- CALL_(SetScreen)
- ld hl, $0f00
- ld ($8333), hl
- ld hl, MainSecond
- ld de, (PROGRAM_ADDR)
- add hl, de
- ROM_CALL(D_ZM_STR)
- ld de, $1500
- ld ($8333), de
- ROM_CALL(D_ZM_STR)
- ld de, $1b00
- ld ($8333), de
- ROM_CALL(D_ZM_STR)
- ld de, $2100
- ld ($8333), de
- ROM_CALL(D_ZM_STR)
- ld de, $2700
- ld ($8333), de
- ROM_CALL(D_ZM_STR)
- MainKeyLoop:
- CALL_(WaitKey)
- cp (K_EXIT)
- jr z, EXITNOW
- cp (K_F1)
- JUMP_Z(PASSOFF)
- cp (K_F2)
- jr z, OFFNOW
- cp (K_F3)
- jr z, ChangePWJump
- cp (K_F5)
- jr z, Exit_Set
- cp (K_F4)
- jr nz, MainKeyLoop
- ld hl, ChangeOwner
- ld de, (PROGRAM_ADDR)
- add hl, de
- jp (hl)
-
- ExitBytes:
- .db $0
- randNum:
- .db $0
- Exit_Set:
- ld de, ExitBytes
- ld hl, (PROGRAM_ADDR)
- add hl, de
- bit 0, (hl)
- jr nz, TIOS
- set 0, (hl)
- ld de, TIOS_String
- jr ChangeExit_String
- TIOS:
- res 0, (hl)
- ld de, ZShell_String
- ChangeExit_String:
- ld hl, MainExit_String
- ld bc, (PROGRAM_ADDR)
- add hl, bc
- ex de, hl
- add hl, bc
- ld bc, $0006
- ldir
- CALL_(Return_Main)
-
- ChangePWJump:
- ld hl, ChangePW
- ld de, (PROGRAM_ADDR)
- add hl, de
- jp (hl)
-
- EXITNOW:
- ld de, (PROGRAM_ADDR)
- ld hl, randNum
- add hl, de
- ld a, (hl)
- ld hl, Password
- add hl, de
- ld d, a
- ld b, 10
- ScrewPass:
- ld a, (hl)
- add a, d
- ld (hl), a
- inc hl
- djnz ScrewPass
- ld hl, ZS_BITS
- push hl
- ld hl, ExitBytes
- ld de, (PROGRAM_ADDR)
- add hl, de
- bit 0, (hl)
- jr z, EXIT
- pop hl
- set 1, (hl)
- push hl
- EXIT:
- pop hl
- set 0, (hl)
- ret
- OFFNOW:
- CALL_(Off)
- CALL_(SetScreen)
- CALL_(WaitKey)
- jr EXITNOW
-
- PASSOFF:
- CALL_(Off)
- CALL_(SetScreen)
- ld hl, Dummyone
- CALL_(GetPass)
- or a
- jr nz, PASSOFF
- ld de, Dummyone
- ld hl, Password
- ld b, $0a
- CALL_(Compare)
- or a
- jr z, RightPass
- ld hl, $1800
- ld ($8333), hl
- ld hl, WrongPass
- CALL_(DispMenu)
- CALL_(WaitKey)
- jr PASSOFF
- RightPass:
- CALL_(SetScreen)
- CALL_(WaitKey)
- ld hl, EXITNOW
- ld de, (PROGRAM_ADDR)
- add hl, de
- Jumpit:
- jp (hl)
-
- ChangePW:
- CALL_(SetScreen)
- ld hl, Dummyone
- CALL_(GetPass)
- or a
- CALL_NZ(Return_Main)
- ld de, Dummyone
- ld hl, Password
- ld b, $0a
- CALL_(Compare)
- or a
- jr z, BeginChange
- CALL_(Return_Main)
- BeginChange:
- ld hl, $1100
- ld ($8333), hl
- ld hl, NewPrompt
- CALL_(DispMenu)
- ld hl, Dummyone
- push hl
- Pressed1:
- CALL_(GetWordStuff)
- or a
- jr nz, Pressed1
- ld hl, $1700
- ld ($8333), hl
- ld hl, RePrompt
- CALL_(DispMenu)
- ld hl, Dummytwo
- push hl
- Pressed2:
- CALL_(GetWordStuff)
- or a
- jr nz, Pressed2
- pop de
- pop hl
- ld b, $0a
- CALL_(Compare)
- or a
- jr z, PWChanging
- ld hl, $1d00
- ld ($8333), hl
- ld hl, PWmissmatch
- CALL_(DispMenu)
- CALL_(WaitKey)
- CALL_(Return_Main)
- PWChanging:
- ld hl, Password
- ld de, Dummytwo
- ld bc, (PROGRAM_ADDR)
- add hl, bc
- ex de, hl
- add hl, bc
- ld bc, $0a
- ldir
- ld hl, $1d00
- ld ($8333), hl
- ld hl, PWChanged
- CALL_(DispMenu)
- CALL_(WaitKey)
-
- Return:
- CALL_(Return_Main)
-
- ChangeOwner:
- CALL_(SetScreen)
- ld hl, Dummyone
- CALL_(GetPass)
- or a
- CALL_NZ(Return_Main)
- ld hl, Dummyone
- ld de, Password
- CALL_(Compare)
- or a
- jr z, ChangeOwner_
- CALL_(Return_Main)
- ChangeOwner_:
- CALL_(SetScreen)
- ld hl, $1100
- ld ($8333), hl
- ld hl, NewOwner
- CALL_(DispMenu)
- ld hl, Owner
- ld de, (PROGRAM_ADDR)
- add hl, de
- push hl
- ld b, $15
- CALL_(FillLoop)
- pop hl
- ld b, $15
- OwnerLoop:
- push hl
- ld hl, ($8333)
- push hl
- ld a, '_'
- ROM_CALL(M_CHARPUT)
- pop hl
- ld ($8333), hl
- pop hl
- CALL_(GetLetter)
- or a
- jr z, DoneOwn
- cp (K_ENTER)
- jr z, DoneOwn
- ld (hl), a
- inc hl
- ROM_CALL(M_CHARPUT)
- djnz OwnerLoop
- DoneOwn:
- CALL_(Return_Main)
-
-
-
-
-
-
-
-
-
-
- ;**************************SUBROUTINES******************************
-
- ;Sets Screen in (cool) mode (i.e. Main Screen).
- SetScreen:
- ROM_CALL(CLEARLCD)
- ld hl, $0700
- ld ($8333), hl
- ld hl, Registered_To
- CALL_(DispMenu)
- ld hl, $fc00
- ld a, $ff
- ld b, $70
- Blacken:
- ld (hl), a
- inc hl
- djnz Blacken
- ld hl, $0018
- ld ($8333), hl
- ld hl, MainScreen
- set 3, (IY+5)
- res 1, (IY+5)
- CALL_(DispMenu)
- ld hl, $fce0
- ld b, 16
- ld a, $ff
- DrawLine_1:
- ld (hl), a
- inc hl
- djnz DrawLine_1
- ld hl, $ff30
- ld b, $d0
- DrawLine_2:
- ld (hl), a
- inc hl
- djnz DrawLine_2
- ld hl, $3300
- ld ($8333), hl
- ld hl, Name
- CALL_(DispMenu)
- ld hl, $3900
- ld ($8333), hl
- ld hl, Address
- CALL_(DispMenu)
- res 3, (IY+5)
- set 1, (IY+5)
- ret
-
- ;Waits for Key input (returns ACC as keypress value, $0 if TimeOut)
- WaitKey:
- push hl
- ld de, 0
- WaitKey_Loop:
- call GET_KEY
- or a
- jr nz, WaitKey_Done
- inc de
- ld hl, $ffff
- call CP_HL_DE
- jr z, TimeOut_Set
- jr WaitKey_Loop
- TimeOut_Set:
- ld a, $0
- WaitKey_Done:
- pop hl
- ret
-
- ;Writes a zero terminated menutext string on the screen
- ;given $8333=x_cursor and $8334=y_cursor, and hl points
- ;to the beginning of the string (relative to the beginning
- ;of the program).
- DispMenu:
- ld de, (PROGRAM_ADDR)
- add hl, de
- ROM_CALL(D_ZM_STR)
- ret
-
- ;Input password to dummy string (hl must point to dummy string,
- ;relatively). If Key gotten is exit or timeout, loop quits with a value
- ;in accumulator.
- GetPass:
- push hl
- ld hl, $1100
- ld ($8333), hl
- ld hl, Prompt
- CALL_(DispMenu)
- pop hl
- GetWordStuff:
- ld de, (PROGRAM_ADDR)
- add hl, de
- ld a, 0
- ld b, $0a
- push hl
- CALL_(FillLoop)
- pop hl
- ld b, $0a
- Getkys:
- CALL_(WaitKey)
- or a
- jr z, Exited
- cp (K_EXIT)
- jr z, Exited
- cp (K_ENTER)
- jr z, DoneNowPass
- ld (hl), a
- inc hl
- djnz Getkys
- DoneNowPass:
- ld a, $00
- ret
- Exited:
- ld a, $0f
- ret
-
- ;Compares strings pointed to by relative addresses (hl) and (de) with
- ;each other (given their length in b). Returns a value if they don't
- ;match, and $00 if to do match in register a.
- Compare:
- push bc
- ld bc, (PROGRAM_ADDR)
- add hl, bc
- ex de, hl
- add hl, bc
- pop bc
- CompareNow:
- ld a, (hl)
- ld c, a
- ex de, hl
- ld a, (hl)
- ex de, hl
- cp c
- jr nz, NotEqual
- NotDoneYet:
- or a
- jr z, DoneYet
- inc de
- inc hl
- djnz CompareNow
- DoneYet:
- ld a, $00
- ret
- NotEqual:
- ld a, $0f
- ret
-
- ;Turns off the calculator. When turned on, it has altered the
- ;accumulator.
- Off:
- ld a, $01
- out (3), a
- res 0, (6)
- HALT
- ld a, $0b
- out (3), a
- set 0, (6)
- ret
-
- ;/ Note - Added 3/4/98
- ;/ Not the best way... May not turn off the calculator quite like TI-OS...
- ;/ A RAM Bit and ROM call might work best... Using interrupts built into the ROM...
-
- ;Fills String pointed to by absolute (hl) with null's (must have
- ;length of string in b).
- FillLoop:
- ld a, 0
- FillLoop1:
- ld (hl), a
- inc hl
- djnz FillLoop1
- ret
-
- ;Returns to the main menu
- Return_Main:
- ld hl, MAIN
- ld de, (PROGRAM_ADDR)
- add hl, de
- pop de
- push hl
- ret
-
-
- ;************************************************************************
- ;Gets letters after keypress. **Note** From Magnus Hagander's Texanoid!!
- ;Both routine and letter table. Slightly edited for purpose.
- GetLetter:
- push hl
- push bc
- ld hl,(PROGRAM_ADDR)
- ld de,LetterTable-1 ;Point to one before, since we always inc once
- add hl,de ;HL now points right
-
- ConvertLoop:
- push hl
- CALL_(WaitKey) ;ACC holds key
- pop hl
- or a
- jr z, Shazam
- cp K_EXIT ;temp
- jr nz, NEXTCONVERT
- ld a, $0
- jr Shazam
-
- NEXTCONVERT:
- cp K_ENTER
- jr z, Shazam
- cp 0
- jr z,ConvertLoop
-
- push hl ;save away...
- ld b,a
- ld c,0
-
- ConversionLoop:
- inc hl
- djnz ConversionLoop ;After this, we have the correct offset...
- ld a,(HL)
- pop hl
- cp 255
- jr z,ConvertLoop ;Invalid key
- Shazam:
-
- pop bc
- pop hl
-
- ret ;Value is in acc
-
-
-
-
-
- ;*********************************************************************
- ;***************************Strings and Data**************************
-
- Prompt:
- .db "Enter Password:", 0
- Dummyone:
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- Dummytwo:
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- Password:
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-
-
- ;MainScreen:
- ;.db " SecureIt-85 ", 0
- Registered_To:
- .db "Owner: "
- Owner:
- .db 'M', 'i', 'c', 'h', 'a', 'e', 'l', ' ', 'W', 'y', 'm', 'a', 'n', 0, 0, 0, 0, 0, 0, 0, 0, 0
- NewOwner:
- .db "New Owner: ", 0
- WrongPass:
- .db "Wrong PassWord!!", 0
- MainSecond:
- .db "F1-Lock Calc", 0
- .db "F2-Powerdown", 0
- .db "F3-Change Password", 0
- .db "F4-Change Owner", 0
- .db "F5-Exit to "
- MainExit_String:
- .db "ZShell", 0
- Name:
- .db " By: M. Wyman "
- .db "& SeaHorse Software", 0
- Address:
- .db " wyma0012@gold.tc.umn.edu", 0
- RePrompt:
- .db "Re"
- NewPrompt:
- .db "Enter New Password", 0
- PWChanged:
- .db "Password Changed", 0
- PWmissmatch:
- .db "Entry Error!!", 0
- ZShell_String:
- .db "ZShell"
- TIOS_String:
- .db "TI-OS", 0
-
-
- LetterTable: ; For converting keys into letters
- .db 255,255,255,255
- .db 255,255,255,255
- .db 000,'X','T','O'
- .db 'J','E','0',255
- .db ' ','W','S','N'
- .db 'I','D','9',255
- .db 'Z','V','R','M'
- .db 'H','C','8',255
- .db 'Y','U','Q','L'
- .db 'G','B','7',255
- .db 255,255,'P','K'
- .db 'F','A','6',255
- .db '5','4','3','2'
- .db '1','-',255,255
-
- .end
- ;END of FILE