diff options
author | yenatch <yenatch@gmail.com> | 2018-04-04 21:04:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-04 21:04:14 -0400 |
commit | fe4377ce532d1fea1b28d2c52e4f62f0ca702a30 (patch) | |
tree | 6ce2635ce57ff2735839235e3061e7f3009cfe5d /engine/pokemon/check_nick_errors.asm | |
parent | 0c446367ce79dfe2a26f4bd7668036477811a279 (diff) | |
parent | 38107209a6ad431b399cc36405c0af8b5babf5ef (diff) |
Merge pull request #501 from mid-kid/reorg
Organize the engine/ directory
Diffstat (limited to 'engine/pokemon/check_nick_errors.asm')
-rw-r--r-- | engine/pokemon/check_nick_errors.asm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/engine/pokemon/check_nick_errors.asm b/engine/pokemon/check_nick_errors.asm new file mode 100644 index 000000000..87ebd6bb3 --- /dev/null +++ b/engine/pokemon/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, 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 ; 66cf +; table defining which characters are actually text commands +; format: + ; ≥ < + db TX_START, TX_BOX + 1 + 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 |