diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 4e0c3126f..835d43bad 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -8,1048 +8,6 @@ - thumb_func_start sub_819BF2C -sub_819BF2C: @ 819BF2C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - movs r7, 0 - ldr r0, =gUnknown_0300127C - mov r9, r0 -_0819BF3E: - movs r2, 0 - adds r1, r7, 0x1 - mov r10, r1 - lsls r0, r7, 2 - mov r8, r0 -_0819BF48: - mov r0, r9 - ldr r1, [r0] - movs r0, 0x6C - adds r4, r2, 0 - muls r4, r0 - adds r0, r1, r4 - ldrb r0, [r0, 0x10] - cmp r0, r10 - bne _0819C008 - adds r4, r1 - adds r4, 0x14 - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0 - bl GetMonData - adds r6, r0, 0 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - lsls r0, r7, 3 - adds r0, r7 - lsls r0, 19 - movs r2, 0x80 - lsls r2, 13 - adds r0, r2 - asrs r0, 16 - str r0, [sp] - movs r0, 0x20 - str r0, [sp, 0x4] - adds r0, r7, 0 - adds r0, 0xD - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x8] - ldr r0, =0x0000ffff - str r0, [sp, 0xC] - adds r0, r5, 0 - adds r2, r6, 0 - movs r3, 0x1 - bl CreateMonPicSprite_HandleDeoxys - mov r2, r9 - ldr r1, [r2] - add r1, r8 - movs r2, 0xA5 - lsls r2, 2 - adds r1, r2 - strb r0, [r1] - mov r1, r9 - ldr r0, [r1] - add r0, r8 - adds r0, r2 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r2, =gSprites - adds r0, r2 - adds r0, 0x28 - movs r1, 0 - strb r1, [r0] - mov r2, r9 - ldr r0, [r2] - add r0, r8 - movs r1, 0xA5 - lsls r1, 2 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r2, =gSprites - adds r0, r2 - adds r0, 0x29 - movs r1, 0 - strb r1, [r0] - b _0819C012 - .pool -_0819C008: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x5 - bls _0819BF48 -_0819C012: - mov r2, r10 - lsls r0, r2, 24 - lsrs r7, r0, 24 - cmp r7, 0x2 - bls _0819BF3E - ldr r0, =gUnknown_0300127C - ldr r0, [r0] - movs r1, 0xA8 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - 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_819BF2C - - thumb_func_start sub_819C040 -sub_819C040: @ 819C040 - push {r4-r6,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0819C0DC - ldr r3, =gSprites - ldr r6, =gUnknown_0300127C - ldr r2, [r6] - ldr r0, =0x00000295 - adds r5, r2, r0 - ldrb r0, [r5] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - adds r1, 0x3F - ldrb r0, [r1] - lsls r0, 26 - cmp r0, 0 - bge _0819C0DC - ldr r1, =0x0000029d - adds r0, r2, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _0819C0DC - adds r1, r4, 0 - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldr r0, [r6] - ldr r1, =0x0000029d - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldr r0, =sub_819C1D0 - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_0819C0DC: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819C040 - - thumb_func_start sub_819C100 -sub_819C100: @ 819C100 - push {r4-r7,lr} - adds r5, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0819C1BA - ldr r6, =gSprites - ldr r4, =gUnknown_0300127C - ldr r2, [r4] - ldr r7, =0x00000295 - adds r0, r2, r7 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _0819C1BA - ldr r1, =0x0000029d - adds r0, r2, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _0819C1BA - ldrb r0, [r5, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldr r0, [r4] - adds r0, r7 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldr r0, [r4] - ldr r1, =0x0000029d - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldr r0, [r4] - movs r1, 0xA8 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - ldr r0, [r4] - adds r0, r7 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - bl DestroySprite - ldr r0, [r4] - ldr r1, =0x0000029d - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - bl DestroySprite - adds r0, r5, 0 - bl DestroySprite -_0819C1BA: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819C100 - - thumb_func_start sub_819C1D0 -sub_819C1D0: @ 819C1D0 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _0819C24E - cmp r0, 0x1 - bgt _0819C1F8 - cmp r0, 0 - beq _0819C1FE - b _0819C2BA - .pool -_0819C1F8: - cmp r0, 0x2 - beq _0819C270 - b _0819C2BA -_0819C1FE: - movs r0, 0x10 - strh r0, [r4, 0xE] - movs r0, 0xE0 - strh r0, [r4, 0x38] - movs r0, 0x40 - strh r0, [r4, 0x12] - movs r0, 0x41 - strh r0, [r4, 0x18] - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - ldrh r1, [r4, 0xE] - lsls r1, 8 - ldrh r0, [r4, 0x38] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x40 - bl SetGpuReg - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - b _0819C2C6 -_0819C24E: - movs r0, 0x3 - bl ShowBg - ldr r1, =0x00001248 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000040b - movs r0, 0x52 - bl SetGpuReg - b _0819C2C6 - .pool -_0819C270: - ldrh r0, [r4, 0x12] - subs r0, 0x4 - strh r0, [r4, 0x12] - ldrh r1, [r4, 0x18] - adds r1, 0x4 - strh r1, [r4, 0x18] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x20 - ble _0819C28C - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x5F - ble _0819C29E -_0819C28C: - movs r0, 0x20 - strh r0, [r4, 0x12] - movs r0, 0x60 - strh r0, [r4, 0x18] - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl ClearGpuRegBits -_0819C29E: - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0x20 - bne _0819C2CC - b _0819C2C6 -_0819C2BA: - adds r0, r2, 0 - bl DestroyTask - bl sub_819BF2C - b _0819C2CC -_0819C2C6: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_0819C2CC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_819C1D0 - - thumb_func_start sub_819C2D4 -sub_819C2D4: @ 819C2D4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0819C2F6 - b _0819C410 -_0819C2F6: - cmp r0, 0x1 - bne _0819C2FC - b _0819C460 -_0819C2FC: - movs r0, 0x3 - bl HideBg - ldr r4, =gSprites - ldr r0, =gUnknown_0300127C - mov r8, r0 - ldr r0, [r0] - ldr r1, =0x00000299 - mov r12, r1 - add r0, r12 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - adds r1, 0x3E - ldrb r2, [r1] - movs r3, 0x5 - negs r3, r3 - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - mov r0, r8 - ldr r2, [r0] - mov r1, r12 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r6, r4, 0 - adds r6, 0x1C - adds r0, r6 - ldr r1, =sub_819C100 - str r1, [r0] - ldr r0, =0x00000295 - mov r9, r0 - add r2, r9 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r3, 0 - ands r1, r2 - strb r1, [r0] - mov r1, r8 - ldr r2, [r1] - mov r1, r9 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldr r1, =SpriteCallbackDummy - mov r10, r1 - str r1, [r0] - ldr r5, =0x0000029d - adds r2, r5 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, 0x3E - ldrb r1, [r0] - ands r3, r1 - strb r3, [r0] - mov r0, r8 - ldr r2, [r0] - adds r0, r2, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - mov r1, r10 - str r1, [r0] - add r2, r12 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x1 - bl StartSpriteAffineAnim - mov r1, r8 - ldr r0, [r1] - add r0, r9 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x1 - bl StartSpriteAffineAnim - mov r1, r8 - ldr r0, [r1] - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x1 - bl StartSpriteAffineAnim - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl ClearGpuRegBits - adds r0, r7, 0 - bl DestroyTask - b _0819C4A4 - .pool -_0819C410: - movs r0, 0x10 - strh r0, [r4, 0xE] - movs r0, 0xE0 - strh r0, [r4, 0x38] - movs r0, 0x20 - strh r0, [r4, 0x12] - movs r0, 0x60 - strh r0, [r4, 0x18] - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - ldrh r1, [r4, 0xE] - lsls r1, 8 - ldrh r0, [r4, 0x38] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x40 - bl SetGpuReg - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - b _0819C49E -_0819C460: - ldrh r0, [r4, 0x12] - adds r0, 0x4 - strh r0, [r4, 0x12] - ldrh r1, [r4, 0x18] - subs r1, 0x4 - strh r1, [r4, 0x18] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3F - bgt _0819C47C - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0x41 - bgt _0819C484 -_0819C47C: - movs r0, 0x40 - strh r0, [r4, 0x12] - movs r0, 0x41 - strh r0, [r4, 0x18] -_0819C484: - ldrh r1, [r4, 0x12] - lsls r1, 8 - ldrh r0, [r4, 0x18] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x44 - bl SetGpuReg - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0x40 - bne _0819C4A4 -_0819C49E: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_0819C4A4: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819C2D4 - - thumb_func_start sub_819C4B4 -sub_819C4B4: @ 819C4B4 - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r4, =gUnknown_08610638 - adds r0, r4, 0 - movs r1, 0x78 - movs r2, 0x40 - movs r3, 0x1 - bl CreateSprite - ldr r6, =gUnknown_0300127C - ldr r1, [r6] - ldr r2, =0x00000299 - mov r8, r2 - add r1, r8 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0x2C - movs r2, 0x40 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r6] - ldr r5, =0x00000295 - adds r1, r5 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0xC4 - movs r2, 0x40 - movs r3, 0x1 - bl CreateSprite - ldr r1, [r6] - ldr r4, =0x0000029d - adds r1, r4 - strb r0, [r1] - ldr r3, =gSprites - ldr r2, [r6] - add r8, r2 - mov r0, r8 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r3, 0x1C - adds r0, r3 - ldr r1, =sub_819C040 - str r1, [r0] - adds r5, r2, r5 - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldr r5, =SpriteCallbackDummy - str r5, [r0] - adds r4, r2, r4 - ldrb r1, [r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - str r5, [r0] - movs r0, 0xA8 - lsls r0, 2 - adds r2, r0 - movs r0, 0x1 - strb r0, [r2] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819C4B4 - - thumb_func_start sub_819C568 -sub_819C568: @ 819C568 - push {r4,lr} - ldr r4, =gUnknown_0300127C - ldr r0, [r4] - movs r1, 0xA5 - lsls r1, 2 - adds r0, r1 - ldrb r0, [r0] - bl FreeAndDestroyMonPicSprite - ldr r0, [r4] - movs r1, 0xA6 - lsls r1, 2 - adds r0, r1 - ldrb r0, [r0] - bl FreeAndDestroyMonPicSprite - ldr r0, [r4] - movs r1, 0xA7 - lsls r1, 2 - adds r0, r1 - ldrb r0, [r0] - bl FreeAndDestroyMonPicSprite - ldr r0, =sub_819C2D4 - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - ldr r0, [r4] - movs r1, 0xA8 - lsls r1, 2 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819C568 - - thumb_func_start sub_819C5D0 -sub_819C5D0: @ 819C5D0 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r6, r1, 0 - adds r5, r2, 0 - mov r8, r3 - lsls r4, 16 - lsrs r4, 16 - lsls r6, 16 - lsrs r6, 16 - lsls r5, 16 - lsrs r5, 16 - mov r0, r8 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - lsls r4, 24 - lsrs r4, 16 - orrs r4, r6 - movs r0, 0x40 - adds r1, r4, 0 - bl SetGpuReg - lsls r5, 24 - lsrs r5, 16 - mov r0, r8 - orrs r5, r0 - movs r0, 0x44 - adds r1, r5, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x37 - bl SetGpuReg - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_819C5D0 - - thumb_func_start sub_819C634 -sub_819C634: @ 819C634 - push {r4-r7,lr} - lsls r0, 16 - ldr r2, =gFacilityTrainerMons - ldr r1, [r2] - lsrs r0, 12 - adds r0, r1 - ldrh r6, [r0] - ldr r0, =gUnknown_0300127C - ldr r0, [r0] - ldrb r5, [r0, 0x5] - movs r3, 0x1 - cmp r3, r5 - bcs _0819C694 - adds r4, r0, 0 - movs r0, 0x6C - mov r12, r0 - adds r7, r2, 0 -_0819C656: - movs r2, 0 -_0819C658: - mov r0, r12 - muls r0, r2 - adds r1, r4, r0 - ldrb r0, [r1, 0x10] - cmp r0, r3 - bne _0819C680 - ldrh r0, [r1, 0xC] - ldr r1, [r7] - lsls r0, 4 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r6 - bne _0819C68A - movs r0, 0 - b _0819C696 - .pool -_0819C680: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x5 - bls _0819C658 -_0819C68A: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r5 - bcc _0819C656 -_0819C694: - movs r0, 0x1 -_0819C696: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_819C634 - - thumb_func_start sub_819C69C -sub_819C69C: @ 819C69C - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r1 - movs r0, 0x8 - ldrsh r2, [r5, r0] - cmp r2, 0x1 - beq _0819C6F8 - cmp r2, 0x1 - bgt _0819C6C4 - cmp r2, 0 - beq _0819C6CA - b _0819C7D8 - .pool -_0819C6C4: - cmp r2, 0x2 - beq _0819C7B4 - b _0819C7D8 -_0819C6CA: - ldr r1, =gUnknown_0300127C - ldr r0, [r1] - ldr r3, =0x000002a7 - adds r0, r3 - strb r2, [r0] - ldr r0, [r1] - adds r3, 0x1 - adds r0, r3 - strb r2, [r0] - ldr r0, [r1] - ldr r1, =0x000002a6 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - strh r1, [r5, 0x8] - b _0819C7D8 - .pool -_0819C6F8: - ldr r0, =gUnknown_0300127C - ldr r3, [r0] - ldr r2, =0x000002a2 - adds r1, r3, r2 - ldrb r1, [r1] - adds r7, r0, 0 - cmp r1, 0 - beq _0819C7D8 - ldr r1, =0x000002a9 - adds r0, r3, r1 - ldrb r4, [r0] - cmp r4, 0 - beq _0819C724 - movs r0, 0x2 - strh r0, [r5, 0x8] - b _0819C7D8 - .pool -_0819C724: - ldr r2, =0x000002a7 - adds r1, r3, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r7] - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0x6 - bls _0819C764 - strb r4, [r1] - ldr r1, [r7] - subs r2, 0x1 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _0819C758 - movs r3, 0xAA - lsls r3, 2 - adds r1, r3 - ldrb r0, [r1] - subs r0, 0x1 - b _0819C762 - .pool -_0819C758: - movs r0, 0xAA - lsls r0, 2 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 -_0819C762: - strb r0, [r1] -_0819C764: - movs r0, 0x80 - lsls r0, 7 - ldr r1, [r7] - movs r4, 0xAA - lsls r4, 2 - adds r1, r4 - ldrb r1, [r1] - movs r2, 0 - bl BlendPalettes - ldr r2, [r7] - adds r4, r2, r4 - ldrb r0, [r4] - cmp r0, 0x5 - bls _0819C790 - ldr r3, =0x000002a6 - adds r1, r2, r3 - movs r0, 0 - b _0819C7D6 - .pool -_0819C790: - cmp r0, 0 - bne _0819C7D8 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - movs r1, 0x2 - strh r1, [r0, 0x8] - ldr r0, =0x000002a6 - adds r1, r2, r0 - movs r0, 0x1 - b _0819C7D6 - .pool -_0819C7B4: - ldr r0, =gUnknown_0300127C - ldr r0, [r0] - ldr r2, =0x000002a9 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xE - bls _0819C7D4 - movs r0, 0 - strb r0, [r1] - movs r0, 0x1 - strh r0, [r5, 0x8] - b _0819C7D8 - .pool -_0819C7D4: - adds r0, 0x1 -_0819C7D6: - strb r0, [r1] -_0819C7D8: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819C69C - thumb_func_start sub_819C7E0 sub_819C7E0: @ 819C7E0 push {lr} diff --git a/data/battle_frontier_2.s b/data/battle_frontier_2.s index bbb2a2c62..c03c9c368 100644 --- a/data/battle_frontier_2.s +++ b/data/battle_frontier_2.s @@ -6,96 +6,6 @@ .section .rodata - .align 2 -gUnknown_0860F13C:: @ 860F13C - .incbin "graphics/unknown/unknown_60F13C.gbapal" - - .align 2 -gUnknown_0860F15C:: @ 860F15C - .incbin "graphics/unknown/unknown_60F15C.gbapal" - - .align 2 -gUnknown_0860F17C:: @ 860F17C - .incbin "graphics/unknown/unknown_60F17C.gbapal" - - .align 2 -gUnknown_0860F1BC:: @ 860F1BC - .incbin "graphics/unknown/unknown_60F1BC.4bpp" - - .align 2 -gUnknown_0860F3BC:: @ 860F3BC - .incbin "graphics/unknown/unknown_60F3BC.4bpp" - - .align 2 -gUnknown_0860F43C:: @ 860F43C - .incbin "graphics/unknown/unknown_60F43C.4bpp" - - .align 2 -gUnknown_0860F53C:: @ 860F53C - .incbin "graphics/unknown/unknown_60F53C.4bpp" - - .align 2 -gUnknown_0860F63C:: @ 860F63C - .incbin "graphics/unknown/unknown_60F63C.4bpp" - - .align 2 -gUnknown_0860F6BC:: @ 860F6BC - .incbin "graphics/unknown/unknown_60F6BC.4bpp" - - .align 2 -gUnknown_0860F7BC:: @ 860F7BC - .incbin "graphics/unknown/unknown_60F7BC.4bpp" - - .align 2 -gUnknown_0860F83C:: @ 860F83C - .incbin "graphics/unknown/unknown_60F83C.4bpp" - - .align 2 -gUnknown_0860F93C:: @ 860F93C - .incbin "graphics/unknown/unknown_60F93C.4bpp" - - .align 2 -gUnknown_0860FA3C:: @ 860FA3C - .incbin "graphics/unknown/unknown_60FA3C.4bpp" - - .align 2 -gUnknown_0861023C:: @ 861023C - .incbin "graphics/unknown/unknown_61023C.bin" - - .align 2 -gUnknown_0861033C:: @ 861033C - .incbin "graphics/unknown/unknown_61033C.4bpp" - - .align 2 -gUnknown_0861039C:: @ 861039C - .incbin "graphics/unknown/unknown_61039C.gbapal" - - .align 2 -gUnknown_086103BC:: @ 86103BC - obj_tiles gUnknown_0860F3BC, 0x0080, 0x0065 - obj_tiles gUnknown_0860F43C, 0x0100, 0x0066 - obj_tiles gUnknown_0860F53C, 0x0100, 0x0067 - obj_tiles gUnknown_0860FA3C, 0x0800, 0x006d - null_obj_tiles - - .align 2 -gUnknown_086103E4:: @ 86103E4 - obj_tiles gUnknown_085B18AC, 0x0800, 0x0064 - null_obj_tiles - - .align 2 -gUnknown_086103F4:: @ 86103F4 - obj_pal gUnknown_0860F13C, 0x0064 - obj_pal gUnknown_0860F15C, 0x0065 - obj_pal gUnknown_0860F17C, 0x0066 - obj_pal gUnknown_0861039C, 0x0067 - null_obj_pal - - .align 2 -gUnknown_0861041C:: @ 861041C - .4byte sub_819BCCC - .4byte sub_819BC30 - .4byte sub_819BCD0 .align 2 gUnknown_08610428:: @ 8610428 diff --git a/ld_script.txt b/ld_script.txt index 6e4885e4c..9e64023d1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -530,6 +530,7 @@ SECTIONS { src/battle_dome.o(.rodata); data/battle_frontier_1.o(.rodata); src/menu.o(.rodata); + src/battle_factory.o(.rodata); data/battle_frontier_2.o(.rodata); src/item_menu.o(.rodata); src/list_menu.o(.rodata); diff --git a/src/battle_factory.c b/src/battle_factory.c index 9cb773ea3..f7568055c 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -19,10 +19,14 @@ #include "pokemon_summary_screen.h" #include "sound.h" #include "pokedex.h" +#include "blend_palette.h" #include "trainer_pokemon_sprites.h" #include "constants/battle_frontier.h" #include "constants/songs.h" +// Select_ refers to the first Pokemon selection screen where you choose 3 Pokemon. +// Swap_ refers to the consecutive selection screen where you can keep your Pokemon or swap one with beaten trainer's. + #define MENU_SUMMARY 0 #define MENU_RENT 1 #define MENU_DESELECT 1 @@ -57,23 +61,19 @@ struct FactorySelectMonsStruct u8 selectingMonsState; bool8 fromSummaryScreen; u8 yesNoCursorPos; - u8 unk8; - u8 unk9; + u8 unused8; struct FactorySelecteableMon mons[SELECTABLE_MONS_COUNT]; - u32 unk294; - struct UnkFactoryStruct unk298; - u32 unk29C; + struct UnkFactoryStruct unk294[3]; u8 unk2A0; - u8 unk2A1; - u8 unk2A2; - u8 unk2A3; + u8 palBlendTaskId; + bool8 unk2A2; u16 unk2A4; - u16 unk2A6; - u16 unk2A8; - u16 unk2AA; + bool8 unk2A6; + u8 unk2A7; + u8 unk2A8; + u8 unk2A9; }; -extern struct FactorySelectMonsStruct *gUnknown_0300127C; extern u8 (*gUnknown_030062E8)(void); extern u8 gUnknown_0203CF20; @@ -81,42 +81,46 @@ extern const u16 gBattleFrontierHeldItems[]; extern const struct FacilityMon gBattleFrontierMons[]; extern const struct FacilityMon gSlateportBattleTentMons[]; extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; +extern const u8 gUnknown_085B18AC[]; extern void SetMonMoveAvoidReturn(struct Pokemon *mon, u16 move, u8 moveSlot); // This file's functions. -void sub_819A514(void); -void sub_819C5D0(u16 mWin0H, u16 nWin0H, u16 mWin0V, u16 nWin0V); -void sub_819A9AC(void); -void sub_819AA18(void); -void sub_819BE34(void); -void PrintSelectMonString(void); -void PrintMonSpecies(void); -void PrintMonCategory(void); -void sub_819B9E8(void); -void PrintRentalPkmnString(void); -void CopySelectedMonsToPlayerParty(void); -void sub_819C4B4(void); -void sub_819B8D4(void); -void sub_819C568(void); -void sub_819B844(void); -void PrintSelectableMenuOptions(void); -void PrintSelectableYesNo(void); -void sub_819C69C(u8 taskId); -void Task_HandleSelectionScreenChooseMons(u8 taskId); -void Task_HandleSelectionScreenMenu(u8 taskId); -void CreateFrontierFactorySelectableMons(u8 firstMonId); -void CreateTentFactorySelectableMons(u8 firstMonId); -void SetBallSpritePaletteNum(u8 id); +static void CB2_InitSelectScreen(void); +static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V); +static void Select_InitMonsData(void); +static void Select_InitAllSprites(void); +static void Select_ShowCheckedMonSprite(void); +static void Select_PrintSelectMonString(void); +static void Select_PrintMonSpecies(void); +static void Select_PrintMonCategory(void); +static void Select_PrintRentalPkmnString(void); +static void Select_CopyMonsToPlayerParty(void); +static void sub_819C4B4(void); +static void Select_ShowYesNoOptions(void); +static void sub_819C568(void); +static void Select_ShowMenuOptions(void); +static void Select_PrintMenuOptions(void); +static void Select_PrintYesNoOptions(void); +static void Task_SelectBlendPalette(u8 taskId); +static void sub_819C1D0(u8 taskId); +static void Task_HandleSelectionScreenChooseMons(u8 taskId); +static void Task_HandleSelectionScreenMenu(u8 taskId); +static void CreateFrontierFactorySelectableMons(u8 firstMonId); +static void CreateTentFactorySelectableMons(u8 firstMonId); +static void Select_SetBallSpritePaletteNum(u8 id); void sub_819F444(struct UnkFactoryStruct arg0, u8 *arg1); -void sub_819B958(u8 windowId); +static void sub_819B958(u8 windowId); void sub_819F2B4(u8 *arg0, u8 *arg1, u8 arg2); void sub_819F3F8(struct UnkFactoryStruct arg0, u8 *arg1, u8 arg2); -u8 sub_819BC04(void); -u8 sub_819BC9C(void); +static u8 Select_RunMenuOptionFunc(void); +static u8 sub_819BC9C(void); +static u8 Select_OptionSummary(void); +static u8 Select_OptionOthers(void); +static u8 Select_OptionRentDeselect(void); u8 sub_81A6F70(u8 battleMode, u8 lvlMode); u8 sub_81A6CA8(u8 arg0, u8 arg1); -bool32 sub_819C634(u16 monSetId); +static bool32 Select_AreSpeciesValid(u16 monSetId); // Ewram variables EWRAM_DATA u8 *gUnknown_0203CE2C = NULL; @@ -125,17 +129,68 @@ EWRAM_DATA u8 *gUnknown_0203CE34 = NULL; EWRAM_DATA u8 *gUnknown_0203CE38 = NULL; static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL; +// IWRAM bss +static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen; + // Const rom data. +const u16 gUnknown_0860F13C[] = INCBIN_U16("graphics/unknown/unknown_60F13C.gbapal"); +const u16 gUnknown_0860F15C[] = INCBIN_U16("graphics/unknown/unknown_60F15C.gbapal"); +const u16 gUnknown_0860F17C[] = INCBIN_U16("graphics/unknown/unknown_60F17C.gbapal"); +const u8 gUnknown_0860F1BC[] = INCBIN_U8("graphics/unknown/unknown_60F1BC.4bpp"); +const u8 gUnknown_0860F3BC[] = INCBIN_U8("graphics/unknown/unknown_60F3BC.4bpp"); +const u8 gUnknown_0860F43C[] = INCBIN_U8("graphics/unknown/unknown_60F43C.4bpp"); +const u8 gUnknown_0860F53C[] = INCBIN_U8("graphics/unknown/unknown_60F53C.4bpp"); +const u8 gUnknown_0860F63C[] = INCBIN_U8("graphics/unknown/unknown_60F63C.4bpp"); +const u8 gUnknown_0860F6BC[] = INCBIN_U8("graphics/unknown/unknown_60F6BC.4bpp"); +const u8 gUnknown_0860F7BC[] = INCBIN_U8("graphics/unknown/unknown_60F7BC.4bpp"); +const u8 gUnknown_0860F83C[] = INCBIN_U8("graphics/unknown/unknown_60F83C.4bpp"); +const u8 gUnknown_0860F93C[] = INCBIN_U8("graphics/unknown/unknown_60F93C.4bpp"); +const u8 gUnknown_0860FA3C[] = INCBIN_U8("graphics/unknown/unknown_60FA3C.4bpp"); +const u8 gUnknown_0861023C[] = INCBIN_U8("graphics/unknown/unknown_61023C.bin"); +const u8 gUnknown_0861033C[] = INCBIN_U8("graphics/unknown/unknown_61033C.4bpp"); +const u16 gUnknown_0861039C[] = INCBIN_U16("graphics/unknown/unknown_61039C.gbapal"); + +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}, + {}, +}; + +const struct CompressedSpriteSheet gUnknown_086103E4[] = +{ + {gUnknown_085B18AC, 0x800, 0x64}, + {}, +}; + +const struct SpritePalette gUnknown_086103F4[] = +{ + {gUnknown_0860F13C, 0x64}, + {gUnknown_0860F15C, 0x65}, + {gUnknown_0860F17C, 0x66}, + {gUnknown_0861039C, 0x67}, + {}, +}; + +u8 (* const sSelect_MenuOptionFuncs[])(void) = +{ + [MENU_SUMMARY] = Select_OptionSummary, + [MENU_RENT] /*Or Deselect*/ = Select_OptionRentDeselect, + [MENU_OTHERS] = Select_OptionOthers +}; + extern const struct BgTemplate gUnknown_08610428[3]; extern const struct WindowTemplate gUnknown_08610434[]; -extern const u8 gUnknown_0861033C[]; -extern const u8 gUnknown_0861023C[]; extern const u16 gUnknown_0861046C[]; -extern const u16 gUnknown_0861039C[]; -extern const struct SpritePalette gUnknown_086103F4[]; -extern const struct SpriteSheet gUnknown_086103BC[]; -extern const struct CompressedSpriteSheet gUnknown_086103E4[]; extern const struct SpriteTemplate gUnknown_086105D8; +extern const struct SpriteTemplate gUnknown_086105F0; +extern const struct SpriteTemplate gUnknown_08610608; +extern const struct SpriteTemplate gUnknown_08610620; +extern const struct SpriteTemplate gUnknown_08610638; +extern const u8 gUnknown_08610479[]; +extern const u8 gUnknown_08610476[]; // gfx extern const u8 gFrontierFactorySelectMenu_Gfx[]; @@ -188,7 +243,7 @@ void sub_819A44C(struct Sprite *sprite) } } -void sub_819A4C8(void) +static void Select_CB2(void) { AnimateSprites(); BuildOamBuffer(); @@ -197,7 +252,7 @@ void sub_819A4C8(void) RunTasks(); } -void sub_819A4E4(void) +static void Select_VblankCb(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -206,11 +261,11 @@ void sub_819A4E4(void) void sub_819A4F8(void) { - gUnknown_0300127C = NULL; - SetMainCallback2(sub_819A514); + sFactorySelectScreen = NULL; + SetMainCallback2(CB2_InitSelectScreen); } -void sub_819A514(void) +static void CB2_InitSelectScreen(void) { u8 taskId; @@ -265,8 +320,8 @@ void sub_819A514(void) LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_0861046C, 0xF0, 8); LoadPalette(gUnknown_0861046C, 0xE0, 10); - if (gUnknown_0300127C->fromSummaryScreen == TRUE) - gPlttBufferUnfaded[228] = gUnknown_0300127C->unk2A4; + if (sFactorySelectScreen->fromSummaryScreen == TRUE) + gPlttBufferUnfaded[228] = sFactorySelectScreen->unk2A4; LoadPalette(gUnknown_0861039C, 0x20, 4); gMain.state++; break; @@ -284,12 +339,12 @@ void sub_819A514(void) LoadCompressedObjectPic(gUnknown_086103E4); ShowBg(0); ShowBg(1); - SetVBlankCallback(sub_819A4E4); + SetVBlankCallback(Select_VblankCb); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); - if (gUnknown_0300127C->fromSummaryScreen == TRUE) + if (sFactorySelectScreen->fromSummaryScreen == TRUE) { - sub_819C5D0(88, 152, 32, 96); + Select_SetWinRegs(88, 152, 32, 96); 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)); @@ -301,67 +356,67 @@ void sub_819A514(void) gMain.state++; break; case 5: - if (gUnknown_0300127C->fromSummaryScreen == TRUE) - gUnknown_0300127C->cursorPos = gUnknown_0203CF20; - sub_819A9AC(); - sub_819AA18(); - if (gUnknown_0300127C->fromSummaryScreen == TRUE) - sub_819BE34(); + if (sFactorySelectScreen->fromSummaryScreen == TRUE) + sFactorySelectScreen->cursorPos = gUnknown_0203CF20; + Select_InitMonsData(); + Select_InitAllSprites(); + if (sFactorySelectScreen->fromSummaryScreen == TRUE) + Select_ShowCheckedMonSprite(); gMain.state++; break; case 6: - PrintSelectMonString(); + Select_PrintSelectMonString(); PutWindowTilemap(2); gMain.state++; break; case 7: - PrintMonCategory(); + Select_PrintMonCategory(); PutWindowTilemap(5); gMain.state++; break; case 8: - PrintMonSpecies(); + Select_PrintMonSpecies(); PutWindowTilemap(1); gMain.state++; break; case 9: - PrintRentalPkmnString(); + Select_PrintRentalPkmnString(); PutWindowTilemap(0); gMain.state++; break; case 10: - gUnknown_0300127C->unk2A1 = CreateTask(sub_819C69C, 0); - if (!gUnknown_0300127C->fromSummaryScreen) + sFactorySelectScreen->palBlendTaskId = CreateTask(Task_SelectBlendPalette, 0); + if (!sFactorySelectScreen->fromSummaryScreen) { - gTasks[gUnknown_0300127C->unk2A1].data[0] = 0; + gTasks[sFactorySelectScreen->palBlendTaskId].data[0] = 0; taskId = CreateTask(Task_HandleSelectionScreenChooseMons, 0); gTasks[taskId].data[0] = 0; } else { - gTasks[gUnknown_0300127C->unk2A1].data[0] = 1; - gUnknown_0300127C->unk2A2 = 0; + gTasks[sFactorySelectScreen->palBlendTaskId].data[0] = 1; + sFactorySelectScreen->unk2A2 = FALSE; taskId = CreateTask(Task_HandleSelectionScreenMenu, 0); gTasks[taskId].data[0] = 13; } - SetMainCallback2(sub_819A4C8); + SetMainCallback2(Select_CB2); break; } } -void sub_819A9AC(void) +static void Select_InitMonsData(void) { u8 i; - if (gUnknown_0300127C != NULL) + if (sFactorySelectScreen != NULL) return; - gUnknown_0300127C = AllocZeroed(sizeof(*gUnknown_0300127C)); - gUnknown_0300127C->cursorPos = 0; - gUnknown_0300127C->selectingMonsState = 1; - gUnknown_0300127C->fromSummaryScreen = FALSE; + sFactorySelectScreen = AllocZeroed(sizeof(*sFactorySelectScreen)); + sFactorySelectScreen->cursorPos = 0; + sFactorySelectScreen->selectingMonsState = 1; + sFactorySelectScreen->fromSummaryScreen = FALSE; for (i = 0; i < SELECTABLE_MONS_COUNT; i++) - gUnknown_0300127C->mons[i].selectedId = 0; + sFactorySelectScreen->mons[i].selectedId = 0; if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_TENT) CreateFrontierFactorySelectableMons(0); @@ -369,157 +424,153 @@ void sub_819A9AC(void) CreateTentFactorySelectableMons(0); } -extern const struct SpriteTemplate gUnknown_086105F0; -extern const struct SpriteTemplate gUnknown_08610608; -extern const struct SpriteTemplate gUnknown_08610620; - -void sub_819AA18(void) +static void Select_InitAllSprites(void) { u8 i, cursorPos; s16 x; for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { - gUnknown_0300127C->mons[i].spriteId = CreateSprite(&gUnknown_086105D8, (35 * i) + 32, 64, 1); - gSprites[gUnknown_0300127C->mons[i].spriteId].data[0] = 0; - SetBallSpritePaletteNum(i); + sFactorySelectScreen->mons[i].spriteId = CreateSprite(&gUnknown_086105D8, (35 * i) + 32, 64, 1); + gSprites[sFactorySelectScreen->mons[i].spriteId].data[0] = 0; + Select_SetBallSpritePaletteNum(i); } - cursorPos = gUnknown_0300127C->cursorPos; - x = gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].pos1.x; - gUnknown_0300127C->cursorSpriteId = CreateSprite(&gUnknown_086105F0, x, 88, 0); - gUnknown_0300127C->menuCursor1SpriteId = CreateSprite(&gUnknown_08610608, 176, 112, 0); - gUnknown_0300127C->menuCursor2SpriteId = CreateSprite(&gUnknown_08610620, 176, 144, 0); + cursorPos = sFactorySelectScreen->cursorPos; + x = gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].pos1.x; + sFactorySelectScreen->cursorSpriteId = CreateSprite(&gUnknown_086105F0, x, 88, 0); + sFactorySelectScreen->menuCursor1SpriteId = CreateSprite(&gUnknown_08610608, 176, 112, 0); + sFactorySelectScreen->menuCursor2SpriteId = CreateSprite(&gUnknown_08610620, 176, 144, 0); - gSprites[gUnknown_0300127C->menuCursor1SpriteId].invisible = 1; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].invisible = 1; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = 1; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = 1; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].centerToCornerVecX = 0; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].centerToCornerVecY = 0; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].centerToCornerVecX = 0; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].centerToCornerVecY = 0; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].centerToCornerVecY = 0; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].centerToCornerVecY = 0; } -void sub_819AB40(void) +static void Select_DestroyAllSprites(void) { u8 i; for (i = 0; i < SELECTABLE_MONS_COUNT; i++) - DestroySprite(&gSprites[gUnknown_0300127C->mons[i].spriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->mons[i].spriteId]); - DestroySprite(&gSprites[gUnknown_0300127C->cursorSpriteId]); - DestroySprite(&gSprites[gUnknown_0300127C->menuCursor1SpriteId]); - DestroySprite(&gSprites[gUnknown_0300127C->menuCursor2SpriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->cursorSpriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->menuCursor1SpriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->menuCursor2SpriteId]); } -void UpdateBallCursorPosition(s8 direction) +static void Select_UpdateBallCursorPosition(s8 direction) { u8 cursorPos; if (direction > 0) // Move cursor right. { - if (gUnknown_0300127C->cursorPos != SELECTABLE_MONS_COUNT - 1) - gUnknown_0300127C->cursorPos++; + if (sFactorySelectScreen->cursorPos != SELECTABLE_MONS_COUNT - 1) + sFactorySelectScreen->cursorPos++; else - gUnknown_0300127C->cursorPos = 0; + sFactorySelectScreen->cursorPos = 0; } else // Move cursor left. { - if (gUnknown_0300127C->cursorPos != 0) - gUnknown_0300127C->cursorPos--; + if (sFactorySelectScreen->cursorPos != 0) + sFactorySelectScreen->cursorPos--; else - gUnknown_0300127C->cursorPos = SELECTABLE_MONS_COUNT - 1; + sFactorySelectScreen->cursorPos = SELECTABLE_MONS_COUNT - 1; } - cursorPos = gUnknown_0300127C->cursorPos; - gSprites[gUnknown_0300127C->cursorSpriteId].pos1.x = gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].pos1.x; + cursorPos = sFactorySelectScreen->cursorPos; + gSprites[sFactorySelectScreen->cursorSpriteId].pos1.x = gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].pos1.x; } -void UpdateMenuCursorPosition(s8 direction) +static void Select_UpdateMenuCursorPosition(s8 direction) { if (direction > 0) // Move cursor down. { - if (gUnknown_0300127C->menuCursorPos != MENU_OPTIONS_COUNT - 1) - gUnknown_0300127C->menuCursorPos++; + if (sFactorySelectScreen->menuCursorPos != MENU_OPTIONS_COUNT - 1) + sFactorySelectScreen->menuCursorPos++; else - gUnknown_0300127C->menuCursorPos = 0; + sFactorySelectScreen->menuCursorPos = 0; } else // Move cursor up. { - if (gUnknown_0300127C->menuCursorPos != 0) - gUnknown_0300127C->menuCursorPos--; + if (sFactorySelectScreen->menuCursorPos != 0) + sFactorySelectScreen->menuCursorPos--; else - gUnknown_0300127C->menuCursorPos = MENU_OPTIONS_COUNT - 1; + sFactorySelectScreen->menuCursorPos = MENU_OPTIONS_COUNT - 1; } - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.y = (sFactorySelectScreen->menuCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.y = (sFactorySelectScreen->menuCursorPos * 16) + 112; } -void UpdateYesNoCursorPosition(s8 direction) +static void Select_UpdateYesNoCursorPosition(s8 direction) { if (direction > 0) // Move cursor down. { - if (gUnknown_0300127C->yesNoCursorPos != 1) - gUnknown_0300127C->yesNoCursorPos++; + if (sFactorySelectScreen->yesNoCursorPos != 1) + sFactorySelectScreen->yesNoCursorPos++; else - gUnknown_0300127C->yesNoCursorPos = 0; + sFactorySelectScreen->yesNoCursorPos = 0; } else // Move cursor up. { - if (gUnknown_0300127C->yesNoCursorPos != 0) - gUnknown_0300127C->yesNoCursorPos--; + if (sFactorySelectScreen->yesNoCursorPos != 0) + sFactorySelectScreen->yesNoCursorPos--; else - gUnknown_0300127C->yesNoCursorPos = 1; + sFactorySelectScreen->yesNoCursorPos = 1; } - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = (gUnknown_0300127C->yesNoCursorPos * 16) + 112; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = (gUnknown_0300127C->yesNoCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.y = (sFactorySelectScreen->yesNoCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.y = (sFactorySelectScreen->yesNoCursorPos * 16) + 112; } -void HandleMonSelectionChange(void) +static void Select_HandleMonSelectionChange(void) { u8 i, paletteNum; - u8 cursorPos = gUnknown_0300127C->cursorPos; - if (gUnknown_0300127C->mons[cursorPos].selectedId) // Deselect a mon. + u8 cursorPos = sFactorySelectScreen->cursorPos; + if (sFactorySelectScreen->mons[cursorPos].selectedId) // Deselect a mon. { paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); - if (gUnknown_0300127C->selectingMonsState == 3 && gUnknown_0300127C->mons[cursorPos].selectedId == 1) + if (sFactorySelectScreen->selectingMonsState == 3 && sFactorySelectScreen->mons[cursorPos].selectedId == 1) { for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { - if (gUnknown_0300127C->mons[i].selectedId == 2) + if (sFactorySelectScreen->mons[i].selectedId == 2) break; } if (i == SELECTABLE_MONS_COUNT) return; else - gUnknown_0300127C->mons[i].selectedId = 1; + sFactorySelectScreen->mons[i].selectedId = 1; } - gUnknown_0300127C->mons[cursorPos].selectedId = 0; - gUnknown_0300127C->selectingMonsState--; + sFactorySelectScreen->mons[cursorPos].selectedId = 0; + sFactorySelectScreen->selectingMonsState--; } else // Select a mon. { paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); - gUnknown_0300127C->mons[cursorPos].selectedId = gUnknown_0300127C->selectingMonsState; - gUnknown_0300127C->selectingMonsState++; + sFactorySelectScreen->mons[cursorPos].selectedId = sFactorySelectScreen->selectingMonsState; + sFactorySelectScreen->selectingMonsState++; } - gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].oam.paletteNum = paletteNum; + gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].oam.paletteNum = paletteNum; } -void SetBallSpritePaletteNum(u8 id) +static void Select_SetBallSpritePaletteNum(u8 id) { u8 palNum; - if (gUnknown_0300127C->mons[id].selectedId) + if (sFactorySelectScreen->mons[id].selectedId) palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); else palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); - gSprites[gUnknown_0300127C->mons[id].spriteId].oam.paletteNum = palNum; + gSprites[sFactorySelectScreen->mons[id].spriteId].oam.paletteNum = palNum; } -void Task_FromSelectScreenToSummaryScreen(u8 taskId) +static void Task_FromSelectScreenToSummaryScreen(u8 taskId) { u8 i; u8 currMonId; @@ -534,9 +585,9 @@ void Task_FromSelectScreenToSummaryScreen(u8 taskId) case 7: if (!gPaletteFade.active) { - DestroyTask(gUnknown_0300127C->unk2A1); - sub_819F444(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0); - sub_819AB40(); + DestroyTask(sFactorySelectScreen->palBlendTaskId); + sub_819F444(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0); + Select_DestroyAllSprites(); FREE_AND_SET_NULL(gUnknown_0203CE2C); FREE_AND_SET_NULL(gUnknown_0203CE30); FREE_AND_SET_NULL(gUnknown_0203CE34); @@ -546,21 +597,21 @@ void Task_FromSelectScreenToSummaryScreen(u8 taskId) } break; case 8: - gUnknown_0300127C->unk2A4 = gPlttBufferUnfaded[228]; + sFactorySelectScreen->unk2A4 = gPlttBufferUnfaded[228]; DestroyTask(taskId); - gUnknown_0300127C->fromSummaryScreen = TRUE; - currMonId = gUnknown_0300127C->cursorPos; + sFactorySelectScreen->fromSummaryScreen = TRUE; + currMonId = sFactorySelectScreen->cursorPos; sFactorySelectMons = AllocZeroed(sizeof(struct Pokemon) * SELECTABLE_MONS_COUNT); for (i = 0; i < SELECTABLE_MONS_COUNT; i++) - sFactorySelectMons[i] = gUnknown_0300127C->mons[i].monData; - ShowPokemonSummaryScreen(1, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, sub_819A514); + sFactorySelectMons[i] = sFactorySelectScreen->mons[i].monData; + ShowPokemonSummaryScreen(1, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, CB2_InitSelectScreen); break; } } -void Task_CloseSelectionScreen(u8 taskId) +static void Task_CloseSelectionScreen(u8 taskId) { - if (gUnknown_0300127C->unk2A0 != 1) + if (sFactorySelectScreen->unk2A0 != 1) { switch (gTasks[taskId].data[0]) { @@ -571,13 +622,13 @@ void Task_CloseSelectionScreen(u8 taskId) case 1: if (!UpdatePaletteFade()) { - CopySelectedMonsToPlayerParty(); - DestroyTask(gUnknown_0300127C->unk2A1); - sub_819AB40(); + Select_CopyMonsToPlayerParty(); + DestroyTask(sFactorySelectScreen->palBlendTaskId); + Select_DestroyAllSprites(); FREE_AND_SET_NULL(gUnknown_0203CE2C); FREE_AND_SET_NULL(gUnknown_0203CE34); FREE_AND_SET_NULL(gUnknown_0203CE38); - FREE_AND_SET_NULL(gUnknown_0300127C); + FREE_AND_SET_NULL(sFactorySelectScreen); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldContinueScript); DestroyTask(taskId); @@ -587,9 +638,9 @@ void Task_CloseSelectionScreen(u8 taskId) } } -void Task_HandleSelectionScreenYesNo(u8 taskId) +static void Task_HandleSelectionScreenYesNo(u8 taskId) { - if (gUnknown_0300127C->unk2A0 != 1) + if (sFactorySelectScreen->unk2A0 != 1) { switch (gTasks[taskId].data[0]) { @@ -598,14 +649,14 @@ void Task_HandleSelectionScreenYesNo(u8 taskId) gTasks[taskId].data[0] = 4; break; case 4: - sub_819B8D4(); + Select_ShowYesNoOptions(); gTasks[taskId].data[0] = 5; break; case 5: if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if (gUnknown_0300127C->yesNoCursorPos == 0) + if (sFactorySelectScreen->yesNoCursorPos == 0) { sub_819C568(); gTasks[taskId].data[0] = 0; @@ -615,7 +666,7 @@ void Task_HandleSelectionScreenYesNo(u8 taskId) { sub_819B958(4); sub_819BC9C(); - gUnknown_0300127C->unk2A2 = 1; + sFactorySelectScreen->unk2A2 = TRUE; gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } @@ -625,39 +676,39 @@ void Task_HandleSelectionScreenYesNo(u8 taskId) PlaySE(SE_SELECT); sub_819B958(4); sub_819BC9C(); - gUnknown_0300127C->unk2A2 = 1; + sFactorySelectScreen->unk2A2 = TRUE; gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } else if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - UpdateYesNoCursorPosition(-1); + Select_UpdateYesNoCursorPosition(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - UpdateYesNoCursorPosition(1); + Select_UpdateYesNoCursorPosition(1); } break; } } } -void Task_HandleSelectionScreenMenu(u8 taskId) +static void Task_HandleSelectionScreenMenu(u8 taskId) { switch (gTasks[taskId].data[0]) { case 2: - if (!gUnknown_0300127C->fromSummaryScreen) - sub_819F2B4(&gUnknown_0300127C->unk298.field1, &gUnknown_0300127C->unk2A0, 0); + if (!sFactorySelectScreen->fromSummaryScreen) + sub_819F2B4(&sFactorySelectScreen->unk294[1].field1, &sFactorySelectScreen->unk2A0, 0); gTasks[taskId].data[0] = 9; break; case 9: - if (gUnknown_0300127C->unk2A0 != 1) + if (sFactorySelectScreen->unk2A0 != 1) { - sub_819B844(); - gUnknown_0300127C->fromSummaryScreen = FALSE; + Select_ShowMenuOptions(); + sFactorySelectScreen->fromSummaryScreen = FALSE; gTasks[taskId].data[0] = 3; } break; @@ -666,10 +717,10 @@ void Task_HandleSelectionScreenMenu(u8 taskId) { u8 retVal; PlaySE(SE_SELECT); - retVal = sub_819BC04(); + retVal = Select_RunMenuOptionFunc(); if (retVal == 1) { - gUnknown_0300127C->unk2A2 = 1; + sFactorySelectScreen->unk2A2 = TRUE; gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } @@ -692,45 +743,45 @@ void Task_HandleSelectionScreenMenu(u8 taskId) else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - sub_819F3F8(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0, 0); + sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, 0); sub_819B958(3); - gUnknown_0300127C->unk2A2 = 1; + sFactorySelectScreen->unk2A2 = TRUE; gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } else if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - UpdateMenuCursorPosition(-1); + Select_UpdateMenuCursorPosition(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - UpdateMenuCursorPosition(1); + Select_UpdateMenuCursorPosition(1); } break; case 12: if (!gPaletteFade.active) { - if (gUnknown_0300127C->fromSummaryScreen == TRUE) + if (sFactorySelectScreen->fromSummaryScreen == TRUE) { - gPlttBufferFaded[228] = gUnknown_0300127C->unk2A4; + gPlttBufferFaded[228] = sFactorySelectScreen->unk2A4; gPlttBufferUnfaded[228] = gPlttBufferUnfaded[244]; } - gUnknown_0300127C->fromSummaryScreen = FALSE; + sFactorySelectScreen->fromSummaryScreen = FALSE; gTasks[taskId].data[0] = 3; } break; case 13: - sub_819B844(); + Select_ShowMenuOptions(); gTasks[taskId].data[0] = 12; break; } } -void Task_HandleSelectionScreenChooseMons(u8 taskId) +static void Task_HandleSelectionScreenChooseMons(u8 taskId) { - if (gUnknown_0300127C->unk2A0 != 1) + if (sFactorySelectScreen->unk2A0 != 1) { switch (gTasks[taskId].data[0]) { @@ -738,39 +789,39 @@ void Task_HandleSelectionScreenChooseMons(u8 taskId) if (!gPaletteFade.active) { gTasks[taskId].data[0] = 1; - gUnknown_0300127C->unk2A2 = 1; + sFactorySelectScreen->unk2A2 = TRUE; } break; case 1: if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gUnknown_0300127C->unk2A2 = 0; + sFactorySelectScreen->unk2A2 = FALSE; gTasks[taskId].data[0] = 2; gTasks[taskId].func = Task_HandleSelectionScreenMenu; } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) { PlaySE(SE_SELECT); - UpdateBallCursorPosition(-1); - PrintMonCategory(); - PrintMonSpecies(); + Select_UpdateBallCursorPosition(-1); + Select_PrintMonCategory(); + Select_PrintMonSpecies(); } else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { PlaySE(SE_SELECT); - UpdateBallCursorPosition(1); - PrintMonCategory(); - PrintMonSpecies(); + Select_UpdateBallCursorPosition(1); + Select_PrintMonCategory(); + Select_PrintMonSpecies(); } break; case 11: if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - sub_819F3F8(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0, 0); - PrintSelectMonString(); - gUnknown_0300127C->unk2A2 = 1; + sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, 0); + Select_PrintSelectMonString(); + sFactorySelectScreen->unk2A2 = TRUE; gTasks[taskId].data[0] = 1; } break; @@ -778,7 +829,7 @@ void Task_HandleSelectionScreenChooseMons(u8 taskId) } } -void CreateFrontierFactorySelectableMons(u8 firstMonId) +static void CreateFrontierFactorySelectableMons(u8 firstMonId) { u8 i, j = 0; u8 ivs = 0; @@ -802,12 +853,12 @@ void CreateFrontierFactorySelectableMons(u8 firstMonId) for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { u16 monSetId = gSaveBlock2Ptr->frontier.field_E70[i].monId; - gUnknown_0300127C->mons[i + firstMonId].monSetId = monSetId; + sFactorySelectScreen->mons[i + firstMonId].monSetId = monSetId; if (i < var_28) ivs = sub_81A6CA8(var_2C + 1, 0); else ivs = sub_81A6CA8(var_2C, 0); - CreateMonWithEVSpreadPersonalityOTID(&gUnknown_0300127C->mons[i + firstMonId].monData, + CreateMonWithEVSpreadPersonalityOTID(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].species, level, gFacilityTrainerMons[monSetId].nature, @@ -816,13 +867,13 @@ void CreateFrontierFactorySelectableMons(u8 firstMonId) otId); happiness = 0; for (j = 0; j < 4; j++) - SetMonMoveAvoidReturn(&gUnknown_0300127C->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j); - SetMonData(&gUnknown_0300127C->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); - SetMonData(&gUnknown_0300127C->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]); + SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]); } } -void CreateTentFactorySelectableMons(u8 firstMonId) +static void CreateTentFactorySelectableMons(u8 firstMonId) { u8 i, j; u8 ivs = 0; @@ -836,8 +887,8 @@ void CreateTentFactorySelectableMons(u8 firstMonId) for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { u16 monSetId = gSaveBlock2Ptr->frontier.field_E70[i].monId; - gUnknown_0300127C->mons[i + firstMonId].monSetId = monSetId; - CreateMonWithEVSpreadPersonalityOTID(&gUnknown_0300127C->mons[i + firstMonId].monData, + sFactorySelectScreen->mons[i + firstMonId].monSetId = monSetId; + CreateMonWithEVSpreadPersonalityOTID(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].species, level, gFacilityTrainerMons[monSetId].nature, @@ -846,13 +897,13 @@ void CreateTentFactorySelectableMons(u8 firstMonId) otId); happiness = 0; for (j = 0; j < 4; j++) - SetMonMoveAvoidReturn(&gUnknown_0300127C->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j); - SetMonData(&gUnknown_0300127C->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); - SetMonData(&gUnknown_0300127C->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]); + SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]); } } -void CopySelectedMonsToPlayerParty(void) +static void Select_CopyMonsToPlayerParty(void) { u8 i, j; @@ -860,10 +911,10 @@ void CopySelectedMonsToPlayerParty(void) { for (j = 0; j < SELECTABLE_MONS_COUNT; j++) { - if (gUnknown_0300127C->mons[j].selectedId == i + 1) + if (sFactorySelectScreen->mons[j].selectedId == i + 1) { - gPlayerParty[i] = gUnknown_0300127C->mons[j].monData; - gSaveBlock2Ptr->frontier.field_E70[i].monId = gUnknown_0300127C->mons[j].monSetId; + gPlayerParty[i] = sFactorySelectScreen->mons[j].monData; + gSaveBlock2Ptr->frontier.field_E70[i].monId = sFactorySelectScreen->mons[j].monSetId; gSaveBlock2Ptr->frontier.field_E70[i].personality = GetMonData(&gPlayerParty[i].box, MON_DATA_PERSONALITY, NULL); gSaveBlock2Ptr->frontier.field_E70[i].abilityBit = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ALT_ABILITY, NULL); gSaveBlock2Ptr->frontier.field_E70[i].ivs = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ATK_IV, NULL); @@ -874,80 +925,77 @@ void CopySelectedMonsToPlayerParty(void) CalculatePlayerPartyCount(); } -void sub_819B844(void) +static void Select_ShowMenuOptions(void) { - if (!gUnknown_0300127C->fromSummaryScreen) - gUnknown_0300127C->menuCursorPos = 0; + if (!sFactorySelectScreen->fromSummaryScreen) + sFactorySelectScreen->menuCursorPos = 0; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.x = 176; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.x = 208; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.x = 176; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.y = (sFactorySelectScreen->menuCursorPos * 16) + 112; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.x = 208; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.y = (sFactorySelectScreen->menuCursorPos * 16) + 112; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].invisible = 0; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].invisible = 0; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = 0; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = 0; - PrintSelectableMenuOptions(); + Select_PrintMenuOptions(); } -void sub_819B8D4(void) +static void Select_ShowYesNoOptions(void) { - gUnknown_0300127C->yesNoCursorPos = 0; + sFactorySelectScreen->yesNoCursorPos = 0; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.x = 176; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = 112; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.x = 208; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = 112; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.x = 176; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.y = 112; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.x = 208; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].pos1.y = 112; - gSprites[gUnknown_0300127C->menuCursor1SpriteId].invisible = 0; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].invisible = 0; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = 0; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = 0; - PrintSelectableYesNo(); + Select_PrintYesNoOptions(); } -void sub_819B958(u8 windowId) +static void sub_819B958(u8 windowId) { - gSprites[gUnknown_0300127C->menuCursor1SpriteId].invisible = 1; - gSprites[gUnknown_0300127C->menuCursor2SpriteId].invisible = 1; + gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = 1; + gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = 1; FillWindowPixelBuffer(windowId, 0); CopyWindowToVram(windowId, 2); ClearWindowTilemap(windowId); } -void PrintRentalPkmnString(void) +static void Select_PrintRentalPkmnString(void) { FillWindowPixelBuffer(0, 0); PrintTextOnWindow(0, 1, gText_RentalPkmn2, 2, 1, 0, NULL); CopyWindowToVram(0, 3); } -extern const u8 gUnknown_08610479[]; -extern const u8 gUnknown_08610476[]; - -void PrintMonSpecies(void) +static void Select_PrintMonSpecies(void) { u16 species; u8 x; - u8 monId = gUnknown_0300127C->cursorPos; + u8 monId = sFactorySelectScreen->cursorPos; FillWindowPixelBuffer(1, 0); - species = GetMonData(&gUnknown_0300127C->mons[monId].monData, MON_DATA_SPECIES, NULL); + species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); x = GetStringRightAlignXOffset(1, gStringVar4, 86); AddTextPrinterParameterized3(1, 1, x, 1, gUnknown_08610479, 0, gStringVar4); CopyWindowToVram(1, 2); } -void PrintSelectMonString(void) +static void Select_PrintSelectMonString(void) { const u8 *str = NULL; FillWindowPixelBuffer(2, 0); - if (gUnknown_0300127C->selectingMonsState == 1) + if (sFactorySelectScreen->selectingMonsState == 1) str = gText_SelectFirstPkmn; - else if (gUnknown_0300127C->selectingMonsState == 2) + else if (sFactorySelectScreen->selectingMonsState == 2) str = gText_SelectSecondPkmn; - else if (gUnknown_0300127C->selectingMonsState == 3) + else if (sFactorySelectScreen->selectingMonsState == 3) str = gText_SelectThirdPkmn; else str = gText_TheseThreePkmnOkay; @@ -956,16 +1004,16 @@ void PrintSelectMonString(void) CopyWindowToVram(2, 2); } -void PrintCantSelectSameMon(void) +static void Select_PrintCantSelectSameMon(void) { FillWindowPixelBuffer(2, 0); PrintTextOnWindow(2, 1, gText_CantSelectSamePkmn, 2, 5, 0, NULL); CopyWindowToVram(2, 2); } -void PrintSelectableMenuOptions(void) +static void Select_PrintMenuOptions(void) { - u8 selectedId = gUnknown_0300127C->mons[gUnknown_0300127C->cursorPos].selectedId; + u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId; PutWindowTilemap(3); FillWindowPixelBuffer(3, 0); @@ -979,7 +1027,7 @@ void PrintSelectableMenuOptions(void) CopyWindowToVram(3, 3); } -void PrintSelectableYesNo(void) +static void Select_PrintYesNoOptions(void) { PutWindowTilemap(4); FillWindowPixelBuffer(4, 0); @@ -988,72 +1036,70 @@ void PrintSelectableYesNo(void) CopyWindowToVram(4, 3); } -extern u8 (* const gUnknown_0861041C[])(void); - -u8 sub_819BC04(void) +static u8 Select_RunMenuOptionFunc(void) { - gUnknown_030062E8 = gUnknown_0861041C[gUnknown_0300127C->menuCursorPos]; + gUnknown_030062E8 = sSelect_MenuOptionFuncs[sFactorySelectScreen->menuCursorPos]; return gUnknown_030062E8(); } -u8 sub_819BC30(void) +static u8 Select_OptionRentDeselect(void) { - u8 selectedId = gUnknown_0300127C->mons[gUnknown_0300127C->cursorPos].selectedId; - u16 monSetId = gUnknown_0300127C->mons[gUnknown_0300127C->cursorPos].monSetId; - if (selectedId == 0 && !sub_819C634(monSetId)) + u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId; + u16 monSetId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monSetId; + if (selectedId == 0 && !Select_AreSpeciesValid(monSetId)) { - PrintCantSelectSameMon(); + Select_PrintCantSelectSameMon(); sub_819B958(3); return 3; } else { - sub_819F3F8(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0, 0); - HandleMonSelectionChange(); - PrintSelectMonString(); + sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, 0); + Select_HandleMonSelectionChange(); + Select_PrintSelectMonString(); sub_819B958(3); - if (gUnknown_0300127C->selectingMonsState > 3) + if (sFactorySelectScreen->selectingMonsState > 3) return 2; else return 1; } } -u8 sub_819BC9C(void) +static u8 sub_819BC9C(void) { sub_819C568(); - HandleMonSelectionChange(); - PrintSelectMonString(); + Select_HandleMonSelectionChange(); + Select_PrintSelectMonString(); sub_819B958(3); - if (gUnknown_0300127C->selectingMonsState > 3) + if (sFactorySelectScreen->selectingMonsState > 3) return 2; else return 1; } -u8 sub_819BCCC(void) +static u8 Select_OptionSummary(void) { return 0; } -u8 sub_819BCD0(void) +static u8 Select_OptionOthers(void) { - sub_819F3F8(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0, 0); + sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, 0); sub_819B958(3); return 1; } -void PrintMonCategory(void) +static void Select_PrintMonCategory(void) { u16 species; u8 text[30]; u8 x; - u8 monId = gUnknown_0300127C->cursorPos; + u8 monId = sFactorySelectScreen->cursorPos; if (monId < SELECTABLE_MONS_COUNT) { PutWindowTilemap(5); FillWindowPixelBuffer(5, 0); - species = GetMonData(&gUnknown_0300127C->mons[monId].monData, MON_DATA_SPECIES, NULL); + species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); x = GetStringRightAlignXOffset(1, text, 0x76); PrintTextOnWindow(5, 1, text, x, 1, 0, NULL); @@ -1063,43 +1109,305 @@ void PrintMonCategory(void) void sub_819BD70(void) { - u8 monId = gUnknown_0300127C->cursorPos; - struct Pokemon *mon = &gUnknown_0300127C->mons[monId].monData; + u8 monId = sFactorySelectScreen->cursorPos; + struct Pokemon *mon = &sFactorySelectScreen->mons[monId].monData; u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - gUnknown_0300127C->unk298.field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - gSprites[gUnknown_0300127C->unk298.field0].centerToCornerVecX = 0; - gSprites[gUnknown_0300127C->unk298.field0].centerToCornerVecY = 0; + sFactorySelectScreen->unk294[1].field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecY = 0; - gUnknown_0300127C->unk2A0 = 0; + sFactorySelectScreen->unk2A0 = 0; } -extern const struct SpriteTemplate gUnknown_08610638; - void sub_819BE20(u8 arg0) { - gUnknown_0300127C->unk2A0 = arg0; + sFactorySelectScreen->unk2A0 = arg0; } -void sub_819BE34(void) +static void Select_ShowCheckedMonSprite(void) { struct Pokemon *mon; u16 species; u32 personality, otId; - gUnknown_0300127C->unk298.field1 = CreateSprite(&gUnknown_08610638, 120, 64, 1); - StartSpriteAffineAnim(&gSprites[gUnknown_0300127C->unk298.field1], 2); + sFactorySelectScreen->unk294[1].field1 = CreateSprite(&gUnknown_08610638, 120, 64, 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[1].field1], 2); - mon = &gUnknown_0300127C->mons[gUnknown_0300127C->cursorPos].monData; + mon = &sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monData; species = GetMonData(mon, MON_DATA_SPECIES, NULL); personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - gUnknown_0300127C->unk298.field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - gSprites[gUnknown_0300127C->unk298.field0].centerToCornerVecX = 0; - gSprites[gUnknown_0300127C->unk298.field0].centerToCornerVecY = 0; + sFactorySelectScreen->unk294[1].field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecY = 0; - gSprites[gUnknown_0300127C->unk298.field1].invisible = 1; + gSprites[sFactorySelectScreen->unk294[1].field1].invisible = 1; +} + +static void Select_ShowChosenMonsSprites(void) +{ + u8 i, j; + + for (i = 0; i < 3; i++) + { + for (j = 0; j < SELECTABLE_MONS_COUNT; j++) + { + if (sFactorySelectScreen->mons[j].selectedId == i + 1) + { + struct Pokemon *mon = &sFactorySelectScreen->mons[j].monData; + u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); + u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); + u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL); + + sFactorySelectScreen->unk294[i].field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, (i * 72) + 16, 32, i + 13, 0xFFFF); + gSprites[sFactorySelectScreen->unk294[i].field0].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->unk294[i].field0].centerToCornerVecY = 0; + break; + } + } + } + sFactorySelectScreen->unk2A0 = 0; +} + +static void sub_819C040(struct Sprite *sprite) +{ + u8 taskId; + + if (sprite->affineAnimEnded + && gSprites[sFactorySelectScreen->unk294[0].field1].affineAnimEnded + && gSprites[sFactorySelectScreen->unk294[2].field1].affineAnimEnded) + { + sprite->invisible = 1; + gSprites[sFactorySelectScreen->unk294[0].field1].invisible = 1; + gSprites[sFactorySelectScreen->unk294[2].field1].invisible = 1; + + taskId = CreateTask(sub_819C1D0, 1); + gTasks[taskId].func(taskId); + + sprite->callback = SpriteCallbackDummy; + } +} + +static void sub_819C100(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded + && gSprites[sFactorySelectScreen->unk294[0].field1].affineAnimEnded + && gSprites[sFactorySelectScreen->unk294[2].field1].affineAnimEnded) + { + FreeOamMatrix(sprite->oam.matrixNum); + FreeOamMatrix(gSprites[sFactorySelectScreen->unk294[0].field1].oam.matrixNum); + FreeOamMatrix(gSprites[sFactorySelectScreen->unk294[2].field1].oam.matrixNum); + + sFactorySelectScreen->unk2A0 = 0; + + DestroySprite(&gSprites[sFactorySelectScreen->unk294[0].field1]); + DestroySprite(&gSprites[sFactorySelectScreen->unk294[2].field1]); + DestroySprite(sprite); + } +} + +static void sub_819C1D0(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + case 0: + task->data[3] = 16; + task->data[24] = 224; // BUG: writing outside the array's bounds. + task->data[5] = 64; + task->data[8] = 65; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WINHV_COORDS(task->data[3], task->data[24])); + SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + break; + case 1: + 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)); + break; + case 2: + task->data[5] -= 4; + task->data[8] += 4; + if (task->data[5] <= 32 || task->data[8] >= 96) + { + task->data[5] = 32; + task->data[8] = 96; + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + } + SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(task->data[5], task->data[8])); + if (task->data[5] != 32) + return; + break; + default: + DestroyTask(taskId); + Select_ShowChosenMonsSprites(); + return; + } + task->data[0]++; +} + +static void sub_819C2D4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + default: + HideBg(3); + gSprites[sFactorySelectScreen->unk294[1].field1].invisible = 0; + gSprites[sFactorySelectScreen->unk294[1].field1].callback = sub_819C100; + gSprites[sFactorySelectScreen->unk294[0].field1].invisible = 0; + gSprites[sFactorySelectScreen->unk294[0].field1].callback = SpriteCallbackDummy; + gSprites[sFactorySelectScreen->unk294[2].field1].invisible = 0; + gSprites[sFactorySelectScreen->unk294[2].field1].callback = SpriteCallbackDummy; + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[1].field1], 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[0].field1], 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[2].field1], 1); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + DestroyTask(taskId); + break; + case 0: + task->data[3] = 16; + task->data[24] = 224; // BUG: writing outside the array's bounds. + task->data[5] = 32; + task->data[8] = 96; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WINHV_COORDS(task->data[3], task->data[24])); + SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + task->data[0]++; + break; + case 1: + task->data[5] += 4; + task->data[8] -= 4; + if (task->data[5] >= 64 || task->data[8] <= 65) + { + task->data[5] = 64; + task->data[8] = 65; + } + SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(task->data[5], task->data[8])); + if (task->data[5] == 64) + task->data[0]++; + break; + } +} + +static void sub_819C4B4(void) +{ + sFactorySelectScreen->unk294[1].field1 = CreateSprite(&gUnknown_08610638, 120, 64, 1); + sFactorySelectScreen->unk294[0].field1 = CreateSprite(&gUnknown_08610638, 44, 64, 1); + sFactorySelectScreen->unk294[2].field1 = CreateSprite(&gUnknown_08610638, 196, 64, 1); + + gSprites[sFactorySelectScreen->unk294[1].field1].callback = sub_819C040; + gSprites[sFactorySelectScreen->unk294[0].field1].callback = SpriteCallbackDummy; + gSprites[sFactorySelectScreen->unk294[2].field1].callback = SpriteCallbackDummy; + + sFactorySelectScreen->unk2A0 = 1; +} + +static void sub_819C568(void) +{ + u8 taskId; + + FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[0].field0); + FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[1].field0); + FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[2].field0); + + taskId = CreateTask(sub_819C2D4, 1); + gTasks[taskId].func(taskId); + + sFactorySelectScreen->unk2A0 = 1; +} + +static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V) +{ + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WINHV_COORDS(mWin0H, nWin0H)); + SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(mWin0V, nWin0V)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); +} + +static bool32 Select_AreSpeciesValid(u16 monSetId) +{ + u8 i, j; + u32 species = gFacilityTrainerMons[monSetId].species; + u8 selectState = sFactorySelectScreen->selectingMonsState; + + for (i = 1; i < selectState; i++) + { + for (j = 0; j < SELECTABLE_MONS_COUNT; j++) + { + if (sFactorySelectScreen->mons[j].selectedId == i) + { + if (gFacilityTrainerMons[sFactorySelectScreen->mons[j].monSetId].species == species) + return FALSE; + + break; + } + } + } + + return TRUE; +} + +static void Task_SelectBlendPalette(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + sFactorySelectScreen->unk2A7 = 0; + sFactorySelectScreen->unk2A8 = 0; + sFactorySelectScreen->unk2A6 = TRUE; + gTasks[taskId].data[0] = 1; + break; + case 1: + if (sFactorySelectScreen->unk2A2) + { + if (sFactorySelectScreen->unk2A9) + { + gTasks[taskId].data[0] = 2; + } + else + { + sFactorySelectScreen->unk2A7++; + if (sFactorySelectScreen->unk2A7 > 6) + { + sFactorySelectScreen->unk2A7 = 0; + if (!sFactorySelectScreen->unk2A6) + sFactorySelectScreen->unk2A8--; + else + sFactorySelectScreen->unk2A8++; + } + BlendPalettes(0x4000, sFactorySelectScreen->unk2A8, 0); + if (sFactorySelectScreen->unk2A8 > 5) + { + sFactorySelectScreen->unk2A6 = FALSE; + } + else if (sFactorySelectScreen->unk2A8 == 0) + { + gTasks[taskId].data[0] = 2; + sFactorySelectScreen->unk2A6 = TRUE; + } + } + } + break; + case 2: + if (sFactorySelectScreen->unk2A9 > 14) + { + sFactorySelectScreen->unk2A9 = 0; + gTasks[taskId].data[0] = 1; + } + else + { + sFactorySelectScreen->unk2A9++; + } + break; + } } diff --git a/sym_bss.txt b/sym_bss.txt index 0b861774b..9294c5177 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -78,8 +78,7 @@ gUnknown_03001278: @ 3001278 gUnknown_03001279: @ 3001279 .space 0x3 -gUnknown_0300127C: @ 300127C - .space 0x4 + .include "src/battle_factory.o" gUnknown_03001280: @ 3001280 .space 0x4