From 256bfc3caafe1f665cc3682522d9b7ed7a0730f2 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 25 Nov 2018 15:32:22 -0600 Subject: [PATCH] Decompile script_pokemon_util_80F87D8 --- asm/script_pokemon_util_80F87D8.s | 1667 ------------------------- include/contest.h | 6 + include/contest_link_80F57C4.h | 3 + include/contest_painting.h | 1 + include/international_string_util.h | 2 +- include/script_pokemon_util_80F87D8.h | 1 - ld_script.txt | 2 +- src/contest_ai.c | 2 - src/script_pokemon_util_80F87D8.c | 891 +++++++++++++ 9 files changed, 903 insertions(+), 1672 deletions(-) delete mode 100644 asm/script_pokemon_util_80F87D8.s create mode 100755 src/script_pokemon_util_80F87D8.c diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s deleted file mode 100644 index 1202473ee7..0000000000 --- a/asm/script_pokemon_util_80F87D8.s +++ /dev/null @@ -1,1667 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80F87D8 -sub_80F87D8: @ 80F87D8 - push {r4,lr} - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r1, =gContestMons - ldrb r3, [r1, 0x15] - ldr r4, =0x000013bc - adds r0, r2, r4 - strh r3, [r0] - adds r0, r1, 0 - adds r0, 0x55 - ldrb r3, [r0] - adds r4, 0x2 - adds r0, r2, r4 - strh r3, [r0] - adds r1, 0x95 - ldrb r0, [r1] - movs r1, 0x9E - lsls r1, 5 - adds r2, r1 - strh r0, [r2] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F87D8 - - thumb_func_start sub_80F8814 -sub_80F8814: @ 80F8814 - push {lr} - ldr r0, =gSpecialVar_0x8005 - ldrb r0, [r0] - adds r1, r0, 0 - cmp r0, 0x1 - beq _080F883A - cmp r0, 0x1 - bgt _080F8830 - cmp r0, 0 - beq _080F8836 - b _080F8842 - .pool -_080F8830: - cmp r1, 0x2 - beq _080F883E - b _080F8842 -_080F8836: - movs r1, 0x3 - b _080F8844 -_080F883A: - movs r1, 0x4 - b _080F8844 -_080F883E: - movs r1, 0x5 - b _080F8844 -_080F8842: - movs r1, 0x64 -_080F8844: - ldr r0, =gSpecialVar_0x8004 - strh r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8814 - - thumb_func_start sub_80F8850 -sub_80F8850: @ 80F8850 - push {lr} - bl sub_80F8264 - bl sub_80F8290 - bl sub_80F8438 - pop {r0} - bx r0 - thumb_func_end sub_80F8850 - - thumb_func_start sub_80F8864 -sub_80F8864: @ 80F8864 - push {lr} - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - cmp r0, 0x4 - bhi _080F88A4 - lsls r0, 2 - ldr r1, =_080F8880 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080F8880: - .4byte _080F8894 - .4byte _080F8898 - .4byte _080F889C - .4byte _080F88A0 - .4byte _080F88A4 -_080F8894: - movs r1, 0x8 - b _080F88A6 -_080F8898: - movs r1, 0x9 - b _080F88A6 -_080F889C: - movs r1, 0xA - b _080F88A6 -_080F88A0: - movs r1, 0xB - b _080F88A6 -_080F88A4: - movs r1, 0xC -_080F88A6: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - lsls r1, 5 - adds r0, r1 - ldr r1, =0x00002e98 - adds r0, r1 - ldrh r1, [r0] - cmp r1, 0 - bne _080F88CC - ldr r0, =gSpecialVar_0x8004 - strh r1, [r0] - b _080F88D2 - .pool -_080F88CC: - ldr r1, =gSpecialVar_0x8004 - movs r0, 0x1 - strh r0, [r1] -_080F88D2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8864 - - thumb_func_start sub_80F88DC -sub_80F88DC: @ 80F88DC - push {lr} - movs r0, 0xFF - bl sub_80DEDA8 - pop {r0} - bx r0 - thumb_func_end sub_80F88DC - - thumb_func_start sub_80F88E8 -sub_80F88E8: @ 80F88E8 - push {lr} - ldr r0, =gContestFinalStandings - ldr r1, =gContestPlayerMonIndex - ldrb r2, [r1] - adds r0, r2, r0 - ldrb r0, [r0] - cmp r0, 0 - bne _080F8930 - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r0, 0x3 - bne _080F8930 - ldr r1, =gUnknown_02039F08 - lsls r0, r2, 1 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - ldr r0, =0x0000031f - cmp r1, r0 - ble _080F8930 - ldr r1, =gSpecialVar_0x8004 - movs r0, 0x1 - b _080F8934 - .pool -_080F8930: - ldr r1, =gSpecialVar_0x8004 - movs r0, 0 -_080F8934: - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F88E8 - - thumb_func_start sub_80F8940 -sub_80F8940: @ 80F8940 - push {lr} - movs r3, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002f98 - adds r1, r0, r2 - movs r2, 0x4 -_080F894E: - ldrh r0, [r1] - cmp r0, 0 - beq _080F895A - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 -_080F895A: - adds r1, 0x20 - subs r2, 0x1 - cmp r2, 0 - bge _080F894E - adds r0, r3, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80F8940 - - thumb_func_start sub_80F8970 -sub_80F8970: @ 80F8970 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - ldr r0, =gContestMonConditions - mov r12, r0 - ldr r1, =gSpecialVar_0x8006 - mov r9, r1 - ldr r2, =gContestMons + 2 - mov r10, r2 - mov r2, r12 - mov r1, sp - movs r6, 0x3 -_080F898E: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r6, 0x1 - cmp r6, 0 - bge _080F898E - movs r6, 0 -_080F899E: - movs r1, 0x3 - cmp r1, r6 - ble _080F89C8 -_080F89A4: - subs r5, r1, 0x1 - lsls r0, r5, 1 - mov r4, sp - adds r3, r4, r0 - lsls r0, r1, 1 - adds r2, r4, r0 - ldrh r4, [r3] - movs r7, 0 - ldrsh r1, [r3, r7] - movs r7, 0 - ldrsh r0, [r2, r7] - cmp r1, r0 - bge _080F89C2 - strh r4, [r2] - strh r0, [r3] -_080F89C2: - adds r1, r5, 0 - cmp r1, r6 - bgt _080F89A4 -_080F89C8: - adds r6, 0x1 - cmp r6, 0x2 - ble _080F899E - mov r2, r9 - ldrh r0, [r2] - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - movs r2, 0 - mov r8, r2 - movs r6, 0 - lsls r0, 16 - asrs r4, r0, 16 - adds r3, r0, 0 - mov r1, sp - mov r5, r9 -_080F89E8: - movs r7, 0 - ldrsh r0, [r1, r7] - cmp r0, r4 - bne _080F8A02 - lsls r0, r2, 24 - movs r2, 0x80 - lsls r2, 17 - adds r0, r2 - lsrs r2, r0, 24 - ldrh r7, [r5] - cmp r6, r7 - bne _080F8A02 - mov r8, r2 -_080F8A02: - adds r1, 0x2 - adds r6, 0x1 - cmp r6, 0x3 - ble _080F89E8 - movs r6, 0 - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - asrs r1, r3, 16 - lsls r2, 24 - mov r9, r2 - cmp r0, r1 - beq _080F8A30 - adds r2, r1, 0 - mov r1, sp -_080F8A20: - adds r1, 0x2 - adds r6, 0x1 - cmp r6, 0x3 - bgt _080F8A30 - movs r4, 0 - ldrsh r0, [r1, r4] - cmp r0, r2 - bne _080F8A20 -_080F8A30: - lsls r0, r6, 24 - lsrs r7, r0, 24 - mov r2, r8 - movs r6, 0 - asrs r1, r3, 16 - mov r5, r12 - movs r4, 0 - ldrsh r0, [r5, r4] - b _080F8A66 - .pool -_080F8A50: - subs r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 -_080F8A56: - adds r6, 0x1 - cmp r6, 0x3 - bgt _080F8A6E - lsls r0, r6, 1 - add r0, r12 - asrs r1, r3, 16 - movs r5, 0 - ldrsh r0, [r0, r5] -_080F8A66: - cmp r1, r0 - bne _080F8A56 - cmp r2, 0x1 - bne _080F8A50 -_080F8A6E: - lsls r4, r6, 6 - mov r0, r10 - adds r1, r4, r0 - ldr r0, =gStringVar1 - bl StringCopy - ldr r5, =gStringVar2 - mov r0, r10 - adds r0, 0xB - adds r4, r0 - adds r0, r5, 0 - adds r1, r4, 0 - bl StringCopy - adds r0, r5, 0 - bl sub_81DB5AC - mov r1, r9 - asrs r0, r1, 24 - cmp r0, 0x1 - beq _080F8A9C - cmp r8, r0 - bne _080F8AB0 -_080F8A9C: - ldr r0, =gSpecialVar_0x8006 - strh r7, [r0] - b _080F8AB6 - .pool -_080F8AB0: - ldr r1, =gSpecialVar_0x8006 - adds r0, r7, 0x4 - strh r0, [r1] -_080F8AB6: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8970 - - thumb_func_start sub_80F8ACC -sub_80F8ACC: @ 80F8ACC - push {lr} - ldr r0, =CB2_ReturnToFieldContinueScriptPlayMapMusic - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8ACC - - thumb_func_start ShowContestWinner -ShowContestWinner: @ 80F8ADC - push {lr} - ldr r0, =sub_812FDEC - bl SetMainCallback2 - ldr r1, =gMain - ldr r0, =sub_80F8ACC - str r0, [r1, 0x8] - pop {r0} - bx r0 - .pool - thumb_func_end ShowContestWinner - - thumb_func_start sub_80F8AFC -sub_80F8AFC: @ 80F8AFC - push {r4,r5,lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080F8B7C - movs r3, 0 - ldr r0, =gUnknown_02039F30 - adds r4, r0, 0 - ldr r5, =gContestMons - ldrb r0, [r4] - cmp r3, r0 - bge _080F8B50 - adds r2, r5, 0 - ldr r1, =gLinkPlayers -_080F8B1C: - ldrb r0, [r1] - subs r0, 0x1 - cmp r0, 0x1 - bhi _080F8B44 - ldrb r0, [r1, 0x13] - cmp r0, 0 - bne _080F8B40 - movs r0, 0xEB - b _080F8B42 - .pool -_080F8B40: - movs r0, 0xEC -_080F8B42: - strb r0, [r2, 0x15] -_080F8B44: - adds r2, 0x40 - adds r1, 0x1C - adds r3, 0x1 - ldrb r0, [r4] - cmp r3, r0 - blt _080F8B1C -_080F8B50: - ldr r0, =0x00004010 - ldrb r1, [r5, 0x15] - bl VarSet - ldr r0, =0x00004011 - adds r1, r5, 0 - adds r1, 0x55 - ldrb r1, [r1] - bl VarSet - ldr r0, =0x00004012 - adds r1, r5, 0 - adds r1, 0x95 - ldrb r1, [r1] - bl VarSet - ldr r0, =0x00004013 - adds r1, r5, 0 - adds r1, 0xD5 - ldrb r1, [r1] - bl VarSet -_080F8B7C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8AFC - - thumb_func_start sub_80F8B94 -sub_80F8B94: @ 80F8B94 - push {r4-r7,lr} - ldr r1, =gReservedSpritePaletteCount - movs r0, 0xC - strb r0, [r1] - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080F8C6E - movs r5, 0 - ldr r0, =gUnknown_02039F30 - ldrb r0, [r0] - cmp r5, r0 - bge _080F8C6E - movs r7, 0 - movs r6, 0x60 - movs r4, 0xB0 - lsls r4, 17 -_080F8BBA: - ldr r0, =gUnknown_0858D8EC - adds r0, r5, r0 - ldrb r0, [r0] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gEventObjects - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0x4] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - ldrb r2, [r1, 0x5] - movs r0, 0xF - ands r0, r2 - orrs r0, r6 - strb r0, [r1, 0x5] - ldr r0, =gLinkPlayers - adds r1, r7, r0 - ldrb r0, [r1] - subs r0, 0x1 - cmp r0, 0x1 - bhi _080F8C38 - ldrb r0, [r1, 0x13] - cmp r0, 0 - bne _080F8C2C - lsrs r1, r4, 16 - ldr r0, =gEventObjectPalette33 - b _080F8C42 - .pool -_080F8C2C: - lsrs r1, r4, 16 - ldr r0, =gEventObjectPalette34 - b _080F8C42 - .pool -_080F8C38: - ldrb r0, [r1, 0x13] - cmp r0, 0 - bne _080F8C50 - lsrs r1, r4, 16 - ldr r0, =gEventObjectPalette8 -_080F8C42: - movs r2, 0x20 - bl LoadPalette - b _080F8C5A - .pool -_080F8C50: - lsrs r1, r4, 16 - ldr r0, =gEventObjectPalette17 - movs r2, 0x20 - bl LoadPalette -_080F8C5A: - movs r0, 0x80 - lsls r0, 13 - adds r4, r0 - adds r7, 0x1C - adds r6, 0x10 - adds r5, 0x1 - ldr r0, =gUnknown_02039F30 - ldrb r0, [r0] - cmp r5, r0 - blt _080F8BBA -_080F8C6E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8B94 - - thumb_func_start sub_80F8C7C -sub_80F8C7C: @ 80F8C7C - push {r4-r6,lr} - sub sp, 0x4 - ldr r6, =gUnknown_02039F24 - ldrb r0, [r6] - movs r5, 0x64 - muls r0, r5 - ldr r4, =gPlayerParty - adds r0, r4 - movs r1, 0x46 - bl GetMonData - lsls r0, 24 - lsrs r0, 24 - mov r1, sp - strb r0, [r1] - cmp r0, 0 - bne _080F8D18 - ldr r0, =gContestFinalStandings - ldr r1, =gContestPlayerMonIndex - ldrb r2, [r1] - adds r0, r2, r0 - ldrb r0, [r0] - cmp r0, 0 - bne _080F8D18 - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r0, 0x3 - bne _080F8D18 - ldr r1, =gUnknown_02039F08 - lsls r0, r2, 1 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - ldr r0, =0x0000031f - cmp r1, r0 - ble _080F8D18 - movs r1, 0x1 - mov r0, sp - strb r1, [r0] - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - movs r1, 0x46 - mov r2, sp - bl SetMonData - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bls _080F8CF6 - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - movs r1, 0x46 - bl sub_80EE4DC -_080F8CF6: - movs r0, 0x1 - b _080F8D1A - .pool -_080F8D18: - movs r0, 0 -_080F8D1A: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80F8C7C - - thumb_func_start sub_80F8D24 -sub_80F8D24: @ 80F8D24 - movs r0, 0 - bx lr - thumb_func_end sub_80F8D24 - - thumb_func_start sub_80F8D28 -sub_80F8D28: @ 80F8D28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r7, =sub_80F8EE8 - adds r0, r7, 0 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _080F8D44 - b _080F8E9C -_080F8D44: - bl AllocateMonSpritesGfx - movs r0, 0xA - mov r9, r0 - movs r1, 0x3 - mov r10, r1 - ldr r2, =gContestMons - ldr r4, =gSpecialVar_0x8006 - ldrh r1, [r4] - lsls r1, 6 - adds r0, r1, r2 - ldrh r6, [r0] - adds r0, r2, 0 - adds r0, 0x38 - adds r0, r1, r0 - ldr r5, [r0] - adds r2, 0x3C - adds r1, r2 - ldr r1, [r1] - mov r8, r1 - adds r0, r7, 0 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - movs r1, 0 - strh r1, [r0, 0x8] - strh r6, [r0, 0xA] - ldr r1, =gContestPlayerMonIndex - ldrh r0, [r4] - ldrb r1, [r1] - cmp r0, r1 - bne _080F8DC4 - lsls r0, r6, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x8] - adds r2, r6, 0 - adds r3, r5, 0 - bl HandleLoadSpecialPokePic_2 - b _080F8DD8 - .pool -_080F8DC4: - lsls r0, r6, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x8] - adds r2, r6, 0 - adds r3, r5, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys -_080F8DD8: - adds r0, r6, 0 - mov r1, r8 - adds r2, r5, 0 - bl GetMonSpritePalStructFromOtIdPersonality - adds r4, r0, 0 - bl LoadCompressedObjectPalette - adds r0, r6, 0 - movs r1, 0x1 - bl SetMultiuseSpriteTemplateToPokemon - ldr r0, =gMultiuseSpriteTemplate - ldrh r1, [r4, 0x4] - strh r1, [r0, 0x2] - mov r1, r9 - adds r1, 0x1 - lsls r1, 19 - movs r2, 0x80 - lsls r2, 14 - adds r1, r2 - asrs r1, 16 - mov r3, r10 - lsls r2, r3, 19 - movs r3, 0xA0 - lsls r3, 14 - adds r2, r3 - asrs r2, 16 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080F8E58 - movs r0, 0x4 - ands r0, r1 - lsls r4, r5, 4 - cmp r0, 0 - bne _080F8E6C - adds r0, r4, r5 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r1, r6, 0 - movs r2, 0 - movs r3, 0 - bl DoMonFrontSpriteAnimation - b _080F8E6C - .pool -_080F8E58: - lsls r4, r5, 4 - adds r0, r4, r5 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r1, r6, 0 - movs r2, 0 - movs r3, 0 - bl DoMonFrontSpriteAnimation -_080F8E6C: - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0xC] - mov r1, r9 - strh r1, [r0, 0xE] - mov r2, r10 - strh r2, [r0, 0x10] - ldr r3, =gSprites - adds r1, r4, r5 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x1C - adds r0, r1, r0 - ldr r2, =SpriteCallbackDummy - str r2, [r0] - adds r1, r3 - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x5] -_080F8E9C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8D28 - - thumb_func_start sub_80F8EB8 -sub_80F8EB8: @ 80F8EB8 - push {lr} - ldr r0, =sub_80F8EE8 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _080F8EDC - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - bl FreeMonSpritesGfx -_080F8EDC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8EB8 - - thumb_func_start sub_80F8EE8 -sub_80F8EE8: @ 80F8EE8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - movs r2, 0x8 - ldrsh r0, [r5, r2] - adds r2, r1, 0 - cmp r0, 0x4 - bhi _080F8F98 - lsls r0, 2 - ldr r1, =_080F8F14 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080F8F14: - .4byte _080F8F78 - .4byte _080F8F28 - .4byte _080F8F98 - .4byte _080F8F42 - .4byte _080F8F84 -_080F8F28: - movs r0, 0xA - movs r1, 0x3 - movs r2, 0x8 - movs r3, 0x8 - bl CreateWindowFromRect - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x12] - movs r1, 0x1 - bl SetStandardWindowBorderStyle - b _080F8F78 -_080F8F42: - movs r0, 0xC - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - ldrb r0, [r4, 0x5] - lsrs r0, 4 - bl GetSpritePaletteTagByPaletteNum - lsls r0, 16 - lsrs r0, 16 - bl FreeSpritePaletteByTag - ldrb r0, [r4, 0x1] - lsls r0, 30 - cmp r0, 0 - beq _080F8F72 - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix -_080F8F72: - adds r0, r4, 0 - bl DestroySprite -_080F8F78: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _080F8F98 - .pool -_080F8F84: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x12] - bl sub_80E2A78 - adds r0, r4, 0 - bl DestroyTask -_080F8F98: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80F8EE8 - - thumb_func_start sub_80F8FA0 -sub_80F8FA0: @ 80F8FA0 - push {r4,lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080F8FD8 - ldr r0, =gUnknown_02039F30 - ldrb r0, [r0] - cmp r0, 0x4 - bne _080F8FD8 - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _080F8FD8 - ldr r4, =gSpecialVar_Result - bl GetMultiplayerId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - b _080F8FDE - .pool -_080F8FD8: - ldr r1, =gSpecialVar_Result - movs r0, 0x4 - strh r0, [r1] -_080F8FDE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8FA0 - - thumb_func_start sub_80F8FE8 -sub_80F8FE8: @ 80F8FE8 - push {r4,lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080F9020 - ldr r2, =gContestRngValue - ldr r1, [r2] - ldr r0, =0x41c64e6d - muls r0, r1 - ldr r1, =0x00006073 - adds r0, r1 - str r0, [r2] - lsrs r0, 16 - ldr r4, =gSpecialVar_Result - b _080F902A - .pool -_080F9020: - ldr r4, =gSpecialVar_Result - bl Random - lsls r0, 16 - lsrs r0, 16 -_080F902A: - ldrh r1, [r4] - bl __umodsi3 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8FE8 - - thumb_func_start sub_80F903C -sub_80F903C: @ 80F903C - ldr r2, =gContestRngValue - ldr r1, [r2] - ldr r0, =0x41c64e6d - muls r0, r1 - ldr r1, =0x00006073 - adds r0, r1 - str r0, [r2] - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_80F903C - - thumb_func_start sub_80F905C -sub_80F905C: @ 80F905C - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _080F9074 - movs r0, 0 - b _080F907E - .pool -_080F9074: - ldr r0, =sub_80F9088 - movs r1, 0x5 - bl CreateTask - movs r0, 0x1 -_080F907E: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80F905C - - thumb_func_start sub_80F9088 -sub_80F9088: @ 80F9088 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080F90C0 - cmp r0, 0x1 - beq _080F90CE - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080F90D4 - bl EnableBothScriptContexts - adds r0, r5, 0 - bl DestroyTask - b _080F90D4 - .pool -_080F90C0: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080F90D4 - bl sub_800ADF8 -_080F90CE: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_080F90D4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80F9088 - - thumb_func_start sub_80F90DC -sub_80F90DC: @ 80F90DC - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080F90FE - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _080F90FE - bl sub_800E0E8 - movs r0, 0x8 - movs r1, 0x8 - bl CreateWirelessStatusIndicatorSprite -_080F90FE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F90DC - - thumb_func_start sub_80F910C -sub_80F910C: @ 80F910C - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080F9126 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _080F9126 - bl sub_800E084 -_080F9126: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F910C - - thumb_func_start sub_80F9134 -sub_80F9134: @ 80F9134 - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _080F914C - movs r0, 0 - b _080F914E - .pool -_080F914C: - movs r0, 0x1 -_080F914E: - pop {r1} - bx r1 - thumb_func_end sub_80F9134 - - thumb_func_start sub_80F9154 -sub_80F9154: @ 80F9154 - ldr r1, =gIsLinkContest - movs r0, 0 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_80F9154 - - thumb_func_start sub_80F9160 -sub_80F9160: @ 80F9160 - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _080F9178 - movs r0, 0 - b _080F917A - .pool -_080F9178: - movs r0, 0x1 -_080F917A: - pop {r1} - bx r1 - thumb_func_end sub_80F9160 - - thumb_func_start HealPlayerParty -HealPlayerParty: @ 80F9180 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r0, 0 - mov r8, r0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r8, r0 - bcs _080F922C - ldr r1, =gPlayerParty - mov r10, r1 - mov r6, sp -_080F919E: - movs r0, 0x64 - mov r4, r8 - muls r4, r0 - add r4, r10 - adds r0, r4, 0 - movs r1, 0x3A - bl GetMonData - lsls r1, r0, 16 - strb r0, [r6] - lsrs r1, 24 - strb r1, [r6, 0x1] - adds r0, r4, 0 - movs r1, 0x39 - mov r2, sp - bl SetMonData - adds r0, r4, 0 - movs r1, 0x15 - bl GetMonData - lsls r0, 24 - lsrs r7, r0, 24 - movs r5, 0 - movs r1, 0x1 - add r1, r8 - mov r9, r1 -_080F91D4: - adds r1, r5, 0 - adds r1, 0xD - adds r0, r4, 0 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - adds r1, r7, 0 - adds r2, r5, 0 - bl CalculatePPWithBonus - strb r0, [r6] - adds r1, r5, 0 - adds r1, 0x11 - adds r0, r4, 0 - mov r2, sp - bl SetMonData - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _080F91D4 - movs r0, 0 - strb r0, [r6] - strb r0, [r6, 0x1] - strb r0, [r6, 0x2] - strb r0, [r6, 0x3] - movs r1, 0x64 - mov r0, r8 - muls r0, r1 - add r0, r10 - movs r1, 0x37 - mov r2, sp - bl SetMonData - mov r1, r9 - lsls r0, r1, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r8, r0 - bcc _080F919E -_080F922C: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end HealPlayerParty - - thumb_func_start ScriptGiveMon -@ void ScriptGiveMon(s16 species_num, u8 level, int held_item) -ScriptGiveMon: @ 80F9244 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x78 - adds r5, r0, 0 - adds r3, r1, 0 - adds r4, r2, 0 - lsls r5, 16 - lsrs r5, 16 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 16 - lsrs r0, r4, 16 - mov r8, r0 - add r6, sp, 0x14 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r3, 0 - movs r3, 0x20 - bl CreateMon - add r0, sp, 0x10 - mov r1, r8 - strb r1, [r0] - lsrs r4, 24 - strb r4, [r0, 0x1] - adds r0, r6, 0 - movs r1, 0xC - add r2, sp, 0x10 - bl SetMonData - adds r0, r6, 0 - bl GiveMonToPlayer - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r5, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r5, r0, 16 - cmp r4, 0x1 - bgt _080F92B8 - cmp r4, 0 - blt _080F92B8 - adds r0, r5, 0 - movs r1, 0x2 - bl GetSetPokedexFlag - adds r0, r5, 0 - movs r1, 0x3 - bl GetSetPokedexFlag -_080F92B8: - adds r0, r4, 0 - add sp, 0x78 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end ScriptGiveMon - - thumb_func_start ScriptGiveEgg -ScriptGiveEgg: @ 80F92C8 - push {lr} - sub sp, 0x68 - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r0, sp - movs r2, 0x1 - bl CreateEgg - add r2, sp, 0x64 - movs r0, 0x1 - strb r0, [r2] - mov r0, sp - movs r1, 0x2D - bl SetMonData - mov r0, sp - bl GiveMonToPlayer - lsls r0, 24 - lsrs r0, 24 - add sp, 0x68 - pop {r1} - bx r1 - thumb_func_end ScriptGiveEgg - - thumb_func_start HasEnoughMonsForDoubleBattle -HasEnoughMonsForDoubleBattle: @ 80F92F8 - push {lr} - bl GetMonsStateToDoubles - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - beq _080F9314 - cmp r1, 0x1 - bgt _080F9310 - cmp r1, 0 - beq _080F9314 - b _080F9318 -_080F9310: - cmp r1, 0x2 - bne _080F9318 -_080F9314: - ldr r0, =gSpecialVar_Result - strh r1, [r0] -_080F9318: - pop {r0} - bx r0 - .pool - thumb_func_end HasEnoughMonsForDoubleBattle - - thumb_func_start sub_80F9320 -sub_80F9320: @ 80F9320 - push {r4-r7,lr} - lsls r0, 16 - lsrs r6, r0, 16 - movs r5, 0 - movs r7, 0xCE - lsls r7, 1 -_080F932C: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _080F9360 - cmp r0, r7 - beq _080F9360 - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - cmp r0, r6 - bne _080F9360 - movs r0, 0x1 - b _080F9368 - .pool -_080F9360: - adds r5, 0x1 - cmp r5, 0x5 - ble _080F932C - movs r0, 0 -_080F9368: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80F9320 - - thumb_func_start sub_80F9370 -sub_80F9370: @ 80F9370 - push {r4,lr} - movs r0, 0xAF - bl sub_80F9320 - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - cmp r4, 0x1 - bne _080F9392 - movs r0, 0xAF - bl ItemIdToBerryType - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gStringVar1 - bl GetBerryNameByBerryType -_080F9392: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80F9370 - - thumb_func_start CreateScriptedWildMon -CreateScriptedWildMon: @ 80F93A0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 24 - lsrs r5, 24 - lsls r7, r2, 16 - lsrs r6, r7, 16 - bl ZeroEnemyPartyMons - ldr r0, =gEnemyParty - mov r8, r0 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - mov r0, r8 - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0x20 - bl CreateMon - cmp r6, 0 - beq _080F93EE - add r0, sp, 0x10 - strb r6, [r0] - adds r1, r0, 0 - lsrs r0, r7, 24 - strb r0, [r1, 0x1] - mov r0, r8 - movs r1, 0xC - add r2, sp, 0x10 - bl SetMonData -_080F93EE: - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end CreateScriptedWildMon - - thumb_func_start ScriptSetMonMoveSlot -ScriptSetMonMoveSlot: @ 80F9400 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 24 - lsrs r2, 24 - cmp r3, 0x6 - bls _080F941C - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - subs r0, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 -_080F941C: - movs r0, 0x64 - muls r0, r3 - ldr r1, =gPlayerParty - adds r0, r1 - adds r1, r4, 0 - bl SetMonMoveSlot - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ScriptSetMonMoveSlot - - thumb_func_start sub_80F9438 -sub_80F9438: @ 80F9438 - push {lr} - ldr r0, =gMain - ldr r1, =sub_80F9460 - str r1, [r0, 0x8] - ldr r0, =0x000040cf - movs r1, 0x9 - bl VarSet - movs r0, 0 - bl sub_81B8518 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F9438 - - thumb_func_start sub_80F9460 -sub_80F9460: @ 80F9460 - push {lr} - ldr r0, =gUnknown_0203CEF8 - ldrb r1, [r0] - cmp r1, 0 - bne _080F9478 - ldr r0, =gSpecialVar_Result - strh r1, [r0] - b _080F947E - .pool -_080F9478: - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] -_080F947E: - ldr r0, =CB2_ReturnToFieldContinueScriptPlayMapMusic - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F9460 - - thumb_func_start sub_80F9490 -sub_80F9490: @ 80F9490 - push {lr} - ldr r1, =gMain - ldr r0, =sub_80F94B8 - str r0, [r1, 0x8] - ldr r0, =gSpecialVar_0x8004 - ldrb r0, [r0] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - bl sub_81B8518 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F9490 - - thumb_func_start sub_80F94B8 -sub_80F94B8: @ 80F94B8 - push {lr} - ldr r0, =gUnknown_0203CEF8 - ldrb r1, [r0] - cmp r1, 0 - bne _080F94D0 - ldr r0, =gSpecialVar_Result - strh r1, [r0] - b _080F94D6 - .pool -_080F94D0: - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] -_080F94D6: - ldr r0, =CB2_ReturnToFieldContinueScriptPlayMapMusic - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F94B8 - - thumb_func_start ReducePlayerPartyToThree -ReducePlayerPartyToThree: @ 80F94E8 - push {r4-r7,lr} - sub sp, 0x198 - add r0, sp, 0x190 - movs r1, 0 - str r1, [r0] - ldr r2, =0x05000064 - mov r1, sp - bl CpuSet - movs r5, 0 - movs r7, 0x64 - ldr r6, =gPlayerParty - mov r4, sp -_080F9502: - ldr r0, =gUnknown_0203CEF8 - adds r1, r5, r0 - ldrb r0, [r1] - cmp r0, 0 - beq _080F951C - subs r0, 0x1 - adds r1, r0, 0 - muls r1, r7 - adds r1, r6 - adds r0, r4, 0 - movs r2, 0x64 - bl memcpy -_080F951C: - adds r4, 0x64 - adds r5, 0x1 - cmp r5, 0x3 - ble _080F9502 - add r0, sp, 0x194 - movs r1, 0 - str r1, [r0] - ldr r4, =gPlayerParty - ldr r2, =0x05000096 - adds r1, r4, 0 - bl CpuSet - mov r5, sp - add r6, sp, 0x12C -_080F9538: - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x64 - bl memcpy - adds r5, 0x64 - adds r4, 0x64 - cmp r5, r6 - ble _080F9538 - bl CalculatePlayerPartyCount - add sp, 0x198 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end ReducePlayerPartyToThree - - .align 2, 0 @ Don't pad with nop. diff --git a/include/contest.h b/include/contest.h index 502d44b906..8790d7371e 100644 --- a/include/contest.h +++ b/include/contest.h @@ -226,6 +226,11 @@ extern u8 gUnknown_02039F24; extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; extern u8 gUnknown_02039F30; +extern u8 gContestFinalStandings[4]; +extern u8 gContestPlayerMonIndex; +extern s16 gUnknown_02039F08[4]; +extern s16 gContestMonConditions[4]; +extern u8 gIsLinkContest; struct Shared18000 { @@ -427,5 +432,6 @@ bool8 Contest_IsMonsTurnDisabled(u8 a); bool8 sub_80DE1E8(u8 a); void SetStartledString(u8 a, u8 b); s8 Contest_GetMoveExcitement(u16); +void sub_80DEDA8(u8); #endif //GUARD_CONTEST_H diff --git a/include/contest_link_80F57C4.h b/include/contest_link_80F57C4.h index 3c12e5e538..b4ccf2803c 100644 --- a/include/contest_link_80F57C4.h +++ b/include/contest_link_80F57C4.h @@ -1,7 +1,10 @@ #ifndef GUARD_CONTEST_LINK_80F57C4_H #define GUARD_CONTEST_LINK_80F57C4_H +void sub_80F8264(void); +void sub_80F8290(void); void sub_80F840C(void); +void sub_80F8438(void); void sub_80F8484(void); void sub_80F84C4(u8); void sub_80FC998(u8 taskId); diff --git a/include/contest_painting.h b/include/contest_painting.h index f8366a997b..67a845d629 100644 --- a/include/contest_painting.h +++ b/include/contest_painting.h @@ -2,5 +2,6 @@ #define GUARD_CONTESTPAINTING_H void sub_812FDA8(u32); +void sub_812FDEC(void); #endif diff --git a/include/international_string_util.h b/include/international_string_util.h index 426a2d48ca..343c5453c1 100644 --- a/include/international_string_util.h +++ b/include/international_string_util.h @@ -16,7 +16,7 @@ s32 sub_81DB3D8(const struct MenuAction *str, const u8* arg1, s32 arg2); // sub_81DB494 void PadNameString(u8 *dst, u8 padWith); void sub_81DB554(u8 *, u8); -// sub_81DB5AC +void sub_81DB5AC(u8 *); u32 sub_81DB604(const u8 *); // sub_81DB620 diff --git a/include/script_pokemon_util_80F87D8.h b/include/script_pokemon_util_80F87D8.h index 7c2a1ff661..a638387c2e 100644 --- a/include/script_pokemon_util_80F87D8.h +++ b/include/script_pokemon_util_80F87D8.h @@ -1,4 +1,3 @@ - #ifndef GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H #define GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H diff --git a/ld_script.txt b/ld_script.txt index 635f09662b..8439a84350 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -147,7 +147,7 @@ SECTIONS { src/secret_base.o(.text); src/tv.o(.text); asm/contest_link_80F57C4.o(.text); - asm/script_pokemon_util_80F87D8.o(.text); + src/script_pokemon_util_80F87D8.o(.text); src/field_poison.o(.text); src/pokemon_size_record.o(.text); asm/fldeff_80F9BCC.o(.text); diff --git a/src/contest_ai.c b/src/contest_ai.c index 3324ddf87a..1342ea1020 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -4,8 +4,6 @@ #include "contest_ai.h" #include "contest_effect.h" -extern u16 gContestMonConditions[]; - extern const u8 *gAIScriptPtr; extern const u8 *gContestAIs[]; diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c new file mode 100755 index 0000000000..2732d106aa --- /dev/null +++ b/src/script_pokemon_util_80F87D8.c @@ -0,0 +1,891 @@ +#include "global.h" +#include "battle.h" +#include "battle_gfx_sfx_util.h" +#include "berry.h" +#include "contest.h" +#include "contest_link_80F57C4.h" +#include "contest_painting.h" +#include "daycare.h" +#include "decompress.h" +#include "event_data.h" +#include "event_object_movement.h" +#include "international_string_util.h" +#include "link.h" +#include "link_rfu.h" +#include "main.h" +#include "menu.h" +#include "overworld.h" +#include "palette.h" +#include "party_menu.h" +#include "pokedex.h" +#include "pokemon.h" +#include "random.h" +#include "script.h" +#include "script_menu.h" +#include "sprite.h" +#include "string_util.h" +#include "tv.h" +#include "constants/event_objects.h" +#include "constants/items.h" +#include "constants/species.h" +#include "constants/vars.h" + +extern const u16 gEventObjectPalette8[]; +extern const u16 gEventObjectPalette17[]; +extern const u16 gEventObjectPalette33[]; +extern const u16 gEventObjectPalette34[]; +extern const u8 gUnknown_0858D8EC[]; +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; + +extern u8 gUnknown_0203CEF8[]; + +static void sub_80F8EE8(u8 taskId); +static void sub_80F9088(u8 taskId); +static void sub_80F9460(void); +static void sub_80F94B8(void); + + +void sub_80F87D8(void) +{ + gSaveBlock1Ptr->vars[VAR_OBJ_GFX_ID_0 - VARS_START] = gContestMons[0].trainerGfxId; + gSaveBlock1Ptr->vars[VAR_OBJ_GFX_ID_1 - VARS_START] = gContestMons[1].trainerGfxId; + gSaveBlock1Ptr->vars[VAR_OBJ_GFX_ID_2 - VARS_START] = gContestMons[2].trainerGfxId; +} + +void sub_80F8814(void) +{ + u16 var1; + u8 var0 = gSpecialVar_0x8005; + switch (var0) + { + case 0: + var1 = 3; + break; + case 1: + var1 = 4; + break; + case 2: + var1 = 5; + break; + default: + var1 = 100; + break; + } + + gSpecialVar_0x8004 = var1; +} + +void sub_80F8850(void) +{ + sub_80F8264(); + sub_80F8290(); + sub_80F8438(); +} + +void sub_80F8864(void) +{ + int contestWinner; + switch (gSpecialVar_ContestCategory) + { + case CONTEST_CATEGORY_COOL: + contestWinner = 8; + break; + case CONTEST_CATEGORY_BEAUTY: + contestWinner = 9; + break; + case CONTEST_CATEGORY_CUTE: + contestWinner = 10; + break; + case CONTEST_CATEGORY_SMART: + contestWinner = 11; + break; + case CONTEST_CATEGORY_TOUGH: + default: + contestWinner = 12; + break; + } + + if (!gSaveBlock1Ptr->contestWinners[contestWinner].species) + gSpecialVar_0x8004 = 0; + else + gSpecialVar_0x8004 = 1; +} + +void sub_80F88DC(void) +{ + sub_80DEDA8(0xFF); +} + +void sub_80F88E8(void) +{ + if (gContestFinalStandings[gContestPlayerMonIndex] == 0 + && gSpecialVar_ContestRank == 3 + && gUnknown_02039F08[gContestPlayerMonIndex] >= 800) + { + gSpecialVar_0x8004 = 1; + } + else + { + gSpecialVar_0x8004 = 0; + } +} + +u8 sub_80F8940(void) +{ + int i; + u8 var0 = 0; + + for (i = 0; i < 5; i++) + { + if (gSaveBlock1Ptr->contestWinners[8 + i].species) + var0++; + } + + return var0; +} + +#ifdef NONMATCHING +void sub_80F8970(void) +{ + s16 sp[4]; + int i, j; + s16 condition; + u8 var2; + u8 var1; + s8 var0; + u8 r7; + + for (i = 0; i < 4; i++) + sp[i] = gContestMonConditions[i]; + + + for (i = 0; i < 3; i++) + { + for (j = 3; j > i; j--) + { + if (sp[j - 1] < sp[j]) + { + int temp = sp[j]; + sp[j] = sp[j - 1]; + sp[j - 1] = temp; + } + } + } + + condition = sp[gSpecialVar_0x8006]; + var0 = 0; + var1 = 0; + for (i = 0; i < 4; i++) + { + if (sp[i] == condition) + { + var0++; + if (i == gSpecialVar_0x8006) + var1 = var0; + } + } + + for (i = 0; i < 4; i++) + { + if (sp[i] == condition) + break; + } + + r7 = i; + var2 = var1; + for (i = 0; i < 4; i++) + { + if (condition == gContestMonConditions[i]) + { + if (var2 == 1) + break; + var2--; + } + } + + StringCopy(gStringVar1, gContestMons[i].nickname); + StringCopy(gStringVar2, gContestMons[i].trainerName); + sub_81DB5AC(gStringVar2); + + if (var0 == 1 || var1 == var0) + gSpecialVar_0x8006 = r7; + else + gSpecialVar_0x8006 = r7 + 4; +} +#else +NAKED +void sub_80F8970(void) +{ + asm_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, 0x8\n\ + ldr r0, =gContestMonConditions\n\ + mov r12, r0\n\ + ldr r1, =gSpecialVar_0x8006\n\ + mov r9, r1\n\ + ldr r2, =gContestMons + 2\n\ + mov r10, r2\n\ + mov r2, r12\n\ + mov r1, sp\n\ + movs r6, 0x3\n\ +_080F898E:\n\ + ldrh r0, [r2]\n\ + strh r0, [r1]\n\ + adds r2, 0x2\n\ + adds r1, 0x2\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080F898E\n\ + movs r6, 0\n\ +_080F899E:\n\ + movs r1, 0x3\n\ + cmp r1, r6\n\ + ble _080F89C8\n\ +_080F89A4:\n\ + subs r5, r1, 0x1\n\ + lsls r0, r5, 1\n\ + mov r4, sp\n\ + adds r3, r4, r0\n\ + lsls r0, r1, 1\n\ + adds r2, r4, r0\n\ + ldrh r4, [r3]\n\ + movs r7, 0\n\ + ldrsh r1, [r3, r7]\n\ + movs r7, 0\n\ + ldrsh r0, [r2, r7]\n\ + cmp r1, r0\n\ + bge _080F89C2\n\ + strh r4, [r2]\n\ + strh r0, [r3]\n\ +_080F89C2:\n\ + adds r1, r5, 0\n\ + cmp r1, r6\n\ + bgt _080F89A4\n\ +_080F89C8:\n\ + adds r6, 0x1\n\ + cmp r6, 0x2\n\ + ble _080F899E\n\ + mov r2, r9\n\ + ldrh r0, [r2]\n\ + lsls r0, 1\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + movs r2, 0\n\ + mov r8, r2\n\ + movs r6, 0\n\ + lsls r0, 16\n\ + asrs r4, r0, 16\n\ + adds r3, r0, 0\n\ + mov r1, sp\n\ + mov r5, r9\n\ +_080F89E8:\n\ + movs r7, 0\n\ + ldrsh r0, [r1, r7]\n\ + cmp r0, r4\n\ + bne _080F8A02\n\ + lsls r0, r2, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r2\n\ + lsrs r2, r0, 24\n\ + ldrh r7, [r5]\n\ + cmp r6, r7\n\ + bne _080F8A02\n\ + mov r8, r2\n\ +_080F8A02:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + ble _080F89E8\n\ + movs r6, 0\n\ + mov r0, sp\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + asrs r1, r3, 16\n\ + lsls r2, 24\n\ + mov r9, r2\n\ + cmp r0, r1\n\ + beq _080F8A30\n\ + adds r2, r1, 0\n\ + mov r1, sp\n\ +_080F8A20:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080F8A30\n\ + movs r4, 0\n\ + ldrsh r0, [r1, r4]\n\ + cmp r0, r2\n\ + bne _080F8A20\n\ +_080F8A30:\n\ + lsls r0, r6, 24\n\ + lsrs r7, r0, 24\n\ + mov r2, r8\n\ + movs r6, 0\n\ + asrs r1, r3, 16\n\ + mov r5, r12\n\ + movs r4, 0\n\ + ldrsh r0, [r5, r4]\n\ + b _080F8A66\n\ + .pool\n\ +_080F8A50:\n\ + subs r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ +_080F8A56:\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080F8A6E\n\ + lsls r0, r6, 1\n\ + add r0, r12\n\ + asrs r1, r3, 16\n\ + movs r5, 0\n\ + ldrsh r0, [r0, r5]\n\ +_080F8A66:\n\ + cmp r1, r0\n\ + bne _080F8A56\n\ + cmp r2, 0x1\n\ + bne _080F8A50\n\ +_080F8A6E:\n\ + lsls r4, r6, 6\n\ + mov r0, r10\n\ + adds r1, r4, r0\n\ + ldr r0, =gStringVar1\n\ + bl StringCopy\n\ + ldr r5, =gStringVar2\n\ + mov r0, r10\n\ + adds r0, 0xB\n\ + adds r4, r0\n\ + adds r0, r5, 0\n\ + adds r1, r4, 0\n\ + bl StringCopy\n\ + adds r0, r5, 0\n\ + bl sub_81DB5AC\n\ + mov r1, r9\n\ + asrs r0, r1, 24\n\ + cmp r0, 0x1\n\ + beq _080F8A9C\n\ + cmp r8, r0\n\ + bne _080F8AB0\n\ +_080F8A9C:\n\ + ldr r0, =gSpecialVar_0x8006\n\ + strh r7, [r0]\n\ + b _080F8AB6\n\ + .pool\n\ +_080F8AB0:\n\ + ldr r1, =gSpecialVar_0x8006\n\ + adds r0, r7, 0x4\n\ + strh r0, [r1]\n\ +_080F8AB6:\n\ + add sp, 0x8\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"); +} +#endif // NONMATCHING + +void sub_80F8ACC(void) +{ + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); +} + +void ShowContestWinner(void) +{ + SetMainCallback2(sub_812FDEC); + gMain.savedCallback = sub_80F8ACC; +} + +void sub_80F8AFC(void) +{ + int i; + + if (gIsLinkContest & 1) + { + for (i = 0; i < gUnknown_02039F30; i++) + { + int version = (u8)gLinkPlayers[i].version; + if (version == VERSION_RUBY || version == VERSION_SAPPHIRE) + { + if (gLinkPlayers[i].gender == MALE) + gContestMons[i].trainerGfxId = EVENT_OBJ_GFX_LINK_RS_BRENDAN; + else + gContestMons[i].trainerGfxId = EVENT_OBJ_GFX_LINK_RS_MAY; + } + } + + VarSet(VAR_OBJ_GFX_ID_0, gContestMons[0].trainerGfxId); + VarSet(VAR_OBJ_GFX_ID_1, gContestMons[1].trainerGfxId); + VarSet(VAR_OBJ_GFX_ID_2, gContestMons[2].trainerGfxId); + VarSet(VAR_OBJ_GFX_ID_3, gContestMons[3].trainerGfxId); + } +} + +void sub_80F8B94(void) +{ + int i; + u8 eventObjectId; + int version; + struct Sprite *sprite; + + gReservedSpritePaletteCount = 12; + if (gIsLinkContest & 1) + { + for (i = 0; i < gUnknown_02039F30; i++) + { + eventObjectId = GetEventObjectIdByLocalIdAndMap(gUnknown_0858D8EC[i], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + sprite = &gSprites[gEventObjects[eventObjectId].spriteId]; + sprite->oam.paletteNum = 6 + i; + version = (u8)gLinkPlayers[i].version; + if (version == VERSION_RUBY || version == VERSION_SAPPHIRE) + { + if (gLinkPlayers[i].gender == MALE) + LoadPalette(gEventObjectPalette33, 0x160 + i * 0x10, 0x20); + else + LoadPalette(gEventObjectPalette34, 0x160 + i * 0x10, 0x20); + } + else + { + if (gLinkPlayers[i].gender == MALE) + LoadPalette(gEventObjectPalette8, 0x160 + i * 0x10, 0x20); + else + LoadPalette(gEventObjectPalette17, 0x160 + i * 0x10, 0x20); + } + } + } +} + +u8 sub_80F8C7C(void) +{ + u8 hasArtistRibbon; + + hasArtistRibbon = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON); + if (!hasArtistRibbon && gContestFinalStandings[gContestPlayerMonIndex] == 0 && gSpecialVar_ContestRank == 3 + && gUnknown_02039F08[gContestPlayerMonIndex] >= 800) + { + hasArtistRibbon = 1; + SetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon); + if (GetRibbonCount(&gPlayerParty[gUnknown_02039F24]) > 4) + sub_80EE4DC(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON); + + return 1; + } + else + { + return 0; + } +} + +u8 sub_80F8D24(void) +{ + return 0; +} + +void sub_80F8D28(void) +{ + const struct CompressedSpritePalette *palette; + u32 personality, otId; + u16 species; + u8 spriteId; + u8 taskId; + u8 left, top; + + if (FindTaskIdByFunc(sub_80F8EE8) == 0xFF) + { + AllocateMonSpritesGfx(); + left = 10; + top = 3; + species = gContestMons[gSpecialVar_0x8006].species; + personality = gContestMons[gSpecialVar_0x8006].personality; + otId = gContestMons[gSpecialVar_0x8006].otId; + taskId = CreateTask(sub_80F8EE8, 0x50); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = species; + if (gSpecialVar_0x8006 == gContestPlayerMonIndex) + { + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); + } + else + { + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); + } + + palette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); + LoadCompressedObjectPalette(palette); + SetMultiuseSpriteTemplateToPokemon(species, 1); + gMultiuseSpriteTemplate.paletteTag = palette->tag; + spriteId = CreateSprite(&gMultiuseSpriteTemplate, (left + 1) * 8 + 32, (top * 8) + 40, 0); + + if (gIsLinkContest & 1) + { + if (!(gIsLinkContest & 4)) + DoMonFrontSpriteAnimation(&gSprites[spriteId], species, FALSE, 0); + } + else + { + DoMonFrontSpriteAnimation(&gSprites[spriteId], species, FALSE, 0); + } + + gTasks[taskId].data[2] = spriteId; + gTasks[taskId].data[3] = left; + gTasks[taskId].data[4] = top; + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[spriteId].oam.priority = 0; + } +} + +void sub_80F8EB8(void) +{ + u8 taskId = FindTaskIdByFunc(sub_80F8EE8); + if (taskId != 0xFF) + { + gTasks[taskId].data[0]++; + FreeMonSpritesGfx(); + } +} + +static void sub_80F8EE8(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + struct Sprite *sprite; + + switch(task->data[0]) + { + case 0: + task->data[0]++; + break; + case 1: + task->data[5] = CreateWindowFromRect(10, 3, 8, 8); + SetStandardWindowBorderStyle(task->data[5], 1); + task->data[0]++; + break; + case 2: + break; + case 3: + sprite = &gSprites[task->data[2]]; + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); + + if(sprite->oam.affineMode) + FreeOamMatrix(sprite->oam.matrixNum); + + DestroySprite(sprite); + task->data[0]++; + break; + case 4: + sub_80E2A78(gTasks[taskId].data[5]); + DestroyTask(taskId); + break; + } +} + +void sub_80F8FA0(void) +{ + if ((gIsLinkContest & 1) && gUnknown_02039F30 == 4 && !(gIsLinkContest & 2)) + gSpecialVar_Result = GetMultiplayerId(); + else + gSpecialVar_Result = 4; +} + +void sub_80F8FE8(void) +{ + u16 random; + u16 *scriptPtr; + + if (gIsLinkContest & 1) + { + gContestRngValue = 1103515245 * gContestRngValue + 24691; + random = gContestRngValue >> 16; + scriptPtr = &gSpecialVar_Result; + } + else + { + scriptPtr = &gSpecialVar_Result; + random = Random(); + } + *scriptPtr = random % *scriptPtr; +} + +u16 sub_80F903C(void) +{ + gContestRngValue = 1103515245 * gContestRngValue + 24691; + return gContestRngValue >> 16; +} + +u8 sub_80F905C(void) +{ + if (gIsLinkContest & 2) + { + CreateTask(sub_80F9088, 5); + return 1; + } + else + { + return 0; + } +} + +static void sub_80F9088(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + if (sub_800A520()) + { + sub_800ADF8(); + gTasks[taskId].data[0]++; + } + break; + case 1: + gTasks[taskId].data[0]++; + break; + default: + if (sub_800A520() == 1) + { + EnableBothScriptContexts(); + DestroyTask(taskId); + } + break; + } +} + +void sub_80F90DC(void) +{ + if (gIsLinkContest & 2) + { + if (gReceivedRemoteLinkPlayers) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(8, 8); + } + } +} + +void sub_80F910C(void) +{ + if (gIsLinkContest & 2) + { + if (gReceivedRemoteLinkPlayers) + sub_800E084(); + } +} + +u8 sub_80F9134(void) +{ + if (gIsLinkContest & 4) + return 1; + else + return 0; +} + +void sub_80F9154(void) +{ + gIsLinkContest = 0; +} + +u8 sub_80F9160(void) +{ + if (gIsLinkContest & 2) + return 1; + else + return 0; +} + +void HealPlayerParty(void) +{ + u8 i, j; + u8 ppBonuses; + u8 arg[4]; + + // restore HP. + for(i = 0; i < gPlayerPartyCount; i++) + { + u16 maxHP = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + arg[0] = maxHP; + arg[1] = maxHP >> 8; + SetMonData(&gPlayerParty[i], MON_DATA_HP, arg); + ppBonuses = GetMonData(&gPlayerParty[i], MON_DATA_PP_BONUSES); + + // restore PP. + for(j = 0; j < 4; j++) + { + arg[0] = CalculatePPWithBonus(GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j), ppBonuses, j); + SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, arg); + } + + // since status is u32, the four 0 assignments here are probably for safety to prevent undefined data from reaching SetMonData. + arg[0] = 0; + arg[1] = 0; + arg[2] = 0; + arg[3] = 0; + SetMonData(&gPlayerParty[i], MON_DATA_STATUS, arg); + } +} + +u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 unused3) +{ + u16 nationalDexNum; + int sentToPc; + u8 heldItem[2]; + struct Pokemon mon; + + CreateMon(&mon, species, level, 32, 0, 0, 0, 0); + heldItem[0] = item; + heldItem[1] = item >> 8; + SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem); + sentToPc = GiveMonToPlayer(&mon); + nationalDexNum = SpeciesToNationalPokedexNum(species); + + switch(sentToPc) + { + case 0: + case 1: + GetSetPokedexFlag(nationalDexNum, 2); + GetSetPokedexFlag(nationalDexNum, 3); + break; + } + return sentToPc; +} + +u8 ScriptGiveEgg(u16 species) +{ + struct Pokemon mon; + u8 isEgg; + + CreateEgg(&mon, species, TRUE); + isEgg = TRUE; + SetMonData(&mon, MON_DATA_IS_EGG, &isEgg); + + return GiveMonToPlayer(&mon); +} + +void HasEnoughMonsForDoubleBattle(void) +{ + switch (GetMonsStateToDoubles()) + { + case 0: + gSpecialVar_Result = 0; + break; + case 1: + gSpecialVar_Result = 1; + break; + case 2: + gSpecialVar_Result = 2; + break; + } +} + +bool8 CheckPartyMonHasHeldItem(u16 item) +{ + int i; + + for(i = 0; i < PARTY_SIZE; i++) + { + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == item) + return TRUE; + } + return FALSE; +} + +bool8 sub_80F9370(void) +{ + bool8 hasItem = CheckPartyMonHasHeldItem(ITEM_ENIGMA_BERRY); + if (hasItem == TRUE) + GetBerryNameByBerryType(ItemIdToBerryType(ITEM_ENIGMA_BERRY), gStringVar1); + + return hasItem; +} + +void CreateScriptedWildMon(u16 species, u8 level, u16 item) +{ + u8 heldItem[2]; + + ZeroEnemyPartyMons(); + CreateMon(&gEnemyParty[0], species, level, 0x20, 0, 0, 0, 0); + if (item) + { + heldItem[0] = item; + heldItem[1] = item >> 8; + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem); + } +} + +void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot) +{ + if (monIndex > PARTY_SIZE) + monIndex = gPlayerPartyCount - 1; + + SetMonMoveSlot(&gPlayerParty[monIndex], move, slot); +} + +void sub_80F9438(void) +{ + gMain.savedCallback = sub_80F9460; + VarSet(VAR_FRONTIER_FACILITY, 9); // this isn't a valid frontier facility id (??) + sub_81B8518(0); +} + +static void sub_80F9460(void) +{ + switch (gUnknown_0203CEF8[0]) + { + case 0: + gSpecialVar_Result = 0; + break; + default: + gSpecialVar_Result = 1; + break; + } + + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); +} + +void sub_80F9490(void) +{ + gMain.savedCallback = sub_80F94B8; + sub_81B8518(gSpecialVar_0x8004 + 1); +} + +static void sub_80F94B8(void) +{ + switch (gUnknown_0203CEF8[0]) + { + case 0: + gSpecialVar_Result = 0; + break; + default: + gSpecialVar_Result = 1; + break; + } + + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); +} + +void ReducePlayerPartyToThree(void) +{ + struct Pokemon party[4]; + int i; + + CpuFill32(0, party, sizeof party); + + // copy the selected pokemon according to the order. + for (i = 0; i < 4; i++) + if (gUnknown_0203CEF8[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop + party[i] = gPlayerParty[gUnknown_0203CEF8[i] - 1]; // index is 0 based, not literal + + CpuFill32(0, gPlayerParty, sizeof gPlayerParty); + + // overwrite the first 4 with the order copied to. + for (i = 0; i < 4; i++) + gPlayerParty[i] = party[i]; + + CalculatePlayerPartyCount(); +}