diff --git a/asm/trade.s b/asm/trade.s index 2fad5efed..7c37a9310 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -6,2196 +6,6 @@ .text - thumb_func_start sub_807BA94 -sub_807BA94: @ 807BA94 - push {lr} - ldr r0, =gUnknown_08338D70 - bl LoadSpriteSheet - ldr r0, =gUnknown_08338DC0 - bl LoadSpriteSheet - ldr r0, =gUnknown_08338DF4 - bl LoadSpriteSheet - ldr r0, =gUnknown_08338E6C - bl LoadSpriteSheet - ldr r0, =gUnknown_08338D78 - bl LoadSpritePalette - ldr r0, =gUnknown_08338D80 - bl LoadSpritePalette - pop {r0} - bx r0 - .pool - thumb_func_end sub_807BA94 - - thumb_func_start sub_807BAD8 -sub_807BAD8: @ 807BAD8 - push {r4,r5,lr} - sub sp, 0x14 - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0xEE - ldrb r0, [r0] - cmp r0, 0 - beq _0807BB68 - bl GetMultiplayerId - lsls r0, 24 - ldr r3, =gStringVar1 - movs r2, 0x80 - lsls r2, 17 - eors r2, r0 - lsrs r2, 24 - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - ldr r0, =gLinkPlayers + 8 - adds r1, r0 - adds r0, r3, 0 - bl StringCopy - ldr r5, =gUnknown_02032298 - ldrb r0, [r5, 0x1] - movs r1, 0x6 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - movs r4, 0x64 - muls r0, r4 - ldr r1, =gEnemyParty - adds r0, r1 - movs r1, 0x2 - mov r2, sp - bl GetMonData - ldr r0, =gStringVar3 - mov r1, sp - bl StringCopy10 - ldrb r0, [r5] - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2 - mov r2, sp - bl GetMonData - ldr r0, =gStringVar2 - mov r1, sp - bl StringCopy10 - b _0807BBA4 - .pool -_0807BB68: - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - lsls r4, r0, 4 - subs r4, r0 - lsls r4, 2 - ldr r0, =gIngameTrades - adds r4, r0 - ldr r0, =gStringVar1 - adds r1, r4, 0 - adds r1, 0x2B - bl StringCopy - ldr r0, =gStringVar3 - adds r1, r4, 0 - bl StringCopy10 - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x2 - mov r2, sp - bl GetMonData - ldr r0, =gStringVar2 - mov r1, sp - bl StringCopy10 -_0807BBA4: - add sp, 0x14 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_807BAD8 - - thumb_func_start sub_807BBC8 -sub_807BBC8: @ 807BBC8 - push {lr} - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0xFA - ldrb r0, [r0] - cmp r0, 0 - bne _0807BBE0 - bl sub_807CFC8 - b _0807BBE4 - .pool -_0807BBE0: - bl sub_807BBEC -_0807BBE4: - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_807BBC8 - - thumb_func_start sub_807BBEC -sub_807BBEC: @ 807BBEC - push {r4-r7,lr} - sub sp, 0x14 - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - adds r1, 0x94 - ldrh r5, [r1] - ldr r1, =0x0000010b - adds r7, r0, 0 - cmp r5, r1 - bls _0807BC04 - bl _0807CFB4 -_0807BC04: - lsls r0, r5, 2 - ldr r1, =_0807BC1C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0807BC1C: - .4byte _0807C04C - .4byte _0807C0C4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807C120 - .4byte _0807C168 - .4byte _0807C1DC - .4byte _0807CFB4 - .4byte _0807C248 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807C26C - .4byte _0807C29C - .4byte _0807C2AE - .4byte _0807C2D0 - .4byte _0807C318 - .4byte _0807C348 - .4byte _0807C390 - .4byte _0807C3E0 - .4byte _0807C434 - .4byte _0807C4B8 - .4byte _0807C4DC - .4byte _0807C528 - .4byte _0807C574 - .4byte _0807C5D0 - .4byte _0807C630 - .4byte _0807C644 - .4byte _0807C658 - .4byte _0807C66C - .4byte _0807C794 - .4byte _0807C864 - .4byte _0807C8EC - .4byte _0807C964 - .4byte _0807C974 - .4byte _0807C994 - .4byte _0807C9E4 - .4byte _0807CA02 - .4byte _0807CA40 - .4byte _0807CA50 - .4byte _0807CAC8 - .4byte _0807CFB4 - .4byte _0807CAF0 - .4byte _0807CB30 - .4byte _0807CB70 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CB90 - .4byte _0807CBB8 - .4byte _0807CBD4 - .4byte _0807CBF4 - .4byte _0807CC9C - .4byte _0807CCD0 - .4byte _0807CD1C - .4byte _0807CDDC - .4byte _0807CE54 - .4byte _0807CEA0 - .4byte _0807CEB0 - .4byte _0807CEB6 - .4byte _0807CEDC - .4byte _0807CF38 - .4byte _0807CF5C - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CE18 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807C460 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CFB4 - .4byte _0807CE38 -_0807C04C: - ldr r3, =gSprites - ldr r0, [r7] - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - ldr r4, [r7] - adds r2, r4, 0 - adds r2, 0x8E - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldr r1, =0x0000ff4c - strh r1, [r0, 0x24] - ldrb r0, [r2] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - ldr r2, =gMonFrontPicCoords - adds r0, r4, 0 - adds r0, 0xF0 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - strh r0, [r1, 0x26] - adds r1, r4, 0 - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - bl GetCurrentMapMusic - ldr r1, [r7] - adds r1, 0xF4 - strh r0, [r1] - ldr r0, =0x00000179 - bl PlayNewMapMusic - bl _0807CFB4 - .pool -_0807C0C4: - ldr r5, [r7] - adds r6, r5, 0 - adds r6, 0xE6 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - ble _0807C0F8 - ldr r2, =gSprites - adds r0, r5, 0 - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x24] - adds r1, 0x3 - strh r1, [r0, 0x24] - ldrh r0, [r6] - subs r0, 0x3 - strh r0, [r6] - bl _0807CFB4 - .pool -_0807C0F8: - ldr r2, =gSprites - adds r0, r5, 0 - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strh r1, [r0, 0x24] - strh r1, [r6] - adds r1, r5, 0 - adds r1, 0x94 - movs r0, 0xA - strh r0, [r1] - bl _0807CFB4 - .pool -_0807C120: - ldr r4, =gStringVar4 - ldr r1, =gText_XWillBeSentToY - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_807F1A8 - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r2, r0, 0 - adds r2, 0xF0 - ldrh r1, [r2] - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - beq _0807C14E - adds r0, r1, 0 - movs r1, 0 - bl PlayCry1 -_0807C14E: - ldr r3, [r4] - adds r1, r3, 0 - adds r1, 0x94 - movs r2, 0 - movs r0, 0xB - bl _0807CE06 - .pool -_0807C168: - ldr r1, [r7] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0x50 - beq _0807C178 - bl _0807CFB4 -_0807C178: - adds r0, r1, 0 - adds r0, 0x8E - ldrb r0, [r0] - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r1, [r1, 0x5] - lsrs r1, 4 - movs r2, 0x2 - str r2, [sp] - movs r2, 0x1 - str r2, [sp, 0x4] - movs r2, 0x14 - str r2, [sp, 0x8] - ldr r2, =0x000fffff - str r2, [sp, 0xC] - movs r2, 0x78 - movs r3, 0x20 - bl sub_807671C - ldr r1, [r7] - adds r1, 0xD2 - strb r0, [r1] - ldr r1, [r7] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - ldr r4, =gStringVar4 - ldr r1, =gText_ByeByeVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_807F1A8 - bl _0807CFB4 - .pool -_0807C1DC: - ldr r5, =gSprites - ldr r0, [r7] - adds r0, 0xD2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, r5, 0 - adds r4, 0x1C - adds r0, r4 - ldr r1, [r0] - ldr r0, =SpriteCallbackDummy - cmp r1, r0 - beq _0807C1FC - bl _0807CFB4 -_0807C1FC: - ldr r0, =gSpriteTemplate_8338D28 - movs r1, 0x78 - movs r2, 0x20 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - adds r1, 0xD3 - strb r0, [r1] - ldr r2, [r7] - adds r0, r2, 0 - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldr r1, =sub_807E5D8 - str r1, [r0] - adds r2, 0xD2 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - bl DestroySprite - ldr r1, [r7] - bl _0807CF4C - .pool -_0807C248: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0x94 - movs r1, 0x14 - strh r1, [r0] - bl _0807CFB4 - .pool -_0807C26C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807C27C - bl _0807CFB4 -_0807C27C: - movs r0, 0x4 - bl sub_807B62C - movs r0, 0 - movs r1, 0xFF - bl FillWindowPixelBuffer - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - bl _0807CF48 - .pool -_0807C29C: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0x10 - movs r3, 0 - bl _0807CF44 -_0807C2AE: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807C2BE - bl _0807CFB4 -_0807C2BE: - ldr r0, [r7] - adds r0, 0x94 - movs r1, 0x17 - strh r1, [r0] - bl _0807CFB4 - .pool -_0807C2D0: - ldr r4, =gUnknown_020322A0 - ldr r0, [r4] - adds r2, r0, 0 - adds r2, 0xEA - ldrh r1, [r2] - movs r0, 0x80 - lsls r0, 1 - cmp r1, r0 - bls _0807C2F0 - adds r0, r1, 0 - subs r0, 0x34 - strh r0, [r2] - b _0807C30C - .pool -_0807C2F0: - movs r0, 0x1 - bl sub_807B62C - ldr r3, [r4] - adds r1, r3, 0 - adds r1, 0xEA - movs r2, 0 - movs r0, 0x80 - strh r0, [r1] - subs r1, 0x56 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - str r2, [r3, 0x64] -_0807C30C: - ldr r0, =gUnknown_020322A0 - ldr r4, [r0] - bl _0807CB5C - .pool -_0807C318: - ldr r1, [r7] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0x14 - bhi _0807C328 - bl _0807CFB4 -_0807C328: - bl sub_807AB28 - ldr r0, =gSpriteTemplate_8338E74 - movs r1, 0x78 - movs r2, 0x50 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - adds r1, 0x91 - strb r0, [r1] - ldr r1, [r7] - bl _0807CF4C - .pool -_0807C348: - ldr r2, =gSprites - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 27 - cmp r0, 0 - blt _0807C368 - bl _0807CFB4 -_0807C368: - adds r0, r1, 0 - bl DestroySprite - movs r1, 0xC8 - lsls r1, 3 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000040c - movs r0, 0x52 - bl SetGpuReg - ldr r1, [r7] - bl _0807CF4C - .pool -_0807C390: - ldr r2, [r7] - adds r0, r2, 0 - adds r0, 0xE0 - ldrh r1, [r0] - subs r1, 0x1 - strh r1, [r0] - lsls r1, 16 - movs r0, 0x9E - lsls r0, 17 - cmp r1, r0 - bne _0807C3B0 - adds r1, r2, 0 - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0807C3B0: - ldr r0, [r7] - adds r0, 0xE0 - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - beq _0807C3C4 - bl _0807CFB4 -_0807C3C4: - ldr r0, =gSpriteTemplate_8338DFC - movs r1, 0x80 - movs r2, 0x41 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - adds r1, 0x92 - strb r0, [r1] - bl _0807CFB4 - .pool -_0807C3E0: - ldr r0, =gUnknown_08338D88 - movs r1, 0x80 - movs r2, 0x50 - movs r3, 0x3 - bl CreateSprite - ldr r4, =gUnknown_020322A0 - ldr r1, [r4] - adds r1, 0x90 - strb r0, [r1] - ldr r0, =gSpriteTemplate_8338DC8 - movs r1, 0x80 - movs r2, 0x50 - movs r3, 0 - bl CreateSprite - ldr r1, [r4] - adds r1, 0x91 - strb r0, [r1] - ldr r0, [r4] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - movs r1, 0x1 - bl StartSpriteAnim - ldr r1, [r4] - bl _0807CF4C - .pool -_0807C434: - ldr r2, [r7] - adds r1, r2, 0 - adds r1, 0xE0 - ldrh r0, [r1] - subs r0, 0x2 - strh r0, [r1] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA6 - bne _0807C44E - subs r1, 0x4C - movs r0, 0xC8 - strh r0, [r1] -_0807C44E: - ldr r1, =0x00001241 - movs r0, 0 - bl SetGpuReg - bl _0807CFB4 - .pool -_0807C460: - ldr r2, =gSprites - ldr r4, [r7] - adds r3, r4, 0 - adds r3, 0x90 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - subs r1, 0x2 - strh r1, [r0, 0x22] - adds r0, r4, 0 - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - subs r1, 0x2 - strh r1, [r0, 0x22] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0x22 - ldrsh r1, [r0, r3] - movs r0, 0x8 - negs r0, r0 - cmp r1, r0 - blt _0807C4A6 - bl _0807CFB4 -_0807C4A6: - adds r1, r4, 0 - adds r1, 0x94 - movs r0, 0x1D - strh r0, [r1] - bl _0807CFB4 - .pool -_0807C4B8: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0x94 - movs r1, 0x1E - strh r1, [r0] - bl _0807CFB4 - .pool -_0807C4DC: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807C4EC - bl _0807CFB4 -_0807C4EC: - ldr r0, [r7] - adds r0, 0x90 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl DestroySprite - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - movs r0, 0x2 - bl sub_807B62C - ldr r1, [r7] - bl _0807CF4C - .pool -_0807C528: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r5, =gSpriteTemplate_8338DC8 - adds r0, r5, 0 - movs r1, 0x6F - movs r2, 0xAA - movs r3, 0 - bl CreateSprite - ldr r4, =gUnknown_020322A0 - ldr r1, [r4] - adds r1, 0x90 - strb r0, [r1] - movs r2, 0xA - negs r2, r2 - adds r0, r5, 0 - movs r1, 0x81 - movs r3, 0 - bl CreateSprite - ldr r1, [r4] - adds r1, 0x91 - strb r0, [r1] - ldr r1, [r4] - bl _0807CF4C - .pool -_0807C574: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0807C592 - movs r0, 0x2E - bl PlaySE - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0807C592: - ldr r3, =gSprites - ldr r0, =gUnknown_020322A0 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x90 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x26] - subs r1, 0x3 - strh r1, [r0, 0x26] - adds r2, 0x91 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - bl _0807CFB4 - .pool -_0807C5D0: - ldr r5, =gSprites - ldr r4, [r7] - adds r2, r4, 0 - adds r2, 0x90 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrh r1, [r0, 0x26] - subs r1, 0x3 - strh r1, [r0, 0x26] - adds r6, r4, 0 - adds r6, 0x91 - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r3, r0, r5 - movs r0, 0x26 - ldrsh r1, [r3, r0] - movs r0, 0x5A - negs r0, r0 - cmp r1, r0 - ble _0807C616 - bl _0807CFB4 -_0807C616: - movs r2, 0x1 - strh r2, [r3, 0x30] - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - strh r2, [r0, 0x30] - adds r1, r4, 0 - bl _0807CF4C - .pool -_0807C630: - ldr r2, =0x0000ffff - movs r0, 0x1 - movs r1, 0x10 - bl BlendPalettes - bl _0807CF48 - .pool -_0807C644: - ldr r2, =0x0000ffff - movs r0, 0x1 - movs r1, 0 - bl BlendPalettes - bl _0807CF48 - .pool -_0807C658: - ldr r2, =0x0000ffff - movs r0, 0x1 - movs r1, 0x10 - bl BlendPalettes - bl _0807CF48 - .pool -_0807C66C: - ldr r5, =gUnknown_020322A0 - ldr r0, [r5] - adds r0, 0xF0 - ldrh r0, [r0] - bl IsMonSpriteNotFlipped - lsls r0, 24 - cmp r0, 0 - bne _0807C6E4 - ldr r4, =gSprites - ldr r2, [r5] - adds r2, 0x8E - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x10 - adds r0, r1 - ldr r1, =gSpriteAffineAnimTable_8338ECC - str r1, [r0] - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x1] - movs r2, 0x3 - orrs r1, r2 - strb r1, [r0, 0x1] - ldr r0, [r5] - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0 - movs r2, 0x3 - movs r3, 0x3 - bl CalcCenterToCornerVec - ldr r0, [r5] - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0 - bl StartSpriteAffineAnim - b _0807C6FA - .pool -_0807C6E4: - ldr r0, [r5] - adds r0, 0x8E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - movs r1, 0 - bl StartSpriteAffineAnim -_0807C6FA: - ldr r5, =gUnknown_020322A0 - ldr r0, [r5] - adds r0, 0x8F - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - movs r1, 0 - bl StartSpriteAffineAnim - ldr r2, [r5] - adds r3, r2, 0 - adds r3, 0x8E - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x3C - strh r1, [r0, 0x20] - adds r2, 0x8F - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0xB4 - strh r1, [r0, 0x20] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0xC0 - strh r1, [r0, 0x22] - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldr r1, =0x0000ffe0 - strh r1, [r0, 0x22] - ldrb r0, [r3] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - adds r1, 0x3E - ldrb r3, [r1] - movs r2, 0x5 - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - strb r0, [r1] - ldr r0, [r5] - adds r0, 0x8F - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x3E - ldrb r1, [r0] - ands r2, r1 - strb r2, [r0] - ldr r1, [r5] - bl _0807CF4C - .pool -_0807C794: - ldr r4, =gSprites - ldr r2, [r7] - adds r3, r2, 0 - adds r3, 0x8E - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r0, 0x26] - subs r1, 0x3 - movs r5, 0 - strh r1, [r0, 0x26] - adds r2, 0x8F - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r0, [r0, 0x26] - adds r0, 0xA3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x2 - bhi _0807C7DC - movs r0, 0x2D - bl PlaySE -_0807C7DC: - ldr r2, [r7] - adds r3, r2, 0 - adds r3, 0x8E - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r6, 0x26 - ldrsh r1, [r0, r6] - movs r0, 0xDE - negs r0, r0 - cmp r1, r0 - blt _0807C7FC - bl _0807CFB4 -_0807C7FC: - adds r0, r2, 0 - adds r0, 0x90 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - strh r5, [r0, 0x30] - adds r0, r2, 0 - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - strh r5, [r0, 0x30] - adds r1, r2, 0 - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r7] - adds r0, 0x8F - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldr r2, =0x0000ffff - movs r0, 0x1 - movs r1, 0 - bl BlendPalettes - b _0807CFB4 - .pool -_0807C864: - ldr r4, =gSprites - ldr r2, [r7] - adds r3, r2, 0 - adds r3, 0x90 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r0, 0x26] - subs r1, 0x3 - strh r1, [r0, 0x26] - adds r2, 0x91 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r2, 0x26 - ldrsh r1, [r0, r2] - movs r0, 0xDE - negs r0, r0 - cmp r1, r0 - ble _0807C8A6 - b _0807CFB4 -_0807C8A6: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, [r7] - adds r2, r1, 0 - adds r2, 0x94 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - adds r1, 0x90 - ldrb r1, [r1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - b _0807CFB4 - .pool -_0807C8EC: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807C8FA - b _0807CFB4 -_0807C8FA: - ldr r1, [r7] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - movs r0, 0x1 - bl sub_807B62C - ldr r0, [r7] - adds r0, 0xE0 - movs r1, 0xA6 - strh r1, [r0] - ldr r0, =gUnknown_08338D88 - movs r4, 0x14 - negs r4, r4 - movs r1, 0x80 - adds r2, r4, 0 - movs r3, 0x3 - bl CreateSprite - ldr r1, [r7] - adds r1, 0x90 - strb r0, [r1] - ldr r0, =gSpriteTemplate_8338DC8 - movs r1, 0x80 - adds r2, r4, 0 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - adds r1, 0x91 - strb r0, [r1] - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - movs r1, 0x1 - bl StartSpriteAnim - b _0807CFB4 - .pool -_0807C964: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0x10 - movs r3, 0 - b _0807CF44 -_0807C974: - movs r1, 0x92 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807C98C - b _0807CFB4 -_0807C98C: - b _0807CF48 - .pool -_0807C994: - ldr r2, =gSprites - ldr r4, [r7] - adds r3, r4, 0 - adds r3, 0x90 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - adds r0, r4, 0 - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - adds r1, 0x3 - strh r1, [r0, 0x26] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r3, 0x26 - ldrsh r1, [r0, r3] - movs r6, 0x22 - ldrsh r0, [r0, r6] - adds r1, r0 - cmp r1, 0x40 - beq _0807C9DA - b _0807CFB4 -_0807C9DA: - adds r1, r4, 0 - b _0807CF4C - .pool -_0807C9E4: - ldr r1, [r7] - adds r5, r1, 0 - adds r5, 0xE0 - ldrh r0, [r5] - adds r0, 0x2 - strh r0, [r5] - lsls r0, 16 - asrs r0, 16 - movs r6, 0x9E - lsls r6, 1 - cmp r0, r6 - bgt _0807C9FE - b _0807CFB4 -_0807C9FE: - strh r6, [r5] - b _0807CF4C -_0807CA02: - ldr r0, [r7] - adds r0, 0x90 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl DestroySprite - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - ldr r3, [r7] - adds r2, r3, 0 - adds r2, 0x94 - ldrh r0, [r2] - adds r0, 0x1 - movs r1, 0 - strh r0, [r2] - str r1, [r3, 0x64] - b _0807CFB4 - .pool -_0807CA40: - ldr r1, [r7] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0xA - beq _0807CA4E - b _0807CFB4 -_0807CA4E: - b _0807CF4C -_0807CA50: - ldr r1, [r7] - adds r2, r1, 0 - adds r2, 0xE0 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - lsls r0, 16 - asrs r0, 16 - movs r3, 0xAE - lsls r3, 1 - cmp r0, r3 - ble _0807CA72 - strh r3, [r2] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0807CA72: - ldr r2, [r7] - adds r0, r2, 0 - adds r0, 0xE0 - movs r3, 0 - ldrsh r1, [r0, r3] - movs r0, 0xA4 - lsls r0, 1 - cmp r1, r0 - beq _0807CA86 - b _0807CFB4 -_0807CA86: - adds r0, r2, 0 - adds r0, 0xFA - ldrb r0, [r0] - cmp r0, 0 - bne _0807CA92 - b _0807CFB4 -_0807CA92: - ldr r0, =gSpriteTemplate_8338DFC - movs r1, 0x80 - movs r2, 0x41 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - adds r1, 0x92 - strb r0, [r1] - ldr r2, =gSprites - ldr r0, [r7] - adds r0, 0x92 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, =sub_807AAE0 - str r1, [r0] - b _0807CFB4 - .pool -_0807CAC8: - ldr r0, =gSpriteTemplate_8338E74 - movs r1, 0x78 - movs r2, 0x50 - movs r3, 0 - bl CreateSprite - ldr r2, =gUnknown_020322A0 - ldr r1, [r2] - adds r1, 0x91 - strb r0, [r1] - ldr r0, [r2] - adds r0, 0x94 - movs r1, 0x32 - strh r1, [r0] - b _0807CFB4 - .pool -_0807CAF0: - ldr r2, =gSprites - ldr r0, [r7] - adds r0, 0x91 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 27 - cmp r0, 0 - blt _0807CB0E - b _0807CFB4 -_0807CB0E: - adds r0, r1, 0 - bl DestroySprite - movs r0, 0x6 - bl sub_807B62C - ldr r1, [r7] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - movs r0, 0x9F - bl PlaySE - b _0807CFB4 - .pool -_0807CB30: - ldr r1, [r7] - adds r2, r1, 0 - adds r2, 0xEA - ldrh r3, [r2] - ldr r0, =0x000003ff - cmp r3, r0 - bhi _0807CB4C - adds r0, r3, 0 - adds r0, 0x34 - strh r0, [r2] - b _0807CB5A - .pool -_0807CB4C: - movs r0, 0x80 - lsls r0, 3 - strh r0, [r2] - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0807CB5A: - ldr r4, [r7] -_0807CB5C: - adds r0, r4, 0 - adds r0, 0xEA - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 8 - bl __divsi3 - adds r4, 0xE8 - strh r0, [r4] - b _0807CFB4 -_0807CB70: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0x94 - movs r1, 0x3C - strh r1, [r0] - b _0807CFB4 - .pool -_0807CB90: - ldr r4, =gPaletteFade - ldrb r1, [r4, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807CB9E - b _0807CFB4 -_0807CB9E: - movs r0, 0x5 - bl sub_807B62C - movs r0, 0x7 - bl sub_807B62C - ldrb r0, [r4, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r4, 0x8] - b _0807CF48 - .pool -_0807CBB8: - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x8] - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - b _0807CF44 - .pool -_0807CBD4: - movs r1, 0xA2 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0807CBEC - b _0807CFB4 -_0807CBEC: - b _0807CF48 - .pool -_0807CBF4: - ldr r0, =gSpriteTemplate_8338D28 - movs r2, 0x8 - negs r2, r2 - movs r1, 0x78 - movs r3, 0 - bl CreateSprite - ldr r5, =gUnknown_020322A0 - ldr r1, [r5] - adds r1, 0xD3 - movs r6, 0 - strb r0, [r1] - ldr r4, =gSprites - ldr r2, [r5] - adds r2, 0xD3 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x4A - strh r1, [r0, 0x34] - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_807E6AC - str r1, [r0] - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x1 - bl StartSpriteAnim - ldr r0, [r5] - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x2 - bl StartSpriteAffineAnim - ldr r0, [r5] - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x5] - lsrs r1, 4 - adds r1, 0x10 - movs r0, 0x1 - lsls r0, r1 - ldr r2, =0x0000ffff - movs r1, 0x10 - bl BlendPalettes - ldr r2, [r5] - adds r1, r2, 0 - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - str r6, [r2, 0x64] - b _0807CFB4 - .pool -_0807CC9C: - ldr r2, =gSprites - ldr r0, [r7] - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x5] - lsrs r1, 4 - adds r1, 0x10 - movs r0, 0x1 - lsls r0, r1 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0x1 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r1, [r7] - b _0807CF4C - .pool -_0807CCD0: - ldr r2, =gSprites - ldr r3, [r7] - adds r0, r3, 0 - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, [r0] - ldr r0, =SpriteCallbackDummy - cmp r1, r0 - beq _0807CCEE - b _0807CFB4 -_0807CCEE: - adds r0, r3, 0 - adds r0, 0xF2 - ldrh r2, [r0] - lsls r0, r2, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x10] - ldr r3, [r3, 0x6C] - bl HandleLoadSpecialPokePic_2 - ldr r1, [r7] - b _0807CF4C - .pool -_0807CD1C: - ldr r4, =gSprites - ldr r2, [r7] - adds r6, r2, 0 - adds r6, 0x8F - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r5, 0 - movs r1, 0x78 - strh r1, [r0, 0x20] - ldrb r0, [r6] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldr r3, =gMonFrontPicCoords - adds r2, 0xF2 - ldrh r0, [r2] - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x1] - adds r0, 0x3C - strh r0, [r1, 0x22] - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - strh r5, [r0, 0x24] - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - strh r5, [r0, 0x26] - ldrb r1, [r6] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0 - bl StartSpriteAnim - ldr r3, [r7] - adds r0, r3, 0 - adds r0, 0x8F - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r1, [r1, 0x5] - lsrs r1, 4 - movs r2, 0x2 - str r2, [sp] - movs r2, 0x1 - str r2, [sp, 0x4] - movs r2, 0x14 - str r2, [sp, 0x8] - ldr r2, =0x000fffff - str r2, [sp, 0xC] - adds r3, 0xF2 - ldrh r2, [r3] - str r2, [sp, 0x10] - movs r2, 0x78 - movs r3, 0x54 - bl CreatePokeballSpriteToReleaseMon - ldr r0, [r7] - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl FreeSpriteOamMatrix - ldr r0, [r7] - adds r0, 0xD3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - ldr r1, [r7] - b _0807CF4C - .pool -_0807CDDC: - movs r1, 0xAA - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r4, =gStringVar4 - ldr r1, =gText_XSentOverY - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_807F1A8 - ldr r0, =gUnknown_020322A0 - ldr r3, [r0] - adds r1, r3, 0 - adds r1, 0x94 - movs r2, 0 - movs r0, 0xA7 -_0807CE06: - strh r0, [r1] - str r2, [r3, 0x64] - b _0807CFB4 - .pool -_0807CE18: - ldr r3, [r7] - ldr r0, [r3, 0x64] - adds r0, 0x1 - str r0, [r3, 0x64] - cmp r0, 0x3C - bhi _0807CE26 - b _0807CFB4 -_0807CE26: - adds r0, r3, 0 - adds r0, 0x94 - movs r2, 0 - ldr r1, =0x0000010b - strh r1, [r0] - str r2, [r3, 0x64] - b _0807CFB4 - .pool -_0807CE38: - bl IsCryFinished - lsls r0, 24 - cmp r0, 0 - bne _0807CE44 - b _0807CFB4 -_0807CE44: - ldr r0, =gUnknown_020322A0 - ldr r0, [r0] - adds r0, 0x94 - movs r1, 0x44 - strh r1, [r0] - b _0807CFB4 - .pool -_0807CE54: - ldr r1, [r7] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0xA - bne _0807CE66 - ldr r0, =0x00000173 - bl PlayFanfare -_0807CE66: - ldr r1, [r7] - ldr r0, [r1, 0x64] - cmp r0, 0xFA - beq _0807CE70 - b _0807CFB4 -_0807CE70: - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - movs r5, 0 - strh r0, [r1] - ldr r4, =gStringVar4 - ldr r1, =gText_TakeGoodCareOfX - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_807F1A8 - ldr r0, [r7] - str r5, [r0, 0x64] - b _0807CFB4 - .pool -_0807CEA0: - ldr r1, [r7] - ldr r0, [r1, 0x64] - adds r0, 0x1 - str r0, [r1, 0x64] - cmp r0, 0x3C - beq _0807CEAE - b _0807CFB4 -_0807CEAE: - b _0807CF4C -_0807CEB0: - bl sub_807F14C - b _0807CF48 -_0807CEB6: - ldr r2, [r7] - adds r0, r2, 0 - adds r0, 0xEE - ldrb r0, [r0] - cmp r0, 0 - beq _0807CEC6 - movs r0, 0x1 - b _0807CFB6 -_0807CEC6: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0807CFB4 - adds r1, r2, 0 - b _0807CF4C - .pool -_0807CEDC: - ldr r0, =gSpecialVar_0x8005 - ldrb r0, [r0] - movs r1, 0 - bl sub_807B4D0 - ldr r1, =gCB2_AfterEvolution - ldr r0, =sub_807B60C - str r0, [r1] - ldr r7, =gUnknown_02032298 - ldrb r0, [r7] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0x1 - movs r2, 0 - bl GetEvolutionTargetSpecies - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _0807CF48 - ldrb r3, [r7] - adds r0, r3, 0 - muls r0, r6 - adds r0, r5 - ldr r1, =gUnknown_020322A0 - ldr r1, [r1] - adds r1, 0x8F - ldrb r2, [r1] - adds r1, r4, 0 - bl TradeEvolutionScene - b _0807CF48 - .pool -_0807CF38: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 -_0807CF44: - bl BeginNormalPaletteFade -_0807CF48: - ldr r0, =gUnknown_020322A0 - ldr r1, [r0] -_0807CF4C: - adds r1, 0x94 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _0807CFB4 - .pool -_0807CF5C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0807CFB4 - ldr r0, [r7] - adds r0, 0xF4 - ldrh r0, [r0] - bl PlayNewMapMusic - ldr r0, [r7] - cmp r0, 0 - beq _0807CFAA - bl FreeAllWindowBuffers - movs r0, 0x3 - bl GetBgTilemapBuffer - bl Free - movs r0, 0x1 - bl GetBgTilemapBuffer - bl Free - movs r0, 0 - bl GetBgTilemapBuffer - bl Free - bl FreeMonSpritesGfx - ldr r0, [r7] - bl Free - str r4, [r7] -_0807CFAA: - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - bl sub_807E784 -_0807CFB4: - movs r0, 0 -_0807CFB6: - add sp, 0x14 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_807BBEC - thumb_func_start sub_807CFC8 sub_807CFC8: @ 807CFC8 push {r4-r7,lr} diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index c20b69886..448fae06d 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -600,7 +600,7 @@ #define BLDCNT_TGT2_ALL (BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD) // BLDALPHA -#define BLDALPHA_BLEND(target1, target2) (((target2) << 8) | (target1)) +#define BLDALPHA_BLEND(target1, target2) ((target1)) | ((target2) << 8) // SOUNDCNT_H #define SOUND_CGB_MIX_QUARTER 0x0000 diff --git a/include/strings.h b/include/strings.h index 64222cddb..528990bfe 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1984,4 +1984,10 @@ extern const u8 gText_EggCantBeTradedNow[]; extern const u8 gText_OtherTrainerCantAcceptPkmn[]; extern const u8 gText_CantTradeWithTrainer[]; +// trade +extern const u8 gText_XWillBeSentToY[]; +extern const u8 gText_ByeByeVar1[]; +extern const u8 gText_XSentOverY[]; +extern const u8 gText_TakeGoodCareOfX[]; + #endif //GUARD_STRINGS_H diff --git a/src/trade.c b/src/trade.c index 4d5edffd7..c996c3348 100644 --- a/src/trade.c +++ b/src/trade.c @@ -8,6 +8,7 @@ #include "daycare.h" #include "decompress.h" #include "event_data.h" +#include "evolution_scene.h" #include "gpu_regs.h" #include "graphics.h" #include "international_string_util.h" @@ -19,11 +20,13 @@ #include "overworld.h" #include "palette.h" #include "party_menu.h" +#include "pokeball.h" #include "pokedex.h" #include "pokemon_icon.h" #include "pokemon_summary_screen.h" #include "sound.h" #include "string_util.h" +#include "strings.h" #include "task.h" #include "text.h" #include "text_window.h" @@ -31,92 +34,113 @@ #include "trade.h" #include "util.h" #include "window.h" +#include "constants/items.h" #include "constants/moves.h" #include "constants/species.h" #include "constants/songs.h" #include "constants/rgb.h" +struct InGameTrade { + /*0x00*/ u8 name[11]; + /*0x0C*/ u16 species; + /*0x0E*/ u8 ivs[6]; + /*0x14*/ bool8 secondAbility; + /*0x18*/ u32 otId; + /*0x1C*/ u8 stats[5]; + /*0x24*/ u32 personality; + /*0x28*/ u16 heldItem; + /*0x2A*/ u8 mailNum; + /*0x2B*/ u8 otName[11]; + /*0x36*/ u8 otGender; + /*0x37*/ u8 sheen; + /*0x38*/ u16 playerSpecies; +}; + extern u8 gUnknown_02022C2C; extern struct { - u8 unk_0; - u8 unk_1; - u8 filler_2[0x28 - 2]; - u8 unk_28[2][PARTY_SIZE]; - u8 unk_34; - u8 unk_35; - u8 unk_36[2]; - u8 unk_38[12]; - u8 unk_44; - u8 unk_45[2][PARTY_SIZE]; - u8 unk_51[2][PARTY_SIZE]; - u8 unk_5D[PARTY_SIZE]; - u8 unk_63[PARTY_SIZE]; - u8 unk_69; - u8 filler_6A[0x6F - 0x6A]; - u8 unk_6F; - u8 unk_70; - u8 filler_71; - u16 unk_72; - u8 unk_74[2]; - u8 unk_76[2]; - u8 unk_78; - u8 unk_79; - u8 unk_7A; - u8 unk_7B; - u8 filler_7C[0x7E - 0x7C]; - u8 unk_7E; - u8 filler_7F; - u16 unk_80[2]; - u8 filler_84[0xA8 - 0x84]; - u8 unk_A8; - u8 unk_A9[11]; - u8 filler_B4[0x8D0-0xB4]; - struct { + /*0x0000*/ u8 unk_0; + /*0x0001*/ u8 unk_1; + /*0x0002*/ u8 filler_2[0x28 - 2]; + /*0x0028*/ u8 unk_28[2][PARTY_SIZE]; + /*0x0034*/ u8 unk_34; + /*0x0035*/ u8 unk_35; + /*0x0036*/ u8 partyCounts[2]; + /*0x0038*/ u8 unk_38[12]; + /*0x0044*/ u8 unk_44; + /*0x0045*/ u8 unk_45[2][PARTY_SIZE]; + /*0x0051*/ u8 unk_51[2][PARTY_SIZE]; + /*0x005D*/ u8 unk_5D[2][PARTY_SIZE]; + /*0x0069*/ u8 unk_69; + /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; + /*0x006F*/ u8 unk_6F; + /*0x0070*/ u8 unk_70; + /*0x0071*/ u8 filler_71; + /*0x0072*/ u16 unk_72; + /*0x0074*/ u8 unk_74[2]; + /*0x0076*/ u8 unk_76[2]; + /*0x0078*/ u8 unk_78; + /*0x0079*/ u8 unk_79; + /*0x007A*/ u8 unk_7A; + /*0x007B*/ u8 unk_7B; + /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; + /*0x007E*/ u8 unk_7E; + /*0x007F*/ u8 filler_7F; + /*0x0080*/ u16 unk_80[2]; + /*0x0084*/ u8 filler_84[0xA8 - 0x84]; + /*0x00A8*/ u8 unk_A8; + /*0x00A9*/ u8 unk_A9[11]; + /*0x00B4*/ u8 filler_B4[0x8D0-0xB4]; + /*0x08D0*/ struct { bool8 unk_0; u16 unk_2; u8 unk_4; } unk_8D0[4]; - u16 tilemapBuffer[0x400]; // 8F0 + /*0x08F0*/ u16 tilemapBuffer[0x400]; } *gUnknown_0203229C; 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]; + /*0x00*/ struct Pokemon mon; + /*0x64*/ u32 unk_64; + /*0x68*/ u32 unk_68[2]; + /*0x70*/ u8 filler_70[2]; + /*0x72*/ u8 unk_72; + /*0x73*/ u8 unk_73; + /*0x74*/ u8 unk_74[20]; + /*0x88*/ u8 unk_88; + /*0x89*/ u8 unk_89; + /*0x8A*/ u16 unk_8A; + /*0x8C*/ u16 unk_8C; + /*0x8E*/ u8 pokePicSpriteIdxs[2]; + /*0x90*/ u8 unk_90; + /*0x91*/ u8 unk_91; + /*0x92*/ u8 unk_92; + /*0x93*/ u8 unk_93; + /*0x94*/ u16 unk_94; + /*0x96*/ u8 filler_96[0xD2 - 0x96]; + /*0xD2*/ u8 unk_D2; + /*0xD3*/ u8 unk_D3; + /*0xD4*/ u16 unk_D4; + /*0xD6*/ u16 unk_D6; + /*0xD8*/ u16 unk_D8; + /*0xDA*/ u16 unk_DA; + /*0xDC*/ s16 unk_DC; + /*0xDE*/ s16 unk_DE; + /*0xE0*/ s16 bg1vofs; + /*0xE2*/ s16 bg1hofs; + /*0xE4*/ s16 bg2vofs; + /*0xE6*/ s16 bg2hofs; + /*0xE8*/ s16 unk_E8; + /*0xEA*/ u16 unk_EA; + /*0xEC*/ u16 unk_EC; + /*0xEE*/ bool8 isLinkTrade; + /*0xEF*/ u8 filler_EF; + /*0xF0*/ u16 tradeSpecies[2]; + /*0xF4*/ u16 unk_F4; + /*0xF6*/ u8 filler_F6[0xFA - 0xF6]; + /*0xFA*/ u8 unk_FA; + /*0xFB*/ u8 filler_FB[0x100 - 0xFB]; } *gUnknown_020322A0; extern u8 gUnknown_0203CF20; @@ -162,8 +186,24 @@ extern const u32 gUnknown_08338550[]; extern const u8 gUnknown_08332F60[]; extern const u8 gUnknown_083357A0[]; extern const u8 gUnknown_083358A0[]; +extern const struct SpriteSheet gUnknown_08338D70; +extern const struct SpriteSheet gUnknown_08338DC0; +extern const struct SpriteSheet gUnknown_08338DF4; +extern const struct SpriteSheet gUnknown_08338E6C; +extern const struct SpritePalette gUnknown_08338D78; +extern const struct SpritePalette gUnknown_08338D80; +extern const struct InGameTrade gIngameTrades[]; +extern const struct SpriteTemplate gSpriteTemplate_8338D28; +extern const struct SpriteTemplate gSpriteTemplate_8338E74; +extern const struct SpriteTemplate gSpriteTemplate_8338DFC; +extern const struct SpriteTemplate gUnknown_08338D88; +extern const struct SpriteTemplate gSpriteTemplate_8338DC8; +extern const union AffineAnimCmd *const gSpriteAffineAnimTable_8338ECC[]; +extern const struct SpriteTemplate gSpriteTemplate_8338E74; +// external to this file extern const struct CompressedSpriteSheet gMonFrontPicTable[]; +extern const struct MonCoords gMonFrontPicCoords[]; bool32 sub_8077260(void); void sub_80773D0(void); @@ -202,7 +242,16 @@ void sub_807BAD8(void); void sub_807EA2C(void); void sub_807B62C(u8); void sub_807B60C(void); -void sub_807BBC8(void); +u8 sub_807BBC8(void); +u8 sub_807CFC8(void); +u8 sub_807BBEC(void); +void sub_807F1A8(u8, u8 *, u8); +void sub_807E5D8(struct Sprite *); +void sub_807AAE0(struct Sprite *); +void sub_807E6AC(struct Sprite *); +void sub_807F14C(void); +void sub_807E784(void); +void c3_0805465C(u8); bool8 sub_8077170(const void *a0, u32 a1) { @@ -462,10 +511,10 @@ void sub_80773D0(void) CalculateEnemyPartyCount(); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0); - gUnknown_0203229C->unk_36[0] = gPlayerPartyCount; - gUnknown_0203229C->unk_36[1] = gEnemyPartyCount; + gUnknown_0203229C->partyCounts[0] = gPlayerPartyCount; + gUnknown_0203229C->partyCounts[1] = gEnemyPartyCount; - for (i = 0; i < gUnknown_0203229C->unk_36[0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { struct Pokemon *mon = &gPlayerParty[i]; gUnknown_0203229C->unk_28[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), @@ -477,7 +526,7 @@ void sub_80773D0(void) TRUE); } - for (i = 0; i < gUnknown_0203229C->unk_36[1]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) { struct Pokemon *mon = &gEnemyParty[i]; gUnknown_0203229C->unk_28[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), @@ -492,11 +541,11 @@ void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->unk_36[0], gUnknown_0203229C->unk_28[0], 0); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->unk_28[0], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->unk_36[0], gUnknown_0203229C->unk_28[0], 1); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->unk_28[0], 1); gMain.state++; break; case 10: @@ -645,13 +694,13 @@ void sub_8077B74(void) break; case 7: CalculateEnemyPartyCount(); - gUnknown_0203229C->unk_36[0] = gPlayerPartyCount; - gUnknown_0203229C->unk_36[1] = gEnemyPartyCount; + gUnknown_0203229C->partyCounts[0] = gPlayerPartyCount; + gUnknown_0203229C->partyCounts[1] = gEnemyPartyCount; ClearWindowTilemap(0); sub_8079BE0(0); sub_8079BE0(1); - for (i = 0; i < gUnknown_0203229C->unk_36[0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { struct Pokemon *mon = &gPlayerParty[i]; gUnknown_0203229C->unk_28[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), @@ -663,7 +712,7 @@ void sub_8077B74(void) TRUE); } - for (i = 0; i < gUnknown_0203229C->unk_36[1]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) { struct Pokemon *mon = &gEnemyParty[i]; gUnknown_0203229C->unk_28[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), @@ -678,11 +727,11 @@ void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->unk_36[0], gUnknown_0203229C->unk_28[0], 0); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->unk_28[0], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->unk_36[0], gUnknown_0203229C->unk_28[0], 1); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->unk_28[0], 1); gMain.state++; break; case 10: @@ -906,7 +955,7 @@ void sub_8078388(void) for (i = 0; i < PARTY_SIZE; i++) { - if (i < gUnknown_0203229C->unk_36[0]) + if (i < gUnknown_0203229C->partyCounts[0]) { gSprites[gUnknown_0203229C->unk_28[0][i]].invisible = FALSE; gUnknown_0203229C->unk_38[i] = TRUE; @@ -916,7 +965,7 @@ void sub_8078388(void) gUnknown_0203229C->unk_38[i] = FALSE; } - if (i < gUnknown_0203229C->unk_36[1]) + if (i < gUnknown_0203229C->partyCounts[1]) { gSprites[gUnknown_0203229C->unk_28[1][i]].invisible = FALSE; gUnknown_0203229C->unk_38[i + PARTY_SIZE] = TRUE; @@ -1452,11 +1501,11 @@ void sub_807905C(void) { if (gUnknown_0203229C->unk_35 < PARTY_SIZE) { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203229C->unk_35, gUnknown_0203229C->unk_36[0] - 1, sub_8077B74); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203229C->unk_35, gUnknown_0203229C->partyCounts[0] - 1, sub_8077B74); } else { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, gUnknown_0203229C->unk_35 - PARTY_SIZE, gUnknown_0203229C->unk_36[1] - 1, sub_8077B74); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, gUnknown_0203229C->unk_35 - PARTY_SIZE, gUnknown_0203229C->partyCounts[1] - 1, sub_8077B74); } FreeAllWindowBuffers(); } @@ -1508,12 +1557,12 @@ bool32 sub_8079174(void) int i; u8 arr[12]; - for (i = 0; i < gUnknown_0203229C->unk_36[0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { arr[i] = gUnknown_0203229C->unk_45[0][i]; } - switch (sub_80790D4(arr, gUnknown_0203229C->unk_36[0], gUnknown_0203229C->unk_35, gUnknown_0203229C->unk_7E)) + switch (sub_80790D4(arr, gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->unk_35, gUnknown_0203229C->unk_7E)) { case 0: sub_807A048(3, 3); @@ -1563,7 +1612,7 @@ void sub_807929C(void) { int i; - for (i = 0; i < gUnknown_0203229C->unk_36[1] - 4; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[1] - 4; i++) { PutWindowTilemap(i + 12); CopyWindowToVram(i + 12, 1); @@ -1793,7 +1842,7 @@ void sub_80796B4(u8 a0) switch (gUnknown_0203229C->unk_74[a0]) { case 1: - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[a0]; i++) { gSprites[gUnknown_0203229C->unk_28[0][i + (sp60 * 6)]].invisible = TRUE; } @@ -1921,7 +1970,7 @@ void sub_8079BE0(u8 a0) u8 sp14[32]; struct Pokemon *mons = a0 == 0 ? gPlayerParty : gEnemyParty; - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[a0]; i++) { GetMonData(&mons[i], MON_DATA_NICKNAME, sp); StringCopy10(sp14, sp); @@ -1999,18 +2048,18 @@ extern const u8 gUnknown_0832DE3E[][6][2]; extern const u8 gUnknown_0832DE56[][6][2]; // Very close but loop preamble not working. #ifdef NONMATCHING -void sub_8079E44(u8 a0) +void sub_8079E44(u8 whichParty) { int i; - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) { - sub_8079C4C(a0, i, gUnknown_0832DE3E[a0][i][0], gUnknown_0832DE3E[a0][i][1], gUnknown_0832DE56[a0][i][0], gUnknown_0832DE56[a0][i][1]); + sub_8079C4C(whichParty, i, gUnknown_0832DE3E[whichParty][i][0], gUnknown_0832DE3E[whichParty][i][1], gUnknown_0832DE56[whichParty][i][0], gUnknown_0832DE56[whichParty][i][1]); } } #else NAKED -void sub_8079E44(u8 a0) +void sub_8079E44(u8 whichParty) { asm_unified("push {r4-r7,lr}\n\ sub sp, 0x8\n\ @@ -2065,7 +2114,7 @@ void sub_8079EA8(u8 a0) { int i; - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[a0]; i++) { gSprites[gUnknown_0203229C->unk_28[a0][i]].invisible = FALSE; gSprites[gUnknown_0203229C->unk_28[a0][i]].pos1.x = gUnknown_0832DE24[(a0 * 6) + i][0] * 8 + 14; @@ -2238,75 +2287,75 @@ void sub_807A308(const u8 *a0, u8 *a1, u8 unused) sub_80C6D80(a0, a1, 0, 0, 6); } -void sub_807A320(u8 a0) +void sub_807A320(u8 who) { int i; - switch (a0) + switch (who) { case 0: - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[who]; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) { - gUnknown_0203229C->unk_45[a0][i] = 0; - gUnknown_0203229C->unk_51[a0][i] = 1; + gUnknown_0203229C->unk_45[who][i] = 0; + gUnknown_0203229C->unk_51[who][i] = 1; } else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - gUnknown_0203229C->unk_45[a0][i] = 0; - gUnknown_0203229C->unk_51[a0][i] = 0; + gUnknown_0203229C->unk_45[who][i] = 0; + gUnknown_0203229C->unk_51[who][i] = 0; } else { - gUnknown_0203229C->unk_45[a0][i] = 1; - gUnknown_0203229C->unk_51[a0][i] = 0; + gUnknown_0203229C->unk_45[who][i] = 1; + gUnknown_0203229C->unk_51[who][i] = 0; } } break; case 1: - for (i = 0; i < gUnknown_0203229C->unk_36[a0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[who]; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) { - gUnknown_0203229C->unk_45[a0][i] = 0; - gUnknown_0203229C->unk_51[a0][i] = 1; + gUnknown_0203229C->unk_45[who][i] = 0; + gUnknown_0203229C->unk_51[who][i] = 1; } else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) { - gUnknown_0203229C->unk_45[a0][i] = 0; - gUnknown_0203229C->unk_51[a0][i] = 0; + gUnknown_0203229C->unk_45[who][i] = 0; + gUnknown_0203229C->unk_51[who][i] = 0; } else { - gUnknown_0203229C->unk_45[a0][i] = 1; - gUnknown_0203229C->unk_51[a0][i] = 0; + gUnknown_0203229C->unk_45[who][i] = 1; + gUnknown_0203229C->unk_51[who][i] = 0; } } break; } } -void sub_807A468(u8 a0) +void sub_807A468(u8 who) { - u16 i, hp, maxHp; + u16 i, curHp, maxHp; - switch (a0) + switch (who) { case 0: - for (i = 0; i < gUnknown_0203229C->unk_36[0]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { - hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + curHp = GetMonData(&gPlayerParty[i], MON_DATA_HP); maxHp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); - gUnknown_0203229C->unk_5D[i] = GetHPBarLevel(hp, maxHp); + gUnknown_0203229C->unk_5D[0][i] = GetHPBarLevel(curHp, maxHp); } break; case 1: - for (i = 0; i < gUnknown_0203229C->unk_36[1]; i++) + for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) { - hp = GetMonData(&gEnemyParty[i], MON_DATA_HP); + curHp = GetMonData(&gEnemyParty[i], MON_DATA_HP); maxHp = GetMonData(&gEnemyParty[i], MON_DATA_MAX_HP); - gUnknown_0203229C->unk_63[i] = GetHPBarLevel(hp, maxHp); + gUnknown_0203229C->unk_5D[1][i] = GetHPBarLevel(curHp, maxHp); } break; } @@ -2318,9 +2367,9 @@ void sub_807A53C(void) for (i = 0; i < 2; i++) { - for (j = 0; j < gUnknown_0203229C->unk_36[i]; j++) + for (j = 0; j < gUnknown_0203229C->partyCounts[i]; j++) { - sub_80D32C8(&gSprites[gUnknown_0203229C->unk_28[i][j]], 4 - gUnknown_0203229C->unk_5D[i * 6 + j]); + sub_80D32C8(&gSprites[gUnknown_0203229C->unk_28[i][j]], 4 - gUnknown_0203229C->unk_5D[i][j]); } } } @@ -2959,14 +3008,14 @@ void sub_807ABCC(void) { u16 dispcnt; - SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_020322A0->unk_E0); - SetGpuReg(REG_OFFSET_BG1HOFS, gUnknown_020322A0->unk_E2); + SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_020322A0->bg1vofs); + SetGpuReg(REG_OFFSET_BG1HOFS, gUnknown_020322A0->bg1hofs); 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); + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_020322A0->bg2vofs); + SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_020322A0->bg2hofs); } else { @@ -3055,15 +3104,16 @@ void sub_807ACFC(u8 a0, u8 a1) { HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[a0 * 2 + 1], species, personality); } + LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); - gUnknown_020322A0->unk_F0[a0] = species; + gUnknown_020322A0->tradeSpecies[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; + gUnknown_020322A0->pokePicSpriteIdxs[a0] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[a0]].invisible = TRUE; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[a0]].callback = SpriteCallbackDummy; break; } } @@ -3089,7 +3139,7 @@ void sub_807AE50(void) gMain.state++; gUnknown_020322A0->unk_8C = 0; gUnknown_020322A0->unk_94 = 0; - gUnknown_020322A0->unk_EE = 1; + gUnknown_020322A0->isLinkTrade = TRUE; gUnknown_020322A0->unk_D4 = 64; gUnknown_020322A0->unk_D6 = 64; gUnknown_020322A0->unk_D8 = 0; @@ -3237,9 +3287,10 @@ void sub_807B170(void) LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); } +// In-game trade init void sub_807B270(void) { - u8 name[12]; + u8 name[11]; switch (gMain.state) { @@ -3258,7 +3309,7 @@ void sub_807B270(void) FreeAllSpritePalettes(); SetVBlankCallback(sub_807AC24); sub_807B170(); - gUnknown_020322A0->unk_EE = 0; + gUnknown_020322A0->isLinkTrade = FALSE; gUnknown_020322A0->unk_8C = 0; gUnknown_020322A0->unk_94 = 0; gUnknown_020322A0->unk_D4 = 64; @@ -3322,14 +3373,12 @@ void sub_807B270(void) 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); + u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); species = SpeciesToNationalPokedexNum(species); GetSetPokedexFlag(species, FLAG_SET_SEEN); HandleSetPokedexFlag(species, FLAG_SET_CAUGHT, personality); @@ -3338,7 +3387,10 @@ void sub_807B464(u8 a0) void sub_807B4C4(void) { - GetMultiplayerId(); + u8 mpId = GetMultiplayerId(); + // Originally in Ruby but commented out + /*if (gLinkPlayers[mpId ^ 1].lp_field_2 == 0x8000) + EnableNationalPokedex();*/ } void sub_807B4D0(u8 a0, u8 a1) @@ -3358,9 +3410,9 @@ void sub_807B4D0(u8 a0, u8 a1) 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)); + gUnknown_020322A0->mon = *mon1; + *mon1 = *mon2; + *mon2 = gUnknown_020322A0->mon; friendship = 70; if (!GetMonData(mon1, MON_DATA_IS_EGG)) @@ -3407,14 +3459,13 @@ void sub_807B60C(void) 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; + gUnknown_020322A0->bg2vofs = 0; + gUnknown_020322A0->bg2hofs = 180; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | @@ -3427,11 +3478,11 @@ void sub_807B62C(u8 a0) 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); + DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); break; case 1: - gUnknown_020322A0->unk_E2 = 0; - gUnknown_020322A0->unk_E0 = 348; + gUnknown_020322A0->bg1hofs = 0; + gUnknown_020322A0->bg1vofs = 348; SetGpuReg(REG_OFFSET_BG1VOFS, 348); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | @@ -3460,8 +3511,8 @@ void sub_807B62C(u8 a0) DISPCNT_OBJ_ON); break; case 2: - gUnknown_020322A0->unk_E0 = 0; - gUnknown_020322A0->unk_E2 = 0; + gUnknown_020322A0->bg1vofs = 0; + gUnknown_020322A0->bg1hofs = 0; if (!gUnknown_020322A0->unk_FA) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | @@ -3485,7 +3536,7 @@ void sub_807B62C(u8 a0) 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; + gUnknown_020322A0->bg2vofs = 80; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | @@ -3520,8 +3571,8 @@ void sub_807B62C(u8 a0) } break; case 5: - gUnknown_020322A0->unk_E0 = 0; - gUnknown_020322A0->unk_E2 = 0; + gUnknown_020322A0->bg1vofs = 0; + gUnknown_020322A0->bg1hofs = 0; break; case 6: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | @@ -3553,8 +3604,8 @@ void sub_807B62C(u8 a0) } break; case 7: - gUnknown_020322A0->unk_E4 = 0; - gUnknown_020322A0->unk_E6 = 0; + gUnknown_020322A0->bg2vofs = 0; + gUnknown_020322A0->bg2hofs = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(1) | @@ -3563,7 +3614,551 @@ void sub_807B62C(u8 a0) 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); + DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); break; } } + +void sub_807BA94(void) +{ + LoadSpriteSheet(&gUnknown_08338D70); + LoadSpriteSheet(&gUnknown_08338DC0); + LoadSpriteSheet(&gUnknown_08338DF4); + LoadSpriteSheet(&gUnknown_08338E6C); + LoadSpritePalette(&gUnknown_08338D78); + LoadSpritePalette(&gUnknown_08338D80); +} + +void sub_807BAD8(void) +{ + /*Sets the variable strings printed on the + *actual trading screen. For use in strings + *like "[Pokemon] will be sent to [Trainer]." + */ + u8 mpId; + u8 name[20]; + const struct InGameTrade *ingameTrade; + + if (gUnknown_020322A0->isLinkTrade) + { + mpId = GetMultiplayerId(); + StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); + GetMonData(&gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE], MON_DATA_NICKNAME, name); + StringCopy10(gStringVar3, name); + GetMonData(&gPlayerParty[gUnknown_02032298[0]], MON_DATA_NICKNAME, name); + StringCopy10(gStringVar2, name); + } + else + { + ingameTrade = &gIngameTrades[gSpecialVar_0x8004]; + StringCopy(gStringVar1, ingameTrade->otName); + StringCopy10(gStringVar3, ingameTrade->name); + GetMonData(&gPlayerParty[gSpecialVar_0x8005], MON_DATA_NICKNAME, name); + StringCopy10(gStringVar2, name); + } +} + +u8 sub_807BBC8(void) +{ + if (gUnknown_020322A0->unk_FA) + { + return sub_807BBEC(); + } + else + { + return sub_807CFC8(); + } +} + +bool8 sub_807BBEC(void) +{ + u16 evoTarget; + + switch (gUnknown_020322A0->unk_94) + { + case 0: + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = -180; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[0]].y_offset; + gUnknown_020322A0->unk_94++; + gUnknown_020322A0->unk_F4 = GetCurrentMapMusic(); + PlayNewMapMusic(MUS_SHINKA); + break; + case 1: + if (gUnknown_020322A0->bg2hofs > 0) + { + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3; + gUnknown_020322A0->bg2hofs -= 3; + } + else + { + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0; + gUnknown_020322A0->bg2hofs = 0; + gUnknown_020322A0->unk_94 = 10; + } + break; + case 10: + StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); + sub_807F1A8(0, gStringVar4, 0); + + if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG) + { + PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0); + } + + gUnknown_020322A0->unk_94 = 11; + gUnknown_020322A0->unk_64 = 0; + break; + case 11: + if (++gUnknown_020322A0->unk_64 == 80) + { + gUnknown_020322A0->unk_D2 = sub_807671C(gUnknown_020322A0->pokePicSpriteIdxs[0], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + gUnknown_020322A0->unk_94++; + StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); + sub_807F1A8(0, gStringVar4, 0); + } + break; + case 12: + if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy) + { + gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[gUnknown_020322A0->unk_D2]); + gUnknown_020322A0->unk_94++; + } + break; + /*case 13: + // The game waits here for the sprite to finish its animation sequence. + break;*/ + case 14: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_020322A0->unk_94 = 20; + break; + + case 20: + if (!gPaletteFade.active) + { + sub_807B62C(4); + FillWindowPixelBuffer(0, 0xFF); + CopyWindowToVram(0, 3); + gUnknown_020322A0->unk_94++; + } + break; + case 21: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + gUnknown_020322A0->unk_94++; + break; + case 22: + if (!gPaletteFade.active) + { + gUnknown_020322A0->unk_94 = 23; + } + break; + case 23: + if (gUnknown_020322A0->unk_EA > 0x100) + { + gUnknown_020322A0->unk_EA -= 0x34; + } + else + { + sub_807B62C(1); + gUnknown_020322A0->unk_EA = 0x80; + gUnknown_020322A0->unk_94++; + gUnknown_020322A0->unk_64 = 0; + } + gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + break; + case 24: + if (++gUnknown_020322A0->unk_64 > 20) + { + sub_807AB28(); + gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + gUnknown_020322A0->unk_94++; + } + break; + case 25: + if (gSprites[gUnknown_020322A0->unk_91].animEnded) + { + DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | + BLDCNT_TGT2_BG1 | + BLDCNT_TGT2_BG2); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 4)); + gUnknown_020322A0->unk_94++; + } + break; + case 26: + if (--gUnknown_020322A0->bg1vofs == 316) + { + gUnknown_020322A0->unk_94++; + } + if (gUnknown_020322A0->bg1vofs == 328) + { + gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + } + break; + case 27: + gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); + gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); + StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); + gUnknown_020322A0->unk_94++; + break; + case 28: + if ((gUnknown_020322A0->bg1vofs -= 2) == 166) + { + gUnknown_020322A0->unk_94 = 200; + } + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + break; + case 200: + gSprites[gUnknown_020322A0->unk_90].pos1.y -= 2; + gSprites[gUnknown_020322A0->unk_91].pos1.y -= 2; + if (gSprites[gUnknown_020322A0->unk_90].pos1.y < -8) + { + gUnknown_020322A0->unk_94 = 29; + } + break; + case 29: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + gUnknown_020322A0->unk_94 = 30; + break; + case 30: + if (!gPaletteFade.active) + { + DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); + DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + sub_807B62C(2); + gUnknown_020322A0->unk_94++; + } + break; + case 31: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + gUnknown_020322A0->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + gUnknown_020322A0->unk_94++; + break; + case 32: + if (!gPaletteFade.active) + { + PlaySE(SE_TK_WARPOUT); + gUnknown_020322A0->unk_94++; + } + gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; + gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + break; + case 33: + gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; + gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -90) + { + gSprites[gUnknown_020322A0->unk_90].data[1] = 1; + gSprites[gUnknown_020322A0->unk_91].data[1] = 1; + gUnknown_020322A0->unk_94++; + } + break; + case 34: + BlendPalettes(0x1, 16, RGB_WHITEALPHA); + gUnknown_020322A0->unk_94++; + break; + case 35: + BlendPalettes(0x1, 0, RGB_WHITEALPHA); + gUnknown_020322A0->unk_94++; + break; + case 36: + BlendPalettes(0x1, 16, RGB_WHITEALPHA); + gUnknown_020322A0->unk_94++; + break; + case 37: + if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0])) + { + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); + } + else + { + StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); + } + StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.x = 60; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 180; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.y = 192; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = -32; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = FALSE; + gUnknown_020322A0->unk_94++; + break; + case 38: + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y -= 3; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y += 3; + if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y >= -163) + { + PlaySE(SE_TK_WARPIN); + } + if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222) + { + gSprites[gUnknown_020322A0->unk_90].data[1] = 0; + gSprites[gUnknown_020322A0->unk_91].data[1] = 0; + gUnknown_020322A0->unk_94++; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = TRUE; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = TRUE; + BlendPalettes(0x1, 0, RGB_WHITEALPHA); + } + break; + case 39: + gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; + gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -222) + { + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + gUnknown_020322A0->unk_94++; + DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); + DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + } + break; + case 40: + if (!gPaletteFade.active) + { + gUnknown_020322A0->unk_94++; + sub_807B62C(1); + gUnknown_020322A0->bg1vofs = 166; + gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); + gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); + StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); + } + break; + case 41: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + gUnknown_020322A0->unk_94++; + break; + case 42: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + gUnknown_020322A0->unk_94++; + } + break; + case 43: + gSprites[gUnknown_020322A0->unk_90].pos2.y += 3; + gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + if (gSprites[gUnknown_020322A0->unk_90].pos2.y + gSprites[gUnknown_020322A0->unk_90].pos1.y == 64) + { + gUnknown_020322A0->unk_94++; + } + break; + case 44: + if ((gUnknown_020322A0->bg1vofs += 2) > 316) + { + gUnknown_020322A0->bg1vofs = 316; + gUnknown_020322A0->unk_94++; + } + break; + case 45: + DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); + DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + gUnknown_020322A0->unk_94++; + gUnknown_020322A0->unk_64 = 0; + break; + case 46: + if (++gUnknown_020322A0->unk_64 == 10) + { + gUnknown_020322A0->unk_94++; + } + break; + case 47: + if (++gUnknown_020322A0->bg1vofs > 348) + { + gUnknown_020322A0->bg1vofs = 348; + gUnknown_020322A0->unk_94++; + } + if (gUnknown_020322A0->bg1vofs == 328 && gUnknown_020322A0->unk_FA) + { + gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + gSprites[gUnknown_020322A0->unk_92].callback = sub_807AAE0; + } + break; + case 48: + gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + gUnknown_020322A0->unk_94 = 50; + break; + case 50: + if (gSprites[gUnknown_020322A0->unk_91].animEnded) + { + DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + sub_807B62C(6); + gUnknown_020322A0->unk_94++; + PlaySE(SE_W028); + } + break; + case 51: + if (gUnknown_020322A0->unk_EA < 0x400) + { + gUnknown_020322A0->unk_EA += 0x34; + } + else + { + gUnknown_020322A0->unk_EA = 0x400; + gUnknown_020322A0->unk_94++; + } + gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + break; + case 52: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_020322A0->unk_94 = 60; + break; + + case 60: + if (!gPaletteFade.active) + { + sub_807B62C(5); + sub_807B62C(7); + gPaletteFade.bufferTransferDisabled = TRUE; + gUnknown_020322A0->unk_94++; + } + break; + case 61: + gPaletteFade.bufferTransferDisabled = FALSE; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gUnknown_020322A0->unk_94++; + break; + case 62: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + gUnknown_020322A0->unk_94++; + } + break; + case 63: + gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); + gSprites[gUnknown_020322A0->unk_D3].data[3] = 74; + gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E6AC; + StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_D3], 1); + StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->unk_D3], 2); + BlendPalettes(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); + gUnknown_020322A0->unk_94++; + gUnknown_020322A0->unk_64 = 0; + break; + case 64: + BeginNormalPaletteFade(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + gUnknown_020322A0->unk_94++; + break; + case 65: + if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy) + { + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[gUnknown_020322A0->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], gUnknown_020322A0->tradeSpecies[1], gUnknown_020322A0->unk_68[1]); + gUnknown_020322A0->unk_94++; + } + break; + case 66: + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 120; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[1]].y_offset + 60; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.x = 0; + gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y = 0; + StartSpriteAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); + CreatePokeballSpriteToReleaseMon(gUnknown_020322A0->pokePicSpriteIdxs[1], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, gUnknown_020322A0->tradeSpecies[1]); + FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->unk_D3]); + DestroySprite(&gSprites[gUnknown_020322A0->unk_D3]); + gUnknown_020322A0->unk_94++; + break; + case 67: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG0_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + StringExpandPlaceholders(gStringVar4, gText_XSentOverY); + sub_807F1A8(0, gStringVar4, 0); + gUnknown_020322A0->unk_94 = 167; + gUnknown_020322A0->unk_64 = 0; + break; + // 167 and 267 are extra cases added in for animations + case 167: + if (++gUnknown_020322A0->unk_64 > 60) + { + gUnknown_020322A0->unk_94 = 267; + gUnknown_020322A0->unk_64 = 0; + } + break; + case 267: + if (IsCryFinished()) + { + gUnknown_020322A0->unk_94 = 68; + } + break; + case 68: + if (++gUnknown_020322A0->unk_64 == 10) + { + PlayFanfare(MUS_FANFA5); + } + if (gUnknown_020322A0->unk_64 == 250) + { + gUnknown_020322A0->unk_94++; + StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); + sub_807F1A8(0, gStringVar4, 0); + gUnknown_020322A0->unk_64 = 0; + } + break; + case 69: + if (++gUnknown_020322A0->unk_64 == 60) + { + gUnknown_020322A0->unk_94++; + } + break; + case 70: + sub_807F14C(); + gUnknown_020322A0->unk_94++; + break; + case 71: + if (gUnknown_020322A0->isLinkTrade) + { + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { + gUnknown_020322A0->unk_94++; + } + break; + case 72: // Only if in-game trade + sub_807B4D0(gSpecialVar_0x8005, 0); + gCB2_AfterEvolution = sub_807B60C; + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE); + if (evoTarget != SPECIES_NONE) + { + TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); + } + gUnknown_020322A0->unk_94++; + break; + case 73: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_020322A0->unk_94++; + break; + case 74: + if (!gPaletteFade.active) + { + PlayNewMapMusic(gUnknown_020322A0->unk_F4); + if (gUnknown_020322A0) + { + FreeAllWindowBuffers(); + Free(GetBgTilemapBuffer(3)); + Free(GetBgTilemapBuffer(1)); + Free(GetBgTilemapBuffer(0)); + FreeMonSpritesGfx(); + FREE_AND_SET_NULL(gUnknown_020322A0); + } + SetMainCallback2(CB2_ReturnToField); + sub_807E784(); + } + break; + } + return FALSE; +}