made ROT command only use letters, added in lib

This commit is contained in:
Stephen Toth 2018-07-10 09:54:24 -04:00
parent a1f172cccb
commit 1f2660ab45
6 changed files with 1057 additions and 871 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ cryptocmdROTfExe:
ld hl, FshCmdArg0 ld hl, FshCmdArg0
ld a, (hl) ld a, (hl)
ld hl, FshScratch ld hl, FshScratch
call rotasciiencrypt call rotletencrypt
call _PutS call _PutS
call _NewLine call _NewLine
jp Fin jp Fin

View File

@ -1,3 +1,72 @@
;;rotletencrypt
;;Encrypts a string in rot-x (uses $41 to $5B)
;;Inputs:
;; HL: string pointer
;; A: x
;;Notes:
;; Changes string in place.
rotletencrypt:
push hl
push bc
ld c, 0
ld c, a
rotletencryptLoop:
ld a, (hl)
cp 0
jr z, rotletencryptEnd
add a, c
cp 0
jr nz, rotletencryptLd
inc a
rotletencryptLd:
ld (hl), a
inc hl
cp a, $5c
jr c, rotletencryptLoop
dec hl
sub a, 'Z' + 1 - 'A'
ld (hl), a
inc hl
jr rotletencryptLoop
rotletencryptEnd:
ld (hl), $00
pop bc
pop hl
ret
;;rotletdecrypt
;;Encrypts a string in rot-x (uses $41 to $5B)
;;Inputs:
;; HL: string pointer
;; A: x
;;Notes:
;; Changes string in place.
rotletdecrypt:
push hl
push bc
ld c, 0
ld c, a
rotletdecryptLoop:
ld a, (hl)
cp 0
jr z, rotletdecryptEnd
sub a, c
rotletdecryptLd:
ld (hl), a
inc hl
cp a, $5c
jr c, rotletdecryptLoop
dec hl
add a, 'Z' + 1 - 'A'
ld (hl), a
inc hl
jr rotletdecryptLoop
rotletdecryptEnd:
ld (hl), $00
pop bc
pop hl
ret
;;rotasciiencrypt ;;rotasciiencrypt
;;Encrypts a string in rot-x (uses $00 to $EF) ;;Encrypts a string in rot-x (uses $00 to $EF)
;;Inputs: ;;Inputs:
@ -33,4 +102,40 @@ rotasciiencryptEnd:
pop bc pop bc
pop hl pop hl
ret ret
;;rotasciidecrypt
;;Encrypts a string in rot-x (uses $00 to $EF)
;;Inputs:
;; HL: string pointer
;; A: x
;;Notes:
;; Changes string in place.
rotasciidecrypt:
push hl
push bc
ld c, 0
ld c, a
rotasciidecryptLoop:
ld a, (hl)
cp 0
jr z, rotasciidecryptEnd
sub a, c
cp 0
jr nz, rotasciidecryptLd
dec a
rotasciidecryptLd:
ld (hl), a
inc hl
cp a, $EF
jr c, rotasciidecryptLoop
dec hl
add a, $0F
ld (hl), a
inc hl
jr rotasciidecryptLoop
rotasciidecryptEnd:
ld (hl), $00
pop bc
pop hl
ret

View File

@ -15,6 +15,7 @@ manroute:
#endmacro #endmacro
call fshcmdmanroute call fshcmdmanroute
call cryptocmdmanroute
;Extention Point ;Extention Point
ld hl, FshCmdErrCode ld hl, FshCmdErrCode
@ -41,6 +42,7 @@ manrouteu:
#endmacro #endmacro
call fshcmdmanrouteu call fshcmdmanrouteu
call cryptocmdmanrouteu
;Extention Point ;Extention Point
ld hl, FshCmdErrCode ld hl, FshCmdErrCode

View File

@ -1,3 +1,4 @@
.nolist
; Included for Assembler Compatibility ; Included for Assembler Compatibility
;------------------------------------ ;------------------------------------
#define equ .equ #define equ .equ
@ -27,3 +28,5 @@ FshCmdArgFlags equ FshCmdArg3 + 10
FshCmdErrCode equ FshCmdArgFlags + 1 FshCmdErrCode equ FshCmdArgFlags + 1
FshScratch equ FshCmdErrCode + 1 FshScratch equ FshCmdErrCode + 1
.list