Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .nolist
- #include "ti83plus.inc"
- #include "dcs7.inc"
- .list
- .org $9D93
- .db t2ByteTok,tAsmCmp
- CipherText .equ appBackUpScreen ; Will contain final result
- ExpandedKey .equ appBackUpScreen+256 ; Will contain key to full length
- OffsetConvString .equ appBackUpScreen+512 ; Will contain string as values 0-25
- Init: ; Doors CS 7 Header
- xor d
- ret
- jr Start
- .dw Description
- .db $07,$00
- .dw Icon
- .dw 0000
- Start:
- bcall(_ClrLCDFull)
- call OpenGUIStack
- ld hl,MainGUIData
- call PushGUIStacks
- ld hl,0
- call GUIMouse
- ret
- Encrypt:
- call ResetAppPage
- call ExpandKey
- ; call ASCIIToOffset
- ld hl,OffsetConvString
- ld de,ExpandedKey
- ld bc,CipherText
- bcall(_GetKey)
- ret
- ASCIIToOffset:
- ; I'm not sure what a good routine for this would be
- ret
- Decrypt:
- ; This will be trivial once enciphering is working
- call ResetAppPage
- ret
- GetStringLocation:
- call GUIFindThis
- ld de,6
- add hl,de
- ret
- Sub26:
- sub 26
- ret
- ExpandKey:
- ld a,3
- call GetStringLocation ; hl contains pointer to string
- ld b,0
- StringSizeLoop:
- inc hl
- inc b
- ld a,(hl)
- cp 0
- jr z,SizeCheckComplete
- jr StringSizeLoop
- SizeCheckComplete: ; b contains character count from string
- call ResetKeyPointer ; hl has pointer to key
- ld de,ExpandedKey
- ExpandKeyLoop:
- ld a,(hl)
- cp 0
- jr z,ResetKeyPointer
- ld (de),a
- inc de
- inc hl
- djnz ExpandKeyLoop
- ret
- ResetKeyPointer:
- push de
- push bc
- ld a,4
- call GetStringLocation
- pop bc
- pop de
- ret
- About:
- call ResetAppPage
- ld hl,AboutGUIData
- call PushGUIStacks
- ld hl,0
- call GUIMouse
- ret
- ReturnFromAbout:
- call ResetAppPage
- ld b,3
- call PopGUIStacks
- ld hl,0
- call GUIMouse
- ret
- Quit:
- call ResetAppPage
- call CloseGUIStack
- ret
- CharacterData:
- ; There are likely other Doors-compatible characters not here which need to be
- .db "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890 %#.-?()[],*/+^",$5B,$B0,$26,$22,$27,$D0,$B6,$B7,$5D,$C1,$05,$21,$24,$1A,0
- ; If 0<=n<=25, keep as-is; if 26<=n<=51, subtract 26; if n>=52, ignore
- ; >=52, use cp 52 & check for nc
- ; <=25, use cp 26 & check for c
- ; 26<=n<=51, neither of the above conditions were true
- MainGUIData:
- ; Main window
- .dw 29 ; Section size
- .db GUIRLargeWin ; Element type
- .db %10001000 ; Window icon
- .db %11011000
- .db %01010000
- .db %01010000
- .db %00100000
- .db "Vigenere Cipher Tool",0 ; Window title
- ; Buttons for main window
- .dw 10 ; Section size
- .db GUIRWinButtons ; Element type
- .db %00100000 ; No _, no [], yes X
- .dw 0 ; No pointer for _
- .dw 0 ; No pointer for []
- .dw Quit ; Jump to Quit when X pressed
- ; Text "Plaintext"
- .dw 16 ; Section size
- .db GUIRText ; Element type
- .db 8,0 ; x,y
- .db 0 ; Font (must be 0 atm)
- .db "Plaintext",0 ; Text
- ; Text "Key"
- .dw 10 ; Section size
- .db GUIRText ; Element type
- .db 64,0 ; x,y
- .db 0 ; Font (must be 0 atm)
- .db "Key",0 ; Text
- ; Plaintext input
- .dw 10 ; Section size
- .db GUIRTextMultiline ; Element type
- .db 1,7 ; x,y
- .db 6 ; 6 Rows
- .db 44 ; 44 px wide
- .dw 0 ; Offset
- .db 0 ; Default message
- ; Key input
- .dw 10 ; Section size
- .db GUIRTextMultiline ; Element type
- .db 48,7 ; x,y
- .db 6 ; 6 Rows
- .db 44 ; 44 px wide
- .dw 0 ; Offset
- .db 0 ; Default message
- ; Encrypt button
- .dw 16 ; Section size
- .db GUIRButtonText ; Element type
- .db 5,45 ; x,y
- .dw Encrypt ; Encrypt when clicked
- .db "Encipher",0 ; Text
- ; Decrypt button
- .dw 16 ; Section size
- .db GUIRButtonText ; Element type
- .db 56,45 ; x,y
- .dw Decrypt ; Decrypt when clicked
- .db "Decipher",0 ; Text
- ; About button
- .dw 14 ; Section size
- .db GUIRButtonImg ; Element type
- .db 43,45 ; x,y
- .dw About ; Load about screen
- .db 1 ; 1 byte per row
- .db 5 ; 5 px per byte
- .db %11011000 ; Icon
- .db %11111000
- .db %10011000
- .db %11011000
- .db %10001000
- ; End of main win data
- .dw $FFFF ; Tell DCS the data ends
- AboutGUIData:
- ; About window
- .dw 16 ; Section size
- .db GUIRSmallWin ; Element type
- .db 8,13 ; x,y
- .db %00100000 ; Icon
- .db %00000000
- .db %01100000
- .db %00100000
- .db %01110000
- .db "About",0 ; Window title
- ; About text
- .dw 50 ; Section size
- .db GUIRWrappedText ; Element type
- .db 5,0 ; x,y
- .db 72 ; 77px wide
- .db 0 ; Font (must be 0 atm)
- .db "Vigenere Cipher Tool",$D6," (C)2012 Jonathan Z.",0 ; Text
- ; About window buttons
- .dw 10 ; Section size
- .db GUIRWinButtons ; Element type
- .db %00100000 ; Only X button
- .dw 0 ; Nothing for _
- .dw 0 ; Nothing for []
- .dw ReturnFromAbout ; Jump to ReturnFromAbout when X is clicked
- ; End of about win data
- .dw $FFFF
- ;----------;
- ; DCS Data ;
- ;----------;
- Description: ; DCS7 Description
- .db "Vigenere Cipher Tool",0
- Icon: ; DCS7 Icon
- .db %00000011,%11000000
- .db %00001100,%00110000
- .db %00010001,%10001000
- .db %00010010,%01001000
- .db %00010010,%01001000
- .db %00010010,%01001000
- .db %00010010,%01001000
- .db %01111111,%11111110
- .db %01000000,%00000010
- .db %01000011,%11000010
- .db %01000011,%11000010
- .db %01000011,%11000010
- .db %01000001,%10000010
- .db %01000001,%10000010
- .db %01000000,%00000010
- .db %01111111,%11111110
Advertisement
Add Comment
Please, Sign In to add comment