From cd994f4935b9de81383d8e0a17d790414652a4d6 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 18 Dec 2018 19:29:41 -0600 Subject: [PATCH] Begin trade.c --- asm/trade.s | 2452 ---------------------------------------- include/graphics.h | 5 + include/librfu.h | 2 +- include/link.h | 1 + include/link_rfu.h | 2 + include/party_menu.h | 2 + include/pokemon_icon.h | 1 + include/trainer_card.h | 1 + ld_script.txt | 1 + src/trade.c | 993 ++++++++++++++++ 10 files changed, 1007 insertions(+), 2453 deletions(-) create mode 100644 src/trade.c diff --git a/asm/trade.s b/asm/trade.s index a583e4319..2c11ae661 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -6,2458 +6,6 @@ .text - thumb_func_start sub_8077170 -sub_8077170: @ 8077170 - push {r4,lr} - adds r4, r0, 0 - adds r3, r1, 0 - ldr r0, =gUnknown_02022C2C - ldrb r0, [r0] - cmp r0, 0x1D - beq _08077194 - lsls r2, r3, 16 - lsrs r2, 16 - movs r0, 0 - adds r1, r4, 0 - bl SendBlock - lsls r0, 24 - lsrs r0, 24 - b _080771A2 - .pool -_08077194: - ldr r0, =gUnknown_03004140 - ldrb r0, [r0] - movs r1, 0x54 - adds r2, r4, 0 - bl rfu_NI_setSendData - movs r0, 0x1 -_080771A2: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8077170 - - thumb_func_start sub_80771AC -sub_80771AC: @ 80771AC - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_800A4D8 - pop {r0} - bx r0 - thumb_func_end sub_80771AC - - thumb_func_start sub_80771BC -sub_80771BC: @ 80771BC - push {r4,lr} - ldr r0, =gUnknown_02022C2C - ldrb r0, [r0] - cmp r0, 0x1D - bne _080771F0 - ldr r4, =gUnknown_03007880 - ldr r0, =gUnknown_03004140 - ldrb r0, [r0] - bl sub_800E87C - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ldrh r0, [r0] - cmp r0, 0 - bne _080771EC - movs r0, 0x1 - b _080771F8 - .pool -_080771EC: - movs r0, 0 - b _080771F8 -_080771F0: - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 -_080771F8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80771BC - - thumb_func_start sub_8077200 -sub_8077200: @ 8077200 - push {lr} - bl GetBlockReceivedStatus - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8077200 - - thumb_func_start sub_8077210 -sub_8077210: @ 8077210 - push {lr} - bl sub_8077260 - cmp r0, 0 - beq _0807722C - ldr r0, =gUnknown_03004140 - ldrb r1, [r0] - movs r0, 0xC - bl rfu_clearSlot - b _08077230 - .pool -_0807722C: - bl ResetBlockReceivedFlags -_08077230: - pop {r0} - bx r0 - thumb_func_end sub_8077210 - - thumb_func_start sub_8077234 -sub_8077234: @ 8077234 - push {r4,lr} - adds r4, r0, 0 - bl sub_8077260 - cmp r0, 0 - beq _08077250 - ldr r0, =gUnknown_03004140 - ldrb r1, [r0] - movs r0, 0xC - bl rfu_clearSlot - b _08077258 - .pool -_08077250: - lsls r0, r4, 24 - lsrs r0, 24 - bl ResetBlockReceivedFlag -_08077258: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8077234 - - thumb_func_start sub_8077260 -sub_8077260: @ 8077260 - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08077280 - ldr r0, =gUnknown_02022C2C - ldrb r0, [r0] - cmp r0, 0x1D - bne _08077280 - movs r0, 0x1 - b _08077282 - .pool -_08077280: - movs r0, 0 -_08077282: - pop {r1} - bx r1 - thumb_func_end sub_8077260 - - thumb_func_start sub_8077288 -sub_8077288: @ 8077288 - push {lr} - bl sub_800ADF8 - pop {r0} - bx r0 - thumb_func_end sub_8077288 - - thumb_func_start sub_8077294 -sub_8077294: @ 8077294 - push {lr} - bl sub_800A520 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8077294 - - thumb_func_start sub_80772A4 -sub_80772A4: @ 80772A4 - push {r4,r5,lr} - sub sp, 0xC - bl ResetSpriteData - bl FreeAllSpritePalettes - bl ResetTasks - bl ResetPaletteFade - ldr r2, =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r0, =sub_807811C - bl SetVBlankCallback - ldr r4, =gUnknown_0860F074 - adds r0, r4, 0 - movs r1, 0xF0 - movs r2, 0x14 - bl LoadPalette - adds r0, r4, 0 - movs r1, 0xD0 - movs r2, 0x14 - bl LoadPalette - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0832DEE4 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - movs r0, 0x8F - lsls r0, 4 - adds r1, r0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r0, =gUnknown_0832DEF4 - bl InitWindows - lsls r0, 16 - cmp r0, 0 - beq _0807738C - bl DeactivateAllTextPrinters - movs r5, 0 -_08077310: - lsls r4, r5, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl ClearWindowTilemap - adds r0, r4, 0 - movs r1, 0 - bl FillWindowPixelBuffer - adds r5, 0x1 - cmp r5, 0x11 - bls _08077310 - movs r0, 0x1E - str r0, [sp] - movs r0, 0x14 - str r0, [sp, 0x4] - movs r0, 0xF - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect - movs r0, 0 - movs r1, 0x14 - movs r2, 0xC0 - bl LoadUserWindowBorderGfx_ - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0xE0 - bl LoadUserWindowBorderGfx - bl LoadMonIconPalettes - ldr r2, =gUnknown_0203229C - ldr r0, [r2] - adds r0, 0x69 - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x6F - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x70 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x74 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x75 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x7A - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x7B - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xA8 - strb r1, [r0] -_0807738C: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80772A4 - - thumb_func_start sub_80773AC -sub_80773AC: @ 80773AC - push {lr} - ldr r0, =sub_80773D0 - bl SetMainCallback2 - ldr r0, =gMain - movs r1, 0 - str r1, [r0] - ldr r0, =gEnemyPartyCount - strb r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80773AC - - thumb_func_start sub_80773D0 -sub_80773D0: @ 80773D0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x28 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r3, r1, 0 - cmp r0, 0x16 - bls _080773EA - b _08077B46 -_080773EA: - lsls r0, 2 - ldr r1, =_080773FC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080773FC: - .4byte _08077458 - .4byte _080774A4 - .4byte _08077560 - .4byte _0807758C - .4byte _080775E8 - .4byte _08077648 - .4byte _08077688 - .4byte _080776A8 - .4byte _080777E8 - .4byte _08077810 - .4byte _08077834 - .4byte _080778BC - .4byte _080778CA - .4byte _08077970 - .4byte _08077A40 - .4byte _08077A80 - .4byte _08077A9A - .4byte _08077AA8 - .4byte _08077ABC - .4byte _08077ADC - .4byte _08077AFC - .4byte _08077B10 - .4byte _08077B30 -_08077458: - ldr r4, =gUnknown_0203229C - ldr r0, =0x000010f0 - bl AllocZeroed - str r0, [r4] - bl sub_80772A4 - ldr r4, =gUnknown_02032184 - movs r0, 0xE0 - lsls r0, 4 - bl AllocZeroed - str r0, [r4] - movs r6, 0 - ldr r2, =gUnknown_02032188 -_08077476: - lsls r1, r6, 8 - ldr r0, [r4] - adds r0, r1 - stm r2!, {r0} - adds r6, 0x1 - cmp r6, 0xD - ble _08077476 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _08077B22 - .pool -_080774A4: - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x8] - movs r6, 0 - movs r4, 0 -_080774B2: - movs r0, 0x64 - muls r0, r6 - ldr r1, =gEnemyParty - adds r0, r1 - str r4, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - str r4, [sp, 0xC] - movs r1, 0 - movs r2, 0 - movs r3, 0x20 - bl CreateMon - adds r6, 0x1 - cmp r6, 0x5 - ble _080774B2 - movs r0, 0 - bl sub_807A19C - movs r0, 0 - bl ShowBg - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r2, [r0] - cmp r2, 0 - bne _0807754C - ldr r1, =gLinkType - ldr r5, =0x00001122 - adds r0, r5, 0 - strh r0, [r1] - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - adds r0, 0xA8 - strb r2, [r0] - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08077528 - bl sub_800B488 - bl OpenLink - bl sub_8011BA4 - b _08077B46 - .pool -_08077528: - bl OpenLink - ldr r0, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r0, r7 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, =task00_08081A90 - movs r1, 0x1 - bl CreateTask - b _08077B46 - .pool -_0807754C: - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x4 - strb r1, [r0] - b _08077B46 - .pool -_08077560: - ldr r2, =gUnknown_0203229C - ldr r1, [r2] - adds r1, 0xA8 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r2] - adds r1, r0, 0 - adds r1, 0xA8 - ldrb r0, [r1] - cmp r0, 0xB - bhi _0807757A - b _08077B46 -_0807757A: - movs r0, 0 - strb r0, [r1] - movs r2, 0x87 - lsls r2, 3 - adds r1, r3, r2 - b _08077B22 - .pool -_0807758C: - bl GetLinkPlayerCount_2 - adds r4, r0, 0 - bl sub_800AA48 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bcs _080775A0 - b _08077B46 -_080775A0: - bl IsLinkMaster - lsls r0, 24 - cmp r0, 0 - beq _080775D8 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r1, 0xA8 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1E - bhi _080775C0 - b _08077B46 -_080775C0: - bl sub_800A620 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _08077B22 - .pool -_080775D8: - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _08077B22 - .pool -_080775E8: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0x1 - beq _080775F2 - b _08077B46 -_080775F2: - bl IsLinkPlayerDataExchangeComplete - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08077600 - b _08077B46 -_08077600: - bl sub_8011BD0 - bl CalculatePlayerPartyCount - ldr r1, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r1, r7 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - adds r0, 0xA8 - strb r2, [r0] - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - bne _0807762A - b _08077B46 -_0807762A: - movs r0, 0x1 - bl sub_801048C - bl sub_800ADF8 - b _08077B46 - .pool -_08077648: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08077680 - bl sub_8010500 - lsls r0, 24 - cmp r0, 0 - bne _0807765C - b _08077B46 -_0807765C: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite - b _08077B46 - .pool -_08077680: - movs r2, 0x87 - lsls r2, 3 - adds r1, r3, r2 - b _08077B22 -_08077688: - bl shedinja_maker_maybe - lsls r0, 24 - cmp r0, 0 - bne _08077694 - b _08077B46 -_08077694: - bl sub_807A5B0 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _08077B22 - .pool -_080776A8: - bl CalculateEnemyPartyCount - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - ldr r2, =gUnknown_0203229C - ldr r0, [r2] - ldr r1, =gPlayerPartyCount - ldrb r1, [r1] - adds r0, 0x36 - strb r1, [r0] - ldr r0, [r2] - ldr r1, =gEnemyPartyCount - ldrb r1, [r1] - adds r0, 0x37 - strb r1, [r0] - movs r6, 0 - ldr r0, [r2] - adds r0, 0x36 - ldrb r0, [r0] - cmp r6, r0 - bge _08077740 - mov r8, r2 - ldr r7, =gUnknown_0832DE24 -_080776E2: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - ldrb r2, [r7] - lsls r2, 19 - movs r1, 0xE0 - lsls r1, 12 - adds r2, r1 - asrs r2, 16 - ldrb r3, [r7, 0x1] - lsls r3, 19 - ldr r1, =0xfff40000 - adds r3, r1 - asrs r3, 16 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - str r1, [sp, 0x8] - adds r0, r5, 0 - ldr r1, =sub_80D3014 - bl CreateMonIcon - mov r2, r8 - ldr r1, [r2] - adds r1, 0x28 - adds r1, r6 - strb r0, [r1] - adds r7, 0x2 - adds r6, 0x1 - ldr r0, [r2] - adds r0, 0x36 - ldrb r0, [r0] - cmp r6, r0 - blt _080776E2 -_08077740: - movs r6, 0 - ldr r1, =gUnknown_0203229C - ldr r0, [r1] - adds r0, 0x37 - ldrb r0, [r0] - cmp r6, r0 - bge _080777B8 - ldr r0, =gUnknown_0832DE24 - mov r8, r1 - adds r7, r0, 0 - adds r7, 0xC -_08077756: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gEnemyParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - ldrb r2, [r7] - lsls r2, 19 - movs r3, 0xE0 - lsls r3, 12 - adds r2, r3 - asrs r2, 16 - ldrb r3, [r7, 0x1] - lsls r3, 19 - ldr r1, =0xfff40000 - adds r3, r1 - asrs r3, 16 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r5, 0 - ldr r1, =sub_80D3014 - bl CreateMonIcon - mov r2, r8 - ldr r1, [r2] - adds r1, 0x2E - adds r1, r6 - strb r0, [r1] - adds r7, 0x2 - adds r6, 0x1 - ldr r0, [r2] - adds r0, 0x37 - ldrb r0, [r0] - cmp r6, r0 - blt _08077756 -_080777B8: - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _08077B22 - .pool -_080777E8: - bl sub_81B5D30 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x36 - adds r1, 0x28 - movs r2, 0 - bl sub_81B5D4C - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _08077B22 - .pool -_08077810: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x36 - adds r1, 0x28 - movs r2, 0x1 - bl sub_81B5D4C - ldr r1, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r1, r7 - b _08077B22 - .pool -_08077834: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r5, =gUnknown_02032188 - ldr r1, [r5] - movs r4, 0x3 - str r4, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - bl GetMultiplayerId - lsls r0, 24 - movs r1, 0x80 - lsls r1, 17 - eors r1, r0 - lsrs r1, 24 - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - ldr r1, =gLinkPlayers + 8 - adds r0, r1 - ldr r1, [r5, 0xC] - str r4, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - ldr r4, =gUnknown_0832DE94 - ldr r0, [r4] - ldr r1, [r5, 0x18] - movs r2, 0x2 - str r2, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - ldr r0, [r4, 0x4] - ldr r1, [r5, 0x20] - movs r2, 0x18 - bl sub_807A308 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - adds r0, 0xA8 - strb r2, [r0] - b _08077B46 - .pool -_080778BC: - bl sub_807A1F0 - lsls r0, 24 - cmp r0, 0 - bne _080778C8 - b _08077B46 -_080778C8: - b _08077B1A -_080778CA: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - movs r0, 0x1 - movs r2, 0x78 - bl GetStringCenterAlignXOffset - movs r6, 0 - add r5, sp, 0x10 - adds r4, r0, 0 - adds r4, 0x10 -_080778DE: - add r1, sp, 0x10 - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldrh r0, [r5] - adds r0, r6 - strh r0, [r5] - lsls r1, r4, 16 - asrs r1, 16 - add r0, sp, 0x10 - movs r2, 0xA - movs r3, 0x1 - bl CreateSprite - adds r4, 0x20 - adds r6, 0x1 - cmp r6, 0x2 - ble _080778DE - bl GetMultiplayerId - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - ldr r0, =gLinkPlayers + 8 - adds r1, r0 - movs r0, 0x1 - movs r2, 0x78 - bl GetStringCenterAlignXOffset - movs r6, 0 - add r5, sp, 0x10 - adds r4, r0, 0 - adds r4, 0x88 -_0807792C: - add r1, sp, 0x10 - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - adds r0, r6, 0x3 - ldrh r3, [r5] - adds r0, r3 - strh r0, [r5] - lsls r1, r4, 16 - asrs r1, 16 - add r0, sp, 0x10 - movs r2, 0xA - movs r3, 0x1 - bl CreateSprite - adds r4, 0x20 - adds r6, 0x1 - cmp r6, 0x2 - ble _0807792C - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _08077B22 - .pool -_08077970: - ldr r4, =gSpriteTemplate_832DCAC - add r1, sp, 0x10 - adds r0, r4, 0 - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r5,r7} - stm r1!, {r2,r5,r7} - add r1, sp, 0x10 - adds r0, r1, 0 - ldrh r0, [r0] - adds r0, 0x6 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xD7 - movs r2, 0x98 - movs r3, 0x1 - bl CreateSprite - add r0, sp, 0x10 - ldm r4!, {r3,r5,r7} - stm r0!, {r3,r5,r7} - ldm r4!, {r1-r3} - stm r0!, {r1-r3} - add r1, sp, 0x10 - adds r0, r1, 0 - ldrh r0, [r0] - adds r0, 0x7 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xF7 - movs r2, 0x98 - movs r3, 0x1 - bl CreateSprite - movs r6, 0 - add r4, sp, 0x10 - movs r5, 0xC0 - lsls r5, 13 -_080779BC: - add r1, sp, 0x10 - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - adds r0, r6, 0 - adds r0, 0x8 - ldrh r7, [r4] - adds r0, r7 - strh r0, [r4] - asrs r1, r5, 16 - add r0, sp, 0x10 - movs r2, 0x96 - movs r3, 0x1 - bl CreateSprite - movs r0, 0x80 - lsls r0, 14 - adds r5, r0 - adds r6, 0x1 - cmp r6, 0x5 - ble _080779BC - ldr r0, =gSpriteTemplate_832DC94 - ldr r2, =gUnknown_0832DE24 - ldrb r1, [r2] - lsls r1, 19 - movs r3, 0x80 - lsls r3, 14 - adds r1, r3 - asrs r1, 16 - ldrb r2, [r2, 0x1] - lsls r2, 3 - movs r3, 0x2 - bl CreateSprite - ldr r2, =gUnknown_0203229C - ldr r1, [r2] - adds r1, 0x34 - movs r3, 0 - strb r0, [r1] - ldr r0, [r2] - adds r0, 0x35 - strb r3, [r0] - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r0, 0 - bl rbox_fill_rectangle - b _08077B46 - .pool -_08077A40: - movs r0, 0 - bl sub_807A320 - movs r0, 0 - bl sub_8079BE0 - ldr r2, =gUnknown_0203229C - ldr r0, [r2] - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x1] - bl sub_8078388 - ldr r1, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r1, r7 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, =0x000001b3 - bl PlayBGM - b _08077B46 - .pool -_08077A80: - movs r0, 0x1 - bl sub_807A320 - movs r0, 0x1 - bl sub_8079BE0 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_08077A9A: - movs r0, 0 - bl sub_80782B8 - b _08077B1A - .pool -_08077AA8: - movs r0, 0x1 - bl sub_80782B8 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _08077B22 - .pool -_08077ABC: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _08077B22 - .pool -_08077ADC: - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0x2 - bl sub_80782B8 - ldr r1, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r1, r7 - b _08077B22 - .pool -_08077AFC: - movs r0, 0 - bl sub_807A468 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _08077B22 - .pool -_08077B10: - movs r0, 0x1 - bl sub_807A468 - bl sub_807A53C -_08077B1A: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 -_08077B22: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08077B46 - .pool -_08077B30: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08077B46 - ldr r0, =sub_8078C34 - str r0, [r3] - ldr r0, =sub_807825C - bl SetMainCallback2 -_08077B46: - bl RunTextPrinters - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - add sp, 0x28 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80773D0 - - thumb_func_start sub_8077B74 -sub_8077B74: @ 8077B74 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x24 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0x16 - bls _08077B8E - b _080780F6 -_08077B8E: - lsls r0, 2 - ldr r1, =_08077BA0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08077BA0: - .4byte _08077BFC - .4byte _08077C10 - .4byte _08077C18 - .4byte _08077C20 - .4byte _08077C28 - .4byte _08077C3C - .4byte _08077C64 - .4byte _08077C6C - .4byte _08077DB0 - .4byte _08077DD8 - .4byte _08077DFC - .4byte _08077E84 - .4byte _08077EA0 - .4byte _08077F48 - .4byte _080780F6 - .4byte _080780F6 - .4byte _08078038 - .4byte _08078040 - .4byte _08078068 - .4byte _080780A4 - .4byte _080780C4 - .4byte _080780CC - .4byte _080780E4 -_08077BFC: - bl sub_80772A4 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _080780D8 - .pool -_08077C10: - movs r5, 0x87 - lsls r5, 3 - adds r1, r2, r5 - b _08077E58 -_08077C18: - movs r7, 0x87 - lsls r7, 3 - adds r1, r2, r7 - b _080780D8 -_08077C20: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _080780D8 -_08077C28: - bl CalculatePlayerPartyCount - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _080780D8 - .pool -_08077C3C: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08077C50 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite -_08077C50: - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _080780D8 - .pool -_08077C64: - movs r5, 0x87 - lsls r5, 3 - adds r1, r2, r5 - b _080780D8 -_08077C6C: - bl CalculateEnemyPartyCount - ldr r4, =gUnknown_0203229C - ldr r0, [r4] - ldr r1, =gPlayerPartyCount - ldrb r1, [r1] - adds r0, 0x36 - strb r1, [r0] - ldr r0, [r4] - ldr r1, =gEnemyPartyCount - ldrb r1, [r1] - adds r0, 0x37 - strb r1, [r0] - movs r0, 0 - bl ClearWindowTilemap - movs r0, 0 - bl sub_8079BE0 - movs r0, 0x1 - bl sub_8079BE0 - movs r6, 0 - ldr r0, [r4] - adds r0, 0x36 - ldrb r0, [r0] - cmp r6, r0 - bge _08077D08 - mov r8, r4 - ldr r7, =gUnknown_0832DE24 -_08077CA8: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - ldrb r2, [r7] - lsls r2, 19 - movs r1, 0xE0 - lsls r1, 12 - adds r2, r1 - asrs r2, 16 - ldrb r3, [r7, 0x1] - lsls r3, 19 - ldr r1, =0xfff40000 - adds r3, r1 - asrs r3, 16 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - str r1, [sp, 0x8] - adds r0, r5, 0 - ldr r1, =sub_80D3014 - bl CreateMonIcon - mov r2, r8 - ldr r1, [r2] - adds r1, 0x28 - adds r1, r6 - strb r0, [r1] - adds r7, 0x2 - adds r6, 0x1 - ldr r0, [r2] - adds r0, 0x36 - ldrb r0, [r0] - cmp r6, r0 - blt _08077CA8 -_08077D08: - movs r6, 0 - ldr r1, =gUnknown_0203229C - ldr r0, [r1] - adds r0, 0x37 - ldrb r0, [r0] - cmp r6, r0 - bge _08077D80 - ldr r0, =gUnknown_0832DE24 - mov r8, r1 - adds r7, r0, 0 - adds r7, 0xC -_08077D1E: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gEnemyParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - ldrb r2, [r7] - lsls r2, 19 - movs r3, 0xE0 - lsls r3, 12 - adds r2, r3 - asrs r2, 16 - ldrb r3, [r7, 0x1] - lsls r3, 19 - ldr r1, =0xfff40000 - adds r3, r1 - asrs r3, 16 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r5, 0 - ldr r1, =sub_80D3014 - bl CreateMonIcon - mov r2, r8 - ldr r1, [r2] - adds r1, 0x2E - adds r1, r6 - strb r0, [r1] - adds r7, 0x2 - adds r6, 0x1 - ldr r0, [r2] - adds r0, 0x37 - ldrb r0, [r0] - cmp r6, r0 - blt _08077D1E -_08077D80: - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _080780D8 - .pool -_08077DB0: - bl sub_81B5D30 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x36 - adds r1, 0x28 - movs r2, 0 - bl sub_81B5D4C - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _080780D8 - .pool -_08077DD8: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x36 - adds r1, 0x28 - movs r2, 0x1 - bl sub_81B5D4C - ldr r1, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r1, r7 - b _080780D8 - .pool -_08077DFC: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r5, =gUnknown_02032188 - ldr r1, [r5] - movs r4, 0x3 - str r4, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - bl GetMultiplayerId - lsls r0, 24 - movs r1, 0x80 - lsls r1, 17 - eors r1, r0 - lsrs r1, 24 - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - ldr r1, =gLinkPlayers + 8 - adds r0, r1 - ldr r1, [r5, 0xC] - str r4, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - ldr r4, =gUnknown_0832DE94 - ldr r0, [r4] - ldr r1, [r5, 0x18] - movs r2, 0x2 - str r2, [sp] - movs r2, 0 - movs r3, 0 - bl sub_80C6D80 - ldr r0, [r4, 0x4] - ldr r1, [r5, 0x20] - movs r2, 0x18 - bl sub_807A308 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_08077E58: - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - adds r0, 0xA8 - strb r2, [r0] - b _080780F6 - .pool -_08077E84: - bl sub_807A1F0 - lsls r0, 24 - cmp r0, 0 - bne _08077E90 - b _080780F6 -_08077E90: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _080780D8 - .pool -_08077EA0: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - movs r0, 0x1 - movs r2, 0x78 - bl GetStringCenterAlignXOffset - movs r6, 0 - add r5, sp, 0xC - adds r4, r0, 0 - adds r4, 0x10 -_08077EB4: - add r1, sp, 0xC - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldrh r0, [r5] - adds r0, r6 - strh r0, [r5] - lsls r1, r4, 16 - asrs r1, 16 - add r0, sp, 0xC - movs r2, 0xA - movs r3, 0x1 - bl CreateSprite - adds r4, 0x20 - adds r6, 0x1 - cmp r6, 0x2 - ble _08077EB4 - bl GetMultiplayerId - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - ldr r0, =gLinkPlayers + 8 - adds r1, r0 - movs r0, 0x1 - movs r2, 0x78 - bl GetStringCenterAlignXOffset - movs r6, 0 - add r5, sp, 0xC - adds r4, r0, 0 - adds r4, 0x88 -_08077F02: - add r1, sp, 0xC - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - adds r0, r6, 0x3 - ldrh r3, [r5] - adds r0, r3 - strh r0, [r5] - lsls r1, r4, 16 - asrs r1, 16 - add r0, sp, 0xC - movs r2, 0xA - movs r3, 0x1 - bl CreateSprite - adds r4, 0x20 - adds r6, 0x1 - cmp r6, 0x2 - ble _08077F02 - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _080780D8 - .pool -_08077F48: - ldr r4, =gSpriteTemplate_832DCAC - add r1, sp, 0xC - adds r0, r4, 0 - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r5,r7} - stm r1!, {r2,r5,r7} - add r1, sp, 0xC - adds r0, r1, 0 - ldrh r0, [r0] - adds r0, 0x6 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xD7 - movs r2, 0x98 - movs r3, 0x1 - bl CreateSprite - add r0, sp, 0xC - ldm r4!, {r3,r5,r7} - stm r0!, {r3,r5,r7} - ldm r4!, {r1-r3} - stm r0!, {r1-r3} - add r1, sp, 0xC - adds r0, r1, 0 - ldrh r0, [r0] - adds r0, 0x7 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xF7 - movs r2, 0x98 - movs r3, 0x1 - bl CreateSprite - movs r6, 0 - add r4, sp, 0xC - movs r5, 0xC0 - lsls r5, 13 -_08077F94: - add r1, sp, 0xC - ldr r0, =gSpriteTemplate_832DCAC - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - adds r0, r6, 0 - adds r0, 0x8 - ldrh r7, [r4] - adds r0, r7 - strh r0, [r4] - asrs r1, r5, 16 - add r0, sp, 0xC - movs r2, 0x96 - movs r3, 0x1 - bl CreateSprite - movs r0, 0x80 - lsls r0, 14 - adds r5, r0 - adds r6, 0x1 - cmp r6, 0x5 - ble _08077F94 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - adds r2, r1, 0 - adds r2, 0x35 - ldrb r1, [r2] - adds r4, r0, 0 - cmp r1, 0x5 - bhi _08077FE4 - ldr r0, =gUnknown_0203CF20 - ldrb r0, [r0] - b _08077FEA - .pool -_08077FE4: - ldr r0, =gUnknown_0203CF20 - ldrb r0, [r0] - adds r0, 0x6 -_08077FEA: - strb r0, [r2] - ldr r0, =gSpriteTemplate_832DC94 - ldr r3, =gUnknown_0832DE24 - ldr r1, [r4] - adds r1, 0x35 - ldrb r2, [r1] - lsls r2, 1 - adds r1, r2, r3 - ldrb r1, [r1] - lsls r1, 19 - movs r5, 0x80 - lsls r5, 14 - adds r1, r5 - asrs r1, 16 - adds r3, 0x1 - adds r2, r3 - ldrb r2, [r2] - lsls r2, 3 - movs r3, 0x2 - bl CreateSprite - ldr r1, [r4] - adds r1, 0x34 - strb r0, [r1] - ldr r0, =gMain - movs r7, 0x87 - lsls r7, 3 - adds r0, r7 - movs r1, 0x10 - strb r1, [r0] - b _080780F6 - .pool -_08078038: - movs r0, 0 - bl sub_80782B8 - b _080780D0 -_08078040: - movs r0, 0x1 - bl sub_80782B8 - ldr r2, =gUnknown_0203229C - ldr r0, [r2] - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - strb r1, [r0, 0x1] - bl sub_8078388 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _080780D8 - .pool -_08078068: - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x8] - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _080780D8 - .pool -_080780A4: - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0x2 - bl sub_80782B8 - ldr r1, =gMain - movs r5, 0x87 - lsls r5, 3 - adds r1, r5 - b _080780D8 - .pool -_080780C4: - movs r7, 0x87 - lsls r7, 3 - adds r1, r2, r7 - b _080780D8 -_080780CC: - bl sub_807A53C -_080780D0: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_080780D8: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080780F6 - .pool -_080780E4: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080780F6 - ldr r0, =sub_807825C - bl SetMainCallback2 -_080780F6: - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - add sp, 0x24 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8077B74 - - thumb_func_start sub_807811C -sub_807811C: @ 807811C - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_807811C - - thumb_func_start sub_8078130 -sub_8078130: @ 8078130 - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203229C - ldr r1, [r4] - adds r1, 0xA8 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xF - bls _08078160 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, [r4] - adds r0, 0x6F - movs r1, 0xA - strb r1, [r0] -_08078160: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8078130 - - thumb_func_start sub_807816C -sub_807816C: @ 807816C - push {r4,lr} - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080781C2 - ldr r1, =gUnknown_02032298 - ldr r4, =gUnknown_0203229C - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x35 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r2, 0 - adds r0, 0x7E - ldrb r0, [r0] - strb r0, [r1, 0x1] - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _080781B4 - adds r1, r2, 0 - adds r1, 0x6F - movs r0, 0x10 - strb r0, [r1] - b _080781C2 - .pool -_080781B4: - movs r0, 0x20 - bl sub_800ABF4 - ldr r0, [r4] - adds r0, 0x6F - movs r1, 0xD - strb r1, [r0] -_080781C2: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_807816C - - thumb_func_start sub_80781C8 -sub_80781C8: @ 80781C8 - push {r4,r5,lr} - ldr r5, =gMain - ldr r0, =sub_80773AC - str r0, [r5, 0x8] - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08078220 - bl sub_8010500 - lsls r0, 24 - cmp r0, 0 - beq _08078244 - ldr r0, =gUnknown_02032184 - ldr r0, [r0] - bl Free - bl FreeAllWindowBuffers - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - bl Free - movs r0, 0 - str r0, [r5] - bl sub_800E084 - ldr r0, =sub_807AE50 - bl SetMainCallback2 - b _08078244 - .pool -_08078220: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r4, [r0] - cmp r4, 0 - bne _08078244 - ldr r0, =gUnknown_02032184 - ldr r0, [r0] - bl Free - bl FreeAllWindowBuffers - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - bl Free - str r4, [r5] - ldr r0, =sub_807AE50 - bl SetMainCallback2 -_08078244: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80781C8 - - thumb_func_start sub_807825C -sub_807825C: @ 807825C - push {r4,lr} - bl sub_80795AC - bl sub_807A0C4 - movs r0, 0 - bl sub_80796B4 - movs r0, 0x1 - bl sub_80796B4 - ldr r4, =gUnknown_0203229C - ldr r2, [r4] - ldrb r1, [r2] - adds r0, r1, 0x1 - strb r0, [r2] - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x18 - bl SetGpuReg - ldr r2, [r4] - ldrb r1, [r2, 0x1] - adds r0, r1, 0 - adds r0, 0xFF - strb r0, [r2, 0x1] - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x1C - bl SetGpuReg - bl RunTextPrintersAndIsPrinter0Active - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807825C - - thumb_func_start sub_80782B8 -sub_80782B8: @ 80782B8 - push {r4,r5,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - beq _08078324 - cmp r4, 0x1 - bgt _080782CE - cmp r4, 0 - beq _080782D4 - b _0807837E -_080782CE: - cmp r4, 0x2 - beq _0807834C - b _0807837E -_080782D4: - ldr r0, =gUnknown_08DDB3E4 - movs r1, 0 - movs r2, 0x60 - bl LoadPalette - ldr r1, =gUnknown_08DDB464 - movs r2, 0x94 - lsls r2, 5 - movs r0, 0x1 - movs r3, 0 - bl LoadBgTiles - ldr r1, =gUnknown_08DDCF04 - movs r0, 0x20 - str r0, [sp] - movs r0, 0x14 - str r0, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBufferRect_ChangePalette - ldr r1, =gTradeStripesBG2Tilemap - movs r2, 0x80 - lsls r2, 4 - movs r0, 0x2 - movs r3, 0 - bl LoadBgTilemap - b _0807837E - .pool -_08078324: - ldr r1, =gTradeStripesBG3Tilemap - movs r2, 0x80 - lsls r2, 4 - movs r0, 0x3 - movs r3, 0 - bl LoadBgTilemap - movs r0, 0 - bl sub_8079E44 - movs r0, 0x1 - bl sub_8079E44 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - b _0807837E - .pool -_0807834C: - movs r5, 0x80 - lsls r5, 21 - movs r4, 0x3 -_08078352: - lsrs r0, r5, 24 - movs r1, 0 - bl SetGpuReg - movs r0, 0x80 - lsls r0, 18 - adds r5, r0 - subs r4, 0x1 - cmp r4, 0 - bge _08078352 - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg -_0807837E: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80782B8 - - thumb_func_start sub_8078388 -sub_8078388: @ 8078388 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r3, 0 - ldr r5, =gUnknown_0203229C - mov r8, r5 - ldr r0, =gSprites - mov r12, r0 - movs r1, 0x5 - negs r1, r1 - mov r9, r1 - movs r4, 0x6 - movs r7, 0x1 - movs r6, 0 -_080783A6: - mov r1, r8 - ldr r0, [r1] - adds r1, r0, 0 - adds r1, 0x36 - ldrb r1, [r1] - cmp r3, r1 - bge _080783E0 - adds r0, 0x28 - adds r0, r3 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r12 - adds r1, 0x3E - ldrb r2, [r1] - mov r0, r9 - ands r0, r2 - strb r0, [r1] - ldr r0, [r5] - adds r0, 0x38 - adds r0, r3 - strb r7, [r0] - b _080783E6 - .pool -_080783E0: - adds r0, 0x38 - adds r0, r3 - strb r6, [r0] -_080783E6: - mov r1, r8 - ldr r0, [r1] - adds r1, r0, 0 - adds r1, 0x37 - ldrb r1, [r1] - cmp r3, r1 - bge _08078416 - adds r0, 0x2E - adds r0, r3 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r12 - adds r1, 0x3E - ldrb r2, [r1] - mov r0, r9 - ands r0, r2 - strb r0, [r1] - ldr r0, [r5] - adds r0, 0x38 - adds r0, r4 - strb r7, [r0] - b _0807841C -_08078416: - adds r0, 0x38 - adds r0, r4 - strb r6, [r0] -_0807841C: - adds r4, 0x1 - adds r3, 0x1 - cmp r3, 0x5 - ble _080783A6 - ldr r0, [r5] - adds r0, 0x44 - movs r1, 0x1 - strb r1, [r0] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8078388 - - thumb_func_start sub_8078438 -sub_8078438: @ 8078438 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r3, 0 - cmp r3, r2 - bcs _08078452 -_08078444: - adds r0, r5, r3 - adds r1, r4, r3 - ldrb r1, [r1] - strb r1, [r0] - adds r3, 0x1 - cmp r3, r2 - bcc _08078444 -_08078452: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8078438 - - thumb_func_start shedinja_maker_maybe -shedinja_maker_maybe: @ 8078458 - push {r4-r6,lr} - sub sp, 0xC - bl GetMultiplayerId - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gUnknown_0203229C - ldr r0, [r0] - adds r0, 0x69 - ldrb r0, [r0] - cmp r0, 0x15 - bls _08078472 - b _080787AA -_08078472: - lsls r0, 2 - ldr r1, =_08078484 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08078484: - .4byte _080784DC - .4byte _08078508 - .4byte _08078784 - .4byte _08078534 - .4byte _08078548 - .4byte _0807857C - .4byte _08078784 - .4byte _08078598 - .4byte _080785AC - .4byte _080785E0 - .4byte _08078784 - .4byte _080785FC - .4byte _08078610 - .4byte _08078644 - .4byte _08078784 - .4byte _0807866C - .4byte _08078680 - .4byte _080786B4 - .4byte _08078784 - .4byte _080786DC - .4byte _080786F0 - .4byte _08078720 -_080784DC: - ldr r0, =gBlockSendBuffer - ldr r1, =gPlayerParty - movs r2, 0xC8 - bl sub_8078438 - ldr r3, =gUnknown_0203229C - ldr r1, [r3] - adds r1, 0x69 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - ldr r0, [r3] - adds r0, 0xA8 - strb r2, [r0] - b _080787AA - .pool -_08078508: - bl sub_80771BC - cmp r0, 0 - bne _08078512 - b _080787AA -_08078512: - bl sub_8077200 - cmp r0, 0 - bne _08078524 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078524: - bl sub_8077210 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078534: - cmp r5, 0 - bne _0807853E - movs r0, 0x1 - bl sub_80771AC -_0807853E: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078548: - bl sub_8077200 - cmp r0, 0x3 - beq _08078552 - b _080787AA -_08078552: - ldr r0, =gEnemyParty - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - lsls r1, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - movs r2, 0xC8 - bl sub_8078438 - bl sub_8077210 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_0807857C: - ldr r0, =gBlockSendBuffer - ldr r1, =gPlayerParty + 200 - movs r2, 0xC8 - bl sub_8078438 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078598: - cmp r5, 0 - bne _080785A2 - movs r0, 0x1 - bl sub_80771AC -_080785A2: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080785AC: - bl sub_8077200 - cmp r0, 0x3 - beq _080785B6 - b _080787AA -_080785B6: - ldr r0, =gEnemyParty + 200 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - lsls r1, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - movs r2, 0xC8 - bl sub_8078438 - bl sub_8077210 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080785E0: - ldr r0, =gBlockSendBuffer - ldr r1, =gPlayerParty + 400 - movs r2, 0xC8 - bl sub_8078438 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080785FC: - cmp r5, 0 - bne _08078606 - movs r0, 0x1 - bl sub_80771AC -_08078606: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078610: - bl sub_8077200 - cmp r0, 0x3 - beq _0807861A - b _080787AA -_0807861A: - ldr r0, =gEnemyParty + 400 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - lsls r1, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - movs r2, 0xC8 - bl sub_8078438 - bl sub_8077210 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078644: - ldr r0, =gBlockSendBuffer - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - ldr r2, =0x00002be0 - adds r1, r2 - movs r2, 0xDC - bl sub_8078438 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_0807866C: - cmp r5, 0 - bne _08078676 - movs r0, 0x3 - bl sub_80771AC -_08078676: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_08078680: - bl sub_8077200 - cmp r0, 0x3 - beq _0807868A - b _080787AA -_0807868A: - ldr r0, =gUnknown_020321C0 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - lsls r1, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - movs r2, 0xD8 - bl sub_8078438 - bl sub_8077210 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080786B4: - ldr r0, =gBlockSendBuffer - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - ldr r2, =0x000031a8 - adds r1, r2 - movs r2, 0xB - bl sub_8078438 - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080786DC: - cmp r5, 0 - bne _080786E6 - movs r0, 0x4 - bl sub_80771AC -_080786E6: - ldr r0, =gUnknown_0203229C - ldr r1, [r0] - b _080787A2 - .pool -_080786F0: - bl sub_8077200 - cmp r0, 0x3 - bne _080787AA - ldr r4, =gUnknown_0203229C - ldr r0, [r4] - adds r0, 0xA9 - movs r2, 0x1 - adds r1, r5, 0 - eors r1, r2 - lsls r1, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - movs r2, 0xB - bl sub_8078438 - bl sub_8077210 - ldr r1, [r4] - b _080787A2 - .pool -_08078720: - ldr r4, =gEnemyParty - ldr r6, =0x0000012f - movs r5, 0x5 -_08078726: - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _08078766 - cmp r0, r6 - bne _08078766 - adds r0, r4, 0 - movs r1, 0x3 - bl GetMonData - cmp r0, 0x1 - beq _08078766 - adds r0, r4, 0 - movs r1, 0x2 - mov r2, sp - bl GetMonData - mov r0, sp - ldr r1, =gJPText_Shedinja - bl StringCompareWithoutExtCtrlCodes - cmp r0, 0 - bne _08078766 - adds r0, r4, 0 - movs r1, 0x2 - ldr r2, =gSpeciesNames + 303 * POKEMON_NAME_LENGTH @ SPECIES_SHEDINJA - bl SetMonData -_08078766: - adds r4, 0x64 - subs r5, 0x1 - cmp r5, 0 - bge _08078726 - movs r0, 0x1 - b _080787AC - .pool -_08078784: - ldr r2, =gUnknown_0203229C - ldr r1, [r2] - adds r1, 0xA8 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r2] - adds r1, r0, 0 - adds r1, 0xA8 - ldrb r0, [r1] - cmp r0, 0xA - bls _080787AA - movs r0, 0 - strb r0, [r1] - ldr r1, [r2] -_080787A2: - adds r1, 0x69 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_080787AA: - movs r0, 0 -_080787AC: - add sp, 0xC - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end shedinja_maker_maybe - - thumb_func_start sub_80787B8 -sub_80787B8: @ 80787B8 - push {lr} - ldr r0, =gText_IsThisTradeOkay - ldr r1, =gUnknown_0203229C - ldr r1, [r1] - adds r1, 0x72 - ldrh r1, [r1] - lsls r1, 5 - ldr r2, =0x06010000 - adds r1, r2 - movs r2, 0x18 - bl sub_807A308 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80787B8 - thumb_func_start sub_80787E0 sub_80787E0: @ 80787E0 push {r4,lr} diff --git a/include/graphics.h b/include/graphics.h index 33a26068b..924d2d58e 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4754,4 +4754,9 @@ extern const u32 gUnknown_08C2DDA4[]; extern const u32 gUnknown_08C2EA50[]; extern const u32 gUnknown_08C2EA9C[]; +// Trade +extern const u16 gUnknown_08DDB3E4[]; +extern const u8 gUnknown_08DDB464[]; +extern const u16 gUnknown_08DDCF04[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/librfu.h b/include/librfu.h index 49df42541..38c819835 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -255,6 +255,6 @@ void rfu_REQ_recvData(void); void rfu_UNI_readySendData(u8 a0); void rfu_UNI_clearRecvNewDataFlag(u8 a0); void rfu_REQ_PARENT_resumeRetransmitAndChange(void); -void rfu_NI_setSendData(u8, u8, u8 *, u8); +void rfu_NI_setSendData(u8, u8, const void *, u32); #endif // GUARD_LIBRFU_H diff --git a/include/link.h b/include/link.h index f12f0990f..f2463983b 100644 --- a/include/link.h +++ b/include/link.h @@ -311,5 +311,6 @@ void sub_800AD10(void); void sub_800AB18(void); void sub_8009F18(void); bool8 sub_800AA60(void); +void sub_800ABF4(u16 a0); #endif // GUARD_LINK_H diff --git a/include/link_rfu.h b/include/link_rfu.h index 426565e56..eb7097bc1 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -278,5 +278,7 @@ void sub_8011DE0(u32 arg0); u8 sub_801100C(int a0); void sub_800EF7C(void); bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); +s32 sub_800E87C(u8 idx); +void sub_8011BA4(void); #endif //GUARD_LINK_RFU_H diff --git a/include/party_menu.h b/include/party_menu.h index cb82eb82c..35c06f6e0 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -61,6 +61,8 @@ u8 sub_81B205C(struct Pokemon* a); void sub_81B617C(void); u8 sub_81B6D14(u16 a); bool8 hm_add_c3_without_phase_2(void); +void sub_81B5D30(void); +void sub_81B5D4C(u8 *a0, u8 *a1, u8 a2); extern void dp05_ether(u8, u16, TaskFunc); extern void dp05_pp_up(u8, u16, TaskFunc); diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index f1c8a3e61..926b7585b 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -16,5 +16,6 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u u8 UpdateMonIconFrame(struct Sprite *sprite); void LoadMonIconPalette(u16 species); void sub_80D328C(struct Sprite *sprite); +void sub_80D3014(struct Sprite *sprite); #endif // GUARD_POKEMON_ICON_H diff --git a/include/trainer_card.h b/include/trainer_card.h index d80a5fa52..1af247d8a 100644 --- a/include/trainer_card.h +++ b/include/trainer_card.h @@ -38,5 +38,6 @@ void sub_80C3120(struct TrainerCard *arg0, u16 *arg1, u8 gameVersion); void TrainerCard_ShowLinkCard(u8 arg0, void (*callback)(void)); void TrainerCard_GenerateCardForPlayer(struct TrainerCard *); u8 sub_80C4904(u8); +void sub_80C6D80(const u8 *, u8 *, u8, u8, u8); #endif // GUARD_TRAINER_CARD_H diff --git a/ld_script.txt b/ld_script.txt index fcf362aa1..5032fb036 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -81,6 +81,7 @@ SECTIONS { src/smokescreen.o(.text); src/pokeball.o(.text); src/load_save.o(.text); + src/trade.o(.text); asm/trade.o(.text); src/berry_blender.o(.text); src/play_time.o(.text); diff --git a/src/trade.c b/src/trade.c new file mode 100644 index 000000000..fc9b2ead0 --- /dev/null +++ b/src/trade.c @@ -0,0 +1,993 @@ +#include "global.h" +#include "alloc.h" +#include "bg.h" +#include "cable_club.h" +#include "data2.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "international_string_util.h" +#include "librfu.h" +#include "link.h" +#include "link_rfu.h" +#include "main.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon_icon.h" +#include "sound.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "text_window.h" +#include "trainer_card.h" +#include "trade.h" +#include "window.h" +#include "constants/species.h" +#include "constants/songs.h" +#include "constants/rgb.h" + +extern u8 gUnknown_02022C2C; +extern struct { + u8 unk_0; + u8 unk_1; + u8 filler_2[0x28 - 2]; + u8 unk_28[6]; + u8 unk_2E[6]; + u8 unk_34; + u8 unk_35; + u8 unk_36; + u8 unk_37; + u8 unk_38[12]; + u8 unk_44; + u8 filler_45[0x69 - 0x45]; + u8 unk_69; + u8 filler_6A[0x6F - 0x6A]; + u8 unk_6F; + u8 unk_70; + u8 filler_71; + u16 unk_72; + u8 unk_74; + u8 unk_75; + u8 filler_76[0x7A - 0x76]; + u8 unk_7A; + u8 unk_7B; + u8 filler_7C[0x7E - 0x7C]; + u8 unk_7E; + u8 filler_7F[0xA8 - 0x7F]; + u8 unk_A8; + u8 unk_A9[11]; + u8 filler_B4[0x8F0-0xB4]; + u8 tilemapBuffer[0x800]; +} *gUnknown_0203229C; +extern u8 *gUnknown_02032184; +extern u8 *gUnknown_02032188[14]; +extern u8 gUnknown_02032298[2]; + +extern u8 gUnknown_0203CF20; + +extern const struct BgTemplate gUnknown_0832DEE4[4]; +extern const struct WindowTemplate gUnknown_0832DEF4[]; +extern const u8 gUnknown_0832DE24[][2]; +extern const u8 *gUnknown_0832DE94[]; +extern const struct SpriteTemplate gSpriteTemplate_832DC94; +extern const struct SpriteTemplate gSpriteTemplate_832DCAC; +extern const u8 gTradeStripesBG2Tilemap[]; +extern const u8 gTradeStripesBG3Tilemap[]; +extern struct MailStruct gUnknown_020321C0[PARTY_SIZE]; +extern const u8 gJPText_Shedinja[]; +extern const u8 gText_IsThisTradeOkay[]; + +bool32 sub_8077260(void); +void sub_80773D0(void); +void sub_807811C(void); +void sub_807A19C(u8); +bool8 shedinja_maker_maybe(void); +void sub_807A308(const u8 *, u8 *, u8); +bool8 sub_807A1F0(void); +void sub_807A320(u8); +void sub_8079BE0(u8); +void sub_8078388(void); +void sub_80782B8(u8); +void sub_807A468(u8); +void sub_807A53C(void); +void sub_8078C34(void); +void sub_807825C(void); +void sub_807A5B0(void); +void sub_80795AC(void); +void sub_807A0C4(void); +void sub_80796B4(u8); +void sub_8079E44(u8); + +bool8 sub_8077170(const void *a0, u32 a1) +{ + if (gUnknown_02022C2C == 29) + { + rfu_NI_setSendData(gUnknown_03004140.unk_00, 84, a0, a1); + return TRUE; + } + else + { + return SendBlock(0, a0, a1); + } +} + +void sub_80771AC(u8 a0) +{ + sub_800A4D8(a0); +} + +bool32 sub_80771BC(void) +{ + if (gUnknown_02022C2C == 29) + { + if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) + { + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return sub_800A520(); + } +} + +u32 sub_8077200(void) +{ + return GetBlockReceivedStatus(); +} + +void sub_8077210(void) +{ + if (sub_8077260()) + { + rfu_clearSlot(12, gUnknown_03004140.unk_00); + } + else + { + ResetBlockReceivedFlags(); + } +} + +void sub_8077234(u32 a0) +{ + if (sub_8077260()) + { + rfu_clearSlot(12, gUnknown_03004140.unk_00); + } + else + { + ResetBlockReceivedFlag(a0); + } +} + +bool32 sub_8077260(void) +{ + if (gWirelessCommType != 0 && gUnknown_02022C2C == 29) + { + return TRUE; + } + else + { + return FALSE; + } +} + +void sub_8077288(void) +{ + sub_800ADF8(); +} + +bool8 sub_8077294(void) +{ + return sub_800A520(); +} + +void sub_80772A4(void) +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + ResetPaletteFade(); + + gPaletteFade.bufferTransferDisabled = TRUE; + + SetVBlankCallback(sub_807811C); + LoadPalette(gUnknown_0860F074, 0xF0, 20); + LoadPalette(gUnknown_0860F074, 0xD0, 20); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0832DEE4, ARRAY_COUNT(gUnknown_0832DEE4)); + SetBgTilemapBuffer(1, gUnknown_0203229C->tilemapBuffer); + + if (InitWindows(gUnknown_0832DEF4)) + { + u32 i; + + DeactivateAllTextPrinters(); + + for (i = 0; i < 18; i++) + { + ClearWindowTilemap(i); + FillWindowPixelBuffer(i, 0); + } + + FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 15); + LoadUserWindowBorderGfx_(0, 20, 0xC0); + LoadUserWindowBorderGfx(2, 1, 0xE0); + LoadMonIconPalettes(); + gUnknown_0203229C->unk_69 = 0; + gUnknown_0203229C->unk_6F = 0; + gUnknown_0203229C->unk_70 = 0; + gUnknown_0203229C->unk_74 = 0; + gUnknown_0203229C->unk_75 = 0; + gUnknown_0203229C->unk_7A = 0; + gUnknown_0203229C->unk_7B = 0; + gUnknown_0203229C->unk_A8 = 0; + } +} + +void sub_80773AC(void) +{ + SetMainCallback2(sub_80773D0); + gMain.callback1 = NULL; + gEnemyPartyCount = 0; +} + +void sub_80773D0(void) +{ + int i; + struct SpriteTemplate temp; + u8 id; + u32 xPos; + + switch (gMain.state) + { + case 0: + gUnknown_0203229C = AllocZeroed(sizeof(*gUnknown_0203229C)); + sub_80772A4(); + gUnknown_02032184 = AllocZeroed(0xE00); + + for (i = 0; i < 14; i++) + { + gUnknown_02032188[i] = &gUnknown_02032184[i * 256]; + } + + gMain.state++; + break; + case 1: + gPaletteFade.bufferTransferDisabled = FALSE; + + for (i = 0; i < PARTY_SIZE; i++) + { + CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, 0x20, FALSE, 0, 0, 0); + } + + sub_807A19C(0); + ShowBg(0); + + if (gReceivedRemoteLinkPlayers == 0) + { + gLinkType = 0x1122; + gUnknown_0203229C->unk_A8 = 0; + + if (gWirelessCommType != 0) + { + sub_800B488(); + OpenLink(); + sub_8011BA4(); + } + else + { + OpenLink(); + gMain.state++; + CreateTask(task00_08081A90, 1); + } + } + else + { + gMain.state = 4; + } + break; + case 2: + gUnknown_0203229C->unk_A8++; + if (gUnknown_0203229C->unk_A8 > 11) + { + gUnknown_0203229C->unk_A8 = 0; + gMain.state++; + } + break; + case 3: + if (GetLinkPlayerCount_2() >= sub_800AA48()) + { + if (IsLinkMaster()) + { + if (++gUnknown_0203229C->unk_A8 > 30) + { + sub_800A620(); + gMain.state++; + } + } + else + { + gMain.state++; + } + } + break; + case 4: + if (gReceivedRemoteLinkPlayers == 1 && IsLinkPlayerDataExchangeComplete() == 1) + { + sub_8011BD0(); + CalculatePlayerPartyCount(); + gMain.state++; + gUnknown_0203229C->unk_A8 = 0; + if (gWirelessCommType != 0) + { + sub_801048C(TRUE); + sub_800ADF8(); + } + } + break; + case 5: + if (gWirelessCommType != 0) + { + if (sub_8010500()) + { + gMain.state++; + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + } + else + { + gMain.state++; + } + break; + case 6: + if (shedinja_maker_maybe()) + { + sub_807A5B0(); + gMain.state++; + } + break; + case 7: + CalculateEnemyPartyCount(); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + gUnknown_0203229C->unk_36 = gPlayerPartyCount; + gUnknown_0203229C->unk_37 = gEnemyPartyCount; + + for (i = 0; i < gUnknown_0203229C->unk_36; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + gUnknown_0203229C->unk_28[i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sub_80D3014, + (gUnknown_0832DE24[i][0] * 8) + 14, + (gUnknown_0832DE24[i][1] * 8) - 12, + 1, + GetMonData(mon, MON_DATA_PERSONALITY), + TRUE); + } + + for (i = 0; i < gUnknown_0203229C->unk_37; i++) + { + struct Pokemon *mon = &gEnemyParty[i]; + gUnknown_0203229C->unk_2E[i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sub_80D3014, + (gUnknown_0832DE24[i + 6][0] * 8) + 14, + (gUnknown_0832DE24[i + 6][1] * 8) - 12, + 1, + GetMonData(mon, MON_DATA_PERSONALITY), + FALSE); + } + gMain.state++; + break; + case 8: + sub_81B5D30(); + sub_81B5D4C(&gUnknown_0203229C->unk_36, gUnknown_0203229C->unk_28, 0); + gMain.state++; + break; + case 9: + sub_81B5D4C(&gUnknown_0203229C->unk_36, gUnknown_0203229C->unk_28, 1); + gMain.state++; + break; + case 10: + sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + id = GetMultiplayerId(); + sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); + sub_80C6D80(gUnknown_0832DE94[0], gUnknown_02032188[6], 0, 0, 2); + sub_807A308(gUnknown_0832DE94[1], gUnknown_02032188[8], 24); + gMain.state++; + gUnknown_0203229C->unk_A8 = 0; + break; + case 11: + if (sub_807A1F0()) + gMain.state++; + break; + case 12: + xPos = GetStringCenterAlignXOffset(1, gSaveBlock2Ptr->playerName, 120); + for (i = 0; i < 3; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i; + CreateSprite(&temp, xPos + (i * 32) + 16, 10, 1); + } + + xPos = GetStringCenterAlignXOffset(1, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); + for (i = 0; i < 3; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i + 3; + CreateSprite(&temp, xPos + (i * 32) + 136, 10, 1); + } + gMain.state++; + break; + case 13: + temp = gSpriteTemplate_832DCAC; + temp.tileTag += 6; + CreateSprite(&temp, 215, 152, 1); + temp = gSpriteTemplate_832DCAC; + temp.tileTag += 7; + CreateSprite(&temp, 247, 152, 1); + + for (i = 0; i < 6; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i + 8; + CreateSprite(&temp, (i * 32) + 24, 150, 1); + } + + gUnknown_0203229C->unk_34 = CreateSprite(&gSpriteTemplate_832DC94, gUnknown_0832DE24[0][0] * 8 + 32, gUnknown_0832DE24[0][1] * 8, 2); + gUnknown_0203229C->unk_35 = 0; + gMain.state++; + rbox_fill_rectangle(0); + break; + case 14: + sub_807A320(0); + sub_8079BE0(0); + gUnknown_0203229C->unk_0 = 0; + gUnknown_0203229C->unk_1 = 0; + sub_8078388(); + gMain.state++; + PlayBGM(MUS_P_SCHOOL); + break; + case 15: + sub_807A320(1); + sub_8079BE0(1); + gMain.state++; + case 16: // fallthrough + sub_80782B8(0); + gMain.state++; + break; + case 17: + sub_80782B8(1); + gMain.state++; + break; + case 18: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + case 19: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + sub_80782B8(2); + gMain.state++; + break; + case 20: + sub_807A468(0); + gMain.state++; + break; + case 21: + sub_807A468(1); + sub_807A53C(); + gMain.state++; + break; + case 22: + if (!gPaletteFade.active) + { + gMain.callback1 = sub_8078C34; + SetMainCallback2(sub_807825C); + } + break; + } + + RunTextPrinters(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_8077B74(void) +{ + int i; + struct SpriteTemplate temp; + u8 id; + u32 xPos; + + switch (gMain.state) + { + case 0: + sub_80772A4(); + gMain.state++; + break; + case 1: + gMain.state++; + gUnknown_0203229C->unk_A8 = 0; + break; + case 2: + gMain.state++; + break; + case 3: + gMain.state++; + break; + case 4: + CalculatePlayerPartyCount(); + gMain.state++; + break; + case 5: + if (gWirelessCommType != 0) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + gMain.state++; + break; + case 6: + gMain.state++; + break; + case 7: + CalculateEnemyPartyCount(); + gUnknown_0203229C->unk_36 = gPlayerPartyCount; + gUnknown_0203229C->unk_37 = gEnemyPartyCount; + ClearWindowTilemap(0); + sub_8079BE0(0); + sub_8079BE0(1); + + for (i = 0; i < gUnknown_0203229C->unk_36; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + gUnknown_0203229C->unk_28[i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sub_80D3014, + (gUnknown_0832DE24[i][0] * 8) + 14, + (gUnknown_0832DE24[i][1] * 8) - 12, + 1, + GetMonData(mon, MON_DATA_PERSONALITY), + TRUE); + } + + for (i = 0; i < gUnknown_0203229C->unk_37; i++) + { + struct Pokemon *mon = &gEnemyParty[i]; + gUnknown_0203229C->unk_2E[i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sub_80D3014, + gUnknown_0832DE24[i + 6][0] * 8 + 14, + (gUnknown_0832DE24[i + 6][1] * 8) - 12, + 1, + GetMonData(mon, MON_DATA_PERSONALITY), + FALSE); + } + gMain.state++; + break; + case 8: + sub_81B5D30(); + sub_81B5D4C(&gUnknown_0203229C->unk_36, gUnknown_0203229C->unk_28, 0); + gMain.state++; + break; + case 9: + sub_81B5D4C(&gUnknown_0203229C->unk_36, gUnknown_0203229C->unk_28, 1); + gMain.state++; + break; + case 10: + sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + id = GetMultiplayerId(); + sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); + sub_80C6D80(gUnknown_0832DE94[0], gUnknown_02032188[6], 0, 0, 2); + sub_807A308(gUnknown_0832DE94[1], gUnknown_02032188[8], 24); + gMain.state++; + gUnknown_0203229C->unk_A8 = 0; + break; + case 11: + if (sub_807A1F0()) + gMain.state++; + break; + case 12: + xPos = GetStringCenterAlignXOffset(1, gSaveBlock2Ptr->playerName, 120); + for (i = 0; i < 3; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i; + CreateSprite(&temp, xPos + (i * 32) + 16, 10, 1); + } + + xPos = GetStringCenterAlignXOffset(1, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); + for (i = 0; i < 3; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i + 3; + CreateSprite(&temp, xPos + (i * 32) + 136, 10, 1); + } + gMain.state++; + break; + case 13: + temp = gSpriteTemplate_832DCAC; + temp.tileTag += 6; + CreateSprite(&temp, 215, 152, 1); + temp = gSpriteTemplate_832DCAC; + temp.tileTag += 7; + CreateSprite(&temp, 247, 152, 1); + + for (i = 0; i < PARTY_SIZE; i++) + { + temp = gSpriteTemplate_832DCAC; + temp.tileTag += i + 8; + CreateSprite(&temp, (i * 32) + 24, 150, 1); + } + + if (gUnknown_0203229C->unk_35 < PARTY_SIZE) + { + gUnknown_0203229C->unk_35 = gUnknown_0203CF20; + } + else + { + gUnknown_0203229C->unk_35 = gUnknown_0203CF20 + PARTY_SIZE; + } + + gUnknown_0203229C->unk_34 = CreateSprite(&gSpriteTemplate_832DC94, gUnknown_0832DE24[gUnknown_0203229C->unk_35][0] * 8 + 32, gUnknown_0832DE24[gUnknown_0203229C->unk_35][1] * 8, 2); + gMain.state = 16; + break; + case 16: + sub_80782B8(0); + gMain.state++; + break; + case 17: + sub_80782B8(1); + gUnknown_0203229C->unk_0 = 0; + gUnknown_0203229C->unk_1 = 0; + sub_8078388(); + gMain.state++; + break; + case 18: + gPaletteFade.bufferTransferDisabled = FALSE; + BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + case 19: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + sub_80782B8(2); + gMain.state++; + break; + case 20: + gMain.state++; + break; + case 21: + sub_807A53C(); + gMain.state++; + break; + case 22: + if (!gPaletteFade.active) + { + SetMainCallback2(sub_807825C); + } + break; + } + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_807811C(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void sub_8078130(void) +{ + if (++gUnknown_0203229C->unk_A8 > 15) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_0203229C->unk_6F = 10; + } +} + +void sub_807816C(void) +{ + if (!gPaletteFade.active) + { + gUnknown_02032298[0] = gUnknown_0203229C->unk_35; + gUnknown_02032298[1] = gUnknown_0203229C->unk_7E; + + if (gWirelessCommType != 0) + { + gUnknown_0203229C->unk_6F = 16; + } + else + { + sub_800ABF4(32); + gUnknown_0203229C->unk_6F = 13; + } + } +} + +void sub_80781C8(void) +{ + gMain.savedCallback = sub_80773AC; + + if (gWirelessCommType != 0) + { + if (sub_8010500()) + { + Free(gUnknown_02032184); + FreeAllWindowBuffers(); + Free(gUnknown_0203229C); + gMain.callback1 = NULL; + sub_800E084(); + SetMainCallback2(sub_807AE50); + } + } + else + { + if (gReceivedRemoteLinkPlayers == 0) + { + Free(gUnknown_02032184); + FreeAllWindowBuffers(); + Free(gUnknown_0203229C); + gMain.callback1 = NULL; + SetMainCallback2(sub_807AE50); + } + } +} + +void sub_807825C(void) +{ + u8 temp; + + sub_80795AC(); + sub_807A0C4(); + sub_80796B4(0); + sub_80796B4(1); + + SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_0203229C->unk_0++); + SetGpuReg(REG_OFFSET_BG3HOFS, gUnknown_0203229C->unk_1--); + + RunTextPrintersAndIsPrinter0Active(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_80782B8(u8 a0) +{ + int i; + + switch (a0) + { + case 0: + LoadPalette(gUnknown_08DDB3E4, 0, 0x60); + LoadBgTiles(1, gUnknown_08DDB464, 0x1280, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDCF04, 0, 0, 32, 20, 0); + LoadBgTilemap(2, gTradeStripesBG2Tilemap, 0x800, 0); + break; + case 1: + LoadBgTilemap(3, gTradeStripesBG3Tilemap, 0x800, 0); + sub_8079E44(0); + sub_8079E44(1); + CopyBgTilemapBufferToVram(1); + break; + case 2: + for (i = 0; i < 4; i++) + { + SetGpuReg(REG_OFFSET_BG0HOFS + (i * 2), 0); + } + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + break; + } +} + +void sub_8078388(void) +{ + int i; + + for (i = 0; i < 6; i++) + { + if (i < gUnknown_0203229C->unk_36) + { + gSprites[gUnknown_0203229C->unk_28[i]].invisible = FALSE; + gUnknown_0203229C->unk_38[i] = TRUE; + } + else + { + gUnknown_0203229C->unk_38[i] = FALSE; + } + + if (i < gUnknown_0203229C->unk_37) + { + gSprites[gUnknown_0203229C->unk_2E[i]].invisible = FALSE; + gUnknown_0203229C->unk_38[i + 6] = TRUE; + } + else + { + gUnknown_0203229C->unk_38[i + 6] = FALSE; + } + } + + gUnknown_0203229C->unk_44 = 1; +} + +void sub_8078438(u8 *dest, const u8 *src, u32 count) +{ + u32 i; + + for (i = 0; i < count; i++) + { + dest[i] = src[i]; + } +} + +bool8 shedinja_maker_maybe(void) +{ + u8 id = GetMultiplayerId(); + int i; + struct Pokemon *mon; + + switch (gUnknown_0203229C->unk_69) + { + case 0: + sub_8078438(gBlockSendBuffer, (void *)&gPlayerParty[0], 200); + gUnknown_0203229C->unk_69++; + gUnknown_0203229C->unk_A8 = 0; + break; + case 1: + if (sub_80771BC()) + { + if (!sub_8077200()) + { + gUnknown_0203229C->unk_69++; + } + else + { + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + } + break; + case 3: + if (id == 0) + { + sub_80771AC(1); + } + gUnknown_0203229C->unk_69++; + break; + case 4: + if (sub_8077200() == 3) + { + sub_8078438((void *)&gEnemyParty[0], (void *)gBlockRecvBuffer[id ^ 1], 200); + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + break; + case 5: + sub_8078438(gBlockSendBuffer, (void *)&gPlayerParty[2], 200); + gUnknown_0203229C->unk_69++; + break; + case 7: + if (id == 0) + { + sub_80771AC(1); + } + gUnknown_0203229C->unk_69++; + break; + case 8: + if (sub_8077200() == 3) + { + sub_8078438((void *)&gEnemyParty[2], (void *)gBlockRecvBuffer[id ^ 1], 200); + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + break; + case 9: + sub_8078438(gBlockSendBuffer, (void *)&gPlayerParty[4], 200); + gUnknown_0203229C->unk_69++; + break; + case 11: + if (id == 0) + { + sub_80771AC(1); + } + gUnknown_0203229C->unk_69++; + break; + case 12: + if (sub_8077200() == 3) + { + sub_8078438((void *)&gEnemyParty[4], (void *)gBlockRecvBuffer[id ^ 1], 200); + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + break; + case 13: + sub_8078438(gBlockSendBuffer, (void *)gSaveBlock1Ptr->mail, 220); + gUnknown_0203229C->unk_69++; + break; + case 15: + if (id == 0) + { + sub_80771AC(3); + } + gUnknown_0203229C->unk_69++; + break; + case 16: + if (sub_8077200() == 3) + { + sub_8078438((void *)gUnknown_020321C0, (void *)gBlockRecvBuffer[id ^ 1], 216); + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + break; + case 17: + sub_8078438(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11); + gUnknown_0203229C->unk_69++; + break; + case 19: + if (id == 0) + { + sub_80771AC(4); + } + gUnknown_0203229C->unk_69++; + break; + case 20: + if (sub_8077200() == 3) + { + sub_8078438(gUnknown_0203229C->unk_A9, (void *)gBlockRecvBuffer[id ^ 1], 11); + sub_8077210(); + gUnknown_0203229C->unk_69++; + } + break; + case 21: + for (i = 0, mon = gEnemyParty; i < 6; mon++, i++) + { + u8 name[POKEMON_NAME_LENGTH + 1]; + u16 species = GetMonData(mon, MON_DATA_SPECIES); + + if (species != SPECIES_NONE) + { + if (species == SPECIES_SHEDINJA && GetMonData(mon, MON_DATA_LANGUAGE) != LANGUAGE_JAPANESE) + { + GetMonData(mon, MON_DATA_NICKNAME, name); + + if (!StringCompareWithoutExtCtrlCodes(name, gJPText_Shedinja)) + { + SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[SPECIES_SHEDINJA]); + } + } + } + } + return TRUE; + case 2: + case 6: + case 10: + case 14: + case 18: + gUnknown_0203229C->unk_A8++; + if (gUnknown_0203229C->unk_A8 > 10) + { + gUnknown_0203229C->unk_A8 = 0; + gUnknown_0203229C->unk_69++; + } + break; + } + return FALSE; +} + +void sub_80787B8(void) +{ + sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (gUnknown_0203229C->unk_72 * 32)), 24); +}