From 02651f6177032baad32efdddeee54a9af624812b Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Tue, 2 Apr 2019 19:18:36 -0700 Subject: [PATCH 1/3] Attempt to decompile menu_specialized. 2 NONMATCHING --- asm/menu_specialized.s | 336 ---------------------------- include/menu_specialized.h | 6 +- include/strings.h | 2 + ld_script.txt | 1 - src/menu_specialized.c | 437 ++++++++++++++++++++++++++++++++++++- 5 files changed, 441 insertions(+), 341 deletions(-) delete mode 100644 asm/menu_specialized.s diff --git a/asm/menu_specialized.s b/asm/menu_specialized.s deleted file mode 100644 index 36db0f865..000000000 --- a/asm/menu_specialized.s +++ /dev/null @@ -1,336 +0,0 @@ - - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - thumb_func_start DrawLevelUpWindowPg1 -DrawLevelUpWindowPg1: @ 81D3640 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - mov r8, r0 - adds r6, r1, 0 - adds r5, r2, 0 - adds r4, r3, 0 - ldr r3, [sp, 0x4C] - ldr r0, [sp, 0x50] - mov r9, r0 - lsls r4, 24 - lsrs r4, 24 - lsls r3, 24 - lsrs r3, 24 - mov r1, r9 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, r4, 4 - orrs r1, r4 - lsls r1, 24 - lsrs r1, 24 - str r3, [sp, 0x28] - bl FillWindowPixelBuffer - add r2, sp, 0xC - ldrh r0, [r5] - ldrh r1, [r6] - subs r0, r1 - strh r0, [r2] - ldrh r0, [r5, 0x2] - ldrh r1, [r6, 0x2] - subs r0, r1 - strh r0, [r2, 0x2] - ldrh r0, [r5, 0x4] - ldrh r1, [r6, 0x4] - subs r0, r1 - strh r0, [r2, 0x4] - ldrh r0, [r5, 0x8] - ldrh r1, [r6, 0x8] - subs r0, r1 - strh r0, [r2, 0x6] - ldrh r0, [r5, 0xA] - ldrh r1, [r6, 0xA] - subs r0, r1 - strh r0, [r2, 0x8] - ldrh r0, [r5, 0x6] - ldrh r1, [r6, 0x6] - subs r0, r1 - strh r0, [r2, 0xA] - add r0, sp, 0x24 - strb r4, [r0] - ldr r3, [sp, 0x28] - strb r3, [r0, 0x1] - mov r1, r9 - strb r1, [r0, 0x2] - movs r7, 0 - mov r10, r0 - movs r0, 0x1 - negs r0, r0 - mov r9, r0 - add r6, sp, 0x18 -_081D36CA: - lsls r0, r7, 4 - subs r0, r7 - lsls r0, 24 - lsrs r5, r0, 24 - mov r1, r10 - str r1, [sp] - mov r0, r9 - str r0, [sp, 0x4] - ldr r1, =gUnknown_08625B54 - lsls r0, r7, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [sp, 0x8] - mov r0, r8 - movs r1, 0x1 - movs r2, 0 - adds r3, r5, 0 - bl AddTextPrinterParameterized3 - lsls r0, r7, 1 - mov r4, sp - adds r4, r0 - adds r4, 0xC - movs r1, 0 - ldrsh r0, [r4, r1] - ldr r1, =gText_Dash - cmp r0, 0 - blt _081D3704 - ldr r1, =gText_UnkCtrlF904 -_081D3704: - adds r0, r6, 0 - bl StringCopy - mov r0, r10 - str r0, [sp] - mov r1, r9 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - movs r1, 0x1 - movs r2, 0x38 - adds r3, r5, 0 - bl AddTextPrinterParameterized3 - movs r0, 0 - ldrsh r1, [r4, r0] - adds r0, r1, 0 - cmp r1, 0 - bge _081D372C - negs r0, r1 -_081D372C: - movs r4, 0xC - cmp r0, 0x9 - bgt _081D3734 - movs r4, 0x12 -_081D3734: - cmp r1, 0 - bge _081D373A - negs r1, r1 -_081D373A: - adds r0, r6, 0 - movs r2, 0 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - adds r2, r4, 0 - adds r2, 0x38 - mov r1, r10 - str r1, [sp] - mov r0, r9 - str r0, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - movs r1, 0x1 - adds r3, r5, 0 - bl AddTextPrinterParameterized3 - adds r0, r7, 0x1 - lsls r0, 16 - lsrs r7, r0, 16 - cmp r7, 0x5 - bls _081D36CA - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end DrawLevelUpWindowPg1 - - thumb_func_start DrawLevelUpWindowPg2 -DrawLevelUpWindowPg2: @ 81D3784 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - mov r8, r0 - adds r5, r1, 0 - adds r4, r2, 0 - adds r6, r3, 0 - ldr r2, [sp, 0x4C] - lsls r4, 24 - lsrs r4, 24 - lsls r6, 24 - lsrs r6, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, r4, 4 - orrs r1, r4 - lsls r1, 24 - lsrs r1, 24 - str r2, [sp, 0x28] - bl FillWindowPixelBuffer - add r1, sp, 0xC - ldrh r0, [r5] - strh r0, [r1] - ldrh r0, [r5, 0x2] - strh r0, [r1, 0x2] - ldrh r0, [r5, 0x4] - strh r0, [r1, 0x4] - ldrh r0, [r5, 0x8] - strh r0, [r1, 0x6] - ldrh r0, [r5, 0xA] - strh r0, [r1, 0x8] - ldrh r0, [r5, 0x6] - strh r0, [r1, 0xA] - add r0, sp, 0x24 - strb r4, [r0] - strb r6, [r0, 0x1] - ldr r2, [sp, 0x28] - strb r2, [r0, 0x2] - movs r6, 0 - add r1, sp, 0x18 - mov r9, r1 - mov r7, r8 - mov r10, r0 - movs r2, 0x1 - negs r2, r2 - mov r8, r2 -_081D37EE: - lsls r1, r6, 1 - mov r0, sp - adds r0, r1 - adds r0, 0xC - movs r2, 0 - ldrsh r0, [r0, r2] - movs r4, 0x3 - cmp r0, 0x63 - bgt _081D3808 - movs r4, 0x1 - cmp r0, 0x9 - ble _081D3808 - movs r4, 0x2 -_081D3808: - mov r0, sp - adds r0, r1 - adds r0, 0xC - movs r2, 0 - ldrsh r1, [r0, r2] - mov r0, r9 - movs r2, 0 - adds r3, r4, 0 - bl ConvertIntToDecimalStringN - movs r0, 0x4 - subs r0, r4 - lsls r4, r0, 1 - adds r4, r0 - lsls r4, 17 - lsrs r4, 16 - lsls r5, r6, 4 - subs r5, r6 - lsls r5, 24 - lsrs r5, 24 - mov r0, r10 - str r0, [sp] - mov r1, r8 - str r1, [sp, 0x4] - ldr r1, =gUnknown_08625B54 - lsls r0, r6, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [sp, 0x8] - adds r0, r7, 0 - movs r1, 0x1 - movs r2, 0 - adds r3, r5, 0 - bl AddTextPrinterParameterized3 - adds r4, 0x38 - lsls r4, 24 - lsrs r4, 24 - mov r2, r10 - str r2, [sp] - mov r0, r8 - str r0, [sp, 0x4] - mov r1, r9 - str r1, [sp, 0x8] - adds r0, r7, 0 - movs r1, 0x1 - adds r2, r4, 0 - adds r3, r5, 0 - bl AddTextPrinterParameterized3 - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x5 - bls _081D37EE - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end DrawLevelUpWindowPg2 - - thumb_func_start GetMonLevelUpWindowStats -GetMonLevelUpWindowStats: @ 81D388C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r1, 0x3A @ MON_DATA_MAX_HP - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x3B @ MON_DATA_ATK - bl GetMonData - strh r0, [r5, 0x2] - adds r0, r4, 0 - movs r1, 0x3C @ MON_DATA_DEF - bl GetMonData - strh r0, [r5, 0x4] - adds r0, r4, 0 - movs r1, 0x3D @ MON_DATA_SPEED - bl GetMonData - strh r0, [r5, 0x6] - adds r0, r4, 0 - movs r1, 0x3E @ MON_DATA_SPATK - bl GetMonData - strh r0, [r5, 0x8] - adds r0, r4, 0 - movs r1, 0x3F @ MON_DATA_SPDEF - bl GetMonData - strh r0, [r5, 0xA] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetMonLevelUpWindowStats - - .align 2, 0 @ Don't pad with nop. diff --git a/include/menu_specialized.h b/include/menu_specialized.h index d29ac5751..fb23e7ce6 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -32,8 +32,8 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); void sub_81D1E90(struct PlayerPCItemPageStruct *page); void sub_81D1EC0(void); void sub_81D1D04(u8 a0); -void DrawLevelUpWindowPg1(u16 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); -void DrawLevelUpWindowPg2(u16 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); +void DrawLevelUpWindowPg1(u16 arg0, u16* statStoreLocation1, u16* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); +void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0); void sub_81D2108(struct UnknownStruct_81D1ED4 *arg0); void sub_81D20AC(struct UnknownStruct_81D1ED4 *arg0); @@ -47,7 +47,7 @@ bool16 MoveRelearnerRunTextPrinters(void); void MoveRelearnerCreateYesNoMenu(void); u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices); void InitMoveRelearnerWindows(bool8 useContextWindow); -void GetMonLevelUpWindowStats(struct Pokemon* mon, void* statStoreLocation); +void GetMonLevelUpWindowStats(struct Pokemon* mon, u16* statStoreLocation); s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); diff --git a/include/strings.h b/include/strings.h index 8aa296eb1..fc5724af3 100644 --- a/include/strings.h +++ b/include/strings.h @@ -471,6 +471,8 @@ extern const u8 gText_EggCantBattle[]; extern const u8 gText_PkmnAlreadySelected[]; extern const u8 gText_PkmnAlreadyInBattle[]; extern const u8 gText_PkmnCantSwitchOut[]; +extern const u8 gText_Dash[]; +extern const u8 gText_UnkCtrlF904[]; //pokedex text extern const u8 gText_CryOf[]; diff --git a/ld_script.txt b/ld_script.txt index 619abfce1..5cb7851bf 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -303,7 +303,6 @@ SECTIONS { asm/pokenav.o(.text); src/pokenav_match_call.o(.text); src/menu_specialized.o(.text); - asm/menu_specialized.o(.text); src/ereader_helpers.o(.text); src/faraway_island.o(.text); src/ereader_screen.o(.text); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index f21f4e51a..c8c46fbc1 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -28,6 +28,7 @@ #include "gba/io_reg.h" extern const struct CompressedSpriteSheet gMonFrontPicTable[]; +extern const u8 *gUnknown_08625B54[]; EWRAM_DATA static u8 sUnknown_0203CF48[3] = {0}; EWRAM_DATA static struct ListMenuItem *sUnknown_0203CF4C = NULL; @@ -259,7 +260,7 @@ static void sub_81D1D44(u8 windowId, s32 itemId, u8 y) u8 buffer[30]; u16 length; - if (itemId == LIST_CANCEL) + if (itemId == LIST_CANCEL) return; StringCopy(buffer, gSaveBlock1Ptr->mail[6 + itemId].playerName); @@ -1639,3 +1640,437 @@ static void sub_81D35E8(struct Sprite *sprite) id = gSprites[id].data[5]; } } + + +#ifdef NONMATCHING +void DrawLevelUpWindowPg1(u8 arg0, u16 *statStoreLocation1, u16 *statStoreLocation2, u8 arg3, u8 arg4, u8 arg5) +{ + s32 i; + s16 array[6]; + u8 *text; + u8 *text2; + s16 *ptr; + u8 something[14]; + s32 var; + u8 var2; + s32 var3; + + + + + + FillWindowPixelBuffer(arg0, arg3 * 16 | arg3); + + + array[0] = statStoreLocation2[0] - statStoreLocation1[0]; + array[1] = statStoreLocation2[1] - statStoreLocation1[1]; + array[2] = statStoreLocation2[2] - statStoreLocation1[2]; + array[3] = statStoreLocation2[4] - statStoreLocation1[4]; + array[4] = statStoreLocation2[5] - statStoreLocation1[5]; + array[5] = statStoreLocation2[3] - statStoreLocation1[3]; + + + for(i = 0; i < 6; i++) + { + AddTextPrinterParameterized3(arg0, 1, 0, 15 * i, &arg3, TEXT_SPEED_FF, gUnknown_08625B54[i]); + ptr = &array[i]; + text = (u8 *) gText_Dash; + + if(*ptr >= 0) + { + text = (u8 *) gText_UnkCtrlF904; + } + + StringCopy(text2, text); + AddTextPrinterParameterized3(arg0, 1, 56, 15 * i, &arg3, TEXT_SPEED_FF, text2); + var3 = *ptr; + var = var3; + + if(var3 < 0) + { + var = -var3; + } + + var2 = 12; + + if(var <= 9) + { + var2 = 18; + } + + if(var3 < 0) + { + var3 = -var3; + } + + ConvertIntToDecimalStringN(text2, var3, 0, 2); + AddTextPrinterParameterized3(arg0, 1, var2 + 56, 15 * i, &arg3, TEXT_SPEED_FF, text2); + } +} +#else +NAKED +void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocation2, u8 arg3, u8 arg4, u8 arg5) +{ + asm(".syntax unified\n\ +push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x2C\n\ + mov r8, r0\n\ + adds r6, r1, 0\n\ + adds r5, r2, 0\n\ + adds r4, r3, 0\n\ + ldr r3, [sp, 0x4C]\n\ + ldr r0, [sp, 0x50]\n\ + mov r9, r0\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + mov r1, r9\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r9, r1\n\ + mov r0, r8\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + lsls r1, r4, 4\n\ + orrs r1, r4\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + str r3, [sp, 0x28]\n\ + bl FillWindowPixelBuffer\n\ + add r2, sp, 0xC\n\ + ldrh r0, [r5]\n\ + ldrh r1, [r6]\n\ + subs r0, r1\n\ + strh r0, [r2]\n\ + ldrh r0, [r5, 0x2]\n\ + ldrh r1, [r6, 0x2]\n\ + subs r0, r1\n\ + strh r0, [r2, 0x2]\n\ + ldrh r0, [r5, 0x4]\n\ + ldrh r1, [r6, 0x4]\n\ + subs r0, r1\n\ + strh r0, [r2, 0x4]\n\ + ldrh r0, [r5, 0x8]\n\ + ldrh r1, [r6, 0x8]\n\ + subs r0, r1\n\ + strh r0, [r2, 0x6]\n\ + ldrh r0, [r5, 0xA]\n\ + ldrh r1, [r6, 0xA]\n\ + subs r0, r1\n\ + strh r0, [r2, 0x8]\n\ + ldrh r0, [r5, 0x6]\n\ + ldrh r1, [r6, 0x6]\n\ + subs r0, r1\n\ + strh r0, [r2, 0xA]\n\ + add r0, sp, 0x24\n\ + strb r4, [r0]\n\ + ldr r3, [sp, 0x28]\n\ + strb r3, [r0, 0x1]\n\ + mov r1, r9\n\ + strb r1, [r0, 0x2]\n\ + movs r7, 0\n\ + mov r10, r0\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + mov r9, r0\n\ + add r6, sp, 0x18\n\ +_081D36CA:\n\ + lsls r0, r7, 4\n\ + subs r0, r7\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + mov r1, r10\n\ + str r1, [sp]\n\ + mov r0, r9\n\ + str r0, [sp, 0x4]\n\ + ldr r1, =gUnknown_08625B54\n\ + lsls r0, r7, 2\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + str r0, [sp, 0x8]\n\ + mov r0, r8\n\ + movs r1, 0x1\n\ + movs r2, 0\n\ + adds r3, r5, 0\n\ + bl AddTextPrinterParameterized3\n\ + lsls r0, r7, 1\n\ + mov r4, sp\n\ + adds r4, r0\n\ + adds r4, 0xC\n\ + movs r1, 0\n\ + ldrsh r0, [r4, r1]\n\ + ldr r1, =gText_Dash\n\ + cmp r0, 0\n\ + blt _081D3704\n\ + ldr r1, =gText_UnkCtrlF904\n\ +_081D3704:\n\ + adds r0, r6, 0\n\ + bl StringCopy\n\ + mov r0, r10\n\ + str r0, [sp]\n\ + mov r1, r9\n\ + str r1, [sp, 0x4]\n\ + str r6, [sp, 0x8]\n\ + mov r0, r8\n\ + movs r1, 0x1\n\ + movs r2, 0x38\n\ + adds r3, r5, 0\n\ + bl AddTextPrinterParameterized3\n\ + movs r0, 0\n\ + ldrsh r1, [r4, r0]\n\ + adds r0, r1, 0\n\ + cmp r1, 0\n\ + bge _081D372C\n\ + negs r0, r1\n\ +_081D372C:\n\ + movs r4, 0xC\n\ + cmp r0, 0x9\n\ + bgt _081D3734\n\ + movs r4, 0x12\n\ +_081D3734:\n\ + cmp r1, 0\n\ + bge _081D373A\n\ + negs r1, r1\n\ +_081D373A:\n\ + adds r0, r6, 0\n\ + movs r2, 0\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + adds r2, r4, 0\n\ + adds r2, 0x38\n\ + mov r1, r10\n\ + str r1, [sp]\n\ + mov r0, r9\n\ + str r0, [sp, 0x4]\n\ + str r6, [sp, 0x8]\n\ + mov r0, r8\n\ + movs r1, 0x1\n\ + adds r3, r5, 0\n\ + bl AddTextPrinterParameterized3\n\ + adds r0, r7, 0x1\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + cmp r7, 0x5\n\ + bls _081D36CA\n\ + add sp, 0x2C\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} +#endif // NONMATCHING + +#ifdef NONMATCHING +void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) +{ + s32 i; + s32 var; + s32 var2; + u8 text; + s16 array[6]; + u8 *something; + u8 some; + FillWindowPixelBuffer(arg0, arg2 * 16 | arg2); + array[0] = statStoreLocation1[0]; + array[1] = statStoreLocation1[1]; + array[2] = statStoreLocation1[2]; + array[3] = statStoreLocation1[4]; + array[4] = statStoreLocation1[5]; + array[5] = statStoreLocation1[3]; + for(i = 0; i <= 5; i++) + { + var = array[i]; + var2 = 3; + if(var <= 99) + { + var2 = 1; + if(var > 9) + { + var2 = 2; + } + } + something = ConvertIntToDecimalStringN(&text, array[i], 0, var2); + some = (((4 - *something) * 2) + *something) * 2; + AddTextPrinterParameterized3(arg0, 1, 0, 15 * i, &arg2, TEXT_SPEED_FF, gUnknown_08625B54[i]); + AddTextPrinterParameterized3(arg0, 1, some + 56, 15 * i, &arg2, TEXT_SPEED_FF, &text); + } +} +#else +NAKED +void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x2C\n\ + mov r8, r0\n\ + adds r5, r1, 0\n\ + adds r4, r2, 0\n\ + adds r6, r3, 0\n\ + ldr r2, [sp, 0x4C]\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + lsls r6, 24\n\ + lsrs r6, 24\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + lsls r1, r4, 4\n\ + orrs r1, r4\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + str r2, [sp, 0x28]\n\ + bl FillWindowPixelBuffer\n\ + add r1, sp, 0xC\n\ + ldrh r0, [r5]\n\ + strh r0, [r1]\n\ + ldrh r0, [r5, 0x2]\n\ + strh r0, [r1, 0x2]\n\ + ldrh r0, [r5, 0x4]\n\ + strh r0, [r1, 0x4]\n\ + ldrh r0, [r5, 0x8]\n\ + strh r0, [r1, 0x6]\n\ + ldrh r0, [r5, 0xA]\n\ + strh r0, [r1, 0x8]\n\ + ldrh r0, [r5, 0x6]\n\ + strh r0, [r1, 0xA]\n\ + add r0, sp, 0x24\n\ + strb r4, [r0]\n\ + strb r6, [r0, 0x1]\n\ + ldr r2, [sp, 0x28]\n\ + strb r2, [r0, 0x2]\n\ + movs r6, 0\n\ + add r1, sp, 0x18\n\ + mov r9, r1\n\ + mov r7, r8\n\ + mov r10, r0\n\ + movs r2, 0x1\n\ + negs r2, r2\n\ + mov r8, r2\n\ +_081D37EE:\n\ + lsls r1, r6, 1\n\ + mov r0, sp\n\ + adds r0, r1\n\ + adds r0, 0xC\n\ + movs r2, 0\n\ + ldrsh r0, [r0, r2]\n\ + movs r4, 0x3\n\ + cmp r0, 0x63\n\ + bgt _081D3808\n\ + movs r4, 0x1\n\ + cmp r0, 0x9\n\ + ble _081D3808\n\ + movs r4, 0x2\n\ +_081D3808:\n\ + mov r0, sp\n\ + adds r0, r1\n\ + adds r0, 0xC\n\ + movs r2, 0\n\ + ldrsh r1, [r0, r2]\n\ + mov r0, r9\n\ + movs r2, 0\n\ + adds r3, r4, 0\n\ + bl ConvertIntToDecimalStringN\n\ + movs r0, 0x4\n\ + subs r0, r4\n\ + lsls r4, r0, 1\n\ + adds r4, r0\n\ + lsls r4, 17\n\ + lsrs r4, 16\n\ + lsls r5, r6, 4\n\ + subs r5, r6\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + mov r0, r10\n\ + str r0, [sp]\n\ + mov r1, r8\n\ + str r1, [sp, 0x4]\n\ + ldr r1, =gUnknown_08625B54\n\ + lsls r0, r6, 2\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + str r0, [sp, 0x8]\n\ + adds r0, r7, 0\n\ + movs r1, 0x1\n\ + movs r2, 0\n\ + adds r3, r5, 0\n\ + bl AddTextPrinterParameterized3\n\ + adds r4, 0x38\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + mov r2, r10\n\ + str r2, [sp]\n\ + mov r0, r8\n\ + str r0, [sp, 0x4]\n\ + mov r1, r9\n\ + str r1, [sp, 0x8]\n\ + adds r0, r7, 0\n\ + movs r1, 0x1\n\ + adds r2, r4, 0\n\ + adds r3, r5, 0\n\ + bl AddTextPrinterParameterized3\n\ + adds r0, r6, 0x1\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + cmp r6, 0x5\n\ + bls _081D37EE\n\ + add sp, 0x2C\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} +#endif // NONMATCHING + +void GetMonLevelUpWindowStats(struct Pokemon* mon, u16* statStoreLocation) +{ + statStoreLocation[0] = GetMonData(mon, MON_DATA_MAX_HP); + statStoreLocation[1] = GetMonData(mon, MON_DATA_ATK); + statStoreLocation[2] = GetMonData(mon, MON_DATA_DEF); + statStoreLocation[3] = GetMonData(mon, MON_DATA_SPEED); + statStoreLocation[4] = GetMonData(mon, MON_DATA_SPATK); + statStoreLocation[5] = GetMonData(mon, MON_DATA_SPDEF); +} + + + + + + + + + + + + + + + + + + + + + + From 91a94a0ca1f2df00a776c85b40d76c193977d13a Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Wed, 3 Apr 2019 21:13:26 -0700 Subject: [PATCH 2/3] Try to get closer to matching. --- include/menu_specialized.h | 6 +- src/battle_script_commands.c | 8 +- src/menu_specialized.c | 160 ++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 74 deletions(-) diff --git a/include/menu_specialized.h b/include/menu_specialized.h index fb23e7ce6..405d78830 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -32,8 +32,8 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); void sub_81D1E90(struct PlayerPCItemPageStruct *page); void sub_81D1EC0(void); void sub_81D1D04(u8 a0); -void DrawLevelUpWindowPg1(u16 arg0, u16* statStoreLocation1, u16* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); -void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); +void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); +void DrawLevelUpWindowPg2(u16 arg0, u16 *statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0); void sub_81D2108(struct UnknownStruct_81D1ED4 *arg0); void sub_81D20AC(struct UnknownStruct_81D1ED4 *arg0); @@ -47,7 +47,7 @@ bool16 MoveRelearnerRunTextPrinters(void); void MoveRelearnerCreateYesNoMenu(void); u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices); void InitMoveRelearnerWindows(bool8 useContextWindow); -void GetMonLevelUpWindowStats(struct Pokemon* mon, u16* statStoreLocation); +void GetMonLevelUpWindowStats(struct Pokemon *mon, u16 *statStoreLocation); s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0a0c34ad2..d1d8d87ac 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6295,16 +6295,16 @@ static void sub_804F100(void) { struct StatsArray currentStats; - GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], ¤tStats); - DrawLevelUpWindowPg1(0xD, gBattleResources->statsBeforeLvlUp, ¤tStats, 0xE, 0xD, 0xF); + GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], (u16*) ¤tStats); + DrawLevelUpWindowPg1(0xD, (u16*) gBattleResources->statsBeforeLvlUp,(u16*) ¤tStats, 0xE, 0xD, 0xF); } static void sub_804F144(void) { struct StatsArray currentStats; - GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], ¤tStats); - DrawLevelUpWindowPg2(0xD, ¤tStats, 0xE, 0xD, 0xF); + GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], (u16*) ¤tStats); + DrawLevelUpWindowPg2(0xD, (u16*) ¤tStats, 0xE, 0xD, 0xF); } static void sub_804F17C(void) diff --git a/src/menu_specialized.c b/src/menu_specialized.c index c8c46fbc1..58ed6e982 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1643,47 +1643,51 @@ static void sub_81D35E8(struct Sprite *sprite) #ifdef NONMATCHING -void DrawLevelUpWindowPg1(u8 arg0, u16 *statStoreLocation1, u16 *statStoreLocation2, u8 arg3, u8 arg4, u8 arg5) +void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocation2, u8 arg3, u8 arg4, u8 arg5) { - s32 i; + u16 i; s16 array[6]; u8 *text; - u8 *text2; - s16 *ptr; - u8 something[14]; + u8 text2; + s16 *statVal; s32 var; - u8 var2; + u8 padding; s32 var3; + u8 color[11]; + FillWindowPixelBuffer(arg0, PIXEL_FILL(arg3)); + + array[0] = statStoreLocation2[STAT_HP] - statStoreLocation1[STAT_HP]; + array[1] = statStoreLocation2[STAT_ATK] - statStoreLocation1[STAT_ATK]; + array[2] = statStoreLocation2[STAT_DEF] - statStoreLocation1[STAT_DEF]; + array[3] = statStoreLocation2[STAT_SPATK] - statStoreLocation1[STAT_SPATK]; + array[4] = statStoreLocation2[STAT_SPDEF] - statStoreLocation1[STAT_SPDEF]; + array[5] = statStoreLocation2[STAT_SPEED] - statStoreLocation1[STAT_SPEED]; + + color[0] = arg3; + color[1] = arg4; + color[2] = arg5; - - - - FillWindowPixelBuffer(arg0, arg3 * 16 | arg3); - - - array[0] = statStoreLocation2[0] - statStoreLocation1[0]; - array[1] = statStoreLocation2[1] - statStoreLocation1[1]; - array[2] = statStoreLocation2[2] - statStoreLocation1[2]; - array[3] = statStoreLocation2[4] - statStoreLocation1[4]; - array[4] = statStoreLocation2[5] - statStoreLocation1[5]; - array[5] = statStoreLocation2[3] - statStoreLocation1[3]; - - - for(i = 0; i < 6; i++) + for(i = 0; i <= 5; i++) { - AddTextPrinterParameterized3(arg0, 1, 0, 15 * i, &arg3, TEXT_SPEED_FF, gUnknown_08625B54[i]); - ptr = &array[i]; - text = (u8 *) gText_Dash; - - if(*ptr >= 0) - { - text = (u8 *) gText_UnkCtrlF904; - } - - StringCopy(text2, text); - AddTextPrinterParameterized3(arg0, 1, 56, 15 * i, &arg3, TEXT_SPEED_FF, text2); - var3 = *ptr; + AddTextPrinterParameterized3(arg0, + 1, + 0, + 15 * i, + color, + TEXT_SPEED_FF, + gUnknown_08625B54[i]); + statVal = &array[i]; + text = array[i] >= 0 ? (u8 *) gText_UnkCtrlF904 : (u8 *) gText_Dash;//Plus sign for stat gain, dash for none maybe + StringCopy(&text2, text); + AddTextPrinterParameterized3(arg0, + 1, + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text2); + var3 = *statVal; var = var3; if(var3 < 0) @@ -1691,11 +1695,11 @@ void DrawLevelUpWindowPg1(u8 arg0, u16 *statStoreLocation1, u16 *statStoreLocati var = -var3; } - var2 = 12; + padding = 12; //amount of padding if(var <= 9) { - var2 = 18; + padding = 18; //more padding for single digit numbers } if(var3 < 0) @@ -1703,8 +1707,14 @@ void DrawLevelUpWindowPg1(u8 arg0, u16 *statStoreLocation1, u16 *statStoreLocati var3 = -var3; } - ConvertIntToDecimalStringN(text2, var3, 0, 2); - AddTextPrinterParameterized3(arg0, 1, var2 + 56, 15 * i, &arg3, TEXT_SPEED_FF, text2); + ConvertIntToDecimalStringN(&text2, var3, STR_CONV_MODE_LEFT_ALIGN, 2); + AddTextPrinterParameterized3(arg0, + 1, + padding + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text2); } } #else @@ -1872,43 +1882,59 @@ _081D373A:\n\ #endif // NONMATCHING #ifdef NONMATCHING -void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) +void DrawLevelUpWindowPg2(u16 arg0, u16 *statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) { s32 i; - s32 var; - s32 var2; + s16 *var; + s32 numDigits; u8 text; s16 array[6]; - u8 *something; - u8 some; - FillWindowPixelBuffer(arg0, arg2 * 16 | arg2); - array[0] = statStoreLocation1[0]; - array[1] = statStoreLocation1[1]; - array[2] = statStoreLocation1[2]; - array[3] = statStoreLocation1[4]; - array[4] = statStoreLocation1[5]; - array[5] = statStoreLocation1[3]; + u8 color[11]; + + FillWindowPixelBuffer(arg0, PIXEL_FILL(arg2)); + + array[0] = statStoreLocation1[STAT_HP]; + array[1] = statStoreLocation1[STAT_ATK]; + array[2] = statStoreLocation1[STAT_DEF]; + array[3] = statStoreLocation1[STAT_SPATK]; + array[4] = statStoreLocation1[STAT_SPDEF]; + array[5] = statStoreLocation1[STAT_SPEED]; + + color[0] = arg2; + color[1] = arg3; + color[2] = arg4; + for(i = 0; i <= 5; i++) { - var = array[i]; - var2 = 3; - if(var <= 99) + numDigits = 3; //3 digit stat + if(array[i] <= 99) { - var2 = 1; - if(var > 9) + numDigits = 1; //1 digit stat + if(array[i] > 9) { - var2 = 2; + numDigits = 2; //2 digit stat } } - something = ConvertIntToDecimalStringN(&text, array[i], 0, var2); - some = (((4 - *something) * 2) + *something) * 2; - AddTextPrinterParameterized3(arg0, 1, 0, 15 * i, &arg2, TEXT_SPEED_FF, gUnknown_08625B54[i]); - AddTextPrinterParameterized3(arg0, 1, some + 56, 15 * i, &arg2, TEXT_SPEED_FF, &text); + ConvertIntToDecimalStringN(&text, array[i], STR_CONV_MODE_LEFT_ALIGN, numDigits); + AddTextPrinterParameterized3(arg0, + 1, + 0, + 15 * i, + color, + TEXT_SPEED_FF, + gUnknown_08625B54[i]); + AddTextPrinterParameterized3(arg0, + 1, + 6 * (4 - numDigits) + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text); } } #else NAKED -void DrawLevelUpWindowPg2(u16 arg0, u16* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) +void DrawLevelUpWindowPg2(u16 arg0, u16 *statStoreLocation1, u8 arg2, u8 arg3, u8 arg4) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -2043,14 +2069,14 @@ _081D3808:\n\ } #endif // NONMATCHING -void GetMonLevelUpWindowStats(struct Pokemon* mon, u16* statStoreLocation) +void GetMonLevelUpWindowStats(struct Pokemon *mon, u16 *statStoreLocation) { - statStoreLocation[0] = GetMonData(mon, MON_DATA_MAX_HP); - statStoreLocation[1] = GetMonData(mon, MON_DATA_ATK); - statStoreLocation[2] = GetMonData(mon, MON_DATA_DEF); - statStoreLocation[3] = GetMonData(mon, MON_DATA_SPEED); - statStoreLocation[4] = GetMonData(mon, MON_DATA_SPATK); - statStoreLocation[5] = GetMonData(mon, MON_DATA_SPDEF); + statStoreLocation[STAT_HP] = GetMonData(mon, MON_DATA_MAX_HP); + statStoreLocation[STAT_ATK] = GetMonData(mon, MON_DATA_ATK); + statStoreLocation[STAT_DEF] = GetMonData(mon, MON_DATA_DEF); + statStoreLocation[STAT_SPEED] = GetMonData(mon, MON_DATA_SPEED); + statStoreLocation[STAT_SPATK] = GetMonData(mon, MON_DATA_SPATK); + statStoreLocation[STAT_SPDEF] = GetMonData(mon, MON_DATA_SPDEF); } From 64da3d051ecf8617c081f64a49f62c7e79354585 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Wed, 3 Apr 2019 21:15:45 -0700 Subject: [PATCH 3/3] Fix formatting. --- src/menu_specialized.c | 108 ++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 65 deletions(-) diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 58ed6e982..cbdef3d39 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1653,10 +1653,10 @@ void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocat s32 var; u8 padding; s32 var3; - u8 color[11]; + u8 color[11]; FillWindowPixelBuffer(arg0, PIXEL_FILL(arg3)); - + array[0] = statStoreLocation2[STAT_HP] - statStoreLocation1[STAT_HP]; array[1] = statStoreLocation2[STAT_ATK] - statStoreLocation1[STAT_ATK]; array[2] = statStoreLocation2[STAT_DEF] - statStoreLocation1[STAT_DEF]; @@ -1665,28 +1665,28 @@ void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocat array[5] = statStoreLocation2[STAT_SPEED] - statStoreLocation1[STAT_SPEED]; color[0] = arg3; - color[1] = arg4; - color[2] = arg5; + color[1] = arg4; + color[2] = arg5; for(i = 0; i <= 5; i++) { AddTextPrinterParameterized3(arg0, - 1, - 0, - 15 * i, - color, - TEXT_SPEED_FF, - gUnknown_08625B54[i]); + 1, + 0, + 15 * i, + color, + TEXT_SPEED_FF, + gUnknown_08625B54[i]); statVal = &array[i]; text = array[i] >= 0 ? (u8 *) gText_UnkCtrlF904 : (u8 *) gText_Dash;//Plus sign for stat gain, dash for none maybe StringCopy(&text2, text); AddTextPrinterParameterized3(arg0, - 1, - 56, - 15 * i, - color, - TEXT_SPEED_FF, - &text2); + 1, + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text2); var3 = *statVal; var = var3; @@ -1709,12 +1709,12 @@ void DrawLevelUpWindowPg1(u16 arg0, u16 *statStoreLocation1, u16 *statStoreLocat ConvertIntToDecimalStringN(&text2, var3, STR_CONV_MODE_LEFT_ALIGN, 2); AddTextPrinterParameterized3(arg0, - 1, - padding + 56, - 15 * i, - color, - TEXT_SPEED_FF, - &text2); + 1, + padding + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text2); } } #else @@ -1889,21 +1889,21 @@ void DrawLevelUpWindowPg2(u16 arg0, u16 *statStoreLocation1, u8 arg2, u8 arg3, u s32 numDigits; u8 text; s16 array[6]; - u8 color[11]; - + u8 color[11]; + FillWindowPixelBuffer(arg0, PIXEL_FILL(arg2)); - + array[0] = statStoreLocation1[STAT_HP]; array[1] = statStoreLocation1[STAT_ATK]; array[2] = statStoreLocation1[STAT_DEF]; array[3] = statStoreLocation1[STAT_SPATK]; array[4] = statStoreLocation1[STAT_SPDEF]; array[5] = statStoreLocation1[STAT_SPEED]; - - color[0] = arg2; - color[1] = arg3; - color[2] = arg4; - + + color[0] = arg2; + color[1] = arg3; + color[2] = arg4; + for(i = 0; i <= 5; i++) { numDigits = 3; //3 digit stat @@ -1917,19 +1917,19 @@ void DrawLevelUpWindowPg2(u16 arg0, u16 *statStoreLocation1, u8 arg2, u8 arg3, u } ConvertIntToDecimalStringN(&text, array[i], STR_CONV_MODE_LEFT_ALIGN, numDigits); AddTextPrinterParameterized3(arg0, - 1, - 0, - 15 * i, - color, - TEXT_SPEED_FF, - gUnknown_08625B54[i]); + 1, + 0, + 15 * i, + color, + TEXT_SPEED_FF, + gUnknown_08625B54[i]); AddTextPrinterParameterized3(arg0, - 1, - 6 * (4 - numDigits) + 56, - 15 * i, - color, - TEXT_SPEED_FF, - &text); + 1, + 6 * (4 - numDigits) + 56, + 15 * i, + color, + TEXT_SPEED_FF, + &text); } } #else @@ -2071,32 +2071,10 @@ _081D3808:\n\ void GetMonLevelUpWindowStats(struct Pokemon *mon, u16 *statStoreLocation) { - statStoreLocation[STAT_HP] = GetMonData(mon, MON_DATA_MAX_HP); + statStoreLocation[STAT_HP] = GetMonData(mon, MON_DATA_MAX_HP); statStoreLocation[STAT_ATK] = GetMonData(mon, MON_DATA_ATK); statStoreLocation[STAT_DEF] = GetMonData(mon, MON_DATA_DEF); statStoreLocation[STAT_SPEED] = GetMonData(mon, MON_DATA_SPEED); statStoreLocation[STAT_SPATK] = GetMonData(mon, MON_DATA_SPATK); statStoreLocation[STAT_SPDEF] = GetMonData(mon, MON_DATA_SPDEF); } - - - - - - - - - - - - - - - - - - - - - -