pokecrystal-board/engine/pokemon/correct_nick_errors.asm

75 lines
1.2 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
CorrectNickErrors::
; error-check monster nick before use
; must be a peace offering to gamesharkers
; input: de = nick location
push bc
push de
2018-01-20 09:25:55 -08:00
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
2018-06-24 07:09:41 -07:00
.textcommands
; table defining which characters are actually text commands
; format:
; ≥ <
db "<NULL>", "ガ"
2018-01-19 17:48:33 -08:00
db "<PLAY_G>", "<JP_18>" + 1
db "<NI>", "<NO>" + 1
db "<ROUTE>", "<GREEN>" + 1
db "<ENEMY>", "<ENEMY>" + 1
db "<MOM>", "<TM>" + 1
db "<ROCKET>", "┘" + 1
db -1 ; end