summaryrefslogtreecommitdiff
path: root/engine/pokemon/correct_nick_errors.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/pokemon/correct_nick_errors.asm')
-rw-r--r--engine/pokemon/correct_nick_errors.asm53
1 files changed, 53 insertions, 0 deletions
diff --git a/engine/pokemon/correct_nick_errors.asm b/engine/pokemon/correct_nick_errors.asm
new file mode 100644
index 00000000..c7b6ff39
--- /dev/null
+++ b/engine/pokemon/correct_nick_errors.asm
@@ -0,0 +1,53 @@
+CorrectNickErrors:: ; 677e (1:677e)
+ push bc
+ push de
+ ld b, MON_NAME_LENGTH
+.checkchar
+ ld a, [de]
+ cp "@"
+ jr z, .done
+ ld hl, .textcommands
+ dec hl
+.loop
+ inc hl
+ ld a, [hl]
+ cp $ff
+ jr z, .next
+ ld a, [de]
+ cp [hl]
+ inc hl
+ jr c, .loop
+ cp [hl]
+ jr nc, .loop
+ ld a, "?"
+ ld [de], a
+ jr .loop
+
+.next
+ inc de
+ dec b
+ jr nz, .checkchar
+ pop de
+ push de
+ ld a, "?"
+ ld [de], a
+ inc de
+ ld a, "@"
+ ld [de], a
+.done
+ pop de
+ pop bc
+ ret
+
+.textcommands
+; table defining which characters are actually text commands
+; format:
+ ; ≥ <
+ db "<START>", $04 + 1
+ db "<PLAY_G>", $18 + 1
+ db $1d, "%" + 1
+ db $35, "<GREEN>" + 1
+ db "<ENEMY>", "<ENEMY>" + 1
+ db $49, "<TM>" + 1
+ db "<ROCKET>", "┘" + 1
+ db -1 ; end \ No newline at end of file