Added ROT command and rot lib
This commit is contained in:
parent
19a5357d41
commit
a1f172cccb
1
FSHa.asm
1
FSHa.asm
|
|
@ -70,6 +70,7 @@ FshFlags: .DB %00000000
|
|||
|
||||
#include "includes/lib/std/std.inc"
|
||||
#include "includes/lib/fsh/fsh.inc"
|
||||
#include "includes/lib/crypto/crypto.inc"
|
||||
|
||||
#include "includes/man-db.asm"
|
||||
#include "includes/Command.asm"
|
||||
|
|
|
|||
BIN
bin/FSHa.8xp
BIN
bin/FSHa.8xp
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
|
@ -1 +1,2 @@
|
|||
SPASM.exe -ETA "FSHa.asm" "bin\FSHa.8xp"
|
||||
SPASM.exe -E -T "FSHa.asm" "bin\FSHa.8xp"
|
||||
pause
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
;; Sets (DE) with command op code
|
||||
commanddecode:
|
||||
call fshcmddecode
|
||||
call cryptocmddecode
|
||||
;Extention Point
|
||||
|
||||
ret
|
||||
|
|
@ -17,6 +18,7 @@ commanddecode:
|
|||
;; HL: Op code mem loc
|
||||
commandroute:
|
||||
call fshcmdroute
|
||||
call cryptocmdroute
|
||||
;Extention Point
|
||||
|
||||
ld hl, ErrCmdNotFoundo
|
||||
|
|
@ -26,3 +28,4 @@ commandroute:
|
|||
jp Err
|
||||
|
||||
#include "includes/FshCommands/FshCommand.asm"
|
||||
#include "includes/CryptoCommands/CryptoCommand.asm"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
cryptocmddecode:
|
||||
decodecmdopt(cryptocmdROT, cryptocmdROTo)
|
||||
ret
|
||||
|
||||
cryptocmdroute:
|
||||
pop bc
|
||||
routeoptjp(cryptocmdROTo, cryptocmdROTf)
|
||||
push bc
|
||||
ret
|
||||
|
||||
cryptocmdmanroute:
|
||||
pop bc
|
||||
routestrjp(cryptocmdROT, cryptocmdROTm)
|
||||
push bc
|
||||
ret
|
||||
|
||||
cryptocmdmanrouteu:
|
||||
pop bc
|
||||
routeustrjp(cryptocmdROT, cryptocmdROTu)
|
||||
push bc
|
||||
ret
|
||||
|
||||
#include "includes/CryptoCommands/CryptoCommands.inc"
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "includes/CryptoCommands/ROT.asm"
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
cryptocmdROT: .db "ROT", 0
|
||||
cryptocmdROTo: .db $40
|
||||
cryptocmdROTm: .db "ROT Cypher, rotates the alphabet and encodes a string", 0
|
||||
cryptocmdROTu: .db "ROT <shift#>", 0
|
||||
cryptocmdROTf:
|
||||
cryptocmdROTfArg0:
|
||||
ld hl, FshCmdArgFlags
|
||||
bit 1, (hl)
|
||||
jr nz, cryptocmdROTfArg1
|
||||
bit 0, (hl)
|
||||
jr z, cryptocmdROTfArg0Get
|
||||
ld hl, ErrUsageo
|
||||
call ErrSet
|
||||
call ErrCatch
|
||||
cryptocmdROTfArg0Get:
|
||||
ld hl, cryptocmdROTfDShift
|
||||
call printprompt
|
||||
ld hl, FshCmdArg0
|
||||
ld de, 3
|
||||
call inputnumstr
|
||||
call strtow
|
||||
ld de, FshCmdArg0
|
||||
ex de, hl
|
||||
ld (hl), e
|
||||
call _NewLine
|
||||
cryptocmdROTfArg1:
|
||||
jr cryptocmdROTfArg1Get
|
||||
ld hl, FshCmdArg1
|
||||
ld de, FshScratch
|
||||
call strcpy
|
||||
ld hl, FshCmdArgFlags
|
||||
bit 3, (hl)
|
||||
jr z, cryptocmdROTfExe
|
||||
bit 2, (hl)
|
||||
jr z, cryptocmdROTfArg1Get
|
||||
ld hl, ErrUsageo
|
||||
call ErrSet
|
||||
call ErrCatch
|
||||
cryptocmdROTfArg1Get:
|
||||
ld hl, cryptocmdROTfDMessage
|
||||
call printprompt
|
||||
ld hl, FshScratch
|
||||
ld de, FshScratchSize - 4
|
||||
call inputstr
|
||||
call _NewLine
|
||||
cryptocmdROTfExe:
|
||||
ld hl, FshCmdArg0
|
||||
ld a, (hl)
|
||||
ld hl, FshScratch
|
||||
call rotasciiencrypt
|
||||
call _PutS
|
||||
call _NewLine
|
||||
jp Fin
|
||||
|
||||
cryptocmdROTfDShift: .db "Shift= ", 0
|
||||
cryptocmdROTfDMessage: .db "Message= ", 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "includes/lib/crypto/rot.asm"
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
;;rotasciiencrypt
|
||||
;;Encrypts a string in rot-x (uses $00 to $EF)
|
||||
;;Inputs:
|
||||
;; HL: string pointer
|
||||
;; A: x
|
||||
;;Notes:
|
||||
;; Changes string in place.
|
||||
rotasciiencrypt:
|
||||
push hl
|
||||
push bc
|
||||
ld c, 0
|
||||
ld c, a
|
||||
rotasciiencryptLoop:
|
||||
ld a, (hl)
|
||||
cp 0
|
||||
jr z, rotasciiencryptEnd
|
||||
add a, c
|
||||
cp 0
|
||||
jr nz, rotasciiencryptLd
|
||||
inc a
|
||||
rotasciiencryptLd:
|
||||
ld (hl), a
|
||||
inc hl
|
||||
cp a, $EF
|
||||
jr c, rotasciiencryptLoop
|
||||
dec hl
|
||||
sub a, $0F
|
||||
ld (hl), a
|
||||
inc hl
|
||||
jr rotasciiencryptLoop
|
||||
rotasciiencryptEnd:
|
||||
ld (hl), $00
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
.nolist
|
||||
|
||||
; Included for Assembler Compatibility
|
||||
;------------------------------------
|
||||
#define equ .equ
|
||||
|
|
@ -11,6 +9,7 @@
|
|||
#define FshCmdSize 64 ;64 bytes | 44 chars , 5 qwords (CMD + args) , + 4 0's| 1 byte null | 2 byte optcode | 1 byte arg flags |1 byte (err code) | 6 unused
|
||||
#define FshCmdInptSize 44
|
||||
#define FshCmdCmdSize 8
|
||||
#define FshScratchSize FshCmdSize - FshCmdInptSize
|
||||
#define FshPrgmSize 1024
|
||||
|
||||
RamVars equ 0D0EA1Fh ;saveSScreen | 21945 bytes
|
||||
|
|
@ -26,3 +25,5 @@ FshCmdArg2 equ FshCmdArg1 + 9
|
|||
FshCmdArg3 equ FshCmdArg2 + 9
|
||||
FshCmdArgFlags equ FshCmdArg3 + 10
|
||||
FshCmdErrCode equ FshCmdArgFlags + 1
|
||||
|
||||
FshScratch equ FshCmdErrCode + 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue