From eb48cc2f7eefc1e56c2dcec21c38381b4534b897 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sat, 23 Feb 2019 09:08:07 -0800 Subject: [PATCH] Decompile through sub_8167930. --- asm/use_pokeblock.s | 2491 ------------------------------------------ data/use_pokeblock.s | 6 +- include/graphics.h | 5 + include/strings.h | 5 + src/use_pokeblock.c | 2047 +++++++++++++++++++++++++++++++++- 5 files changed, 2058 insertions(+), 2496 deletions(-) diff --git a/asm/use_pokeblock.s b/asm/use_pokeblock.s index d2d4913b1..1fe1f81ef 100644 --- a/asm/use_pokeblock.s +++ b/asm/use_pokeblock.s @@ -5,2497 +5,6 @@ .text - - - thumb_func_start sub_8166564 -sub_8166564: @ 8166564 - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203BC90 - ldr r0, [r4] - adds r0, 0x50 - ldrb r1, [r0] - cmp r1, 0 - beq _08166580 - cmp r1, 0x1 - beq _081665C0 - b _08166610 - .pool -_08166580: - movs r0, 0x1 - negs r0, r0 - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_8166340 - bl SetVBlankCallback - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x3 - bl ShowBg - movs r0, 0x2 - bl ShowBg - ldr r1, [r4] - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08166610 - .pool -_081665C0: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08166610 - ldr r4, =gUnknown_0203BCAC - ldr r0, [r4] - ldr r1, =0x00007b1c - adds r0, r1 - bl sub_81D3464 - ldr r4, [r4] - ldr r2, =0x00008041 - adds r0, r4, r2 - ldrb r1, [r0] - ldr r3, =0x00008040 - adds r0, r4, r3 - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - beq _0816660A - ldr r1, =0x00007fb3 - adds r0, r4, r1 - movs r1, 0 - ldrsb r1, [r0, r1] - subs r2, 0x91 - adds r0, r4, r2 - adds r0, r1 - ldrb r2, [r0] - ldr r3, =0x00007b1c - adds r0, r4, r3 - subs r3, 0xC - adds r1, r4, r3 - ldrb r1, [r1] - bl sub_81D3480 -_0816660A: - ldr r0, =sub_8166634 - bl sub_816636C -_08166610: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166564 - - thumb_func_start sub_8166634 -sub_8166634: @ 8166634 - push {lr} - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - ldrb r0, [r0] - cmp r0, 0x7 - bls _08166644 - b _0816680E -_08166644: - lsls r0, 2 - ldr r1, =_08166658 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08166658: - .4byte _08166678 - .4byte _0816675C - .4byte _0816680E - .4byte _08166788 - .4byte _0816680E - .4byte _08166794 - .4byte _081667AC - .4byte _081667F4 -_08166678: - ldr r2, =gMain - ldrh r1, [r2, 0x2C] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081666B8 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - bl sub_8167CA0 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b1c - adds r0, r1 - bl sub_81D3520 - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x1 - b _0816680C - .pool -_081666B8: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081666F0 - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_8167CA0 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00007b1c - adds r0, r2 - bl sub_81D3520 - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x1 - b _0816680C - .pool -_081666F0: - ldrh r1, [r2, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08166710 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x3 - b _0816680C - .pool -_08166710: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0816671A - b _0816680E -_0816671A: - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00008041 - adds r1, r0, r2 - ldrb r1, [r1] - subs r2, 0x1 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - bne _0816674C - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x3 - b _0816680C - .pool -_0816674C: - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x5 - b _0816680C - .pool -_0816675C: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00008044 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0816680E - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - b _0816680C - .pool -_08166788: - ldr r0, =sub_8166BEC - bl sub_816636C - b _0816680E - .pool -_08166794: - bl sub_8166D44 - ldr r0, =gUnknown_0203BC90 - ldr r1, [r0] - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0816680E - .pool -_081667AC: - bl sub_8166DE4 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _081667CC - cmp r1, 0 - bgt _081667C6 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _08166804 - b _0816680E -_081667C6: - cmp r1, 0x1 - bne _0816680E - b _08166804 -_081667CC: - bl sub_8167268 - lsls r0, 24 - cmp r0, 0 - beq _081667E8 - bl sub_8166F50 - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0x7 - b _0816680C - .pool -_081667E8: - ldr r0, =sub_816681C - bl sub_816636C - b _0816680E - .pool -_081667F4: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0816680E - bl sub_8166F94 -_08166804: - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - movs r1, 0 -_0816680C: - strb r1, [r0] -_0816680E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166634 - - thumb_func_start sub_816681C -sub_816681C: @ 816681C - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, =gUnknown_0203BC90 - ldr r0, [r5] - adds r0, 0x50 - ldrb r4, [r0] - cmp r4, 0 - beq _08166838 - cmp r4, 0x1 - beq _08166888 - b _081668D4 - .pool -_08166838: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00008041 - adds r0, r1 - ldrb r0, [r0] - bl sub_81672A4 - ldr r1, =gPokeblockMonId - strb r0, [r1] - ldr r1, =gUnknown_0203BC94 - ldr r2, [r5] - ldr r0, [r2, 0x4] - str r0, [r1] - ldr r1, =gUnknown_0203BC98 - ldr r0, [r2, 0x8] - str r0, [r1] - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, [r5] - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _081668D4 - .pool -_08166888: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _081668D4 - movs r0, 0 - bl SetVBlankCallback - ldr r4, =gUnknown_0203BCA0 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203BCA4 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203BCA8 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203BCAC - ldr r0, [r4] - bl Free - str r5, [r4] - bl FreeAllWindowBuffers - ldr r1, =gMain - ldr r0, =CB2_ReturnAndChooseMonToGivePokeblock - str r0, [r1, 0x8] - bl CB2_PreparePokeblockFeedScene -_081668D4: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816681C - - thumb_func_start sub_81668F8 -sub_81668F8: @ 81668F8 - push {r4,lr} - sub sp, 0x4 - ldr r1, =gUnknown_0203BC90 - ldr r0, [r1] - adds r0, 0x50 - ldrb r0, [r0] - adds r4, r1, 0 - cmp r0, 0x6 - bls _0816690C - b _08166A18 -_0816690C: - lsls r0, 2 - ldr r1, =_08166920 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08166920: - .4byte _0816693C - .4byte _08166972 - .4byte _08166A18 - .4byte _081669A0 - .4byte _081669AE - .4byte _081669C8 - .4byte _081669F4 -_0816693C: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00008041 - adds r0, r1 - ldr r1, =gPokeblockMonId - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - beq _08166968 - ldr r0, [r4] - adds r0, 0x56 - ldrb r0, [r0] - bl sub_8167CA0 - ldr r1, [r4] - b _081669E2 - .pool -_08166968: - ldr r0, [r4] - adds r0, 0x50 - movs r1, 0x3 - strb r1, [r0] - b _08166A18 -_08166972: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00008044 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08166A18 - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - adds r0, 0x50 - strb r1, [r0] - b _08166A18 - .pool -_081669A0: - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - b _081669DE -_081669AE: - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x3 - bl ShowBg - movs r0, 0x2 - bl ShowBg - b _081669DE -_081669C8: - ldr r0, =sub_8166340 - bl SetVBlankCallback - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade -_081669DE: - ldr r0, =gUnknown_0203BC90 - ldr r1, [r0] -_081669E2: - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08166A18 - .pool -_081669F4: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08166A18 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b1c - adds r0, r1 - bl sub_81D3464 - ldr r0, =sub_8166A34 - bl sub_816636C - ldr r0, =sub_816631C - bl SetMainCallback2 -_08166A18: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81668F8 - - thumb_func_start sub_8166A34 -sub_8166A34: @ 8166A34 - push {r4-r6,lr} - ldr r1, =gUnknown_0203BC90 - ldr r0, [r1] - adds r0, 0x50 - ldrb r0, [r0] - adds r5, r1, 0 - cmp r0, 0x5 - bls _08166A46 - b _08166BDA -_08166A46: - lsls r0, 2 - ldr r1, =_08166A58 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08166A58: - .4byte _08166A70 - .4byte _08166AAC - .4byte _08166AC0 - .4byte _08166B14 - .4byte _08166B94 - .4byte _08166BB6 -_08166A70: - ldr r4, [r5] - ldr r3, =gPlayerParty - str r3, [r4, 0xC] - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00008041 - adds r1, r0, r2 - ldrb r1, [r1] - lsls r1, 2 - adds r1, r0, r1 - subs r2, 0x88 - adds r1, r2 - ldrb r2, [r1] - movs r1, 0x64 - muls r1, r2 - adds r1, r3 - str r1, [r4, 0xC] - ldr r3, =0x00007b1c - adds r0, r3 - bl sub_81D3520 - b _08166BAA - .pool -_08166AAC: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _08166ABA - b _08166BDA -_08166ABA: - b _08166BAA - .pool -_08166AC0: - bl sub_8167104 - ldr r6, =gUnknown_0203BC90 - ldr r0, [r6] - adds r0, 0x5C - ldr r4, =gUnknown_0203BCAC - ldr r1, [r4] - ldr r5, =0x00007ca8 - adds r1, r5 - bl sub_81D2754 - ldr r2, [r4] - ldr r4, =0x00007c58 - adds r0, r2, r4 - ldr r3, =0x00007fb3 - adds r1, r2, r3 - movs r3, 0 - ldrsb r3, [r1, r3] - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 2 - adds r4, 0x14 - adds r1, r4 - adds r1, r2, r1 - adds r2, r5 - bl sub_81D1F84 - bl sub_8167338 - ldr r1, [r6] - b _08166BAC - .pool -_08166B14: - ldr r5, =gUnknown_0203BCAC - ldr r0, [r5] - ldr r1, =0x00007c58 - adds r0, r1 - bl sub_81D2074 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _08166BDA - ldr r0, [r5] - ldr r4, =0x00008041 - adds r0, r4 - ldrb r0, [r0] - bl sub_81672A4 - lsls r0, 24 - lsrs r0, 24 - bl sub_81681F4 - ldr r3, [r5] - adds r4, r3, r4 - ldrb r1, [r4] - ldr r2, =0x00008040 - adds r0, r3, r2 - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - beq _08166B6C - ldr r4, =0x00007fb3 - adds r0, r3, r4 - movs r1, 0 - ldrsb r1, [r0, r1] - subs r2, 0x90 - adds r0, r3, r2 - adds r0, r1 - ldrb r2, [r0] - ldr r4, =0x00007b1c - adds r0, r3, r4 - subs r4, 0xC - adds r1, r3, r4 - ldrb r1, [r1] - bl sub_81D3480 -_08166B6C: - ldr r1, =gUnknown_0203BC90 - ldr r0, [r1] - adds r0, 0x52 - strb r6, [r0] - ldr r1, [r1] - b _08166BAC - .pool -_08166B94: - ldr r1, [r5] - adds r1, 0x52 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x10 - bls _08166BDA - bl sub_8166E24 -_08166BAA: - ldr r1, [r5] -_08166BAC: - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08166BDA -_08166BB6: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _08166BDA - bl sub_8166EDC - lsls r0, 24 - cmp r0, 0 - bne _08166BDA - ldr r0, =gSpecialVar_ItemId - ldrb r0, [r0] - bl TryClearPokeblock - ldr r0, =sub_8166BEC - bl sub_816636C -_08166BDA: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166A34 - - thumb_func_start sub_8166BEC -sub_8166BEC: @ 8166BEC - push {r4-r6,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203BC90 - ldr r0, [r4] - adds r2, r0, 0 - adds r2, 0x50 - ldrb r1, [r2] - cmp r1, 0x1 - beq _08166C28 - cmp r1, 0x1 - bgt _08166C0C - cmp r1, 0 - beq _08166C16 - b _08166D18 - .pool -_08166C0C: - cmp r1, 0x2 - beq _08166C40 - cmp r1, 0x3 - beq _08166C5C - b _08166D18 -_08166C16: - movs r0, 0x1 - negs r0, r0 - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _08166C4A -_08166C28: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08166D18 - movs r0, 0x2 - strb r0, [r2] - b _08166D18 - .pool -_08166C40: - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] - bl ScanlineEffect_InitHBlankDmaTransfer -_08166C4A: - ldr r1, [r4] - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08166D18 - .pool -_08166C5C: - ldr r0, [r0, 0x4] - bl SetMainCallback2 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b1c - adds r0, r1 - bl sub_81D354C - movs r4, 0 -_08166C70: - ldr r5, =gUnknown_0203BCAC - ldr r0, [r5] - ldr r2, =0x00007b06 - adds r0, r2 - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x6 - bls _08166C70 - movs r0, 0 - bl FreeSpriteTilesByTag - movs r0, 0x1 - bl FreeSpriteTilesByTag - movs r0, 0 - bl FreeSpritePaletteByTag - movs r0, 0x1 - bl FreeSpritePaletteByTag - movs r4, 0 -_08166CAE: - ldr r0, [r5] - lsls r1, r4, 2 - ldr r2, =0x00007b44 - adds r0, r2 - adds r0, r1 - ldr r0, [r0] - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _08166CAE - ldr r6, =gUnknown_0203BCAC - ldr r0, [r6] - ldr r2, =0x00007b10 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xFF - beq _08166CE6 - adds r1, r0, 0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite -_08166CE6: - movs r0, 0 - bl SetVBlankCallback - ldr r4, =gUnknown_0203BCA0 - ldr r0, [r4] - bl Free - movs r5, 0 - str r5, [r4] - ldr r4, =gUnknown_0203BCA4 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203BCA8 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r0, [r6] - bl Free - str r5, [r6] - bl FreeAllWindowBuffers -_08166D18: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166BEC - - thumb_func_start sub_8166D44 -sub_8166D44: @ 8166D44 - push {r4,lr} - sub sp, 0x4C - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00008041 - adds r0, r1 - ldrb r0, [r0] - bl sub_81672A4 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2 - add r2, sp, 0xC - bl GetMonData - add r0, sp, 0xC - bl StringGetEnd10 - ldr r1, =gText_GetsAPokeBlockQuestion - add r0, sp, 0xC - bl StringAppend - ldr r4, =gStringVar4 - adds r0, r4, 0 - add r1, sp, 0xC - bl StringCopy - movs r0, 0x2 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0x2 - movs r1, 0x97 - movs r2, 0xE - bl sub_8098858 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl AddTextPrinterParameterized - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x3 - bl CopyWindowToVram - ldr r0, =sUsePokeblockYesNoWinTemplate - movs r1, 0x97 - movs r2, 0xE - movs r3, 0 - bl CreateYesNoMenu - add sp, 0x4C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166D44 - - thumb_func_start sub_8166DE4 -sub_8166DE4: @ 8166DE4 - push {r4,lr} - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - lsrs r4, r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _08166E18 - cmp r1, 0 - bgt _08166E02 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _08166E06 - b _08166E18 -_08166E02: - cmp r1, 0x1 - bne _08166E18 -_08166E06: - movs r0, 0x5 - bl PlaySE - movs r0, 0x2 - bl rbox_fill_rectangle - movs r0, 0x2 - bl ClearWindowTilemap -_08166E18: - lsls r0, r4, 24 - asrs r0, 24 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8166DE4 - - thumb_func_start sub_8166E24 -sub_8166E24: @ 8166E24 - push {r4,lr} - movs r0, 0x2 - movs r1, 0x97 - movs r2, 0xE - bl sub_8098858 - movs r0, 0x2 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r3, =gUnknown_0203BC90 - ldr r0, [r3] - adds r0, 0x53 - movs r1, 0 - strb r1, [r0] - ldr r2, [r3] - adds r1, r2, 0 - adds r1, 0x53 - ldrb r0, [r1] - cmp r0, 0x4 - bhi _08166EA8 - adds r0, r2, 0 - adds r0, 0x61 - ldrb r1, [r1] - adds r0, r1 - ldrb r0, [r0] - adds r4, r3, 0 - cmp r0, 0 - bne _08166E84 - adds r2, r4, 0 -_08166E60: - ldr r0, [r2] - adds r0, 0x53 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r3, [r2] - adds r1, r3, 0 - adds r1, 0x53 - ldrb r0, [r1] - cmp r0, 0x4 - bhi _08166EA8 - adds r0, r3, 0 - adds r0, 0x61 - ldrb r1, [r1] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _08166E60 -_08166E84: - ldr r2, [r4] - adds r1, r2, 0 - adds r1, 0x53 - ldrb r0, [r1] - cmp r0, 0x4 - bhi _08166EA8 - ldr r0, =gStringVar4 - ldrb r1, [r1] - adds r2, 0x61 - adds r2, r1 - ldrb r2, [r2] - bl sub_8166FD4 - b _08166EB8 - .pool -_08166EA8: - ldr r0, =gStringVar4 - ldr r1, =gUnknown_0203BC90 - ldr r1, [r1] - adds r1, 0x53 - ldrb r1, [r1] - movs r2, 0 - bl sub_8166FD4 -_08166EB8: - ldr r0, =gStringVar4 - bl sub_8166FB0 - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166E24 - - thumb_func_start sub_8166EDC -sub_8166EDC: @ 8166EDC - push {r4,r5,lr} - movs r0, 0x2 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r5, =gUnknown_0203BC90 - adds r3, r5, 0 - movs r4, 0x5 -_08166EEC: - ldr r0, [r3] - adds r0, 0x53 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r2, [r3] - adds r1, r2, 0 - adds r1, 0x53 - ldrb r0, [r1] - cmp r0, 0x4 - bhi _08166F18 - adds r0, r2, 0 - adds r0, 0x61 - ldrb r1, [r1] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08166F1E - b _08166EEC - .pool -_08166F18: - strb r4, [r1] - movs r0, 0 - b _08166F44 -_08166F1E: - ldr r4, =gStringVar4 - ldr r0, [r5] - adds r1, r0, 0 - adds r1, 0x53 - ldrb r1, [r1] - adds r0, 0x61 - adds r0, r1 - ldrb r2, [r0] - adds r0, r4, 0 - bl sub_8166FD4 - adds r0, r4, 0 - bl sub_8166FB0 - movs r0, 0x2 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x1 -_08166F44: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8166EDC - - thumb_func_start sub_8166F50 -sub_8166F50: @ 8166F50 - push {lr} - sub sp, 0xC - movs r0, 0x2 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0x2 - movs r1, 0x97 - movs r2, 0xE - bl sub_8098858 - ldr r2, =gText_WontEatAnymore - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166F50 - - thumb_func_start sub_8166F94 -sub_8166F94: @ 8166F94 - push {lr} - movs r0, 0x2 - bl rbox_fill_rectangle - movs r0, 0x2 - bl ClearWindowTilemap - movs r0, 0x2 - movs r1, 0x3 - bl CopyWindowToVram - pop {r0} - bx r0 - thumb_func_end sub_8166F94 - - thumb_func_start sub_8166FB0 -sub_8166FB0: @ 8166FB0 - push {lr} - sub sp, 0xC - ldr r2, =gStringVar4 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166FB0 - - thumb_func_start sub_8166FD4 -sub_8166FD4: @ 8166FD4 - push {r4,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r2, 16 - lsrs r0, r2, 16 - asrs r2, 16 - cmp r2, 0 - beq _08167010 - cmp r2, 0 - ble _08166FEC - movs r0, 0 -_08166FEC: - lsls r0, 16 - ldr r1, =sContestStatNames - lsls r0, r3, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl StringCopy - ldr r1, =gText_WasEnhanced - adds r0, r4, 0 - bl StringAppend - b _08167018 - .pool -_08167010: - ldr r1, =gText_NothingChanged - adds r0, r4, 0 - bl StringCopy -_08167018: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166FD4 - - thumb_func_start sub_8167024 -sub_8167024: @ 8167024 - push {r4-r7,lr} - adds r6, r0, 0 - adds r5, r1, 0 - movs r4, 0 - ldr r7, =gUnknown_085DFCB0 -_0816702E: - lsls r0, r4, 2 - adds r0, r7 - ldr r1, [r0] - adds r0, r6, 0 - bl GetMonData - adds r1, r5, r4 - strb r0, [r1] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x4 - bls _0816702E - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167024 - - thumb_func_start sub_8167054 -sub_8167054: @ 8167054 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - mov r8, r0 - adds r5, r1, 0 - adds r0, r5, 0 - movs r1, 0x30 - bl GetMonData - cmp r0, 0xFF - beq _081670F0 - mov r0, r8 - adds r1, r5, 0 - bl sub_8167184 - movs r4, 0 - mov r7, sp -_08167078: - ldr r1, =gUnknown_085DFCB0 - lsls r0, r4, 2 - adds r0, r1 - ldr r6, [r0] - adds r0, r5, 0 - adds r1, r6, 0 - bl GetMonData - lsls r0, 24 - lsrs r0, 24 - strb r0, [r7] - ldr r1, =gUnknown_0203BC90 - ldr r1, [r1] - lsls r2, r4, 1 - adds r1, 0x66 - adds r1, r2 - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r0, 0 - bge _081670A6 - movs r1, 0 -_081670A6: - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xFF - ble _081670B0 - movs r1, 0xFF -_081670B0: - strb r1, [r7] - adds r0, r5, 0 - adds r1, r6, 0 - mov r2, sp - bl SetMonData - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x4 - bls _08167078 - adds r0, r5, 0 - movs r1, 0x30 - bl GetMonData - lsls r0, 24 - lsrs r0, 24 - mov r2, r8 - ldrb r2, [r2, 0x6] - adds r1, r0, r2 - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xFF - ble _081670E2 - movs r1, 0xFF -_081670E2: - mov r0, sp - strb r1, [r0] - adds r0, r5, 0 - movs r1, 0x30 - mov r2, sp - bl SetMonData -_081670F0: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167054 - - thumb_func_start sub_8167104 -sub_8167104: @ 8167104 - push {r4,r5,lr} - ldr r5, =gPlayerParty - ldr r0, =gUnknown_0203BCAC - ldr r1, [r0] - ldr r2, =0x00008041 - adds r0, r1, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r1, r0 - ldr r0, =0x00007fb9 - adds r1, r0 - ldrb r1, [r1] - movs r0, 0x64 - muls r0, r1 - adds r5, r0, r5 - ldr r4, =gUnknown_0203BC90 - ldr r1, [r4] - adds r1, 0x57 - adds r0, r5, 0 - bl sub_8167024 - ldr r0, [r4] - ldr r0, [r0, 0x8] - adds r1, r5, 0 - bl sub_8167054 - ldr r1, [r4] - adds r1, 0x5C - adds r0, r5, 0 - bl sub_8167024 - movs r3, 0 -_08167144: - ldr r0, [r4] - adds r2, r0, 0 - adds r2, 0x61 - adds r2, r3 - adds r1, r0, 0 - adds r1, 0x5C - adds r1, r3 - adds r0, 0x57 - adds r0, r3 - ldrb r1, [r1] - ldrb r0, [r0] - subs r1, r0 - strb r1, [r2] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x4 - bls _08167144 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167104 - - thumb_func_start sub_8167184 -sub_8167184: @ 8167184 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r10, r1 - ldr r1, =gUnknown_0203BC90 - ldr r3, [r1] - ldrb r1, [r0, 0x1] - adds r2, r3, 0 - adds r2, 0x66 - strh r1, [r2] - ldrb r2, [r0, 0x5] - adds r1, r3, 0 - adds r1, 0x68 - strh r2, [r1] - ldrb r1, [r0, 0x4] - adds r2, r3, 0 - adds r2, 0x6A - strh r1, [r2] - ldrb r2, [r0, 0x3] - adds r1, r3, 0 - adds r1, 0x6C - strh r2, [r1] - ldrb r1, [r0, 0x2] - adds r0, r3, 0 - adds r0, 0x6E - strh r1, [r0] - ldr r0, =gPokeblockGain - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - ble _081671D4 - movs r0, 0x1 - b _081671DA - .pool -_081671D4: - cmp r0, 0 - bge _08167250 - movs r0, 0xFF -_081671DA: - movs r2, 0 - lsls r0, 24 - mov r9, r0 - ldr r0, =gUnknown_0203BC90 - mov r8, r0 -_081671E4: - mov r0, r8 - ldr r1, [r0] - lsls r0, r2, 24 - asrs r6, r0, 24 - lsls r7, r6, 1 - adds r1, 0x66 - adds r1, r7 - movs r2, 0 - ldrsh r4, [r1, r2] - adds r0, r4, 0 - movs r1, 0xA - bl __divsi3 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - movs r1, 0xA - bl __modsi3 - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - ble _0816721C - lsls r0, r5, 24 - movs r1, 0x80 - lsls r1, 17 - adds r0, r1 - lsrs r5, r0, 24 -_0816721C: - ldr r0, =gUnknown_085DFCC4 - adds r0, r6, r0 - ldrb r1, [r0] - mov r0, r10 - bl GetMonFlavorRelation - lsls r0, 24 - asrs r2, r0, 24 - cmp r0, r9 - bne _08167244 - mov r1, r8 - ldr r0, [r1] - adds r0, 0x66 - adds r0, r7 - lsls r1, r5, 24 - asrs r1, 24 - muls r1, r2 - ldrh r2, [r0] - adds r1, r2 - strh r1, [r0] -_08167244: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - asrs r0, 24 - cmp r0, 0x4 - ble _081671E4 -_08167250: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167184 - - thumb_func_start sub_8167268 -sub_8167268: @ 8167268 - push {lr} - ldr r0, =gUnknown_0203BCAC - ldr r1, [r0] - ldr r2, =0x00008041 - adds r0, r1, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r1, r0 - subs r2, 0x89 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, 0x1 - adds r1, r2 - ldrb r1, [r1] - movs r2, 0x30 - movs r3, 0 - bl sub_81D2C68 - cmp r0, 0xFF - beq _0816729C - movs r0, 0 - b _0816729E - .pool -_0816729C: - movs r0, 0x1 -_0816729E: - pop {r1} - bx r1 - thumb_func_end sub_8167268 - - thumb_func_start sub_81672A4 -sub_81672A4: @ 81672A4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 -_081672AC: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _081672D2 - cmp r5, 0 - bne _081672CC - adds r0, r4, 0 - b _081672DE - .pool -_081672CC: - subs r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_081672D2: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x5 - bls _081672AC - movs r0, 0 -_081672DE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81672A4 - - thumb_func_start sub_81672E4 -sub_81672E4: @ 81672E4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - movs r6, 0 - cmp r6, r5 - bcs _08167314 -_081672F2: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - beq _0816730A - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0816730A: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r5 - bcc _081672F2 -_08167314: - subs r0, r5, r6 - lsls r0, 24 - lsrs r0, 24 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81672E4 - - thumb_func_start sub_8167324 -sub_8167324: @ 8167324 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_81672A4 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8167324 - - thumb_func_start sub_8167338 -sub_8167338: @ 8167338 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gUnknown_085DFD18 - bl LoadSpriteSheet - ldr r0, =gUnknown_085DFD20 - bl LoadSpritePalette - ldr r2, =gUnknown_0203BC90 - ldr r0, [r2] - adds r0, 0x54 - movs r1, 0 - strb r1, [r0] - movs r4, 0 - adds r5, r2, 0 - ldr r6, =gUnknown_085DFD28 - adds r0, r6, 0x2 - mov r8, r0 - ldr r7, =gSprites + 0x1C -_08167360: - ldr r0, [r5] - adds r0, 0x61 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - beq _081673AC - lsls r2, r4, 2 - adds r0, r2, r6 - movs r3, 0 - ldrsh r1, [r0, r3] - add r2, r8 - movs r0, 0 - ldrsh r2, [r2, r0] - ldr r0, =gUnknown_085DFD5C - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _081673AC - ldr r0, [r5] - adds r0, 0x61 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - beq _081673A2 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldr r1, =sub_81673DC - str r1, [r0] -_081673A2: - ldr r1, [r5] - adds r1, 0x54 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_081673AC: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x4 - bls _08167360 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167338 - - thumb_func_start sub_81673DC -sub_81673DC: @ 81673DC - push {lr} - adds r1, r0, 0 - movs r2, 0x2E - ldrsh r0, [r1, r2] - cmp r0, 0x5 - bgt _081673EE - ldrh r0, [r1, 0x26] - subs r0, 0x2 - b _081673F6 -_081673EE: - cmp r0, 0xB - bgt _081673F8 - ldrh r0, [r1, 0x26] - adds r0, 0x2 -_081673F6: - strh r0, [r1, 0x26] -_081673F8: - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3C - ble _08167418 - adds r0, r1, 0 - bl DestroySprite - ldr r0, =gUnknown_0203BC90 - ldr r1, [r0] - adds r1, 0x54 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_08167418: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81673DC - - thumb_func_start sub_8167420 -sub_8167420: @ 8167420 - push {r4-r6,lr} - movs r4, 0 - movs r5, 0 - ldr r6, =gUnknown_0203BCAC - b _08167472 - .pool -_08167430: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2D - bl GetMonData - adds r3, r0, 0 - cmp r3, 0 - bne _0816746C - ldr r1, [r6] - lsls r2, r5, 2 - adds r1, r2 - ldr r0, =0x00007fb8 - adds r1, r0 - movs r0, 0xE - strb r0, [r1] - ldr r0, [r6] - adds r0, r2 - ldr r1, =0x00007fb9 - adds r0, r1 - strb r4, [r0] - ldr r0, [r6] - adds r0, r2 - ldr r2, =0x00007fba - adds r0, r2 - strh r3, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_0816746C: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 -_08167472: - bl CalculatePlayerPartyCount - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _08167430 - ldr r2, =gUnknown_0203BCAC - ldr r0, [r2] - ldr r1, =0x00008041 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r1, r5, 0x1 - ldr r2, =0x00008040 - adds r0, r2 - strb r1, [r0] - bl sub_81674BC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167420 - - thumb_func_start sub_81674BC -sub_81674BC: @ 81674BC - push {r4,r5,lr} - ldr r4, =gUnknown_0203BCAC - ldr r0, [r4] - ldr r5, =0x00008041 - adds r0, r5 - ldrb r0, [r0] - movs r1, 0 - bl sub_816753C - ldr r0, [r4] - ldr r1, =0x00007fb3 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - ldr r0, [r4] - ldr r2, =0x00007fb4 - adds r0, r2 - movs r1, 0x1 - strb r1, [r0] - ldr r0, [r4] - ldr r1, =0x00007fb5 - adds r0, r1 - movs r1, 0x2 - strb r1, [r0] - ldr r0, [r4] - adds r5, r0, r5 - ldrb r3, [r5] - adds r1, r3, 0x1 - adds r2, 0x8C - adds r0, r2 - ldrb r2, [r0] - cmp r1, r2 - blt _08167500 - movs r1, 0 -_08167500: - subs r0, r3, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r0, 0 - bge _08167510 - subs r0, r2, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 -_08167510: - adds r0, r1, 0 - movs r1, 0x1 - bl sub_816753C - lsls r0, r4, 16 - asrs r0, 16 - movs r1, 0x2 - bl sub_816753C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81674BC - - thumb_func_start sub_816753C -sub_816753C: @ 816753C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - adds r5, r0, 0 - adds r4, r1, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_0203BCAC - mov r9, r0 - ldr r1, [r0] - lsls r5, 16 - asrs r0, r5, 14 - adds r0, r1, r0 - ldr r3, =0x00007fb8 - adds r2, r0, r3 - ldrb r7, [r2] - ldr r2, =0x00007fb9 - adds r0, r2 - ldrb r0, [r0] - mov r10, r0 - adds r3, 0x88 - adds r0, r1, r3 - ldrb r6, [r0] - movs r0, 0 - mov r8, r0 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - ldr r2, =0x00007b4d - adds r0, r2 - adds r0, r1, r0 - lsls r2, r4, 6 - ldr r3, =0x00007b95 - adds r2, r3 - adds r1, r2 - lsrs r5, 16 - str r5, [sp] - str r6, [sp, 0x4] - mov r2, r8 - str r2, [sp, 0x8] - adds r2, r7, 0 - mov r3, r10 - bl sub_81D2ED4 - mov r3, r9 - ldr r1, [r3] - ldr r2, =0x00007c58 - adds r0, r1, r2 - ldr r3, =0x00007fb0 - adds r1, r3 - str r5, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r2, r8 - str r2, [sp, 0xC] - adds r2, r7, 0 - mov r3, r10 - bl sub_81D2F78 - lsls r0, r4, 13 - movs r1, 0xC1 - lsls r1, 2 - adds r0, r1 - mov r3, r9 - ldr r1, [r3] - adds r0, r1, r0 - lsls r4, 7 - adds r4, 0x4 - adds r1, r4 - str r5, [sp] - str r6, [sp, 0x4] - mov r2, r8 - str r2, [sp, 0x8] - adds r2, r7, 0 - mov r3, r10 - bl sub_81D3094 - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816753C - - thumb_func_start sub_8167608 -sub_8167608: @ 8167608 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x28 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gUnknown_0203BCAC - ldr r3, [r1] - ldr r0, =0x00007b10 - mov r8, r0 - adds r0, r3, r0 - ldrb r0, [r0] - adds r7, r1, 0 - cmp r0, 0xFF - bne _08167714 - add r5, sp, 0x18 - add r4, sp, 0x20 - adds r0, r5, 0 - mov r1, sp - adds r2, r4, 0 - bl sub_81D31D0 - lsls r0, r6, 13 - movs r1, 0xC1 - lsls r1, 2 - adds r0, r1 - ldr r1, [r7] - adds r0, r1, r0 - str r0, [sp, 0x18] - lsls r0, r6, 7 - adds r0, 0x4 - adds r1, r0 - str r1, [sp, 0x20] - adds r0, r4, 0 - bl LoadSpritePalette - ldr r1, [r7] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =0x00007b12 - adds r1, r2 - strh r0, [r1] - adds r0, r5, 0 - bl LoadSpriteSheet - ldr r1, [r7] - ldr r3, =0x00007b14 - adds r1, r3 - strh r0, [r1] - mov r0, sp - movs r1, 0x26 - movs r2, 0x68 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, [r7] - ldr r2, =0x00007b10 - adds r0, r2 - strb r1, [r0] - cmp r1, 0x40 - bne _081676AC - movs r0, 0x64 - bl FreeSpriteTilesByTag - movs r0, 0x64 - bl FreeSpritePaletteByTag - ldr r0, [r7] - add r0, r8 - movs r1, 0xFF - strb r1, [r0] - b _08167742 - .pool -_081676AC: - ldr r0, [r7] - add r0, r8 - strb r1, [r0] - ldr r4, =gSprites - ldr r2, [r7] - mov r0, r8 - adds r3, r2, r0 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_8168168 - str r1, [r0] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r0, 0x26] - subs r1, 0x22 - strh r1, [r0, 0x26] - ldr r3, =0x00007b18 - adds r1, r2, r3 - subs r3, 0x4 - adds r0, r2, r3 - ldrh r0, [r0] - lsls r0, 5 - ldr r3, =0x06010000 - adds r0, r3 - str r0, [r1] - ldr r0, =0x00007b12 - adds r2, r0 - ldrh r0, [r2] - lsls r0, 4 - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - strh r0, [r2] - b _08167742 - .pool -_08167714: - lsls r1, r6, 13 - movs r0, 0xC1 - lsls r0, 2 - adds r1, r0 - adds r1, r3, r1 - ldr r2, =0x00007b18 - adds r0, r3, r2 - ldr r2, [r0] - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000400 - str r1, [r0, 0x8] - ldr r0, [r0, 0x8] - lsls r0, r6, 7 - adds r0, 0x4 - adds r0, r3, r0 - ldr r2, =0x00007b12 - adds r1, r3, r2 - ldrh r1, [r1] - movs r2, 0x20 - bl LoadPalette -_08167742: - add sp, 0x28 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167608 - - thumb_func_start sub_8167760 -sub_8167760: @ 8167760 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x60 - add r5, sp, 0x20 - add r4, sp, 0x38 - mov r0, sp - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_81D321C - mov r0, sp - bl LoadSpriteSheets - adds r0, r4, 0 - bl LoadSpritePalettes - movs r4, 0 - ldr r1, =gUnknown_0203BCAC - ldr r0, [r1] - ldr r2, =0x00008040 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x1 - adds r6, r5, 0 - add r2, sp, 0x50 - mov r9, r2 - add r2, sp, 0x58 - mov r10, r2 - cmp r4, r0 - bge _0816781C - adds r5, r1, 0 - ldr r7, =gSprites - movs r0, 0x1C - adds r0, r7 - mov r8, r0 -_081677AC: - lsls r2, r4, 2 - adds r2, r4 - lsls r2, 18 - movs r1, 0x80 - lsls r1, 12 - adds r2, r1 - asrs r2, 16 - adds r0, r6, 0 - movs r1, 0xE2 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - beq _081677FC - ldr r0, [r5] - ldr r2, =0x00007b06 - adds r0, r2 - adds r0, r4 - strb r3, [r0] - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - adds r1, r0, r7 - strh r4, [r1, 0x2E] - add r0, r8 - ldr r1, =sub_8168180 - str r1, [r0] - b _08167808 - .pool -_081677FC: - ldr r0, [r5] - ldr r1, =0x00007b06 - adds r0, r1 - adds r0, r4 - movs r1, 0xFF - strb r1, [r0] -_08167808: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, [r5] - ldr r2, =0x00008040 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x1 - cmp r4, r0 - blt _081677AC -_0816781C: - movs r0, 0x67 - strh r0, [r6] - cmp r4, 0x5 - bhi _0816788A - ldr r5, =gUnknown_0203BCAC - ldr r7, =gSprites -_08167828: - lsls r2, r4, 2 - adds r2, r4 - lsls r2, 18 - movs r0, 0x80 - lsls r0, 12 - adds r2, r0 - asrs r2, 16 - adds r0, r6, 0 - movs r1, 0xE6 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - beq _08167874 - ldr r0, [r5] - ldr r1, =0x00007b06 - adds r0, r1 - adds r0, r4 - strb r3, [r0] - lsls r1, r3, 4 - adds r1, r3 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x3] - movs r0, 0x3F - ands r0, r2 - strb r0, [r1, 0x3] - b _08167880 - .pool -_08167874: - ldr r0, [r5] - ldr r2, =0x00007b06 - adds r0, r2 - adds r0, r4 - movs r1, 0xFF - strb r1, [r0] -_08167880: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x5 - bls _08167828 -_0816788A: - movs r0, 0x66 - strh r0, [r6] - ldr r0, =sub_81681B4 - str r0, [r6, 0x14] - lsls r2, r4, 2 - adds r2, r4 - lsls r2, 18 - movs r0, 0x80 - lsls r0, 12 - adds r2, r0 - asrs r2, 16 - adds r0, r6, 0 - movs r1, 0xDE - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - beq _081678F4 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b06 - adds r0, r1 - adds r0, r4 - strb r3, [r0] - ldr r0, =gSprites - lsls r2, r3, 4 - adds r2, r3 - lsls r2, 2 - adds r2, r0 - ldrb r3, [r2, 0x1] - movs r1, 0x3F - adds r0, r1, 0 - ands r0, r3 - movs r3, 0x40 - orrs r0, r3 - strb r0, [r2, 0x1] - ldrb r0, [r2, 0x3] - ands r1, r0 - movs r0, 0x80 - orrs r1, r0 - strb r1, [r2, 0x3] - b _08167902 - .pool -_081678F4: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00007b06 - adds r0, r2 - adds r0, r4 - movs r1, 0xFF - strb r1, [r0] -_08167902: - mov r0, r9 - mov r1, r10 - bl sub_81D32B0 - mov r0, r9 - bl LoadSpriteSheet - mov r0, r10 - bl LoadSpritePalette - add sp, 0x60 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8167760 - - thumb_func_start sub_8167930 -sub_8167930: @ 8167930 - push {r4,r5,lr} - sub sp, 0x8 - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00008048 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xB - bls _08167944 - b _08167B78 -_08167944: - lsls r0, 2 - ldr r1, =_0816795C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0816795C: - .4byte _0816798C - .4byte _08167A04 - .4byte _08167A38 - .4byte _08167A48 - .4byte _08167A5C - .4byte _08167A74 - .4byte _08167A9C - .4byte _08167AB0 - .4byte _08167AD4 - .4byte _08167AEC - .4byte _08167B1C - .4byte _08167B38 -_0816798C: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r1, 0x88 - lsls r1, 6 - movs r0, 0x3 - movs r2, 0 - bl ChangeBgY - ldr r1, =0x00007040 - movs r0, 0 - bl SetGpuReg - movs r1, 0x91 - lsls r1, 2 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000040b - movs r0, 0x52 - bl SetGpuReg - b _08167B7E - .pool -_08167A04: - ldr r4, =gUnknown_0203BCA4 - movs r0, 0xD0 - lsls r0, 5 - bl Alloc - str r0, [r4] - ldr r5, =gUnknown_0203BCA0 - movs r4, 0xA0 - lsls r4, 3 - adds r0, r4, 0 - bl Alloc - str r0, [r5] - ldr r5, =gUnknown_0203BCA8 - adds r0, r4, 0 - bl Alloc - str r0, [r5] - b _08167B7E - .pool -_08167A38: - ldr r0, =gUnknown_085DFB60 - ldr r1, =gUnknown_0203BCA8 - b _08167AA0 - .pool -_08167A48: - ldr r1, =gUnknown_085DFA80 - movs r0, 0x3 - movs r2, 0xE0 - movs r3, 0 - bl LoadBgTiles - b _08167B7E - .pool -_08167A5C: - ldr r0, =gUnknown_0203BCA8 - ldr r1, [r0] - movs r2, 0xA0 - lsls r2, 3 - movs r0, 0x3 - movs r3, 0 - bl LoadBgTilemap - b _08167B7E - .pool -_08167A74: - ldr r0, =gUnknown_085DFA60 - movs r1, 0xD0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b0e - adds r0, r1 - ldr r1, =0x0000ffb0 - strh r1, [r0] - b _08167B7E - .pool -_08167A9C: - ldr r0, =gUsePokeblockGraph_Gfx - ldr r1, =gUnknown_0203BCA4 -_08167AA0: - ldr r1, [r1] - bl LZ77UnCompVram - b _08167B7E - .pool -_08167AB0: - ldr r0, =gUsePokeblockGraph_Tilemap - ldr r1, =gUnknown_0203BCA0 - ldr r1, [r1] - bl LZ77UnCompVram - ldr r0, =gUsePokeblockGraph_Pal - movs r1, 0x20 - movs r2, 0x20 - bl LoadPalette - b _08167B7E - .pool -_08167AD4: - ldr r0, =gUnknown_0203BCA4 - ldr r1, [r0] - movs r2, 0xD0 - lsls r2, 5 - movs r3, 0xA0 - lsls r3, 2 - movs r0, 0x1 - bl LoadBgTiles - b _08167B7E - .pool -_08167AEC: - ldr r0, =gUnknown_0203BCA0 - ldr r1, [r0] - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, =gUsePokeblockNatureWin_Pal - movs r0, 0xC - str r0, [sp] - movs r0, 0x4 - str r0, [sp, 0x4] - movs r0, 0x1 - movs r2, 0 - movs r3, 0xD - bl CopyToBgTilemapBufferRect - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - b _08167B7E - .pool -_08167B1C: - ldr r0, =gUnknown_085DFC0C - ldr r1, =gUnknown_0203BCAC - ldr r1, [r1] - ldr r2, =0x00007304 - adds r1, r2 - bl LZ77UnCompVram - b _08167B7E - .pool -_08167B38: - ldr r0, =gUnknown_0203BCAC - ldr r1, [r0] - ldr r0, =0x00007304 - adds r1, r0 - movs r2, 0xA0 - lsls r2, 3 - movs r0, 0x2 - movs r3, 0 - bl LoadBgTilemap - ldr r0, =gUnknown_086231E8 - movs r1, 0x30 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_08623208 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r0, 0x2 - bl sub_81D21DC - b _08167B7E - .pool -_08167B78: - movs r0, 0 - strb r0, [r1] - b _08167B8E -_08167B7E: - ldr r0, =gUnknown_0203BCAC - ldr r1, [r0] - ldr r2, =0x00008048 - adds r1, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r0, 0x1 -_08167B8E: - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8167930 - thumb_func_start sub_8167BA0 sub_8167BA0: @ 8167BA0 push {r4-r7,lr} diff --git a/data/use_pokeblock.s b/data/use_pokeblock.s index c257961d3..dc2c7bd70 100644 --- a/data/use_pokeblock.s +++ b/data/use_pokeblock.s @@ -48,10 +48,10 @@ sContestStatNames:: @ 85DFD04 .4byte gText_Cuteness .4byte gText_Beauty3 -gUnknown_085DFD18:: @ 85DFD18 +gSpriteSheet_ConditionUpDown:: @ 85DFD18 obj_tiles gUsePokeblockUpDown_Gfx, 0x200, 0 -gUnknown_085DFD20:: @ 85DFD20 +gSpritePalette_ConditionUpDown:: @ 85DFD20 obj_pal gUsePokeblockUpDown_Pal, 0 gUnknown_085DFD28:: @ 85DFD28 @@ -79,7 +79,7 @@ gUnknown_085DFD54:: @ 85DFD54 .4byte gUnknown_085DFD44 .4byte gUnknown_085DFD4C -gUnknown_085DFD5C:: @ 85DFD5C +gSpriteTemplate_085DFD5C:: @ 85DFD5C spr_template 0, 0, gUnknown_085DFD3C, gUnknown_085DFD54, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy gUnknown_085DFD74:: @ 85DFD74 diff --git a/include/graphics.h b/include/graphics.h index f7eaa394d..47962110d 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4762,6 +4762,11 @@ extern const u32 gBattleAnimBackgroundImageMuddyWater_Pal[]; extern const u32 gBattleAnimFogTilemap[]; +extern const u32 gUsePokeblockGraph_Gfx[]; +extern const u32 gUsePokeblockGraph_Tilemap[]; +extern const u16 gUsePokeblockGraph_Pal[]; +extern const u16 gUsePokeblockNatureWin_Pal[]; + // Berry blender extern const u32 gBerryBlenderArrowTiles[]; extern const u32 gBerryBlenderStartTiles[]; diff --git a/include/strings.h b/include/strings.h index 74f3ca727..2c3d966b7 100644 --- a/include/strings.h +++ b/include/strings.h @@ -9,6 +9,11 @@ extern const u8 gText_OpenLevel[]; extern const u8 gText_Mom[]; extern const u8 gText_Dad[]; +extern const u8 gText_GetsAPokeBlockQuestion[]; +extern const u8 gText_WontEatAnymore[]; +extern const u8 gText_WasEnhanced[]; +extern const u8 gText_NothingChanged[]; + extern const u8 gText_Cool[]; extern const u8 gText_Beauty[]; extern const u8 gText_Cute[]; diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 762019ecd..baf86eb17 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -9,6 +9,15 @@ #include "bg.h" #include "window.h" #include "text_window.h" +#include "constants/rgb.h" +#include "sound.h" +#include "constants/songs.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "menu.h" +#include "gpu_regs.h" +#include "graphics.h" struct UsePokeblockSubStruct { @@ -28,12 +37,29 @@ struct UsePokeblockSubStruct u8 field_5c[5]; u8 field_61[5]; s16 field_66[5]; + u8 field_76; + u8 field_77; + u8 field_78; + u8 field_79; + u8 (*funcPtr8044) (void); + u8 field_8048; }; struct UsePokeblockStruct { - u8 field_0[0x7C58]; - u8 field_7C58[0x378]; + u8 field_0[0x7B0E]; + u16 field_7B0E; + u8 field_7B10[0x148]; + u8 field_7C58[0x35B]; + u8 field_7FB3; + u8 field_7FB4; + u8 field_7FB5; + u8 field_7FB6; + u8 field_7FB7; + u8 field_7FB8; + u8 field_7FB9; + u16 field_7FBA; + u8 field_7FBC[0x14]; struct UsePokeblockSubStruct info; }; @@ -54,9 +80,59 @@ bool8 sub_8168328(void); bool8 sub_8167930(void); void sub_8167608(u8 arg0); void sub_8167BA0(u16 arg0, u8 copyToVramMode); +void sub_8166634(void); +void sub_8167CA0(bool8); +extern void sub_81D3520(u8*); +void sub_8166BEC(void); +void sub_8166D44(void); +s8 sub_8166DE4(void); +bool8 sub_8167268(void); +void sub_8166F50(void); +void sub_816681C(void); +void sub_8166F94(void); +u8 sub_81672A4(u8 a0); +void sub_8166A34(void); +void sub_8167104(void); +void sub_8167338(void); +extern void sub_81D2074(void); +void sub_81681F4(u8); +void sub_8166E24(void); +bool8 sub_8166EDC(void); +void sub_81D354C(u8*); +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2); +void Pokeblock_MenuWindowTextPrint(const u8 *message); +void sub_8167184(struct Pokeblock *, struct Pokemon *); +extern u32 sub_81D2C68(s32, s32, s32, u8 *); +void sub_81673DC(struct Sprite *sprite); +void sub_81674BC(void); +void sub_816753C(s16, u8); +extern void sub_81D2ED4(u8, u8, u16, u8, u8, u8, u8); +extern void sub_81D2F78(u8, u8, s16, u16, u8, u8, u8, u8); +extern void sub_81D3094(u8, u8, s16, u16, u8, u8, u8); +extern void sub_81D31D0(struct SpritePalette *, struct SpritePalette *, struct SpritePalette *); +extern void sub_81D321C(struct SpriteSheet *, struct SpriteTemplate *, struct SpritePalette*); +void sub_8168180(void); +void sub_81681B4(void); +extern void sub_81D32B0(struct SpriteSheet *, struct SpritePalette*); +extern void sub_81D21DC(u8); extern const struct BgTemplate gUnknown_085DFCCC[4]; extern const struct WindowTemplate gUnknown_085DFCDC[]; +extern u16 gSpecialVar_ItemId; +extern const struct WindowTemplate sUsePokeblockYesNoWinTemplate[]; +extern const u8* sContestStatNames[]; +extern const u32 gUnknown_085DFCB0[]; +extern const u8 gUnknown_085DFCC4[]; +extern const struct SpriteSheet gSpriteSheet_ConditionUpDown; +extern const struct SpritePalette gSpritePalette_ConditionUpDown; +extern const struct SpriteTemplate gSpriteTemplate_085DFD5C; +extern const s16 gUnknown_085DFD28[][2]; +extern const u32 gUnknown_085DFB60[]; +extern const u32 gUnknown_085DFA80[]; +extern const u32 gUnknown_085DFA60[]; +extern const u32 gUnknown_085DFC0C[]; +extern const u16 gUnknown_086231E8[]; +extern const u16 gUnknown_08623208[]; // ram variables EWRAM_DATA struct UsePokeblockSubStruct *gUnknown_0203BC90 = NULL; @@ -228,3 +304,1970 @@ void sub_8166380(void) break; } } + +#ifdef NONMATCHING +void sub_8166564(void) +{ + switch (gUnknown_0203BC90->field_50) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); + SetVBlankCallback(sub_8166340); + ShowBg(0); + ShowBg(1); + ShowBg(3); + ShowBg(2); + gUnknown_0203BC90->field_50++; + break; + case 1: + if (!gPaletteFade.active) { + sub_81D3464((&gUnknown_0203BCAC + 0x7b1c)); + if (*(&gUnknown_0203BCAC + 0x8041) != *(&gUnknown_0203BCAC + 0x8040) - 1){ + sub_81D3480(*(&gUnknown_0203BCAC - 0x7b1c), *(&gUnknown_0203BCAC + 0x7b1c - 0xC), *(&gUnknown_0203BCAC + 0x8041 - 0x91) + *(&gUnknown_0203BCAC + 0x7fb3)); + } + else { + sub_816636C(sub_8166634); + } + } + break; + } +} + +#else +NAKED +void sub_8166564(void) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + sub sp, 0x4\n\ + ldr r4, =gUnknown_0203BC90\n\ + ldr r0, [r4]\n\ + adds r0, 0x50\n\ + ldrb r1, [r0]\n\ + cmp r1, 0\n\ + beq _08166580\n\ + cmp r1, 0x1\n\ + beq _081665C0\n\ + b _08166610\n\ + .pool\n\ +_08166580:\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + movs r2, 0x10\n\ + movs r3, 0\n\ + bl BeginNormalPaletteFade\n\ + ldr r0, =sub_8166340\n\ + bl SetVBlankCallback\n\ + movs r0, 0\n\ + bl ShowBg\n\ + movs r0, 0x1\n\ + bl ShowBg\n\ + movs r0, 0x3\n\ + bl ShowBg\n\ + movs r0, 0x2\n\ + bl ShowBg\n\ + ldr r1, [r4]\n\ + adds r1, 0x50\n\ + ldrb r0, [r1]\n\ + adds r0, 0x1\n\ + strb r0, [r1]\n\ + b _08166610\n\ + .pool\n\ +_081665C0:\n\ + ldr r0, =gPaletteFade\n\ + ldrb r1, [r0, 0x7]\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08166610\n\ + ldr r4, =gUnknown_0203BCAC\n\ + ldr r0, [r4]\n\ + ldr r1, =0x00007b1c\n\ + adds r0, r1\n\ + bl sub_81D3464\n\ + ldr r4, [r4]\n\ + ldr r2, =0x00008041\n\ + adds r0, r4, r2\n\ + ldrb r1, [r0]\n\ + ldr r3, =0x00008040\n\ + adds r0, r4, r3\n\ + ldrb r0, [r0]\n\ + subs r0, 0x1\n\ + cmp r1, r0\n\ + beq _0816660A\n\ + ldr r1, =0x00007fb3\n\ + adds r0, r4, r1\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + subs r2, 0x91\n\ + adds r0, r4, r2\n\ + adds r0, r1\n\ + ldrb r2, [r0]\n\ + ldr r3, =0x00007b1c\n\ + adds r0, r4, r3\n\ + subs r3, 0xC\n\ + adds r1, r4, r3\n\ + ldrb r1, [r1]\n\ + bl sub_81D3480\n\ +_0816660A:\n\ + ldr r0, =sub_8166634\n\ + bl sub_816636C\n\ +_08166610:\n\ + add sp, 0x4\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_8166634(void) +{ + u8 var; + switch (gUnknown_0203BC90->field_50) + { + case 0: + if (gMain.heldKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + sub_8167CA0(TRUE); + sub_81D3520(&gUnknown_0203BCAC->field_0[0x7B1C]); + gUnknown_0203BC90->field_50 = 1; + } + else if (gMain.heldKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + sub_8167CA0(FALSE); + sub_81D3520(&gUnknown_0203BCAC->field_0[0x7B1C]); + gUnknown_0203BC90->field_50 = 1; + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_0203BC90->field_50 = 3; + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if (gUnknown_0203BCAC->info.field_77 == gUnknown_0203BCAC->info.field_76 - 1) + { + gUnknown_0203BC90->field_50 = 3; + } + else + { + gUnknown_0203BC90->field_50 = 5; + } + } + + break; + case 1: + var = gUnknown_0203BCAC->info.funcPtr8044(); + if(!var) + gUnknown_0203BC90->field_50 = var; + break; + case 2: + break; + case 3: + sub_816636C(sub_8166BEC); + break; + case 4: + break; + case 5: + sub_8166D44(); + gUnknown_0203BC90->field_50++; + break; + case 6: + switch (sub_8166DE4()) + { + case 1: + case -1: + gUnknown_0203BC90->field_50 = 0; + break; + case 0: + if (sub_8167268()) + { + sub_8166F50(); + gUnknown_0203BC90->field_50 = 7; + } + else + { + sub_816636C(sub_816681C); + } + break; + } + break; + case 7: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8166F94(); + gUnknown_0203BC90->field_50 = 0; + } + break; + } +} + +void sub_816681C(void) +{ + switch (gUnknown_0203BC90->field_50) + { + case 0: + gPokeblockMonId = sub_81672A4(gUnknown_0203BCAC->info.field_77); + gUnknown_0203BC94 = gUnknown_0203BC90->callback; + gUnknown_0203BC98 = gUnknown_0203BC90->pokeblock; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); + gUnknown_0203BC90->field_50++; + break; + case 1: + if (!gPaletteFade.active) + { + SetVBlankCallback(NULL); + Free(gUnknown_0203BCA0); + gUnknown_0203BCA0 = NULL; + Free(gUnknown_0203BCA4); + gUnknown_0203BCA4 = NULL; + Free(gUnknown_0203BCA8); + gUnknown_0203BCA8 = NULL; + Free(gUnknown_0203BCAC); + gUnknown_0203BCAC = NULL; + FreeAllWindowBuffers(); + gMain.savedCallback = CB2_ReturnAndChooseMonToGivePokeblock; + CB2_PreparePokeblockFeedScene(); + } + break; + } +} + +void sub_81668F8(void) +{ + switch (gUnknown_0203BC90->field_50) + { + u16 var; + case 0: + if (gUnknown_0203BCAC->info.field_77 != gPokeblockMonId) + { + sub_8167CA0(gUnknown_0203BC90->field_56); + gUnknown_0203BC90->field_50++; + } + else + { + gUnknown_0203BC90->field_50 = 3; + } + break; + case 1: + var = gUnknown_0203BCAC->info.funcPtr8044(); + if (!var) + { + gUnknown_0203BC90->field_50 = var; + } + break; + case 2: + break; + case 3: + BlendPalettes(0xFFFFFFFF, 16, RGB(0, 0, 0)); + gUnknown_0203BC90->field_50++; + break; + case 4: + ShowBg(0); + ShowBg(1); + ShowBg(3); + ShowBg(2); + gUnknown_0203BC90->field_50++; + break; + case 5: + SetVBlankCallback(sub_8166340); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); + gUnknown_0203BC90->field_50++; + break; + case 6: + if (!gPaletteFade.active) + { + sub_81D3464(&gUnknown_0203BCAC->field_0[0x7B1C]); + sub_816636C(sub_8166A34); + SetMainCallback2(sub_816631C); + } + break; + } +} + +#ifdef NONMATCHING +void sub_8166A34(void) +{ + switch (gUnknown_0203BC90->field_50) + { + u8 var; + case 0: + gUnknown_0203BC90->field_5c[0] = (u8) &gPlayerParty; + gUnknown_0203BCAC->info.field_77 = (u32) &gUnknown_0203BCAC->field_0[gUnknown_0203BCAC->info.field_77]; + gUnknown_0203BC90->field_5c[0] = &gPlayerParty + sub_81D3520(&gUnknown_0203BCAC->field_0[0x7B1C]); + /*gUnknown_0203BCAC->pokemon = &gPlayerParty[gUnknown_083DFEC4->unk893c[gUnknown_0203BCAC->field_0[0x7B1C]].partyIdx]; + move_anim_execute();*/ + gUnknown_0203BC90->field_50++; + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + gUnknown_0203BC90->field_50++; + break; + case 2: + sub_8167104(); + sub_81D2754(gUnknown_0203BC90->field_5c, &gUnknown_0203BCAC->field_7C58[0x50]); + sub_81D1F84(&gUnknown_0203BCAC->field_7C58[0], &gUnknown_0203BCAC->field_7C58[gUnknown_0203BCAC->field_7C58[0x35B] + 0x14], 0); + sub_8167338(); + gUnknown_0203BC90->field_50++; + break; + case 3: + var = gUnknown_0203BCAC->field_7C58[0]; + sub_81D2074(); + if (!var) + { + sub_81681F4(sub_81672A4(gUnknown_0203BCAC->info.field_77)); + /*sub_80F3D00(); + gUnknown_0203BCAC->unk52 = 0;*/ + if(gUnknown_0203BCAC->info.field_77 == gUnknown_0203BCAC->info.field_76 - 1) + { + gUnknown_0203BC90->field_52 = var; + } + + sub_81D3480(&gUnknown_0203BCAC->field_7C58[0x35B], gUnknown_0203BCAC->field_7C58[0x35B + gUnknown_0203BCAC->field_7C58[0x358]]); + + } + break; + case 4: + if ((++gUnknown_0203BC90->field_52) > 16) + { + sub_8166E24(); + gUnknown_0203BC90->field_50++; + } + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8166EDC()) + { + TryClearPokeblock((u8)gSpecialVar_ItemId); + sub_816636C(sub_8166BEC); + } + break; + } +} +#else +NAKED +void sub_8166A34(void) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + ldr r1, =gUnknown_0203BC90\n\ + ldr r0, [r1]\n\ + adds r0, 0x50\n\ + ldrb r0, [r0]\n\ + adds r5, r1, 0\n\ + cmp r0, 0x5\n\ + bls _08166A46\n\ + b _08166BDA\n\ +_08166A46:\n\ + lsls r0, 2\n\ + ldr r1, =_08166A58\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .pool\n\ + .align 2, 0\n\ +_08166A58:\n\ + .4byte _08166A70\n\ + .4byte _08166AAC\n\ + .4byte _08166AC0\n\ + .4byte _08166B14\n\ + .4byte _08166B94\n\ + .4byte _08166BB6\n\ +_08166A70:\n\ + ldr r4, [r5]\n\ + ldr r3, =gPlayerParty\n\ + str r3, [r4, 0xC]\n\ + ldr r0, =gUnknown_0203BCAC\n\ + ldr r0, [r0]\n\ + ldr r2, =0x00008041\n\ + adds r1, r0, r2\n\ + ldrb r1, [r1]\n\ + lsls r1, 2\n\ + adds r1, r0, r1\n\ + subs r2, 0x88\n\ + adds r1, r2\n\ + ldrb r2, [r1]\n\ + movs r1, 0x64\n\ + muls r1, r2\n\ + adds r1, r3\n\ + str r1, [r4, 0xC]\n\ + ldr r3, =0x00007b1c\n\ + adds r0, r3\n\ + bl sub_81D3520\n\ + b _08166BAA\n\ + .pool\n\ +_08166AAC:\n\ + ldr r0, =gMain\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x3\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08166ABA\n\ + b _08166BDA\n\ +_08166ABA:\n\ + b _08166BAA\n\ + .pool\n\ +_08166AC0:\n\ + bl sub_8167104\n\ + ldr r6, =gUnknown_0203BC90\n\ + ldr r0, [r6]\n\ + adds r0, 0x5C\n\ + ldr r4, =gUnknown_0203BCAC\n\ + ldr r1, [r4]\n\ + ldr r5, =0x00007ca8\n\ + adds r1, r5\n\ + bl sub_81D2754\n\ + ldr r2, [r4]\n\ + ldr r4, =0x00007c58\n\ + adds r0, r2, r4\n\ + ldr r3, =0x00007fb3\n\ + adds r1, r2, r3\n\ + movs r3, 0\n\ + ldrsb r3, [r1, r3]\n\ + lsls r1, r3, 2\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r4, 0x14\n\ + adds r1, r4\n\ + adds r1, r2, r1\n\ + adds r2, r5\n\ + bl sub_81D1F84\n\ + bl sub_8167338\n\ + ldr r1, [r6]\n\ + b _08166BAC\n\ + .pool\n\ +_08166B14:\n\ + ldr r5, =gUnknown_0203BCAC\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00007c58\n\ + adds r0, r1\n\ + bl sub_81D2074\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + cmp r6, 0\n\ + bne _08166BDA\n\ + ldr r0, [r5]\n\ + ldr r4, =0x00008041\n\ + adds r0, r4\n\ + ldrb r0, [r0]\n\ + bl sub_81672A4\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl sub_81681F4\n\ + ldr r3, [r5]\n\ + adds r4, r3, r4\n\ + ldrb r1, [r4]\n\ + ldr r2, =0x00008040\n\ + adds r0, r3, r2\n\ + ldrb r0, [r0]\n\ + subs r0, 0x1\n\ + cmp r1, r0\n\ + beq _08166B6C\n\ + ldr r4, =0x00007fb3\n\ + adds r0, r3, r4\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + subs r2, 0x90\n\ + adds r0, r3, r2\n\ + adds r0, r1\n\ + ldrb r2, [r0]\n\ + ldr r4, =0x00007b1c\n\ + adds r0, r3, r4\n\ + subs r4, 0xC\n\ + adds r1, r3, r4\n\ + ldrb r1, [r1]\n\ + bl sub_81D3480\n\ +_08166B6C:\n\ + ldr r1, =gUnknown_0203BC90\n\ + ldr r0, [r1]\n\ + adds r0, 0x52\n\ + strb r6, [r0]\n\ + ldr r1, [r1]\n\ + b _08166BAC\n\ + .pool\n\ +_08166B94:\n\ + ldr r1, [r5]\n\ + adds r1, 0x52\n\ + ldrb r0, [r1]\n\ + adds r0, 0x1\n\ + strb r0, [r1]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x10\n\ + bls _08166BDA\n\ + bl sub_8166E24\n\ +_08166BAA:\n\ + ldr r1, [r5]\n\ +_08166BAC:\n\ + adds r1, 0x50\n\ + ldrb r0, [r1]\n\ + adds r0, 0x1\n\ + strb r0, [r1]\n\ + b _08166BDA\n\ +_08166BB6:\n\ + ldr r0, =gMain\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x3\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08166BDA\n\ + bl sub_8166EDC\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08166BDA\n\ + ldr r0, =gSpecialVar_ItemId\n\ + ldrb r0, [r0]\n\ + bl TryClearPokeblock\n\ + ldr r0, =sub_8166BEC\n\ + bl sub_816636C\n\ +_08166BDA:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_8166BEC(void) +{ + u8 i; + u8 var; + switch (gUnknown_0203BC90->field_50) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); + gUnknown_0203BC90->field_50++; + break; + case 1: + if (!gPaletteFade.active) + { + gUnknown_0203BC90->field_50 = 2; + } + break; + case 2: + gScanlineEffect.state = 3; + ScanlineEffect_InitHBlankDmaTransfer(); + gUnknown_0203BC90->field_50++; + break; + case 3: + SetMainCallback2(gUnknown_0203BC90->callback); + sub_81D354C(&gUnknown_0203BCAC->field_0[0x7B1C]); + for(i = 0; i < 7; i++) + { + DestroySprite(&gSprites[gUnknown_0203BCAC->field_0[0x7B06 + i]]); + } + + FreeSpriteTilesByTag(0); + FreeSpriteTilesByTag(1); + FreeSpriteTilesByTag(0); + FreeSpriteTilesByTag(1); + + for(i = 0; i < 2; i++) + { + DestroySprite(&gUnknown_0203BCAC->sprite7B44[i*4]); + } + + if(gUnknown_0203BCAC->field_0[0x7B10] != 255) + { + DestroySprite(&gSprites[gUnknown_0203BCAC->field_0[0x7B10]]); + return; + + } + + SetVBlankCallback(NULL); + Free(gUnknown_0203BCA0); + gUnknown_0203BCA0 = NULL; + Free(gUnknown_0203BCA4); + gUnknown_0203BCA0 = NULL; + Free(gUnknown_0203BCA8); + gUnknown_0203BCA8 = NULL; + Free(gUnknown_0203BCAC); + gUnknown_0203BCAC = NULL; + FreeAllWindowBuffers(); + break; + } +} +#else +NAKED +void sub_8166BEC(void) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + sub sp, 0x4\n\ + ldr r4, =gUnknown_0203BC90\n\ + ldr r0, [r4]\n\ + adds r2, r0, 0\n\ + adds r2, 0x50\n\ + ldrb r1, [r2]\n\ + cmp r1, 0x1\n\ + beq _08166C28\n\ + cmp r1, 0x1\n\ + bgt _08166C0C\n\ + cmp r1, 0\n\ + beq _08166C16\n\ + b _08166D18\n\ + .pool\n\ +_08166C0C:\n\ + cmp r1, 0x2\n\ + beq _08166C40\n\ + cmp r1, 0x3\n\ + beq _08166C5C\n\ + b _08166D18\n\ +_08166C16:\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + movs r2, 0\n\ + movs r3, 0x10\n\ + bl BeginNormalPaletteFade\n\ + b _08166C4A\n\ +_08166C28:\n\ + ldr r0, =gPaletteFade\n\ + ldrb r1, [r0, 0x7]\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08166D18\n\ + movs r0, 0x2\n\ + strb r0, [r2]\n\ + b _08166D18\n\ + .pool\n\ +_08166C40:\n\ + ldr r1, =gScanlineEffect\n\ + movs r0, 0x3\n\ + strb r0, [r1, 0x15]\n\ + bl ScanlineEffect_InitHBlankDmaTransfer\n\ +_08166C4A:\n\ + ldr r1, [r4]\n\ + adds r1, 0x50\n\ + ldrb r0, [r1]\n\ + adds r0, 0x1\n\ + strb r0, [r1]\n\ + b _08166D18\n\ + .pool\n\ +_08166C5C:\n\ + ldr r0, [r0, 0x4]\n\ + bl SetMainCallback2\n\ + ldr r0, =gUnknown_0203BCAC\n\ + ldr r0, [r0]\n\ + ldr r1, =0x00007b1c\n\ + adds r0, r1\n\ + bl sub_81D354C\n\ + movs r4, 0\n\ +_08166C70:\n\ + ldr r5, =gUnknown_0203BCAC\n\ + ldr r0, [r5]\n\ + ldr r2, =0x00007b06\n\ + adds r0, r2\n\ + adds r0, r4\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, =gSprites\n\ + adds r0, r1\n\ + bl DestroySprite\n\ + adds r0, r4, 0x1\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r4, 0x6\n\ + bls _08166C70\n\ + movs r0, 0\n\ + bl FreeSpriteTilesByTag\n\ + movs r0, 0x1\n\ + bl FreeSpriteTilesByTag\n\ + movs r0, 0\n\ + bl FreeSpritePaletteByTag\n\ + movs r0, 0x1\n\ + bl FreeSpritePaletteByTag\n\ + movs r4, 0\n\ +_08166CAE:\n\ + ldr r0, [r5]\n\ + lsls r1, r4, 2\n\ + ldr r2, =0x00007b44\n\ + adds r0, r2\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + bl DestroySprite\n\ + adds r0, r4, 0x1\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r4, 0x1\n\ + bls _08166CAE\n\ + ldr r6, =gUnknown_0203BCAC\n\ + ldr r0, [r6]\n\ + ldr r2, =0x00007b10\n\ + adds r1, r0, r2\n\ + ldrb r0, [r1]\n\ + cmp r0, 0xFF\n\ + beq _08166CE6\n\ + adds r1, r0, 0\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, =gSprites\n\ + adds r0, r1\n\ + bl DestroySprite\n\ +_08166CE6:\n\ + movs r0, 0\n\ + bl SetVBlankCallback\n\ + ldr r4, =gUnknown_0203BCA0\n\ + ldr r0, [r4]\n\ + bl Free\n\ + movs r5, 0\n\ + str r5, [r4]\n\ + ldr r4, =gUnknown_0203BCA4\n\ + ldr r0, [r4]\n\ + bl Free\n\ + str r5, [r4]\n\ + ldr r4, =gUnknown_0203BCA8\n\ + ldr r0, [r4]\n\ + bl Free\n\ + str r5, [r4]\n\ + ldr r0, [r6]\n\ + bl Free\n\ + str r5, [r6]\n\ + bl FreeAllWindowBuffers\n\ +_08166D18:\n\ + add sp, 0x4\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_8166D44(void) +{ + u8 stringBuffer[0x40]; + GetMonData(&gPlayerParty[sub_81672A4(gUnknown_0203BCAC->info.field_77)], MON_DATA_NICKNAME, stringBuffer); + StringGetEnd10(stringBuffer); + StringAppend(stringBuffer, gText_GetsAPokeBlockQuestion); + StringCopy(gStringVar4, stringBuffer); + FillWindowPixelBuffer(2, 17); + sub_8098858(2, 151, 14); + AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); + PutWindowTilemap(2); + CopyWindowToVram(2, 3); + CreateYesNoMenu(sUsePokeblockYesNoWinTemplate, 151, 14, 0); +} + +s8 sub_8166DE4(void) +{ + s8 retval = Menu_ProcessInputNoWrapClearOnChoose(); + switch(retval) + { + case 0: + break; + case -1: + case 1: + PlaySE(SE_SELECT); + rbox_fill_rectangle(2); + ClearWindowTilemap(2); + break; + + } + return retval; +} + +void sub_8166E24(void) +{ + sub_8098858(2, 151, 14); + FillWindowPixelBuffer(2, 17); + + for (gUnknown_0203BC90->field_53 = 0; gUnknown_0203BC90->field_53 < 5 && gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] == 0; gUnknown_0203BC90->field_53++); + + if (gUnknown_0203BC90->field_53 < 5) + { + Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]); + } + else + { + Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, 0); + } + + Pokeblock_MenuWindowTextPrint(gStringVar4); + PutWindowTilemap(2); + CopyWindowToVram(2, 3); +} + +bool8 sub_8166EDC(void) +{ + FillWindowPixelBuffer(2, 17); + + while (1) + { + gUnknown_0203BC90->field_53++; + if (gUnknown_0203BC90->field_53 < 5) + { + if (gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] != 0) + break; + } + else + { + gUnknown_0203BC90->field_53 = 5; + return FALSE; + } + } + + Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]); + Pokeblock_MenuWindowTextPrint(gStringVar4); + CopyWindowToVram(2, 2); + + return TRUE; +} + +void sub_8166F50(void) +{ + FillWindowPixelBuffer(2, 17); + sub_8098858(2, 151, 14); + AddTextPrinterParameterized(2, 1, gText_WontEatAnymore, 0, 1, 0, NULL); + PutWindowTilemap(2); + CopyWindowToVram(2, 3); +} + +void sub_8166F94(void) +{ + rbox_fill_rectangle(2); + ClearWindowTilemap(2); + CopyWindowToVram(2, 3); +} + +void Pokeblock_MenuWindowTextPrint(const u8 *message) +{ + AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); +} + +#ifdef NONMATCHING +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +{ + if (a2 != 0) + { + if(a2 > 0) + { + statID = 0; + } + + StringCopy(dest, sContestStatNames[statID]); + StringAppend(dest, gText_WasEnhanced); + } + else + { + StringCopy(dest, gText_NothingChanged); + } +} +#else +NAKED +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +{ + asm(".syntax unified\n\ +push {r4,lr}\n\ + adds r4, r0, 0\n\ + lsls r1, 24\n\ + lsrs r3, r1, 24\n\ + lsls r2, 16\n\ + lsrs r0, r2, 16\n\ + asrs r2, 16\n\ + cmp r2, 0\n\ + beq _08167010\n\ + cmp r2, 0\n\ + ble _08166FEC\n\ + movs r0, 0\n\ +_08166FEC:\n\ + lsls r0, 16\n\ + ldr r1, =sContestStatNames\n\ + lsls r0, r3, 2\n\ + adds r0, r1\n\ + ldr r1, [r0]\n\ + adds r0, r4, 0\n\ + bl StringCopy\n\ + ldr r1, =gText_WasEnhanced\n\ + adds r0, r4, 0\n\ + bl StringAppend\n\ + b _08167018\n\ + .pool\n\ +_08167010:\n\ + ldr r1, =gText_NothingChanged\n\ + adds r0, r4, 0\n\ + bl StringCopy\n\ +_08167018:\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void Pokeblock_GetMonContestStats(struct Pokemon *pokemon, u8 *data) +{ + u16 i = 0; + + for (; i < 5; i++) + { + data[i] = GetMonData(pokemon, gUnknown_085DFCB0[i]); + } +} + +void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +{ + u16 i; + s16 cstat; + u8 data; + if (GetMonData(pokemon, MON_DATA_SHEEN) != 255) + { + sub_8167184(pokeblock, pokemon); + for (i=0; i<5; i++) + { + data = GetMonData(pokemon, gUnknown_085DFCB0[i]); + cstat = data + gUnknown_0203BC90->field_66[i]; + if (cstat < 0) + cstat = 0; + if (cstat > 255) + cstat = 255; + data = cstat; + SetMonData(pokemon, gUnknown_085DFCB0[i], &data); + } + cstat = (u8)GetMonData(pokemon, MON_DATA_SHEEN); + cstat = cstat + pokeblock->feel; + if (cstat > 255) + cstat = 255; + data = cstat; + SetMonData(pokemon, MON_DATA_SHEEN, &data); + } +} + +void sub_8167104(void) +{ + u16 i; + struct Pokemon *pokemon = gPlayerParty; + pokemon += gUnknown_0203BCAC->field_7C58[gUnknown_0203BCAC->info.field_77 * 4 + 865]; + Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_57); + sub_8167054(gUnknown_0203BC90->pokeblock, pokemon); + Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_5c); + for (i=0; i<5; i++) + { + gUnknown_0203BC90->field_61[i] = gUnknown_0203BC90->field_5c[i] - gUnknown_0203BC90->field_57[i]; + } +} + +void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +{ + s8 direction; + s8 i; + s16 amount; + s8 boost; + s8 taste; + gUnknown_0203BC90->field_66[0] = pokeblock->spicy; + gUnknown_0203BC90->field_66[1] = pokeblock->sour; + gUnknown_0203BC90->field_66[2] = pokeblock->bitter; + gUnknown_0203BC90->field_66[3] = pokeblock->sweet; + gUnknown_0203BC90->field_66[4] = pokeblock->dry; + if (gPokeblockGain > 0) + direction = 1; + else if (gPokeblockGain < 0) + direction = -1; + else + return; + for (i=0; i<5; i++) + { + amount = gUnknown_0203BC90->field_66[i]; + boost = amount / 10; + if (amount % 10 >= 5) // round to the nearest + boost++; + taste = GetMonFlavorRelation(pokemon, gUnknown_085DFCC4[i]); + if (taste == direction) + { + gUnknown_0203BC90->field_66[i] += boost * taste; + } + } +} + +bool8 sub_8167268(void) +{ + u8 *mon; + mon = (u8 *) &gUnknown_0203BCAC->field_0[gUnknown_0203BCAC->info.field_77 * 4]; + if (sub_81D2C68(*(mon + 864 + 0x7C58), *(mon + 865 + 0x7C58), MON_DATA_SHEEN, 0) == 255) + return TRUE; + return FALSE; +} + +u8 sub_81672A4(u8 a0) +{ + u8 i; + for (i=0; ifield_54 = 0; + for (flavor=0; flavor<5; flavor++) + { + if (gUnknown_0203BC90->field_61[flavor] != 0) + { + spriteidx = CreateSprite(&gSpriteTemplate_085DFD5C, gUnknown_085DFD28[flavor][0], gUnknown_085DFD28[flavor][1], 0); + if (spriteidx != MAX_SPRITES) + { + if (gUnknown_0203BC90->field_61[flavor] != 0) + { + gSprites[spriteidx].callback = sub_81673DC; + } + gUnknown_0203BC90->field_54++; + } + } + } +} + +void sub_81673DC(struct Sprite *sprite) +{ + if (sprite->data[0] <= 5) + sprite->pos2.y -= 2; + else if (sprite->data[0] <= 11) + sprite->pos2.y += 2; + if ((++sprite->data[0]) > 60) + { + DestroySprite(sprite); + gUnknown_0203BC90->field_54--; + } +} + +#ifdef NONMATCHING +void sub_8167420(void) +{ + u16 i; + u16 ct; + + for (i=0, ct=0; i < CalculatePlayerPartyCount(); i++) + { + if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) + { + *(&gUnknown_0203BCAC->field_7FB8 + ct * 4) = 14; + *(&gUnknown_0203BCAC->field_7FB9 + ct * 4)= i; + *(&gUnknown_0203BCAC->field_7FBA + ct * 2) = 0; + ct++; + } + } + gUnknown_0203BCAC->info.field_77 = 0; + gUnknown_0203BCAC->info.field_76 = ct + 1; + sub_81674BC(); +} +#else +NAKED +void sub_8167420(void) +{ + asm(".syntax unified\n\ +push {r4-r6,lr}\n\ + movs r4, 0\n\ + movs r5, 0\n\ + ldr r6, =gUnknown_0203BCAC\n\ + b _08167472\n\ + .pool\n\ +_08167430:\n\ + movs r0, 0x64\n\ + muls r0, r4\n\ + ldr r1, =gPlayerParty\n\ + adds r0, r1\n\ + movs r1, 0x2D\n\ + bl GetMonData\n\ + adds r3, r0, 0\n\ + cmp r3, 0\n\ + bne _0816746C\n\ + ldr r1, [r6]\n\ + lsls r2, r5, 2\n\ + adds r1, r2\n\ + ldr r0, =0x00007fb8\n\ + adds r1, r0\n\ + movs r0, 0xE\n\ + strb r0, [r1]\n\ + ldr r0, [r6]\n\ + adds r0, r2\n\ + ldr r1, =0x00007fb9\n\ + adds r0, r1\n\ + strb r4, [r0]\n\ + ldr r0, [r6]\n\ + adds r0, r2\n\ + ldr r2, =0x00007fba\n\ + adds r0, r2\n\ + strh r3, [r0]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ +_0816746C:\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ +_08167472:\n\ + bl CalculatePlayerPartyCount\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r4, r0\n\ + bcc _08167430\n\ + ldr r2, =gUnknown_0203BCAC\n\ + ldr r0, [r2]\n\ + ldr r1, =0x00008041\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r2]\n\ + adds r1, r5, 0x1\n\ + ldr r2, =0x00008040\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + bl sub_81674BC\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_81674BC(void) +{ + s16 var; + s16 var2; + + sub_816753C(gUnknown_0203BCAC->info.field_77, 0); + gUnknown_0203BCAC->field_7FB3 = 0; + gUnknown_0203BCAC->field_7FB4 = 1; + gUnknown_0203BCAC->field_7FB5 = 2; + + var = gUnknown_0203BCAC->info.field_77 + 1; + + if(var >= gUnknown_0203BCAC->info.field_76) + { + var = 0; + + } + + var2 = var - 1; + + if(var2 < 0) + { + var2 = gUnknown_0203BCAC->info.field_76 - 1; + } + + sub_816753C(var, 1); + sub_816753C(var2, 2); +} +#else +NAKED +void sub_81674BC(void) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + ldr r4, =gUnknown_0203BCAC\n\ + ldr r0, [r4]\n\ + ldr r5, =0x00008041\n\ + adds r0, r5\n\ + ldrb r0, [r0]\n\ + movs r1, 0\n\ + bl sub_816753C\n\ + ldr r0, [r4]\n\ + ldr r1, =0x00007fb3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r4]\n\ + ldr r2, =0x00007fb4\n\ + adds r0, r2\n\ + movs r1, 0x1\n\ + strb r1, [r0]\n\ + ldr r0, [r4]\n\ + ldr r1, =0x00007fb5\n\ + adds r0, r1\n\ + movs r1, 0x2\n\ + strb r1, [r0]\n\ + ldr r0, [r4]\n\ + adds r5, r0, r5\n\ + ldrb r3, [r5]\n\ + adds r1, r3, 0x1\n\ + adds r2, 0x8C\n\ + adds r0, r2\n\ + ldrb r2, [r0]\n\ + cmp r1, r2\n\ + blt _08167500\n\ + movs r1, 0\n\ +_08167500:\n\ + subs r0, r3, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r0, 0\n\ + bge _08167510\n\ + subs r0, r2, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ +_08167510:\n\ + adds r0, r1, 0\n\ + movs r1, 0x1\n\ + bl sub_816753C\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + movs r1, 0x2\n\ + bl sub_816753C\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_816753C(s16 a1, u8 a2) +{ + u8 *v3; + int v5; + int v6; + + v3 = &gUnknown_0203BCAC->field_0[a1 << 16 >> 14]; + v5 = *(0x7FB8 + v3); + v6 = *(0x7FB9 + v3); + + sub_81D2ED4(gUnknown_0203BCAC->field_0[0x7B4D + 24 * a2], gUnknown_0203BCAC->field_0[0x7B95 + 64 * a2], v5, v6, a1, gUnknown_0203BCAC->info.field_76, 0); + sub_81D2F78(gUnknown_0203BCAC->field_7C58[0], gUnknown_0203BCAC->field_0[0x7FB0], v5, v6, a1, a2, gUnknown_0203BCAC->info.field_76, 0); + sub_81D3094(gUnknown_0203BCAC->field_0[(a2 << 13) + 0x304], gUnknown_0203BCAC->field_0[(a2 << 7) + 4], v5, v6, a1, gUnknown_0203BCAC->info.field_76, 0); + //gUnknown_0203BCAC->field_0[0x7B4D + a1 * 40], gUnknown_0203BCAC->field_7FB8, gUnknown_0203BCAC->field_7FB9, gUnknown_203BCAC->field_0[0], gUnknown_203BCAC->info.field_76, 0) +} +#else +NAKED +void sub_816753C(s16 a1, u8 a2) +{ + 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, 0x10\n\ + adds r5, r0, 0\n\ + adds r4, r1, 0\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + ldr r0, =gUnknown_0203BCAC\n\ + mov r9, r0\n\ + ldr r1, [r0]\n\ + lsls r5, 16\n\ + asrs r0, r5, 14\n\ + adds r0, r1, r0\n\ + ldr r3, =0x00007fb8\n\ + adds r2, r0, r3\n\ + ldrb r7, [r2]\n\ + ldr r2, =0x00007fb9\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + mov r10, r0\n\ + adds r3, 0x88\n\ + adds r0, r1, r3\n\ + ldrb r6, [r0]\n\ + movs r0, 0\n\ + mov r8, r0\n\ + lsls r0, r4, 1\n\ + adds r0, r4\n\ + lsls r0, 3\n\ + ldr r2, =0x00007b4d\n\ + adds r0, r2\n\ + adds r0, r1, r0\n\ + lsls r2, r4, 6\n\ + ldr r3, =0x00007b95\n\ + adds r2, r3\n\ + adds r1, r2\n\ + lsrs r5, 16\n\ + str r5, [sp]\n\ + str r6, [sp, 0x4]\n\ + mov r2, r8\n\ + str r2, [sp, 0x8]\n\ + adds r2, r7, 0\n\ + mov r3, r10\n\ + bl sub_81D2ED4\n\ + mov r3, r9\n\ + ldr r1, [r3]\n\ + ldr r2, =0x00007c58\n\ + adds r0, r1, r2\n\ + ldr r3, =0x00007fb0\n\ + adds r1, r3\n\ + str r5, [sp]\n\ + str r4, [sp, 0x4]\n\ + str r6, [sp, 0x8]\n\ + mov r2, r8\n\ + str r2, [sp, 0xC]\n\ + adds r2, r7, 0\n\ + mov r3, r10\n\ + bl sub_81D2F78\n\ + lsls r0, r4, 13\n\ + movs r1, 0xC1\n\ + lsls r1, 2\n\ + adds r0, r1\n\ + mov r3, r9\n\ + ldr r1, [r3]\n\ + adds r0, r1, r0\n\ + lsls r4, 7\n\ + adds r4, 0x4\n\ + adds r1, r4\n\ + str r5, [sp]\n\ + str r6, [sp, 0x4]\n\ + mov r2, r8\n\ + str r2, [sp, 0x8]\n\ + adds r2, r7, 0\n\ + mov r3, r10\n\ + bl sub_81D3094\n\ + add sp, 0x10\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\n"); +} +#endif + +#ifdef NONMATCHING +void sub_8167608(u8 arg0) +{ + u8 v4; + u8 *v5; + u8 *v6; + u32 v7; + struct SpritePalette array[5]; + if(gUnknown_0203BCAC->field_0[0x7B10] == 255) + { + sub_81D31D0(&array[3], &array[0], &array[4]); + array[1] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 13) + 772]); + array[2] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 7) + 4]); + gUnknown_0203BCAC->field_0[0x7B12] = LoadSpritePalette(&array[3]); + gUnknown_0203BCAC->field_0[0x7B14] = LoadSpritePalette(&array[4]); + v4 = CreateSprite(array[0], 38, 104, 0); + gUnknown_0203BCAC->field_0[0x7B10] = v4; + if(v4 == 64) + { + FreeSpriteTilesByTag(100); + FreeSpritePaletteByTag(100); + gUnknown_0203BCAC->field_0[0x7B10] = 255; + } + else + { + gUnknown_0203BCAC->field_0[0x7B10] = v4; + v5 = &gUnknown_0203BCAC->field_0[0]; + v6 = &gUnknown_0203BCAC->field_0[0x7B10]; + gSprites[v6].callback = sub_8168168; + gSprites[v6].pos2.y -= 32; + *(v5+0x7B18) = 32 * *(v5+0x7B14) + 0x06010000; + *(v5+0x7B12) = 16 * *(v5+0x7B12) + 0x100; + } + } + else + { + v7 = gUnknown_0203BCAC->field_0[0x7B18]; + REG_ADDR_DMA3SAD = gUnknown_0203BCAC->field_0[(arg0 << 13) + 772]; + REG_ADDR_DMA3DAD = v7; + REG_ADDR_DMA3CNT = 0x80000400; + LoadPalette(gUnknown_0203BCAC->field_0[arg0 << 7) + 4), gUnknown_0203BCAC->field_0[0x7B12], 32); + } +} +#else +NAKED +void sub_8167608(u8 arg0) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x28\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + ldr r1, =gUnknown_0203BCAC\n\ + ldr r3, [r1]\n\ + ldr r0, =0x00007b10\n\ + mov r8, r0\n\ + adds r0, r3, r0\n\ + ldrb r0, [r0]\n\ + adds r7, r1, 0\n\ + cmp r0, 0xFF\n\ + bne _08167714\n\ + add r5, sp, 0x18\n\ + add r4, sp, 0x20\n\ + adds r0, r5, 0\n\ + mov r1, sp\n\ + adds r2, r4, 0\n\ + bl sub_81D31D0\n\ + lsls r0, r6, 13\n\ + movs r1, 0xC1\n\ + lsls r1, 2\n\ + adds r0, r1\n\ + ldr r1, [r7]\n\ + adds r0, r1, r0\n\ + str r0, [sp, 0x18]\n\ + lsls r0, r6, 7\n\ + adds r0, 0x4\n\ + adds r1, r0\n\ + str r1, [sp, 0x20]\n\ + adds r0, r4, 0\n\ + bl LoadSpritePalette\n\ + ldr r1, [r7]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + ldr r2, =0x00007b12\n\ + adds r1, r2\n\ + strh r0, [r1]\n\ + adds r0, r5, 0\n\ + bl LoadSpriteSheet\n\ + ldr r1, [r7]\n\ + ldr r3, =0x00007b14\n\ + adds r1, r3\n\ + strh r0, [r1]\n\ + mov r0, sp\n\ + movs r1, 0x26\n\ + movs r2, 0x68\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r1, r0, 24\n\ + ldr r0, [r7]\n\ + ldr r2, =0x00007b10\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + cmp r1, 0x40\n\ + bne _081676AC\n\ + movs r0, 0x64\n\ + bl FreeSpriteTilesByTag\n\ + movs r0, 0x64\n\ + bl FreeSpritePaletteByTag\n\ + ldr r0, [r7]\n\ + add r0, r8\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ + b _08167742\n\ + .pool\n\ +_081676AC:\n\ + ldr r0, [r7]\n\ + add r0, r8\n\ + strb r1, [r0]\n\ + ldr r4, =gSprites\n\ + ldr r2, [r7]\n\ + mov r0, r8\n\ + adds r3, r2, r0\n\ + ldrb r1, [r3]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r1, r4, 0\n\ + adds r1, 0x1C\n\ + adds r0, r1\n\ + ldr r1, =sub_8168168\n\ + str r1, [r0]\n\ + ldrb r1, [r3]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r4\n\ + ldrh r1, [r0, 0x26]\n\ + subs r1, 0x22\n\ + strh r1, [r0, 0x26]\n\ + ldr r3, =0x00007b18\n\ + adds r1, r2, r3\n\ + subs r3, 0x4\n\ + adds r0, r2, r3\n\ + ldrh r0, [r0]\n\ + lsls r0, 5\n\ + ldr r3, =0x06010000\n\ + adds r0, r3\n\ + str r0, [r1]\n\ + ldr r0, =0x00007b12\n\ + adds r2, r0\n\ + ldrh r0, [r2]\n\ + lsls r0, 4\n\ + movs r1, 0x80\n\ + lsls r1, 1\n\ + adds r0, r1\n\ + strh r0, [r2]\n\ + b _08167742\n\ + .pool\n\ +_08167714:\n\ + lsls r1, r6, 13\n\ + movs r0, 0xC1\n\ + lsls r0, 2\n\ + adds r1, r0\n\ + adds r1, r3, r1\n\ + ldr r2, =0x00007b18\n\ + adds r0, r3, r2\n\ + ldr r2, [r0]\n\ + ldr r0, =0x040000d4\n\ + str r1, [r0]\n\ + str r2, [r0, 0x4]\n\ + ldr r1, =0x80000400\n\ + str r1, [r0, 0x8]\n\ + ldr r0, [r0, 0x8]\n\ + lsls r0, r6, 7\n\ + adds r0, 0x4\n\ + adds r0, r3, r0\n\ + ldr r2, =0x00007b12\n\ + adds r1, r3, r2\n\ + ldrh r1, [r1]\n\ + movs r2, 0x20\n\ + bl LoadPalette\n\ +_08167742:\n\ + add sp, 0x28\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_8167760(void) +{ + s32 i; + u8 v1; + u8 v2; + u8 v3; + u32 v4; + struct SpriteSheet *v6; + struct SpriteTemplate *v7; + void (*funcCB) (void); + struct SpritePalette *v9; + struct SpriteSheet *v10; + struct SpritePalette *v11; + + sub_81D321C(v6, v7, v9); + LoadSpriteSheets(v6); + LoadSpritePalettes(v9); + for(i = 0; i < gUnknown_0203BCAC->info.field_76 - 1; i++) + { + v1 = CreateSprite(v7, 226, (0x140000 * i + 0x80000) >> 16, 0); + if(v1 == 64) + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; + } + else + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = v1; + gSprites[v1].data[0] = i; + gSprites[v1].callback = (SpriteCallback) sub_8168180; + } + } + for(v7->tileTag = 103; i <= 5; i++) + { + v2 = CreateSprite(v7, 230, (0x140000 * i + 0x80000) >> 16, 0); + if(v2 == 64 ) + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; + } + else + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = v2; + gSprites[v2].oam.tileNum &= 0x3F; + } + } + v7->tileTag = 102; + funcCB = sub_81681B4; + v3 = CreateSprite(v7, 222, (0x140000 * i + 0x80000) >> 16, 0); + if(v3 == 64) + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; + } + else + { + gUnknown_0203BCAC->field_0[0x7B06 + i] = v3; + v4 = 68 * v3 + 0x2020630; + (v4 + 1) = gSprites[v2].oam.affineMode & (0x3F | 0x40); + (v4 + 3) = (v4 + 3) & (0x3F | 0x80); + } + sub_81D32B0(v10, v11); + LoadSpriteSheet(v10); + LoadSpritePalette(v11); +} +#else +NAKED +void sub_8167760(void) +{ + 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, 0x60\n\ + add r5, sp, 0x20\n\ + add r4, sp, 0x38\n\ + mov r0, sp\n\ + adds r1, r5, 0\n\ + adds r2, r4, 0\n\ + bl sub_81D321C\n\ + mov r0, sp\n\ + bl LoadSpriteSheets\n\ + adds r0, r4, 0\n\ + bl LoadSpritePalettes\n\ + movs r4, 0\n\ + ldr r1, =gUnknown_0203BCAC\n\ + ldr r0, [r1]\n\ + ldr r2, =0x00008040\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + subs r0, 0x1\n\ + adds r6, r5, 0\n\ + add r2, sp, 0x50\n\ + mov r9, r2\n\ + add r2, sp, 0x58\n\ + mov r10, r2\n\ + cmp r4, r0\n\ + bge _0816781C\n\ + adds r5, r1, 0\n\ + ldr r7, =gSprites\n\ + movs r0, 0x1C\n\ + adds r0, r7\n\ + mov r8, r0\n\ +_081677AC:\n\ + lsls r2, r4, 2\n\ + adds r2, r4\n\ + lsls r2, 18\n\ + movs r1, 0x80\n\ + lsls r1, 12\n\ + adds r2, r1\n\ + asrs r2, 16\n\ + adds r0, r6, 0\n\ + movs r1, 0xE2\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + cmp r3, 0x40\n\ + beq _081677FC\n\ + ldr r0, [r5]\n\ + ldr r2, =0x00007b06\n\ + adds r0, r2\n\ + adds r0, r4\n\ + strb r3, [r0]\n\ + lsls r0, r3, 4\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r1, r0, r7\n\ + strh r4, [r1, 0x2E]\n\ + add r0, r8\n\ + ldr r1, =sub_8168180\n\ + str r1, [r0]\n\ + b _08167808\n\ + .pool\n\ +_081677FC:\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00007b06\n\ + adds r0, r1\n\ + adds r0, r4\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ +_08167808:\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + ldr r0, [r5]\n\ + ldr r2, =0x00008040\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + subs r0, 0x1\n\ + cmp r4, r0\n\ + blt _081677AC\n\ +_0816781C:\n\ + movs r0, 0x67\n\ + strh r0, [r6]\n\ + cmp r4, 0x5\n\ + bhi _0816788A\n\ + ldr r5, =gUnknown_0203BCAC\n\ + ldr r7, =gSprites\n\ +_08167828:\n\ + lsls r2, r4, 2\n\ + adds r2, r4\n\ + lsls r2, 18\n\ + movs r0, 0x80\n\ + lsls r0, 12\n\ + adds r2, r0\n\ + asrs r2, 16\n\ + adds r0, r6, 0\n\ + movs r1, 0xE6\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + cmp r3, 0x40\n\ + beq _08167874\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00007b06\n\ + adds r0, r1\n\ + adds r0, r4\n\ + strb r3, [r0]\n\ + lsls r1, r3, 4\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r1, r7\n\ + ldrb r2, [r1, 0x3]\n\ + movs r0, 0x3F\n\ + ands r0, r2\n\ + strb r0, [r1, 0x3]\n\ + b _08167880\n\ + .pool\n\ +_08167874:\n\ + ldr r0, [r5]\n\ + ldr r2, =0x00007b06\n\ + adds r0, r2\n\ + adds r0, r4\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ +_08167880:\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r4, 0x5\n\ + bls _08167828\n\ +_0816788A:\n\ + movs r0, 0x66\n\ + strh r0, [r6]\n\ + ldr r0, =sub_81681B4\n\ + str r0, [r6, 0x14]\n\ + lsls r2, r4, 2\n\ + adds r2, r4\n\ + lsls r2, 18\n\ + movs r0, 0x80\n\ + lsls r0, 12\n\ + adds r2, r0\n\ + asrs r2, 16\n\ + adds r0, r6, 0\n\ + movs r1, 0xDE\n\ + movs r3, 0\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + cmp r3, 0x40\n\ + beq _081678F4\n\ + ldr r0, =gUnknown_0203BCAC\n\ + ldr r0, [r0]\n\ + ldr r1, =0x00007b06\n\ + adds r0, r1\n\ + adds r0, r4\n\ + strb r3, [r0]\n\ + ldr r0, =gSprites\n\ + lsls r2, r3, 4\n\ + adds r2, r3\n\ + lsls r2, 2\n\ + adds r2, r0\n\ + ldrb r3, [r2, 0x1]\n\ + movs r1, 0x3F\n\ + adds r0, r1, 0\n\ + ands r0, r3\n\ + movs r3, 0x40\n\ + orrs r0, r3\n\ + strb r0, [r2, 0x1]\n\ + ldrb r0, [r2, 0x3]\n\ + ands r1, r0\n\ + movs r0, 0x80\n\ + orrs r1, r0\n\ + strb r1, [r2, 0x3]\n\ + b _08167902\n\ + .pool\n\ +_081678F4:\n\ + ldr r0, =gUnknown_0203BCAC\n\ + ldr r0, [r0]\n\ + ldr r2, =0x00007b06\n\ + adds r0, r2\n\ + adds r0, r4\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ +_08167902:\n\ + mov r0, r9\n\ + mov r1, r10\n\ + bl sub_81D32B0\n\ + mov r0, r9\n\ + bl LoadSpriteSheet\n\ + mov r0, r10\n\ + bl LoadSpritePalette\n\ + add sp, 0x60\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\n"); +} +#endif + +bool8 sub_8167930(void) +{ + bool8 retvalue; + switch(gUnknown_0203BCAC->info.field_8048) + { + case 0: + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 136 << 6, 0); + SetGpuReg(REG_OFFSET_DISPCNT, 28736); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2|BLDCNT_EFFECT_BLEND|BLDCNT_TGT2_BG1); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); + break; + case 1: + (u32 *) gUnknown_0203BCA4 = Alloc(6656); + (u32 *) gUnknown_0203BCA0 = Alloc(1280); + (u32 *) gUnknown_0203BCA8 = Alloc(1280); + break; + case 2: + LZ77UnCompVram(gUnknown_085DFB60, gUnknown_0203BCA8); + break; + case 3: + LoadBgTiles(3, gUnknown_085DFA80, 224, 0); + break; + case 4: + LoadBgTilemap(3, gUnknown_0203BCA8, 1280, 0); + break; + case 5: + LoadPalette(gUnknown_085DFA60, 208, 32); + gUnknown_0203BCAC->field_7B0E = 0xFFB0; + break; + case 6: + LZ77UnCompVram(gUsePokeblockGraph_Gfx, gUnknown_0203BCA4); + break; + case 7: + LZ77UnCompVram(gUsePokeblockGraph_Tilemap, gUnknown_0203BCA0); + LoadPalette(gUsePokeblockGraph_Pal, 32, 32); + break; + case 8: + LoadBgTiles(1, gUnknown_0203BCA4, 6656, 160 << 2); + break; + case 9: + SetBgTilemapBuffer(1, gUnknown_0203BCA0); + CopyToBgTilemapBufferRect(1, gUsePokeblockNatureWin_Pal, 0, 13, 12, 4); + CopyBgTilemapBufferToVram(1); + break; + case 10: + LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]); + break; + case 11: + LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0); + LoadPalette(gUnknown_086231E8, 48, 32); + LoadPalette(gUnknown_08623208, 240, 32); + sub_81D21DC(2); + break; + default: + gUnknown_0203BCAC->info.field_8048 = 0; + retvalue = 0; + return retvalue; + } + gUnknown_0203BCAC->info.field_8048++; + retvalue = 1; + return retvalue; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +