From d3cc861d334c8b773c1b6c662ed9924c43cef009 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 4 Apr 2018 22:26:07 +0200 Subject: Fix snake_case filenames Renamed a bunch of files, most of them one-off functions, to better fit the general snake_case naming scheme. Also renamed some awfully long filenames. --- engine/pokemon/check_nick_errors.asm | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 engine/pokemon/check_nick_errors.asm (limited to 'engine/pokemon/check_nick_errors.asm') 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 "", "" + 1 + db "", "" + 1 + db "", "" + 1 + db "", "" + 1 + db "", "" + 1 + db "", "┘" + 1 + db -1 ; end -- cgit v1.2.3