diff options
Diffstat (limited to 'engine/pokemon/correct_nick_errors.asm')
-rw-r--r-- | engine/pokemon/correct_nick_errors.asm | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/engine/pokemon/correct_nick_errors.asm b/engine/pokemon/correct_nick_errors.asm index 44748a00..421bf92d 100644 --- a/engine/pokemon/correct_nick_errors.asm +++ b/engine/pokemon/correct_nick_errors.asm @@ -1,32 +1,52 @@ 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 "@" - jr z, .done + 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 $ff - jr z, .next + 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 -.next +.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, "?" @@ -34,7 +54,8 @@ CorrectNickErrors:: inc de ld a, "@" ld [de], a -.done +.end +; if the nick has any errors at this point it's out of our hands pop de pop bc ret |