diff options
author | YamaArashi <shadow962@live.com> | 2017-01-12 21:00:43 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2017-01-12 21:00:52 -0800 |
commit | 88d87495ed2e5e29074ee97d5c636ec75a6e88fe (patch) | |
tree | db8d8b3b35d3836162cc5749fc11f930cf1590a4 | |
parent | 0db72319326c6b29b0fdcdd1e7767a7e7ba46a1d (diff) |
decompile name_string_util
-rw-r--r-- | asm/name_string_util.s | 76 | ||||
-rw-r--r-- | ld_script.txt | 2 | ||||
-rw-r--r-- | src/name_string_util.c | 39 |
3 files changed, 40 insertions, 77 deletions
diff --git a/asm/name_string_util.s b/asm/name_string_util.s deleted file mode 100644 index 3fcfd89d9..000000000 --- a/asm/name_string_util.s +++ /dev/null @@ -1,76 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start PadNameString -PadNameString: @ 814A518 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - bl StripExtCtrlCodes - adds r0, r4, 0 - bl StringLength - lsls r0, 24 - lsrs r1, r0, 24 - cmp r5, 0xFC - bne _0814A556 - cmp r1, 0x5 - bhi _0814A55A - movs r3, 0xFC - movs r2, 0x7 -_0814A53A: - adds r0, r4, r1 - strb r3, [r0] - strb r2, [r0, 0x1] - adds r0, r1, 0x2 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x5 - bls _0814A53A - b _0814A55A -_0814A54C: - adds r0, r4, r1 - strb r5, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 -_0814A556: - cmp r1, 0x5 - bls _0814A54C -_0814A55A: - adds r1, r4, r1 - movs r0, 0xFF - strb r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end PadNameString - - thumb_func_start SanitizeNameString -SanitizeNameString: @ 814A568 - push {r4,lr} - adds r4, r0, 0 - bl StringLength - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bhi _0814A582 - adds r0, r4, 0 - movs r1, 0x1 - bl ConvertInternationalString - b _0814A588 -_0814A582: - adds r0, r4, 0 - bl StripExtCtrlCodes -_0814A588: - pop {r4} - pop {r0} - bx r0 - thumb_func_end SanitizeNameString - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index 9ac37701c..50630c9fb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -243,7 +243,7 @@ SECTIONS { src/bard_music.o(.text); asm/fldeff_teleport.o(.text); asm/unknown_debug_menu.o(.text); - asm/name_string_util.o(.text); + src/name_string_util.o(.text); src/menu_cursor.o(.text); } =0 diff --git a/src/name_string_util.c b/src/name_string_util.c new file mode 100644 index 000000000..27e6d99d0 --- /dev/null +++ b/src/name_string_util.c @@ -0,0 +1,39 @@ +#include "global.h" +#include "text.h" +#include "string_util.h" + +void PadNameString(u8 *a1, u8 a2) +{ + u8 i; + + StripExtCtrlCodes(a1); + i = StringLength(a1); + + if (a2 == 0xFC) + { + while (i < 6) + { + a1[i] = 0xFC; + a1[i + 1] = 7; + i += 2; + } + } + else + { + while (i < 6) + { + a1[i] = a2; + i++; + } + } + + a1[i] = EOS; +} + +void SanitizeNameString(u8 *a1) +{ + if (StringLength(a1) < 6) + ConvertInternationalString(a1, 1); + else + StripExtCtrlCodes(a1); +} |