diff --git a/asm/easy_chat.s b/asm/easy_chat.s index eb20e68fa..602e7b3e7 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -3691,7 +3691,7 @@ sub_811BDF0: @ 811BDF0 adds r6, r0, 0 ldr r0, =gSaveBlock1Ptr ldr r4, [r0] - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r0, =0x00003b70 adds r5, r4, r0 adds r0, r5, 0 @@ -3707,17 +3707,17 @@ sub_811BDF0: @ 811BDF0 bl TVShowConvertInternationalString movs r0, 0 mov r1, sp - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI b _0811BE3C .pool _0811BE34: ldr r1, =gText_Lady movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI _0811BE3C: ldr r1, =gText_F700sQuiz adds r0, r6, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders add sp, 0x20 pop {r4-r6} pop {r0} diff --git a/asm/link.s b/asm/link.s index d2dc05630..acf24716e 100644 --- a/asm/link.s +++ b/asm/link.s @@ -28007,14 +28007,14 @@ _08017F8A: lsls r0, r4, 24 lsrs r0, 24 adds r1, r5, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI adds r5, 0x10 adds r4, 0x1 cmp r4, 0x3 ble _08017F8A ldr r1, =gUnknown_082EE47C adds r0, r7, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders b _08017FB4 .pool _08017FAC: @@ -28379,7 +28379,7 @@ sub_8018220: @ 8018220 ldr r0, =gUnknown_02039B58 adds r1, r0 mov r8, r1 - bl sub_81AFBF0 + bl UnkTextUtil_Reset mov r6, r9 adds r6, 0xC0 bl sub_8068BB0 @@ -28393,11 +28393,11 @@ sub_8018220: @ 8018220 bl StringCopy movs r0, 0 adds r1, r6, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI mov r1, r8 adds r1, 0x30 movs r0, 0x1 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r4, 0xBA lsls r4, 1 add r4, r9 @@ -28411,7 +28411,7 @@ sub_8018220: @ 8018220 bl StringCopy movs r0, 0x2 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI mov r5, r9 adds r5, 0xDE mov r0, r8 @@ -28422,7 +28422,7 @@ sub_8018220: @ 8018220 bl ConvertIntToDecimalStringN movs r0, 0x3 adds r1, r5, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r2, 0xED add r2, r9 mov r10, r2 @@ -28442,16 +28442,16 @@ sub_8018220: @ 8018220 bl ConvertIntToDecimalStringN movs r0, 0x4 mov r1, r10 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r0, 0x5 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r4, 0xD2 lsls r4, 1 add r4, r9 ldr r1, =gUnknown_082EFF64 adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldr r0, =gStringVar4 adds r1, r4, 0 bl StringCopy @@ -28468,7 +28468,7 @@ _0801830C: bl ConvertIntToDecimalStringN movs r0, 0 adds r1, r6, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI mov r2, r8 ldrh r1, [r2, 0x16] cmp r1, r4 @@ -28483,7 +28483,7 @@ _08018328: bl ConvertIntToDecimalStringN movs r0, 0x2 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI mov r0, r8 ldrh r1, [r0, 0x20] adds r0, r5, 0 @@ -28492,7 +28492,7 @@ _08018328: bl ConvertIntToDecimalStringN movs r0, 0x3 adds r1, r5, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r7, 0 movs r6, 0x80 lsls r6, 19 @@ -28505,7 +28505,7 @@ _08018360: bl CopyEasyChatWord lsrs r0, r6, 24 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r2, 0x80 lsls r2, 17 adds r6, r2 @@ -28519,7 +28519,7 @@ _08018360: add r4, r9 ldr r1, =gUnknown_082EFFA4 adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldr r5, =gStringVar4 adds r0, r5, 0 adds r1, r4, 0 @@ -28529,7 +28529,7 @@ _08018360: bne _080183D0 ldr r1, =gUnknown_082F0020 adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders adds r0, r5, 0 adds r1, r4, 0 bl StringAppend @@ -28546,7 +28546,7 @@ _080183D0: adds r1, r0 ldr r1, [r1] adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders adds r0, r5, 0 adds r1, r4, 0 bl StringAppend @@ -32659,7 +32659,7 @@ sub_801A43C: @ 801A43C bl LoadPalette movs r0, 0xF0 bl sub_81978B0 - bl sub_81AFBF0 + bl UnkTextUtil_Reset movs r0, 0x20 str r0, [sp] str r0, [sp, 0x4] @@ -41936,10 +41936,10 @@ _0801F020: ldrb r1, [r4, 0x8] cmp r0, r1 beq _0801F0A8 - bl sub_81AFBF0 + bl UnkTextUtil_Reset movs r0, 0 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r1, =gText_F700JoinedChat b _0801F094 .pool @@ -41976,14 +41976,14 @@ _0801F07A: ldrb r5, [r5] cmp r0, r5 beq _0801F0A8 - bl sub_81AFBF0 + bl UnkTextUtil_Reset movs r0, 0 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r1, =gText_F700LeftChat _0801F094: adds r0, r6, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x1 b _0801F0AA .pool @@ -43456,11 +43456,11 @@ sub_801FBF8: @ 801FBF8 beq _0801FC38 b _0801FC42 _0801FC08: - bl sub_81AFBF0 + bl UnkTextUtil_Reset bl sub_801F1D0 adds r1, r0, 0 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r0, 0x5 movs r1, 0 bl sub_801FF18 @@ -43617,11 +43617,11 @@ sub_801FD30: @ 801FD30 beq _0801FD74 b _0801FD7E _0801FD40: - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r0, =gSaveBlock2Ptr ldr r1, [r0] movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r0, 0x9 movs r1, 0 bl sub_801FF18 @@ -43925,7 +43925,7 @@ _0801FF98: adds r0, r1, 0 adds r0, 0x22 ldr r1, [r4] - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldr r0, [r5] adds r6, r0, 0 adds r6, 0x22 @@ -47204,7 +47204,7 @@ _08021A92: lsls r4, 2 str r4, [sp, 0x24] _08021A98: - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r0, [sp, 0x10] cmp r0, 0x1 beq _08021B48 @@ -47463,10 +47463,10 @@ _08021CC8: ldr r0, [sp, 0xC] adds r1, r0, r1 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r0, =gStringVar4 adds r1, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldr r1, [sp, 0xC] movs r2, 0xDD lsls r2, 1 @@ -63514,7 +63514,7 @@ _08029DA0: movs r1, 0x1 adds r2, r5, 0 bl PrintTextOnWindow - bl sub_81AFBF0 + bl UnkTextUtil_Reset bl sub_802762C lsls r0, 16 lsrs r0, 16 @@ -63523,11 +63523,11 @@ _08029DA0: bl CopyItemName movs r0, 0 adds r1, r5, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r7, =gStringVar4 ldr r1, =gText_FirstPlacePrize adds r0, r7, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldr r0, [r4] add r0, r10 ldrb r0, [r0] @@ -63548,7 +63548,7 @@ _08029DA0: beq _08029EC8 cmp r4, 0x3 beq _08029EC8 - bl sub_81AFBF0 + bl UnkTextUtil_Reset bl sub_802762C lsls r0, 16 lsrs r0, 16 @@ -63556,12 +63556,12 @@ _08029DA0: bl CopyItemName movs r0, 0 adds r1, r5, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI cmp r4, 0x2 bne _08029E9C ldr r1, =gText_CantHoldAnyMore adds r0, r7, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders b _08029EA8 .pool _08029E9C: @@ -63569,7 +63569,7 @@ _08029E9C: bne _08029EA8 ldr r1, =gText_FilledStorageSpace adds r0, r7, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders _08029EA8: ldr r0, =gUnknown_02022CF8 ldr r0, [r0] @@ -70729,19 +70729,19 @@ sub_802D7E8: @ 802D7E8 movs r2, 0 movs r3, 0x1 bl ConvertIntToDecimalStringN - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r1, [r5] adds r1, 0x26 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r1, [r5] adds r1, 0x66 movs r0, 0x1 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r0, [r5] adds r0, 0xA6 ldr r1, =gText_AwesomeWonF701F700 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x4 movs r1, 0x8 movs r2, 0x16 @@ -70786,15 +70786,15 @@ sub_802D884: @ 802D884 ldr r1, [r4] adds r1, 0x26 bl CopyItemName - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r1, [r4] adds r1, 0x26 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r0, [r4] adds r0, 0xA6 ldr r1, =gText_FilledStorageSpace2 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x4 movs r1, 0x8 movs r2, 0x16 @@ -70839,15 +70839,15 @@ sub_802D8FC: @ 802D8FC ldr r1, [r4] adds r1, 0x26 bl CopyItemName - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r1, [r4] adds r1, 0x26 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r0, [r4] adds r0, 0xA6 ldr r1, =gText_CantHoldMore - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x4 movs r1, 0x9 movs r2, 0x16 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 94245f93b..c30cd7c28 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -6737,7 +6737,7 @@ sub_80CAC58: @ 80CAC58 sub sp, 0xC lsls r0, 24 lsrs r6, r0, 24 - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r1, =gUnknown_0857276C lsls r0, r6, 3 adds r0, r1 @@ -6774,7 +6774,7 @@ _080CACB8: adds r1, r2 _080CACC0: movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI b _080CAD30 .pool _080CACD0: @@ -6817,7 +6817,7 @@ _080CAD16: ldr r0, =0x000021eb adds r1, r0 movs r0, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI _080CAD30: ldr r5, =gUnknown_02039D08 ldr r0, [r5] @@ -6827,7 +6827,7 @@ _080CAD30: lsls r1, r6, 3 adds r1, r2 ldr r1, [r1] - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x1 movs r1, 0x11 bl FillWindowPixelBuffer diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index d30c6b4ee..9aed72097 100755 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -212,17 +212,17 @@ _081C3FEC: movs r2, 0x1 movs r3, 0x2 bl ConvertIntToDecimalStringN - bl sub_81AFBF0 + bl UnkTextUtil_Reset movs r0, 0 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r0, 0x1 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r4, =gStringVar4 ldr r1, =gUnknown_0861CE97 adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders movs r0, 0x1 adds r1, r4, 0 movs r2, 0x2C diff --git a/asm/pokenav.s b/asm/pokenav.s index 6da267d78..0f4ab7fec 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -16941,17 +16941,17 @@ sub_81CF7F4: @ 81CF7F4 mov r8, r0 bl sub_81CF0F0 adds r7, r0, 0 - bl sub_81AFBF0 + bl UnkTextUtil_Reset ldr r4, =gStringVar1 movs r0, 0 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI movs r0, 0xFF strb r0, [r4] ldr r5, =gStringVar2 ldr r1, =gText_NumberF700 adds r0, r5, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders mov r1, r8 ldrb r0, [r1, 0x8] movs r1, 0x1 @@ -19854,14 +19854,14 @@ sub_81D0E84: @ 81D0E84 movs r2, 0 movs r3, 0x2 bl ConvertIntToDecimalStringN - bl sub_81AFBF0 + bl UnkTextUtil_Reset movs r0, 0 adds r1, r4, 0 - bl sub_81AFC0C + bl UnkTextUtil_SetPtrI ldr r4, =gStringVar4 ldr r1, =gText_RibbonsF700 adds r0, r4, 0 - bl sub_81AFC28 + bl UnkTextUtil_StringExpandPlaceholders ldrb r0, [r5, 0xA] movs r1, 0x44 bl FillWindowPixelBuffer diff --git a/asm/unk_text_util.s b/asm/unk_text_util.s deleted file mode 100755 index f8dabb5b7..000000000 --- a/asm/unk_text_util.s +++ /dev/null @@ -1,99 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81AFBF0 -sub_81AFBF0: @ 81AFBF0 - push {lr} - ldr r1, =gUnknown_0203CE9C - movs r2, 0 - adds r0, r1, 0 - adds r0, 0x1C -_081AFBFA: - str r2, [r0] - subs r0, 0x4 - cmp r0, r1 - bge _081AFBFA - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AFBF0 - - thumb_func_start sub_81AFC0C -sub_81AFC0C: @ 81AFC0C - push {lr} - adds r2, r1, 0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x7 - bhi _081AFC20 - ldr r1, =gUnknown_0203CE9C - lsls r0, 2 - adds r0, r1 - str r2, [r0] -_081AFC20: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AFC0C - - thumb_func_start sub_81AFC28 -sub_81AFC28: @ 81AFC28 - push {r4,r5,lr} - adds r2, r0, 0 - adds r4, r1, 0 - ldrb r1, [r4] - adds r0, r1, 0 - cmp r0, 0xFF - beq _081AFC68 - ldr r5, =gUnknown_0203CE9C -_081AFC38: - cmp r1, 0xF7 - beq _081AFC48 - strb r1, [r2] - adds r4, 0x1 - adds r2, 0x1 - b _081AFC60 - .pool -_081AFC48: - adds r4, 0x1 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r5 - ldr r1, [r0] - cmp r1, 0 - beq _081AFC5E - adds r0, r2, 0 - bl StringCopy - adds r2, r0, 0 -_081AFC5E: - adds r4, 0x1 -_081AFC60: - ldrb r1, [r4] - adds r0, r1, 0 - cmp r0, 0xFF - bne _081AFC38 -_081AFC68: - movs r0, 0xFF - strb r0, [r2] - adds r0, r2, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81AFC28 - - thumb_func_start sub_81AFC74 -sub_81AFC74: @ 81AFC74 - lsls r0, 24 - ldr r1, =gUnknown_0203CE9C - lsrs r0, 22 - adds r0, r1 - ldr r0, [r0] - bx lr - .pool - thumb_func_end sub_81AFC74 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/unk_text_util.h b/include/unk_text_util.h new file mode 100644 index 000000000..72243a90e --- /dev/null +++ b/include/unk_text_util.h @@ -0,0 +1,9 @@ +#ifndef GUARD_UNK_TEXT_UTIL_H +#define GUARD_UNK_TEXT_UTIL_H + +void UnkTextUtil_Reset(void); +void UnkTextUtil_SetPtrI(u8 idx, const u8 *ptr); +u8 *UnkTextUtil_StringExpandPlaceholders(u8 *dest, const u8 *src); +const u8 *UnkTextUtil_GetPtrI(u8 idx); + +#endif //GUARD_UNK_TEXT_UTIL_H diff --git a/ld_script.txt b/ld_script.txt index e9c810adc..9a03db633 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -244,7 +244,7 @@ SECTIONS { asm/item_menu.o(.text); asm/list_menu.o(.text); asm/menu_indicators.o(.text); - asm/unk_text_util.o(.text); + src/unk_text_util.o(.text); src/save_location.o(.text); asm/item_icon.o(.text); asm/party_menu.o(.text); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index d09cbc407..e9cd3e215 100755 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -15,6 +15,7 @@ #include "sound.h" #include "species.h" #include "sprite.h" +#include "unk_text_util.h" #include "string_util.h" #include "task.h" #include "text.h" @@ -166,9 +167,7 @@ extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern bool8 sub_81A6BF4(); extern bool8 sub_81B9E94(); -extern void sub_81AFBF0(); -extern u8 sub_81AFC0C(u8 a, u8 *b); -extern void sub_81AFC28(u8 *a, u8 *b); +extern void UnkTextUtil_Reset(); extern void sub_8124610(u8 *a, u8 b); extern int GetPlayerIDAsU32(); extern u8 GetCurrentPpToMaxPpState(u8 a, u8 b); @@ -2993,12 +2992,12 @@ void sub_81C307C() { struct PokeSummary *sum = &gUnknown_0203CF1C->summary; u8 *text; - sub_81AFBF0(); - sub_81AFC0C(0, gUnknown_0861CE74); - sub_81AFC0C(1, gUnknown_0861CE7B); + UnkTextUtil_Reset(); + UnkTextUtil_SetPtrI(0, gUnknown_0861CE74); + UnkTextUtil_SetPtrI(1, gUnknown_0861CE7B); sub_81C31C0(); if (sub_81A6BF4() == TRUE || sub_81B9E94() == TRUE || sub_81C3304() == TRUE) - sub_81AFC28(gStringVar4, gText_XNature); + UnkTextUtil_StringExpandPlaceholders(gStringVar4, gText_XNature); else { u8 *alloced1 = Alloc(32); @@ -3007,7 +3006,7 @@ void sub_81C307C() if (sum->metLocation <= 0xD4) { sub_8124610(alloced2, sum->metLocation); - sub_81AFC0C(4, alloced2); + UnkTextUtil_SetPtrI(4, alloced2); } if (sub_81C3220() == 1) { @@ -3022,7 +3021,7 @@ void sub_81C307C() text = (sum->metLocation > 0xD4) ? gText_XNatureObtainedInTrade : gText_XNatureProbablyMetAt; else text = gText_XNatureObtainedInTrade; - sub_81AFC28(gStringVar4, text); + UnkTextUtil_StringExpandPlaceholders(gStringVar4, text); Free(alloced1); Free(alloced2); } @@ -3036,8 +3035,8 @@ void sub_81C3194() void sub_81C31C0() { struct UnkSummaryStruct *sumStruct = gUnknown_0203CF1C; - sub_81AFC0C(2, gNatureNamePointers[sumStruct->summary.nature]); - sub_81AFC0C(5, gText_EmptyString5); + UnkTextUtil_SetPtrI(2, gNatureNamePointers[sumStruct->summary.nature]); + UnkTextUtil_SetPtrI(5, gText_EmptyString5); } void sub_81C31F0(u8 *a) @@ -3046,7 +3045,7 @@ void sub_81C31F0(u8 *a) if (level == 0) level = 5; ConvertIntToDecimalStringN(a, level, 0, 3); - sub_81AFC0C(3, a); + UnkTextUtil_SetPtrI(3, a); } u8 sub_81C3220() @@ -3301,12 +3300,12 @@ void sub_81C3710() ConvertIntToDecimalStringN(alloced2, gUnknown_0203CF1C->summary.maxHP, 1, 3); ConvertIntToDecimalStringN(alloced3, gUnknown_0203CF1C->summary.atk, 1, 7); ConvertIntToDecimalStringN(alloced4, gUnknown_0203CF1C->summary.def, 1, 7); - sub_81AFBF0(); - sub_81AFC0C(0, alloced1); - sub_81AFC0C(1, alloced2); - sub_81AFC0C(2, alloced3); - sub_81AFC0C(3, alloced4); - sub_81AFC28(gStringVar4, gUnknown_0861CE82); + UnkTextUtil_Reset(); + UnkTextUtil_SetPtrI(0, alloced1); + UnkTextUtil_SetPtrI(1, alloced2); + UnkTextUtil_SetPtrI(2, alloced3); + UnkTextUtil_SetPtrI(3, alloced4); + UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE82); Free(alloced1); Free(alloced2); Free(alloced3); @@ -3323,11 +3322,11 @@ void sub_81C3808() ConvertIntToDecimalStringN(gStringVar1, gUnknown_0203CF1C->summary.spatk, 1, 3); ConvertIntToDecimalStringN(gStringVar2, gUnknown_0203CF1C->summary.spdef, 1, 3); ConvertIntToDecimalStringN(gStringVar3, gUnknown_0203CF1C->summary.speed, 1, 3); - sub_81AFBF0(); - sub_81AFC0C(0, gStringVar1); - sub_81AFC0C(1, gStringVar2); - sub_81AFC0C(2, gStringVar3); - sub_81AFC28(gStringVar4, gUnknown_0861CE8E); + UnkTextUtil_Reset(); + UnkTextUtil_SetPtrI(0, gStringVar1); + UnkTextUtil_SetPtrI(1, gStringVar2); + UnkTextUtil_SetPtrI(2, gStringVar3); + UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE8E); } void sub_81C3890() @@ -3436,10 +3435,10 @@ void sub_81C3B08(u8 a) sub_81C25A4(r8, gMoveNames[move], 0, (a<<4) + 1, 0, 1); ConvertIntToDecimalStringN(gStringVar1, r10->summary.pp[a], 1, 2); ConvertIntToDecimalStringN(gStringVar2, r6, 1, 2); - sub_81AFBF0(); - sub_81AFC0C(0, gStringVar1); - sub_81AFC0C(1, gStringVar2); - sub_81AFC28(gStringVar4, gUnknown_0861CE97); + UnkTextUtil_Reset(); + UnkTextUtil_SetPtrI(0, gStringVar1); + UnkTextUtil_SetPtrI(1, gStringVar2); + UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE97); text = gStringVar4; r5 = GetCurrentPpToMaxPpState(r10->summary.pp[a], r6) + 9; offset = GetStringRightAlignXOffset(1, text, 0x2C); @@ -3531,17 +3530,17 @@ void sub_81C3B08(u8 a) movs r2, 0x1\n\ movs r3, 0x2\n\ bl ConvertIntToDecimalStringN\n\ - bl sub_81AFBF0\n\ + bl UnkTextUtil_Reset\n\ movs r0, 0\n\ mov r1, r8\n\ - bl sub_81AFC0C\n\ + bl UnkTextUtil_SetPtrI\n\ movs r0, 0x1\n\ adds r1, r4, 0\n\ - bl sub_81AFC0C\n\ + bl UnkTextUtil_SetPtrI\n\ ldr r4, =gStringVar4\n\ ldr r1, =gUnknown_0861CE97\n\ adds r0, r4, 0\n\ - bl sub_81AFC28\n\ + bl UnkTextUtil_StringExpandPlaceholders\n\ adds r7, r4, 0\n\ ldrb r0, [r5]\n\ adds r1, r6, 0\n\ diff --git a/src/text.c b/src/text.c index 8108a6867..4ebe5a422 100644 --- a/src/text.c +++ b/src/text.c @@ -13,7 +13,7 @@ extern void CopyWindowToVram(u8 windowId, u8 mode); extern u16 Font6Func(struct TextPrinter *textPrinter); extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); extern void PlaySE(u16 songNum); -extern u8* sub_81AFC74(u8 a1); +extern u8* UnkTextUtil_GetPtrI(u8 a1); EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0}; @@ -2932,7 +2932,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) } case 0xF7: if (bufferPointer == NULL) - bufferPointer = sub_81AFC74(*++str); + bufferPointer = UnkTextUtil_GetPtrI(*++str); while (*bufferPointer != 0xFF) { glyphWidth = func(*bufferPointer++, isJapanese); diff --git a/src/unk_text_util.c b/src/unk_text_util.c new file mode 100644 index 000000000..825b333bb --- /dev/null +++ b/src/unk_text_util.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "text.h" +#include "unk_text_util.h" +#include "string_util.h" + +static EWRAM_DATA const u8 *sStringPointers[8] = {}; + +void UnkTextUtil_Reset(void) +{ + const u8 **ptr; + u8 *fillval; + const u8 **ptr2; + + ptr = sStringPointers; + fillval = NULL; + ptr2 = ptr + (ARRAY_COUNT(sStringPointers) - 1); + do + { + *ptr2-- = fillval; + } while ((int)ptr2 >= (int)ptr); +} + +void UnkTextUtil_SetPtrI(u8 idx, const u8 *ptr) +{ + if (idx < ARRAY_COUNT(sStringPointers)) + { + sStringPointers[idx] = ptr; + } +} + +u8 *UnkTextUtil_StringExpandPlaceholders(u8 *dest, const u8 *src) +{ + while (*src != EOS) + { + if (*src != 0xF7) + { + *dest++ = *src++; + } + else + { + src++; + if (sStringPointers[*src] != NULL) + { + dest = StringCopy(dest, sStringPointers[*src]); + } + src++; + } + } + *dest = EOS; + return dest; +} + +const u8 *UnkTextUtil_GetPtrI(u8 idx) +{ + return sStringPointers[idx]; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index cfe686a7c..889b89823 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1545,8 +1545,7 @@ gUnknown_0203CE84: @ 203CE84 gUnknown_0203CE8C: @ 203CE8C .space 0x10 -gUnknown_0203CE9C: @ 203CE9C - .space 0x20 + .include "src/unk_text_util.o" gUnknown_0203CEBC: @ 203CEBC .space 0x4