diff options
author | yenatch <yenatch@gmail.com> | 2017-12-23 17:14:09 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2017-12-23 17:14:09 -0500 |
commit | c51968f0de6b8420c141dde27339e82a42837c5b (patch) | |
tree | 782f2b25f21adacb48fd516694b8a82864fe0b99 /engine/check_nick_errors.asm | |
parent | c883ab4d34ecb4890010e808d6b6d533f5d8ad56 (diff) | |
parent | 878092004956418bfd77bfdb9fc9dd7f640f80d2 (diff) |
Merge remote-tracking branch 'origin/master' into master
Diffstat (limited to 'engine/check_nick_errors.asm')
-rw-r--r-- | engine/check_nick_errors.asm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/engine/check_nick_errors.asm b/engine/check_nick_errors.asm new file mode 100644 index 000000000..1cedca420 --- /dev/null +++ b/engine/check_nick_errors.asm @@ -0,0 +1,74 @@ +CheckNickErrors:: ; 669f +; error-check monster nick before use +; must be a peace offering to gamesharkers + +; input: de = nick location + + push bc + push de + ld b, PKMN_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 ; 66cf +; table defining which characters are actually text commands +; format: + ; ≥ < + db "<START>", TX_BOX + 1 + db "<PLAY_G>", $18 + 1 + db $1d, "%" + 1 + db $35, "<GREEN>" + 1 + db "<ENEMY>", "<ENEMY>" + 1 + db "<MOM>", "<TM>" + 1 + db "<ROCKET>", "┘" + 1 + db -1 ; end |