diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 489eb2d15..ffbd7c58d 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -6,2327 +6,6 @@ .text - - - thumb_func_start sub_819D12C -sub_819D12C: @ 819D12C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - ldr r1, =gTasks - lsls r0, 2 - ldr r2, [sp] - adds r0, r2 - lsls r0, 3 - adds r4, r0, r1 - movs r2, 0x8 - ldrsh r3, [r4, r2] - cmp r3, 0 - beq _0819D15C - cmp r3, 0x1 - beq _0819D168 - b _0819D310 - .pool -_0819D15C: - strh r3, [r4, 0xA] - strh r3, [r4, 0xC] - strh r3, [r4, 0xE] - movs r0, 0x1 - strh r0, [r4, 0x8] - b _0819D310 -_0819D168: - movs r3, 0 - str r3, [sp, 0x4] - movs r1, 0x2 - str r0, [sp, 0x8] - ldr r0, =gTasks - str r0, [sp, 0xC] -_0819D174: - lsls r0, r1, 24 - asrs r4, r0, 24 - mov r9, r0 - cmp r4, 0x2 - beq _0819D1F2 - ldr r2, =gSprites - ldr r3, =sFactorySwapScreen - ldr r0, [r3] - adds r0, 0x5 - mov r8, r0 - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r6, r0, r2 - ldrh r1, [r6, 0x20] - mov r12, r1 - mov r7, r12 - ldr r1, [sp, 0x4] - subs r0, r1, r7 - lsls r0, 24 - lsrs r5, r0, 24 - mov r10, r2 - cmp r5, 0x10 - beq _0819D1BE - adds r0, r4, 0x2 - lsls r0, 1 - ldr r2, [sp, 0x8] - adds r0, r2 - ldr r1, =gTasks - adds r1, 0x8 - adds r0, r1 - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r0, 0x1 - bne _0819D1D8 -_0819D1BE: - lsls r0, r7, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - mov r0, r12 - adds r0, 0xA - strh r0, [r6, 0x20] - b _0819D210 - .pool -_0819D1D8: - cmp r5, 0x10 - bls _0819D210 - adds r0, r4, 0x1 - add r0, r8 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r10 - ldrh r0, [r0, 0x20] - subs r0, 0x30 - strh r0, [r6, 0x20] - b _0819D210 -_0819D1F2: - ldr r3, =gSprites - ldr r4, =sFactorySwapScreen - ldr r0, [r4] - ldrb r1, [r0, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r2, [r0, 0x20] - lsls r1, r2, 24 - lsrs r1, 24 - str r1, [sp, 0x4] - adds r2, 0xA - strh r2, [r0, 0x20] - mov r10, r3 -_0819D210: - mov r0, r9 - asrs r2, r0, 24 - adds r0, r2, 0x1 - lsls r0, 1 - ldr r1, [sp, 0x8] - adds r0, r1 - ldr r1, =gTasks - adds r1, 0x8 - adds r0, r1 - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r0, 0x1 - bne _0819D26A - ldr r1, =sFactorySwapScreen - ldr r0, [r1] - adds r0, 0x5 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - mov r3, r10 - adds r1, r0, r3 - movs r0, 0x20 - ldrsh r3, [r1, r0] - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 4 - adds r0, 0x48 - cmp r3, r0 - ble _0819D260 - strh r0, [r1, 0x20] - movs r7, 0x1 - b _0819D26C - .pool -_0819D260: - movs r7, 0 - cmp r3, r0 - bne _0819D26C - movs r7, 0x1 - b _0819D26C -_0819D26A: - movs r7, 0 -_0819D26C: - mov r6, r10 - ldr r5, =sFactorySwapScreen - ldr r2, [r5] - mov r1, r9 - asrs r4, r1, 24 - adds r0, r2, 0x5 - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r6 - movs r3, 0x20 - ldrsh r0, [r1, r3] - subs r0, 0x10 - cmp r0, 0xF0 - ble _0819D2F8 - ldrh r0, [r1, 0x20] - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - ldr r0, =0x0000fff0 - strh r0, [r1, 0x20] - ldrb r0, [r2, 0x14] - cmp r0, 0x1 - bne _0819D2C0 - movs r0, 0x65 - bl IndexOfSpritePaletteTag - ldr r1, [r5] - adds r1, 0x5 - adds r1, r4 - ldrb r1, [r1] - lsls r2, r1, 4 - adds r2, r1 - lsls r2, 2 - adds r2, r6 - b _0819D2D8 - .pool -_0819D2C0: - movs r0, 0x64 - bl IndexOfSpritePaletteTag - ldr r2, =sFactorySwapScreen - ldr r1, [r2] - adds r1, 0x5 - adds r1, r4 - ldrb r1, [r1] - lsls r2, r1, 4 - adds r2, r1 - lsls r2, 2 - add r2, r10 -_0819D2D8: - lsls r0, 4 - ldrb r3, [r2, 0x5] - movs r1, 0xF - ands r1, r3 - orrs r1, r0 - strb r1, [r2, 0x5] - mov r3, r9 - asrs r0, r3, 23 - adds r0, 0x2 - ldr r1, [sp, 0x8] - adds r0, r1 - ldr r2, [sp, 0xC] - adds r2, 0x8 - adds r0, r2 - movs r1, 0x1 - strh r1, [r0] -_0819D2F8: - movs r0, 0xFF - lsls r0, 24 - add r0, r9 - lsrs r1, r0, 24 - cmp r0, 0 - blt _0819D306 - b _0819D174 -_0819D306: - cmp r7, 0x1 - bne _0819D310 - ldr r0, [sp] - bl DestroyTask -_0819D310: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819D12C - - thumb_func_start sub_819D324 -sub_819D324: @ 819D324 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r7, r0, 24 - movs r0, 0 - mov r8, r0 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r2, r0, r1 - ldrb r4, [r2, 0xE] - movs r0, 0xC - ldrsh r5, [r2, r0] - mov r10, r1 - cmp r5, 0x1 - bne _0819D352 - lsls r0, r4, 24 - negs r0, r0 - lsrs r4, r0, 24 -_0819D352: - movs r1, 0x8 - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _0819D368 - cmp r0, 0x1 - bne _0819D360 - b _0819D480 -_0819D360: - b _0819D570 - .pool -_0819D368: - ldr r3, =gSprites - ldr r2, =sFactorySwapScreen - ldr r0, [r2] - ldrb r1, [r0, 0x8] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r0, [r0, 0x20] - cmp r5, 0 - bne _0819D39C - lsls r0, 16 - asrs r0, 16 - lsls r2, r4, 24 - asrs r1, r2, 24 - adds r0, r1 - movs r1, 0x1 - cmp r0, 0xEF - ble _0819D3B2 - movs r1, 0 - movs r0, 0xF0 - b _0819D3B0 - .pool -_0819D39C: - lsls r0, 16 - asrs r0, 16 - lsls r2, r4, 24 - asrs r1, r2, 24 - adds r0, r1 - movs r1, 0x1 - cmp r0, 0xA0 - bgt _0819D3B2 - movs r1, 0 - movs r0, 0xA0 -_0819D3B0: - mov r8, r0 -_0819D3B2: - cmp r1, 0x1 - bne _0819D3FC - movs r3, 0 - ldr r7, =gSprites - ldr r6, =sFactorySwapScreen - asrs r5, r2, 24 -_0819D3BE: - movs r4, 0 - adds r2, r3, 0x1 -_0819D3C2: - ldr r1, [r6] - lsls r0, r4, 1 - adds r0, r4 - adds r0, r3, r0 - adds r1, 0x8 - adds r1, r0 - ldrb r1, [r1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, r5 - strh r1, [r0, 0x20] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _0819D3C2 - lsls r0, r2, 24 - lsrs r3, r0, 24 - cmp r3, 0x2 - bls _0819D3BE - b _0819D570 - .pool -_0819D3FC: - movs r4, 0 - lsls r1, r7, 2 - mov r12, r1 - mov r6, r8 - adds r6, 0x10 - movs r0, 0x30 - add r0, r8 - mov r9, r0 - ldr r5, =gSprites -_0819D40E: - ldr r1, =sFactorySwapScreen - ldr r2, [r1] - lsls r3, r4, 1 - adds r3, r4 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - mov r1, r8 - strh r1, [r0, 0x20] - adds r0, r2, 0 - adds r0, 0x9 - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - strh r6, [r0, 0x20] - adds r2, 0xA - adds r2, r3 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - mov r1, r9 - strh r1, [r0, 0x20] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _0819D40E - mov r1, r12 - adds r0, r1, r7 - lsls r0, 3 - add r0, r10 - ldrb r1, [r0, 0xA] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - add r0, r10 - movs r1, 0x1 - strh r1, [r0, 0xE] - adds r0, r7, 0 - bl DestroyTask - b _0819D570 - .pool -_0819D480: - ldr r2, =gSprites - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r1, [r0, 0xE] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r0, [r0, 0x20] - cmp r5, 0 - bne _0819D4B4 - lsls r0, 16 - asrs r0, 16 - lsls r2, r4, 24 - asrs r1, r2, 24 - adds r0, r1 - movs r1, 0x1 - cmp r0, 0xEF - ble _0819D4CA - movs r1, 0 - movs r0, 0xF0 - b _0819D4C8 - .pool -_0819D4B4: - lsls r0, 16 - asrs r0, 16 - lsls r2, r4, 24 - asrs r1, r2, 24 - adds r0, r1 - movs r1, 0x1 - cmp r0, 0xC0 - bgt _0819D4CA - movs r1, 0 - movs r0, 0xC0 -_0819D4C8: - mov r8, r0 -_0819D4CA: - cmp r1, 0x1 - bne _0819D510 - movs r3, 0 - ldr r7, =gSprites - ldr r6, =sFactorySwapScreen - asrs r5, r2, 24 -_0819D4D6: - movs r4, 0 - adds r2, r3, 0x1 -_0819D4DA: - ldr r0, [r6] - lsls r1, r4, 1 - adds r1, r3, r1 - adds r0, 0xE - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrh r1, [r0, 0x20] - adds r1, r5 - strh r1, [r0, 0x20] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _0819D4DA - lsls r0, r2, 24 - lsrs r3, r0, 24 - cmp r3, 0x1 - bls _0819D4D6 - b _0819D570 - .pool -_0819D510: - movs r4, 0 - lsls r1, r7, 2 - mov r12, r1 - mov r6, r8 - adds r6, 0x10 - ldr r5, =gSprites - ldr r0, =sFactorySwapScreen - mov r9, r0 -_0819D520: - mov r1, r9 - ldr r2, [r1] - lsls r3, r4, 1 - adds r0, r2, 0 - adds r0, 0xE - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - mov r1, r8 - strh r1, [r0, 0x20] - adds r2, 0xF - adds r2, r3 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - strh r6, [r0, 0x20] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _0819D520 - mov r1, r12 - adds r0, r1, r7 - lsls r0, 3 - add r0, r10 - ldrb r1, [r0, 0xA] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - add r0, r10 - movs r1, 0x1 - strh r1, [r0, 0x10] - adds r0, r7, 0 - bl DestroyTask -_0819D570: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819D324 - - thumb_func_start sub_819D588 -sub_819D588: @ 819D588 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - mov r8, r1 - cmp r0, 0x5 - bls _0819D5AA - b _0819D762 -_0819D5AA: - lsls r0, 2 - ldr r1, =_0819D5BC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0819D5BC: - .4byte _0819D5D4 - .4byte _0819D5F0 - .4byte _0819D60C - .4byte _0819D63C - .4byte _0819D6F0 - .4byte _0819D73A -_0819D5D4: - ldr r0, =gUnknown_08610918 - movs r1, 0xE0 - movs r2, 0xA - bl LoadPalette - bl sub_819ED34 - movs r0, 0x5 - bl PutWindowTilemap - b _0819D622 - .pool -_0819D5F0: - movs r0, 0x3 - bl sub_819EA64 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _0819D762 - .pool -_0819D60C: - movs r0, 0x80 - lsls r0, 7 - ldr r1, =gUnknown_0860F13C - adds r1, 0x4A - ldrh r1, [r1] - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade -_0819D622: - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _0819D762 - .pool -_0819D63C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - beq _0819D64E - b _0819D762 -_0819D64E: - movs r0, 0x5 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x5 - movs r1, 0x2 - bl CopyWindowToVram - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x14] - cmp r0, 0x1 - bne _0819D6B0 - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r2, r5, 2 - adds r2, r5 - lsls r2, 3 - adds r2, r1 - strh r6, [r2, 0xE] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0xA] - strh r6, [r0, 0x8] - strh r6, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - movs r0, 0x5 - strh r0, [r2, 0xC] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _0819D762 - .pool -_0819D6B0: - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - ldr r3, =gTasks - lsls r2, r5, 2 - adds r2, r5 - lsls r2, 3 - adds r2, r3 - movs r1, 0x1 - strh r1, [r2, 0xE] - strh r6, [r2, 0x10] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r3 - strh r5, [r0, 0xA] - strh r1, [r0, 0x8] - strh r6, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - ldrh r0, [r2, 0x8] - adds r0, 0x2 - strh r0, [r2, 0x8] - b _0819D762 - .pool -_0819D6F0: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - mov r1, r8 - adds r6, r0, r1 - ldrh r0, [r6, 0xC] - movs r2, 0xC - ldrsh r7, [r6, r2] - cmp r7, 0 - bne _0819D734 - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - strh r7, [r6, 0x10] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - strh r5, [r0, 0xA] - movs r1, 0x1 - strh r1, [r0, 0x8] - strh r7, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - b _0819D762 - .pool -_0819D734: - subs r0, 0x1 - strh r0, [r6, 0xC] - b _0819D762 -_0819D73A: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - mov r1, r8 - adds r2, r0, r1 - movs r1, 0xE - ldrsh r0, [r2, r1] - cmp r0, 0x1 - bne _0819D762 - movs r1, 0x10 - ldrsh r0, [r2, r1] - cmp r0, 0x1 - bne _0819D762 - ldrh r0, [r2, 0x12] - strh r0, [r2, 0x8] - ldrh r0, [r2, 0x14] - ldrh r1, [r2, 0x16] - lsls r0, 16 - orrs r0, r1 - str r0, [r2] -_0819D762: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819D588 - - thumb_func_start sub_819D770 -sub_819D770: @ 819D770 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =sFactorySwapScreen - ldr r0, [r1] - adds r0, 0x30 - ldrb r0, [r0] - adds r3, r1, 0 - cmp r0, 0x1 - bne _0819D78C - b _0819D9D8 -_0819D78C: - ldr r0, =gTasks - lsls r2, r6, 2 - adds r1, r2, r6 - lsls r1, 3 - adds r1, r0 - movs r4, 0x8 - ldrsh r1, [r1, r4] - mov r8, r0 - adds r5, r2, 0 - cmp r1, 0x8 - bls _0819D7A4 - b _0819D9D8 -_0819D7A4: - lsls r0, r1, 2 - ldr r1, =_0819D7BC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0819D7BC: - .4byte _0819D7E0 - .4byte _0819D868 - .4byte _0819D8AE - .4byte _0819D8F4 - .4byte _0819D910 - .4byte _0819D928 - .4byte _0819D936 - .4byte _0819D948 - .4byte _0819D9B0 -_0819D7E0: - ldr r0, [r3] - ldrb r7, [r0, 0x14] - cmp r7, 0x1 - bne _0819D828 - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - ldr r3, =gTasks - adds r2, r5, r6 - lsls r2, 3 - adds r2, r3 - movs r1, 0 - strh r1, [r2, 0xE] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r3 - strh r6, [r0, 0xA] - strh r1, [r0, 0x8] - strh r7, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - movs r0, 0xA - strh r0, [r2, 0xC] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _0819D9D8 - .pool -_0819D828: - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - ldr r3, =gTasks - adds r2, r5, r6 - lsls r2, 3 - adds r2, r3 - movs r0, 0 - movs r1, 0x1 - strh r1, [r2, 0xE] - strh r0, [r2, 0x10] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r3 - strh r6, [r0, 0xA] - strh r1, [r0, 0x8] - strh r1, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - ldrh r0, [r2, 0x8] - adds r0, 0x2 - strh r0, [r2, 0x8] - b _0819D9D8 - .pool -_0819D868: - adds r0, r5, r6 - lsls r0, 3 - mov r1, r8 - adds r5, r0, r1 - ldrh r0, [r5, 0xC] - movs r2, 0xC - ldrsh r7, [r5, r2] - cmp r7, 0 - bne _0819D8A8 - ldr r0, =sub_819D324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - strh r7, [r5, 0x10] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - strh r6, [r0, 0xA] - movs r1, 0x1 - strh r1, [r0, 0x8] - strh r1, [r0, 0xC] - movs r1, 0x6 - strh r1, [r0, 0xE] - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - b _0819D9D8 - .pool -_0819D8A8: - subs r0, 0x1 - strh r0, [r5, 0xC] - b _0819D9D8 -_0819D8AE: - adds r0, r5, r6 - lsls r0, 3 - mov r1, r8 - adds r4, r0, r1 - movs r2, 0xE - ldrsh r0, [r4, r2] - cmp r0, 0x1 - beq _0819D8C0 - b _0819D9D8 -_0819D8C0: - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _0819D8CA - b _0819D9D8 -_0819D8CA: - ldr r1, =gPlttBufferFaded - ldr r0, =gUnknown_0860F13C - adds r0, 0x4A - ldrh r0, [r0] - movs r2, 0xE2 - lsls r2, 1 - adds r1, r2 - strh r0, [r1] - bl sub_819ED34 - movs r0, 0x5 - bl PutWindowTilemap - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0819D9D8 - .pool -_0819D8F4: - movs r0, 0x80 - lsls r0, 7 - ldr r1, =gUnknown_0860F13C - adds r1, 0x4A - ldrh r1, [r1] - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _0819D990 - .pool -_0819D910: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0819D9D8 - movs r0, 0 - bl sub_819EDBC - b _0819D990 - .pool -_0819D928: - movs r0, 0x1 - bl sub_819EDBC - movs r0, 0x3 - bl PutWindowTilemap - b _0819D990 -_0819D936: - movs r0, 0x5 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x5 - movs r1, 0x2 - bl CopyWindowToVram - b _0819D990 -_0819D948: - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x14] - cmp r0, 0 - bne _0819D964 - ldr r0, =gText_SelectPkmnToSwap - bl Swap_PrintOnYesNoQuestionWindow - b _0819D96A - .pool -_0819D964: - ldr r0, =gText_SelectPkmnToAccept - bl Swap_PrintOnYesNoQuestionWindow -_0819D96A: - ldr r0, =sFactorySwapScreen - ldr r1, [r0] - ldrb r0, [r1, 0x3] - cmp r0, 0x2 - bhi _0819D98C - ldr r2, =gSprites - ldrb r1, [r1, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] -_0819D98C: - bl Swap_PrintMonCategory -_0819D990: - ldr r0, =gTasks - adds r1, r5, r6 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _0819D9D8 - .pool -_0819D9B0: - bl sub_819EEF0 - bl sub_819EADC - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - adds r0, 0x22 - movs r1, 0x1 - strb r1, [r0] - ldr r1, =gTasks - adds r0, r5, r6 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x12] - strh r1, [r0, 0x8] - ldrh r1, [r0, 0x14] - ldrh r2, [r0, 0x16] - lsls r1, 16 - orrs r1, r2 - str r1, [r0] -_0819D9D8: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819D770 - - thumb_func_start sub_819D9EC -sub_819D9EC: @ 819D9EC - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - adds r0, 0x30 - ldrb r0, [r0] - cmp r0, 0x1 - bne _0819DA00 - b _0819DBCA -_0819DA00: - ldr r0, =gTasks - lsls r2, r6, 2 - adds r1, r2, r6 - lsls r1, 3 - adds r1, r0 - movs r3, 0x8 - ldrsh r1, [r1, r3] - adds r3, r0, 0 - adds r7, r2, 0 - cmp r1, 0x4 - bls _0819DA18 - b _0819DBCA -_0819DA18: - lsls r0, r1, 2 - ldr r1, =_0819DA30 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0819DA30: - .4byte _0819DA44 - .4byte _0819DA58 - .4byte _0819DA8C - .4byte _0819DABC - .4byte _0819DBB0 -_0819DA44: - bl sub_819EEF0 - ldr r0, =gTasks - adds r1, r7, r6 - lsls r1, 3 - adds r1, r0 - b _0819DB96 - .pool -_0819DA58: - bl sub_819EADC - ldr r2, =gSprites - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, =gTasks - adds r1, r7, r6 - lsls r1, 3 - adds r1, r0 - b _0819DB96 - .pool -_0819DA8C: - ldr r0, =sub_819D12C - movs r1, 0 - bl CreateTask - ldr r2, =gTasks - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldr r1, =sub_819D064 - str r1, [r0] - b _0819DB90 - .pool -_0819DABC: - ldr r0, =sub_819D12C - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _0819DACA - b _0819DBCA -_0819DACA: - ldr r2, =gTasks - ldr r4, =sFactorySwapScreen - ldr r0, [r4] - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0x10 - ldrsh r0, [r0, r1] - cmp r0, 0x1 - bne _0819DBCA - bl sub_819EAC0 - ldr r0, [r4] - ldrb r0, [r0, 0x14] - cmp r0, 0 - bne _0819DB04 - movs r0, 0x1 - bl sub_819F048 - b _0819DB32 - .pool -_0819DB04: - movs r0, 0 - bl sub_819F048 - movs r2, 0 - ldr r5, =gSprites - movs r3, 0x4 -_0819DB10: - ldr r0, [r4] - adds r0, 0xB - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r3 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x2 - bls _0819DB10 -_0819DB32: - ldr r5, =gSprites - ldr r4, =sFactorySwapScreen - ldr r3, [r4] - ldrb r0, [r3, 0x4] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - adds r0, r3, 0x5 - ldrb r2, [r3, 0x3] - adds r0, r2 - ldrb r2, [r0] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r5 - ldrh r0, [r0, 0x20] - movs r5, 0 - strh r0, [r1, 0x20] - ldr r2, =gTasks - adds r0, r3, 0 - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldr r1, =sub_819CF54 - str r1, [r0] - adds r3, 0x27 - strb r5, [r3] - ldr r0, [r4] - adds r0, 0x28 - movs r1, 0x6 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0x26 - strb r5, [r0] - ldr r0, [r4] - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0x1 - strh r1, [r0, 0x8] -_0819DB90: - adds r1, r7, r6 - lsls r1, 3 - adds r1, r2 -_0819DB96: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _0819DBCA - .pool -_0819DBB0: - adds r0, r7, r6 - lsls r0, 3 - adds r0, r3 - movs r1, 0 - strh r1, [r0, 0x8] - ldr r2, =Task_HandleSwapScreenChooseMons - lsrs r1, r2, 16 - strh r1, [r0, 0x14] - strh r2, [r0, 0x16] - movs r1, 0x1 - strh r1, [r0, 0x12] - ldr r1, =sub_819D770 - str r1, [r0] -_0819DBCA: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819D9EC - - thumb_func_start sub_819DBD8 -sub_819DBD8: @ 819DBD8 - push {r4,r5,lr} - ldr r5, =sFactorySwapScreen - ldr r4, [r5] - cmp r4, 0 - bne _0819DBF6 - movs r0, 0x34 - bl AllocZeroed - str r0, [r5] - strb r4, [r0, 0x3] - ldr r0, [r5] - adds r0, 0x30 - strb r4, [r0] - ldr r0, [r5] - strb r4, [r0, 0x15] -_0819DBF6: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819DBD8 - - thumb_func_start sub_819DC00 -sub_819DC00: @ 819DC00 - push {lr} - ldr r0, =sFactorySwapScreen - movs r1, 0 - str r1, [r0] - ldr r0, =sub_819DC1C - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_819DC00 - - thumb_func_start sub_819DC1C -sub_819DC1C: @ 819DC1C - push {r4-r6,lr} - sub sp, 0xC - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0xF - bls _0819DC32 - b _0819E0AA -_0819DC32: - lsls r0, 2 - ldr r1, =_0819DC44 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0819DC44: - .4byte _0819DC84 - .4byte _0819DCD4 - .4byte _0819DDA8 - .4byte _0819DE68 - .4byte _0819DE94 - .4byte _0819DECC - .4byte _0819DEEC - .4byte _0819DF10 - .4byte _0819DF30 - .4byte _0819DF3C - .4byte _0819DF64 - .4byte _0819DF70 - .4byte _0819DF78 - .4byte _0819DF8C - .4byte _0819DFA4 - .4byte _0819E01C -_0819DC84: - movs r0, 0 - bl SetHBlankCallback - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - str r0, [sp, 0x8] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - add r0, sp, 0x8 - bl CpuSet - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_086108B8 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r0, =gUnknown_086108C8 - bl InitWindows - bl DeactivateAllTextPrinters - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DCD4: - ldr r5, =gUnknown_0203CE40 - movs r4, 0x88 - lsls r4, 3 - adds r0, r4, 0 - bl Alloc - str r0, [r5] - ldr r5, =gUnknown_0203CE44 - adds r0, r4, 0 - bl AllocZeroed - str r0, [r5] - ldr r5, =gUnknown_0203CE48 - movs r4, 0x80 - lsls r4, 4 - adds r0, r4, 0 - bl Alloc - str r0, [r5] - ldr r5, =gUnknown_0203CE4C - adds r0, r4, 0 - bl AllocZeroed - str r0, [r5] - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x42 - movs r1, 0 - bl SetGpuReg - movs r0, 0x46 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - b _0819E006 - .pool -_0819DDA8: - bl ResetPaletteFade - bl ResetSpriteData - bl ResetTasks - bl FreeAllSpritePalettes - bl ResetAllPicSprites - ldr r0, =gFrontierFactorySelectMenu_Gfx - ldr r5, =gUnknown_0203CE40 - ldr r1, [r5] - movs r2, 0x88 - lsls r2, 2 - bl CpuSet - ldr r0, =gUnknown_0861033C - ldr r4, =gUnknown_0203CE44 - ldr r1, [r4] - movs r2, 0x30 - bl CpuSet - ldr r1, [r5] - movs r2, 0x88 - lsls r2, 3 - movs r0, 0x1 - movs r3, 0 - bl LoadBgTiles - ldr r1, [r4] - movs r0, 0x3 - movs r2, 0x60 - movs r3, 0 - bl LoadBgTiles - ldr r0, =gFrontierFactorySelectMenu_Tilemap - ldr r4, =gUnknown_0203CE48 - ldr r1, [r4] - movs r2, 0x80 - lsls r2, 3 - bl CpuSet - ldr r1, [r4] - movs r2, 0x80 - lsls r2, 4 - movs r0, 0x1 - movs r3, 0 - bl LoadBgTilemap - ldr r0, =gFrontierFactorySelectMenu_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r4, =gUnknown_08610918 - adds r0, r4, 0 - movs r1, 0xF0 - movs r2, 0xA - bl LoadPalette - adds r0, r4, 0 - movs r1, 0xE0 - movs r2, 0xA - bl LoadPalette - ldr r0, =gUnknown_0861039C - movs r1, 0x20 - movs r2, 0x4 - bl LoadPalette - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DE68: - ldr r0, =gUnknown_0203CE4C - ldr r1, [r0] - movs r0, 0x3 - bl SetBgTilemapBuffer - ldr r1, =gUnknown_0861023C - movs r0, 0x8 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x3 - movs r2, 0xB - movs r3, 0x4 - bl CopyToBgTilemapBufferRect - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - b _0819E006 - .pool -_0819DE94: - ldr r0, =gUnknown_086106B0 - bl LoadSpritePalettes - ldr r0, =gUnknown_08610650 - bl LoadSpriteSheets - ldr r0, =gUnknown_086106A0 - bl LoadCompressedObjectPic - ldr r0, =sub_819C7FC - bl SetVBlankCallback - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DECC: - ldr r0, =sFactorySwapScreen - ldr r1, [r0] - ldrb r0, [r1, 0x15] - cmp r0, 0x1 - bne _0819DEDC - ldr r0, =gUnknown_0203CF20 - ldrb r0, [r0] - strb r0, [r1, 0x3] -_0819DEDC: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _0819E00E - .pool -_0819DEEC: - bl sub_819DBD8 - bl sub_819E0C0 - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x15] - cmp r0, 0x1 - bne _0819DF02 - bl sub_819F304 -_0819DF02: - movs r0, 0 - bl sub_819F048 - b _0819E006 - .pool -_0819DF10: - ldr r0, =gText_SelectPkmnToSwap - bl Swap_PrintOnYesNoQuestionWindow - movs r0, 0x2 - bl PutWindowTilemap - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DF30: - bl Swap_PrintMonCategory - movs r0, 0x8 - bl PutWindowTilemap - b _0819E006 -_0819DF3C: - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x15] - cmp r0, 0 - bne _0819DF4A - bl Swap_PrintMonSpecies -_0819DF4A: - movs r0, 0x1 - bl PutWindowTilemap - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DF64: - bl sub_819EB18 - movs r0, 0 - bl PutWindowTilemap - b _0819E006 -_0819DF70: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _0819E00E -_0819DF78: - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x15] - cmp r0, 0 - beq _0819E006 - bl sub_819EE08 - b _0819E006 - .pool -_0819DF8C: - bl sub_819ED78 - movs r0, 0x3 - bl PutWindowTilemap - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0819E00E - .pool -_0819DFA4: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - ldr r0, =sFactorySwapScreen - ldr r0, [r0] - ldrb r0, [r0, 0x15] - cmp r0, 0x1 - bne _0819E000 - movs r0, 0x3 - bl ShowBg - ldr r1, =0x00001248 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000040b - movs r0, 0x52 - bl SetGpuReg - b _0819E006 - .pool -_0819E000: - movs r0, 0x3 - bl HideBg -_0819E006: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 -_0819E00E: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0819E0AA - .pool -_0819E01C: - ldr r0, =sub_819CF54 - movs r1, 0 - bl CreateTask - ldr r6, =sFactorySwapScreen - ldr r1, [r6] - adds r1, 0x21 - strb r0, [r1] - ldr r0, [r6] - ldrb r5, [r0, 0x15] - cmp r5, 0 - bne _0819E06C - ldr r4, =gTasks - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r4 - strh r5, [r0, 0x8] - ldr r0, =Task_HandleSwapScreenChooseMons - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r4 - strh r5, [r0, 0x8] - b _0819E0A4 - .pool -_0819E06C: - bl sub_819EAF8 - ldr r4, =gTasks - ldr r2, [r6] - adds r0, r2, 0 - adds r0, 0x21 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r4 - movs r3, 0 - movs r1, 0x1 - strh r1, [r0, 0x8] - adds r2, 0x22 - strb r3, [r2] - ldr r0, =Task_HandleSwapScreenMenu - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r4 - movs r1, 0x2 - strh r1, [r0, 0x8] -_0819E0A4: - ldr r0, =sub_819C7E0 - bl SetMainCallback2 -_0819E0AA: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819DC1C - - thumb_func_start sub_819E0C0 -sub_819E0C0: @ 819E0C0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - mov r1, sp - ldr r0, =gUnknown_08610834 - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r2,r5,r6} - stm r1!, {r2,r5,r6} - mov r1, sp - movs r0, 0x65 - strh r0, [r1, 0x2] - movs r6, 0 - ldr r4, =sFactorySwapScreen - movs r7, 0 - ldr r5, =gSprites -_0819E0E6: - lsls r1, r6, 1 - adds r1, r6 - lsls r1, 20 - movs r3, 0x90 - lsls r3, 15 - adds r1, r3 - asrs r1, 16 - mov r0, sp - movs r2, 0x40 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r4] - adds r1, 0x5 - adds r1, r6 - strb r0, [r1] - ldr r0, [r4] - adds r0, 0x5 - adds r0, r6 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - strh r7, [r0, 0x2E] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x2 - bls _0819E0E6 - ldr r7, =sFactorySwapScreen - ldr r1, [r7] - adds r0, r1, 0x5 - ldrb r1, [r1, 0x3] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - movs r5, 0x20 - ldrsh r1, [r0, r5] - ldr r0, =gUnknown_0861084C - movs r2, 0x58 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - movs r4, 0 - strb r0, [r1, 0x4] - ldr r0, =gUnknown_08610864 - movs r1, 0xB0 - movs r2, 0x70 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x1] - ldr r0, =gUnknown_0861087C - movs r1, 0xB0 - movs r2, 0x90 - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x2] - ldr r0, [r7] - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r6, =gSprites - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r7] - ldrb r1, [r0, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldr r0, [r7] - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x28 - strb r4, [r0] - ldr r0, [r7] - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x29 - strb r4, [r0] - ldr r0, [r7] - ldrb r1, [r0, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x28 - strb r4, [r0] - ldr r0, [r7] - ldrb r1, [r0, 0x2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x29 - strb r4, [r0] - ldr r0, [r7] - ldrb r0, [r0, 0x15] - movs r1, 0xC0 - str r1, [sp, 0x18] - cmp r0, 0x1 - bne _0819E1E8 - movs r2, 0xF0 - str r2, [sp, 0x18] -_0819E1E8: - mov r1, sp - ldr r0, =gUnknown_0861084C - ldm r0!, {r3-r5} - stm r1!, {r3-r5} - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - mov r0, sp - movs r4, 0x68 - mov r10, r4 - mov r5, r10 - strh r5, [r0] - movs r1, 0xF0 - movs r2, 0x78 - movs r3, 0xA - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x8] - mov r1, sp - ldr r0, =gUnknown_08610864 - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r4-r6} - stm r1!, {r4-r6} - mov r0, sp - movs r1, 0x69 - mov r9, r1 - mov r2, r9 - strh r2, [r0] - movs r4, 0x80 - lsls r4, 1 - adds r1, r4, 0 - movs r2, 0x78 - movs r3, 0xA - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x9] - movs r5, 0x90 - lsls r5, 1 - mov r0, sp - adds r1, r5, 0 - movs r2, 0x78 - movs r3, 0xA - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xA] - mov r1, sp - ldr r0, =gUnknown_0861084C - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - mov r0, sp - movs r3, 0x6A - mov r8, r3 - mov r6, r8 - strh r6, [r0] - movs r1, 0xF0 - movs r2, 0x78 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xB] - mov r1, sp - ldr r0, =gUnknown_08610864 - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - mov r1, sp - movs r0, 0x6B - strh r0, [r1] - mov r0, sp - adds r1, r4, 0 - movs r2, 0x78 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xC] - mov r0, sp - movs r6, 0x6C - strh r6, [r0] - adds r1, r5, 0 - movs r2, 0x78 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xD] - mov r1, sp - ldr r0, =gUnknown_0861084C - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - mov r0, sp - mov r4, r10 - strh r4, [r0] - ldr r1, [sp, 0x18] - movs r2, 0x90 - movs r3, 0xA - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xE] - mov r1, sp - ldr r0, =gUnknown_08610864 - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r4,r5} - stm r1!, {r2,r4,r5} - mov r0, sp - mov r3, r9 - strh r3, [r0] - ldr r4, [sp, 0x18] - adds r4, 0x10 - adds r1, r4, 0 - movs r2, 0x90 - movs r3, 0xA - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0xF] - mov r1, sp - ldr r0, =gUnknown_0861084C - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - mov r0, sp - mov r5, r8 - strh r5, [r0] - ldr r1, [sp, 0x18] - movs r2, 0x90 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x10] - mov r1, sp - ldr r0, =gUnknown_08610864 - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - mov r0, sp - strh r6, [r0] - adds r1, r4, 0 - movs r2, 0x90 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r7] - strb r0, [r1, 0x11] - movs r6, 0 - ldr r5, =gSprites - adds r4, r7, 0 - movs r7, 0 - movs r0, 0x4 - mov r10, r0 -_0819E330: - ldr r0, [r4] - lsls r3, r6, 1 - adds r2, r3, r6 - adds r0, 0x8 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x28 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0x8 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x29 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0x9 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x28 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0x9 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x29 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xA - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x28 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xA - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x29 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xE - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x28 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xE - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x29 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xF - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x28 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0xF - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x29 - strb r7, [r0] - ldr r0, [r4] - adds r0, 0x8 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - mov r8, r0 - ldrb r1, [r0] - mov r0, r10 - orrs r1, r0 - mov r0, r8 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0x9 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - mov r8, r0 - ldrb r1, [r0] - mov r0, r10 - orrs r1, r0 - mov r0, r8 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0xA - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - mov r2, r10 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0xE - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldr r0, [r4] - adds r0, 0xF - adds r0, r3 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r3, =sFactorySwapScreen - mov r8, r3 - ldr r0, =gSprites - mov r9, r0 - cmp r6, 0x1 - bhi _0819E496 - b _0819E330 -_0819E496: - ldr r0, [r3] - ldrb r0, [r0, 0xE] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r9 - adds r1, 0x3E - ldrb r2, [r1] - movs r3, 0x5 - negs r3, r3 - adds r0, r3, 0 - b _0819E4C8 - .pool -_0819E4C8: - ands r0, r2 - strb r0, [r1] - mov r1, r8 - ldr r0, [r1] - ldrb r1, [r0, 0xF] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r3, 0 - ands r1, r2 - strb r1, [r0] - mov r2, r8 - ldr r0, [r2] - ldrb r1, [r0, 0x8] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r3, 0 - ands r1, r2 - strb r1, [r0] - mov r4, r8 - ldr r0, [r4] - ldrb r1, [r0, 0x9] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r3, 0 - ands r1, r2 - strb r1, [r0] - ldr r0, [r4] - ldrb r1, [r0, 0xA] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r1, [r0] - ands r3, r1 - strb r3, [r0] - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819E0C0 - thumb_func_start sub_819E538 sub_819E538: @ 819E538 push {r4-r7,lr} @@ -3095,8 +774,8 @@ sub_819EAF8: @ 819EAF8 bx r0 thumb_func_end sub_819EAF8 - thumb_func_start sub_819EB18 -sub_819EB18: @ 819EB18 + thumb_func_start Swap_PrintPkmnSwap +Swap_PrintPkmnSwap: @ 819EB18 push {lr} sub sp, 0xC movs r0, 0 @@ -3118,7 +797,7 @@ sub_819EB18: @ 819EB18 pop {r0} bx r0 .pool - thumb_func_end sub_819EB18 + thumb_func_end Swap_PrintPkmnSwap thumb_func_start Swap_PrintMonSpecies Swap_PrintMonSpecies: @ 819EB4C @@ -3192,8 +871,8 @@ _0819EBD4: .pool thumb_func_end Swap_PrintMonSpecies - thumb_func_start Swap_PrintOnYesNoQuestionWindow -Swap_PrintOnYesNoQuestionWindow: @ 819EBEC + thumb_func_start Swap_PrintOnInfoWindow +Swap_PrintOnInfoWindow: @ 819EBEC push {r4,lr} sub sp, 0xC adds r4, r0, 0 @@ -3217,7 +896,7 @@ Swap_PrintOnYesNoQuestionWindow: @ 819EBEC pop {r4} pop {r0} bx r0 - thumb_func_end Swap_PrintOnYesNoQuestionWindow + thumb_func_end Swap_PrintOnInfoWindow thumb_func_start sub_819EC20 sub_819EC20: @ 819EC20 @@ -3340,8 +1019,8 @@ sub_819ECF0: @ 819ECF0 .pool thumb_func_end sub_819ECF0 - thumb_func_start sub_819ED34 -sub_819ED34: @ 819ED34 + thumb_func_start Swap_PrintActionStrings +Swap_PrintActionStrings: @ 819ED34 push {lr} movs r0, 0x5 movs r1, 0 @@ -3369,10 +1048,10 @@ _0819ED60: pop {r0} bx r0 .pool - thumb_func_end sub_819ED34 + thumb_func_end Swap_PrintActionStrings - thumb_func_start sub_819ED78 -sub_819ED78: @ 819ED78 + thumb_func_start Swap_PrintActionStrings2 +Swap_PrintActionStrings2: @ 819ED78 push {lr} movs r0, 0x3 movs r1, 0 @@ -3400,10 +1079,10 @@ _0819EDA4: pop {r0} bx r0 .pool - thumb_func_end sub_819ED78 + thumb_func_end Swap_PrintActionStrings2 - thumb_func_start sub_819EDBC -sub_819EDBC: @ 819EDBC + thumb_func_start Swap_PrintActionStrings3 +Swap_PrintActionStrings3: @ 819EDBC push {lr} lsls r0, 24 lsrs r0, 24 @@ -3436,10 +1115,10 @@ _0819EDF6: pop {r0} bx r0 .pool - thumb_func_end sub_819EDBC + thumb_func_end Swap_PrintActionStrings3 - thumb_func_start sub_819EE08 -sub_819EE08: @ 819EE08 + thumb_func_start Swap_PrintMonSpecies2 +Swap_PrintMonSpecies2: @ 819EE08 push {r4,lr} sub sp, 0x18 ldr r0, =gUnknown_08610918 @@ -3537,10 +1216,10 @@ _0819EED8: pop {r0} bx r0 .pool - thumb_func_end sub_819EE08 + thumb_func_end Swap_PrintMonSpecies2 - thumb_func_start sub_819EEF0 -sub_819EEF0: @ 819EEF0 + thumb_func_start Swap_PrintMonSpecies3 +Swap_PrintMonSpecies3: @ 819EEF0 push {r4,lr} sub sp, 0xC ldr r0, =gUnknown_08610918 @@ -3614,7 +1293,7 @@ _0819EF90: pop {r0} bx r0 .pool - thumb_func_end sub_819EEF0 + thumb_func_end Swap_PrintMonSpecies3 thumb_func_start Swap_PrintMonCategory Swap_PrintMonCategory: @ 819EFA8 @@ -4016,8 +1695,8 @@ sub_819F2B4: @ 819F2B4 .pool thumb_func_end sub_819F2B4 - thumb_func_start sub_819F304 -sub_819F304: @ 819F304 + thumb_func_start Swap_ShowSummaryMonSprite +Swap_ShowSummaryMonSprite: @ 819F304 push {r4-r6,lr} mov r6, r10 mov r5, r9 @@ -4125,7 +1804,7 @@ sub_819F304: @ 819F304 pop {r0} bx r0 .pool - thumb_func_end sub_819F304 + thumb_func_end Swap_ShowSummaryMonSprite thumb_func_start sub_819F3F8 sub_819F3F8: @ 819F3F8 @@ -4232,7 +1911,7 @@ _0819F4C8: .4byte _0819F568 _0819F4DC: ldr r0, =gText_SamePkmnInPartyAlready - bl Swap_PrintOnYesNoQuestionWindow + bl Swap_PrintOnInfoWindow ldr r0, =sFactorySwapScreen ldr r0, [r0] adds r0, 0x20 @@ -4277,7 +1956,7 @@ _0819F52C: b _0819F54E _0819F548: ldr r0, =gText_SelectPkmnToAccept - bl Swap_PrintOnYesNoQuestionWindow + bl Swap_PrintOnInfoWindow _0819F54E: ldr r0, =gTasks adds r1, r5, r4 @@ -4289,7 +1968,7 @@ _0819F54E: b _0819F58A .pool _0819F568: - bl sub_819EEF0 + bl Swap_PrintMonSpecies3 bl sub_819EADC ldr r0, =sFactorySwapScreen ldr r0, [r0] diff --git a/src/battle_factory.c b/src/battle_factory.c index 1609658f3..6324f4040 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -34,8 +34,22 @@ #define MENU_OPTIONS_COUNT 3 #define SELECTABLE_MONS_COUNT 6 + #define TAG_PAL_BALL_GREY 0x64 #define TAG_PAL_BALL_SELECTED 0x65 +#define TAG_PAL_66 0x66 +#define TAG_PAL_67 0x67 + +#define TAG_TILE_64 0x64 +#define TAG_TILE_65 0x65 +#define TAG_TILE_66 0x66 +#define TAG_TILE_67 0x67 +#define TAG_TILE_68 0x68 +#define TAG_TILE_69 0x69 +#define TAG_TILE_6A 0x6A +#define TAG_TILE_6B 0x6B +#define TAG_TILE_6C 0x6C +#define TAG_TILE_6D 0x6D struct FactorySelecteableMon { @@ -74,29 +88,21 @@ struct FactorySelectMonsStruct u8 unk2A9; }; +// 'Action' refers to the Cancel, Pknm for swap windows. + struct FactorySwapMonsStruct { - u8 unk0; - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; - u8 unk5; - u8 unk6; - u8 unk7; - u8 unk8; - u8 unk9; - u8 unkA; - u8 unkB; - u8 unkC; - u8 unkD; - u8 unkE; - u8 unkF; - u8 unk10; - u8 unk11; + u8 menuCursorPos; + u8 menuCursor1SpriteId; + u8 menuCursor2SpriteId; + u8 cursorPos; + u8 cursorSpriteId; + u8 ballSpriteIds[3]; + u8 unk8[2][3]; + u8 unkE[2][2]; u8 unk12; u8 unk13; - u8 unk14; + u8 actionsState; bool8 fromSummaryScreen; u8 yesNoCursorPos; u8 unk17; @@ -109,7 +115,7 @@ struct FactorySwapMonsStruct u8 unk1E; u8 unk1F; u8 unk20; - u8 unk21; + u8 palBlendTaskId; u8 unk22; u8 unk23; u16 unk24; @@ -169,9 +175,7 @@ u8 sub_81A6F70(u8 battleMode, u8 lvlMode); u8 sub_81A6CA8(u8 arg0, u8 arg1); static bool32 Select_AreSpeciesValid(u16 monSetId); void sub_819E538(void); -void sub_819DC1C(void); void sub_819E9E0(void); -void sub_819EE08(void); void sub_819EAC0(void); void Swap_UpdateYesNoCursorPosition(s8 direction); void Swap_UpdateMenuCursorPosition(s8 direction); @@ -179,14 +183,26 @@ void sub_819EA64(u8 windowId); void sub_819D770(u8 taskId); void Task_HandleSwapScreenChooseMons(u8 taskId); void sub_819D588(u8 taskId); -void Swap_PrintOnYesNoQuestionWindow(const u8 *str); +void Swap_PrintOnInfoWindow(const u8 *str); void Swap_ShowMenuOptions(void); void Swap_PrintMonSpecies(void); +void Swap_PrintMonSpecies2(void); +void Swap_PrintMonSpecies3(void); void Swap_PrintMonCategory(void); +void Swap_InitAllSprites(void); +void Swap_PrintPkmnSwap(void); +void sub_819EADC(void); +void sub_819EAF8(void); +void CB2_InitSwapScreen(void); +void Swap_ShowSummaryMonSprite(void); void Swap_UpdateActionCursorPosition(s8 direction); void Swap_UpdateBallCursorPosition(s8 direction); void Swap_RunMenuOptionFunc(u8 taskId); void sub_819F184(u8 taskId); +void Swap_PrintActionStrings(void); +void Swap_PrintActionStrings2(void); +void Swap_PrintActionStrings3(u8 field); +void sub_819F048(u8 field); // Ewram variables EWRAM_DATA u8 *gUnknown_0203CE2C = NULL; @@ -224,25 +240,25 @@ const u16 gUnknown_0861039C[] = INCBIN_U16("graphics/unknown/unknown_61039C.gbap const struct SpriteSheet gUnknown_086103BC[] = { - {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), 0x65}, - {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), 0x66}, - {gUnknown_0860F53C, sizeof(gUnknown_0860F53C), 0x67}, - {gUnknown_0860FA3C, sizeof(gUnknown_0860FA3C), 0x6D}, + {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), TAG_TILE_65}, + {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), TAG_TILE_66}, + {gUnknown_0860F53C, sizeof(gUnknown_0860F53C), TAG_TILE_67}, + {gUnknown_0860FA3C, sizeof(gUnknown_0860FA3C), TAG_TILE_6D}, {}, }; const struct CompressedSpriteSheet gUnknown_086103E4[] = { - {gUnknown_085B18AC, 0x800, 0x64}, + {gUnknown_085B18AC, 0x800, TAG_TILE_64}, {}, }; const struct SpritePalette gUnknown_086103F4[] = { - {gUnknown_0860F13C, 0x64}, - {gUnknown_0860F15C, 0x65}, - {gUnknown_0860F17C, 0x66}, - {gUnknown_0861039C, 0x67}, + {gUnknown_0860F13C, TAG_PAL_BALL_GREY}, + {gUnknown_0860F15C, TAG_PAL_BALL_SELECTED}, + {gUnknown_0860F17C, TAG_PAL_66}, + {gUnknown_0861039C, TAG_PAL_67}, {}, }; @@ -254,8 +270,11 @@ u8 (* const sSelect_MenuOptionFuncs[])(void) = }; extern const struct BgTemplate gUnknown_08610428[3]; +extern const struct BgTemplate gUnknown_086108B8[4]; extern const struct WindowTemplate gUnknown_08610434[]; +extern const struct WindowTemplate gUnknown_086108C8[]; extern const u16 gUnknown_0861046C[]; +extern const u16 gUnknown_08610918[]; extern const struct SpriteTemplate gUnknown_086105D8; extern const struct SpriteTemplate gUnknown_086105F0; extern const struct SpriteTemplate gUnknown_08610608; @@ -263,6 +282,9 @@ extern const struct SpriteTemplate gUnknown_08610620; extern const struct SpriteTemplate gUnknown_08610638; extern const u8 gUnknown_08610479[]; extern const u8 gUnknown_08610476[]; +extern const struct SpritePalette gUnknown_086106B0[]; +extern const struct SpriteSheet gUnknown_08610650[]; +extern const struct CompressedSpriteSheet gUnknown_086106A0[]; // gfx extern const u8 gFrontierFactorySelectMenu_Gfx[]; @@ -284,6 +306,8 @@ extern const u8 gText_Yes2[]; extern const u8 gText_No2[]; extern const u8 gText_QuitSwapping[]; extern const u8 gText_AcceptThisPkmn[]; +extern const u8 gText_SelectPkmnToAccept[]; +extern const u8 gText_SelectPkmnToSwap[]; // code void sub_819A44C(struct Sprite *sprite) @@ -1486,7 +1510,9 @@ static void Task_SelectBlendPalette(u8 taskId) } } -void sub_819C7E0(void) +// Swap Screen's section begins here. + +void Swap_CB2(void) { AnimateSprites(); BuildOamBuffer(); @@ -1495,7 +1521,7 @@ void sub_819C7E0(void) RunTasks(); } -void sub_819C7FC(void) +void Swap_VblankCb(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1526,7 +1552,7 @@ void sub_819C90C(u8 taskId) // Task_FromSelectScreenToSummaryScreen case 7: if (!gPaletteFade.active) { - DestroyTask(sFactorySwapScreen->unk21); + DestroyTask(sFactorySwapScreen->palBlendTaskId); sub_819F444(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30); sub_819E538(); FREE_AND_SET_NULL(gUnknown_0203CE40); @@ -1541,7 +1567,7 @@ void sub_819C90C(u8 taskId) // Task_FromSelectScreenToSummaryScreen DestroyTask(taskId); sFactorySwapScreen->fromSummaryScreen = TRUE; sFactorySwapScreen->unk24 = gPlttBufferUnfaded[244]; - ShowPokemonSummaryScreen(0, gPlayerParty, sFactorySwapScreen->unk3, 3 - 1, sub_819DC1C); + ShowPokemonSummaryScreen(0, gPlayerParty, sFactorySwapScreen->cursorPos, 3 - 1, CB2_InitSwapScreen); break; } } @@ -1567,7 +1593,7 @@ void sub_819CA08(u8 taskId) // Task_CloseSelectionScreen case 1: if (sFactorySwapScreen->unk20 == 1) { - sFactorySwapScreen->unk13 = sFactorySwapScreen->unk3; + sFactorySwapScreen->unk13 = sFactorySwapScreen->cursorPos; sub_819C810(); } gTasks[taskId].data[0]++; @@ -1579,7 +1605,7 @@ void sub_819CA08(u8 taskId) // Task_CloseSelectionScreen case 3: if (!UpdatePaletteFade()) { - DestroyTask(sFactorySwapScreen->unk21); + DestroyTask(sFactorySwapScreen->palBlendTaskId); sub_819E538(); FREE_AND_SET_NULL(gUnknown_0203CE40); FREE_AND_SET_NULL(gUnknown_0203CE44); @@ -1672,7 +1698,7 @@ void sub_819CC24(u8 taskId) { if (gTasks[taskId].data[0] == 0) { - Swap_PrintOnYesNoQuestionWindow(gText_QuitSwapping); + Swap_PrintOnInfoWindow(gText_QuitSwapping); sFactorySwapScreen->unk20 = 0; gTasks[taskId].data[0] = 4; gTasks[taskId].data[6] = (u32)(sub_819CBDC) >> 16; @@ -1704,7 +1730,7 @@ void sub_819CCD4(u8 taskId) if (gTasks[taskId].data[0] == 0) { sub_819F2B4(&sFactorySwapScreen->unk2C.field1, &sFactorySwapScreen->unk30, 1); - Swap_PrintOnYesNoQuestionWindow(gText_AcceptThisPkmn); + Swap_PrintOnInfoWindow(gText_AcceptThisPkmn); sFactorySwapScreen->unk20 = 1; gTasks[taskId].data[0] = 4; gTasks[taskId].data[6] = (u32)(sub_819CC74) >> 16; @@ -1777,7 +1803,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) { PlaySE(SE_SELECT); sFactorySwapScreen->unk22 = 0; - sub_819EE08(); + Swap_PrintMonSpecies2(); sub_819EAC0(); sub_819F184(taskId); } @@ -1785,7 +1811,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) { PlaySE(SE_SELECT); sFactorySwapScreen->unk22 = 0; - sub_819EE08(); + Swap_PrintMonSpecies2(); sub_819EAC0(); gTasks[taskId].data[6] = (u32)(sub_819CC24) >> 16; gTasks[taskId].data[7] = (u32)(sub_819CC24); @@ -1821,7 +1847,7 @@ void Task_HandleSwapScreenChooseMons(u8 taskId) } } -void sub_819CF54(u8 taskId) +void Task_SwapBlendPalette(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -1876,7 +1902,7 @@ void sub_819CF54(u8 taskId) } } -void sub_819D064(u8 taskId) +void Task_SwapBlendPalette2(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -1906,3 +1932,694 @@ void sub_819D064(u8 taskId) break; } } + +void sub_819D12C(u8 taskId) +{ + s8 i; + u8 var_2C; + bool8 r7; + + switch (gTasks[taskId].data[0]) + { + case 0: + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[0] = 1; + break; + case 1: + var_2C = 0; + for (i = 2; i >= 0; i--) + { + if (i != 2) + { + u8 posX = var_2C - gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + if (posX == 16 || gTasks[taskId].data[i + 2] == 1) + { + var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x += 10; + } + else if (posX > 16) + { + gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x = gSprites[sFactorySwapScreen->ballSpriteIds[i + 1]].pos1.x - 48; + } + } + else + { + var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x += 10; + } + + if (gTasks[taskId].data[i + 1] == 1) + { + if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x > (i * 48) + 72) + { + gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x = (i * 48) + 72; + r7 = TRUE; + } + else if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x == (i * 48) + 72) + { + r7 = TRUE; + } + else + { + r7 = FALSE; + } + } + else + { + r7 = FALSE; + } + + if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x - 16 > 240) + { + var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x = -16; + if (sFactorySwapScreen->actionsState == 1) + gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); + else + gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); + + gTasks[taskId].data[i + 1] = 1; + } + } + if (r7 == TRUE) + DestroyTask(taskId); + break; + } +} + +void sub_819D324(u8 taskId) +{ + u8 i, j; + s32 posX = 0; + s8 r4 = gTasks[taskId].data[3]; + bool8 r1; + s16 currPosX; + u8 taskId2; + + if (gTasks[taskId].data[2] == 1) + r4 *= -1; + + switch (gTasks[taskId].data[0]) + { + case 0: + currPosX = gSprites[sFactorySwapScreen->unk8[0][0]].pos1.x; + if (!gTasks[taskId].data[2]) + { + if (currPosX + r4 < 240) + { + r1 = TRUE; + } + else + { + r1 = FALSE; + posX = 240; + } + } + else + { + if (currPosX + r4 > 160) + { + r1 = TRUE; + } + else + { + r1 = FALSE; + posX = 160; + } + } + + if (r1 == TRUE) + { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 2; j++) + gSprites[sFactorySwapScreen->unk8[j][i]].pos1.x += r4; + } + } + else + { + for (j = 0; j < 2; j++) + { + gSprites[sFactorySwapScreen->unk8[j][0]].pos1.x = posX; + gSprites[sFactorySwapScreen->unk8[j][1]].pos1.x = posX + 16; + gSprites[sFactorySwapScreen->unk8[j][2]].pos1.x = posX + 48; + } + taskId2 = gTasks[taskId].data[1]; + gTasks[taskId2].data[3] = 1; + DestroyTask(taskId); + } + break; + case 1: + currPosX = gSprites[sFactorySwapScreen->unkE[0][0]].pos1.x; + if (!gTasks[taskId].data[2]) + { + if (currPosX + r4 < 240) + { + r1 = TRUE; + } + else + { + r1 = FALSE; + posX = 240; + } + } + else + { + if (currPosX + r4 > 192) + { + r1 = TRUE; + } + else + { + r1 = FALSE; + posX = 192; + } + } + + if (r1 == TRUE) + { + for (i = 0; i < 2; i++) + { + for (j = 0; j < 2; j++) + gSprites[sFactorySwapScreen->unkE[j][i]].pos1.x += r4; + } + } + else + { + for (j = 0; j < 2; j++) + { + gSprites[sFactorySwapScreen->unkE[j][0]].pos1.x = posX; + gSprites[sFactorySwapScreen->unkE[j][1]].pos1.x = posX + 16; + } + taskId2 = gTasks[taskId].data[1]; + gTasks[taskId2].data[4] = 1; + DestroyTask(taskId); + } + break; + } +} + +void sub_819D588(u8 taskId) +{ + u8 anotherTaskId; + u16 loPtr, hiPtr; + + switch (gTasks[taskId].data[0]) + { + case 0: + LoadPalette(gUnknown_08610918, 0xE0, 0xA); + Swap_PrintActionStrings(); + PutWindowTilemap(5); + gTasks[taskId].data[0]++; + break; + case 1: + sub_819EA64(3); + gTasks[taskId].data[0]++; + break; + case 2: + BeginNormalPaletteFade(0x4000, 0, 0, 0x10, gUnknown_0860F13C[37]); + gTasks[taskId].data[0]++; + break; + case 3: + if (!gPaletteFade.active) + { + FillWindowPixelBuffer(5, 0); + CopyWindowToVram(5, 2); + if (sFactorySwapScreen->actionsState == 1) + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[3] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 0; + gTasks[anotherTaskId].data[2] = 0; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[2] = 5; + gTasks[taskId].data[0]++; + } + else + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[3] = 1; + gTasks[taskId].data[4] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 1; + gTasks[anotherTaskId].data[2] = 0; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[0] += 2; + } + } + break; + case 4: + if (gTasks[taskId].data[2] == 0) + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[4] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 1; + gTasks[anotherTaskId].data[2] = 0; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[0]++; + } + else + { + gTasks[taskId].data[2]--; + } + break; + case 5: + if (gTasks[taskId].data[3] == 1 && gTasks[taskId].data[4] == 1) + { + gTasks[taskId].data[0] = gTasks[taskId].data[5]; + loPtr = gTasks[taskId].data[6]; + hiPtr = gTasks[taskId].data[7]; + gTasks[taskId].func = (void *)((loPtr << 0x10) | (hiPtr)); + } + break; + } +} + +void sub_819D770(u8 taskId) +{ + u8 anotherTaskId; + u16 loPtr, hiPtr; + if (sFactorySwapScreen->unk30 == 1) + return; + + switch (gTasks[taskId].data[0]) + { + case 0: + if (sFactorySwapScreen->actionsState == 1) + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[3] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 0; + gTasks[anotherTaskId].data[2] = 1; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[2] = 10; + gTasks[taskId].data[0]++; + } + else + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[3] = 1; + gTasks[taskId].data[4] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 1; + gTasks[anotherTaskId].data[2] = 1; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[0] += 2; + } + break; + case 1: + if (gTasks[taskId].data[2] == 0) + { + anotherTaskId = CreateTask(sub_819D324, 0); + gTasks[taskId].data[4] = 0; + gTasks[anotherTaskId].data[1] = taskId; + gTasks[anotherTaskId].data[0] = 1; + gTasks[anotherTaskId].data[2] = 1; + gTasks[anotherTaskId].data[3] = 6; + gTasks[taskId].data[0]++; + } + else + { + gTasks[taskId].data[2]--; + } + break; + case 2: + if (gTasks[taskId].data[3] == 1 && gTasks[taskId].data[4] == 1) + { + gPlttBufferFaded[226] = gUnknown_0860F13C[37]; + Swap_PrintActionStrings(); + PutWindowTilemap(5); + gTasks[taskId].data[0]++; + } + break; + case 3: + BeginNormalPaletteFade(0x4000, 0, 0x10, 0, gUnknown_0860F13C[37]); + gTasks[taskId].data[0]++; + break; + case 4: + if (!gPaletteFade.active) + { + Swap_PrintActionStrings3(0); + gTasks[taskId].data[0]++; + } + break; + case 5: + Swap_PrintActionStrings3(1); + PutWindowTilemap(3); + gTasks[taskId].data[0]++; + break; + case 6: + FillWindowPixelBuffer(5, 0); + CopyWindowToVram(5, 2); + gTasks[taskId].data[0]++; + break; + case 7: + if (sFactorySwapScreen->actionsState == 0) + Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap); + else + Swap_PrintOnInfoWindow(gText_SelectPkmnToAccept); + if (sFactorySwapScreen->cursorPos < 3) + gSprites[sFactorySwapScreen->cursorSpriteId].invisible = 0; + Swap_PrintMonCategory(); + gTasks[taskId].data[0]++; + break; + case 8: + Swap_PrintMonSpecies3(); + sub_819EADC(); + sFactorySwapScreen->unk22 = 1; + gTasks[taskId].data[0] = gTasks[taskId].data[5]; + loPtr = gTasks[taskId].data[6]; + hiPtr = gTasks[taskId].data[7]; + gTasks[taskId].func = (void *)((loPtr << 0x10) | (hiPtr)); + break; + } +} + +void sub_819D9EC(u8 taskId) +{ + u8 i; + if (sFactorySwapScreen->unk30 == 1) + return; + + switch (gTasks[taskId].data[0]) + { + case 0: + Swap_PrintMonSpecies3(); + gTasks[taskId].data[0]++; + break; + case 1: + sub_819EADC(); + gSprites[sFactorySwapScreen->cursorSpriteId].invisible = 1; + gTasks[taskId].data[0]++; + break; + case 2: + CreateTask(sub_819D12C, 0); + gTasks[sFactorySwapScreen->palBlendTaskId].func = Task_SwapBlendPalette2; + gTasks[taskId].data[0]++; + break; + case 3: + if (!FuncIsActiveTask(sub_819D12C) && gTasks[sFactorySwapScreen->palBlendTaskId].data[4] == 1) + { + sub_819EAC0(); + if (sFactorySwapScreen->actionsState == 0) + { + sub_819F048(1); + } + else + { + sub_819F048(0); + for (i = 0; i < 3; i++) + gSprites[sFactorySwapScreen->unk8[1][i]].invisible = 1; + } + gSprites[sFactorySwapScreen->cursorSpriteId].pos1.x = gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].pos1.x; + gTasks[sFactorySwapScreen->palBlendTaskId].func = Task_SwapBlendPalette; + sFactorySwapScreen->unk27 = 0; + sFactorySwapScreen->unk28 = 6; + sFactorySwapScreen->unk26 = FALSE; + gTasks[sFactorySwapScreen->palBlendTaskId].data[0] = 1; + gTasks[taskId].data[0]++; + } + break; + case 4: + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 0x10; + gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); + gTasks[taskId].data[5] = 1; + gTasks[taskId].func = sub_819D770; + break; + } +} + +void Swap_InitStruct(void) +{ + if (sFactorySwapScreen == NULL) + { + sFactorySwapScreen = AllocZeroed(sizeof(*sFactorySwapScreen)); + sFactorySwapScreen->cursorPos = 0; + sFactorySwapScreen->unk30 = 0; + sFactorySwapScreen->fromSummaryScreen = FALSE; + } +} + +void sub_819DC00(void) +{ + sFactorySwapScreen = NULL; + SetMainCallback2(CB2_InitSwapScreen); +} + +void CB2_InitSwapScreen(void) +{ + u8 taskId; + + switch (gMain.state) + { + case 0: + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + CpuFill32(0, (void *)VRAM, VRAM_SIZE); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_086108B8, ARRAY_COUNT(gUnknown_086108B8)); + InitWindows(gUnknown_086108C8); + DeactivateAllTextPrinters(); + gMain.state++; + break; + case 1: + gUnknown_0203CE40 = Alloc(0x440); + gUnknown_0203CE44 = AllocZeroed(0x440); + gUnknown_0203CE48 = Alloc(0x800); + gUnknown_0203CE4C = AllocZeroed(0x800); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_MOSAIC, 0); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WIN1H, 0); + SetGpuReg(REG_OFFSET_WIN1V, 0); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + gMain.state++; + break; + case 2: + ResetPaletteFade(); + ResetSpriteData(); + ResetTasks(); + FreeAllSpritePalettes(); + ResetAllPicSprites(); + CpuCopy16(gFrontierFactorySelectMenu_Gfx, gUnknown_0203CE40, 0x440); + CpuCopy16(gUnknown_0861033C, gUnknown_0203CE44, 0x60); + LoadBgTiles(1, gUnknown_0203CE40, 0x440, 0); + LoadBgTiles(3, gUnknown_0203CE44, 0x60, 0); + CpuCopy16(gFrontierFactorySelectMenu_Tilemap, gUnknown_0203CE48, 0x800); + LoadBgTilemap(1, gUnknown_0203CE48, 0x800, 0); + LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); + LoadPalette(gUnknown_08610918, 0xF0, 10); + LoadPalette(gUnknown_08610918, 0xE0, 10); + LoadPalette(gUnknown_0861039C, 0x20, 4); + gMain.state++; + break; + case 3: + SetBgTilemapBuffer(3, gUnknown_0203CE4C); + CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 4: + LoadSpritePalettes(gUnknown_086106B0); + LoadSpriteSheets(gUnknown_08610650); + LoadCompressedObjectPic(gUnknown_086106A0); + SetVBlankCallback(Swap_VblankCb); + gMain.state++; + break; + case 5: + if (sFactorySwapScreen->fromSummaryScreen == TRUE) + sFactorySwapScreen->cursorPos = gUnknown_0203CF20; + gMain.state++; + break; + case 6: + Swap_InitStruct(); + Swap_InitAllSprites(); + if (sFactorySwapScreen->fromSummaryScreen == TRUE) + Swap_ShowSummaryMonSprite(); + sub_819F048(0); + gMain.state++; + break; + case 7: + Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap); + PutWindowTilemap(2); + gMain.state++; + break; + case 8: + Swap_PrintMonCategory(); + PutWindowTilemap(8); + gMain.state++; + break; + case 9: + if (!sFactorySwapScreen->fromSummaryScreen) + Swap_PrintMonSpecies(); + PutWindowTilemap(1); + gMain.state++; + break; + case 10: + Swap_PrintPkmnSwap(); + PutWindowTilemap(0); + gMain.state++; + break; + case 11: + gMain.state++; + break; + case 12: + if (sFactorySwapScreen->fromSummaryScreen) + Swap_PrintMonSpecies2(); + gMain.state++; + break; + case 13: + Swap_PrintActionStrings2(); + PutWindowTilemap(3); + gMain.state++; + break; + case 14: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(2); + if (sFactorySwapScreen->fromSummaryScreen == TRUE) + { + ShowBg(3); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); + } + else + { + HideBg(3); + } + gMain.state++; + break; + case 15: + sFactorySwapScreen->palBlendTaskId = CreateTask(Task_SwapBlendPalette, 0); + if (!sFactorySwapScreen->fromSummaryScreen) + { + gTasks[sFactorySwapScreen->palBlendTaskId].data[0] = 0; + taskId = CreateTask(Task_HandleSwapScreenChooseMons, 0); + gTasks[taskId].data[0] = 0; + } + else + { + sub_819EAF8(); + gTasks[sFactorySwapScreen->palBlendTaskId].data[0] = 1; + sFactorySwapScreen->unk22 = FALSE; + taskId = CreateTask(Task_HandleSwapScreenMenu, 0); + gTasks[taskId].data[0] = 2; + } + SetMainCallback2(Swap_CB2); + break; + } +} + +extern const struct SpriteTemplate gUnknown_08610834; +extern const struct SpriteTemplate gUnknown_0861084C; +extern const struct SpriteTemplate gUnknown_08610864; +extern const struct SpriteTemplate gUnknown_0861087C; + +void Swap_InitAllSprites(void) +{ + u8 i; + u8 x; + struct SpriteTemplate spriteTemplate; + + spriteTemplate = gUnknown_08610834; + spriteTemplate.paletteTag = TAG_PAL_BALL_SELECTED; + + for (i = 0; i < 3; i++) + { + sFactorySwapScreen->ballSpriteIds[i] = CreateSprite(&spriteTemplate, (48 * i) + 72, 64, 1); + gSprites[sFactorySwapScreen->ballSpriteIds[i]].data[0] = 0; + } + sFactorySwapScreen->cursorSpriteId = CreateSprite(&gUnknown_0861084C, gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].pos1.x, 88, 0); + sFactorySwapScreen->menuCursor1SpriteId = CreateSprite(&gUnknown_08610864, 176, 112, 0); + sFactorySwapScreen->menuCursor2SpriteId = CreateSprite(&gUnknown_0861087C, 176, 144, 0); + gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = 1; + gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = 1; + gSprites[sFactorySwapScreen->menuCursor1SpriteId].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->menuCursor1SpriteId].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->menuCursor2SpriteId].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->menuCursor2SpriteId].centerToCornerVecY = 0; + + if (sFactorySwapScreen->fromSummaryScreen == TRUE) + x = 240; + else + x = 192; + + spriteTemplate = gUnknown_0861084C; + spriteTemplate.tileTag = TAG_TILE_68; + sFactorySwapScreen->unk8[0][0] = CreateSprite(&spriteTemplate, 240, 120, 10); + + spriteTemplate = gUnknown_08610864; + spriteTemplate.tileTag = TAG_TILE_69; + sFactorySwapScreen->unk8[0][1] = CreateSprite(&spriteTemplate, 256, 120, 10); + sFactorySwapScreen->unk8[0][2] = CreateSprite(&spriteTemplate, 288, 120, 10); + + spriteTemplate = gUnknown_0861084C; + spriteTemplate.tileTag = TAG_TILE_6A; + sFactorySwapScreen->unk8[1][0] = CreateSprite(&spriteTemplate, 240, 120, 1); + + spriteTemplate = gUnknown_08610864; + spriteTemplate.tileTag = TAG_TILE_6B; + sFactorySwapScreen->unk8[1][1] = CreateSprite(&spriteTemplate, 256, 120, 1); + spriteTemplate.tileTag = TAG_TILE_6C; + sFactorySwapScreen->unk8[1][2] = CreateSprite(&spriteTemplate, 288, 120, 1); + + spriteTemplate = gUnknown_0861084C; + spriteTemplate.tileTag = TAG_TILE_68; + sFactorySwapScreen->unkE[0][0] = CreateSprite(&spriteTemplate, x, 144, 10); + + spriteTemplate = gUnknown_08610864; + spriteTemplate.tileTag = TAG_TILE_69; + sFactorySwapScreen->unkE[0][1] = CreateSprite(&spriteTemplate, x + 16, 144, 10); + + spriteTemplate = gUnknown_0861084C; + spriteTemplate.tileTag = TAG_TILE_6A; + sFactorySwapScreen->unkE[1][0] = CreateSprite(&spriteTemplate, x, 144, 1); + + spriteTemplate = gUnknown_08610864; + spriteTemplate.tileTag = TAG_TILE_6C; + sFactorySwapScreen->unkE[1][1] = CreateSprite(&spriteTemplate, x + 16, 144, 1); + + for (i = 0; i < 2; i++) + { + gSprites[sFactorySwapScreen->unk8[i][0]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unk8[i][0]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->unk8[i][1]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unk8[i][1]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->unk8[i][2]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unk8[i][2]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->unkE[i][0]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unkE[i][0]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->unkE[i][1]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->unkE[i][1]].centerToCornerVecY = 0; + + gSprites[sFactorySwapScreen->unk8[i][0]].invisible = 1; + gSprites[sFactorySwapScreen->unk8[i][1]].invisible = 1; + gSprites[sFactorySwapScreen->unk8[i][2]].invisible = 1; + gSprites[sFactorySwapScreen->unkE[i][0]].invisible = 1; + gSprites[sFactorySwapScreen->unkE[i][1]].invisible = 1; + } + + gSprites[sFactorySwapScreen->unkE[0][0]].invisible = 0; + gSprites[sFactorySwapScreen->unkE[0][1]].invisible = 0; + gSprites[sFactorySwapScreen->unk8[0][0]].invisible = 0; + gSprites[sFactorySwapScreen->unk8[0][1]].invisible = 0; + gSprites[sFactorySwapScreen->unk8[0][2]].invisible = 0; +}