mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
69 lines
1.0 KiB
NASM
69 lines
1.0 KiB
NASM
CorrectNickErrors::
|
|
; error-check monster nick before use
|
|
; must be a peace offering to gamesharkers
|
|
|
|
; input: de = nick location
|
|
|
|
push bc
|
|
push de
|
|
ld b, MON_NAME_LENGTH
|
|
|
|
.checkchar
|
|
; end of nick?
|
|
ld a, [de]
|
|
cp "@" ; terminator
|
|
jr z, .end
|
|
|
|
; check if this char is a text command
|
|
ld hl, .textcommands
|
|
dec hl
|
|
.loop
|
|
; next entry
|
|
inc hl
|
|
; reached end of commands table?
|
|
ld a, [hl]
|
|
cp -1
|
|
jr z, .done
|
|
|
|
; is the current char between this value (inclusive)...
|
|
ld a, [de]
|
|
cp [hl]
|
|
inc hl
|
|
jr c, .loop
|
|
; ...and this one?
|
|
cp [hl]
|
|
jr nc, .loop
|
|
|
|
; replace it with a "?"
|
|
ld a, "?"
|
|
ld [de], a
|
|
jr .loop
|
|
|
|
.done
|
|
; next char
|
|
inc de
|
|
; reached end of nick without finding a terminator?
|
|
dec b
|
|
jr nz, .checkchar
|
|
|
|
; change nick to "?@"
|
|
pop de
|
|
push de
|
|
ld a, "?"
|
|
ld [de], a
|
|
inc de
|
|
ld a, "@"
|
|
ld [de], a
|
|
.end
|
|
; if the nick has any errors at this point it's out of our hands
|
|
pop de
|
|
pop bc
|
|
ret
|
|
|
|
.textcommands
|
|
; table defining which characters are actually text commands
|
|
; format:
|
|
; ≥ <
|
|
db "<NULL>", FIRST_REGULAR_TEXT_CHAR
|
|
db -1 ; end
|