diff --git a/asm/trade.s b/asm/trade.s index dd5ff89c5..2fad5efed 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -6,1992 +6,6 @@ .text - thumb_func_start sub_807A8D0 -sub_807A8D0: @ 807A8D0 - push {r4-r6,lr} - lsls r1, 16 - lsrs r5, r1, 16 - adds r6, r5, 0 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 24 - lsrs r3, 24 - lsls r0, 23 - lsrs r4, r0, 31 - adds r0, r2, 0 - adds r1, r3, 0 - bl sub_807A7BC - cmp r0, 0 - bne _0807A90A - cmp r4, 0 - bne _0807A90E - movs r0, 0xCE - lsls r0, 1 - cmp r5, r0 - bne _0807A900 - movs r0, 0x2 - b _0807A910 -_0807A900: - adds r0, r6, 0 - bl IsSpeciesInHoennDex - cmp r0, 0 - bne _0807A90E -_0807A90A: - movs r0, 0x1 - b _0807A910 -_0807A90E: - movs r0, 0 -_0807A910: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_807A8D0 - - thumb_func_start sub_807A918 -sub_807A918: @ 807A918 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x18 - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - movs r5, 0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r5, r0 - bge _0807A95A - mov r4, sp -_0807A934: - movs r0, 0x64 - muls r0, r5 - adds r0, r6, r0 - movs r1, 0x41 - bl GetMonData - str r0, [r4] - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _0807A94E - movs r0, 0 - str r0, [r4] -_0807A94E: - adds r4, 0x4 - adds r5, 0x1 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r5, r0 - blt _0807A934 -_0807A95A: - movs r7, 0 - movs r6, 0x1 - movs r5, 0 - ldr r4, =gLinkPlayers - b _0807A980 - .pool -_0807A96C: - ldrb r0, [r4] - subs r0, 0x4 - cmp r0, 0x1 - bhi _0807A978 - movs r7, 0 - b _0807A97C -_0807A978: - movs r0, 0x1 - orrs r7, r0 -_0807A97C: - adds r4, 0x1C - adds r5, 0x1 -_0807A980: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r5, r0 - blt _0807A96C - movs r5, 0 - movs r4, 0 - b _0807A9B4 -_0807A992: - ldr r0, =gLinkPlayers - adds r2, r4, r0 - ldrb r1, [r2, 0x10] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _0807A9A2 - movs r6, 0 -_0807A9A2: - cmp r7, 0 - beq _0807A9B0 - ldrb r0, [r2, 0x10] - lsrs r0, 4 - cmp r0, 0 - beq _0807A9B0 - movs r6, 0 -_0807A9B0: - adds r4, 0x1C - adds r5, 0x1 -_0807A9B4: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r5, r0 - blt _0807A992 - cmp r6, 0 - bne _0807A9EA - mov r1, r8 - lsls r0, r1, 2 - mov r1, sp - adds r4, r1, r0 - ldrh r0, [r4] - bl IsSpeciesInHoennDex - cmp r0, 0 - bne _0807A9E0 - movs r0, 0x2 - b _0807AA1A - .pool -_0807A9E0: - ldr r0, [r4] - cmp r0, 0 - bne _0807A9EA - movs r0, 0x3 - b _0807AA1A -_0807A9EA: - movs r2, 0 - movs r5, 0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r2, r0 - bge _0807AA0A - adds r3, r0, 0 - mov r1, sp -_0807A9FA: - cmp r8, r5 - beq _0807AA02 - ldr r0, [r1] - adds r2, r0 -_0807AA02: - adds r1, 0x4 - adds r5, 0x1 - cmp r5, r3 - blt _0807A9FA -_0807AA0A: - cmp r2, 0 - beq _0807AA18 - movs r0, 0 - b _0807AA1A - .pool -_0807AA18: - movs r0, 0x1 -_0807AA1A: - add sp, 0x18 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_807A918 - - thumb_func_start sub_807AA28 -sub_807AA28: @ 807AA28 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _0807AA44 - movs r0, 0x17 - bl PlaySE - movs r0, 0 - strh r0, [r4, 0x2E] -_0807AA44: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_807AA28 - - thumb_func_start sub_807AA4C -sub_807AA4C: @ 807AA4C - push {r4,r5,lr} - adds r4, r0, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _0807AA76 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _0807AA76 - movs r0, 0xC2 - bl PlaySE - strh r5, [r4, 0x2E] -_0807AA76: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_807AA4C - - thumb_func_start sub_807AA7C -sub_807AA7C: @ 807AA7C - push {lr} - adds r2, r0, 0 - movs r0, 0x30 - ldrsh r1, [r2, r0] - cmp r1, 0 - bne _0807AAB2 - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - bne _0807AA98 - strh r1, [r2, 0x2E] -_0807AA98: - movs r1, 0x2E - ldrsh r0, [r2, r1] - lsls r0, 1 - ldr r1, =gUnknown_08338EA4 - adds r0, r1 - ldrb r1, [r2, 0x5] - lsrs r1, 4 - adds r1, 0x10 - lsls r1, 4 - adds r1, 0x4 - movs r2, 0x2 - bl LoadPalette -_0807AAB2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_807AA7C - - thumb_func_start sub_807AABC -sub_807AABC: @ 807AABC - push {lr} - adds r2, r0, 0 - ldrh r1, [r2, 0x2E] - adds r1, 0x1 - strh r1, [r2, 0x2E] - ldrh r0, [r2, 0x26] - adds r0, 0x1 - strh r0, [r2, 0x26] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0xA - bne _0807AADA - adds r0, r2, 0 - bl DestroySprite -_0807AADA: - pop {r0} - bx r0 - thumb_func_end sub_807AABC - - thumb_func_start sub_807AAE0 -sub_807AAE0: @ 807AAE0 - push {lr} - adds r2, r0, 0 - ldrh r1, [r2, 0x2E] - adds r1, 0x1 - strh r1, [r2, 0x2E] - ldrh r0, [r2, 0x26] - subs r0, 0x1 - strh r0, [r2, 0x26] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0xA - bne _0807AAFE - adds r0, r2, 0 - bl DestroySprite -_0807AAFE: - pop {r0} - bx r0 - thumb_func_end sub_807AAE0 - - thumb_func_start sub_807AB04 -sub_807AB04: @ 807AB04 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xF - bne _0807AB20 - movs r0, 0xCC - bl PlaySE - movs r0, 0 - strh r0, [r4, 0x2E] -_0807AB20: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_807AB04 - - thumb_func_start sub_807AB28 -sub_807AB28: @ 807AB28 - push {r4,r5,lr} - sub sp, 0x20 - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - mov r12, r0 - adds r0, 0xD4 - ldrh r1, [r0] - lsls r1, 8 - adds r0, 0x2 - ldrh r2, [r0] - lsls r2, 8 - adds r0, 0x6 - movs r4, 0 - ldrsh r3, [r0, r4] - adds r0, 0x2 - movs r5, 0 - ldrsh r0, [r0, r5] - str r0, [sp] - mov r4, r12 - adds r4, 0xE8 - movs r5, 0 - ldrsh r0, [r4, r5] - str r0, [sp, 0x4] - movs r5, 0 - ldrsh r0, [r4, r5] - str r0, [sp, 0x8] - mov r0, r12 - adds r0, 0xEC - ldrh r0, [r0] - str r0, [sp, 0xC] - add r0, sp, 0x10 - bl DoBgAffineSet - add r0, sp, 0x10 - ldrh r1, [r0] - movs r0, 0x20 - bl SetGpuReg - add r0, sp, 0x10 - ldrh r1, [r0, 0x2] - movs r0, 0x22 - bl SetGpuReg - add r0, sp, 0x10 - ldrh r1, [r0, 0x4] - movs r0, 0x24 - bl SetGpuReg - add r0, sp, 0x10 - ldrh r1, [r0, 0x6] - movs r0, 0x26 - bl SetGpuReg - ldr r1, [sp, 0x18] - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x28 - bl SetGpuReg - ldr r1, [sp, 0x18] - lsrs r1, 16 - movs r0, 0x2A - bl SetGpuReg - ldr r1, [sp, 0x1C] - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x2C - bl SetGpuReg - ldr r1, [sp, 0x1C] - lsrs r1, 16 - movs r0, 0x2E - bl SetGpuReg - add sp, 0x20 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807AB28 - - thumb_func_start sub_807ABCC -sub_807ABCC: @ 807ABCC - push {r4,lr} - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r0, 0xE0 - ldrh r1, [r0] - movs r0, 0x16 - bl SetGpuReg - ldr r0, [r4] - adds r0, 0xE2 - ldrh r1, [r0] - movs r0, 0x14 - bl SetGpuReg - movs r0, 0 - bl GetGpuReg - lsls r0, 16 - movs r1, 0xE0 - lsls r1, 11 - ands r1, r0 - cmp r1, 0 - bne _0807AC18 - ldr r0, [r4] - adds r0, 0xE4 - ldrh r1, [r0] - movs r0, 0x1A - bl SetGpuReg - ldr r0, [r4] - adds r0, 0xE6 - ldrh r1, [r0] - movs r0, 0x18 - bl SetGpuReg - b _0807AC1C - .pool -_0807AC18: - bl sub_807AB28 -_0807AC1C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_807ABCC - - thumb_func_start sub_807AC24 -sub_807AC24: @ 807AC24 - push {lr} - bl sub_807ABCC - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_807AC24 - - thumb_func_start sub_807AC3C -sub_807AC3C: @ 807AC3C - push {r4,lr} - ldr r3, =gUnknown_020322A0 - ldr r1, [r3] - movs r0, 0x8A - adds r0, r1 - mov r12, r0 - movs r2, 0 - movs r0, 0 - mov r4, r12 - strh r0, [r4] - adds r1, 0x88 - strb r2, [r1] - ldr r0, [r3] - adds r0, 0x89 - strb r2, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807AC3C - - thumb_func_start sub_807AC64 -sub_807AC64: @ 807AC64 - push {r4,r5,lr} - ldr r0, =gUnknown_020322A0 - ldr r2, [r0] - adds r1, r2, 0 - adds r1, 0x88 - adds r3, r2, 0 - adds r3, 0x89 - ldrb r1, [r1] - adds r5, r0, 0 - ldrb r3, [r3] - cmp r1, r3 - bne _0807AC8C - adds r1, r2, 0 - adds r1, 0x8A - ldrh r0, [r1] - adds r0, 0x1 - b _0807AC92 - .pool -_0807AC8C: - adds r1, r2, 0 - adds r1, 0x8A - movs r0, 0 -_0807AC92: - strh r0, [r1] - adds r4, r5, 0 - ldr r0, [r4] - adds r0, 0x8A - ldrh r1, [r0] - movs r0, 0x96 - lsls r0, 1 - cmp r1, r0 - bls _0807ACC4 - bl CloseLink - ldr r0, =CB2_LinkError - bl SetMainCallback2 - ldr r1, [r4] - adds r3, r1, 0 - adds r3, 0x8A - movs r2, 0 - movs r0, 0 - strh r0, [r3] - adds r1, 0x89 - strb r2, [r1] - ldr r0, [r4] - adds r0, 0x88 - strb r2, [r0] -_0807ACC4: - ldr r0, [r5] - adds r1, r0, 0 - adds r1, 0x88 - ldrb r1, [r1] - adds r0, 0x89 - strb r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807AC64 - - thumb_func_start sub_807ACDC -sub_807ACDC: @ 807ACDC - push {lr} - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0807ACF0 - movs r0, 0 - b _0807ACF8 - .pool -_0807ACF0: - bl GetMultiplayerId - lsls r0, 24 - lsrs r0, 24 -_0807ACF8: - pop {r1} - bx r1 - thumb_func_end sub_807ACDC - - thumb_func_start sub_807ACFC -sub_807ACFC: @ 807ACFC - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - movs r4, 0 - mov r8, r4 - cmp r6, 0 - bne _0807AD22 - ldr r0, =gUnknown_02032298 - ldrb r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - adds r1, r0 - mov r8, r1 - movs r4, 0x1 -_0807AD22: - cmp r6, 0x1 - bne _0807AD40 - ldr r0, =gUnknown_02032298 - ldrb r0, [r0, 0x1] - movs r1, 0x6 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty - adds r1, r0 - mov r8, r1 - movs r4, 0x3 -_0807AD40: - cmp r5, 0 - beq _0807AD58 - cmp r5, 0x1 - beq _0807ADE0 - b _0807AE36 - .pool -_0807AD58: - mov r0, r8 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - mov r0, r8 - movs r1, 0 - bl GetMonData - adds r7, r0, 0 - cmp r6, 0 - bne _0807AD94 - lsls r0, r5, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x8] - adds r2, r5, 0 - adds r3, r7, 0 - bl HandleLoadSpecialPokePic_2 - movs r4, 0 - b _0807ADB2 - .pool -_0807AD94: - lsls r0, r5, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r2, [r1] - lsls r4, r6, 1 - adds r1, r4, 0x1 - lsls r1, 2 - adds r2, 0x4 - adds r2, r1 - ldr r1, [r2] - adds r2, r5, 0 - adds r3, r7, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys -_0807ADB2: - mov r0, r8 - bl GetMonSpritePalStruct - bl LoadCompressedSpritePalette - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF0 - adds r0, r4 - strh r5, [r0] - lsls r0, r6, 2 - adds r1, 0x68 - adds r1, r0 - str r7, [r1] - b _0807AE36 - .pool -_0807ADE0: - mov r0, r8 - bl GetMonSpritePalStruct - ldrh r0, [r0, 0x4] - adds r1, r4, 0 - bl SetMultiuseSpriteTemplateToPokemon - ldr r0, =gMultiuseSpriteTemplate - movs r1, 0x78 - movs r2, 0x3C - movs r3, 0x6 - bl CreateSprite - ldr r4, =gUnknown_020322A0 - ldr r1, [r4] - adds r1, 0x8E - adds r1, r6 - strb r0, [r1] - ldr r3, =gSprites - ldr r0, [r4] - adds r0, 0x8E - adds r0, r6 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0x8E - adds r0, r6 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r3, 0x1C - adds r0, r3 - ldr r1, =SpriteCallbackDummy - str r1, [r0] -_0807AE36: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807ACFC - - thumb_func_start sub_807AE50 -sub_807AE50: @ 807AE50 - push {r4,r5,lr} - sub sp, 0x4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0xC - bls _0807AE66 - b _0807B116 -_0807AE66: - lsls r0, 2 - ldr r1, =_0807AE78 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0807AE78: - .4byte _0807AEAC - .4byte _0807AF58 - .4byte _0807AF9C - .4byte _0807AFBC - .4byte _0807B006 - .4byte _0807B034 - .4byte _0807B058 - .4byte _0807B070 - .4byte _0807B07A - .4byte _0807B094 - .4byte _0807B0B0 - .4byte _0807B0D4 - .4byte _0807B0F0 -_0807AEAC: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0807AEC0 - ldr r1, =gLinkType - ldr r2, =0x00001144 - adds r0, r2, 0 - strh r0, [r1] - bl CloseLink -_0807AEC0: - ldr r4, =gUnknown_020322A0 - movs r5, 0x80 - lsls r5, 1 - adds r0, r5, 0 - bl AllocZeroed - str r0, [r4] - bl AllocateMonSpritesGfx - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =sub_807AC24 - bl SetVBlankCallback - bl sub_807B170 - bl sub_807AC3C - 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 r1, [r4] - adds r0, r1, 0 - adds r0, 0x8C - strh r2, [r0] - adds r0, 0x8 - strh r2, [r0] - adds r1, 0xEE - movs r0, 0x1 - strb r0, [r1] - ldr r3, [r4] - adds r0, r3, 0 - adds r0, 0xD4 - movs r1, 0x40 - strh r1, [r0] - adds r0, 0x2 - strh r1, [r0] - adds r0, 0x2 - strh r2, [r0] - adds r0, 0x2 - strh r2, [r0] - adds r1, r3, 0 - adds r1, 0xDC - movs r0, 0x78 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x50 - strh r0, [r1] - adds r0, r3, 0 - adds r0, 0xE8 - strh r5, [r0] - adds r0, 0x4 - strh r2, [r0] - b _0807B116 - .pool -_0807AF58: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r5, [r0] - cmp r5, 0 - bne _0807AF90 - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r0, 0xFA - movs r1, 0x1 - strb r1, [r0] - bl OpenLink - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r4] - str r5, [r0, 0x64] - b _0807B116 - .pool -_0807AF90: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - movs r0, 0x4 - strb r0, [r1] - b _0807B116 -_0807AF9C: - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0x3C - bhi _0807AFAC - b _0807B116 -_0807AFAC: - movs r0, 0 - str r0, [r1, 0x64] - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _0807B0E4 - .pool -_0807AFBC: - bl IsLinkMaster - lsls r0, 24 - cmp r0, 0 - bne _0807AFC8 - b _0807B0DC -_0807AFC8: - bl GetLinkPlayerCount_2 - adds r4, r0, 0 - bl sub_800AA48 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bcc _0807B000 - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0x1E - bhi _0807AFEA - b _0807B116 -_0807AFEA: - bl sub_800A620 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _0807B0E4 - .pool -_0807B000: - bl sub_807AC64 - b _0807B116 -_0807B006: - bl sub_807AC64 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0x1 - beq _0807B014 - b _0807B116 -_0807B014: - bl IsLinkPlayerDataExchangeComplete - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0807B022 - b _0807B116 -_0807B022: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _0807B0E4 - .pool -_0807B034: - ldr r2, =gUnknown_020322A0 - ldr r0, [r2] - adds r0, 0x72 - movs r1, 0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x73 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0x93 - strb r1, [r0] - movs r0, 0 - bl sub_807ACFC - b _0807B0DC - .pool -_0807B058: - movs r0, 0 - movs r1, 0x1 - bl sub_807ACFC - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _0807B0E4 - .pool -_0807B070: - movs r0, 0x1 - movs r1, 0 - bl sub_807ACFC - b _0807B0DC -_0807B07A: - movs r0, 0x1 - movs r1, 0x1 - bl sub_807ACFC - bl sub_807B154 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _0807B0E4 - .pool -_0807B094: - bl sub_807BA94 - ldr r0, =gUnknown_08338D18 - bl LoadSpriteSheet - ldr r0, =gUnknown_08338D20 - bl LoadSpritePalette - b _0807B0DC - .pool -_0807B0B0: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0 - bl ShowBg - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _0807B0E4 - .pool -_0807B0D4: - bl sub_807B140 - bl sub_807BAD8 -_0807B0DC: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_0807B0E4: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0807B116 - .pool -_0807B0F0: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0807B116 - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _0807B110 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite -_0807B110: - ldr r0, =sub_807EA2C - bl SetMainCallback2 -_0807B116: - bl RunTasks - bl RunTextPrinters - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807AE50 - - thumb_func_start sub_807B140 -sub_807B140: @ 807B140 - push {lr} - movs r0, 0x5 - bl sub_807B62C - movs r0, 0 - bl sub_807B62C - pop {r0} - bx r0 - thumb_func_end sub_807B140 - - thumb_func_start sub_807B154 -sub_807B154: @ 807B154 - push {lr} - movs r0, 0 - movs r1, 0xFF - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - pop {r0} - bx r0 - thumb_func_end sub_807B154 - - thumb_func_start sub_807B170 -sub_807B170: @ 807B170 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0x4 - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_08339014 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r5, 0x80 - lsls r5, 4 - adds r0, r5, 0 - bl Alloc - adds r1, r0, 0 - movs r0, 0 - bl SetBgTilemapBuffer - adds r0, r5, 0 - bl Alloc - adds r1, r0, 0 - movs r0, 0x1 - bl SetBgTilemapBuffer - adds r0, r5, 0 - bl Alloc - adds r1, r0, 0 - movs r0, 0x3 - bl SetBgTilemapBuffer - bl DeactivateAllTextPrinters - ldr r0, =gBattleTextboxTiles - mov r10, r0 - movs r0, 0 - mov r9, r0 - str r0, [sp] - mov r1, r10 - movs r2, 0 - movs r3, 0 - bl DecompressAndLoadBgGfxUsingHeap - ldr r0, =gBattleTextboxTilemap - mov r8, r0 - ldr r4, =gDecompressionBuffer - adds r1, r4, 0 - bl LZDecompressWram - movs r0, 0 - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - ldr r6, =gBattleTextboxPalette - adds r0, r6, 0 - movs r1, 0 - movs r2, 0x20 - bl LoadCompressedPalette - ldr r0, =gUnknown_08338FFC - bl InitWindows - mov r0, r9 - str r0, [sp] - movs r0, 0 - mov r1, r10 - movs r2, 0 - movs r3, 0 - bl DecompressAndLoadBgGfxUsingHeap - mov r0, r8 - adds r1, r4, 0 - bl LZDecompressWram - movs r0, 0 - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - adds r0, r6, 0 - movs r1, 0 - movs r2, 0x20 - bl LoadCompressedPalette - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B170 - - thumb_func_start sub_807B270 -sub_807B270: @ 807B270 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0xC - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xC - bls _0807B288 - b _0807B43E -_0807B288: - lsls r0, 2 - ldr r1, =_0807B29C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0807B29C: - .4byte _0807B2D0 - .4byte _0807B43E - .4byte _0807B43E - .4byte _0807B43E - .4byte _0807B43E - .4byte _0807B3AC - .4byte _0807B3B6 - .4byte _0807B3C0 - .4byte _0807B3D0 - .4byte _0807B3F0 - .4byte _0807B40C - .4byte _0807B414 - .4byte _0807B438 -_0807B2D0: - ldr r1, =gUnknown_02032298 - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - movs r6, 0 - strb r0, [r1] - movs r0, 0x6 - strb r0, [r1, 0x1] - ldr r4, =gLinkPlayers + 8 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r0, r4, 0 - bl StringCopy - ldr r5, =gEnemyParty - adds r0, r5, 0 - movs r1, 0x7 - mov r2, sp - bl GetMonData - adds r0, r4, 0 - adds r0, 0x1C - mov r1, sp - bl StringCopy - subs r4, 0x8 - movs r0, 0 - mov r8, r0 - movs r0, 0x2 - strh r0, [r4, 0x1A] - adds r0, r5, 0 - movs r1, 0x3 - bl GetMonData - strh r0, [r4, 0x36] - ldr r4, =gUnknown_020322A0 - movs r5, 0x80 - lsls r5, 1 - adds r0, r5, 0 - bl AllocZeroed - str r0, [r4] - bl AllocateMonSpritesGfx - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =sub_807AC24 - bl SetVBlankCallback - bl sub_807B170 - ldr r0, [r4] - adds r0, 0xEE - mov r1, r8 - strb r1, [r0] - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x8C - strh r6, [r0] - adds r0, 0x8 - strh r6, [r0] - adds r0, 0x40 - movs r1, 0x40 - strh r1, [r0] - adds r0, 0x2 - strh r1, [r0] - adds r0, 0x2 - strh r6, [r0] - adds r0, 0x2 - strh r6, [r0] - adds r1, r2, 0 - adds r1, 0xDC - movs r0, 0x78 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x50 - strh r0, [r1] - adds r0, r2, 0 - adds r0, 0xE8 - strh r5, [r0] - adds r0, 0x4 - strh r6, [r0] - str r6, [r2, 0x64] - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x5 - strb r1, [r0] - b _0807B43E - .pool -_0807B3AC: - movs r0, 0 - movs r1, 0 - bl sub_807ACFC - b _0807B424 -_0807B3B6: - movs r0, 0 - movs r1, 0x1 - bl sub_807ACFC - b _0807B424 -_0807B3C0: - movs r0, 0x1 - movs r1, 0 - bl sub_807ACFC - movs r0, 0 - bl ShowBg - b _0807B424 -_0807B3D0: - movs r0, 0x1 - movs r1, 0x1 - bl sub_807ACFC - movs r0, 0 - movs r1, 0xFF - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - b _0807B424 -_0807B3F0: - bl sub_807BA94 - ldr r0, =gUnknown_08338D18 - bl LoadSpriteSheet - ldr r0, =gUnknown_08338D20 - bl LoadSpritePalette - b _0807B424 - .pool -_0807B40C: - movs r0, 0 - bl ShowBg - b _0807B424 -_0807B414: - movs r0, 0x5 - bl sub_807B62C - movs r0, 0 - bl sub_807B62C - bl sub_807BAD8 -_0807B424: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0807B43E - .pool -_0807B438: - ldr r0, =sub_807B60C - bl SetMainCallback2 -_0807B43E: - bl RunTasks - bl RunTextPrinters - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B270 - - thumb_func_start sub_807B464 -sub_807B464: @ 807B464 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - adds r5, r1, r0 - adds r0, r5, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _0807B4B8 - adds r0, r5, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0 - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - adds r0, r4, 0 - bl SpeciesToNationalPokedexNum - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r4, 0 - movs r1, 0x2 - bl GetSetPokedexFlag - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl HandleSetPokedexFlag -_0807B4B8: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B464 - - thumb_func_start sub_807B4C4 -sub_807B4C4: @ 807B4C4 - push {lr} - bl GetMultiplayerId - pop {r0} - bx r0 - thumb_func_end sub_807B4C4 - - thumb_func_start sub_807B4D0 -sub_807B4D0: @ 807B4D0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r4, 24 - lsrs r4, 24 - movs r5, 0x64 - mov r1, r9 - muls r1, r5 - ldr r0, =gPlayerParty - adds r7, r1, r0 - adds r0, r7, 0 - movs r1, 0x40 - bl GetMonData - lsls r0, 16 - lsrs r6, r0, 16 - adds r1, r4, 0 - muls r1, r5 - ldr r0, =gEnemyParty - adds r5, r1, r0 - adds r0, r5, 0 - movs r1, 0x40 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - cmp r6, 0xFF - beq _0807B52A - ldr r0, =gSaveBlock1Ptr - lsls r1, r6, 3 - adds r1, r6 - lsls r1, 2 - ldr r2, =0x00002be0 - adds r1, r2 - ldr r0, [r0] - adds r0, r1 - bl ClearMailStruct -_0807B52A: - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r1, r7, 0 - movs r2, 0x64 - bl memcpy - adds r0, r7, 0 - adds r1, r5, 0 - movs r2, 0x64 - bl memcpy - ldr r1, [r4] - adds r0, r5, 0 - movs r2, 0x64 - bl memcpy - movs r1, 0x46 - mov r0, sp - strb r1, [r0] - adds r0, r7, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _0807B566 - adds r0, r7, 0 - movs r1, 0x20 - mov r2, sp - bl SetMonData -_0807B566: - mov r0, r8 - cmp r0, 0xFF - beq _0807B57C - lsls r1, r0, 3 - add r1, r8 - lsls r1, 2 - ldr r0, =gUnknown_020321C0 - adds r1, r0 - adds r0, r7, 0 - bl GiveMailToMon2 -_0807B57C: - mov r0, r9 - bl sub_807B464 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _0807B58E - bl sub_807B4C4 -_0807B58E: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B4D0 - - thumb_func_start sub_807B5B8 -sub_807B5B8: @ 807B5B8 - push {r4,lr} - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r0, 0x93 - ldrb r0, [r0] - cmp r0, 0x1 - beq _0807B5D0 - cmp r0, 0x2 - beq _0807B5F6 - b _0807B600 - .pool -_0807B5D0: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _0807B5F6 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - adds r1, 0x74 - movs r2, 0x14 - bl SendBlock - ldr r1, [r4] - adds r1, 0x93 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0807B5F6: - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0x93 - movs r1, 0 - strb r1, [r0] -_0807B600: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B5B8 - - thumb_func_start sub_807B60C -sub_807B60C: @ 807B60C - push {lr} - bl sub_807BBC8 - bl RunTasks - bl RunTextPrinters - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_807B60C - - thumb_func_start sub_807B62C -sub_807B62C: @ 807B62C - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x7 - bls _0807B638 - b _0807BA68 -_0807B638: - lsls r0, 2 - ldr r1, =_0807B648 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0807B648: - .4byte _0807B668 - .4byte _0807B6DC - .4byte _0807B784 - .4byte _0807B7F8 - .4byte _0807B840 - .4byte _0807B90C - .4byte _0807B924 - .4byte _0807B9FC -_0807B668: - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - adds r2, r1, 0 - adds r2, 0xE4 - movs r0, 0 - strh r0, [r2] - adds r1, 0xE6 - movs r0, 0xB4 - strh r0, [r1] - movs r1, 0xAA - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r1, =0x00005206 - movs r0, 0xC - bl SetGpuReg - ldr r0, =gTradeGba2_Pal - movs r1, 0x10 - movs r2, 0x60 - bl LoadPalette - ldr r3, =gTradeGba_Gfx - ldr r4, =0x06004000 - movs r5, 0xA1 - lsls r5, 5 - ldr r1, =0x040000d4 - ldr r6, =0x80000800 - movs r2, 0x80 - lsls r2, 5 - movs r7, 0x80 - lsls r7, 24 -_0807B6AA: - str r3, [r1] - str r4, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r2 - adds r4, r2 - subs r5, r2 - cmp r5, r2 - bhi _0807B6AA - b _0807BA4C - .pool -_0807B6DC: - ldr r4, =gUnknown_020322A0 - ldr r2, [r4] - adds r1, r2, 0 - adds r1, 0xE2 - movs r0, 0 - strh r0, [r1] - adds r2, 0xE0 - movs r1, 0xAE - lsls r1, 1 - strh r1, [r2] - movs r0, 0x16 - bl SetGpuReg - ldr r1, =0x00008502 - movs r0, 0xA - bl SetGpuReg - ldr r1, =0x00009206 - movs r0, 0xC - bl SetGpuReg - ldr r0, [r4] - adds r0, 0xFA - ldrb r0, [r0] - cmp r0, 0 - beq _0807B724 - ldr r1, =gUnknown_083369A0 - b _0807B726 - .pool -_0807B724: - ldr r1, =gUnknown_083359A0 -_0807B726: - ldr r2, =0x06002800 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000800 - str r1, [r0, 0x8] - ldr r0, [r0, 0x8] - ldr r3, =gTradeGba_Gfx - movs r4, 0xC0 - lsls r4, 19 - movs r5, 0xA1 - lsls r5, 5 - ldr r1, =0x040000d4 - ldr r6, =0x80000800 - movs r2, 0x80 - lsls r2, 5 - movs r7, 0x80 - lsls r7, 24 -_0807B74A: - str r3, [r1] - str r4, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r2 - adds r4, r2 - subs r5, r2 - cmp r5, r2 - bhi _0807B74A - str r3, [r1] - str r4, [r1, 0x4] - lsrs r0, r5, 1 - orrs r0, r7 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r1, 0x92 - lsls r1, 5 - b _0807B820 - .pool -_0807B784: - ldr r0, =gUnknown_020322A0 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0xE0 - movs r1, 0 - strh r1, [r0] - adds r0, 0x2 - strh r1, [r0] - adds r0, 0x18 - ldrb r0, [r0] - cmp r0, 0 - bne _0807B7C0 - ldr r1, =0x00001241 - movs r0, 0 - bl SetGpuReg - ldr r0, =gUnknown_083379A0 - ldr r1, =0x06002800 - bl LZ77UnCompVram - movs r0, 0x8 - b _0807B7DA - .pool -_0807B7C0: - ldr r1, =0x00001241 - movs r0, 0 - bl SetGpuReg - ldr r1, =gUnknown_0832FFC0 - ldr r2, =0x06002800 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000400 - str r1, [r0, 0x8] - ldr r0, [r0, 0x8] - movs r0, 0x1 -_0807B7DA: - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - b _0807BA68 - .pool -_0807B7F8: - ldr r0, =gUnknown_08337EA0 - movs r1, 0x30 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gUnknown_08337EC0 - ldr r1, =0x06004000 - bl LZ77UnCompVram - ldr r0, =gUnknown_08338550 - ldr r1, =0x06009000 - bl LZ77UnCompVram - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0xE4 - movs r1, 0x50 - strh r1, [r0] - movs r1, 0xB2 - lsls r1, 5 -_0807B820: - movs r0, 0 - bl SetGpuReg - b _0807BA68 - .pool -_0807B840: - ldr r1, =0x00001441 - movs r0, 0 - bl SetGpuReg - ldr r1, =0x00001287 - movs r0, 0xC - bl SetGpuReg - ldr r0, =gUnknown_020322A0 - ldr r3, [r0] - adds r1, r3, 0 - adds r1, 0xD4 - movs r2, 0 - movs r0, 0x40 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x5C - strh r0, [r1] - adds r1, 0x12 - movs r0, 0x20 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x80 - lsls r0, 3 - strh r0, [r1] - adds r0, r3, 0 - adds r0, 0xEC - strh r2, [r0] - ldr r3, =gUnknown_08332F60 - ldr r4, =0x06004000 - movs r5, 0xA1 - lsls r5, 6 - ldr r1, =0x040000d4 - ldr r6, =0x80000800 - movs r2, 0x80 - lsls r2, 5 - movs r7, 0x80 - lsls r7, 24 -_0807B88C: - str r3, [r1] - str r4, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r2 - adds r4, r2 - subs r5, r2 - cmp r5, r2 - bhi _0807B88C - str r3, [r1] - str r4, [r1, 0x4] - lsrs r0, r5, 1 - orrs r0, r7 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0xFA - ldrb r0, [r0] - cmp r0, 0 - beq _0807B8EC - ldr r1, =gUnknown_083357A0 - ldr r2, =0x06009000 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000080 - b _0807BA64 - .pool -_0807B8EC: - ldr r1, =gUnknown_083358A0 - ldr r2, =0x06009000 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000080 - b _0807BA64 - .pool -_0807B90C: - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0xE0 - movs r2, 0 - strh r2, [r1] - adds r0, 0xE2 - strh r2, [r0] - b _0807BA68 - .pool -_0807B924: - ldr r1, =0x00001441 - movs r0, 0 - bl SetGpuReg - ldr r1, =0x00001287 - movs r0, 0xC - bl SetGpuReg - ldr r0, =gUnknown_020322A0 - ldr r3, [r0] - adds r1, r3, 0 - adds r1, 0xD4 - movs r2, 0 - movs r0, 0x40 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x5C - strh r0, [r1] - adds r1, 0x12 - adds r0, 0xA4 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x80 - strh r0, [r1] - subs r1, 0xE - movs r0, 0x78 - strh r0, [r1] - adds r1, 0x2 - movs r0, 0x50 - strh r0, [r1] - adds r0, r3, 0 - adds r0, 0xEC - strh r2, [r0] - ldr r3, =gUnknown_08332F60 - ldr r4, =0x06004000 - movs r5, 0xA1 - lsls r5, 6 - ldr r1, =0x040000d4 - ldr r6, =0x80000800 - movs r2, 0x80 - lsls r2, 5 - movs r7, 0x80 - lsls r7, 24 -_0807B97A: - str r3, [r1] - str r4, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r2 - adds r4, r2 - subs r5, r2 - cmp r5, r2 - bhi _0807B97A - str r3, [r1] - str r4, [r1, 0x4] - lsrs r0, r5, 1 - orrs r0, r7 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0xFA - ldrb r0, [r0] - cmp r0, 0 - beq _0807B9DC - ldr r1, =gUnknown_083357A0 - ldr r2, =0x06009000 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000080 - b _0807BA64 - .pool -_0807B9DC: - ldr r1, =gUnknown_083358A0 - ldr r2, =0x06009000 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000080 - b _0807BA64 - .pool -_0807B9FC: - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0xE4 - movs r2, 0 - strh r2, [r1] - adds r0, 0xE6 - strh r2, [r0] - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - ldr r1, =0x00005206 - movs r0, 0xC - bl SetGpuReg - ldr r0, =gTradeGba2_Pal - movs r1, 0x10 - movs r2, 0x60 - bl LoadPalette - ldr r3, =gTradeGba_Gfx - ldr r4, =0x06004000 - movs r5, 0xA1 - lsls r5, 5 - ldr r1, =0x040000d4 - ldr r6, =0x80000800 - movs r2, 0x80 - lsls r2, 5 - movs r7, 0x80 - lsls r7, 24 -_0807BA3A: - str r3, [r1] - str r4, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r2 - adds r4, r2 - subs r5, r2 - cmp r5, r2 - bhi _0807BA3A -_0807BA4C: - str r3, [r1] - str r4, [r1, 0x4] - lsrs r0, r5, 1 - orrs r0, r7 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - ldr r1, =gUnknown_08331F60 - ldr r2, =0x06009000 - ldr r0, =0x040000d4 - str r1, [r0] - str r2, [r0, 0x4] - ldr r1, =0x80000800 -_0807BA64: - str r1, [r0, 0x8] - ldr r0, [r0, 0x8] -_0807BA68: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807B62C - thumb_func_start sub_807BA94 sub_807BA94: @ 807BA94 push {lr} diff --git a/include/trade.h b/include/trade.h index 45d8d9a0d..b7f1fc7ad 100644 --- a/include/trade.h +++ b/include/trade.h @@ -12,7 +12,7 @@ s32 sub_807A728(void); void sub_80773AC(void); void sub_807AE50(void); -int sub_807A8D0(u32 /* probably wrong */, u16, u16, u8); +int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16, u16, u8); int sub_807A7E0(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6); int sub_807A918(struct Pokemon*, u16); diff --git a/include/util.h b/include/util.h index 997c8f713..9d13453c2 100644 --- a/include/util.h +++ b/include/util.h @@ -14,5 +14,6 @@ u16 CalcCRC16(u8 *data, s32 length); u16 CalcCRC16WithTable(u8 *data, u32 length); u32 CalcByteArraySum(const u8* data, u32 length); void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor); +void DoBgAffineSet(struct BgAffineDstData *dest, u32 texX, u32 texY, s16 scrX, s16 scrY, s16 sx, s16 sy, u16 alpha); #endif // GUARD_UTIL_H diff --git a/src/party_menu.c b/src/party_menu.c index f8e312217..34c67c474 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4579,7 +4579,7 @@ static void CursorCb_Register(u8 taskId) u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_OBEDIENCE); - switch (sub_807A8D0(*(u32 *)sub_800F7DC() /* dirty cast, probably needs to be changed */, species2, species, obedience)) + switch (sub_807A8D0(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), species2, species, obedience)) { case 1: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); diff --git a/src/trade.c b/src/trade.c index 8eb0419b9..4d5edffd7 100644 --- a/src/trade.c +++ b/src/trade.c @@ -6,6 +6,7 @@ #include "cable_club.h" #include "data2.h" #include "daycare.h" +#include "decompress.h" #include "event_data.h" #include "gpu_regs.h" #include "graphics.h" @@ -13,10 +14,12 @@ #include "librfu.h" #include "link.h" #include "link_rfu.h" +#include "mail.h" #include "main.h" #include "overworld.h" #include "palette.h" #include "party_menu.h" +#include "pokedex.h" #include "pokemon_icon.h" #include "pokemon_summary_screen.h" #include "sound.h" @@ -26,6 +29,7 @@ #include "text_window.h" #include "trainer_card.h" #include "trade.h" +#include "util.h" #include "window.h" #include "constants/moves.h" #include "constants/species.h" @@ -77,6 +81,43 @@ extern struct { extern u8 *gUnknown_02032184; extern u8 *gUnknown_02032188[14]; extern u8 gUnknown_02032298[2]; +extern struct { + struct Pokemon mon; + u32 unk_64; + u32 unk_68[2]; + u8 filler_70[2]; + u8 unk_72; + u8 unk_73; + u8 unk_74[20]; + u8 unk_88; + u8 unk_89; + u16 unk_8A; + u16 unk_8C; + u8 unk_8E[2]; + u8 filler_90[3]; + u8 unk_93; + u16 unk_94; + u8 filler_96[0xD4 - 0x96]; + u16 unk_D4; + u16 unk_D6; + u16 unk_D8; + u16 unk_DA; + s16 unk_DC; + s16 unk_DE; + u16 unk_E0; + u16 unk_E2; + u16 unk_E4; + u16 unk_E6; + s16 unk_E8; + u16 unk_EA; + u16 unk_EC; + u8 unk_EE; + u8 filler_EF; + u16 unk_F0[2]; + u8 filler_F4[0xFA - 0xF4]; + u8 unk_FA; + u8 filler_FB[0x100 - 0xFB]; +} *gUnknown_020322A0; extern u8 gUnknown_0203CF20; @@ -105,6 +146,24 @@ extern const u8 *gUnknown_0832DEBC[]; extern const struct SpritePalette gSpritePalette_TradeScreenText; extern const struct SpritePalette gUnknown_0832DC44; extern const struct SpriteSheet gUnknown_0832DC3C; +extern const u16 gUnknown_08338EA4[]; +extern const struct SpriteSheet gUnknown_08338D18; +extern const struct SpritePalette gUnknown_08338D20; +extern const struct BgTemplate gUnknown_08339014[4]; +extern const struct WindowTemplate gUnknown_08338FFC[]; +extern const u16 gUnknown_08331F60[]; +extern const u16 gUnknown_083359A0[]; +extern const u16 gUnknown_083369A0[]; +extern const u32 gUnknown_083379A0[]; +extern const u16 gUnknown_0832FFC0[]; +extern const u16 gUnknown_08337EA0[]; +extern const u32 gUnknown_08337EC0[]; +extern const u32 gUnknown_08338550[]; +extern const u8 gUnknown_08332F60[]; +extern const u8 gUnknown_083357A0[]; +extern const u8 gUnknown_083358A0[]; + +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; bool32 sub_8077260(void); void sub_80773D0(void); @@ -135,6 +194,15 @@ u32 sub_807A09C(void); u8 sub_8079A3C(u8 *, bool8, u8); void sub_8079AA4(u8 *, u8, u8); void sub_8079C4C(u8, u8, u8, u8, u8, u8); +void sub_807B170(void); +void sub_807B154(void); +void sub_807BA94(void); +void sub_807B140(void); +void sub_807BAD8(void); +void sub_807EA2C(void); +void sub_807B62C(u8); +void sub_807B60C(void); +void sub_807BBC8(void); bool8 sub_8077170(const void *a0, u32 a1) { @@ -2556,3 +2624,946 @@ int sub_807A7E0(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuS return 0; } + +int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 a1, u16 a2, u8 a3) +{ + u8 unk = a0.unk_01_0; + + if (sub_807A7BC(a2, a3)) + { + return 1; + } + + if (unk) + { + return 0; + } + + if (a1 == SPECIES_EGG) + { + return 2; + } + + if (IsSpeciesInHoennDex(a1)) + { + return 0; + } + + return 1; +} + +// r6/r7 flip. Ugh. +#ifdef NONMATCHING +int sub_807A918(struct Pokemon *a0, u16 a1) +{ + int i, version, versions, unk, unk2; + int arr[PARTY_SIZE]; + + for (i = 0; i < gPlayerPartyCount; i++) + { + arr[i] = GetMonData(&a0[i], MON_DATA_SPECIES2); + if (arr[i] == SPECIES_EGG) + { + arr[i] = 0; + } + } + + versions = 0; + unk = 1; + for (i = 0; i < GetLinkPlayerCount(); i++) + { + version = gLinkPlayers[i].version & 0xFF; + if (version == VERSION_FIRE_RED || + version == VERSION_LEAF_GREEN) + { + versions = 0; + } + else + { + versions |= 1; + } + } + + for (i = 0; i < GetLinkPlayerCount(); i++) + { + struct LinkPlayer *player = &gLinkPlayers[i]; + if ((player->name[8] & 0xF) == 0) + { + unk = 0; + } + + if (versions && (player->name[8] / 16)) + { + unk = 0; + } + } + + if (unk == 0) + { + if (!IsSpeciesInHoennDex(arr[a1])) + { + return 2; + } + + if (arr[a1] == SPECIES_NONE) + { + return 3; + } + } + + unk2 = 0; + for (i = 0; i < gPlayerPartyCount; i++) + { + if (a1 != i) + { + unk2 += arr[i]; + } + } + + if (!unk2) + { + return 1; + } + else + { + return 0; + } +} +#else +NAKED +int sub_807A918(struct Pokemon *a0, u16 a1) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x18\n\ + adds r6, r0, 0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + mov r8, r1\n\ + movs r5, 0\n\ + ldr r0, =gPlayerPartyCount\n\ + ldrb r0, [r0]\n\ + cmp r5, r0\n\ + bge _0807A95A\n\ + mov r4, sp\n\ +_0807A934:\n\ + movs r0, 0x64\n\ + muls r0, r5\n\ + adds r0, r6, r0\n\ + movs r1, 0x41\n\ + bl GetMonData\n\ + str r0, [r4]\n\ + movs r1, 0xCE\n\ + lsls r1, 1\n\ + cmp r0, r1\n\ + bne _0807A94E\n\ + movs r0, 0\n\ + str r0, [r4]\n\ +_0807A94E:\n\ + adds r4, 0x4\n\ + adds r5, 0x1\n\ + ldr r0, =gPlayerPartyCount\n\ + ldrb r0, [r0]\n\ + cmp r5, r0\n\ + blt _0807A934\n\ +_0807A95A:\n\ + movs r7, 0\n\ + movs r6, 0x1\n\ + movs r5, 0\n\ + ldr r4, =gLinkPlayers\n\ + b _0807A980\n\ + .pool\n\ +_0807A96C:\n\ + ldrb r0, [r4]\n\ + subs r0, 0x4\n\ + cmp r0, 0x1\n\ + bhi _0807A978\n\ + movs r7, 0\n\ + b _0807A97C\n\ +_0807A978:\n\ + movs r0, 0x1\n\ + orrs r7, r0\n\ +_0807A97C:\n\ + adds r4, 0x1C\n\ + adds r5, 0x1\n\ +_0807A980:\n\ + bl GetLinkPlayerCount\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r5, r0\n\ + blt _0807A96C\n\ + movs r5, 0\n\ + movs r4, 0\n\ + b _0807A9B4\n\ +_0807A992:\n\ + ldr r0, =gLinkPlayers\n\ + adds r2, r4, r0\n\ + ldrb r1, [r2, 0x10]\n\ + movs r0, 0xF\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0807A9A2\n\ + movs r6, 0\n\ +_0807A9A2:\n\ + cmp r7, 0\n\ + beq _0807A9B0\n\ + ldrb r0, [r2, 0x10]\n\ + lsrs r0, 4\n\ + cmp r0, 0\n\ + beq _0807A9B0\n\ + movs r6, 0\n\ +_0807A9B0:\n\ + adds r4, 0x1C\n\ + adds r5, 0x1\n\ +_0807A9B4:\n\ + bl GetLinkPlayerCount\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r5, r0\n\ + blt _0807A992\n\ + cmp r6, 0\n\ + bne _0807A9EA\n\ + mov r1, r8\n\ + lsls r0, r1, 2\n\ + mov r1, sp\n\ + adds r4, r1, r0\n\ + ldrh r0, [r4]\n\ + bl IsSpeciesInHoennDex\n\ + cmp r0, 0\n\ + bne _0807A9E0\n\ + movs r0, 0x2\n\ + b _0807AA1A\n\ + .pool\n\ +_0807A9E0:\n\ + ldr r0, [r4]\n\ + cmp r0, 0\n\ + bne _0807A9EA\n\ + movs r0, 0x3\n\ + b _0807AA1A\n\ +_0807A9EA:\n\ + movs r2, 0\n\ + movs r5, 0\n\ + ldr r0, =gPlayerPartyCount\n\ + ldrb r0, [r0]\n\ + cmp r2, r0\n\ + bge _0807AA0A\n\ + adds r3, r0, 0\n\ + mov r1, sp\n\ +_0807A9FA:\n\ + cmp r8, r5\n\ + beq _0807AA02\n\ + ldr r0, [r1]\n\ + adds r2, r0\n\ +_0807AA02:\n\ + adds r1, 0x4\n\ + adds r5, 0x1\n\ + cmp r5, r3\n\ + blt _0807A9FA\n\ +_0807AA0A:\n\ + cmp r2, 0\n\ + beq _0807AA18\n\ + movs r0, 0\n\ + b _0807AA1A\n\ + .pool\n\ +_0807AA18:\n\ + movs r0, 0x1\n\ +_0807AA1A:\n\ + add sp, 0x18\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1"); +} +#endif // NONMATCHING + +void sub_807AA28(struct Sprite *sprite) +{ + if (++sprite->data[0] == 10) + { + PlaySE(SE_BOWA); + sprite->data[0] = 0; + } +} + +void sub_807AA4C(struct Sprite *sprite) +{ + if (!sprite->invisible && ++sprite->data[0] == 10) + { + PlaySE(SE_W207B); + sprite->data[0] = 0; + } +} + +void sub_807AA7C(struct Sprite *sprite) +{ + if (!sprite->data[1]) + { + if (++sprite->data[0] == 12) + { + sprite->data[0] = 0; + } + + LoadPalette(&gUnknown_08338EA4[sprite->data[0]], (sprite->oam.paletteNum + 16) * 16 + 4, 2); + } +} + +void sub_807AABC(struct Sprite *sprite) +{ + sprite->data[0]++; + sprite->pos2.y++; + + if (sprite->data[0] == 10) + { + DestroySprite(sprite); + } +} + +void sub_807AAE0(struct Sprite *sprite) +{ + sprite->data[0]++; + sprite->pos2.y--; + + if (sprite->data[0] == 10) + { + DestroySprite(sprite); + } +} + +void sub_807AB04(struct Sprite *sprite) +{ + if (++sprite->data[0] == 15) + { + PlaySE(SE_W107); + sprite->data[0] = 0; + } +} + +void sub_807AB28(void) +{ + struct BgAffineDstData affine; + + DoBgAffineSet(&affine, gUnknown_020322A0->unk_D4 * 0x100, gUnknown_020322A0->unk_D6 * 0x100, gUnknown_020322A0->unk_DC, gUnknown_020322A0->unk_DE, gUnknown_020322A0->unk_E8, gUnknown_020322A0->unk_E8, gUnknown_020322A0->unk_EC); + SetGpuReg(REG_OFFSET_BG2PA, affine.pa); + SetGpuReg(REG_OFFSET_BG2PB, affine.pb); + SetGpuReg(REG_OFFSET_BG2PC, affine.pc); + SetGpuReg(REG_OFFSET_BG2PD, affine.pd); + SetGpuReg(REG_OFFSET_BG2X_L, affine.dx); + SetGpuReg(REG_OFFSET_BG2X_H, affine.dx >> 16); + SetGpuReg(REG_OFFSET_BG2Y_L, affine.dy); + SetGpuReg(REG_OFFSET_BG2Y_H, affine.dy >> 16); +} + +void sub_807ABCC(void) +{ + u16 dispcnt; + + SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_020322A0->unk_E0); + SetGpuReg(REG_OFFSET_BG1HOFS, gUnknown_020322A0->unk_E2); + + dispcnt = GetGpuReg(REG_OFFSET_DISPCNT); + if (!(dispcnt & (DISPCNT_MODE_1 | DISPCNT_MODE_2 | DISPCNT_MODE_3 | DISPCNT_MODE_4 | DISPCNT_MODE_5))) + { + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_020322A0->unk_E4); + SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_020322A0->unk_E6); + } + else + { + sub_807AB28(); + } +} + +void sub_807AC24(void) +{ + sub_807ABCC(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void sub_807AC3C(void) +{ + gUnknown_020322A0->unk_8A = 0; + gUnknown_020322A0->unk_88 = 0; + gUnknown_020322A0->unk_89 = 0; +} + +void sub_807AC64(void) +{ + if (gUnknown_020322A0->unk_88 == gUnknown_020322A0->unk_89) + { + gUnknown_020322A0->unk_8A++; + } + else + { + gUnknown_020322A0->unk_8A = 0; + } + + if (gUnknown_020322A0->unk_8A > 300) + { + CloseLink(); + SetMainCallback2(CB2_LinkError); + gUnknown_020322A0->unk_8A = 0; + gUnknown_020322A0->unk_89 = 0; + gUnknown_020322A0->unk_88 = 0; + } + + gUnknown_020322A0->unk_89 = gUnknown_020322A0->unk_88; +} + +u32 sub_807ACDC(void) +{ + if (gReceivedRemoteLinkPlayers != 0) + { + return GetMultiplayerId(); + } + + return 0; +} + +void sub_807ACFC(u8 a0, u8 a1) +{ + int unk = 0; + struct Pokemon *mon = NULL; + u16 species; + u32 personality; + + if (a0 == 0) + { + mon = &gPlayerParty[gUnknown_02032298[0]]; + unk = 1; + } + + if (a0 == 1) + { + mon = &gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE]; + unk = 3; + } + + switch (a1) + { + case 0: + species = GetMonData(mon, MON_DATA_SPECIES2); + personality = GetMonData(mon, MON_DATA_PERSONALITY); + + if (a0 == 0) + { + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); + } + else + { + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[a0 * 2 + 1], species, personality); + } + LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); + gUnknown_020322A0->unk_F0[a0] = species; + gUnknown_020322A0->unk_68[a0] = personality; + break; + case 1: + SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, unk); + gUnknown_020322A0->unk_8E[a0] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[gUnknown_020322A0->unk_8E[a0]].invisible = TRUE; + gSprites[gUnknown_020322A0->unk_8E[a0]].callback = SpriteCallbackDummy; + break; + } +} + +void sub_807AE50(void) +{ + switch (gMain.state) + { + case 0: + if (gReceivedRemoteLinkPlayers == 0) + { + gLinkType = 0x1144; + CloseLink(); + } + gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); + AllocateMonSpritesGfx(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + SetVBlankCallback(sub_807AC24); + sub_807B170(); + sub_807AC3C(); + gMain.state++; + gUnknown_020322A0->unk_8C = 0; + gUnknown_020322A0->unk_94 = 0; + gUnknown_020322A0->unk_EE = 1; + gUnknown_020322A0->unk_D4 = 64; + gUnknown_020322A0->unk_D6 = 64; + gUnknown_020322A0->unk_D8 = 0; + gUnknown_020322A0->unk_DA = 0; + gUnknown_020322A0->unk_DC = 120; + gUnknown_020322A0->unk_DE = 80; + gUnknown_020322A0->unk_E8 = 256; + gUnknown_020322A0->unk_EC = 0; + break; + case 1: + if (gReceivedRemoteLinkPlayers == 0) + { + gUnknown_020322A0->unk_FA = 1; + OpenLink(); + gMain.state++; + gUnknown_020322A0->unk_64 = 0; + } + else + { + gMain.state = 4; + } + break; + case 2: + if (++gUnknown_020322A0->unk_64 > 60) + { + gUnknown_020322A0->unk_64 = 0; + gMain.state++; + } + break; + case 3: + if (IsLinkMaster()) + { + if (GetLinkPlayerCount_2() >= sub_800AA48()) + { + if (++gUnknown_020322A0->unk_64 > 30) + { + sub_800A620(); + gMain.state++; + } + } + else + { + sub_807AC64(); + } + } + else + { + gMain.state++; + } + break; + case 4: + sub_807AC64(); + if (gReceivedRemoteLinkPlayers == 1 && IsLinkPlayerDataExchangeComplete() == TRUE) + { + gMain.state++; + } + break; + case 5: + gUnknown_020322A0->unk_72 = 0; + gUnknown_020322A0->unk_73 = 0; + gUnknown_020322A0->unk_93 = 0; + sub_807ACFC(0, 0); + gMain.state++; + break; + case 6: + sub_807ACFC(0, 1); + gMain.state++; + break; + case 7: + sub_807ACFC(1, 0); + gMain.state++; + break; + case 8: + sub_807ACFC(1, 1); + sub_807B154(); + gMain.state++; + break; + case 9: + sub_807BA94(); + LoadSpriteSheet(&gUnknown_08338D18); + LoadSpritePalette(&gUnknown_08338D20); + gMain.state++; + break; + case 10: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + ShowBg(0); + gMain.state++; + break; + case 11: + sub_807B140(); + sub_807BAD8(); + gMain.state++; + break; + case 12: + if (!gPaletteFade.active) + { + if (gWirelessCommType) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + SetMainCallback2(sub_807EA2C); + } + break; + } + RunTasks(); + RunTextPrinters(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_807B140(void) +{ + sub_807B62C(5); + sub_807B62C(0); +} + +void sub_807B154(void) +{ + FillWindowPixelBuffer(0, 0xFF); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); +} + +void sub_807B170(void) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_08339014, ARRAY_COUNT(gUnknown_08339014)); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + SetBgTilemapBuffer(0, Alloc(0x800)); + SetBgTilemapBuffer(1, Alloc(0x800)); + SetBgTilemapBuffer(3, Alloc(0x800)); + DeactivateAllTextPrinters(); + DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0); + LZDecompressWram(gBattleTextboxTilemap, gDecompressionBuffer); + CopyToBgTilemapBuffer(0, gDecompressionBuffer, 0x800, 0); + LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); + InitWindows(gUnknown_08338FFC); + DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0); + LZDecompressWram(gBattleTextboxTilemap, gDecompressionBuffer); + CopyToBgTilemapBuffer(0, gDecompressionBuffer, 0x800, 0); + LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); +} + +void sub_807B270(void) +{ + u8 name[12]; + + switch (gMain.state) + { + case 0: + gUnknown_02032298[0] = gSpecialVar_0x8005; + gUnknown_02032298[1] = 6; + StringCopy(gLinkPlayers[0].name, gSaveBlock2Ptr->playerName); + GetMonData(&gEnemyParty[0], MON_DATA_OT_NAME, name); + StringCopy(gLinkPlayers[1].name, name); + gLinkPlayers[0].language = LANGUAGE_ENGLISH; + gLinkPlayers[1].language = GetMonData(&gEnemyParty[0], MON_DATA_LANGUAGE); + gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); + AllocateMonSpritesGfx(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + SetVBlankCallback(sub_807AC24); + sub_807B170(); + gUnknown_020322A0->unk_EE = 0; + gUnknown_020322A0->unk_8C = 0; + gUnknown_020322A0->unk_94 = 0; + gUnknown_020322A0->unk_D4 = 64; + gUnknown_020322A0->unk_D6 = 64; + gUnknown_020322A0->unk_D8 = 0; + gUnknown_020322A0->unk_DA = 0; + gUnknown_020322A0->unk_DC = 120; + gUnknown_020322A0->unk_DE = 80; + gUnknown_020322A0->unk_E8 = 256; + gUnknown_020322A0->unk_EC = 0; + gUnknown_020322A0->unk_64 = 0; + gMain.state = 5; + break; + case 5: + sub_807ACFC(0, 0); + gMain.state++; + break; + case 6: + sub_807ACFC(0, 1); + gMain.state++; + break; + case 7: + sub_807ACFC(1, 0); + ShowBg(0); + gMain.state++; + break; + case 8: + sub_807ACFC(1, 1); + FillWindowPixelBuffer(0, 0xFF); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); + gMain.state++; + break; + case 9: + sub_807BA94(); + LoadSpriteSheet(&gUnknown_08338D18); + LoadSpritePalette(&gUnknown_08338D20); + gMain.state++; + break; + case 10: + ShowBg(0); + gMain.state++; + break; + case 11: + sub_807B62C(5); + sub_807B62C(0); + sub_807BAD8(); + gMain.state++; + break; + case 12: + SetMainCallback2(sub_807B60C); + break; + } + + RunTasks(); + RunTextPrinters(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_807B464(u8 a0) +{ + u16 species; + u32 personality; + struct Pokemon *mon = &gPlayerParty[a0]; + + if (!GetMonData(mon, MON_DATA_IS_EGG)) + { + species = GetMonData(mon, MON_DATA_SPECIES, NULL); + personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); + species = SpeciesToNationalPokedexNum(species); + GetSetPokedexFlag(species, FLAG_SET_SEEN); + HandleSetPokedexFlag(species, FLAG_SET_CAUGHT, personality); + } +} + +void sub_807B4C4(void) +{ + GetMultiplayerId(); +} + +void sub_807B4D0(u8 a0, u8 a1) +{ + u8 friendship; + u16 mailId1; + u16 mailId2; + struct Pokemon *mon1 = &gPlayerParty[a0]; + struct Pokemon *mon2; + + mailId1 = GetMonData(mon1, MON_DATA_MAIL); + mon2 = &gEnemyParty[a1]; + mailId2 = GetMonData(mon2, MON_DATA_MAIL); + + if (mailId1 != 0xFF) + { + ClearMailStruct(&gSaveBlock1Ptr->mail[mailId1]); + } + + memcpy(&gUnknown_020322A0->mon, mon1, sizeof(struct Pokemon)); + memcpy(mon1, mon2, sizeof(struct Pokemon)); + memcpy(mon2, &gUnknown_020322A0->mon, sizeof(struct Pokemon)); + + friendship = 70; + if (!GetMonData(mon1, MON_DATA_IS_EGG)) + { + SetMonData(mon1, MON_DATA_FRIENDSHIP, &friendship); + } + + if (mailId2 != 0xFF) + { + GiveMailToMon2(mon1, &gUnknown_020321C0[mailId2]); + } + + sub_807B464(a0); + + if (gReceivedRemoteLinkPlayers != 0) + { + sub_807B4C4(); + } +} + +void sub_807B5B8(void) +{ + switch (gUnknown_020322A0->unk_93) + { + case 1: + if (sub_800A520()) + { + SendBlock(bitmask_all_link_players_but_self(), gUnknown_020322A0->unk_74, sizeof(gUnknown_020322A0->unk_74)); + gUnknown_020322A0->unk_93++; + } + case 2: + gUnknown_020322A0->unk_93 = 0; + break; + } +} + +void sub_807B60C(void) +{ + sub_807BBC8(); + RunTasks(); + RunTextPrinters(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +// DmaCopy16Defvars in cases 4 and 6 tail merge, when they shouldn't +void sub_807B62C(u8 a0) +{ + switch (a0) + { + case 0: + gUnknown_020322A0->unk_E4 = 0; + gUnknown_020322A0->unk_E6 = 180; + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG0_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT512x256); + LoadPalette(gTradeGba2_Pal, 16, 0x60); + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); + DmaCopy16(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); + break; + case 1: + gUnknown_020322A0->unk_E2 = 0; + gUnknown_020322A0->unk_E0 = 348; + SetGpuReg(REG_OFFSET_BG1VOFS, 348); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(0) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(5) | + BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT256x512); + + if (gUnknown_020322A0->unk_FA) + { + DmaCopy16Defvars(3, gUnknown_083369A0, (void *) BG_SCREEN_ADDR(5), 0x1000); + } + else + { + DmaCopy16Defvars(3, gUnknown_083359A0, (void *) BG_SCREEN_ADDR(5), 0x1000); + } + + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(0), 0x1420, 0x1000); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + break; + case 2: + gUnknown_020322A0->unk_E0 = 0; + gUnknown_020322A0->unk_E2 = 0; + if (!gUnknown_020322A0->unk_FA) + { + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + LZ77UnCompVram(gUnknown_083379A0, (void *) BG_SCREEN_ADDR(5)); + BlendPalettes(0x8, 16, RGB_BLACK); + } + else + { + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + DmaCopy16Defvars(3, gUnknown_0832FFC0, (void *) BG_SCREEN_ADDR(5), 0x800); + BlendPalettes(0x1, 16, RGB_BLACK); + } + break; + case 3: + LoadPalette(gUnknown_08337EA0, 48, 0x20); + LZ77UnCompVram(gUnknown_08337EC0, (void *) BG_CHAR_ADDR(1)); + LZ77UnCompVram(gUnknown_08338550, (void *) BG_SCREEN_ADDR(18)); + gUnknown_020322A0->unk_E4 = 80; + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + break; + case 4: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | + BGCNT_CHARBASE(1) | + BGCNT_256COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_AFF128x128); + gUnknown_020322A0->unk_D4 = 64; + gUnknown_020322A0->unk_D6 = 92; + gUnknown_020322A0->unk_E8 = 32; + gUnknown_020322A0->unk_EA = 1024; + gUnknown_020322A0->unk_EC = 0; + + DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + + if (gUnknown_020322A0->unk_FA) + { + DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); + } + else + { + DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); + } + break; + case 5: + gUnknown_020322A0->unk_E0 = 0; + gUnknown_020322A0->unk_E2 = 0; + break; + case 6: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | + BGCNT_CHARBASE(1) | + BGCNT_256COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_AFF128x128); + gUnknown_020322A0->unk_D4 = 64; + gUnknown_020322A0->unk_D6 = 92; + gUnknown_020322A0->unk_E8 = 256; + gUnknown_020322A0->unk_EA = 128; + gUnknown_020322A0->unk_DC = 120; + gUnknown_020322A0->unk_DE = 80; + gUnknown_020322A0->unk_EC = 0; + + DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + + if (gUnknown_020322A0->unk_FA) + { + DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); + } + else + { + DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); + } + break; + case 7: + gUnknown_020322A0->unk_E4 = 0; + gUnknown_020322A0->unk_E6 = 0; + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT512x256); + LoadPalette(gTradeGba2_Pal, 16, 0x60); + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); + DmaCopy16(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); + break; + } +}