diff --git a/bin/FSHa.8xp b/bin/FSHa.8xp index 4133ecc..814de8f 100644 Binary files a/bin/FSHa.8xp and b/bin/FSHa.8xp differ diff --git a/includes/Memory.asm b/includes/Memory.asm deleted file mode 100644 index e69de29..0000000 diff --git a/includes/String.asm b/includes/String.asm index cd49632..94ccc87 100644 --- a/includes/String.asm +++ b/includes/String.asm @@ -121,6 +121,7 @@ strchrNoCharFound: strtob: push bc push de + ld c, 0 strtobNumFind: ld a, (hl) cp $00 @@ -175,6 +176,108 @@ strtobExit: pop bc ret +;; strtow +;; Converts a string to a byte +;; Inputs: +;; HL: string pointer +;; Outputs: +;; HL: byte +strtow: + push bc + push de + ld bc, 0 +strtowNumFind: + ld a, (hl) + cp $00 + jp z, strtowEXIT + ld c, 0 + sub '1' + cp '9' + 1 + jr c, strtowNumWhile + inc hl + jr strtowNumFind +strtowNumWhile: + push hl +strtowNumWhileLoop: + ld a, c + cp 5 + jp nc, strtowConvert + ld a, (hl) + sub '0' - 1 + jr c, strtowConvert + cp '9' + 1 + jr nc, strtowConvert + inc hl + inc c + jr strtowNumWhileLoop +strtowConvert: + dec hl + ld a, (hl) + sub '0' + ld bc, 0 + ld c, a + dec hl + + pop de + call cpHLDE + jp c, strtowExit + ld a, (hl) + sub '0' + push hl + ld hl, 10 + call mulAbyHL + add hl, bc + ld b, h + ld c, l + pop hl + dec hl + + call cpHLDE + jp c, strtowExit + ld a, (hl) + sub '0' + push hl + ld hl, 100 + call mulAbyHL + add hl, bc + ld b, h + ld c, l + pop hl + dec hl + + call cpHLDE + jp c, strtowExit + ld a, (hl) + sub '0' + push hl + ld hl, 1000 + call mulAbyHL + add hl, bc + ld b, h + ld c, l + pop hl + dec hl + + call cpHLDE + jp c, strtowExit + ld a, (hl) + sub '0' + push hl + ld hl, 10000 + call mulAbyHL + add hl, bc + ld b, h + ld c, l + pop hl + +strtowExit: + ld hl, 0 + ld h, b + ld l, c + pop de + pop bc + ret + ;; toLower [Strings] ;; Converts every alpha character of a string to lowercase. ;; Inputs: diff --git a/includes/commands/SET.asm b/includes/commands/SET.asm index 159eaa8..0c63833 100644 --- a/includes/commands/SET.asm +++ b/includes/commands/SET.asm @@ -42,23 +42,29 @@ fshcmdSETfArg1Get: ld hl, fshcmdSETfDValue call _PutS ld hl, fshcmdSETfInputBuffer - ld de, 3 + ld de, 5 call inputnumstr - call strtob + call strtow + ex de, hl ld hl, FshCmdArg1 - ld (hl), a + ld (hl), d + inc hl + ld (hl), e fshcmdSETfExe: ld hl, FshCmdArg0 ld de, 0 ld e, (hl) - ld hl, FshCmdArg1 - ld b, (hl) - ld hl, 0 - ld l, b + push de + ld hl, FshCmdArg1 + ld d, (hl) + inc hl + ld e, (hl) + ex de, hl + pop de call fshvarset call _NewLine jp ErrCatch -fshcmdSETfInputBuffer: .db $00,$00,$00,$00 +fshcmdSETfInputBuffer: .db $00, $00, $00, $00, $00, $00 fshcmdSETfDIndex: .db "Index= ", 0 fshcmdSETfDValue: .db "Value= ", 0