diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s deleted file mode 100644 index 44f92caca..000000000 --- a/asm/contest_link_80F57C4.s +++ /dev/null @@ -1,2119 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80F7670 -sub_80F7670: @ 80F7670 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r1, r0, r1 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x5 - bne _080F7732 - movs r0, 0 - strh r0, [r1, 0x8] - ldr r0, =gUnknown_0203A034 - mov r8, r0 - ldr r0, [r0] - ldr r0, [r0] - ldrb r0, [r0, 0x7] - cmp r0, 0x27 - bhi _080F7732 - ldr r4, =gSpriteTemplate_858D860 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xF0 - bl __umodsi3 - adds r1, r0, 0 - subs r1, 0x14 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - movs r2, 0x2C - movs r3, 0x5 - bl CreateSprite - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl Random - ldr r1, =gSprites - lsls r5, r4, 4 - adds r5, r4 - lsls r5, 2 - adds r5, r1 - lsls r0, 23 - lsrs r0, 23 - strh r0, [r5, 0x2E] - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x18 - bl __umodsi3 - adds r0, 0x10 - strh r0, [r5, 0x30] - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xFF - ands r0, r1 - adds r0, 0x30 - strh r0, [r5, 0x32] - bl Random - ldrh r6, [r5, 0x4] - lsls r4, r6, 22 - lsrs r4, 22 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x11 - bl __umodsi3 - adds r4, r0 - ldr r1, =0x000003ff - adds r0, r1, 0 - ands r4, r0 - ldr r0, =0xfffffc00 - ands r0, r6 - orrs r0, r4 - strh r0, [r5, 0x4] - mov r1, r8 - ldr r0, [r1] - ldr r1, [r0] - ldrb r0, [r1, 0x7] - adds r0, 0x1 - strb r0, [r1, 0x7] -_080F7732: - ldr r0, =gUnknown_0203A034 - ldr r0, [r0] - ldr r0, [r0] - ldrb r0, [r0, 0x9] - cmp r0, 0 - beq _080F7744 - adds r0, r7, 0 - bl DestroyTask -_080F7744: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7670 - - thumb_func_start sub_80F7768 -sub_80F7768: @ 80F7768 - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - ldrh r1, [r4, 0x34] - adds r0, r1 - strh r0, [r4, 0x34] - lsls r0, 16 - asrs r0, 24 - movs r2, 0x30 - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x24] - ldrh r1, [r4, 0x32] - ldrh r0, [r4, 0x36] - adds r1, r0 - lsls r0, r1, 16 - asrs r0, 24 - ldrh r2, [r4, 0x20] - adds r0, r2 - strh r0, [r4, 0x20] - movs r0, 0xFF - ands r1, r0 - strh r1, [r4, 0x36] - ldrh r0, [r4, 0x22] - adds r0, 0x1 - strh r0, [r4, 0x22] - ldr r5, =gUnknown_0203A034 - ldr r0, [r5] - ldr r0, [r0] - ldrb r0, [r0, 0x9] - cmp r0, 0 - beq _080F77B6 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] -_080F77B6: - movs r1, 0x20 - ldrsh r0, [r4, r1] - cmp r0, 0xF8 - bgt _080F77C6 - movs r2, 0x22 - ldrsh r0, [r4, r2] - cmp r0, 0x74 - ble _080F77D6 -_080F77C6: - adds r0, r4, 0 - bl DestroySprite - ldr r0, [r5] - ldr r1, [r0] - ldrb r0, [r1, 0x7] - subs r0, 0x1 - strb r0, [r1, 0x7] -_080F77D6: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7768 - - thumb_func_start sub_80F77E0 -sub_80F77E0: @ 80F77E0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =sub_80F7824 - movs r1, 0x8 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x8] - strh r5, [r1, 0xA] - ldr r0, =gContestMons - lsls r4, 6 - adds r4, r0 - ldrh r0, [r4] - strh r0, [r1, 0xC] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F77E0 - - thumb_func_start sub_80F7824 -sub_80F7824: @ 80F7824 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - ldrb r5, [r4, 0x8] - ldrh r0, [r4, 0x1C] - adds r1, r0, 0x1 - strh r1, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - movs r2, 0xA - ldrsh r1, [r4, r2] - cmp r0, r1 - bne _080F786E - movs r0, 0 - strh r0, [r4, 0x1C] - ldrh r0, [r4, 0xC] - ldrb r2, [r4, 0x1E] - ldr r1, =gContestMons - lsls r3, r5, 6 - adds r1, 0x38 - adds r3, r1 - ldr r1, [r3] - str r1, [sp] - adds r1, r5, 0 - movs r3, 0 - bl sub_80F69B8 - ldrh r0, [r4, 0x1E] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0x1E] -_080F786E: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7824 - - thumb_func_start sub_80F7880 -sub_80F7880: @ 80F7880 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, =gUnknown_02039F08 - ldrh r2, [r0] - adds r4, r0, 0 - adds r3, r4, 0x2 - movs r0, 0x2 - mov r8, r0 -_080F7898: - lsls r0, r2, 16 - asrs r0, 16 - movs r5, 0 - ldrsh r1, [r3, r5] - cmp r0, r1 - bge _080F78A6 - ldrh r2, [r3] -_080F78A6: - adds r3, 0x2 - movs r0, 0x1 - negs r0, r0 - add r8, r0 - mov r1, r8 - cmp r1, 0 - bge _080F7898 - lsls r0, r2, 16 - str r0, [sp] - cmp r0, 0 - bge _080F78E4 - ldrh r2, [r4] - adds r3, r4, 0x2 - movs r4, 0x2 - mov r8, r4 -_080F78C4: - lsls r0, r2, 16 - asrs r0, 16 - movs r5, 0 - ldrsh r1, [r3, r5] - cmp r0, r1 - ble _080F78D2 - ldrh r2, [r3] -_080F78D2: - adds r3, 0x2 - movs r0, 0x1 - negs r0, r0 - add r8, r0 - lsls r1, r2, 16 - str r1, [sp] - mov r4, r8 - cmp r4, 0 - bge _080F78C4 -_080F78E4: - movs r5, 0 - mov r8, r5 - mov r10, r5 -_080F78EA: - ldr r0, =gContestMonConditions - mov r1, r8 - lsls r7, r1, 1 - adds r0, r7, r0 - movs r2, 0 - ldrsh r1, [r0, r2] - lsls r0, r1, 5 - subs r0, r1 - lsls r0, 2 - adds r0, r1 - lsls r0, 3 - ldr r4, [sp] - asrs r5, r4, 16 - adds r1, r5, 0 - cmp r5, 0 - bge _080F790C - negs r1, r5 -_080F790C: - bl __divsi3 - adds r4, r0, 0 - movs r1, 0xA - bl __modsi3 - cmp r0, 0x4 - ble _080F791E - adds r4, 0xA -_080F791E: - ldr r0, =gUnknown_0203A034 - mov r9, r0 - ldr r0, [r0] - ldr r0, [r0, 0x4] - mov r1, r10 - adds r6, r1, r0 - adds r0, r4, 0 - movs r1, 0xA - bl __divsi3 - str r0, [r6] - ldr r0, =gUnknown_02039F18 - adds r7, r0 - movs r2, 0 - ldrsh r1, [r7, r2] - cmp r1, 0 - bge _080F7942 - negs r1, r1 -_080F7942: - lsls r0, r1, 5 - subs r0, r1 - lsls r0, 2 - adds r0, r1 - lsls r0, 3 - adds r1, r5, 0 - cmp r1, 0 - bge _080F7954 - negs r1, r1 -_080F7954: - bl __divsi3 - adds r4, r0, 0 - movs r1, 0xA - bl __modsi3 - cmp r0, 0x4 - ble _080F7966 - adds r4, 0xA -_080F7966: - adds r0, r4, 0 - movs r1, 0xA - bl __divsi3 - str r0, [r6, 0x4] - movs r4, 0 - ldrsh r0, [r7, r4] - cmp r0, 0 - bge _080F797C - movs r0, 0x1 - strb r0, [r6, 0x10] -_080F797C: - mov r5, r9 - ldr r0, [r5] - ldr r0, [r0, 0x4] - mov r1, r10 - adds r4, r1, r0 - ldr r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - subs r0, r1 - lsls r0, 11 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - movs r5, 0xFF - ands r0, r5 - cmp r0, 0x7F - bls _080F79A8 - movs r2, 0x80 - lsls r2, 1 - adds r1, r2 -_080F79A8: - lsrs r0, r1, 8 - str r0, [r4, 0x8] - ldr r1, [r4, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - subs r0, r1 - lsls r0, 11 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - ands r0, r5 - cmp r0, 0x7F - bls _080F79CC - movs r5, 0x80 - lsls r5, 1 - adds r1, r5 -_080F79CC: - lsrs r0, r1, 8 - str r0, [r4, 0xC] - mov r0, r8 - lsls r4, r0, 24 - lsrs r4, 24 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80F7310 - mov r2, r9 - ldr r1, [r2] - ldr r1, [r1, 0x4] - add r1, r10 - strb r0, [r1, 0x11] - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80F7364 - mov r4, r9 - ldr r1, [r4] - ldr r1, [r1, 0x4] - add r1, r10 - lsls r0, 24 - asrs r0, 24 - cmp r0, 0 - bge _080F7A02 - negs r0, r0 -_080F7A02: - strb r0, [r1, 0x12] - ldr r0, =gContestFinalStandings - add r0, r8 - ldrb r0, [r0] - cmp r0, 0 - beq _080F7A60 - mov r5, r9 - ldr r0, [r5] - ldr r0, [r0, 0x4] - mov r2, r10 - adds r1, r2, r0 - ldr r5, [r1, 0x8] - ldrh r3, [r1, 0x8] - ldr r4, [r1, 0xC] - ldrh r2, [r1, 0xC] - ldrb r0, [r1, 0x10] - cmp r0, 0 - beq _080F7A2C - lsls r0, r2, 16 - negs r0, r0 - lsrs r2, r0, 16 -_080F7A2C: - lsls r0, r3, 16 - asrs r3, r0, 16 - lsls r0, r2, 16 - asrs r2, r0, 16 - adds r0, r3, r2 - cmp r0, 0x58 - bne _080F7A60 - cmp r2, 0 - ble _080F7A58 - subs r0, r4, 0x1 - str r0, [r1, 0xC] - b _080F7A60 - .pool -_080F7A58: - cmp r3, 0 - ble _080F7A60 - subs r0, r5, 0x1 - str r0, [r1, 0x8] -_080F7A60: - movs r4, 0x14 - add r10, r4 - movs r5, 0x1 - add r8, r5 - mov r0, r8 - cmp r0, 0x3 - bgt _080F7A70 - b _080F78EA -_080F7A70: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80F7880 - - thumb_func_start sub_80F7A80 -sub_80F7A80: @ 80F7A80 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - movs r1, 0 - str r1, [sp, 0x8] - movs r3, 0 - str r3, [sp, 0xC] - cmp r0, 0 - bne _080F7B5C - mov r9, r3 - ldr r4, =gUnknown_0203A034 - mov r10, r4 - movs r7, 0xA0 - lsls r7, 19 - movs r6, 0 -_080F7AAC: - mov r1, r10 - ldr r0, [r1] - ldr r0, [r0, 0x4] - adds r0, r6, r0 - ldrb r2, [r0, 0x11] - cmp r8, r2 - bcs _080F7B2E - adds r2, 0x13 - mov r3, r8 - subs r2, r3 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - lsrs r3, r7, 24 - movs r0, 0x1 - str r0, [sp] - str r0, [sp, 0x4] - ldr r1, =0x000060b3 - bl FillBgTilemapBufferRect_Palette0 - ldr r0, =sub_80F7CA8 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r10 - ldr r4, [r0] - ldr r1, [r4, 0x4] - adds r1, r6, r1 - ldr r0, [r1, 0x8] - lsls r0, 16 - ldrb r1, [r1, 0x11] - bl __udivsi3 - mov r1, r8 - adds r1, 0x1 - adds r3, r0, 0 - muls r3, r1 - ldr r0, =0x0000ffff - ands r0, r3 - ldr r1, =0x00007fff - cmp r0, r1 - bls _080F7B0A - movs r1, 0x80 - lsls r1, 9 - adds r3, r1 -_080F7B0A: - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - mov r1, r9 - strh r1, [r0, 0x8] - lsrs r1, r3, 16 - strh r1, [r0, 0xA] - ldr r1, [r4] - ldrb r0, [r1, 0x14] - adds r0, 0x1 - strb r0, [r1, 0x14] - ldr r0, [sp, 0x8] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x8] -_080F7B2E: - movs r3, 0xC0 - lsls r3, 18 - adds r7, r3 - adds r6, 0x14 - movs r4, 0x1 - add r9, r4 - mov r0, r9 - cmp r0, 0x3 - ble _080F7AAC - b _080F7C7E - .pool -_080F7B5C: - movs r1, 0 - mov r9, r1 - mov r10, r1 - movs r3, 0xC0 - lsls r3, 19 - str r3, [sp, 0x10] -_080F7B68: - ldr r4, =gUnknown_0203A034 - ldr r0, [r4] - ldr r0, [r0, 0x4] - add r0, r10 - ldrb r2, [r0, 0x12] - ldrb r0, [r0, 0x10] - ldr r1, =0x000060a3 - cmp r0, 0 - beq _080F7B7C - adds r1, 0x2 -_080F7B7C: - lsls r0, r2, 24 - asrs r0, 24 - cmp r8, r0 - bge _080F7C64 - mov r3, r8 - lsls r2, r3, 24 - asrs r2, 24 - subs r2, 0x13 - subs r2, r0, r2 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldr r4, [sp, 0x10] - lsrs r3, r4, 24 - movs r7, 0x1 - str r7, [sp] - str r7, [sp, 0x4] - movs r0, 0x1 - bl FillBgTilemapBufferRect_Palette0 - ldr r0, =sub_80F7CA8 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gUnknown_0203A034 - ldr r6, [r0] - ldr r1, [r6, 0x4] - add r1, r10 - ldr r0, [r1, 0xC] - lsls r0, 16 - ldrb r1, [r1, 0x12] - bl __udivsi3 - mov r1, r8 - adds r1, 0x1 - adds r3, r0, 0 - muls r3, r1 - ldr r0, =0x0000ffff - ands r0, r3 - ldr r1, =0x00007fff - cmp r0, r1 - bls _080F7BDA - movs r1, 0x80 - lsls r1, 9 - adds r3, r1 -_080F7BDA: - ldr r1, =gTasks - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 3 - adds r4, r0, r1 - mov r0, r9 - strh r0, [r4, 0x8] - ldr r0, [r6, 0x4] - add r0, r10 - ldrb r0, [r0, 0x10] - adds r6, r1, 0 - cmp r0, 0 - beq _080F7C1C - strh r7, [r4, 0xC] - ldr r0, [sp, 0xC] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0xC] - b _080F7C26 - .pool -_080F7C1C: - ldr r0, [sp, 0x8] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x8] -_080F7C26: - ldr r1, =gUnknown_0203A034 - ldr r0, [r1] - ldr r0, [r0, 0x4] - mov r4, r10 - adds r1, r4, r0 - ldrb r0, [r1, 0x10] - ldr r4, =gUnknown_0203A034 - cmp r0, 0 - beq _080F7C4C - adds r0, r2, r5 - lsls r0, 3 - adds r0, r6 - lsrs r2, r3, 16 - ldr r1, [r1, 0x8] - subs r1, r2 - b _080F7C58 - .pool -_080F7C4C: - adds r0, r2, r5 - lsls r0, 3 - adds r0, r6 - lsrs r2, r3, 16 - ldr r1, [r1, 0x8] - adds r1, r2 -_080F7C58: - strh r1, [r0, 0xA] - ldr r0, [r4] - ldr r1, [r0] - ldrb r0, [r1, 0x14] - adds r0, 0x1 - strb r0, [r1, 0x14] -_080F7C64: - movs r0, 0x14 - add r10, r0 - ldr r1, [sp, 0x10] - movs r3, 0xC0 - lsls r3, 18 - adds r1, r3 - str r1, [sp, 0x10] - movs r4, 0x1 - add r9, r4 - mov r0, r9 - cmp r0, 0x3 - bgt _080F7C7E - b _080F7B68 -_080F7C7E: - ldr r1, [sp, 0xC] - cmp r1, 0 - beq _080F7C8A - movs r0, 0x16 - bl PlaySE -_080F7C8A: - ldr r3, [sp, 0x8] - cmp r3, 0 - beq _080F7C96 - movs r0, 0x15 - bl PlaySE -_080F7C96: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80F7A80 - - thumb_func_start sub_80F7CA8 -sub_80F7CA8: @ 80F7CA8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r4, 0 - mov r9, r4 - ldr r1, =gTasks - lsls r0, 2 - add r0, r8 - lsls r0, 3 - adds r0, r1 - ldrb r6, [r0, 0x8] - ldrh r7, [r0, 0xA] - ldrh r1, [r0, 0xC] - mov r12, r1 - movs r2, 0xC - ldrsh r0, [r0, r2] - cmp r0, 0 - beq _080F7CF8 - ldr r2, =gUnknown_0203A034 - ldr r0, [r2] - ldr r0, [r0] - lsls r1, r6, 1 - adds r0, 0xC - adds r0, r1 - movs r3, 0 - ldrsh r0, [r0, r3] - adds r5, r1, 0 - cmp r0, 0 - bgt _080F7D10 - b _080F7D0E - .pool -_080F7CF8: - ldr r2, =gUnknown_0203A034 - ldr r0, [r2] - ldr r0, [r0] - lsls r1, r6, 1 - adds r0, 0xC - adds r0, r1 - movs r3, 0 - ldrsh r0, [r0, r3] - adds r5, r1, 0 - cmp r0, 0x57 - ble _080F7D10 -_080F7D0E: - movs r4, 0x1 -_080F7D10: - ldr r0, [r2] - ldr r0, [r0] - adds r0, 0xC - adds r2, r0, r5 - ldrh r3, [r2] - movs r0, 0 - ldrsh r1, [r2, r0] - lsls r0, r7, 16 - asrs r0, 16 - cmp r1, r0 - bne _080F7D2A - movs r1, 0x1 - mov r9, r1 -_080F7D2A: - mov r0, r9 - cmp r0, 0 - bne _080F7D4A - cmp r4, 0 - beq _080F7D3C - strh r7, [r2] - b _080F7D4A - .pool -_080F7D3C: - mov r1, r12 - cmp r1, 0 - beq _080F7D46 - subs r0, r3, 0x1 - b _080F7D48 -_080F7D46: - adds r0, r3, 0x1 -_080F7D48: - strh r0, [r2] -_080F7D4A: - cmp r4, 0 - bne _080F7DC4 - mov r2, r9 - cmp r2, 0 - bne _080F7DCA - movs r2, 0 -_080F7D56: - ldr r0, =gUnknown_0203A034 - ldr r0, [r0] - ldr r0, [r0] - adds r0, 0xC - adds r0, r5 - movs r1, 0 - ldrsh r3, [r0, r1] - adds r0, r2, 0x1 - lsls r1, r0, 3 - adds r4, r0, 0 - cmp r3, r1 - blt _080F7D78 - movs r0, 0x8 - b _080F7D94 - .pool -_080F7D78: - lsls r0, r2, 3 - cmp r3, r0 - blt _080F7D92 - adds r0, r3, 0 - cmp r3, 0 - bge _080F7D86 - adds r0, r3, 0x7 -_080F7D86: - asrs r0, 3 - lsls r0, 3 - subs r0, r3, r0 - lsls r0, 24 - lsrs r0, 24 - b _080F7D94 -_080F7D92: - movs r0, 0 -_080F7D94: - cmp r0, 0x3 - bhi _080F7DA0 - ldr r3, =0x0000504c - b _080F7DA2 - .pool -_080F7DA0: - ldr r3, =0x00005057 -_080F7DA2: - adds r1, r0, r3 - adds r2, 0x7 - lsls r2, 24 - lsrs r2, 24 - adds r3, r5, r6 - adds r3, 0x6 - lsls r3, 24 - movs r0, 0x1 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x2 - lsrs r3, 24 - bl FillBgTilemapBufferRect_Palette0 - adds r2, r4, 0 - cmp r2, 0xA - ble _080F7D56 -_080F7DC4: - mov r0, r9 - cmp r0, 0 - beq _080F7DDC -_080F7DCA: - ldr r0, =gUnknown_0203A034 - ldr r0, [r0] - ldr r1, [r0] - ldrb r0, [r1, 0x14] - subs r0, 0x1 - strb r0, [r1, 0x14] - mov r0, r8 - bl DestroyTask -_080F7DDC: - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7CA8 - - thumb_func_start sub_80F7DF4 -sub_80F7DF4: @ 80F7DF4 - push {r4,r5,lr} - ldr r4, =gUnknown_0203A034 - movs r0, 0x20 - bl AllocZeroed - str r0, [r4] - movs r0, 0x18 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1] - movs r0, 0x50 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x4] - movs r5, 0x80 - lsls r5, 4 - adds r0, r5, 0 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x8] - adds r0, r5, 0 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0xC] - adds r0, r5, 0 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x10] - adds r0, r5, 0 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x14] - adds r0, r5, 0 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x18] - movs r0, 0x80 - lsls r0, 5 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x1C] - bl AllocateMonSpritesGfx - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7DF4 - - thumb_func_start sub_80F7E64 -sub_80F7E64: @ 80F7E64 - push {r4,r5,lr} - ldr r5, =gUnknown_0203A034 - ldr r0, [r5] - ldr r0, [r0] - bl Free - ldr r0, [r5] - movs r4, 0 - str r4, [r0] - ldr r0, [r0, 0x4] - bl Free - ldr r0, [r5] - str r4, [r0, 0x4] - ldr r0, [r0, 0x8] - bl Free - ldr r0, [r5] - str r4, [r0, 0x8] - ldr r0, [r0, 0xC] - bl Free - ldr r0, [r5] - str r4, [r0, 0xC] - ldr r0, [r0, 0x10] - bl Free - ldr r0, [r5] - str r4, [r0, 0x10] - ldr r0, [r0, 0x14] - bl Free - ldr r0, [r5] - str r4, [r0, 0x14] - ldr r0, [r0, 0x18] - bl Free - ldr r0, [r5] - str r4, [r0, 0x18] - ldr r0, [r0, 0x1C] - bl Free - ldr r0, [r5] - str r4, [r0, 0x1C] - bl Free - str r4, [r5] - bl FreeMonSpritesGfx - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7E64 - - thumb_func_start sub_80F7ED0 -sub_80F7ED0: @ 80F7ED0 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - str r1, [sp] - mov r0, sp - movs r3, 0 - strb r4, [r0, 0x4] - mov r1, sp - movs r0, 0x7 - strb r0, [r1, 0x5] - mov r0, sp - strb r2, [r0, 0x6] - movs r1, 0x2 - strb r1, [r0, 0x7] - strb r2, [r0, 0x8] - strb r1, [r0, 0x9] - strb r3, [r0, 0xA] - strb r3, [r0, 0xB] - mov r3, sp - ldrb r2, [r3, 0xC] - subs r1, 0x12 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - mov r2, sp - movs r0, 0x10 - strb r0, [r2, 0xC] - ldrb r0, [r2, 0xD] - ands r1, r0 - strb r1, [r2, 0xD] - mov r1, sp - movs r0, 0x80 - strb r0, [r1, 0xD] - mov r0, sp - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl PutWindowTilemap - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80F7ED0 - - thumb_func_start sub_80F7F30 -sub_80F7F30: @ 80F7F30 - push {r4,r5,lr} - ldr r0, =gContestMonPartyIndex - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - bl sub_80DAE0C - lsls r0, 24 - lsrs r0, 24 - adds r5, r0, 0 - cmp r5, 0 - beq _080F7F5E - ldr r4, =gSpecialVar_ContestCategory - ldrb r0, [r4] - ldr r1, =gSpecialVar_ContestRank - ldrb r1, [r1] - bl sub_80DAB8C - ldrb r0, [r4] - bl sub_80DB09C -_080F7F5E: - ldr r0, =gSpecialVar_Result - strh r5, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7F30 - - thumb_func_start sub_80F7F7C -sub_80F7F7C: @ 80F7F7C - push {r4,lr} - movs r4, 0 - ldr r0, =gContestMonPartyIndex - ldrb r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - adds r2, r1, r0 - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - cmp r0, 0x4 - bhi _080F7FEE - lsls r0, 2 - ldr r1, =_080F7FB0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080F7FB0: - .4byte _080F7FC4 - .4byte _080F7FCA - .4byte _080F7FD0 - .4byte _080F7FD6 - .4byte _080F7FDC -_080F7FC4: - adds r0, r2, 0 - movs r1, 0x32 - b _080F7FE0 -_080F7FCA: - adds r0, r2, 0 - movs r1, 0x33 - b _080F7FE0 -_080F7FD0: - adds r0, r2, 0 - movs r1, 0x34 - b _080F7FE0 -_080F7FD6: - adds r0, r2, 0 - movs r1, 0x35 - b _080F7FE0 -_080F7FDC: - adds r0, r2, 0 - movs r1, 0x36 -_080F7FE0: - bl GetMonData - ldr r1, =gSpecialVar_ContestRank - ldrh r1, [r1] - cmp r0, r1 - bls _080F7FEE - movs r4, 0x1 -_080F7FEE: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80F7F7C - - thumb_func_start sub_80F7FFC -sub_80F7FFC: @ 80F7FFC - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =gContestFinalStandings - ldr r0, =gContestPlayerMonIndex - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080F8010 - b _080F8250 -_080F8010: - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - cmp r0, 0x4 - bls _080F801A - b _080F8250 -_080F801A: - lsls r0, 2 - ldr r1, =_080F8034 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080F8034: - .4byte _080F8048 - .4byte _080F80B8 - .4byte _080F8124 - .4byte _080F8190 - .4byte _080F81F8 -_080F8048: - ldr r6, =gContestMonPartyIndex - ldrb r0, [r6] - movs r5, 0x64 - muls r0, r5 - ldr r4, =gPlayerParty - adds r0, r4 - movs r1, 0x32 - bl GetMonData - lsls r0, 24 - lsrs r1, r0, 24 - mov r0, sp - strb r1, [r0] - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r1, r0 - bls _080F806C - b _080F8250 -_080F806C: - adds r0, r1, 0 - cmp r0, 0x3 - bls _080F8074 - b _080F8250 -_080F8074: - adds r1, r0, 0x1 - mov r0, sp - strb r1, [r0] - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - movs r1, 0x32 - mov r2, sp - bl SetMonData - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _080F809C - b _080F8250 -_080F809C: - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - movs r1, 0x32 - bl sub_80EE4DC - b _080F8250 - .pool -_080F80B8: - mov r4, sp - ldr r7, =gContestMonPartyIndex - ldrb r0, [r7] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0x33 - bl GetMonData - strb r0, [r4] - mov r0, sp - ldrb r2, [r0] - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r2, r0 - bls _080F80DC - b _080F8250 -_080F80DC: - cmp r2, 0x3 - bls _080F80E2 - b _080F8250 -_080F80E2: - mov r1, sp - adds r0, r2, 0x1 - strb r0, [r1] - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x33 - mov r2, sp - bl SetMonData - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _080F810A - b _080F8250 -_080F810A: - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x33 - bl sub_80EE4DC - b _080F8250 - .pool -_080F8124: - mov r4, sp - ldr r7, =gContestMonPartyIndex - ldrb r0, [r7] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0x34 - bl GetMonData - strb r0, [r4] - mov r0, sp - ldrb r2, [r0] - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r2, r0 - bls _080F8148 - b _080F8250 -_080F8148: - cmp r2, 0x3 - bls _080F814E - b _080F8250 -_080F814E: - mov r1, sp - adds r0, r2, 0x1 - strb r0, [r1] - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x34 - mov r2, sp - bl SetMonData - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bls _080F8250 - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x34 - bl sub_80EE4DC - b _080F8250 - .pool -_080F8190: - mov r4, sp - ldr r7, =gContestMonPartyIndex - ldrb r0, [r7] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0x35 - bl GetMonData - strb r0, [r4] - mov r0, sp - ldrb r2, [r0] - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r2, r0 - bhi _080F8250 - cmp r2, 0x3 - bhi _080F8250 - mov r1, sp - adds r0, r2, 0x1 - strb r0, [r1] - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x35 - mov r2, sp - bl SetMonData - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bls _080F8250 - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x35 - bl sub_80EE4DC - b _080F8250 - .pool -_080F81F8: - mov r4, sp - ldr r7, =gContestMonPartyIndex - ldrb r0, [r7] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0x36 - bl GetMonData - strb r0, [r4] - mov r0, sp - ldrb r2, [r0] - ldr r0, =gSpecialVar_ContestRank - ldrh r0, [r0] - cmp r2, r0 - bhi _080F8250 - cmp r2, 0x3 - bhi _080F8250 - mov r1, sp - adds r0, r2, 0x1 - strb r0, [r1] - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x36 - mov r2, sp - bl SetMonData - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - bl GetRibbonCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bls _080F8250 - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - movs r1, 0x36 - bl sub_80EE4DC -_080F8250: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F7FFC - - thumb_func_start sub_80F8264 -sub_80F8264: @ 80F8264 - push {r4,lr} - ldr r4, =gStringVar1 - ldr r0, =gSpecialVar_0x8006 - ldrh r1, [r0] - lsls r1, 6 - ldr r0, =gContestMons + 13 - adds r1, r0 - adds r0, r4, 0 - bl StringCopy - adds r0, r4, 0 - bl sub_81DB5AC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8264 - - thumb_func_start sub_80F8290 -sub_80F8290: @ 80F8290 - push {lr} - ldr r0, =gStringVar3 - ldr r1, =gSpecialVar_0x8006 - ldrh r1, [r1] - lsls r1, 6 - ldr r2, =gContestMons + 2 - adds r1, r2 - bl StringCopy - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8290 - - thumb_func_start sub_80F82B4 -sub_80F82B4: @ 80F82B4 - push {r4-r6,lr} - movs r1, 0 - movs r2, 0 - ldr r5, =gSpecialVar_0x8004 - ldr r4, =gContestMonConditions - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - lsls r0, 1 - adds r0, r4 - movs r6, 0 - ldrsh r3, [r0, r6] -_080F82CA: - lsls r0, r1, 1 - adds r0, r4 - movs r6, 0 - ldrsh r0, [r0, r6] - cmp r3, r0 - bge _080F82DC - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 -_080F82DC: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _080F82CA - strh r2, [r5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F82B4 - - thumb_func_start sub_80F82FC -sub_80F82FC: @ 80F82FC - ldr r2, =gSpecialVar_0x8004 - ldr r1, =gContestMonConditions - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_80F82FC - - thumb_func_start sub_80F831C -sub_80F831C: @ 80F831C - push {lr} - movs r1, 0 - ldr r2, =gContestFinalStandings - ldrb r0, [r2] - ldr r3, =gSpecialVar_0x8005 - cmp r0, 0 - beq _080F833C -_080F832A: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bhi _080F833C - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _080F832A -_080F833C: - strh r1, [r3] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F831C - - thumb_func_start sub_80F834C -sub_80F834C: @ 80F834C - push {r4,lr} - movs r1, 0 - ldr r2, =gContestFinalStandings - ldrb r0, [r2] - ldr r4, =gStringVar3 - ldr r3, =gContestMons + 13 - cmp r0, 0 - beq _080F836E -_080F835C: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bhi _080F836E - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _080F835C -_080F836E: - lsls r1, 6 - adds r1, r3 - adds r0, r4, 0 - bl StringCopy - adds r0, r4, 0 - bl sub_81DB5AC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F834C - - thumb_func_start sub_80F8390 -sub_80F8390: @ 80F8390 - push {r4,lr} - movs r1, 0 - ldr r2, =gContestFinalStandings - ldrb r0, [r2] - ldr r4, =gStringVar1 - ldr r3, =gContestMons + 2 - cmp r0, 0 - beq _080F83B2 -_080F83A0: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bhi _080F83B2 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _080F83A0 -_080F83B2: - lsls r1, 6 - adds r1, r3 - adds r0, r4, 0 - bl StringCopy - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8390 - - thumb_func_start sub_80F83D0 -sub_80F83D0: @ 80F83D0 - push {lr} - ldr r0, =sub_80D7B24 - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F83D0 - - thumb_func_start sub_80F83E0 -sub_80F83E0: @ 80F83E0 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080F83FE - adds r0, r2, 0 - bl DestroyTask - ldr r0, =sub_80F83D0 - bl SetMainCallback2 -_080F83FE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F83E0 - - thumb_func_start sub_80F840C -sub_80F840C: @ 80F840C - push {lr} - sub sp, 0x4 - bl ScriptContext2_Enable - ldr r0, =sub_80F83E0 - movs r1, 0xA - bl CreateTask - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F840C - - thumb_func_start sub_80F8438 -sub_80F8438: @ 80F8438 - ldr r2, =gSpecialVar_0x8004 - ldr r1, =gContestMons - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - lsls r0, 6 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_80F8438 - - thumb_func_start sub_80F8458 -sub_80F8458: @ 80F8458 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080F8476 - adds r0, r2, 0 - bl DestroyTask - ldr r0, =sub_80F5B00 - bl SetMainCallback2 -_080F8476: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8458 - - thumb_func_start sub_80F8484 -sub_80F8484: @ 80F8484 - push {lr} - sub sp, 0x4 - bl ScriptContext2_Enable - ldr r0, =sub_80F8458 - movs r1, 0xA - bl CreateTask - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8484 - - thumb_func_start sub_80F84B0 -sub_80F84B0: @ 80F84B0 - ldr r0, =gSpecialVar_0x8004 - ldr r1, =gContestPlayerMonIndex - ldrb r1, [r1] - strh r1, [r0] - bx lr - .pool - thumb_func_end sub_80F84B0 - - thumb_func_start sub_80F84C4 -sub_80F84C4: @ 80F84C4 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - bl ScriptContext2_Enable - ldr r6, =sub_80FC580 - adds r0, r6, 0 - movs r1, 0 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r2, =sub_80F8508 - adds r0, r4, 0 - adds r1, r6, 0 - bl SetTaskFuncWithFollowupFunc - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x1A] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F84C4 - - thumb_func_start sub_80F8508 -sub_80F8508: @ 80F8508 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080F8540 - ldr r0, =gContestMonPartyIndex - ldrb r0, [r0] - bl sub_80DA8C8 - ldr r1, =sub_80FC6BC - ldr r2, =sub_80F8568 - adds r0, r4, 0 - bl SetTaskFuncWithFollowupFunc - b _080F8556 - .pool -_080F8540: - ldr r0, =gContestMonPartyIndex - ldrb r0, [r0] - bl sub_80DA8C8 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81D9DE4 - str r1, [r0] -_080F8556: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8508 - - thumb_func_start sub_80F8568 -sub_80F8568: @ 80F8568 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =sub_80FC804 - ldr r2, =sub_80F8584 - bl SetTaskFuncWithFollowupFunc - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8568 - - thumb_func_start sub_80F8584 -sub_80F8584: @ 80F8584 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =sub_80FCE48 - ldr r2, =sub_80F85A0 - bl SetTaskFuncWithFollowupFunc - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8584 - - thumb_func_start sub_80F85A0 -sub_80F85A0: @ 80F85A0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =sub_80FC894 - ldr r2, =sub_80F85BC - bl SetTaskFuncWithFollowupFunc - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F85A0 - - thumb_func_start sub_80F85BC -sub_80F85BC: @ 80F85BC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r6, r0, 24 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - movs r3, 0 - ldr r5, =gNumLinkContestPlayers - mov r12, r5 - ldr r0, =gSpecialVar_0x8004 - mov r9, r0 - add r1, sp, 0x4 - mov r8, r1 - ldrb r0, [r5] - cmp r3, r0 - bcs _080F8606 - lsls r0, r6, 2 - adds r0, r6 - lsls r4, r0, 3 - ldr r7, =gTasks + 0x8 -_080F85EC: - mov r1, sp - adds r2, r1, r3 - adds r1, r3, 0x1 - lsls r0, r1, 1 - adds r0, r4 - adds r0, r7 - ldrh r0, [r0] - strb r0, [r2] - lsls r1, 24 - lsrs r3, r1, 24 - ldrb r0, [r5] - cmp r3, r0 - bcc _080F85EC -_080F8606: - movs r3, 0 - mov r1, r12 - ldrb r0, [r1] - cmp r3, r0 - bcs _080F862A - adds r4, r0, 0 - mov r2, sp -_080F8614: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r4 - bcs _080F862A - mov r0, sp - adds r1, r0, r3 - ldrb r0, [r2] - ldrb r1, [r1] - cmp r0, r1 - beq _080F8614 -_080F862A: - mov r1, r12 - ldrb r1, [r1] - cmp r3, r1 - bne _080F8644 - movs r0, 0 - b _080F8646 - .pool -_080F8644: - movs r0, 0x1 -_080F8646: - mov r1, r9 - strh r0, [r1] - movs r3, 0 - mov r4, r12 - ldrb r0, [r4] - cmp r3, r0 - bcs _080F8678 - mov r5, r8 - lsls r0, r6, 2 - adds r0, r6 - lsls r2, r0, 3 - ldr r7, =gTasks + 0x8 -_080F865E: - adds r1, r5, r3 - adds r0, r3, 0x5 - lsls r0, 1 - adds r0, r2 - adds r0, r7 - ldrh r0, [r0] - strb r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - ldrb r1, [r4] - cmp r3, r1 - bcc _080F865E -_080F8678: - mov r0, r8 - bl sub_80F86E0 - ldr r1, =gUnknown_02039F2B - strb r0, [r1] - ldr r0, =gSpecialVar_ContestCategory - ldrb r0, [r0] - bl sub_80DB09C - ldr r1, =sub_80FCF40 - ldr r2, =sub_80F86B8 - adds r0, r6, 0 - bl SetTaskFuncWithFollowupFunc - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F85BC - - thumb_func_start sub_80F86B8 -sub_80F86B8: @ 80F86B8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - bl sub_80DCE58 - ldr r1, =sub_80FCFD0 - ldr r2, =sub_80F8714 - adds r0, r4, 0 - bl SetTaskFuncWithFollowupFunc - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F86B8 - - thumb_func_start sub_80F86E0 -sub_80F86E0: @ 80F86E0 - push {r4,r5,lr} - adds r3, r0, 0 - movs r4, 0 - movs r2, 0x1 - ldr r0, =gNumLinkContestPlayers - ldrb r0, [r0] - cmp r2, r0 - bge _080F8708 - adds r5, r0, 0 -_080F86F2: - adds r0, r3, r4 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcs _080F8702 - lsls r0, r2, 24 - lsrs r4, r0, 24 -_080F8702: - adds r2, 0x1 - cmp r2, r5 - blt _080F86F2 -_080F8708: - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80F86E0 - - thumb_func_start sub_80F8714 -sub_80F8714: @ 80F8714 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - cmp r0, 0x1 - bne _080F8748 - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _080F877E - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80F878C - str r0, [r1] - b _080F877E - .pool -_080F8748: - ldr r5, =gContestMons + 2 - movs r4, 0x3 -_080F874C: - adds r0, r5, 0 - bl StringGetEnd10 - adds r5, 0x40 - subs r4, 0x1 - cmp r4, 0 - bge _080F874C - adds r0, r6, 0 - bl DestroyTask - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x4 - ldrsb r1, [r0, r1] - movs r2, 0x5 - ldrsb r2, [r0, r2] - movs r3, 0x1 - negs r3, r3 - movs r0, 0 - bl SetDynamicWarp - bl ScriptContext2_Disable - bl EnableBothScriptContexts -_080F877E: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F8714 - - thumb_func_start sub_80F878C -sub_80F878C: @ 80F878C - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_800AC34 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80F87B4 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F878C - - thumb_func_start sub_80F87B4 -sub_80F87B4: @ 80F87B4 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080F87D0 - adds r0, r1, 0 - bl DestroyTask - bl ScriptContext2_Disable - bl EnableBothScriptContexts -_080F87D0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80F87B4 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/contest_link_80FC4F4.h b/include/contest_link_80FC4F4.h index 6f3bab97d..a3f118798 100644 --- a/include/contest_link_80FC4F4.h +++ b/include/contest_link_80FC4F4.h @@ -4,5 +4,10 @@ void sub_80FCC88(u8); void sub_80FCC88(u8); void sub_80FCACC(u8); +void sub_80FC580(u8); +void sub_80FC6BC(u8); +void sub_80FC804(u8); +void sub_80FCE48(u8); +void sub_80FC894(u8); #endif //GUARD_CONTEST_LINK_80FC4F4_H diff --git a/ld_script.txt b/ld_script.txt index be9efb1d5..eaf75c3de 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -147,7 +147,6 @@ SECTIONS { src/secret_base.o(.text); src/tv.o(.text); src/contest_link_80F57C4.o(.text); - asm/contest_link_80F57C4.o(.text); src/script_pokemon_util_80F87D8.o(.text); src/field_poison.o(.text); src/pokemon_size_record.o(.text); diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index c72fc9ba3..485065d71 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -1,8 +1,11 @@ #include "global.h" +#include "alloc.h" #include "battle.h" +#include "battle_gfx_sfx_util.h" #include "bg.h" #include "contest.h" #include "contest_link_80F57C4.h" +#include "contest_link_80FC4F4.h" #include "decompress.h" #include "dma3.h" #include "event_data.h" @@ -22,11 +25,13 @@ #include "random.h" #include "save.h" #include "scanline_effect.h" +#include "script.h" #include "sound.h" #include "string_util.h" #include "strings.h" #include "task.h" #include "text.h" +#include "trig.h" #include "tv.h" #include "util.h" #include "window.h" @@ -44,26 +49,38 @@ struct ContestLinkUnk0 u8 unk4; u8 unk5; u8 unk6; - u8 filler7[0x1]; + u8 unk7; u8 spriteId; u8 unk9; u8 unkA; - u8 fillerB[0x9]; + s16 unkC[4]; u8 unk14; u8 filler15[0x3]; }; +struct ContestLinkUnk14 +{ + int unk0; + int unk4; + u32 unk8; + u32 unkC; + u8 unk10; + u8 unk11; + u8 unk12; +}; + struct ContestLinkUnk4 { - u8 filler0[0x50]; + struct ContestLinkUnk14 unk0[4]; }; struct ContestLink80F57C4 { struct ContestLinkUnk0 *unk0; struct ContestLinkUnk4 *unk4; - u8 filler8[0x4]; + u8 *unk8; u8 *unkC[4]; + u8 *unk1C; }; EWRAM_DATA struct ContestLink80F57C4 *gUnknown_0203A034 = NULL; @@ -80,20 +97,23 @@ extern const u8 gUnknown_0858D6D0[]; extern const struct SpriteTemplate gSpriteTemplate_858D7F8; extern const struct SpriteSheet gUnknown_0858D810[]; extern const struct SpritePalette gUnknown_0858D850; +extern const struct SpriteTemplate gSpriteTemplate_858D860; + +extern void sub_81D9DE4(u8); static void sub_80F6A9C(void); static void sub_80F71C8(void); u8 sub_80F7310(u8, u8); s8 sub_80F7364(u8, u8); -void sub_80F7ED0(int, u8 *, int); -void sub_80F7DF4(void); -static void sub_80F6A64(u8, u8); +static void sub_80F7ED0(int, u8 *, int); +static void sub_80F7DF4(void); +static void LoadAllContestMonIcons(u8, u8); static void sub_80F6DC0(void); static void sub_80F6AE8(void); static void sub_80F5CE4(u8); static void sub_80F5C00(void); static void sub_80F68B4(u8); -void sub_80F7880(void); +static void sub_80F7880(void); static void sub_80F5C24(void); static void sub_80F707C(const u8 *); static void sub_80F5ED8(u8); @@ -105,7 +125,8 @@ static void sub_80F68F0(u8); s16 sub_80F6B78(const u8 *, u8); static void sub_80F6E9C(s16, u16, u16, u16); static void sub_80F6058(u8); -void sub_80F7A80(u8, u8); +static void sub_80F7A80(u8, u8); +void sub_80F7CA8(u8); static void sub_80F6EF4(u16); static void sub_80F60F0(u8); static void sub_80F616C(u8); @@ -113,20 +134,29 @@ static void sub_80F6204(u8); static void sub_80F73DC(u8); static void sub_80F74BC(u8); static void sub_80F753C(u8); -void sub_80F77E0(u8, u8); +static void sub_80F77E0(u8, u8); +static void sub_80F7824(u8); static void sub_80F6404(u8); static void sub_80F75A8(struct Sprite *); -void sub_80F7670(u8); +static void sub_80F7670(u8); static void sub_80F7620(struct Sprite *); static void sub_80F66B4(u8); static void sub_80F671C(u8); static void sub_80F677C(u8); static void sub_80F67C4(u8); static void sub_80F6820(u8); -void sub_80F7E64(void); +static void sub_80F7E64(void); static void sub_80F6F68(struct Sprite *); static void sub_80F7014(struct Sprite *); static void sub_80F6FDC(struct Sprite *); +static void sub_80F8508(u8); +static void sub_80F8568(u8); +static void sub_80F8584(u8); +static void sub_80F85A0(u8); +static void sub_80F85BC(u8); +static void sub_80F86B8(u8); +static void sub_80F878C(u8); +static void sub_80F87B4(u8); void sub_80F57C4(void) { @@ -266,7 +296,7 @@ void sub_80F5B00(void) FreeAllSpritePalettes(); sub_80F591C(); sub_80F6A9C(); - sub_80F6A64(0, 1); + LoadAllContestMonIcons(0, 1); sub_80F5AE0(); memset(gUnknown_0203A034->unk0, 0, sizeof(*gUnknown_0203A034->unk0)); memset(gUnknown_0203A034->unk4, 0, sizeof(*gUnknown_0203A034->unk4)); @@ -828,7 +858,7 @@ static void sub_80F68F0(u8 taskId) gUnknown_0203A034->unk0->unkA = 1; } -void sub_80F69B8(u16 species, u8 monIndex, u8 arg2, u8 arg3, u32 personality) +void sub_80F69B8(u16 species, u8 monIndex, u8 srcOffset, u8 useDmaNow, u32 personality) { u8 frameNum; const u8 *iconPtr; @@ -839,8 +869,8 @@ void sub_80F69B8(u16 species, u8 monIndex, u8 arg2, u8 arg3, u32 personality) frameNum = (monIndex == *contestPlayerMonIndex) ? 1 : 0; iconPtr = GetMonIconPtr(species, personality, frameNum); - iconPtr += arg2 * 0x200 + 0x80; - if (arg3) + iconPtr += srcOffset * 0x200 + 0x80; + if (useDmaNow) { RequestDma3Copy(iconPtr, (void *)BG_CHAR_ADDR(1) + monIndex * 0x200, 0x180, 1); var0 = ((monIndex + 10) << 12); @@ -853,12 +883,12 @@ void sub_80F69B8(u16 species, u8 monIndex, u8 arg2, u8 arg3, u32 personality) } } -static void sub_80F6A64(u8 arg0, u8 arg1) +static void LoadAllContestMonIcons(u8 srcOffset, u8 useDmaNow) { int i; for (i = 0; i < 4; i++) - sub_80F69B8(gContestMons[i].species, i, arg0, arg1, gContestMons[i].personality); + sub_80F69B8(gContestMons[i].species, i, srcOffset, useDmaNow, gContestMons[i].personality); } static void sub_80F6A9C(void) @@ -1567,3 +1597,1530 @@ static void sub_80F7620(struct Sprite *sprite) gUnknown_0203A034->unk0->unk6 = 2; } } + +static void sub_80F7670(u8 taskId) +{ + if (++gTasks[taskId].data[0] == 5) + { + gTasks[taskId].data[0] = 0; + if (gUnknown_0203A034->unk0->unk7 < 40) + { + u8 spriteId = CreateSprite(&gSpriteTemplate_858D860, (Random() % 240) - 20, 44, 5); + gSprites[spriteId].data[0] = Random() % 512; + gSprites[spriteId].data[1] = (Random() % 24) + 16; + gSprites[spriteId].data[2] = (Random() % 256) + 48; + gSprites[spriteId].oam.tileNum += Random() % 17; + gUnknown_0203A034->unk0->unk7++; + } + } + + if (gUnknown_0203A034->unk0->unk9) + DestroyTask(taskId); +} + +void sub_80F7768(struct Sprite *sprite) +{ + register s16 var0 asm("r1"); + + sprite->data[3] += sprite->data[0]; + sprite->pos2.x = Sin(sprite->data[3] >> 8, sprite->data[1]); + var0 = sprite->data[4] + sprite->data[2]; + sprite->pos1.x += var0 >> 8; + var0 = var0 & 0xFF; + sprite->data[4] = var0; + sprite->pos1.y++; + if (gUnknown_0203A034->unk0->unk9) + sprite->invisible = 1; + + if (sprite->pos1.x > 248 || sprite->pos1.y > 116) + { + DestroySprite(sprite); + gUnknown_0203A034->unk0->unk7--; + } +} + +static void sub_80F77E0(u8 monIndex, u8 numFrames) +{ + u8 taskId = CreateTask(sub_80F7824, 8); + gTasks[taskId].data[0] = monIndex; + gTasks[taskId].data[1] = numFrames; + gTasks[taskId].data[2] = gContestMons[monIndex].species; +} + +static void sub_80F7824(u8 taskId) +{ + u8 monIndex = gTasks[taskId].data[0]; + if (gTasks[taskId].data[10]++ == gTasks[taskId].data[1]) + { + gTasks[taskId].data[10] = 0; + sub_80F69B8(gTasks[taskId].data[2], monIndex, gTasks[taskId].data[11], FALSE, gContestMons[monIndex].personality); + gTasks[taskId].data[11] ^= 1; + } +} + +// static void sub_80F7880(void) +// { +// int i; +// int var0; +// int var1; +// int var2; +// int var3; +// u32 var4; +// int var5; +// int var6; +// s16 var7; +// s16 var8; +// s16 r2; + +// r2 = gUnknown_02039F08[0]; +// for (i = 1; i < 4; i++) +// { +// if (r2 < gUnknown_02039F08[i]) +// r2 = gUnknown_02039F08[i]; +// } + +// if (r2 < 0) +// { +// r2 = gUnknown_02039F08[0]; +// for (i = 1; i < 4; i++) +// { +// if (r2 > gUnknown_02039F08[i]) +// r2 = gUnknown_02039F08[i]; +// } +// } + +// // _080F78E4 +// for (i = 0; i < 4; i++) +// { +// var0 = gContestMonConditions[i] * 1000; +// var1 = r2; +// if (r2 < 0) +// var1 = -var1; + +// var2 = var0 / var1; +// if (var2 % 10 > 4) +// var2 += 10; + +// gUnknown_0203A034->unk4->unk0[i].unk0 = var2 / 10; +// var3 = gUnknown_02039F18[i]; +// if (var3 < 0) +// var3 = -var3; + +// var0 = var3 * 1000; +// var1 = r2; +// if (r2 < 0) +// var1 = -var1; + +// var2 = var0 / var1; +// if (var2 % 10 > 4) +// var2 += 10; + +// // _080F7966 +// gUnknown_0203A034->unk4->unk0[i].unk4 = var2 / 10; +// if (gUnknown_02039F18[i] < 0) +// gUnknown_0203A034->unk4->unk0[i].unk10 = 1; + +// var4 = gUnknown_0203A034->unk4->unk0[i].unk0 * 22528 / 100; +// if ((var4 & 0xFF) > 0x7F) +// var4 += 0x100; + +// gUnknown_0203A034->unk4->unk0[i].unk8 = var4 >> 8; +// var4 = gUnknown_0203A034->unk4->unk0[i].unk4 * 22528 / 100; +// if ((var4 & 0xFF) > 0x7F) +// var4 += 0x100; + +// gUnknown_0203A034->unk4->unk0[i].unkC = var4 >> 8; +// gUnknown_0203A034->unk4->unk0[i].unk11 = sub_80F7310(i, 1); +// var5 = sub_80F7364(i, 1); +// if (var5 < 0) +// var5 = -var5; + +// gUnknown_0203A034->unk4->unk0[i].unk12 = var5; +// if (gContestFinalStandings[i]) +// { +// var7 = gUnknown_0203A034->unk4->unk0[i].unk8; +// var8 = gUnknown_0203A034->unk4->unk0[i].unkC; +// if (gUnknown_0203A034->unk4->unk0[i].unk10) +// var8 = -var8; + +// if (var7 + var8 == 88) +// { +// if (var8 > 0) +// gUnknown_0203A034->unk4->unk0[i].unkC--; +// else if (var7 > 0) +// gUnknown_0203A034->unk4->unk0[i].unk8--; +// } +// } +// } +// } + +NAKED +static void sub_80F7880(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + ldr r0, =gUnknown_02039F08\n\ + ldrh r2, [r0]\n\ + adds r4, r0, 0\n\ + adds r3, r4, 0x2\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ +_080F7898:\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + movs r5, 0\n\ + ldrsh r1, [r3, r5]\n\ + cmp r0, r1\n\ + bge _080F78A6\n\ + ldrh r2, [r3]\n\ +_080F78A6:\n\ + adds r3, 0x2\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + add r8, r0\n\ + mov r1, r8\n\ + cmp r1, 0\n\ + bge _080F7898\n\ + lsls r0, r2, 16\n\ + str r0, [sp]\n\ + cmp r0, 0\n\ + bge _080F78E4\n\ + ldrh r2, [r4]\n\ + adds r3, r4, 0x2\n\ + movs r4, 0x2\n\ + mov r8, r4\n\ +_080F78C4:\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + movs r5, 0\n\ + ldrsh r1, [r3, r5]\n\ + cmp r0, r1\n\ + ble _080F78D2\n\ + ldrh r2, [r3]\n\ +_080F78D2:\n\ + adds r3, 0x2\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + add r8, r0\n\ + lsls r1, r2, 16\n\ + str r1, [sp]\n\ + mov r4, r8\n\ + cmp r4, 0\n\ + bge _080F78C4\n\ +_080F78E4:\n\ + movs r5, 0\n\ + mov r8, r5\n\ + mov r10, r5\n\ +_080F78EA:\n\ + ldr r0, =gContestMonConditions\n\ + mov r1, r8\n\ + lsls r7, r1, 1\n\ + adds r0, r7, r0\n\ + movs r2, 0\n\ + ldrsh r1, [r0, r2]\n\ + lsls r0, r1, 5\n\ + subs r0, r1\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + ldr r4, [sp]\n\ + asrs r5, r4, 16\n\ + adds r1, r5, 0\n\ + cmp r5, 0\n\ + bge _080F790C\n\ + negs r1, r5\n\ +_080F790C:\n\ + bl __divsi3\n\ + adds r4, r0, 0\n\ + movs r1, 0xA\n\ + bl __modsi3\n\ + cmp r0, 0x4\n\ + ble _080F791E\n\ + adds r4, 0xA\n\ +_080F791E:\n\ + ldr r0, =gUnknown_0203A034\n\ + mov r9, r0\n\ + ldr r0, [r0]\n\ + ldr r0, [r0, 0x4]\n\ + mov r1, r10\n\ + adds r6, r1, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + str r0, [r6]\n\ + ldr r0, =gUnknown_02039F18\n\ + adds r7, r0\n\ + movs r2, 0\n\ + ldrsh r1, [r7, r2]\n\ + cmp r1, 0\n\ + bge _080F7942\n\ + negs r1, r1\n\ +_080F7942:\n\ + lsls r0, r1, 5\n\ + subs r0, r1\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r1, r5, 0\n\ + cmp r1, 0\n\ + bge _080F7954\n\ + negs r1, r1\n\ +_080F7954:\n\ + bl __divsi3\n\ + adds r4, r0, 0\n\ + movs r1, 0xA\n\ + bl __modsi3\n\ + cmp r0, 0x4\n\ + ble _080F7966\n\ + adds r4, 0xA\n\ +_080F7966:\n\ + adds r0, r4, 0\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + str r0, [r6, 0x4]\n\ + movs r4, 0\n\ + ldrsh r0, [r7, r4]\n\ + cmp r0, 0\n\ + bge _080F797C\n\ + movs r0, 0x1\n\ + strb r0, [r6, 0x10]\n\ +_080F797C:\n\ + mov r5, r9\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + mov r1, r10\n\ + adds r4, r1, r0\n\ + ldr r1, [r4]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + subs r0, r1\n\ + lsls r0, 11\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + adds r1, r0, 0\n\ + movs r5, 0xFF\n\ + ands r0, r5\n\ + cmp r0, 0x7F\n\ + bls _080F79A8\n\ + movs r2, 0x80\n\ + lsls r2, 1\n\ + adds r1, r2\n\ +_080F79A8:\n\ + lsrs r0, r1, 8\n\ + str r0, [r4, 0x8]\n\ + ldr r1, [r4, 0x4]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + subs r0, r1\n\ + lsls r0, 11\n\ + movs r1, 0x64\n\ + bl __divsi3\n\ + adds r1, r0, 0\n\ + ands r0, r5\n\ + cmp r0, 0x7F\n\ + bls _080F79CC\n\ + movs r5, 0x80\n\ + lsls r5, 1\n\ + adds r1, r5\n\ +_080F79CC:\n\ + lsrs r0, r1, 8\n\ + str r0, [r4, 0xC]\n\ + mov r0, r8\n\ + lsls r4, r0, 24\n\ + lsrs r4, 24\n\ + adds r0, r4, 0\n\ + movs r1, 0x1\n\ + bl sub_80F7310\n\ + mov r2, r9\n\ + ldr r1, [r2]\n\ + ldr r1, [r1, 0x4]\n\ + add r1, r10\n\ + strb r0, [r1, 0x11]\n\ + adds r0, r4, 0\n\ + movs r1, 0x1\n\ + bl sub_80F7364\n\ + mov r4, r9\n\ + ldr r1, [r4]\n\ + ldr r1, [r1, 0x4]\n\ + add r1, r10\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0\n\ + bge _080F7A02\n\ + negs r0, r0\n\ +_080F7A02:\n\ + strb r0, [r1, 0x12]\n\ + ldr r0, =gContestFinalStandings\n\ + add r0, r8\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _080F7A60\n\ + mov r5, r9\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + mov r2, r10\n\ + adds r1, r2, r0\n\ + ldr r5, [r1, 0x8]\n\ + ldrh r3, [r1, 0x8]\n\ + ldr r4, [r1, 0xC]\n\ + ldrh r2, [r1, 0xC]\n\ + ldrb r0, [r1, 0x10]\n\ + cmp r0, 0\n\ + beq _080F7A2C\n\ + lsls r0, r2, 16\n\ + negs r0, r0\n\ + lsrs r2, r0, 16\n\ +_080F7A2C:\n\ + lsls r0, r3, 16\n\ + asrs r3, r0, 16\n\ + lsls r0, r2, 16\n\ + asrs r2, r0, 16\n\ + adds r0, r3, r2\n\ + cmp r0, 0x58\n\ + bne _080F7A60\n\ + cmp r2, 0\n\ + ble _080F7A58\n\ + subs r0, r4, 0x1\n\ + str r0, [r1, 0xC]\n\ + b _080F7A60\n\ + .pool\n\ +_080F7A58:\n\ + cmp r3, 0\n\ + ble _080F7A60\n\ + subs r0, r5, 0x1\n\ + str r0, [r1, 0x8]\n\ +_080F7A60:\n\ + movs r4, 0x14\n\ + add r10, r4\n\ + movs r5, 0x1\n\ + add r8, r5\n\ + mov r0, r8\n\ + cmp r0, 0x3\n\ + bgt _080F7A70\n\ + b _080F78EA\n\ +_080F7A70:\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} + +// static void sub_80F7A80(u8 arg0, u8 arg1) +// { +// int i; +// u8 taskId; +// u8 sp8, spC; + +// sp8 = 0; +// spC = 0; +// if (!arg0) +// { +// u32 var0; +// for (i = 0; i < 4; i++) +// { +// int var1 = gUnknown_0203A034->unk4->unk0[i].unk11; +// if (arg1 < var1) +// { +// int x = var1 + 19; +// x -= arg1; +// x--; +// FillBgTilemapBufferRect_Palette0(1, 0x60B3, x, i * 3 + 5, 1, 1); +// taskId = CreateTask(sub_80F7CA8, 10); +// var0 = ((gUnknown_0203A034->unk4->unk0[i].unk8 << 16) / gUnknown_0203A034->unk4->unk0[i].unk11) * (arg1 + 1); +// var0 &= 0xFFFF; +// if (var0 > 0x7FFF) +// var0 += 0x10000; + +// gTasks[taskId].data[0] = i; +// gTasks[taskId].data[1] = var0 >> 16; +// gUnknown_0203A034->unk0->unk14++; +// sp8++; +// } +// } +// } +// else +// { +// u32 var0; +// for (i = 0; i < 4; i++) +// { +// int tile; +// s8 var1 = gUnknown_0203A034->unk4->unk0[i].unk12; +// tile = gUnknown_0203A034->unk4->unk0[i].unk10 ? 0x60A5 : 0x60A3; +// if (arg1 < var1) +// { +// int thing = ((s8)arg1 - 19); +// int x = var1 - thing; +// x--; +// FillBgTilemapBufferRect_Palette0(1, tile, x, i * 3 + 6, 1, 1); +// taskId = CreateTask(sub_80F7CA8, 10); +// var0 = ((gUnknown_0203A034->unk4->unk0[i].unkC << 16) / gUnknown_0203A034->unk4->unk0[i].unk12) * (arg1 + 1); +// var0 &= 0xFFFF; +// if (var0 > 0x7FFF) +// var0 += 0x10000; + +// gTasks[taskId].data[0] = i; +// if (gUnknown_0203A034->unk4->unk0[i].unk10) +// { +// gTasks[taskId].data[2] = 1; +// spC++; +// } +// else +// { +// sp8++; +// } + +// if (gUnknown_0203A034->unk4->unk0[i].unk10) +// gTasks[taskId].data[1] = gUnknown_0203A034->unk4->unk0[i].unk8 - (var0 >> 16); +// else +// gTasks[taskId].data[1] = gUnknown_0203A034->unk4->unk0[i].unk8 + (var0 >> 16); + +// gUnknown_0203A034->unk0->unk14++; +// } +// } +// } + +// if (spC) +// PlaySE(SE_PIN); + +// if (sp8) +// PlaySE(SE_BAN); +// } + +NAKED +static void sub_80F7A80(u8 arg0, u8 arg1) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x14\n\ + lsls r0, 24\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r8, r1\n\ + movs r1, 0\n\ + str r1, [sp, 0x8]\n\ + movs r3, 0\n\ + str r3, [sp, 0xC]\n\ + cmp r0, 0\n\ + bne _080F7B5C\n\ + mov r9, r3\n\ + ldr r4, =gUnknown_0203A034\n\ + mov r10, r4\n\ + movs r7, 0xA0\n\ + lsls r7, 19\n\ + movs r6, 0\n\ +_080F7AAC:\n\ + mov r1, r10\n\ + ldr r0, [r1]\n\ + ldr r0, [r0, 0x4]\n\ + adds r0, r6, r0\n\ + ldrb r2, [r0, 0x11]\n\ + cmp r8, r2\n\ + bcs _080F7B2E\n\ + adds r2, 0x13\n\ + mov r3, r8\n\ + subs r2, r3\n\ + subs r2, 0x1\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + lsrs r3, r7, 24\n\ + movs r0, 0x1\n\ + str r0, [sp]\n\ + str r0, [sp, 0x4]\n\ + ldr r1, =0x000060b3\n\ + bl FillBgTilemapBufferRect_Palette0\n\ + ldr r0, =sub_80F7CA8\n\ + movs r1, 0xA\n\ + bl CreateTask\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + mov r0, r10\n\ + ldr r4, [r0]\n\ + ldr r1, [r4, 0x4]\n\ + adds r1, r6, r1\n\ + ldr r0, [r1, 0x8]\n\ + lsls r0, 16\n\ + ldrb r1, [r1, 0x11]\n\ + bl __udivsi3\n\ + mov r1, r8\n\ + adds r1, 0x1\n\ + adds r3, r0, 0\n\ + muls r3, r1\n\ + ldr r0, =0x0000ffff\n\ + ands r0, r3\n\ + ldr r1, =0x00007fff\n\ + cmp r0, r1\n\ + bls _080F7B0A\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + adds r3, r1\n\ +_080F7B0A:\n\ + ldr r1, =gTasks\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + mov r1, r9\n\ + strh r1, [r0, 0x8]\n\ + lsrs r1, r3, 16\n\ + strh r1, [r0, 0xA]\n\ + ldr r1, [r4]\n\ + ldrb r0, [r1, 0x14]\n\ + adds r0, 0x1\n\ + strb r0, [r1, 0x14]\n\ + ldr r0, [sp, 0x8]\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x8]\n\ +_080F7B2E:\n\ + movs r3, 0xC0\n\ + lsls r3, 18\n\ + adds r7, r3\n\ + adds r6, 0x14\n\ + movs r4, 0x1\n\ + add r9, r4\n\ + mov r0, r9\n\ + cmp r0, 0x3\n\ + ble _080F7AAC\n\ + b _080F7C7E\n\ + .pool\n\ +_080F7B5C:\n\ + movs r1, 0\n\ + mov r9, r1\n\ + mov r10, r1\n\ + movs r3, 0xC0\n\ + lsls r3, 19\n\ + str r3, [sp, 0x10]\n\ +_080F7B68:\n\ + ldr r4, =gUnknown_0203A034\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x4]\n\ + add r0, r10\n\ + ldrb r2, [r0, 0x12]\n\ + ldrb r0, [r0, 0x10]\n\ + ldr r1, =0x000060a3\n\ + cmp r0, 0\n\ + beq _080F7B7C\n\ + adds r1, 0x2\n\ +_080F7B7C:\n\ + lsls r0, r2, 24\n\ + asrs r0, 24\n\ + cmp r8, r0\n\ + bge _080F7C64\n\ + mov r3, r8\n\ + lsls r2, r3, 24\n\ + asrs r2, 24\n\ + subs r2, 0x13\n\ + subs r2, r0, r2\n\ + subs r2, 0x1\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + ldr r4, [sp, 0x10]\n\ + lsrs r3, r4, 24\n\ + movs r7, 0x1\n\ + str r7, [sp]\n\ + str r7, [sp, 0x4]\n\ + movs r0, 0x1\n\ + bl FillBgTilemapBufferRect_Palette0\n\ + ldr r0, =sub_80F7CA8\n\ + movs r1, 0xA\n\ + bl CreateTask\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + ldr r0, =gUnknown_0203A034\n\ + ldr r6, [r0]\n\ + ldr r1, [r6, 0x4]\n\ + add r1, r10\n\ + ldr r0, [r1, 0xC]\n\ + lsls r0, 16\n\ + ldrb r1, [r1, 0x12]\n\ + bl __udivsi3\n\ + mov r1, r8\n\ + adds r1, 0x1\n\ + adds r3, r0, 0\n\ + muls r3, r1\n\ + ldr r0, =0x0000ffff\n\ + ands r0, r3\n\ + ldr r1, =0x00007fff\n\ + cmp r0, r1\n\ + bls _080F7BDA\n\ + movs r1, 0x80\n\ + lsls r1, 9\n\ + adds r3, r1\n\ +_080F7BDA:\n\ + ldr r1, =gTasks\n\ + lsls r2, r5, 2\n\ + adds r0, r2, r5\n\ + lsls r0, 3\n\ + adds r4, r0, r1\n\ + mov r0, r9\n\ + strh r0, [r4, 0x8]\n\ + ldr r0, [r6, 0x4]\n\ + add r0, r10\n\ + ldrb r0, [r0, 0x10]\n\ + adds r6, r1, 0\n\ + cmp r0, 0\n\ + beq _080F7C1C\n\ + strh r7, [r4, 0xC]\n\ + ldr r0, [sp, 0xC]\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0xC]\n\ + b _080F7C26\n\ + .pool\n\ +_080F7C1C:\n\ + ldr r0, [sp, 0x8]\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x8]\n\ +_080F7C26:\n\ + ldr r1, =gUnknown_0203A034\n\ + ldr r0, [r1]\n\ + ldr r0, [r0, 0x4]\n\ + mov r4, r10\n\ + adds r1, r4, r0\n\ + ldrb r0, [r1, 0x10]\n\ + ldr r4, =gUnknown_0203A034\n\ + cmp r0, 0\n\ + beq _080F7C4C\n\ + adds r0, r2, r5\n\ + lsls r0, 3\n\ + adds r0, r6\n\ + lsrs r2, r3, 16\n\ + ldr r1, [r1, 0x8]\n\ + subs r1, r2\n\ + b _080F7C58\n\ + .pool\n\ +_080F7C4C:\n\ + adds r0, r2, r5\n\ + lsls r0, 3\n\ + adds r0, r6\n\ + lsrs r2, r3, 16\n\ + ldr r1, [r1, 0x8]\n\ + adds r1, r2\n\ +_080F7C58:\n\ + strh r1, [r0, 0xA]\n\ + ldr r0, [r4]\n\ + ldr r1, [r0]\n\ + ldrb r0, [r1, 0x14]\n\ + adds r0, 0x1\n\ + strb r0, [r1, 0x14]\n\ +_080F7C64:\n\ + movs r0, 0x14\n\ + add r10, r0\n\ + ldr r1, [sp, 0x10]\n\ + movs r3, 0xC0\n\ + lsls r3, 18\n\ + adds r1, r3\n\ + str r1, [sp, 0x10]\n\ + movs r4, 0x1\n\ + add r9, r4\n\ + mov r0, r9\n\ + cmp r0, 0x3\n\ + bgt _080F7C7E\n\ + b _080F7B68\n\ +_080F7C7E:\n\ + ldr r1, [sp, 0xC]\n\ + cmp r1, 0\n\ + beq _080F7C8A\n\ + movs r0, 0x16\n\ + bl PlaySE\n\ +_080F7C8A:\n\ + ldr r3, [sp, 0x8]\n\ + cmp r3, 0\n\ + beq _080F7C96\n\ + movs r0, 0x15\n\ + bl PlaySE\n\ +_080F7C96:\n\ + add sp, 0x14\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} + +#ifdef NONMATCHING +void sub_80F7CA8(u8 taskId) +{ + register int r4 asm("r4"); + int r9; + u8 r6; + s16 r7; + s16 r12; + int i; + u8 var0; + u16 tileNum; + + r4 = 0; + r9 = 0; + r6 = gTasks[taskId].data[0]; + r7 = gTasks[taskId].data[1]; + r12 = gTasks[taskId].data[2]; + if (r12) + { + if (gUnknown_0203A034->unk0->unkC[r6] <= 0) + r4 = 1; + } + else + { + if (gUnknown_0203A034->unk0->unkC[r6] > 87) + r4 = 1; + } + + if (gUnknown_0203A034->unk0->unkC[r6] == r7) + r9 = 1; + + if (!r9) + { + if (r4) + gUnknown_0203A034->unk0->unkC[r6] = r7; + else if (r12) + gUnknown_0203A034->unk0->unkC[r6] = gUnknown_0203A034->unk0->unkC[r6] - 1; + else + gUnknown_0203A034->unk0->unkC[r6] = gUnknown_0203A034->unk0->unkC[r6] + 1; + } + + if (!r4 && !r9) + { + for (i = 0; i < 11; i++) + { + if (gUnknown_0203A034->unk0->unkC[r6] >= (i + 1) * 8) + { + var0 = 8; + } + else if (gUnknown_0203A034->unk0->unkC[r6] >= i * 8) + { + int var2 = gUnknown_0203A034->unk0->unkC[r6]; + int var1 = var2; + if (var1 < 0) + var1 += 7; + + var0 = var2 - ((var1 >> 3) << 3); + } + else + { + var0 = 0; + } + + if (var0 < 4) + tileNum = 0x504C; + else + tileNum = 0x5057; + + FillBgTilemapBufferRect_Palette0(2, tileNum + var0, i + 7, r6 * 3 + 6, 1, 1); + } + } + + if (r9) + { + gUnknown_0203A034->unk0->unk14--; + DestroyTask(taskId); + } +} +#else +NAKED +void sub_80F7CA8(u8 taskId) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + sub sp, 0x8\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + movs r4, 0\n\ + mov r9, r4\n\ + ldr r1, =gTasks\n\ + lsls r0, 2\n\ + add r0, r8\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldrb r6, [r0, 0x8]\n\ + ldrh r7, [r0, 0xA]\n\ + ldrh r1, [r0, 0xC]\n\ + mov r12, r1\n\ + movs r2, 0xC\n\ + ldrsh r0, [r0, r2]\n\ + cmp r0, 0\n\ + beq _080F7CF8\n\ + ldr r2, =gUnknown_0203A034\n\ + ldr r0, [r2]\n\ + ldr r0, [r0]\n\ + lsls r1, r6, 1\n\ + adds r0, 0xC\n\ + adds r0, r1\n\ + movs r3, 0\n\ + ldrsh r0, [r0, r3]\n\ + adds r5, r1, 0\n\ + cmp r0, 0\n\ + bgt _080F7D10\n\ + b _080F7D0E\n\ + .pool\n\ +_080F7CF8:\n\ + ldr r2, =gUnknown_0203A034\n\ + ldr r0, [r2]\n\ + ldr r0, [r0]\n\ + lsls r1, r6, 1\n\ + adds r0, 0xC\n\ + adds r0, r1\n\ + movs r3, 0\n\ + ldrsh r0, [r0, r3]\n\ + adds r5, r1, 0\n\ + cmp r0, 0x57\n\ + ble _080F7D10\n\ +_080F7D0E:\n\ + movs r4, 0x1\n\ +_080F7D10:\n\ + ldr r0, [r2]\n\ + ldr r0, [r0]\n\ + adds r0, 0xC\n\ + adds r2, r0, r5\n\ + ldrh r3, [r2]\n\ + movs r0, 0\n\ + ldrsh r1, [r2, r0]\n\ + lsls r0, r7, 16\n\ + asrs r0, 16\n\ + cmp r1, r0\n\ + bne _080F7D2A\n\ + movs r1, 0x1\n\ + mov r9, r1\n\ +_080F7D2A:\n\ + mov r0, r9\n\ + cmp r0, 0\n\ + bne _080F7D4A\n\ + cmp r4, 0\n\ + beq _080F7D3C\n\ + strh r7, [r2]\n\ + b _080F7D4A\n\ + .pool\n\ +_080F7D3C:\n\ + mov r1, r12\n\ + cmp r1, 0\n\ + beq _080F7D46\n\ + subs r0, r3, 0x1\n\ + b _080F7D48\n\ +_080F7D46:\n\ + adds r0, r3, 0x1\n\ +_080F7D48:\n\ + strh r0, [r2]\n\ +_080F7D4A:\n\ + cmp r4, 0\n\ + bne _080F7DC4\n\ + mov r2, r9\n\ + cmp r2, 0\n\ + bne _080F7DCA\n\ + movs r2, 0\n\ +_080F7D56:\n\ + ldr r0, =gUnknown_0203A034\n\ + ldr r0, [r0]\n\ + ldr r0, [r0]\n\ + adds r0, 0xC\n\ + adds r0, r5\n\ + movs r1, 0\n\ + ldrsh r3, [r0, r1]\n\ + adds r0, r2, 0x1\n\ + lsls r1, r0, 3\n\ + adds r4, r0, 0\n\ + cmp r3, r1\n\ + blt _080F7D78\n\ + movs r0, 0x8\n\ + b _080F7D94\n\ + .pool\n\ +_080F7D78:\n\ + lsls r0, r2, 3\n\ + cmp r3, r0\n\ + blt _080F7D92\n\ + adds r0, r3, 0\n\ + cmp r3, 0\n\ + bge _080F7D86\n\ + adds r0, r3, 0x7\n\ +_080F7D86:\n\ + asrs r0, 3\n\ + lsls r0, 3\n\ + subs r0, r3, r0\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + b _080F7D94\n\ +_080F7D92:\n\ + movs r0, 0\n\ +_080F7D94:\n\ + cmp r0, 0x3\n\ + bhi _080F7DA0\n\ + ldr r3, =0x0000504c\n\ + b _080F7DA2\n\ + .pool\n\ +_080F7DA0:\n\ + ldr r3, =0x00005057\n\ +_080F7DA2:\n\ + adds r1, r0, r3\n\ + adds r2, 0x7\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r3, r5, r6\n\ + adds r3, 0x6\n\ + lsls r3, 24\n\ + movs r0, 0x1\n\ + str r0, [sp]\n\ + str r0, [sp, 0x4]\n\ + movs r0, 0x2\n\ + lsrs r3, 24\n\ + bl FillBgTilemapBufferRect_Palette0\n\ + adds r2, r4, 0\n\ + cmp r2, 0xA\n\ + ble _080F7D56\n\ +_080F7DC4:\n\ + mov r0, r9\n\ + cmp r0, 0\n\ + beq _080F7DDC\n\ +_080F7DCA:\n\ + ldr r0, =gUnknown_0203A034\n\ + ldr r0, [r0]\n\ + ldr r1, [r0]\n\ + ldrb r0, [r1, 0x14]\n\ + subs r0, 0x1\n\ + strb r0, [r1, 0x14]\n\ + mov r0, r8\n\ + bl DestroyTask\n\ +_080F7DDC:\n\ + add sp, 0x8\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif // NONMATCHING + +static void sub_80F7DF4(void) +{ + gUnknown_0203A034 = AllocZeroed(sizeof(*gUnknown_0203A034)); + gUnknown_0203A034->unk0 = AllocZeroed(sizeof(*gUnknown_0203A034->unk0)); + gUnknown_0203A034->unk4 = AllocZeroed(sizeof(*gUnknown_0203A034->unk4)); + gUnknown_0203A034->unk8 = AllocZeroed(BG_SCREEN_SIZE); + gUnknown_0203A034->unkC[0] = AllocZeroed(BG_SCREEN_SIZE); + gUnknown_0203A034->unkC[1] = AllocZeroed(BG_SCREEN_SIZE); + gUnknown_0203A034->unkC[2] = AllocZeroed(BG_SCREEN_SIZE); + gUnknown_0203A034->unkC[3] = AllocZeroed(BG_SCREEN_SIZE); + gUnknown_0203A034->unk1C = AllocZeroed(0x1000); + AllocateMonSpritesGfx(); +} + +static void sub_80F7E64(void) +{ + FREE_AND_SET_NULL(gUnknown_0203A034->unk0); + FREE_AND_SET_NULL(gUnknown_0203A034->unk4); + FREE_AND_SET_NULL(gUnknown_0203A034->unk8); + FREE_AND_SET_NULL(gUnknown_0203A034->unkC[0]); + FREE_AND_SET_NULL(gUnknown_0203A034->unkC[1]); + FREE_AND_SET_NULL(gUnknown_0203A034->unkC[2]); + FREE_AND_SET_NULL(gUnknown_0203A034->unkC[3]); + FREE_AND_SET_NULL(gUnknown_0203A034->unk1C); + FREE_AND_SET_NULL(gUnknown_0203A034); + FreeMonSpritesGfx(); +} + +static void sub_80F7ED0(int windowId, u8 *str, int arg2) +{ + struct TextPrinterTemplate textPrinter; + textPrinter.currentChar = str; + textPrinter.windowId = windowId; + textPrinter.fontId = 7; + textPrinter.x = arg2; + textPrinter.y = 2; + textPrinter.currentX = arg2; + textPrinter.currentY = 2; + textPrinter.letterSpacing = 0; + textPrinter.lineSpacing = 0; + textPrinter.unk = 0; + textPrinter.fgColor = 1; + textPrinter.bgColor = 0; + textPrinter.shadowColor = 8; + AddTextPrinter(&textPrinter, 0, NULL); + PutWindowTilemap(windowId); +} + +void sub_80F7F30(void) +{ + u8 result = sub_80DAE0C(&gPlayerParty[gContestMonPartyIndex]); + if (result) + { + sub_80DAB8C(gSpecialVar_ContestCategory, gSpecialVar_ContestRank); + sub_80DB09C(gSpecialVar_ContestCategory); + } + + gSpecialVar_Result = result; +} + +u16 sub_80F7F7C(void) +{ + u16 result = 0; + struct Pokemon *mon = &gPlayerParty[gContestMonPartyIndex]; + switch (gSpecialVar_ContestCategory) + { + case CONTEST_CATEGORY_COOL: + if (GetMonData(mon, MON_DATA_COOL_RIBBON) > gSpecialVar_ContestRank) + result = 1; + break; + case CONTEST_CATEGORY_BEAUTY: + if (GetMonData(mon, MON_DATA_BEAUTY_RIBBON) > gSpecialVar_ContestRank) + result = 1; + break; + case CONTEST_CATEGORY_CUTE: + if (GetMonData(mon, MON_DATA_CUTE_RIBBON) > gSpecialVar_ContestRank) + result = 1; + break; + case CONTEST_CATEGORY_SMART: + if (GetMonData(mon, MON_DATA_SMART_RIBBON) > gSpecialVar_ContestRank) + result = 1; + break; + case CONTEST_CATEGORY_TOUGH: + if (GetMonData(mon, MON_DATA_TOUGH_RIBBON) > gSpecialVar_ContestRank) + result = 1; + break; + } + + return result; +} + +void sub_80F7FFC(void) +{ + u8 ribbonData; + + if (gContestFinalStandings[gContestPlayerMonIndex] != 0) + return; + + switch (gSpecialVar_ContestCategory) + { + case CONTEST_CATEGORY_COOL: + ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); + if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + { + ribbonData++; + SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON, &ribbonData); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) + sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); + } + break; + case CONTEST_CATEGORY_BEAUTY: + ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); + if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + { + ribbonData++; + SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON, &ribbonData); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) + sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); + } + break; + case CONTEST_CATEGORY_CUTE: + ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); + if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + { + ribbonData++; + SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON, &ribbonData); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) + sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); + } + break; + case CONTEST_CATEGORY_SMART: + ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); + if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + { + ribbonData++; + SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON, &ribbonData); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) + sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); + } + break; + case CONTEST_CATEGORY_TOUGH: + ribbonData = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); + if (ribbonData <= gSpecialVar_ContestRank && ribbonData < 4) + { + ribbonData++; + SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON, &ribbonData); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) + sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); + } + break; + } +} + +void sub_80F8264(void) +{ + StringCopy(gStringVar1, gContestMons[gSpecialVar_0x8006].trainerName); + sub_81DB5AC(gStringVar1); +} + +void sub_80F8290(void) +{ + StringCopy(gStringVar3, gContestMons[gSpecialVar_0x8006].nickname); +} + +void sub_80F82B4(void) +{ + u8 i; + u8 count; + + for (i = 0, count = 0; i < 4; i++) + { + if (gContestMonConditions[gSpecialVar_0x8006] < gContestMonConditions[i]) + count++; + } + + gSpecialVar_0x8004 = count; +} + +void sub_80F82FC(void) +{ + gSpecialVar_0x8004 = gContestMonConditions[gSpecialVar_0x8006]; +} + +void sub_80F831C(void) +{ + u8 i; + + for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + ; + + gSpecialVar_0x8005 = i; +} + +void sub_80F834C(void) +{ + u8 i; + + for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + ; + + StringCopy(gStringVar3, gContestMons[i].trainerName); + sub_81DB5AC(gStringVar3); +} + +void sub_80F8390(void) +{ + u8 i; + + for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + ; + + StringCopy(gStringVar1, gContestMons[i].nickname); +} + +void sub_80F83D0(void) +{ + SetMainCallback2(sub_80D7B24); +} + +static void sub_80F83E0(u8 taskId) +{ + if (!gPaletteFade.active) + { + DestroyTask(taskId); + SetMainCallback2(sub_80F83D0); + } +} + +void sub_80F840C(void) +{ + ScriptContext2_Enable(); + CreateTask(sub_80F83E0, 10); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); +} + +void sub_80F8438(void) +{ + gSpecialVar_0x8004 = gContestMons[gSpecialVar_0x8006].species; +} + +static void sub_80F8458(u8 taskId) +{ + if (!gPaletteFade.active) + { + DestroyTask(taskId); + SetMainCallback2(sub_80F5B00); + } +} + +void sub_80F8484(void) +{ + ScriptContext2_Enable(); + CreateTask(sub_80F8458, 10); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); +} + +void sub_80F84B0(void) +{ + gSpecialVar_0x8004 = gContestPlayerMonIndex; +} + +void sub_80F84C4(u8 taskId) +{ + u8 newTaskId; + ScriptContext2_Enable(); + newTaskId = CreateTask(sub_80FC580, 0); + SetTaskFuncWithFollowupFunc(newTaskId, sub_80FC580, sub_80F8508); + gTasks[newTaskId].data[9] = taskId; +} + +static void sub_80F8508(u8 taskId) +{ + if (gIsLinkContest & 0x4) + { + sub_80DA8C8(gContestMonPartyIndex); + SetTaskFuncWithFollowupFunc(taskId, sub_80FC6BC, sub_80F8568); + } + else + { + sub_80DA8C8(gContestMonPartyIndex); + gTasks[taskId].func = sub_81D9DE4; + } +} + +static void sub_80F8568(u8 taskId) +{ + SetTaskFuncWithFollowupFunc(taskId, sub_80FC804, sub_80F8584); +} + +static void sub_80F8584(u8 taskId) +{ + SetTaskFuncWithFollowupFunc(taskId, sub_80FCE48, sub_80F85A0); +} + +static void sub_80F85A0(u8 taskId) +{ + SetTaskFuncWithFollowupFunc(taskId, sub_80FC894, sub_80F85BC); +} + +#ifdef NONMATCHING +static void sub_80F85BC(u8 taskId) +{ + u32 i; + u8 sp0[4]; + u8 sp4[4]; + + memset(sp0, 0, sizeof(sp0)); + memset(sp4, 0, sizeof(sp4)); + + for (i = 0; i < gNumLinkContestPlayers; i++) + sp0[i] = gTasks[taskId].data[i + 1]; + + for (i = 0; i < gNumLinkContestPlayers; i++) + { + if (sp0[0] != sp0[i + 1]) + break; + } + + if (i == gNumLinkContestPlayers) + gSpecialVar_0x8004 = 0; + else + gSpecialVar_0x8004 = 1; + + for (i = 0; i < gNumLinkContestPlayers; i++) + sp4[i] = gTasks[taskId].data[i + 5]; + + gUnknown_02039F2B = sub_80F86E0(sp4); + sub_80DB09C(gSpecialVar_ContestCategory); + SetTaskFuncWithFollowupFunc(taskId, sub_80FCF40, sub_80F86B8); +} +#else +NAKED +static void sub_80F85BC(u8 taskId) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + sub sp, 0x8\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + str r0, [sp, 0x4]\n\ + movs r3, 0\n\ + ldr r5, =gNumLinkContestPlayers\n\ + mov r12, r5\n\ + ldr r0, =gSpecialVar_0x8004\n\ + mov r9, r0\n\ + add r1, sp, 0x4\n\ + mov r8, r1\n\ + ldrb r0, [r5]\n\ + cmp r3, r0\n\ + bcs _080F8606\n\ + lsls r0, r6, 2\n\ + adds r0, r6\n\ + lsls r4, r0, 3\n\ + ldr r7, =gTasks + 0x8\n\ +_080F85EC:\n\ + mov r1, sp\n\ + adds r2, r1, r3\n\ + adds r1, r3, 0x1\n\ + lsls r0, r1, 1\n\ + adds r0, r4\n\ + adds r0, r7\n\ + ldrh r0, [r0]\n\ + strb r0, [r2]\n\ + lsls r1, 24\n\ + lsrs r3, r1, 24\n\ + ldrb r0, [r5]\n\ + cmp r3, r0\n\ + bcc _080F85EC\n\ +_080F8606:\n\ + movs r3, 0\n\ + mov r1, r12\n\ + ldrb r0, [r1]\n\ + cmp r3, r0\n\ + bcs _080F862A\n\ + adds r4, r0, 0\n\ + mov r2, sp\n\ +_080F8614:\n\ + adds r0, r3, 0x1\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + cmp r3, r4\n\ + bcs _080F862A\n\ + mov r0, sp\n\ + adds r1, r0, r3\n\ + ldrb r0, [r2]\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + beq _080F8614\n\ +_080F862A:\n\ + mov r1, r12\n\ + ldrb r1, [r1]\n\ + cmp r3, r1\n\ + bne _080F8644\n\ + movs r0, 0\n\ + b _080F8646\n\ + .pool\n\ +_080F8644:\n\ + movs r0, 0x1\n\ +_080F8646:\n\ + mov r1, r9\n\ + strh r0, [r1]\n\ + movs r3, 0\n\ + mov r4, r12\n\ + ldrb r0, [r4]\n\ + cmp r3, r0\n\ + bcs _080F8678\n\ + mov r5, r8\n\ + lsls r0, r6, 2\n\ + adds r0, r6\n\ + lsls r2, r0, 3\n\ + ldr r7, =gTasks + 0x8\n\ +_080F865E:\n\ + adds r1, r5, r3\n\ + adds r0, r3, 0x5\n\ + lsls r0, 1\n\ + adds r0, r2\n\ + adds r0, r7\n\ + ldrh r0, [r0]\n\ + strb r0, [r1]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + ldrb r1, [r4]\n\ + cmp r3, r1\n\ + bcc _080F865E\n\ +_080F8678:\n\ + mov r0, r8\n\ + bl sub_80F86E0\n\ + ldr r1, =gUnknown_02039F2B\n\ + strb r0, [r1]\n\ + ldr r0, =gSpecialVar_ContestCategory\n\ + ldrb r0, [r0]\n\ + bl sub_80DB09C\n\ + ldr r1, =sub_80FCF40\n\ + ldr r2, =sub_80F86B8\n\ + adds r0, r6, 0\n\ + bl SetTaskFuncWithFollowupFunc\n\ + add sp, 0x8\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif // NONMATCHING + +static void sub_80F86B8(u8 taskId) +{ + sub_80DCE58(0); + SetTaskFuncWithFollowupFunc(taskId, sub_80FCFD0, sub_80F8714); +} + +u8 sub_80F86E0(u8 *arg0) +{ + int i; + u8 result = 0; + + for (i = 1; i < gNumLinkContestPlayers; i++) + { + if (arg0[result] < arg0[i]) + result = i; + } + + return result; +} + +void sub_80F8714(u8 taskId) +{ + int i; + + if (gSpecialVar_0x8004 == 1) + { + if (IsLinkTaskFinished()) + gTasks[taskId].func = sub_80F878C; + } + else + { + for (i = 0; i < 4; i++) + StringGetEnd10(gContestMons[i].nickname); + + DestroyTask(taskId); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + } +} + +static void sub_80F878C(u8 taskId) +{ + sub_800AC34(); + gTasks[taskId].func = sub_80F87B4; +} + +static void sub_80F87B4(u8 taskId) +{ + if (!gReceivedRemoteLinkPlayers) + { + DestroyTask(taskId); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + } +}