From 1e1bbbbf8c82364dcfb8e64ad22c4ce3e9988c75 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 5 Apr 2018 00:04:53 -0400 Subject: =?UTF-8?q?check=5Fnick=5Ferrors=20=E2=86=92=20correct=5Fnick=5Fer?= =?UTF-8?q?rors;=20matches=20correct=5Fparty=5Ferrors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/pokemon/check_nick_errors.asm | 74 ---------------------------------- engine/pokemon/correct_nick_errors.asm | 74 ++++++++++++++++++++++++++++++++++ engine/pokemon/stats_screen.asm | 2 +- home.asm | 2 +- main.asm | 2 +- 5 files changed, 77 insertions(+), 77 deletions(-) delete mode 100644 engine/pokemon/check_nick_errors.asm create mode 100644 engine/pokemon/correct_nick_errors.asm diff --git a/engine/pokemon/check_nick_errors.asm b/engine/pokemon/check_nick_errors.asm deleted file mode 100644 index 87ebd6bb3..000000000 --- a/engine/pokemon/check_nick_errors.asm +++ /dev/null @@ -1,74 +0,0 @@ -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 diff --git a/engine/pokemon/correct_nick_errors.asm b/engine/pokemon/correct_nick_errors.asm new file mode 100644 index 000000000..5d44846bf --- /dev/null +++ b/engine/pokemon/correct_nick_errors.asm @@ -0,0 +1,74 @@ +CorrectNickErrors:: ; 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 diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm index 59d96999f..7e44cb96e 100644 --- a/engine/pokemon/stats_screen.asm +++ b/engine/pokemon/stats_screen.asm @@ -772,7 +772,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6) ld hl, .OTNamePointers call GetNicknamePointer call CopyNickname - farcall CheckNickErrors + farcall CorrectNickErrors hlcoord 2, 13 call PlaceString ld a, [wTempMonCaughtGender] diff --git a/home.asm b/home.asm index fe44e3d31..75b5bf283 100644 --- a/home.asm +++ b/home.asm @@ -1211,7 +1211,7 @@ GetNick:: ; 38a2 call CopyBytes pop de - callfar CheckNickErrors + callfar CorrectNickErrors pop bc pop hl diff --git a/main.asm b/main.asm index fac1b8f3f..93a530079 100644 --- a/main.asm +++ b/main.asm @@ -9,7 +9,7 @@ INCLUDE "engine/overworld/map_objects.asm" INCLUDE "engine/menus/intro_menu.asm" INCLUDE "engine/overworld/init_map.asm" INCLUDE "engine/pokemon/learn.asm" -INCLUDE "engine/pokemon/check_nick_errors.asm" +INCLUDE "engine/pokemon/correct_nick_errors.asm" INCLUDE "engine/math/math.asm" INCLUDE "data/items/attributes.asm" INCLUDE "engine/overworld/npc_movement.asm" -- cgit v1.2.3