From 76510d58bb66a2e0fb0909330ac0d3ac97c083e1 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Wed, 19 Dec 2018 08:53:43 -0800 Subject: [PATCH 01/12] Matched up to sub_80DBF68, sub_80DBF90 WIP. --- asm/contest.s | 974 ---------------------------------------------- include/contest.h | 8 + src/contest.c | 308 ++++++++++++++- 3 files changed, 313 insertions(+), 977 deletions(-) diff --git a/asm/contest.s b/asm/contest.s index a9abd9430..8a148e529 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5,980 +5,6 @@ .text - thumb_func_start sub_80DB884 -sub_80DB884: @ 80DB884 - push {r4,lr} - movs r4, 0 -_080DB888: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DB798 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DB888 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DB884 - - thumb_func_start sub_80DB89C -sub_80DB89C: @ 80DB89C - push {lr} - movs r0, 0x4 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0 - bl Contest_SetBgCopyFlags - pop {r0} - bx r0 - thumb_func_end sub_80DB89C - - thumb_func_start sub_80DB8B8 -sub_80DB8B8: @ 80DB8B8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - adds r0, r4, 0 - bl Contest_IsMonsTurnDisabled - lsls r0, 24 - cmp r0, 0 - beq _080DB8D0 - movs r0, 0 - b _080DB90A -_080DB8D0: - ldr r0, =gContestPlayerMonIndex - ldrb r0, [r0] - cmp r4, r0 - beq _080DB8F4 - adds r0, r4, 0 - bl ContestAI_ResetAI - bl ContestAI_GetActionToUse - lsls r0, 24 - ldr r2, =gContestMons - lsrs r0, 23 - lsls r1, r4, 6 - b _080DB902 - .pool -_080DB8F4: - ldr r2, =gContestMons - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - ldrb r0, [r0] - lsls r0, 1 - lsls r1, r5, 6 -_080DB902: - adds r0, r1 - adds r2, 0x1E - adds r0, r2 - ldrh r0, [r0] -_080DB90A: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DB8B8 - - thumb_func_start sub_80DB918 -sub_80DB918: @ 80DB918 - push {r4,r5,lr} - movs r4, 0 - movs r5, 0 -_080DB91E: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DB8B8 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r1, [r1, 0x4] - adds r1, r5, r1 - strh r0, [r1, 0x6] - adds r5, 0x1C - adds r4, 0x1 - cmp r4, 0x3 - ble _080DB91E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DB918 - - thumb_func_start sub_80DB944 -sub_80DB944: @ 80DB944 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - ldr r5, =gContestResources - mov r4, sp - movs r3, 0 - movs r6, 0x3 -_080DB956: - ldr r2, [r5] - ldr r1, [r2, 0x4] - adds r1, r3, r1 - ldrh r0, [r1, 0x2] - ldrh r7, [r1, 0x4] - adds r0, r7 - strh r0, [r1, 0x4] - ldr r0, [r2, 0x4] - adds r0, r3, r0 - ldrh r0, [r0, 0x4] - strh r0, [r4] - adds r4, 0x2 - adds r3, 0x1C - subs r6, 0x1 - cmp r6, 0 - bge _080DB956 - movs r6, 0 -_080DB978: - movs r4, 0x3 - cmp r4, r6 - ble _080DB9A4 -_080DB97E: - subs r5, r4, 0x1 - lsls r0, r5, 1 - mov r1, sp - adds r3, r1, r0 - lsls r0, r4, 1 - adds r2, r1, r0 - ldrh r4, [r3] - movs r7, 0 - ldrsh r1, [r3, r7] - movs r7, 0 - ldrsh r0, [r2, r7] - cmp r1, r0 - bge _080DB99E - ldrh r0, [r2] - strh r4, [r2] - strh r0, [r3] -_080DB99E: - adds r4, r5, 0 - cmp r4, r6 - bgt _080DB97E -_080DB9A4: - adds r6, 0x1 - cmp r6, 0x2 - ble _080DB978 - movs r6, 0 - movs r0, 0x4 - negs r0, r0 - mov r9, r0 - ldr r1, =gContestResources - mov r8, r1 - movs r7, 0x3 - mov r12, r7 -_080DB9BA: - movs r4, 0 - lsls r0, r6, 3 - adds r7, r6, 0x1 - subs r0, r6 - lsls r5, r0, 2 - mov r3, sp -_080DB9C6: - mov r1, r8 - ldr r0, [r1] - ldr r0, [r0, 0x4] - adds r2, r5, r0 - movs r6, 0x4 - ldrsh r1, [r2, r6] - movs r6, 0 - ldrsh r0, [r3, r6] - cmp r1, r0 - bne _080DB9F0 - mov r0, r12 - ands r4, r0 - ldrb r1, [r2, 0xB] - mov r0, r9 - ands r0, r1 - orrs r0, r4 - strb r0, [r2, 0xB] - b _080DB9F8 - .pool -_080DB9F0: - adds r3, 0x2 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DB9C6 -_080DB9F8: - adds r6, r7, 0 - cmp r6, 0x3 - ble _080DB9BA - movs r0, 0x1 - bl sub_80DCE58 - bl sub_80DD590 - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80DB944 - - thumb_func_start sub_80DBA18 -sub_80DBA18: @ 80DBA18 - push {r4,r5,lr} - ldr r4, =gContestResources - movs r2, 0 - movs r3, 0x3 -_080DBA20: - ldr r0, [r4] - ldr r0, [r0, 0x4] - adds r1, r2, r0 - ldrh r0, [r1, 0x6] - cmp r0, 0 - bne _080DBA34 - movs r1, 0x5 - b _080DBA52 - .pool -_080DBA34: - movs r5, 0x2 - ldrsh r0, [r1, r5] - movs r1, 0 - cmp r0, 0 - ble _080DBA52 - movs r1, 0x1 - cmp r0, 0x1D - ble _080DBA52 - movs r1, 0x2 - cmp r0, 0x3B - ble _080DBA52 - movs r1, 0x4 - cmp r0, 0x4F - bgt _080DBA52 - movs r1, 0x3 -_080DBA52: - ldr r0, [r4] - ldr r0, [r0, 0x4] - adds r0, r2, r0 - strb r1, [r0, 0x1A] - adds r2, 0x1C - subs r3, 0x1 - cmp r3, 0 - bge _080DBA20 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80DBA18 - - thumb_func_start sub_80DBA68 -sub_80DBA68: @ 80DBA68 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r2, [r1, 0x4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, r1, r2 - ldrb r1, [r2, 0xC] - movs r0, 0x6 - ands r0, r1 - cmp r0, 0 - bne _080DBA90 - ldrb r1, [r2, 0xB] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080DBA98 -_080DBA90: - movs r0, 0 - b _080DBA9A - .pool -_080DBA98: - movs r0, 0x1 -_080DBA9A: - pop {r1} - bx r1 - thumb_func_end sub_80DBA68 - - thumb_func_start sub_80DBAA0 -sub_80DBAA0: @ 80DBAA0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r5, =gContestResources - movs r0, 0 - mov r8, r0 - movs r1, 0x7 - negs r1, r1 - mov r10, r1 - movs r0, 0x2 - negs r0, r0 - mov r9, r0 - movs r4, 0 - movs r6, 0x3 -_080DBAC0: - ldr r1, [r5] - ldr r0, [r1, 0x4] - adds r0, r4, r0 - movs r2, 0 - strh r2, [r0, 0x2] - ldr r0, [r1, 0x4] - adds r0, r4, r0 - strh r2, [r0] - ldr r0, [r1, 0x4] - adds r0, r4, r0 - mov r1, r8 - strb r1, [r0, 0x12] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r3, r4, r0 - ldrb r2, [r3, 0xC] - movs r0, 0x6 - ands r0, r2 - cmp r0, 0 - beq _080DBAFC - lsls r0, r2, 29 - lsrs r0, 30 - subs r0, 0x1 - movs r1, 0x3 - ands r0, r1 - lsls r0, 1 - mov r1, r10 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xC] -_080DBAFC: - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - mov r1, r8 - strb r1, [r0, 0xE] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x10] - mov r0, r9 - ands r0, r2 - strb r0, [r1, 0x10] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - mov r1, r8 - strb r1, [r0, 0xF] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x10] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x10] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x10] - movs r7, 0x5 - negs r7, r7 - adds r0, r7, 0 - ands r0, r2 - strb r0, [r1, 0x10] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x10] - movs r0, 0x9 - negs r0, r0 - mov r12, r0 - ands r0, r2 - strb r0, [r1, 0x10] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0xC] - mov r0, r9 - ands r0, r2 - strb r0, [r1, 0xC] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - movs r1, 0xFF - strb r1, [r0, 0x13] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0, 0x14] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x10] - movs r0, 0x31 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x10] - ldr r0, [r5] - ldr r2, [r0, 0x4] - adds r2, r4, r2 - ldrb r3, [r2, 0x15] - lsls r1, r3, 31 - lsrs r1, 31 - lsls r1, 2 - adds r0, r7, 0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x15] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x15] - mov r0, r9 - ands r0, r2 - strb r0, [r1, 0x15] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x11] - movs r0, 0x4 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x11] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x11] - movs r0, 0x21 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x11] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r2, r4, r0 - ldrb r1, [r2, 0x11] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _080DBBF4 - ldrb r1, [r2, 0xC] - mov r0, r10 - ands r0, r1 - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2, 0xC] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x11] - adds r0, r7, 0 - ands r0, r2 - strb r0, [r1, 0x11] -_080DBBF4: - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r2, r4, r0 - ldrb r1, [r2, 0x11] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _080DBC1A - ldrb r0, [r2, 0xB] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0xB] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x11] - mov r0, r12 - ands r0, r2 - strb r0, [r1, 0x11] -_080DBC1A: - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x11] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x11] - adds r4, 0x1C - subs r6, 0x1 - cmp r6, 0 - blt _080DBC34 - b _080DBAC0 -_080DBC34: - movs r6, 0 - ldr r5, =gContestResources - movs r7, 0 - movs r4, 0 -_080DBC3C: - ldr r3, [r5] - ldr r0, [r3, 0x4] - adds r0, r4, r0 - ldrh r1, [r0, 0x6] - strh r1, [r0, 0x8] - ldr r2, [r3] - lsls r1, r6, 1 - ldrb r0, [r2, 0x1] - lsls r0, 3 - adds r1, r0 - adds r2, 0x1C - adds r2, r1 - ldr r0, [r3, 0x4] - adds r0, r4, r0 - ldrh r0, [r0, 0x6] - strh r0, [r2] - ldr r0, [r3, 0x4] - adds r0, r4, r0 - ldrh r0, [r0, 0x6] - bl Contest_GetMoveExcitement - ldr r1, [r5] - ldr r2, [r1] - ldrb r1, [r2, 0x1] - lsls r1, 2 - adds r1, r6, r1 - adds r2, 0x44 - adds r2, r1 - strb r0, [r2] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - strh r7, [r0, 0x6] - adds r4, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - ble _080DBC3C - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0, 0x10] - ldrb r1, [r2, 0x1] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DBAA0 - - thumb_func_start Contest_IsMonsTurnDisabled -Contest_IsMonsTurnDisabled: @ 80DBCA8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r2, [r1, 0x4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, r1, r2 - ldrb r1, [r2, 0xC] - movs r0, 0x6 - ands r0, r1 - cmp r0, 0 - bne _080DBCD0 - ldrb r1, [r2, 0xB] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080DBCD8 -_080DBCD0: - movs r0, 0x1 - b _080DBCDA - .pool -_080DBCD8: - movs r0, 0 -_080DBCDA: - pop {r1} - bx r1 - thumb_func_end Contest_IsMonsTurnDisabled - - thumb_func_start sub_80DBCE0 -sub_80DBCE0: @ 80DBCE0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_80DBD34 - ldr r1, =gUnknown_02039F18 - lsls r4, 1 - adds r1, r4, r1 - strh r0, [r1] - ldr r2, =gUnknown_02039F08 - adds r2, r4, r2 - ldr r1, =gContestMonConditions - adds r4, r1 - ldrh r4, [r4] - adds r0, r4 - strh r0, [r2] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DBCE0 - - thumb_func_start sub_80DBD18 -sub_80DBD18: @ 80DBD18 - push {r4,lr} - movs r4, 0 -_080DBD1C: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DBCE0 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DBD1C - bl sub_80DBD4C - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DBD18 - - thumb_func_start sub_80DBD34 -sub_80DBD34: @ 80DBD34 - lsls r0, 24 - ldr r1, =gUnknown_02039F10 - lsrs r0, 23 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - lsls r0, 17 - asrs r0, 16 - bx lr - .pool - thumb_func_end sub_80DBD34 - - thumb_func_start sub_80DBD4C -sub_80DBD4C: @ 80DBD4C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x70 - mov r0, sp - movs r1, 0 - movs r2, 0x8 - bl memset - movs r0, 0 - mov r9, r0 - mov r1, sp - adds r1, 0x8 - str r1, [sp, 0x64] - mov r3, sp - adds r3, 0xC - str r3, [sp, 0x68] - mov r6, sp - adds r6, 0x14 - str r6, [sp, 0x6C] - mov r4, sp -_080DBD7A: - bl Random - strh r0, [r4] - movs r2, 0 - cmp r2, r9 - bge _080DBDB8 - mov r1, sp - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r1] - cmp r0, r1 - bne _080DBD9C - subs r4, 0x2 - movs r7, 0x1 - negs r7, r7 - add r9, r7 - b _080DBDB8 -_080DBD9C: - adds r2, 0x1 - cmp r2, r9 - bge _080DBDB8 - lsls r0, r2, 1 - mov r3, sp - adds r1, r3, r0 - ldrh r0, [r4] - ldrh r1, [r1] - cmp r0, r1 - bne _080DBD9C - subs r4, 0x2 - movs r6, 0x1 - negs r6, r6 - add r9, r6 -_080DBDB8: - adds r4, 0x2 - movs r7, 0x1 - add r9, r7 - mov r0, r9 - cmp r0, 0x3 - ble _080DBD7A - movs r1, 0 - mov r9, r1 - mov r4, sp - ldr r6, =gUnknown_02039F08 - ldr r2, [sp, 0x64] - ldr r5, =gContestMonConditions - ldr r3, [sp, 0x68] -_080DBDD2: - mov r7, r9 - lsls r1, r7, 4 - movs r7, 0 - ldrsh r0, [r6, r7] - str r0, [r2] - movs r7, 0 - ldrsh r0, [r5, r7] - str r0, [r3] - ldrh r0, [r4] - str r0, [r2, 0x8] - ldr r0, [sp, 0x6C] - adds r1, r0, r1 - mov r7, r9 - str r7, [r1] - adds r4, 0x2 - adds r6, 0x2 - adds r2, 0x10 - adds r5, 0x2 - adds r3, 0x10 - movs r0, 0x1 - add r9, r0 - mov r1, r9 - cmp r1, 0x3 - ble _080DBDD2 - movs r3, 0 - mov r9, r3 -_080DBE06: - movs r4, 0x3 - cmp r4, r9 - ble _080DBE90 - add r7, sp, 0x48 - ldr r6, [sp, 0x68] - str r6, [sp, 0x58] - ldr r0, [sp, 0x64] - adds r0, 0x8 - str r0, [sp, 0x5C] - ldr r1, [sp, 0x6C] - str r1, [sp, 0x60] -_080DBE1C: - subs r3, r4, 0x1 - mov r10, r3 - mov r0, r10 - adds r1, r4, 0 - ldr r2, [sp, 0x64] - bl sub_80DBF30 - lsls r0, 24 - cmp r0, 0 - beq _080DBE8A - mov r6, r10 - lsls r2, r6, 4 - ldr r0, [sp, 0x64] - adds r3, r0, r2 - ldr r0, [r3] - str r0, [sp, 0x48] - ldr r1, [sp, 0x58] - adds r6, r1, r2 - ldr r0, [r6] - str r0, [r7, 0x4] - ldr r0, [sp, 0x5C] - adds r0, r2 - mov r8, r0 - ldr r0, [r0] - str r0, [r7, 0x8] - ldr r1, [sp, 0x60] - adds r2, r1, r2 - ldr r0, [r2] - str r0, [r7, 0xC] - lsls r1, r4, 4 - ldr r0, [sp, 0x64] - adds r5, r0, r1 - ldr r0, [r5] - str r0, [r3] - ldr r3, [sp, 0x58] - adds r4, r3, r1 - ldr r0, [r4] - str r0, [r6] - ldr r6, [sp, 0x5C] - adds r3, r6, r1 - ldr r0, [r3] - mov r6, r8 - str r0, [r6] - ldr r0, [sp, 0x60] - adds r1, r0, r1 - ldr r0, [r1] - str r0, [r2] - ldr r0, [sp, 0x48] - str r0, [r5] - ldr r0, [r7, 0x4] - str r0, [r4] - ldr r0, [r7, 0x8] - str r0, [r3] - ldr r0, [r7, 0xC] - str r0, [r1] -_080DBE8A: - mov r4, r10 - cmp r4, r9 - bgt _080DBE1C -_080DBE90: - movs r1, 0x1 - add r9, r1 - mov r3, r9 - cmp r3, 0x2 - ble _080DBE06 - movs r6, 0 - mov r9, r6 - ldr r2, =gContestFinalStandings - ldr r1, [sp, 0x6C] -_080DBEA2: - ldr r0, [r1] - adds r0, r2 - mov r7, r9 - strb r7, [r0] - adds r1, 0x10 - movs r0, 0x1 - add r9, r0 - mov r3, r9 - cmp r3, 0x3 - ble _080DBEA2 - add sp, 0x70 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DBD4C - - thumb_func_start sub_80DBED4 -sub_80DBED4: @ 80DBED4 - push {lr} - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080DBF0E - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, =gContestFinalStandings - ldr r0, =gContestPlayerMonIndex - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - lsls r1, 1 - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - lsls r0, 3 - adds r1, r0 - ldr r0, =0x00000624 - adds r2, r0 - adds r2, r1 - ldrh r0, [r2] - adds r0, 0x1 - ldr r1, =0x0000270f - cmp r0, r1 - ble _080DBF0C - adds r0, r1, 0 -_080DBF0C: - strh r0, [r2] -_080DBF0E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DBED4 - - thumb_func_start sub_80DBF30 -sub_80DBF30: @ 80DBF30 - push {lr} - lsls r0, 4 - adds r0, r2 - lsls r1, 4 - adds r3, r1, r2 - ldr r2, [r0] - ldr r1, [r3] - cmp r2, r1 - blt _080DBF60 - cmp r2, r1 - bgt _080DBF52 - ldr r2, [r0, 0x4] - ldr r1, [r3, 0x4] - cmp r2, r1 - blt _080DBF60 - cmp r2, r1 - ble _080DBF56 -_080DBF52: - movs r2, 0 - b _080DBF62 -_080DBF56: - ldr r1, [r0, 0x8] - ldr r0, [r3, 0x8] - movs r2, 0 - cmp r1, r0 - bge _080DBF62 -_080DBF60: - movs r2, 0x1 -_080DBF62: - adds r0, r2, 0 - pop {r1} - bx r1 - thumb_func_end sub_80DBF30 - - thumb_func_start sub_80DBF68 -sub_80DBF68: @ 80DBF68 - push {lr} - ldr r0, =gBattle_BG0_Y - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_BG2_Y - strh r1, [r0] - bl sub_80DB89C - ldr r0, =gUnknown_0827E8DA - movs r1, 0 - bl Contest_StartTextPrinter - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DBF68 - - thumb_func_start sub_80DBF90 -sub_80DBF90: @ 80DBF90 - push {r4,r5,lr} - sub sp, 0xC - movs r5, 0x80 - lsls r5, 18 - movs r4, 0x3 -_080DBF9A: - lsrs r3, r5, 24 - movs r0, 0x8 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0 - movs r2, 0x16 - bl ContestBG_FillBoxWithTile - movs r0, 0xA0 - lsls r0, 19 - adds r5, r0 - subs r4, 0x1 - cmp r4, 0 - bge _080DBF9A - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80DBF90 - thumb_func_start sub_80DBFC8 sub_80DBFC8: @ 80DBFC8 push {lr} diff --git a/include/contest.h b/include/contest.h index 73ebb79fa..4ab4d350c 100644 --- a/include/contest.h +++ b/include/contest.h @@ -385,6 +385,14 @@ struct UnknownContestStruct4 u8 unk2_2:1; }; +struct UnknownContestStruct6 +{ + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; +}; + struct ContestResourcesField1C { u8 filler_00[0x40]; diff --git a/src/contest.c b/src/contest.c index 7decf88fc..da4fdb3e0 100644 --- a/src/contest.c +++ b/src/contest.c @@ -42,6 +42,7 @@ #include "international_string_util.h" #include "data2.h" #include "constants/rgb.h" +#include "contest_ai.h" extern void (*gFieldCallback)(void); @@ -104,7 +105,7 @@ void sub_80DB2BC(void); void prints_contest_move_description(u16); u16 sub_80DE84C(u16); void sub_80DB89C(void); -u16 sub_80DB8B8(u8); +u16 GetChosenMove(u8); void sub_80DB918(void); bool8 Contest_IsMonsTurnDisabled(u8); void sub_80DBF68(void); @@ -169,6 +170,9 @@ void sub_80DF9D4(u8 *); void sub_80DF9E0(u8 *, s32); void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8); void Contest_PrintTextToBg0WindowStd(u8, const u8 *); +s16 sub_80DBD34(u8); +void DetermineFinalStandings(void); +bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA s16 gContestMonConditions[4] = {0}; @@ -199,6 +203,7 @@ extern const struct WindowTemplate gUnknown_08587F44[]; extern const u8 *const gUnknown_08587D90[]; extern const u8 *const gUnknown_08587F08[]; extern const u8 *const gUnknown_08587F1C[]; +extern const u8 *const gUnknown_0827E8DA[]; extern const u8 gText_0827D55A[]; extern const u8 gText_0827E793[]; extern const u8 gText_0827E32E[]; @@ -855,7 +860,7 @@ void sub_80D8894(u8 taskId) { if (gIsLinkContest & 1) { - u16 var = sub_80DB8B8(gContestPlayerMonIndex); + u16 var = GetChosenMove(gContestPlayerMonIndex); u8 taskId2; gContestResources->field_4[gContestPlayerMonIndex].currMove = var; @@ -934,7 +939,7 @@ void sub_80D8A88(u8 taskId) for (i = 0; i + gNumLinkContestPlayers < 4; i++) { - gContestResources->field_4[gNumLinkContestPlayers + i].currMove = sub_80DB8B8(gNumLinkContestPlayers + i); + gContestResources->field_4[gNumLinkContestPlayers + i].currMove = GetChosenMove(gNumLinkContestPlayers + i); } } gTasks[taskId].data[0] = 0; @@ -2740,3 +2745,300 @@ bool8 sub_80DB798(u8 a) } return r9; } + +void sub_80DB884(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + sub_80DB798(i); +} + +void sub_80DB89C(void) +{ + FillWindowPixelBuffer(4, 0); + CopyWindowToVram(4, 2); + Contest_SetBgCopyFlags(0); +} + +u16 GetChosenMove(u8 a) +{ + if (Contest_IsMonsTurnDisabled(a)) + return 0; + if (a == gContestPlayerMonIndex) + { + return gContestMons[a].moves[sContest.playerMoveChoice]; + } + else + { + u8 moveChoice; + + ContestAI_ResetAI(a); + moveChoice = ContestAI_GetActionToUse(); + return gContestMons[a].moves[moveChoice]; + } +} + +void sub_80DB918(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + sContestantStatus[i].currMove = GetChosenMove(i); +} + +void sub_80DB944(void) +{ + s32 i; + s32 j; + s16 arr[4]; + + for (i = 0; i < 4; i++) + { + sContestantStatus[i].unk4 += sContestantStatus[i].appeal2; + arr[i] = sContestantStatus[i].unk4; + } + for (i = 0; i < 3; i++) + { + for (j = 3; j > i; j--) + { + if (arr[j - 1] < arr[j]) + { + u16 temp = arr[j]; + + arr[j] = arr[j - 1]; + arr[j - 1] = temp; + } + } + } + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + if (sContestantStatus[i].unk4 == arr[j]) + { + sContestantStatus[i].unkB_0 = j; + break; + } + } + } + sub_80DCE58(1); + sub_80DD590(); +} + +void sub_80DBA18(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + u8 attentionLevel; + + if (sContestantStatus[i].currMove == MOVE_NONE) + attentionLevel = 5; + else if (sContestantStatus[i].appeal2 <= 0) + attentionLevel = 0; + else if (sContestantStatus[i].appeal2 < 30) + attentionLevel = 1; + else if (sContestantStatus[i].appeal2 < 60) + attentionLevel = 2; + else if (sContestantStatus[i].appeal2 < 80) + attentionLevel = 3; + else + attentionLevel = 4; + + sContestantStatus[i].attentionLevel = attentionLevel; + } +} + +bool8 sub_80DBA68(u8 a) +{ + if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) + return FALSE; + else + return TRUE; +} + +void sub_80DBAA0(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + sContestantStatus[i].appeal2 = 0; + sContestantStatus[i].appeal1 = 0; + sContestantStatus[i].jamSafetyCount = 0; + if (sContestantStatus[i].numTurnsSkipped > 0) + sContestantStatus[i].numTurnsSkipped--; + sContestantStatus[i].jam = 0; + sContestantStatus[i].resistant = 0; + sContestantStatus[i].jamReduction = 0; + sContestantStatus[i].immune = 0; + sContestantStatus[i].moreEasilyStartled = 0; + sContestantStatus[i].usedRepeatableMove = 0; + sContestantStatus[i].nervous = 0; + sContestantStatus[i].effectStringId = CONTEST_STRING_NONE; + sContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; + sContestantStatus[i].conditionMod = 0; + sContestantStatus[i].unk15_2 = sContestantStatus[i].disappointedRepeat; + sContestantStatus[i].disappointedRepeat = FALSE; + sContestantStatus[i].turnOrderModAction = 0; + sContestantStatus[i].appealTripleCondition = 0; + if (sContestantStatus[i].turnSkipped) + { + sContestantStatus[i].numTurnsSkipped = 1; + sContestantStatus[i].turnSkipped = 0; + } + if (sContestantStatus[i].exploded) + { + sContestantStatus[i].noMoreTurns = 1; + sContestantStatus[i].exploded = 0; + } + sContestantStatus[i].overrideCategoryExcitementMod = 0; + } + for (i = 0; i < 4; i++) + { + sContestantStatus[i].prevMove = sContestantStatus[i].currMove; + sContest.unk19220[sContest.turnNumber][i] = sContestantStatus[i].currMove; + sContest.unk19248[sContest.turnNumber][i] = Contest_GetMoveExcitement(sContestantStatus[i].currMove); + sContestantStatus[i].currMove = MOVE_NONE; + } + shared19328.excitementFrozen = 0; +} + +bool8 Contest_IsMonsTurnDisabled(u8 a) +{ + if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) + return TRUE; + else + return FALSE; +} + +void sub_80DBCE0(u8 a) +{ + gUnknown_02039F18[a] = sub_80DBD34(a); + gUnknown_02039F08[a] = gContestMonConditions[a] + gUnknown_02039F18[a]; +} + +void sub_80DBD18(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + sub_80DBCE0(i); + DetermineFinalStandings(); +} + +s16 sub_80DBD34(u8 a) +{ + return gUnknown_02039F10[a] * 2; +} + +void DetermineFinalStandings(void) +{ + u16 sp0[4] = {0}; + struct UnknownContestStruct6 sp8[4]; + s32 i; + s32 j; + + for (i = 0; i < 4; i++) + { + s32 r2; + + sp0[i] = Random(); + for (r2 = 0; r2 < i; r2++) + { + if (sp0[i] == sp0[r2]) + { + i--; + break; + } + } + } + + for (i = 0; i < 4; i++) + { + sp8[i].unk0 = gUnknown_02039F08[i]; + sp8[i].unk4 = gContestMonConditions[i]; + sp8[i].unk8 = sp0[i]; + sp8[i].unkC = i; + } + + for (i = 0; i < 3; i++) + { + for (j = 3; j > i; j--) + { + if (sub_80DBF30(j - 1, j, sp8)) + { + struct UnknownContestStruct6 temp; + + temp.unk0 = sp8[j - 1].unk0; + temp.unk4 = sp8[j - 1].unk4; + temp.unk8 = sp8[j - 1].unk8; + temp.unkC = sp8[j - 1].unkC; + + sp8[j - 1].unk0 = sp8[j].unk0; + sp8[j - 1].unk4 = sp8[j].unk4; + sp8[j - 1].unk8 = sp8[j].unk8; + sp8[j - 1].unkC = sp8[j].unkC; + + sp8[j].unk0 = temp.unk0; + sp8[j].unk4 = temp.unk4; + sp8[j].unk8 = temp.unk8; + sp8[j].unkC = temp.unkC; + } + } + } + + for (i = 0; i < 4; i++) + gContestFinalStandings[sp8[i].unkC] = i; +} + +void sub_80DBED4(void) +{ + if ((gIsLinkContest & 1)) + { + gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = + ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 0x270F) ? 0x270F : + (gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1); + + } +} + +bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) +{ + bool8 retVal; + + if (c[a].unk0 < c[b].unk0) + retVal = TRUE; + else if (c[a].unk0 > c[b].unk0) + retVal = FALSE; + else if (c[a].unk4 < c[b].unk4) + retVal = TRUE; + else if (c[a].unk4 > c[b].unk4) + retVal = FALSE; + else if (c[a].unk8 < c[b].unk8) + retVal = TRUE; + else + retVal = FALSE; + return retVal; +} + +void sub_80DBF68(void) +{ + gBattle_BG0_Y = 0; + gBattle_BG2_Y = 0; + sub_80DB89C(); + Contest_StartTextPrinter((u8*) &gUnknown_0827E8DA, 0); +} + +void sub_80DBF90(void) +{ + u16 temp = BGCNT_WRAP; + s32 i; + for(i = 3; i >= 0; i--) + { + ContestBG_FillBoxWithIncrementingTile(0, temp, 0, 0x16, 0, 0, 0, 0); + } +} + From f966b6584924531bd4470b98c38ec52cd0004197 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Thu, 20 Dec 2018 11:39:00 -0800 Subject: [PATCH 02/12] Through sub_80DC028, sub_80DC0F4 non-matching. --- asm/contest.s | 372 ------------------------------------------------ src/contest.c | 383 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 376 insertions(+), 379 deletions(-) diff --git a/asm/contest.s b/asm/contest.s index 8a148e529..ebded2d2f 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5,378 +5,6 @@ .text - thumb_func_start sub_80DBFC8 -sub_80DBFC8: @ 80DBFC8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =0x00005011 - cmp r0, 0 - beq _080DBFE2 - ldr r1, =0x00006011 - cmp r0, 0x1 - beq _080DBFE2 - ldr r1, =0x00008011 - cmp r0, 0x2 - bne _080DBFE2 - ldr r1, =0x00007011 -_080DBFE2: - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DBFC8 - - thumb_func_start sub_80DBFFC -sub_80DBFFC: @ 80DBFFC - push {lr} - lsls r0, 16 - asrs r0, 16 - movs r1, 0xA - bl __divsi3 - lsls r0, 24 - lsrs r1, r0, 24 - asrs r2, r0, 24 - cmp r2, 0x10 - ble _080DC016 - movs r1, 0x10 - b _080DC020 -_080DC016: - movs r0, 0x10 - negs r0, r0 - cmp r2, r0 - bge _080DC020 - movs r1, 0xF0 -_080DC020: - lsls r0, r1, 24 - asrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_80DBFFC - - thumb_func_start sub_80DC028 -sub_80DC028: @ 80DC028 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - adds r6, r1, 0 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x14] - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1, 0x2] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1, 0x2] - ldr r0, =sub_80DC0F4 - movs r1, 0x14 - bl CreateTask - lsls r0, 24 - lsrs r7, r0, 24 - lsls r5, 16 - asrs r5, 16 - adds r0, r5, 0 - bl sub_80DBFFC - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r6, 16 - asrs r6, 16 - adds r5, r6 - lsls r5, 16 - asrs r5, 16 - adds r0, r5, 0 - bl sub_80DBFFC - lsls r4, 24 - asrs r4, 24 - subs r0, r4 - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r8 - bl sub_80DBFC8 - ldr r2, =gTasks - lsls r3, r7, 2 - adds r0, r3, r7 - lsls r0, 3 - adds r1, r0, r2 - adds r0, r4, 0 - cmp r4, 0 - bge _080DC0A0 - negs r0, r4 -_080DC0A0: - strh r0, [r1, 0x8] - lsls r0, r5, 24 - asrs r0, 24 - strh r0, [r1, 0xA] - cmp r4, 0 - bgt _080DC0B4 - cmp r4, 0 - bne _080DC0C8 - cmp r0, 0 - ble _080DC0C8 -_080DC0B4: - movs r0, 0x1 - strh r0, [r1, 0xC] - b _080DC0D6 - .pool -_080DC0C8: - ldr r2, =gTasks - lsls r3, r7, 2 - adds r0, r3, r7 - lsls r0, 3 - adds r0, r2 - ldr r1, =0x0000ffff - strh r1, [r0, 0xC] -_080DC0D6: - adds r0, r3, r7 - lsls r0, 3 - adds r0, r2 - mov r1, r8 - strh r1, [r0, 0xE] - adds r0, r7, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DC028 - - thumb_func_start sub_80DC0F4 -sub_80DC0F4: @ 80DC0F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r4, r0, r1 - ldrb r0, [r4, 0xE] - mov r9, r0 - ldrh r3, [r4, 0x8] - ldrh r1, [r4, 0xA] - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - strh r0, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xE - bgt _080DC126 - b _080DC2A8 -_080DC126: - movs r0, 0 - strh r0, [r4, 0x1C] - ldrh r2, [r4, 0xA] - movs r5, 0xA - ldrsh r0, [r4, r5] - cmp r0, 0 - bne _080DC15C - adds r0, r7, 0 - bl DestroyTask - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x14] - mov r2, r9 - lsls r1, r2, 2 - adds r1, r0 - ldrb r2, [r1, 0x2] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x2] - b _080DC2A8 - .pool -_080DC15C: - cmp r3, 0 - bne _080DC1A4 - lsls r0, r1, 16 - mov r8, r0 - cmp r0, 0 - bge _080DC17A - mov r0, r9 - bl sub_80DBFC8 - adds r0, 0x2 - lsls r0, 16 - lsrs r6, r0, 16 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - b _080DC188 -_080DC17A: - mov r0, r9 - bl sub_80DBFC8 - lsls r0, 16 - lsrs r6, r0, 16 - ldrh r0, [r4, 0xA] - subs r0, 0x1 -_080DC188: - strh r0, [r4, 0xA] - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r2, r1, 0x1 - strh r2, [r0, 0x8] - lsls r1, 24 - lsrs r5, r1, 24 - b _080DC210 - .pool -_080DC1A4: - movs r3, 0xC - ldrsh r0, [r4, r3] - cmp r0, 0 - bge _080DC1DE - lsls r0, r1, 16 - mov r8, r0 - cmp r0, 0 - bge _080DC1CC - ldrh r0, [r4, 0x8] - adds r1, r0, 0x1 - strh r1, [r4, 0x8] - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r2, 0x1 - strh r0, [r4, 0xA] - mov r0, r9 - bl sub_80DBFC8 - adds r0, 0x2 - b _080DC20C -_080DC1CC: - ldrh r0, [r4, 0x8] - subs r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r5, r0, 24 - movs r6, 0 - subs r0, r2, 0x1 - strh r0, [r4, 0xA] - b _080DC210 -_080DC1DE: - lsls r0, r1, 16 - mov r8, r0 - cmp r0, 0 - bge _080DC1F8 - ldrh r0, [r4, 0x8] - subs r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r5, r0, 24 - movs r6, 0 - adds r0, r2, 0x1 - strh r0, [r4, 0xA] - b _080DC210 -_080DC1F8: - ldrh r0, [r4, 0x8] - adds r1, r0, 0x1 - strh r1, [r4, 0x8] - lsls r0, 24 - lsrs r5, r0, 24 - subs r0, r2, 0x1 - strh r0, [r4, 0xA] - mov r0, r9 - bl sub_80DBFC8 -_080DC20C: - lsls r0, 16 - lsrs r6, r0, 16 -_080DC210: - str r5, [sp, 0xC] - movs r0, 0 - mov r10, r0 - cmp r5, 0x7 - bls _080DC226 - movs r2, 0x1 - mov r10, r2 - adds r0, r5, 0 - subs r0, 0x8 - lsls r0, 24 - lsrs r5, r0, 24 -_080DC226: - adds r2, r5, 0 - adds r2, 0x16 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_02039F26 - add r0, r9 - ldrb r0, [r0] - lsls r3, r0, 2 - adds r3, r0 - adds r3, 0x2 - add r3, r10 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x1 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0 - adds r1, r6, 0 - bl ContestBG_FillBoxWithTile - mov r3, r8 - cmp r3, 0 - ble _080DC284 - movs r0, 0x60 - bl PlaySE - ldr r4, =gMPlayInfo_SE1 - adds r0, r4, 0 - bl m4aMPlayImmInit - ldr r1, =0x0000ffff - ldr r0, [sp, 0xC] - lsls r2, r0, 24 - asrs r2, 16 - adds r0, r4, 0 - bl m4aMPlayPitchControl - b _080DC28A - .pool -_080DC284: - movs r0, 0x16 - bl PlaySE -_080DC28A: - mov r2, r10 - cmp r2, 0 - bne _080DC2A8 - cmp r5, 0 - bne _080DC2A8 - cmp r6, 0 - bne _080DC2A8 - ldr r0, =gTasks - lsls r1, r7, 2 - adds r1, r7 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xC] - negs r0, r0 - strh r0, [r1, 0xC] -_080DC2A8: - 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_80DC0F4 - thumb_func_start sub_80DC2BC sub_80DC2BC: @ 80DC2BC push {r4,r5,lr} diff --git a/src/contest.c b/src/contest.c index da4fdb3e0..4fb5f76c5 100644 --- a/src/contest.c +++ b/src/contest.c @@ -153,7 +153,7 @@ void sub_80DE12C(void); void sub_80DD45C(u8, u8); void sub_80DD720(u8); void sub_80DE008(bool8); -void sub_80DC028(s16, s16, u8); +u8 sub_80DC028(s16, s16, u8); bool8 sub_80DB5B8(u8, u8); bool8 sub_80DB798(u8); void sub_80DB884(void); @@ -173,6 +173,7 @@ void Contest_PrintTextToBg0WindowStd(u8, const u8 *); s16 sub_80DBD34(u8); void DetermineFinalStandings(void); bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); +void sub_80DC0F4(u8); EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA s16 gContestMonConditions[4] = {0}; @@ -3034,11 +3035,379 @@ void sub_80DBF68(void) void sub_80DBF90(void) { - u16 temp = BGCNT_WRAP; - s32 i; - for(i = 3; i >= 0; i--) - { - ContestBG_FillBoxWithIncrementingTile(0, temp, 0, 0x16, 0, 0, 0, 0); - } + int i; + + for(i = 0; i < 4; i++) + { + ContestBG_FillBoxWithTile(0, 0, 0x16, 2 + i * 5, 8, 2, 0x11); + } } +u16 sub_80DBFC8(u8 a) +{ + u16 var; + + if (a == 0) + var = 0x5011; + else if (a == 1) + var = 0x6011; + else if (a == 2) + var = 0x7011; + else + var = 0x8011; + return var + 1; +} + +s8 sub_80DBFFC(s16 a) +{ + s8 retVal = a / 10; + + if (retVal > 16) + retVal = 16; + else if (retVal < -16) + retVal = -16; + return retVal; +} + +u8 sub_80DC028(s16 a, s16 b, u8 c) +{ + u8 taskId; + s8 r4; + s8 r5; + + gContestResources->field_14[c].unk2_2 = 1; + taskId = CreateTask(sub_80DC0F4, 20); + r4 = sub_80DBFFC(a); + r5 = sub_80DBFFC(a + b) - r4; + sub_80DBFC8(c); // unused return value + gTasks[taskId].data[0] = abs(r4); + gTasks[taskId].data[1] = r5; + if (r4 > 0 || (r4 == 0 && r5 > 0)) + gTasks[taskId].data[2] = 1; + else + gTasks[taskId].data[2] = -1; + gTasks[taskId].data[3] = c; + return taskId; +} + +#ifdef NONMATCHING + +void sub_80DC0F4(u8 taskId) +{ + u8 r7 = gTasks[taskId].data[3]; + s16 r3 = gTasks[taskId].data[0]; + s16 r1 = gTasks[taskId].data[1]; + + if (++gTasks[taskId].data[10] > 14) + { + u16 r6; + u8 r5; + u8 r10; + + gTasks[taskId].data[10] = 0; + if (gTasks[taskId].data[1] == 0) + { + DestroyTask(taskId); + gContestResources->field_14[r7].unk2_2 = 0; + return; + } + else if (r3 == 0) + { + if (r1 < 0) + { + r6 = sub_80DBFC8(r7) + 2; + gTasks[taskId].data[1]++; + } + else + { + r6 = sub_80DBFC8(r7); + gTasks[taskId].data[1]--; + } + r5 = gTasks[taskId].data[0]++; + } + else + { + if (gTasks[taskId].data[2] < 0) + { + if (r1 < 0) + { + r5 = gTasks[taskId].data[0]++; + gTasks[taskId].data[1]++; + r6 = sub_80DBFC8(r7) + 2; + } + else + { + r5 = --gTasks[taskId].data[0]; + r6 = 0; + gTasks[taskId].data[1]--; + } + } + else + { + if (r1 < 0) + { + r5 = --gTasks[taskId].data[0]; + r6 = 0; + gTasks[taskId].data[1]++; + } + else + { + r5 = gTasks[taskId].data[0]++; + gTasks[taskId].data[1]--; + r6 = sub_80DBFC8(r7); + } + } + } + + r10 = r5; + r1 = 0; + if (r5 > 7) + { + r1 = 1; + r5 -= 8; + } + + ContestBG_FillBoxWithTile(0, r6, r5 + 0x16, (gUnknown_02039F26[r7] * 5) + 2 + r3, 1, 1, 0x11); + if (r1 > 0) + { + PlaySE(SE_C_GAJI); + m4aMPlayImmInit(&gMPlayInfo_SE1); + m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, r10 * 256); + } + else + { + PlaySE(SE_BOO); + } + + if (r10 == 0 && r5 == 0 && r6 == 0) + gTasks[taskId].data[2] = -gTasks[taskId].data[2]; + } +} +#else +NAKED +void sub_80DC0F4(u8 taskId) +{ + asm(".syntax 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, 0x10\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldr r1, =gTasks\n\ + lsls r0, r7, 2\n\ + adds r0, r7\n\ + lsls r0, 3\n\ + adds r4, r0, r1\n\ + ldrb r0, [r4, 0xE]\n\ + mov r9, r0\n\ + ldrh r3, [r4, 0x8]\n\ + ldrh r1, [r4, 0xA]\n\ + ldrh r0, [r4, 0x1C]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x1C]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xE\n\ + bgt _080DC126\n\ + b _080DC2A8\n\ +_080DC126:\n\ + movs r0, 0\n\ + strh r0, [r4, 0x1C]\n\ + ldrh r2, [r4, 0xA]\n\ + movs r5, 0xA\n\ + ldrsh r0, [r4, r5]\n\ + cmp r0, 0\n\ + bne _080DC15C\n\ + adds r0, r7, 0\n\ + bl DestroyTask\n\ + ldr r0, =gContestResources\n\ + ldr r0, [r0]\n\ + ldr r0, [r0, 0x14]\n\ + mov r2, r9\n\ + lsls r1, r2, 2\n\ + adds r1, r0\n\ + ldrb r2, [r1, 0x2]\n\ + movs r0, 0x5\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x2]\n\ + b _080DC2A8\n\ + .pool\n\ +_080DC15C:\n\ + cmp r3, 0\n\ + bne _080DC1A4\n\ + lsls r0, r1, 16\n\ + mov r8, r0\n\ + cmp r0, 0\n\ + bge _080DC17A\n\ + mov r0, r9\n\ + bl sub_80DBFC8\n\ + adds r0, 0x2\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + ldrh r0, [r4, 0xA]\n\ + adds r0, 0x1\n\ + b _080DC188\n\ +_080DC17A:\n\ + mov r0, r9\n\ + bl sub_80DBFC8\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + ldrh r0, [r4, 0xA]\n\ + subs r0, 0x1\n\ +_080DC188:\n\ + strh r0, [r4, 0xA]\n\ + ldr r1, =gTasks\n\ + lsls r0, r7, 2\n\ + adds r0, r7\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldrh r1, [r0, 0x8]\n\ + adds r2, r1, 0x1\n\ + strh r2, [r0, 0x8]\n\ + lsls r1, 24\n\ + lsrs r5, r1, 24\n\ + b _080DC210\n\ + .pool\n\ +_080DC1A4:\n\ + movs r3, 0xC\n\ + ldrsh r0, [r4, r3]\n\ + cmp r0, 0\n\ + bge _080DC1DE\n\ + lsls r0, r1, 16\n\ + mov r8, r0\n\ + cmp r0, 0\n\ + bge _080DC1CC\n\ + ldrh r0, [r4, 0x8]\n\ + adds r1, r0, 0x1\n\ + strh r1, [r4, 0x8]\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + adds r0, r2, 0x1\n\ + strh r0, [r4, 0xA]\n\ + mov r0, r9\n\ + bl sub_80DBFC8\n\ + adds r0, 0x2\n\ + b _080DC20C\n\ +_080DC1CC:\n\ + ldrh r0, [r4, 0x8]\n\ + subs r0, 0x1\n\ + strh r0, [r4, 0x8]\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r6, 0\n\ + subs r0, r2, 0x1\n\ + strh r0, [r4, 0xA]\n\ + b _080DC210\n\ +_080DC1DE:\n\ + lsls r0, r1, 16\n\ + mov r8, r0\n\ + cmp r0, 0\n\ + bge _080DC1F8\n\ + ldrh r0, [r4, 0x8]\n\ + subs r0, 0x1\n\ + strh r0, [r4, 0x8]\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r6, 0\n\ + adds r0, r2, 0x1\n\ + strh r0, [r4, 0xA]\n\ + b _080DC210\n\ +_080DC1F8:\n\ + ldrh r0, [r4, 0x8]\n\ + adds r1, r0, 0x1\n\ + strh r1, [r4, 0x8]\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + subs r0, r2, 0x1\n\ + strh r0, [r4, 0xA]\n\ + mov r0, r9\n\ + bl sub_80DBFC8\n\ +_080DC20C:\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ +_080DC210:\n\ + str r5, [sp, 0xC]\n\ + movs r0, 0\n\ + mov r10, r0\n\ + cmp r5, 0x7\n\ + bls _080DC226\n\ + movs r2, 0x1\n\ + mov r10, r2\n\ + adds r0, r5, 0\n\ + subs r0, 0x8\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ +_080DC226:\n\ + adds r2, r5, 0\n\ + adds r2, 0x16\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + ldr r0, =gUnknown_02039F26\n\ + add r0, r9\n\ + ldrb r0, [r0]\n\ + lsls r3, r0, 2\n\ + adds r3, r0\n\ + adds r3, 0x2\n\ + add r3, r10\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + movs r0, 0x1\n\ + str r0, [sp]\n\ + str r0, [sp, 0x4]\n\ + movs r0, 0x11\n\ + str r0, [sp, 0x8]\n\ + movs r0, 0\n\ + adds r1, r6, 0\n\ + bl ContestBG_FillBoxWithTile\n\ + mov r3, r8\n\ + cmp r3, 0\n\ + ble _080DC284\n\ + movs r0, 0x60\n\ + bl PlaySE\n\ + ldr r4, =gMPlayInfo_SE1\n\ + adds r0, r4, 0\n\ + bl m4aMPlayImmInit\n\ + ldr r1, =0x0000ffff\n\ + ldr r0, [sp, 0xC]\n\ + lsls r2, r0, 24\n\ + asrs r2, 16\n\ + adds r0, r4, 0\n\ + bl m4aMPlayPitchControl\n\ + b _080DC28A\n\ + .pool\n\ +_080DC284:\n\ + movs r0, 0x16\n\ + bl PlaySE\n\ +_080DC28A:\n\ + mov r2, r10\n\ + cmp r2, 0\n\ + bne _080DC2A8\n\ + cmp r5, 0\n\ + bne _080DC2A8\n\ + cmp r6, 0\n\ + bne _080DC2A8\n\ + ldr r0, =gTasks\n\ + lsls r1, r7, 2\n\ + adds r1, r7\n\ + lsls r1, 3\n\ + adds r1, r0\n\ + ldrh r0, [r1, 0xC]\n\ + negs r0, r0\n\ + strh r0, [r1, 0xC]\n\ +_080DC2A8:\n\ + add sp, 0x10\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\n\ + .pool\n\ + .syntax divided\n"); +} +#endif \ No newline at end of file From 2ca482dc24accca6bbb808f2c4b847e1d2c2dfac Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Mon, 24 Dec 2018 15:10:36 -0800 Subject: [PATCH 03/12] Committing progress so far. --- asm/contest.s | 1078 ------------------------------------------------ include/util.h | 2 + src/contest.c | 582 +++++++++++++++----------- 3 files changed, 341 insertions(+), 1321 deletions(-) diff --git a/asm/contest.s b/asm/contest.s index ebded2d2f..f5ca016df 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5,1084 +5,6 @@ .text - thumb_func_start sub_80DC2BC -sub_80DC2BC: @ 80DC2BC - push {r4,r5,lr} - ldr r0, =gUnknown_08587A74 - bl LoadSpriteSheet - movs r4, 0 - ldr r5, =gUnknown_08587A6C -_080DC2C8: - ldr r0, =gUnknown_02039F26 - adds r0, r4, r0 - ldrb r0, [r0] - adds r0, r5 - ldrb r2, [r0] - ldr r0, =gSpriteTemplate_8587AD0 - movs r1, 0xB4 - movs r3, 0x1 - bl CreateSprite - ldr r1, =gContestResources - ldr r1, [r1] - ldr r2, [r1, 0x14] - lsls r1, r4, 2 - adds r1, r2 - strb r0, [r1] - adds r4, 0x1 - cmp r4, 0x3 - ble _080DC2C8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC2BC - - thumb_func_start sub_80DC308 -sub_80DC308: @ 80DC308 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r4, =gContestResources - ldr r0, [r4] - ldr r2, [r0, 0x14] - lsls r3, r6, 2 - adds r2, r3, r2 - ldrb r0, [r2, 0x2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2, 0x2] - ldr r1, [r4] - ldr r0, [r1, 0x14] - adds r3, r0 - ldrb r7, [r3] - ldr r1, [r1, 0x4] - lsls r0, r6, 3 - subs r0, r6 - lsls r0, 2 - adds r0, r1 - movs r1, 0x4 - ldrsh r0, [r0, r1] - movs r1, 0xA - bl __divsi3 - lsls r0, 17 - lsrs r5, r0, 16 - asrs r0, 16 - cmp r0, 0x38 - ble _080DC350 - movs r5, 0x38 - b _080DC356 - .pool -_080DC350: - cmp r0, 0 - bge _080DC356 - movs r5, 0 -_080DC356: - ldr r2, =gSprites - lsls r3, r7, 4 - adds r0, r3, r7 - lsls r0, 2 - adds r4, r0, r2 - movs r0, 0x3E - adds r0, r4 - mov r12, r0 - ldrb r1, [r0] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - mov r1, r12 - strb r0, [r1] - strh r6, [r4, 0x2E] - strh r5, [r4, 0x30] - lsls r0, r5, 16 - asrs r0, 16 - movs r5, 0x24 - ldrsh r1, [r4, r5] - cmp r0, r1 - ble _080DC38C - movs r0, 0x1 - b _080DC38E - .pool -_080DC38C: - ldr r0, =0x0000ffff -_080DC38E: - strh r0, [r4, 0x32] - adds r0, r3, r7 - lsls r0, 2 - adds r1, r2, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_80DC408 - str r1, [r0] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC308 - - thumb_func_start sub_80DC3AC -sub_80DC3AC: @ 80DC3AC - push {r4,lr} - movs r4, 0 -_080DC3B0: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DC308 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DC3B0 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DC3AC - - thumb_func_start sub_80DC3C4 -sub_80DC3C4: @ 80DC3C4 - push {r4,lr} - movs r2, 0 - ldr r3, =gContestResources - ldr r0, [r3] - ldr r0, [r0, 0x14] - ldrb r1, [r0, 0x2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080DC3F2 - movs r4, 0x1 -_080DC3DA: - adds r2, 0x1 - cmp r2, 0x3 - bgt _080DC3F2 - ldr r0, [r3] - ldr r1, [r0, 0x14] - lsls r0, r2, 2 - adds r0, r1 - ldrb r1, [r0, 0x2] - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _080DC3DA -_080DC3F2: - cmp r2, 0x4 - beq _080DC400 - movs r0, 0 - b _080DC402 - .pool -_080DC400: - movs r0, 0x1 -_080DC402: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80DC3C4 - - thumb_func_start sub_80DC408 -sub_80DC408: @ 80DC408 - push {r4,lr} - adds r3, r0, 0 - ldrh r2, [r3, 0x24] - movs r0, 0x24 - ldrsh r1, [r3, r0] - movs r4, 0x30 - ldrsh r0, [r3, r4] - cmp r1, r0 - bne _080DC440 - ldr r0, =gContestResources - ldr r0, [r0] - movs r2, 0x2E - ldrsh r1, [r3, r2] - ldr r0, [r0, 0x14] - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1, 0x2] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x2] - ldr r0, =SpriteCallbackDummy - str r0, [r3, 0x1C] - b _080DC446 - .pool -_080DC440: - ldrh r0, [r3, 0x32] - adds r0, r2, r0 - strh r0, [r3, 0x24] -_080DC446: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DC408 - - thumb_func_start sub_80DC44C -sub_80DC44C: @ 80DC44C - push {r4-r6,lr} - movs r2, 0 - ldr r6, =gSprites - ldr r5, =gContestResources - ldr r4, =gUnknown_08587A6C - ldr r3, =gUnknown_02039F26 -_080DC458: - ldr r0, [r5] - ldr r1, [r0, 0x14] - lsls r0, r2, 2 - adds r0, r1 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - adds r0, r2, r3 - ldrb r0, [r0] - adds r0, r4 - ldrb r0, [r0] - strh r0, [r1, 0x22] - adds r2, 0x1 - cmp r2, 0x3 - ble _080DC458 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC44C - - thumb_func_start sub_80DC490 -sub_80DC490: @ 80DC490 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r3, 0 - ldr r7, =gUnknown_02039F26 - ldr r5, =gSprites - ldr r4, =gContestResources - movs r2, 0 -_080DC4A0: - adds r0, r3, r7 - ldrb r0, [r0] - cmp r0, 0x1 - bls _080DC4E2 - cmp r6, 0 - bne _080DC4CC - ldr r0, [r4] - ldr r0, [r0, 0x14] - adds r0, r2, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0xB4 - b _080DC4E0 - .pool -_080DC4CC: - ldr r0, [r4] - ldr r0, [r0, 0x14] - adds r0, r2, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0x80 - lsls r1, 1 -_080DC4E0: - strh r1, [r0, 0x20] -_080DC4E2: - adds r2, 0x4 - adds r3, 0x1 - cmp r3, 0x3 - ble _080DC4A0 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80DC490 - - thumb_func_start sub_80DC4F0 -sub_80DC4F0: @ 80DC4F0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gUnknown_08587B08 - bl LoadSpritePalette - movs r5, 0 - ldr r7, =gContestResources - ldr r0, =gSprites - mov r8, r0 - movs r6, 0 -_080DC506: - lsls r0, r5, 3 - ldr r1, =gUnknown_08587AE8 - adds r0, r1 - bl LoadCompressedSpriteSheet - ldr r0, =gSpriteTemplate_8587B18 - adds r0, r6, r0 - ldr r2, =gUnknown_08587A70 - ldr r1, =gUnknown_02039F26 - adds r1, r5, r1 - ldrb r1, [r1] - adds r1, r2 - ldrb r2, [r1] - movs r1, 0xCC - movs r3, 0 - bl CreateSprite - ldr r1, [r7] - ldr r1, [r1, 0x14] - lsls r4, r5, 2 - adds r1, r4, r1 - strb r0, [r1, 0x1] - ldr r0, [r7] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldr r1, =gSubspriteTables_8587B80 - bl SetSubspriteTables - ldr r0, [r7] - ldr r0, [r0, 0x14] - adds r4, r0 - ldrb r1, [r4, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - adds r6, 0x18 - adds r5, 0x1 - cmp r5, 0x3 - ble _080DC506 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC4F0 - - thumb_func_start sub_80DC594 -sub_80DC594: @ 80DC594 - push {lr} - ldr r0, =gUnknown_08587BB0 - bl LoadCompressedSpriteSheet - ldr r0, =gUnknown_08587BB8 - bl LoadSpritePalette - ldr r0, =gSpriteTemplate_8587BC8 - movs r1, 0x1E - movs r2, 0x2C - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - adds r1, 0x3E - ldrb r2, [r1] - movs r3, 0x4 - orrs r2, r3 - strb r2, [r1] - ldr r1, =gContestResources - ldr r1, [r1] - ldr r1, [r1] - adds r1, 0x58 - strb r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC594 - - thumb_func_start sub_80DC5E8 -sub_80DC5E8: @ 80DC5E8 - push {r4,lr} - ldr r0, =sub_80DC728 - movs r1, 0x1E - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r1, [r1] - strb r0, [r1, 0xD] - movs r2, 0 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r4, =gTasks + 0x8 - movs r3, 0xFF -_080DC60A: - lsls r0, r2, 3 - adds r0, r1 - adds r0, r4 - strh r3, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _080DC60A - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC5E8 - - thumb_func_start sub_80DC630 -sub_80DC630: @ 80DC630 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - ldr r1, =gContestResources - ldr r5, [r1] - ldr r1, [r5] - ldrb r2, [r1, 0xD] - lsls r1, r2, 2 - adds r1, r2 - adds r1, r0 - lsls r1, 3 - adds r3, 0x8 - adds r1, r3 - movs r4, 0 - strh r4, [r1] - lsls r0, 2 - adds r0, 0x1 - lsls r0, 1 - ldr r1, [r5] - ldrb r2, [r1, 0xD] - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r0, r1 - adds r0, r3 - strh r4, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC630 - - thumb_func_start sub_80DC674 -sub_80DC674: @ 80DC674 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80DC6A4 - movs r1, 0x1F - 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] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC674 - - thumb_func_start sub_80DC6A4 -sub_80DC6A4: @ 80DC6A4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - ldr r2, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x8] - adds r5, r0, 0 - ldr r0, =gContestResources - ldr r4, [r0] - ldr r0, [r4] - ldrb r1, [r0, 0xD] - lsls r0, r1, 2 - adds r0, r1 - adds r0, r5 - lsls r0, 3 - adds r7, r2, 0 - adds r7, 0x8 - adds r1, r0, r7 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _080DC6DC - cmp r0, 0xFF - bne _080DC716 -_080DC6DC: - movs r3, 0 - movs r0, 0xFF - strh r0, [r1] - lsls r1, r5, 2 - adds r1, 0x1 - lsls r1, 1 - ldr r0, [r4] - ldrb r2, [r0, 0xD] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r1, r7 - strh r3, [r1] - ldr r0, [r4] - adds r0, 0x14 - adds r0, r5 - ldrb r0, [r0] - adds r0, 0x5 - lsls r0, 4 - adds r0, 0x6 - ldr r3, =0x00004bff - movs r1, 0x2 - movs r2, 0 - bl BlendPalette - adds r0, r6, 0 - bl DestroyTask -_080DC716: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC6A4 - - thumb_func_start sub_80DC728 -sub_80DC728: @ 80DC728 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - movs r6, 0 - lsls r1, r0, 2 - adds r1, r0 - mov r9, r1 - lsls r7, r1, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - movs r1, 0x8 - negs r1, r1 - add r1, r8 - mov r10, r1 -_080DC74C: - lsls r0, r6, 26 - lsrs r3, r0, 24 - lsls r0, r3, 1 - adds r0, r7 - mov r4, r8 - adds r2, r0, r4 - ldrh r4, [r2] - movs r5, 0 - ldrsh r0, [r2, r5] - cmp r0, 0xFF - beq _080DC7CA - adds r0, r3, 0x1 - lsls r1, r0, 1 - adds r1, r7 - add r1, r8 - movs r5, 0 - ldrsh r1, [r1, r5] - adds r5, r0, 0 - cmp r1, 0 - bne _080DC77C - adds r0, r4, 0x1 - b _080DC77E - .pool -_080DC77C: - subs r0, r4, 0x1 -_080DC77E: - strh r0, [r2] - lsls r1, r3, 1 - mov r0, r9 - lsls r2, r0, 3 - adds r0, r1, r2 - mov r3, r10 - adds r3, 0x8 - adds r0, r3 - movs r4, 0 - ldrsh r0, [r0, r4] - adds r4, r1, 0 - cmp r0, 0x10 - beq _080DC79C - cmp r0, 0 - bne _080DC7AA -_080DC79C: - lsls r0, r5, 1 - adds r0, r2 - adds r0, r3 - ldrh r1, [r0] - movs r2, 0x1 - eors r1, r2 - strh r1, [r0] -_080DC7AA: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - adds r0, 0x14 - adds r0, r6 - ldrb r0, [r0] - adds r0, 0x5 - lsls r0, 4 - adds r0, 0x6 - adds r1, r4, r7 - add r1, r8 - ldrb r2, [r1] - movs r1, 0x2 - ldr r3, =0x00004bff - bl BlendPalette -_080DC7CA: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _080DC74C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC728 - - thumb_func_start sub_80DC7EC -sub_80DC7EC: @ 80DC7EC - push {r4,lr} - ldr r0, =sub_80DC8D0 - movs r1, 0x1E - bl CreateTask - ldr r1, =gContestResources - ldr r1, [r1] - ldr r1, [r1] - strb r0, [r1, 0xE] - movs r4, 0 -_080DC800: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DC81C - adds r4, 0x1 - cmp r4, 0x3 - ble _080DC800 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC7EC - - thumb_func_start sub_80DC81C -sub_80DC81C: @ 80DC81C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - ldr r1, =gContestResources - ldr r4, [r1] - ldr r1, [r4] - ldrb r2, [r1, 0xE] - lsls r1, r2, 2 - adds r1, r2 - adds r1, r0 - lsls r1, 3 - adds r3, 0x8 - adds r1, r3 - movs r5, 0 - movs r2, 0xFF - strh r2, [r1] - lsls r0, 2 - adds r0, 0x1 - lsls r0, 1 - ldr r1, [r4] - ldrb r2, [r1, 0xE] - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r0, r1 - adds r0, r3 - strh r5, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC81C - - thumb_func_start sub_80DC864 -sub_80DC864: @ 80DC864 - push {r4,lr} - movs r4, 0 -_080DC868: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80DC87C - adds r4, 0x1 - cmp r4, 0x3 - ble _080DC868 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DC864 - - thumb_func_start sub_80DC87C -sub_80DC87C: @ 80DC87C - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_80DC81C - adds r0, r4, 0x5 - lsls r2, r0, 5 - ldr r3, =gPlttBufferUnfaded + 0x14 - adds r6, r2, r3 - ldr r5, =gPlttBufferFaded + 0x14 - adds r2, r5 - ldr r1, =0x040000d4 - str r6, [r1] - str r2, [r1, 0x4] - ldr r2, =0x80000001 - str r2, [r1, 0x8] - ldr r6, [r1, 0x8] - lsls r0, 4 - adds r4, 0xC - adds r0, r4 - lsls r0, 1 - subs r3, 0x14 - adds r3, r0, r3 - subs r5, 0x14 - adds r0, r5 - str r3, [r1] - str r0, [r1, 0x4] - str r2, [r1, 0x8] - ldr r0, [r1, 0x8] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC87C - - thumb_func_start sub_80DC8D0 -sub_80DC8D0: @ 80DC8D0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - movs r7, 0 - lsls r1, r0, 2 - adds r1, r0 - mov r9, r1 - lsls r6, r1, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - ldr r1, =0x00004bff - mov r10, r1 -_080DC8F0: - lsls r0, r7, 26 - lsrs r3, r0, 24 - lsls r0, r3, 1 - adds r0, r6 - mov r4, r8 - adds r2, r0, r4 - movs r5, 0 - ldrsh r0, [r2, r5] - cmp r0, 0xFF - beq _080DC996 - adds r0, r3, 0x2 - lsls r0, 1 - adds r0, r6 - adds r1, r0, r4 - ldrh r0, [r1] - adds r0, 0x1 - movs r4, 0 - strh r0, [r1] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _080DC996 - strh r4, [r1] - adds r0, r3, 0x1 - lsls r1, r0, 1 - adds r1, r6 - add r1, r8 - movs r4, 0 - ldrsh r1, [r1, r4] - adds r4, r0, 0 - cmp r1, 0 - bne _080DC940 - ldrh r0, [r2] - adds r0, 0x1 - b _080DC944 - .pool -_080DC940: - ldrh r0, [r2] - subs r0, 0x1 -_080DC944: - strh r0, [r2] - lsls r1, r3, 1 - mov r5, r9 - lsls r2, r5, 3 - adds r0, r1, r2 - ldr r3, =gTasks - adds r3, 0x8 - adds r0, r3 - movs r5, 0 - ldrsh r0, [r0, r5] - adds r5, r1, 0 - cmp r0, 0x10 - beq _080DC962 - cmp r0, 0 - bne _080DC970 -_080DC962: - lsls r0, r4, 1 - adds r0, r2 - adds r0, r3 - ldrh r1, [r0] - movs r2, 0x1 - eors r1, r2 - strh r1, [r0] -_080DC970: - adds r4, r7, 0x5 - lsls r4, 4 - adds r0, r4, 0 - adds r0, 0xA - adds r5, r6 - add r5, r8 - ldrb r2, [r5] - movs r1, 0x1 - mov r3, r10 - bl BlendPalette - adds r4, 0xC - adds r4, r7 - ldrb r2, [r5] - adds r0, r4, 0 - movs r1, 0x1 - mov r3, r10 - bl BlendPalette -_080DC996: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _080DC8F0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DC8D0 - - thumb_func_start sub_80DC9B4 -sub_80DC9B4: @ 80DC9B4 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x15] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080DC9E0 - adds r0, r2, 0 - bl sub_80DC630 - b _080DC9E6 - .pool -_080DC9E0: - adds r0, r2, 0 - bl sub_80DC674 -_080DC9E6: - pop {r0} - bx r0 - thumb_func_end sub_80DC9B4 - - thumb_func_start sub_80DC9EC -sub_80DC9EC: @ 80DC9EC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0xC] - ldr r6, =gUnknown_02039F26 - adds r6, r0, r6 - ldrb r0, [r6] - lsls r5, r0, 2 - adds r5, r0 - lsls r5, 27 - movs r0, 0x80 - lsls r0, 22 - adds r5, r0 - lsrs r5, 24 - ldr r1, [sp, 0xC] - lsls r4, r1, 3 - ldr r0, =gUnknown_08589904 - adds r0, r4, r0 - bl LoadCompressedSpriteSheet - ldr r0, =gUnknown_08589924 - adds r4, r0 - adds r0, r4, 0 - bl LoadSpritePalette - ldr r2, [sp, 0xC] - lsls r4, r2, 1 - adds r4, r2 - lsls r4, 3 - ldr r0, =gSpriteTemplate_858998C - adds r4, r0 - adds r0, r4, 0 - movs r1, 0xB8 - adds r2, r5, 0 - movs r3, 0x1D - bl CreateSprite - mov r9, r0 - mov r3, r9 - lsls r3, 24 - lsrs r3, 24 - mov r9, r3 - adds r0, r4, 0 - movs r1, 0xF8 - adds r2, r5, 0 - movs r3, 0x1D - bl CreateSprite - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r5, r0, 4 - add r5, r8 - lsls r5, 2 - ldr r1, =gSprites - adds r5, r1 - ldrh r2, [r5, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x40 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r5, 0x4] - movs r4, 0xC0 - lsls r4, 19 - ldrb r0, [r6] - lsls r3, r0, 2 - adds r3, r0 - lsls r3, 6 - ldr r0, =0x0600e026 - adds r3, r0 - ldr r7, =gContestResources - ldr r0, [r7] - ldr r0, [r0, 0x34] - str r0, [sp] - movs r0, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl CopySpriteTiles - ldrb r0, [r6] - lsls r3, r0, 2 - adds r3, r0 - lsls r3, 6 - ldr r1, =0x0600e036 - adds r3, r1 - ldr r0, [r7] - ldr r0, [r0, 0x38] - str r0, [sp] - movs r0, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl CopySpriteTiles - movs r4, 0 - str r4, [sp, 0x4] - ldr r0, [r7] - ldr r1, [r0, 0x34] - movs r6, 0xA0 - lsls r6, 3 - adds r1, r6 - ldr r2, =0x050000c0 - mov r10, r2 - add r0, sp, 0x4 - bl CpuSet - str r4, [sp, 0x8] - add r0, sp, 0x8 - ldr r1, [r7] - ldr r1, [r1, 0x38] - adds r1, r6 - mov r2, r10 - bl CpuSet - ldr r0, [r7] - ldr r0, [r0, 0x34] - mov r3, r9 - lsls r4, r3, 4 - add r4, r9 - lsls r4, 2 - ldr r1, =gSprites - adds r4, r1 - ldrh r1, [r4, 0x4] - lsls r1, 22 - lsrs r1, 17 - ldr r6, =0x06010000 - adds r1, r6 - movs r2, 0x80 - lsls r2, 4 - mov r10, r2 - movs r3, 0x1 - bl RequestDma3Copy - ldr r0, [r7] - ldr r0, [r0, 0x38] - ldrh r1, [r5, 0x4] - lsls r1, 22 - lsrs r1, 17 - adds r1, r6 - mov r2, r10 - movs r3, 0x1 - bl RequestDma3Copy - mov r3, r8 - strh r3, [r4, 0x2E] - mov r0, r9 - strh r0, [r5, 0x2E] - mov r1, sp - ldrh r1, [r1, 0xC] - strh r1, [r4, 0x30] - mov r2, sp - ldrh r2, [r2, 0xC] - strh r2, [r5, 0x30] - mov r0, r9 - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DC9EC - thumb_func_start sub_80DCB78 sub_80DCB78: @ 80DCB78 push {r4,r5,lr} diff --git a/include/util.h b/include/util.h index 9d13453c2..56c89359a 100644 --- a/include/util.h +++ b/include/util.h @@ -15,5 +15,7 @@ u16 CalcCRC16WithTable(u8 *data, u32 length); u32 CalcByteArraySum(const u8* data, u32 length); void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor); void DoBgAffineSet(struct BgAffineDstData *dest, u32 texX, u32 texY, s16 scrX, s16 scrY, s16 sx, s16 sy, u16 alpha); +void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output); + #endif // GUARD_UTIL_H diff --git a/src/contest.c b/src/contest.c index 4fb5f76c5..a0b44e331 100644 --- a/src/contest.c +++ b/src/contest.c @@ -113,7 +113,7 @@ void sub_80DBF90(void); void sub_80DC2BC(void); void sub_80DC490(bool8); void sub_80DC4F0(void); -void sub_80DC594(void); +void CreateApplauseMeterSprite(void); void sub_80DC5E8(void); void sub_80DC7EC(void); void sub_80DCD48(void); @@ -174,6 +174,14 @@ s16 sub_80DBD34(u8); void DetermineFinalStandings(void); bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); void sub_80DC0F4(u8); +void sub_80DC408(struct Sprite *); +void sub_80DC728(u8); +void sub_80DC6A4(u8); +void sub_80DC8D0(u8); +void sub_80DC81C(u8); +void sub_80DC87C(u8); + + EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA s16 gContestMonConditions[4] = {0}; @@ -230,6 +238,17 @@ extern const struct SpriteTemplate gSpriteTemplate_8587C18; extern const union AffineAnimCmd *const gUnknown_082FF6C0[]; extern const union AffineAnimCmd *const gUnknown_082FF694[]; extern const u8 *const gContestEffectDescriptionPointers[]; +extern const struct SpriteSheet gUnknown_08587A74; +extern const u8 gUnknown_08587A6C[]; +extern const struct SpriteTemplate gSpriteTemplate_8587AD0; +extern const struct SpritePalette gUnknown_08587B08; +extern const struct CompressedSpriteSheet gUnknown_08587AE8[]; +extern const struct SpriteTemplate gSpriteTemplate_8587B18[]; +extern const u8 gUnknown_08587A70[]; +extern const struct SubspriteTable gSubspriteTables_8587B80[]; +extern const struct CompressedSpriteSheet gUnknown_08587BB0; +extern const struct SpritePalette gUnknown_08587BB8; +extern const struct SpriteTemplate gSpriteTemplate_8587BC8; void TaskDummy1(u8 taskId) { @@ -577,7 +596,7 @@ u8 sub_80D7E44(u8 *a) gContestResources->field_0->unk19216 = sub_80DB120(); sub_80DC2BC(); sub_80DC4F0(); - sub_80DC594(); + CreateApplauseMeterSprite(); sub_80DC5E8(); sub_80DC7EC(); gBattlerPositions[0] = 0; @@ -3090,8 +3109,6 @@ u8 sub_80DC028(s16 a, s16 b, u8 c) return taskId; } -#ifdef NONMATCHING - void sub_80DC0F4(u8 taskId) { u8 r7 = gTasks[taskId].data[3]; @@ -3103,7 +3120,8 @@ void sub_80DC0F4(u8 taskId) u16 r6; u8 r5; u8 r10; - + u8 r11; + gTasks[taskId].data[10] = 0; if (gTasks[taskId].data[1] == 0) { @@ -3158,16 +3176,15 @@ void sub_80DC0F4(u8 taskId) } } } - - r10 = r5; - r1 = 0; + r10 = r5; + r11 = 0; + if (r5 > 7) - { - r1 = 1; - r5 -= 8; + { + r11 = 1; + r5-= 8; } - - ContestBG_FillBoxWithTile(0, r6, r5 + 0x16, (gUnknown_02039F26[r7] * 5) + 2 + r3, 1, 1, 0x11); + ContestBG_FillBoxWithTile(0, r6, r5 + 22, gUnknown_02039F26[r7] * 5 + 2 + r11, 1, 1, 17); if (r1 > 0) { PlaySE(SE_C_GAJI); @@ -3175,239 +3192,318 @@ void sub_80DC0F4(u8 taskId) m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, r10 * 256); } else - { PlaySE(SE_BOO); - } - - if (r10 == 0 && r5 == 0 && r6 == 0) + + if (!r11 && !r5 && !r6) gTasks[taskId].data[2] = -gTasks[taskId].data[2]; } } -#else -NAKED -void sub_80DC0F4(u8 taskId) + +void sub_80DC2BC(void) { - asm(".syntax 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, 0x10\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - ldr r1, =gTasks\n\ - lsls r0, r7, 2\n\ - adds r0, r7\n\ - lsls r0, 3\n\ - adds r4, r0, r1\n\ - ldrb r0, [r4, 0xE]\n\ - mov r9, r0\n\ - ldrh r3, [r4, 0x8]\n\ - ldrh r1, [r4, 0xA]\n\ - ldrh r0, [r4, 0x1C]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x1C]\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0xE\n\ - bgt _080DC126\n\ - b _080DC2A8\n\ -_080DC126:\n\ - movs r0, 0\n\ - strh r0, [r4, 0x1C]\n\ - ldrh r2, [r4, 0xA]\n\ - movs r5, 0xA\n\ - ldrsh r0, [r4, r5]\n\ - cmp r0, 0\n\ - bne _080DC15C\n\ - adds r0, r7, 0\n\ - bl DestroyTask\n\ - ldr r0, =gContestResources\n\ - ldr r0, [r0]\n\ - ldr r0, [r0, 0x14]\n\ - mov r2, r9\n\ - lsls r1, r2, 2\n\ - adds r1, r0\n\ - ldrb r2, [r1, 0x2]\n\ - movs r0, 0x5\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x2]\n\ - b _080DC2A8\n\ - .pool\n\ -_080DC15C:\n\ - cmp r3, 0\n\ - bne _080DC1A4\n\ - lsls r0, r1, 16\n\ - mov r8, r0\n\ - cmp r0, 0\n\ - bge _080DC17A\n\ - mov r0, r9\n\ - bl sub_80DBFC8\n\ - adds r0, 0x2\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - ldrh r0, [r4, 0xA]\n\ - adds r0, 0x1\n\ - b _080DC188\n\ -_080DC17A:\n\ - mov r0, r9\n\ - bl sub_80DBFC8\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - ldrh r0, [r4, 0xA]\n\ - subs r0, 0x1\n\ -_080DC188:\n\ - strh r0, [r4, 0xA]\n\ - ldr r1, =gTasks\n\ - lsls r0, r7, 2\n\ - adds r0, r7\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldrh r1, [r0, 0x8]\n\ - adds r2, r1, 0x1\n\ - strh r2, [r0, 0x8]\n\ - lsls r1, 24\n\ - lsrs r5, r1, 24\n\ - b _080DC210\n\ - .pool\n\ -_080DC1A4:\n\ - movs r3, 0xC\n\ - ldrsh r0, [r4, r3]\n\ - cmp r0, 0\n\ - bge _080DC1DE\n\ - lsls r0, r1, 16\n\ - mov r8, r0\n\ - cmp r0, 0\n\ - bge _080DC1CC\n\ - ldrh r0, [r4, 0x8]\n\ - adds r1, r0, 0x1\n\ - strh r1, [r4, 0x8]\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - adds r0, r2, 0x1\n\ - strh r0, [r4, 0xA]\n\ - mov r0, r9\n\ - bl sub_80DBFC8\n\ - adds r0, 0x2\n\ - b _080DC20C\n\ -_080DC1CC:\n\ - ldrh r0, [r4, 0x8]\n\ - subs r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - movs r6, 0\n\ - subs r0, r2, 0x1\n\ - strh r0, [r4, 0xA]\n\ - b _080DC210\n\ -_080DC1DE:\n\ - lsls r0, r1, 16\n\ - mov r8, r0\n\ - cmp r0, 0\n\ - bge _080DC1F8\n\ - ldrh r0, [r4, 0x8]\n\ - subs r0, 0x1\n\ - strh r0, [r4, 0x8]\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - movs r6, 0\n\ - adds r0, r2, 0x1\n\ - strh r0, [r4, 0xA]\n\ - b _080DC210\n\ -_080DC1F8:\n\ - ldrh r0, [r4, 0x8]\n\ - adds r1, r0, 0x1\n\ - strh r1, [r4, 0x8]\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - subs r0, r2, 0x1\n\ - strh r0, [r4, 0xA]\n\ - mov r0, r9\n\ - bl sub_80DBFC8\n\ -_080DC20C:\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ -_080DC210:\n\ - str r5, [sp, 0xC]\n\ - movs r0, 0\n\ - mov r10, r0\n\ - cmp r5, 0x7\n\ - bls _080DC226\n\ - movs r2, 0x1\n\ - mov r10, r2\n\ - adds r0, r5, 0\n\ - subs r0, 0x8\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ -_080DC226:\n\ - adds r2, r5, 0\n\ - adds r2, 0x16\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - ldr r0, =gUnknown_02039F26\n\ - add r0, r9\n\ - ldrb r0, [r0]\n\ - lsls r3, r0, 2\n\ - adds r3, r0\n\ - adds r3, 0x2\n\ - add r3, r10\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - movs r0, 0x1\n\ - str r0, [sp]\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0x11\n\ - str r0, [sp, 0x8]\n\ - movs r0, 0\n\ - adds r1, r6, 0\n\ - bl ContestBG_FillBoxWithTile\n\ - mov r3, r8\n\ - cmp r3, 0\n\ - ble _080DC284\n\ - movs r0, 0x60\n\ - bl PlaySE\n\ - ldr r4, =gMPlayInfo_SE1\n\ - adds r0, r4, 0\n\ - bl m4aMPlayImmInit\n\ - ldr r1, =0x0000ffff\n\ - ldr r0, [sp, 0xC]\n\ - lsls r2, r0, 24\n\ - asrs r2, 16\n\ - adds r0, r4, 0\n\ - bl m4aMPlayPitchControl\n\ - b _080DC28A\n\ - .pool\n\ -_080DC284:\n\ - movs r0, 0x16\n\ - bl PlaySE\n\ -_080DC28A:\n\ - mov r2, r10\n\ - cmp r2, 0\n\ - bne _080DC2A8\n\ - cmp r5, 0\n\ - bne _080DC2A8\n\ - cmp r6, 0\n\ - bne _080DC2A8\n\ - ldr r0, =gTasks\n\ - lsls r1, r7, 2\n\ - adds r1, r7\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - ldrh r0, [r1, 0xC]\n\ - negs r0, r0\n\ - strh r0, [r1, 0xC]\n\ -_080DC2A8:\n\ - add sp, 0x10\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\n\ - .pool\n\ - .syntax divided\n"); + s32 i; + + LoadSpriteSheet(&gUnknown_08587A74); + for (i = 0; i < 4; i++) + { + u8 y = gUnknown_08587A6C[gUnknown_02039F26[i]]; + + gContestResources->field_14[i].unk0 = CreateSprite(&gSpriteTemplate_8587AD0, 180, y, 1); + } } -#endif \ No newline at end of file + +void sub_80DC308(u8 a) +{ + u8 spriteId; + s16 r5; + + gContestResources->field_14[a].unk2_0 = 1; + spriteId = gContestResources->field_14[a].unk0; + r5 = sContestantStatus[a].unk4 / 10 * 2; + if (r5 > 56) + r5 = 56; + else if (r5 < 0) + r5 = 0; + gSprites[spriteId].invisible = FALSE; + gSprites[spriteId].data[0] = a; + gSprites[spriteId].data[1] = r5; + if (gSprites[spriteId].data[1] > gSprites[spriteId].pos2.x) + gSprites[spriteId].data[2] = 1; + else + gSprites[spriteId].data[2] = -1; + gSprites[spriteId].callback = sub_80DC408; +} + +void sub_80DC3AC(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + sub_80DC308(i); +} + +bool8 sub_80DC3C4(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (gContestResources->field_14[i].unk2_0) + break; + } + if (i == 4) + return TRUE; + else + return FALSE; +} + +void sub_80DC408(struct Sprite *sprite) +{ + if (sprite->pos2.x == sprite->data[1]) + { + gContestResources->field_14[sprite->data[0]].unk2_0 = 0; + sprite->callback = SpriteCallbackDummy; + } + else + { + sprite->pos2.x += sprite->data[2]; + } +} + +void sub_80DC44C(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gUnknown_02039F26[i]]; +} + +void sub_80DC490(bool8 a) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (gUnknown_02039F26[i] > 1) + { + if (!a) + gSprites[gContestResources->field_14[i].unk0].pos1.x = 180; + else + gSprites[gContestResources->field_14[i].unk0].pos1.x = 256; + } + } +} + +void sub_80DC4F0(void) +{ + s32 i; + + LoadSpritePalette(&gUnknown_08587B08); + for (i = 0; i < 4; i++) + { + LoadCompressedObjectPic(&gUnknown_08587AE8[i]); + gContestResources->field_14[i].unk1 = CreateSprite( + &gSpriteTemplate_8587B18[i], + 204, gUnknown_08587A70[gUnknown_02039F26[i]], + 0); + SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); + gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; + } +} + +void CreateApplauseMeterSprite(void) +{ + u8 spriteId; + + LoadCompressedObjectPic(&gUnknown_08587BB0); + LoadSpritePalette(&gUnknown_08587BB8); + spriteId = CreateSprite(&gSpriteTemplate_8587BC8, 30, 44, 1); + gSprites[spriteId].invisible = TRUE; + sContest.applauseMeterSpriteId = spriteId; +} + +void sub_80DC5E8(void) +{ + u8 i; + u8 taskId = CreateTask(sub_80DC728, 30); + + sContest.unk19211 = taskId; + for (i = 0; i < 4; i++) + gTasks[taskId].data[i * 4] = 0xFF; +} + +void sub_80DC630(u8 a) +{ + gTasks[sContest.unk19211].data[a * 4 + 0] = 0; + gTasks[sContest.unk19211].data[a * 4 + 1] = 0; +} + +void sub_80DC674(u8 a) +{ + u8 taskId = CreateTask(sub_80DC6A4, 31); + + gTasks[taskId].data[0] = a; +} + +void sub_80DC6A4(u8 taskId) +{ + u8 r4 = gTasks[taskId].data[0]; + + if (gTasks[sContest.unk19211].data[r4 * 4 + 0] == 0 + || gTasks[sContest.unk19211].data[r4 * 4 + 0] == 0xFF) + { + gTasks[sContest.unk19211].data[r4 * 4 + 0] = 0xFF; + gTasks[sContest.unk19211].data[r4 * 4 + 1] = 0; + BlendPalette((sContest.unk19218[r4] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18)); + DestroyTask(taskId); + } +} + +void sub_80DC728(u8 taskId) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + u8 r3 = i * 4; + + if (gTasks[taskId].data[r3 + 0] != 0xFF) + { + if (gTasks[taskId].data[r3 + 1] == 0) + gTasks[taskId].data[r3 + 0]++; + else + gTasks[taskId].data[r3 + 0]--; + + if (gTasks[taskId].data[r3 + 0] == 16 + || gTasks[taskId].data[r3 + 0] == 0) + gTasks[taskId].data[r3 + 1] ^= 1; + + BlendPalette( + (sContest.unk19218[i] + 5) * 16 + 6, + 2, + gTasks[taskId].data[r3 + 0], + RGB(31, 31, 18)); + } + } +} + +void sub_80DC7EC(void) +{ + s32 i; + + sContest.unk19212 = CreateTask(sub_80DC8D0, 30); + for (i = 0; i < 4; i++) + sub_80DC81C(i); +} + +void sub_80DC81C(u8 a) +{ + gTasks[sContest.unk19212].data[a * 4 + 0] = 0xFF; + gTasks[sContest.unk19212].data[a * 4 + 1] = 0; +} + +void sub_80DC864(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + sub_80DC87C(i); +} + +void sub_80DC87C(u8 a) +{ + u32 var; + u32 r0; + + sub_80DC81C(a); + + r0 = a + 5; + DmaCopy16Defvars( + 3, + gPlttBufferUnfaded + r0 * 16 + 10, + gPlttBufferFaded + r0 * 16 + 10, + 2); + + var = (a + 5) * 16 + 12 + a; + DmaCopy16Defvars( + 3, + gPlttBufferUnfaded + var, + gPlttBufferFaded + var, + 2); +} + +void sub_80DC8D0(u8 taskId) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + u8 r3 = i * 4; + + if (gTasks[taskId].data[r3 + 0] != 0xFF) + { + if (++gTasks[taskId].data[r3 + 2] > 2) + { + gTasks[taskId].data[r3 + 2] = 0; + + if (gTasks[taskId].data[r3 + 1] == 0) + gTasks[taskId].data[r3 + 0]++; + else + gTasks[taskId].data[r3 + 0]--; + + if (gTasks[taskId].data[r3 + 0] == 16 + || gTasks[taskId].data[r3 + 0] == 0) + gTasks[taskId].data[r3 + 1] ^= 1; + + BlendPalette((i + 5) * 16 + 10, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + BlendPalette((i + 5) * 16 + 12 + i, 1, gTasks[taskId].data[r3 + 0], RGB(31, 31, 18)); + } + } + } +} + +void sub_80DC9B4(u8 a) +{ + if (sContestantStatus[a].hasJudgesAttention) + sub_80DC630(a); + else + sub_80DC674(a); +} + +extern const struct CompressedSpriteSheet gUnknown_08589904[]; +extern const struct SpritePalette gUnknown_08589924[]; +extern const struct SpriteTemplate gSpriteTemplate_858998C[]; + +u8 sub_80DC9EC(u8 a) +{ + u8 r5 = gUnknown_02039F26[a] * 40 + 32; + u8 r8; + u8 r6; + volatile u8 zero; + + + LoadCompressedObjectPic(&gUnknown_08589904[a]); + LoadSpritePalette(&gUnknown_08589924[a]); + r6 = CreateSprite(&gSpriteTemplate_858998C[a], 184, r5, 29); + gSprites[r8].oam.tileNum += 64; + r8 = CreateSprite(&gSpriteTemplate_858998C[a], 248, r5, 29); + + + CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x26), (u8 *)(VRAM + 0x10000 + gSprites[r6].oam.tileNum * 32)); + CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32)); + CpuSet(&r8, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), 0x050000c0); + + RequestDma3Copy((void *)(VRAM + 0x10000 + (0x28 + gSprites[r6].oam.tileNum) * 32), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32), 0x80, 1); + + // What is this? + zero = 0; + zero = 0; + + RequestDma3Copy((void *)(VRAM + 0x10000 + (0x28 + gSprites[r6].oam.tileNum) * 32), (u8 *)(VRAM + 0x10000 + gSprites[r6].oam.tileNum * 32), 0x80, 1); + + + gSprites[r6].data[0] = r8; + gSprites[r8].data[0] = r6; + + return r6; +} \ No newline at end of file From 284751e7610f5e9cf266bd0a8bb148464753afa1 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sat, 5 Jan 2019 23:02:28 -0800 Subject: [PATCH 04/12] Decompile through ClearContestWinnerPicsInContestHall, 10 NONMATCHINGs present. --- asm/contest.s | 4542 --------------------------------- data/contest.s | 2 +- data/text/contest_strings.inc | 10 +- include/contest.h | 6 +- include/graphics.h | 4 + src/contest.c | 2742 +++++++++++++++++++- src/graphics.c | 4 +- 7 files changed, 2730 insertions(+), 4580 deletions(-) diff --git a/asm/contest.s b/asm/contest.s index f5ca016df..f30eb3261 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5,4548 +5,6 @@ .text - thumb_func_start sub_80DCB78 -sub_80DCB78: @ 80DCB78 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSprites - lsls r5, r0, 4 - adds r5, r0 - lsls r5, 2 - adds r5, r1 - ldrh r0, [r5, 0x2E] - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - adds r4, r1 - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite - adds r0, r5, 0 - bl DestroySpriteAndFreeResources - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCB78 - - thumb_func_start sub_80DCBB4 -sub_80DCBB4: @ 80DCBB4 - push {lr} - movs r1, 0xFD - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x00000907 - movs r0, 0x52 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCBB4 - - thumb_func_start sub_80DCBD0 -sub_80DCBD0: @ 80DCBD0 - push {lr} - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_80DCBD0 - - thumb_func_start sub_80DCBE8 -sub_80DCBE8: @ 80DCBE8 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - adds r4, r0, 0 - mov r9, r1 - lsls r4, 24 - lsrs r4, 24 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - bl sub_80DCBB4 - ldr r0, =gContestResources - ldr r1, [r0] - ldr r2, =gSprites - mov r8, r2 - lsls r6, r4, 4 - adds r6, r4 - lsls r6, 2 - adds r0, r6, r2 - movs r3, 0x30 - ldrsh r2, [r0, r3] - ldr r1, [r1, 0x14] - lsls r2, 2 - adds r2, r1 - ldrb r1, [r2, 0x2] - movs r3, 0x2 - orrs r1, r3 - strb r1, [r2, 0x2] - ldrh r5, [r0, 0x2E] - lsls r5, 24 - lsrs r5, 24 - movs r1, 0x1 - bl StartSpriteAffineAnim - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - mov r1, r8 - adds r0, r4, r1 - movs r1, 0x1 - bl StartSpriteAffineAnim - movs r2, 0x1C - add r8, r2 - add r6, r8 - ldr r0, =sub_80DCC84 - str r0, [r6] - add r4, r8 - ldr r0, =SpriteCallbackDummy - str r0, [r4] - mov r3, r9 - cmp r3, 0 - bne _080DCC70 - movs r0, 0x65 - bl PlaySE - b _080DCC76 - .pool -_080DCC70: - movs r0, 0x2 - bl PlaySE -_080DCC76: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80DCBE8 - - thumb_func_start sub_80DCC84 -sub_80DCC84: @ 80DCC84 - push {lr} - mov r12, r0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080DCCCC - mov r0, r12 - ldrh r1, [r0, 0x2E] - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _080DCCCC - mov r3, r12 - adds r3, 0x3E - ldrb r0, [r3] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r3] - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r2 - strb r0, [r1] - ldr r0, =sub_80DCCD8 - mov r1, r12 - str r0, [r1, 0x1C] -_080DCCCC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCC84 - - thumb_func_start sub_80DCCD8 -sub_80DCCD8: @ 80DCCD8 - push {lr} - ldr r1, =gContestResources - ldr r1, [r1] - movs r3, 0x30 - ldrsh r2, [r0, r3] - ldr r1, [r1, 0x14] - lsls r2, 2 - adds r2, r1 - ldrb r3, [r2, 0x2] - movs r1, 0x3 - negs r1, r1 - ands r1, r3 - strb r1, [r2, 0x2] - ldrh r0, [r0, 0x2E] - lsls r0, 24 - lsrs r0, 24 - bl sub_80DCB78 - bl sub_80DCBD0 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCCD8 - - thumb_func_start sub_80DCD08 -sub_80DCD08: @ 80DCD08 - push {lr} - ldr r0, =gHeap - movs r1, 0xD0 - lsls r1, 9 - adds r2, r0, r1 - ldrb r1, [r2] - adds r3, r0, 0 - cmp r1, 0x1 - bne _080DCD24 - movs r0, 0 - b _080DCD26 - .pool -_080DCD24: - movs r0, 0x1 -_080DCD26: - strb r0, [r2] - movs r1, 0xD0 - lsls r1, 9 - adds r0, r3, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080DCD3E - bl sub_80DAEA4 - bl sub_80DB2BC - b _080DCD42 -_080DCD3E: - bl sub_80DCD48 -_080DCD42: - pop {r0} - bx r0 - thumb_func_end sub_80DCD08 - - thumb_func_start sub_80DCD48 -sub_80DCD48: @ 80DCD48 - push {r4,r5,lr} - sub sp, 0xC - ldr r0, =gUnknown_020322D5 - ldrb r0, [r0] - cmp r0, 0 - beq _080DCE44 - ldr r0, =gHeap - movs r1, 0xD0 - lsls r1, 9 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080DCE44 - cmp r0, 0 - blt _080DCD7C - cmp r0, 0x3 - bgt _080DCD7C - cmp r0, 0x2 - blt _080DCD7C - bl sub_80DF750 - b _080DCE44 - .pool -_080DCD7C: - movs r5, 0 -_080DCD7E: - adds r0, r5, 0 - movs r1, 0 - bl FillWindowPixelBuffer - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _080DCD7E - movs r5, 0 -_080DCD92: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r0, r1 - add r2, sp, 0x4 - ldrh r4, [r0, 0x4] - movs r1, 0x4 - ldrsh r0, [r0, r1] - cmp r0, 0 - bge _080DCDBC - negs r0, r0 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r2, 0 - ldr r1, =gText_OneDash - bl StringCopy - adds r2, r0, 0 -_080DCDBC: - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r2, 0 - movs r2, 0 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r0, =gUnknown_02039F26 - adds r0, r5, r0 - ldrb r0, [r0] - movs r1, 0x7 - str r1, [sp] - add r1, sp, 0x4 - movs r2, 0x37 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _080DCD92 - movs r5, 0 -_080DCDEA: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r0, r1 - add r2, sp, 0x4 - ldrh r4, [r0, 0x2] - movs r1, 0x2 - ldrsh r0, [r0, r1] - cmp r0, 0 - bge _080DCE14 - negs r0, r0 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r2, 0 - ldr r1, =gText_OneDash - bl StringCopy - adds r2, r0, 0 -_080DCE14: - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r2, 0 - movs r2, 0 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r0, =gUnknown_02039F26 - adds r0, r5, r0 - ldrb r0, [r0] - movs r1, 0x7 - str r1, [sp] - add r1, sp, 0x4 - movs r2, 0x5 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _080DCDEA - bl sub_80DB2BC -_080DCE44: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCD48 - - thumb_func_start sub_80DCE58 -sub_80DCE58: @ 80DCE58 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - add r4, sp, 0x4 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x8 - bl memset - movs r5, 0 - add r4, sp, 0x4 - adds r6, r4, 0 - movs r7, 0 -_080DCE7E: - bl Random - adds r1, r0, 0 - mov r0, sp - adds r0, r7 - adds r0, 0x4 - strh r1, [r0] - movs r2, 0 - cmp r2, r5 - bge _080DCEB6 - lsls r0, r1, 16 - lsrs r0, 16 - mov r1, sp - ldrh r1, [r1, 0x4] - cmp r0, r1 - beq _080DCEB0 -_080DCE9E: - adds r2, 0x1 - cmp r2, r5 - bge _080DCEB6 - lsls r0, r2, 1 - adds r0, r4, r0 - ldrh r1, [r6] - ldrh r0, [r0] - cmp r1, r0 - bne _080DCE9E -_080DCEB0: - subs r6, 0x2 - subs r7, 0x2 - subs r5, 0x1 -_080DCEB6: - adds r6, 0x2 - adds r7, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _080DCE7E - mov r2, r8 - cmp r2, 0 - bne _080DCF80 - movs r5, 0 - ldr r3, =gUnknown_02039F26 - mov r8, r3 -_080DCECC: - mov r6, r8 - strb r5, [r6] - movs r4, 0 - cmp r4, r5 - bge _080DCF48 - ldr r7, =gContestMonConditions - mov r9, r7 - lsls r0, r5, 1 - adds r1, r0, 0 - add r1, r9 - mov r12, r1 - mov r2, sp - adds r2, 0x4 - str r2, [sp, 0xC] - add r0, sp - adds r0, 0x4 - str r0, [sp, 0x10] - ldr r3, =gUnknown_02039F26 - adds r6, r3, 0 - mov r10, r6 -_080DCEF4: - ldrb r0, [r3] - lsls r2, r0, 1 - mov r7, r9 - adds r0, r2, r7 - movs r6, 0 - ldrsh r1, [r0, r6] - mov r7, r12 - movs r6, 0 - ldrsh r0, [r7, r6] - cmp r1, r0 - blt _080DCF1C - cmp r1, r0 - bne _080DCF40 - ldr r7, [sp, 0xC] - adds r0, r7, r2 - ldrh r0, [r0] - ldr r1, [sp, 0x10] - ldrh r1, [r1] - cmp r0, r1 - bcs _080DCF40 -_080DCF1C: - adds r2, r5, 0 - cmp r5, r4 - ble _080DCF34 - subs r0, r5, 0x1 - mov r6, r10 - adds r1, r0, r6 -_080DCF28: - ldrb r0, [r1] - strb r0, [r1, 0x1] - subs r1, 0x1 - subs r2, 0x1 - cmp r2, r4 - bgt _080DCF28 -_080DCF34: - strb r5, [r3] - b _080DCF48 - .pool -_080DCF40: - adds r3, 0x1 - adds r4, 0x1 - cmp r4, r5 - blt _080DCEF4 -_080DCF48: - cmp r4, r5 - bne _080DCF50 - mov r7, r8 - strb r5, [r7] -_080DCF50: - movs r0, 0x1 - add r8, r0 - adds r5, 0x1 - cmp r5, 0x3 - ble _080DCECC - ldr r4, =gUnknown_02039F26 - mov r0, sp - adds r1, r4, 0 - movs r2, 0x4 - bl memcpy - movs r5, 0 -_080DCF68: - mov r1, sp - adds r0, r1, r5 - ldrb r0, [r0] - adds r0, r4 - strb r5, [r0] - adds r5, 0x1 - cmp r5, 0x3 - ble _080DCF68 - b _080DD034 - .pool -_080DCF80: - mov r0, sp - movs r1, 0xFF - movs r2, 0x4 - bl memset - movs r5, 0 - ldr r3, =gUnknown_02039F26 - movs r6, 0 -_080DCF90: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x4] - adds r0, r6, r0 - ldrb r0, [r0, 0xB] - lsls r0, 30 - lsrs r2, r0, 30 - mov r7, sp - adds r1, r7, r2 - b _080DCFB6 - .pool -_080DCFAC: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - mov r0, sp - adds r1, r0, r2 -_080DCFB6: - ldrb r0, [r1] - cmp r0, 0xFF - bne _080DCFAC - strb r5, [r1] - strb r2, [r3] - adds r3, 0x1 - adds r6, 0x1C - adds r5, 0x1 - cmp r5, 0x3 - ble _080DCF90 - movs r5, 0 -_080DCFCC: - movs r4, 0x3 - adds r1, r5, 0x1 - mov r10, r1 - cmp r4, r5 - ble _080DD02E - mov r9, r4 - ldr r2, =gUnknown_02039F26 - mov r8, r2 - add r3, sp, 0x4 - mov r12, r3 -_080DCFE0: - ldr r6, =gContestResources - ldr r0, [r6] - ldr r1, [r0, 0x4] - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r0, r1 - adds r1, r0, 0 - subs r1, 0x1C - ldrb r2, [r1, 0xB] - ldrb r3, [r0, 0xB] - mov r1, r9 - ands r1, r2 - mov r0, r9 - ands r0, r3 - subs r3, r4, 0x1 - cmp r1, r0 - bne _080DD028 - mov r0, r8 - adds r7, r3, r0 - adds r2, r4, r0 - ldrb r6, [r7] - ldrb r1, [r2] - cmp r6, r1 - bcs _080DD028 - lsls r0, r3, 1 - add r0, r12 - lsls r1, r4, 1 - add r1, r12 - ldrh r0, [r0] - ldrh r1, [r1] - cmp r0, r1 - bcs _080DD028 - ldrb r0, [r2] - strb r6, [r2] - strb r0, [r7] -_080DD028: - adds r4, r3, 0 - cmp r4, r5 - bgt _080DCFE0 -_080DD02E: - mov r5, r10 - cmp r5, 0x2 - ble _080DCFCC -_080DD034: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DCE58 - - thumb_func_start sub_80DD04C -sub_80DD04C: @ 80DD04C - push {r4,r5,lr} - movs r4, 0 - movs r5, 0xA0 -_080DD052: - ldr r0, =gHeap+0x1A004 - adds r0, r5, r0 - ldr r1, =gUnknown_02039F26 - adds r1, r4, r1 - ldrb r1, [r1] - adds r1, 0x5 - lsls r1, 4 - movs r2, 0x20 - bl LoadPalette - adds r5, 0x20 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DD052 - bl sub_80DAEA4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD04C - - thumb_func_start sub_80DD080 -sub_80DD080: @ 80DD080 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r4, =gContestResources - ldr r3, [r4] - ldr r1, [r3, 0x4] - lsls r7, r6, 3 - subs r0, r7, r6 - lsls r5, r0, 2 - adds r1, r5, r1 - movs r2, 0 - strh r2, [r1, 0x2] - ldr r0, [r3, 0x4] - adds r0, r5, r0 - strh r2, [r0] - adds r0, r6, 0 - bl sub_80DBA68 - lsls r0, 24 - mov r8, r4 - cmp r0, 0 - bne _080DD0B4 - b _080DD3C4 -_080DD0B4: - ldr r0, [r4] - ldr r1, [r0, 0x4] - adds r1, r5, r1 - ldrh r0, [r1, 0x6] - ldr r2, =gContestMoves - lsls r0, 3 - adds r0, r2 - ldrb r2, [r0] - mov r9, r2 - ldrb r0, [r0, 0x1] - lsls r0, 29 - lsrs r0, 29 - strb r0, [r1, 0xA] - ldr r0, [r4] - ldr r0, [r0, 0x4] - adds r2, r5, r0 - ldrh r0, [r2, 0x6] - ldrh r1, [r2, 0x8] - cmp r0, r1 - bne _080DD110 - cmp r0, 0 - beq _080DD110 - ldrb r0, [r2, 0x15] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2, 0x15] - ldr r0, [r4] - ldr r2, [r0, 0x4] - adds r2, r5, r2 - ldrb r3, [r2, 0xB] - lsls r1, r3, 25 - lsrs r1, 29 - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 4 - movs r0, 0x71 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0xB] - b _080DD12C - .pool -_080DD110: - ldr r4, =gContestResources - ldr r0, [r4] - ldr r0, [r0, 0x4] - lsls r3, r6, 3 - subs r1, r3, r6 - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1, 0xB] - movs r0, 0x71 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0xB] - mov r8, r4 - adds r7, r3, 0 -_080DD12C: - mov r2, r8 - ldr r4, [r2] - ldr r2, [r4, 0x4] - subs r0, r7, r6 - lsls r0, 2 - adds r2, r0, r2 - ldr r3, =gContestEffects - mov r1, r9 - lsls r5, r1, 2 - adds r3, r5, r3 - ldrb r1, [r3, 0x1] - strh r1, [r2] - ldr r1, [r4, 0x4] - adds r0, r1 - ldrh r1, [r0] - strh r1, [r0, 0x2] - ldr r1, [r4, 0x8] - ldrb r0, [r3, 0x2] - strh r0, [r1, 0x4] - ldr r1, [r4, 0x8] - ldrh r0, [r1, 0x4] - strh r0, [r1, 0x6] - ldr r0, [r4, 0x8] - strb r6, [r0, 0x11] - movs r2, 0 - mov r9, r5 - mov r4, r8 - movs r3, 0 - movs r1, 0 -_080DD166: - ldr r0, [r4] - ldr r0, [r0, 0x4] - adds r0, r1, r0 - strb r3, [r0, 0xE] - ldr r0, [r4] - ldr r0, [r0, 0x8] - adds r0, 0xD - adds r0, r2 - strb r3, [r0] - adds r1, 0x1C - adds r2, 0x1 - cmp r2, 0x3 - ble _080DD166 - ldr r5, =gContestResources - ldr r0, [r5] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r4, r0, 2 - adds r2, r4, r1 - ldrb r1, [r2, 0x15] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080DD1B4 - ldrh r0, [r2, 0x8] - ldrh r1, [r2, 0x6] - bl AreMovesContestCombo - lsls r0, 24 - cmp r0, 0 - bne _080DD1B4 - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x15] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x15] -_080DD1B4: - ldr r0, =gContestEffectFuncs - add r0, r9 - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r0, 2 - adds r2, r0, r1 - ldrb r1, [r2, 0x10] - movs r0, 0x30 - ands r0, r1 - cmp r0, 0x10 - bne _080DD1EC - ldrh r1, [r2, 0x2] - subs r1, 0xA - movs r0, 0xD - ldrsb r0, [r2, r0] - b _080DD206 - .pool -_080DD1EC: - ldrb r1, [r2, 0x11] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080DD200 - movs r1, 0xD - ldrsb r1, [r2, r1] - lsls r0, r1, 1 - adds r0, r1 - b _080DD204 -_080DD200: - movs r0, 0xD - ldrsb r0, [r2, r0] -_080DD204: - ldrh r1, [r2, 0x2] -_080DD206: - adds r0, r1 - strh r0, [r2, 0x2] - ldr r5, =gContestResources - ldr r0, [r5] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r4, r0, 2 - adds r1, r4, r1 - movs r0, 0 - strb r0, [r1, 0x16] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x15] - movs r0, 0x41 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x15] - adds r0, r6, 0 - bl sub_80DE1E8 - lsls r0, 24 - cmp r0, 0 - beq _080DD2E2 - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrh r0, [r1, 0x8] - ldrh r1, [r1, 0x6] - bl AreMovesContestCombo - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _080DD29C - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r2, r4, r0 - ldrb r1, [r2, 0x15] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080DD29C - strb r3, [r2, 0x16] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r0, [r1, 0x15] - movs r2, 0x40 - orrs r0, r2 - strb r0, [r1, 0x15] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r2, [r1, 0x15] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x15] - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - movs r1, 0 - ldrsh r2, [r0, r1] - ldrb r1, [r0, 0x16] - muls r1, r2 - strb r1, [r0, 0x17] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r0, [r1, 0x15] - movs r2, 0x8 - b _080DD2C8 - .pool -_080DD29C: - ldr r2, =gContestMoves - ldr r5, =gContestResources - ldr r0, [r5] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r4, r0, 2 - adds r3, r4, r1 - ldrh r0, [r3, 0x6] - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x2] - cmp r0, 0 - beq _080DD2D8 - ldrb r0, [r3, 0x15] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r3, 0x15] - ldr r0, [r5] - ldr r1, [r0, 0x4] - adds r1, r4, r1 - ldrb r0, [r1, 0x15] - movs r2, 0x40 -_080DD2C8: - orrs r0, r2 - strb r0, [r1, 0x15] - b _080DD2E2 - .pool -_080DD2D8: - ldrb r1, [r3, 0x15] - movs r0, 0x11 - negs r0, r0 - ands r0, r1 - strb r0, [r3, 0x15] -_080DD2E2: - ldr r5, =gContestResources - ldr r0, [r5] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r4, r0, 2 - adds r2, r4, r1 - ldrb r1, [r2, 0x15] - movs r0, 0x1 - mov r8, r0 - ands r0, r1 - cmp r0, 0 - beq _080DD30A - ldrb r0, [r2, 0xB] - lsls r0, 25 - lsrs r0, 29 - adds r0, 0x1 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 1 - strb r1, [r2, 0x18] -_080DD30A: - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r2, r4, r0 - ldrb r1, [r2, 0xC] - mov r0, r8 - ands r0, r1 - cmp r0, 0 - beq _080DD334 - ldrb r1, [r2, 0x15] - movs r0, 0x11 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x15] - ldr r2, [r5] - ldr r0, [r2, 0x4] - adds r0, r4, r0 - movs r1, 0 - strh r1, [r0, 0x2] - ldr r0, [r2, 0x4] - adds r0, r4, r0 - strh r1, [r0] -_080DD334: - ldr r0, [r5] - ldr r0, [r0, 0x4] - adds r0, r4, r0 - ldrh r0, [r0, 0x6] - bl Contest_GetMoveExcitement - ldr r1, [r5] - ldr r1, [r1, 0x10] - strb r0, [r1] - ldr r2, [r5] - ldr r0, [r2, 0x4] - adds r0, r4, r0 - ldrb r1, [r0, 0x11] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080DD35C - ldr r0, [r2, 0x10] - mov r1, r8 - strb r1, [r0] -_080DD35C: - ldr r1, [r5] - ldr r3, [r1, 0x10] - movs r0, 0 - ldrsb r0, [r3, r0] - cmp r0, 0 - ble _080DD388 - ldr r0, [r1] - ldrb r0, [r0, 0x13] - lsls r0, 24 - asrs r0, 24 - movs r1, 0 - ldrsb r1, [r3, r1] - adds r0, r1 - cmp r0, 0x4 - ble _080DD384 - movs r0, 0x3C - b _080DD38A - .pool -_080DD384: - movs r0, 0xA - b _080DD38A -_080DD388: - movs r0, 0 -_080DD38A: - strb r0, [r3, 0x2] - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - movs r2, 0 - b _080DD3AE -_080DD3A2: - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 -_080DD3A8: - adds r2, 0x1 - cmp r2, 0x3 - bgt _080DD3B6 -_080DD3AE: - cmp r2, r6 - beq _080DD3A8 - cmp r0, 0 - bne _080DD3A2 -_080DD3B6: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x4] - subs r0, r7, r6 - lsls r0, 2 - adds r0, r1 - strb r2, [r0, 0x1B] -_080DD3C4: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD080 - - thumb_func_start SetContestantEffectStringID -SetContestantEffectStringID: @ 80DD3D4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gContestResources - ldr r2, [r2] - ldr r3, [r2, 0x4] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r2, r3 - strb r1, [r2, 0x13] - bx lr - .pool - thumb_func_end SetContestantEffectStringID - - thumb_func_start SetContestantEffectStringID2 -SetContestantEffectStringID2: @ 80DD3F0 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gContestResources - ldr r2, [r2] - ldr r3, [r2, 0x4] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r2, r3 - strb r1, [r2, 0x14] - bx lr - .pool - thumb_func_end SetContestantEffectStringID2 - - thumb_func_start SetStartledString -SetStartledString: @ 80DD40C - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r2, r1, 0 - cmp r1, 0x3B - bls _080DD426 - movs r1, 0x35 - bl SetContestantEffectStringID - b _080DD456 -_080DD426: - cmp r1, 0x27 - bls _080DD432 - movs r1, 0x34 - bl SetContestantEffectStringID - b _080DD456 -_080DD432: - cmp r1, 0x1D - bls _080DD43E - movs r1, 0x33 - bl SetContestantEffectStringID - b _080DD456 -_080DD43E: - cmp r1, 0x13 - bls _080DD44A - movs r1, 0x32 - bl SetContestantEffectStringID - b _080DD456 -_080DD44A: - cmp r2, 0x9 - bls _080DD456 - adds r0, r3, 0 - movs r1, 0x31 - bl SetContestantEffectStringID -_080DD456: - pop {r0} - bx r0 - thumb_func_end SetStartledString - - thumb_func_start sub_80DD45C -sub_80DD45C: @ 80DD45C - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r6, r1, 24 - ldr r0, =gStringVar1 - lsls r1, r4, 6 - ldr r2, =gContestMons + 2 - adds r1, r2 - bl StringCopy - ldr r0, =gStringVar2 - ldr r5, =gContestResources - ldr r1, [r5] - ldr r2, [r1, 0x4] - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 2 - adds r1, r2 - ldrh r2, [r1, 0x6] - movs r1, 0xD - muls r1, r2 - ldr r2, =gMoveNames - adds r1, r2 - bl StringCopy - ldr r3, =gContestMoves - ldr r1, [r5] - ldr r0, [r1, 0x8] - ldrb r2, [r0, 0x11] - ldr r1, [r1, 0x4] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0, 0x6] - lsls r0, 3 - adds r0, r3 - ldrb r0, [r0, 0x1] - lsls r1, r0, 29 - cmp r1, 0 - bne _080DD4DC - ldr r0, =gStringVar3 - ldr r1, =gText_0827E837 - bl StringCopy - b _080DD52C - .pool -_080DD4DC: - lsrs r0, r1, 29 - cmp r0, 0x1 - bne _080DD4F4 - ldr r0, =gStringVar3 - ldr r1, =gText_0827E83F - bl StringCopy - b _080DD52C - .pool -_080DD4F4: - lsrs r0, r1, 29 - cmp r0, 0x2 - bne _080DD50C - ldr r0, =gStringVar3 - ldr r1, =gText_0827E847 - bl StringCopy - b _080DD52C - .pool -_080DD50C: - lsrs r0, r1, 29 - cmp r0, 0x3 - bne _080DD524 - ldr r0, =gStringVar3 - ldr r1, =gText_0827E850 - bl StringCopy - b _080DD52C - .pool -_080DD524: - ldr r0, =gStringVar3 - ldr r1, =gText_0827E85A - bl StringCopy -_080DD52C: - ldr r4, =gStringVar4 - ldr r1, =gUnknown_08587E10 - lsls r0, r6, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl StringExpandPlaceholders - bl sub_80DB89C - adds r0, r4, 0 - movs r1, 0x1 - bl Contest_StartTextPrinter - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD45C - - thumb_func_start MakeContestantNervous -MakeContestantNervous: @ 80DD560 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gContestResources - ldr r1, [r4] - ldr r3, [r1, 0x4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r3, r1, r3 - ldrb r0, [r3, 0xC] - movs r2, 0x1 - orrs r0, r2 - strb r0, [r3, 0xC] - ldr r0, [r4] - ldr r0, [r0, 0x4] - adds r1, r0 - movs r0, 0 - strh r0, [r1, 0x6] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end MakeContestantNervous - - thumb_func_start sub_80DD590 -sub_80DD590: @ 80DD590 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - movs r0, 0 - mov r12, r0 - movs r4, 0 - ldr r1, =gUnknown_02039F26 - mov r9, r1 - add r2, sp, 0x4 - mov r6, r9 - movs r5, 0 - adds r3, r2, 0 -_080DD5AC: - mov r0, sp - adds r1, r0, r4 - adds r0, r4, r6 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r3, r4 - strb r5, [r0] - adds r4, 0x1 - cmp r4, 0x3 - ble _080DD5AC - movs r4, 0 - ldr r7, =gContestResources - ldr r1, [r7] - mov r8, r1 - adds r5, r2, 0 -_080DD5CA: - movs r2, 0 - mov r0, r8 - ldr r1, [r0, 0x4] -_080DD5D0: - ldrb r0, [r1, 0x19] - cmp r0, r4 - beq _080DD604 - adds r1, 0x1C - adds r2, 0x1 - cmp r2, 0x3 - ble _080DD5D0 -_080DD5DE: - cmp r2, 0x4 - bne _080DD684 - movs r2, 0 - ldrb r0, [r5] - cmp r0, 0 - bne _080DD612 - ldr r0, [r7] - ldr r0, [r0, 0x4] - ldrb r0, [r0, 0x19] - cmp r0, 0xFF - bne _080DD612 - mov r12, r2 - movs r2, 0x1 - b _080DD63A - .pool -_080DD604: - mov r1, sp - adds r0, r1, r2 - strb r4, [r0] - adds r1, r5, r2 - movs r0, 0x1 - strb r0, [r1] - b _080DD5DE -_080DD612: - adds r2, 0x1 - cmp r2, 0x3 - bgt _080DD676 - adds r0, r5, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _080DD612 - ldr r0, [r7] - ldr r1, [r0, 0x4] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x19] - cmp r0, 0xFF - bne _080DD612 - lsls r0, r2, 24 - lsrs r0, 24 - mov r12, r0 - adds r2, 0x1 -_080DD63A: - cmp r2, 0x3 - bgt _080DD676 - ldr r6, =gUnknown_02039F26 - lsls r0, r2, 3 - subs r0, r2 - lsls r3, r0, 2 -_080DD646: - adds r0, r5, r2 - ldrb r0, [r0] - cmp r0, 0 - bne _080DD66E - ldr r0, [r7] - ldr r0, [r0, 0x4] - adds r0, r3, r0 - ldrb r0, [r0, 0x19] - cmp r0, 0xFF - bne _080DD66E - mov r1, r12 - adds r0, r1, r6 - adds r1, r2, r6 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bls _080DD66E - lsls r0, r2, 24 - lsrs r0, 24 - mov r12, r0 -_080DD66E: - adds r3, 0x1C - adds r2, 0x1 - cmp r2, 0x3 - ble _080DD646 -_080DD676: - mov r0, sp - add r0, r12 - strb r4, [r0] - mov r0, r12 - adds r1, r5, r0 - movs r0, 0x1 - strb r0, [r1] -_080DD684: - adds r4, 0x1 - cmp r4, 0x3 - ble _080DD5CA - movs r4, 0 - ldr r6, =gContestResources - movs r5, 0 -_080DD690: - ldr r0, [r6] - ldr r1, [r0, 0x8] - adds r1, r4 - mov r0, sp - adds r3, r0, r4 - ldrb r0, [r3] - strb r0, [r1] - ldr r0, [r6] - ldr r0, [r0, 0x4] - adds r0, r5, r0 - movs r1, 0xFF - strb r1, [r0, 0x19] - ldr r0, [r6] - ldr r1, [r0, 0x4] - adds r1, r5, r1 - ldrb r2, [r1, 0x10] - movs r0, 0x3F - ands r0, r2 - strb r0, [r1, 0x10] - mov r0, r9 - adds r1, r4, r0 - ldrb r0, [r3] - strb r0, [r1] - adds r5, 0x1C - adds r4, 0x1 - cmp r4, 0x3 - ble _080DD690 - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD590 - - thumb_func_start sub_80DD6DC -sub_80DD6DC: @ 80DD6DC - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x30] - adds r1, r0, 0x1 - strh r1, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x54 - ble _080DD712 - movs r0, 0 - strh r0, [r2, 0x30] - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r3] - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r1, [r2, 0x6] - movs r0, 0x11 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x6] -_080DD712: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD6DC - - thumb_func_start sub_80DD720 -sub_80DD720: @ 80DD720 - push {r4,r5,lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - ldrb r5, [r0, 0x12] - cmp r1, 0x8 - bls _080DD734 - b _080DD8D4 -_080DD734: - lsls r0, r1, 2 - ldr r1, =_080DD748 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080DD748: - .4byte _080DD76C - .4byte _080DD76C - .4byte _080DD79C - .4byte _080DD7D0 - .4byte _080DD804 - .4byte _080DD838 - .4byte _080DD86C - .4byte _080DD8D4 - .4byte _080DD8A0 -_080DD76C: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x2E] - ldr r2, =0x000003ff - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x20 - bl PlaySE - b _080DD8F8 - .pool -_080DD79C: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0x4 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x1F - bl PlaySE - b _080DD8F8 - .pool -_080DD7D0: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0x8 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x1F - bl PlaySE - b _080DD8F8 - .pool -_080DD804: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0xC - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x2D - bl PlaySE - b _080DD8F8 - .pool -_080DD838: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0xC - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x2D - bl PlaySE - b _080DD8F8 - .pool -_080DD86C: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0x10 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x2D - bl PlaySE - b _080DD8F8 - .pool -_080DD8A0: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0x18 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0xC3 - bl PlaySE - b _080DD8F8 - .pool -_080DD8D4: - ldr r0, =gSprites - lsls r4, r5, 4 - adds r1, r4, r5 - lsls r1, 2 - adds r1, r0 - ldrh r2, [r1, 0x2E] - adds r2, 0x14 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r2, r0 - ldrh r3, [r1, 0x4] - ldr r0, =0xfffffc00 - ands r0, r3 - orrs r0, r2 - strh r0, [r1, 0x4] - movs r0, 0x2D - bl PlaySE -_080DD8F8: - adds r2, r4, 0 - ldr r4, =gSprites - adds r2, r5 - lsls r2, 2 - adds r1, r2, r4 - movs r0, 0 - strh r0, [r1, 0x30] - adds r1, 0x3E - ldrb r3, [r1] - subs r0, 0x5 - ands r0, r3 - strb r0, [r1] - adds r4, 0x1C - adds r2, r4 - ldr r0, =sub_80DD6DC - str r0, [r2] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r0, [r2, 0x6] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r2, 0x6] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD720 - - thumb_func_start sub_80DD940 -sub_80DD940: @ 80DD940 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r5, 0 - ldr r6, =gContestResources - ldr r0, =gSprites - mov r9, r0 - ldr r0, =0x06010000 - mov r8, r0 - ldr r7, =0x04000008 -_080DD956: - ldr r0, [r6] - ldr r1, [r0] - movs r0, 0x13 - ldrsb r0, [r1, r0] - ldr r4, =gContestApplauseMeterGfx - cmp r5, r0 - bge _080DD966 - adds r4, 0x40 -_080DD966: - adds r0, r1, 0 - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - ldrh r1, [r0, 0x4] - lsls r1, 22 - lsrs r1, 22 - adds r0, r5, 0 - adds r0, 0x11 - adds r1, r0 - lsls r1, 5 - add r1, r8 - adds r0, r4, 0 - adds r2, r7, 0 - bl CpuSet - adds r0, r4, 0 - adds r0, 0x20 - ldr r1, [r6] - ldr r1, [r1] - adds r1, 0x58 - ldrb r2, [r1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - add r1, r9 - ldrh r1, [r1, 0x4] - lsls r1, 22 - lsrs r1, 22 - adds r2, r5, 0 - adds r2, 0x19 - adds r1, r2 - lsls r1, 5 - add r1, r8 - adds r2, r7, 0 - bl CpuSet - ldr r0, [r6] - ldr r0, [r0] - ldrb r0, [r0, 0x13] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x4 - ble _080DD9C8 - bl sub_80DDA20 -_080DD9C8: - adds r5, 0x1 - cmp r5, 0x4 - ble _080DD956 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DD940 - - thumb_func_start Contest_GetMoveExcitement -Contest_GetMoveExcitement: @ 80DD9F0 - lsls r0, 16 - ldr r3, =gUnknown_085899EC - ldr r1, =gContestMoves - lsrs r0, 13 - adds r0, r1 - ldrb r1, [r0, 0x1] - lsls r1, 29 - lsrs r1, 29 - ldr r0, =gSpecialVar_ContestCategory - ldrh r2, [r0] - lsls r0, r2, 2 - adds r0, r2 - adds r1, r0 - adds r1, r3 - movs r0, 0 - ldrsb r0, [r1, r0] - bx lr - .pool - thumb_func_end Contest_GetMoveExcitement - - thumb_func_start sub_80DDA20 -sub_80DDA20: @ 80DDA20 - push {r4,r5,lr} - ldr r0, =c3_08130B10 - movs r1, 0xA - bl CreateTask - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - movs r0, 0x1 - strh r0, [r4, 0xA] - ldr r0, =0x0000abe2 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0xC] - adds r0, r5, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DDA20 - - thumb_func_start c3_08130B10 -c3_08130B10: @ 80DDA60 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r2, r0, r1 - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - bne _080DDAFE - movs r0, 0 - strh r0, [r2, 0x8] - movs r3, 0xE - ldrsh r0, [r2, r3] - cmp r0, 0 - bne _080DDA94 - ldrh r0, [r2, 0x10] - adds r0, 0x1 - b _080DDA98 - .pool -_080DDA94: - ldrh r0, [r2, 0x10] - subs r0, 0x1 -_080DDA98: - strh r0, [r2, 0x10] - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0xC - ldrsh r0, [r4, r1] - lsls r0, 4 - movs r3, 0x84 - lsls r3, 1 - adds r6, r3, 0 - adds r0, r6 - lsls r0, 16 - lsrs r0, 16 - ldrb r2, [r4, 0x10] - ldr r3, =0x00007fff - movs r1, 0x1 - bl BlendPalette - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080DDACA - cmp r0, 0x10 - bne _080DDAFE -_080DDACA: - ldrh r0, [r4, 0xE] - movs r1, 0x1 - eors r0, r1 - strh r0, [r4, 0xE] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - ldrb r0, [r0, 0x13] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x4 - bgt _080DDAFE - movs r3, 0xC - ldrsh r0, [r4, r3] - lsls r0, 4 - adds r0, r6 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1F - bl BlendPalette - adds r0, r5, 0 - bl DestroyTask -_080DDAFE: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end c3_08130B10 - - thumb_func_start sub_80DDB0C -sub_80DDB0C: @ 80DDB0C - push {r4,lr} - ldr r0, =sub_80DDB6C - movs r1, 0xA - bl CreateTask - ldr r3, =gSprites - ldr r4, =gContestResources - ldr r2, [r4] - ldr r0, [r2] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldr r1, =0x0000ffba - strh r1, [r0, 0x24] - ldr r0, [r2] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - ldr r0, [r4] - ldr r2, [r0] - ldrb r0, [r2, 0x6] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2, 0x6] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDB0C - - thumb_func_start sub_80DDB6C -sub_80DDB6C: @ 80DDB6C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - ldr r4, =gContestResources - ldr r0, [r4] - ldr r0, [r0] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r2, r0, r1 - ldr r0, =gTasks - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 3 - adds r1, r0 - movs r5, 0xD0 - lsls r5, 3 - adds r0, r5, 0 - ldrh r5, [r1, 0x1C] - adds r0, r5 - strh r0, [r1, 0x1C] - lsls r0, 16 - asrs r0, 24 - ldrh r5, [r2, 0x24] - adds r0, r5 - strh r0, [r2, 0x24] - ldrb r0, [r1, 0x1C] - strh r0, [r1, 0x1C] - movs r1, 0x24 - ldrsh r0, [r2, r1] - cmp r0, 0 - ble _080DDBB8 - movs r0, 0 - strh r0, [r2, 0x24] -_080DDBB8: - movs r5, 0x24 - ldrsh r0, [r2, r5] - cmp r0, 0 - bne _080DDBD4 - ldr r0, [r4] - ldr r2, [r0] - ldrb r1, [r2, 0x6] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x6] - adds r0, r3, 0 - bl DestroyTask -_080DDBD4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDB6C - - thumb_func_start sub_80DDBE8 -sub_80DDBE8: @ 80DDBE8 - push {r4,r5,lr} - ldr r5, =gSprites - ldr r4, =gContestResources - ldr r0, [r4] - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - bge _080DDC1C - ldrb r1, [r2, 0x6] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - b _080DDC40 - .pool -_080DDC1C: - ldr r0, =task08_080CD1CC - movs r1, 0xA - bl CreateTask - ldr r2, [r4] - ldr r0, [r2] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0 - strh r1, [r0, 0x24] - ldr r2, [r2] - ldrb r0, [r2, 0x6] - movs r1, 0x40 - orrs r0, r1 -_080DDC40: - strb r0, [r2, 0x6] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDBE8 - - thumb_func_start task08_080CD1CC -task08_080CD1CC: @ 80DDC4C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - ldr r5, =gContestResources - ldr r0, [r5] - ldr r0, [r0] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r3, r0, r1 - ldr r0, =gTasks - lsls r2, r4, 2 - adds r2, r4 - lsls r2, 3 - adds r2, r0 - movs r1, 0xD0 - lsls r1, 3 - adds r0, r1, 0 - ldrh r1, [r2, 0x1C] - adds r0, r1 - strh r0, [r2, 0x1C] - lsls r0, 16 - asrs r0, 24 - ldrh r1, [r3, 0x24] - subs r1, r0 - strh r1, [r3, 0x24] - ldrb r0, [r2, 0x1C] - strh r0, [r2, 0x1C] - movs r2, 0x24 - ldrsh r0, [r3, r2] - movs r1, 0x46 - negs r1, r1 - cmp r0, r1 - bge _080DDC9C - ldr r0, =0x0000ffba - strh r0, [r3, 0x24] -_080DDC9C: - movs r2, 0x24 - ldrsh r0, [r3, r2] - cmp r0, r1 - bne _080DDCC4 - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, [r5] - ldr r2, [r0] - ldrb r1, [r2, 0x6] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x6] - adds r0, r4, 0 - bl DestroyTask -_080DDCC4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task08_080CD1CC - - thumb_func_start sub_80DDCDC -sub_80DDCDC: @ 80DDCDC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80DDD20 - movs r1, 0x5 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0x8] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r0, [r2, 0x6] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2, 0x6] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDCDC - - thumb_func_start sub_80DDD20 -sub_80DDD20: @ 80DDD20 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x1C - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _080DDD54 - cmp r0, 0x1 - bgt _080DDD48 - cmp r0, 0 - beq _080DDD4E - b _080DDD9C - .pool -_080DDD48: - cmp r0, 0x2 - beq _080DDD70 - b _080DDD9C -_080DDD4E: - bl sub_80DDB0C - b _080DDD64 -_080DDD54: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - ldrb r1, [r0, 0x6] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - bne _080DDD9C -_080DDD64: - ldrh r0, [r4, 0x1C] - adds r0, 0x1 - strh r0, [r4, 0x1C] - b _080DDD9C - .pool -_080DDD70: - ldrh r0, [r4, 0x1E] - adds r1, r0, 0x1 - strh r1, [r4, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - ble _080DDD9C - movs r0, 0 - strh r0, [r4, 0x1E] - bl sub_80DD940 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r1, [r2, 0x6] - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x6] - adds r0, r5, 0 - bl DestroyTask -_080DDD9C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDD20 - - thumb_func_start sub_80DDDA8 -sub_80DDDA8: @ 80DDDA8 - ldr r3, =gSprites - ldr r0, =gContestResources - ldr r2, [r0] - ldr r0, [r2] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0 - strh r1, [r0, 0x24] - ldr r0, [r2] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_80DDDA8 - - thumb_func_start sub_80DDDE4 -sub_80DDDE4: @ 80DDDE4 - ldr r2, =gSprites - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - adds r0, 0x58 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_80DDDE4 - - thumb_func_start sub_80DDE0C -sub_80DDE0C: @ 80DDE0C - push {lr} - ldr r0, =sub_80DDE30 - movs r1, 0xF - bl CreateTask - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r0, [r2, 0x6] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x6] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDE0C - - thumb_func_start sub_80DDE30 -sub_80DDE30: @ 80DDE30 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - ldrh r0, [r4, 0x1C] - adds r1, r0, 0x1 - strh r1, [r4, 0x1C] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x6 - ble _080DDEBA - movs r0, 0 - strh r0, [r4, 0x1C] - movs r1, 0x1E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080DDE78 - ldr r0, =gHeap+0x19000 - ldr r1, =0x06002000 - movs r2, 0x80 - lsls r2, 5 - movs r3, 0x1 - bl RequestDma3Copy - b _080DDE8C - .pool -_080DDE78: - ldr r0, =gHeap+0x18000 - ldr r1, =0x06002000 - movs r2, 0x80 - lsls r2, 5 - movs r3, 0x1 - bl RequestDma3Copy - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] -_080DDE8C: - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x1E] - movs r2, 0x1 - eors r1, r2 - strh r1, [r0, 0x1E] - movs r1, 0x20 - ldrsh r0, [r0, r1] - cmp r0, 0x9 - bne _080DDEBA - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r1, [r2, 0x6] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x6] - adds r0, r5, 0 - bl DestroyTask -_080DDEBA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDE30 - - thumb_func_start sub_80DDED0 -sub_80DDED0: @ 80DDED0 - push {r4-r7,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r5, r1, 24 - ldr r0, =sub_80DDF80 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r6, r0, 24 - lsls r4, 24 - cmp r4, 0 - ble _080DDF38 - ldr r7, =0x0000237e - lsls r0, r5, 24 - adds r4, r0, 0 - cmp r4, 0 - ble _080DDF1C - movs r5, 0 - ldr r2, =gContestResources - ldr r0, [r2] - ldr r0, [r0] - movs r1, 0x13 - ldrsb r1, [r0, r1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 24 - lsrs r3, r0, 24 - b _080DDF4E - .pool -_080DDF1C: - ldr r2, =gContestResources - ldr r0, [r2] - ldr r0, [r0] - movs r1, 0x13 - ldrsb r1, [r0, r1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - movs r3, 0 - b _080DDF4E - .pool -_080DDF38: - movs r7, 0 - lsls r0, r5, 24 - adds r4, r0, 0 - cmp r4, 0 - ble _080DDF48 - movs r5, 0 - movs r3, 0xC - b _080DDF4C -_080DDF48: - movs r5, 0xC - movs r3, 0 -_080DDF4C: - ldr r2, =gContestResources -_080DDF4E: - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - strh r7, [r0, 0x8] - strh r5, [r0, 0xA] - asrs r1, r4, 24 - strh r1, [r0, 0xC] - strh r3, [r0, 0xE] - ldr r0, [r2] - ldr r2, [r0] - ldrb r1, [r2, 0x7] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x7] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDED0 - - thumb_func_start sub_80DDF80 -sub_80DDF80: @ 80DDF80 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r3, r0, r2 - ldrh r0, [r3, 0x1C] - adds r1, r0, 0x1 - strh r1, [r3, 0x1C] - lsls r0, 16 - cmp r0, 0 - blt _080DDFFC - movs r0, 0 - strh r0, [r3, 0x1C] - movs r1, 0xC - ldrsh r0, [r3, r1] - cmp r0, 0 - ble _080DDFB4 - ldrh r0, [r3, 0xA] - adds r0, 0x1 - b _080DDFB8 - .pool -_080DDFB4: - ldrh r0, [r3, 0xA] - subs r0, 0x1 -_080DDFB8: - strh r0, [r3, 0xA] - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r2 - ldrb r2, [r4, 0xA] - ldrh r3, [r4, 0x8] - movs r0, 0x11 - movs r1, 0x1 - bl BlendPalette - ldrb r2, [r4, 0xA] - ldrh r3, [r4, 0x8] - movs r0, 0x1A - movs r1, 0x1 - bl BlendPalette - movs r2, 0xA - ldrsh r1, [r4, r2] - movs r2, 0xE - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _080DDFFC - adds r0, r5, 0 - bl DestroyTask - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r1, [r2, 0x7] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x7] -_080DDFFC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DDF80 - - thumb_func_start sub_80DE008 -sub_80DE008: @ 80DE008 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - movs r5, 0 - ldr r0, =gContestResources - mov r9, r0 - mov r8, r9 - ldr r6, =gSprites - movs r4, 0 - movs r7, 0 -_080DE026: - mov r1, r8 - ldr r0, [r1] - ldr r0, [r0, 0x4] - adds r0, r7, r0 - ldrb r1, [r0, 0x10] - movs r0, 0xC0 - ands r0, r1 - cmp r0, 0 - beq _080DE0BC - mov r2, r10 - cmp r2, 0 - beq _080DE0BC - lsls r0, r5, 24 - lsrs r0, 24 - bl sub_80DE0F0 - mov r3, r8 - ldr r1, [r3] - ldr r1, [r1, 0x14] - adds r1, r4, r1 - ldrb r2, [r1, 0x1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r6 - ldrh r1, [r1, 0x4] - lsls r1, 22 - lsrs r1, 17 - ldr r2, =0x060100c0 - adds r1, r2 - ldr r2, =0x04000008 - bl CpuSet - mov r0, r8 - ldr r3, [r0] - ldr r0, [r3, 0x14] - adds r0, r4, r0 - ldrb r0, [r0, 0x1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldr r2, =gUnknown_08587A70 - ldr r0, =gUnknown_02039F26 - adds r0, r5, r0 - ldrb r0, [r0] - adds r0, r2 - ldrb r0, [r0] - strh r0, [r1, 0x22] - ldr r0, [r3, 0x14] - adds r0, r4, r0 - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r3, 0x5 - negs r3, r3 - adds r2, r3, 0 - ands r1, r2 - b _080DE0D6 - .pool -_080DE0BC: - mov r1, r9 - ldr r0, [r1] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0, 0x1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 -_080DE0D6: - strb r1, [r0] - adds r4, 0x4 - adds r7, 0x1C - adds r5, 0x1 - cmp r5, 0x3 - ble _080DE026 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80DE008 - - thumb_func_start sub_80DE0F0 -sub_80DE0F0: @ 80DE0F0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r2, [r1, 0x4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, r1, r2 - ldrb r1, [r2, 0x10] - movs r0, 0xC0 - ands r0, r1 - cmp r0, 0x40 - bne _080DE120 - ldrb r0, [r2, 0x19] - lsls r0, 5 - ldr r1, =gUnknown_08D8E9B4 - adds r0, r1 - b _080DE122 - .pool -_080DE120: - ldr r0, =gUnknown_08D8EA34 -_080DE122: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DE0F0 - - thumb_func_start sub_80DE12C -sub_80DE12C: @ 80DE12C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - movs r7, 0 - movs r0, 0x2 - mov r10, r0 - movs r0, 0x1 - mov r8, r0 - movs r0, 0x11 - mov r9, r0 -_080DE146: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x8] - adds r0, 0xD - adds r0, r7 - ldrb r0, [r0] - cmp r0, 0 - beq _080DE1CA - lsls r0, r7, 24 - lsrs r0, 24 - bl Contest_IsMonsTurnDisabled - lsls r0, 24 - cmp r0, 0 - bne _080DE1CA - ldr r0, =gUnknown_02039F26 - adds r0, r7, r0 - ldrb r0, [r0] - lsls r5, r0, 2 - adds r5, r0 - adds r6, r5, 0x2 - movs r0, 0x3 - bl sub_80DB748 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r6, 24 - lsrs r6, 24 - mov r0, r10 - str r0, [sp] - mov r0, r8 - str r0, [sp, 0x4] - mov r0, r9 - str r0, [sp, 0x8] - mov r0, r8 - str r0, [sp, 0xC] - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x14 - adds r3, r6, 0 - bl ContestBG_FillBoxWithIncrementingTile - adds r4, 0x10 - lsls r4, 16 - lsrs r4, 16 - adds r5, 0x3 - lsls r5, 24 - lsrs r5, 24 - mov r0, r10 - str r0, [sp] - mov r0, r8 - str r0, [sp, 0x4] - mov r0, r9 - str r0, [sp, 0x8] - mov r0, r8 - str r0, [sp, 0xC] - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x14 - adds r3, r5, 0 - bl ContestBG_FillBoxWithIncrementingTile - movs r0, 0x63 - bl PlaySE -_080DE1CA: - adds r7, 0x1 - cmp r7, 0x3 - ble _080DE146 - 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_80DE12C - - thumb_func_start sub_80DE1E8 -sub_80DE1E8: @ 80DE1E8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gContestResources - ldr r1, [r1] - ldr r2, [r1, 0x4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, r1, r2 - ldrb r1, [r2, 0x15] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _080DE212 - ldrb r1, [r2, 0xC] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _080DE21C -_080DE212: - movs r0, 0 - b _080DE21E - .pool -_080DE21C: - movs r0, 0x1 -_080DE21E: - pop {r1} - bx r1 - thumb_func_end sub_80DE1E8 - - thumb_func_start sub_80DE224 -sub_80DE224: @ 80DE224 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - movs r0, 0xA - bl GetGpuReg - mov r1, sp - strh r0, [r1] - mov r2, sp - ldrb r1, [r2] - movs r4, 0x4 - negs r4, r4 - adds r0, r4, 0 - ands r0, r1 - strb r0, [r2] - ldrb r1, [r2, 0x1] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x1] - ldrb r1, [r2, 0x1] - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x1] - ldrb r1, [r2] - movs r0, 0xD - negs r0, r0 - mov r8, r0 - ands r0, r1 - strb r0, [r2] - mov r0, sp - ldrh r1, [r0] - movs r0, 0xA - bl SetGpuReg - movs r0, 0x8 - bl GetGpuReg - mov r6, sp - adds r6, 0x2 - strh r0, [r6] - movs r0, 0xC - bl GetGpuReg - add r5, sp, 0x4 - strh r0, [r5] - ldrb r1, [r6] - adds r0, r4, 0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r6] - ldrb r0, [r5] - ands r4, r0 - orrs r4, r1 - strb r4, [r5] - ldrh r1, [r6] - movs r0, 0x8 - bl SetGpuReg - ldrh r1, [r5] - movs r0, 0xC - bl SetGpuReg - ldr r1, =gBattle_BG1_X - movs r0, 0xF0 - strh r0, [r1] - ldr r4, =gBattle_BG1_Y - movs r0, 0xA0 - strh r0, [r4] - movs r0, 0x14 - movs r1, 0xF0 - bl SetGpuReg - ldrh r1, [r4] - movs r0, 0x16 - bl SetGpuReg - movs r0, 0 - str r0, [sp, 0x8] - add r0, sp, 0x8 - ldr r4, =gContestResources - ldr r1, [r4] - ldr r1, [r1, 0x28] - ldr r2, =0x05000400 - bl CpuSet - ldr r1, =gUnknown_08C17980 - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - movs r0, 0x1 - bl Contest_SetBgCopyFlags - movs r5, 0 - ldr r7, =gSprites - movs r6, 0x4 -_080DE2F0: - ldr r0, [r4] - ldr r0, [r0, 0x14] - lsls r3, r5, 2 - adds r0, r3, r0 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - mov r0, r8 - ands r0, r2 - orrs r0, r6 - strb r0, [r1, 0x5] - ldr r0, [r4] - ldr r0, [r0, 0x14] - adds r3, r0 - ldrb r0, [r3, 0x1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - mov r0, r8 - ands r0, r2 - orrs r0, r6 - strb r0, [r1, 0x5] - adds r5, 0x1 - cmp r5, 0x3 - ble _080DE2F0 - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE224 - - thumb_func_start sub_80DE350 -sub_80DE350: @ 80DE350 - push {r4-r7,lr} - sub sp, 0x8 - ldr r1, =0x06008000 - movs r2, 0x80 - lsls r2, 6 - movs r0, 0 - movs r3, 0x1 - bl RequestDma3Fill - movs r5, 0 - str r5, [sp] - ldr r6, =gContestResources - ldr r0, [r6] - ldr r1, [r0, 0x28] - ldr r2, =0x05000400 - mov r0, sp - bl CpuSet - movs r0, 0x1 - bl Contest_SetBgCopyFlags - movs r0, 0xA - bl GetGpuReg - add r3, sp, 0x4 - strh r0, [r3] - ldrb r1, [r3] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r3] - mov r1, sp - adds r1, 0x5 - ldrb r2, [r1] - movs r0, 0x3F - ands r0, r2 - strb r0, [r1] - ldrb r2, [r1] - movs r0, 0x21 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrb r1, [r3] - movs r4, 0xD - negs r4, r4 - adds r0, r4, 0 - ands r0, r1 - movs r1, 0x8 - orrs r0, r1 - strb r0, [r3] - ldrh r1, [r3] - movs r0, 0xA - bl SetGpuReg - ldr r0, =gBattle_BG1_X - strh r5, [r0] - ldr r0, =gBattle_BG1_Y - strh r5, [r0] - ldr r7, =gSprites -_080DE3CA: - ldr r0, [r6] - ldr r0, [r0, 0x14] - lsls r3, r5, 2 - adds r0, r3, r0 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - adds r0, r4, 0 - ands r0, r2 - strb r0, [r1, 0x5] - ldr r0, [r6] - ldr r0, [r0, 0x14] - adds r3, r0 - ldrb r0, [r3, 0x1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - adds r0, r4, 0 - ands r0, r2 - strb r0, [r1, 0x5] - adds r5, 0x1 - cmp r5, 0x3 - ble _080DE3CA - add sp, 0x8 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE350 - - thumb_func_start sub_80DE424 -sub_80DE424: @ 80DE424 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gBattle_BG1_X - movs r0, 0 - strh r0, [r1] - ldr r1, =gBattle_BG1_Y - movs r0, 0xA0 - strh r0, [r1] - movs r0, 0x62 - movs r1, 0 - bl PlaySE12WithPanning - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80DE464 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE424 - - thumb_func_start sub_80DE464 -sub_80DE464: @ 80DE464 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r1, =gBattle_BG1_Y - ldrh r0, [r1] - subs r0, 0x7 - strh r0, [r1] - lsls r0, 16 - cmp r0, 0 - bge _080DE47C - movs r0, 0 - strh r0, [r1] -_080DE47C: - ldrh r2, [r1] - cmp r2, 0 - bne _080DE496 - ldr r0, =gTasks - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 3 - adds r1, r0 - strh r2, [r1, 0x8] - strh r2, [r1, 0xA] - strh r2, [r1, 0xC] - ldr r0, =sub_80DE4A8 - str r0, [r1] -_080DE496: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE464 - - thumb_func_start sub_80DE4A8 -sub_80DE4A8: @ 80DE4A8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r3, r4, 2 - adds r0, r3, r4 - lsls r0, 3 - adds r5, r0, r1 - movs r0, 0x8 - ldrsh r1, [r5, r0] - cmp r1, 0x1 - beq _080DE52C - cmp r1, 0x1 - bgt _080DE4D0 - cmp r1, 0 - beq _080DE4DA - b _080DE5B4 - .pool -_080DE4D0: - cmp r1, 0x2 - beq _080DE58A - cmp r1, 0x3 - beq _080DE5A4 - b _080DE5B4 -_080DE4DA: - movs r2, 0 - adds r6, r3, 0 - ldr r5, =gContestResources - ldr r3, =gUnknown_02039F26 -_080DE4E2: - ldr r0, [r5] - ldr r1, [r0] - adds r1, 0x14 - adds r1, r2 - adds r0, r2, r3 - ldrb r0, [r0] - strb r0, [r1] - adds r2, 0x1 - cmp r2, 0x3 - ble _080DE4E2 - bl sub_80DBF90 - bl sub_80DC864 - bl sub_80DB69C - bl sub_80DD04C - movs r0, 0x1 - bl sub_80DE008 - bl sub_80DC44C - ldr r0, =gTasks - adds r1, r6, r4 - lsls r1, 3 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0x8] - b _080DE5B4 - .pool -_080DE52C: - ldr r0, =gIsLinkContest - ldrb r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _080DE584 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r0, [r2, 0x7] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2, 0x7] - bl sub_80DA8A4 - lsls r0, 24 - cmp r0, 0 - beq _080DE552 - bl sub_80DBAA0 -_080DE552: - ldr r4, =sub_80FCC88 - adds r0, r4, 0 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =sub_80DA110 - adds r1, r4, 0 - bl SetTaskFuncWithFollowupFunc - bl sub_80DBF68 - movs r0, 0x2 - strh r0, [r5, 0x8] - b _080DE5B4 - .pool -_080DE584: - bl sub_80DBAA0 - b _080DE59A -_080DE58A: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - ldrb r1, [r0, 0x7] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _080DE5B4 -_080DE59A: - movs r0, 0x3 - strh r0, [r5, 0x8] - b _080DE5B4 - .pool -_080DE5A4: - bl sub_80DB884 - bl sub_80DB2BC - movs r0, 0 - strh r0, [r5, 0x8] - ldr r0, =sub_80DE5F4 - str r0, [r5] -_080DE5B4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE4A8 - - thumb_func_start sub_80DE5C0 -sub_80DE5C0: @ 80DE5C0 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gBattle_BG1_Y - ldrh r0, [r1] - adds r0, 0x7 - strh r0, [r1] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA0 - ble _080DE5E4 - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80DA4F4 - str r0, [r1] -_080DE5E4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE5C0 - - thumb_func_start sub_80DE5F4 -sub_80DE5F4: @ 80DE5F4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r2, [r1, 0xC] - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0x9 - bgt _080DE618 - adds r0, r2, 0x1 - strh r0, [r1, 0xC] - b _080DE654 - .pool -_080DE618: - ldrh r3, [r1, 0xA] - movs r4, 0xA - ldrsh r0, [r1, r4] - cmp r0, 0 - bne _080DE636 - ldrh r2, [r1, 0x8] - movs r4, 0x8 - ldrsh r0, [r1, r4] - cmp r0, 0x10 - bne _080DE632 - adds r0, r3, 0x1 - strh r0, [r1, 0xA] - b _080DE654 -_080DE632: - adds r0, r2, 0x1 - b _080DE652 -_080DE636: - ldrh r0, [r1, 0x8] - movs r3, 0x8 - ldrsh r2, [r1, r3] - cmp r2, 0 - bne _080DE650 - strh r2, [r1, 0xA] - strh r2, [r1, 0xC] - ldr r0, =sub_80DE65C - str r0, [r1] - b _080DE654 - .pool -_080DE650: - subs r0, 0x1 -_080DE652: - strh r0, [r1, 0x8] -_080DE654: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DE5F4 - - thumb_func_start sub_80DE65C -sub_80DE65C: @ 80DE65C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - ldrh r1, [r4, 0xC] - movs r2, 0xC - ldrsh r0, [r4, r2] - cmp r0, 0x9 - bgt _080DE680 - adds r0, r1, 0x1 - strh r0, [r4, 0xC] - b _080DE690 - .pool -_080DE680: - movs r0, 0 - strh r0, [r4, 0xC] - movs r0, 0x61 - movs r1, 0 - bl PlaySE12WithPanning - ldr r0, =sub_80DE5C0 - str r0, [r4] -_080DE690: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE65C - - thumb_func_start sub_80DE69C -sub_80DE69C: @ 80DE69C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r7, 0 - ldr r6, =gSprites - ldr r5, =gContestResources -_080DE6AE: - bl AllocOamMatrix - ldr r1, [r5] - ldr r1, [r1, 0x14] - lsls r4, r7, 2 - adds r1, r4, r1 - ldrb r1, [r1] - lsls r3, r1, 4 - adds r3, r1 - lsls r3, 2 - adds r3, r6 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1F - ands r0, r1 - lsls r0, 1 - ldrb r1, [r3, 0x3] - movs r2, 0x3F - negs r2, r2 - mov r12, r2 - mov r2, r12 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0x3] - ldr r0, [r5] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r2, [r0, 0x1] - movs r3, 0x4 - negs r3, r3 - adds r1, r3, 0 - ands r2, r1 - movs r1, 0x1 - orrs r2, r1 - strb r2, [r0, 0x1] - ldr r0, [r5] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - mov r1, r8 - bl StartSpriteAffineAnim - mov r0, r8 - cmp r0, 0x2 - bne _080DE74C - ldr r0, [r5] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - bl AnimateSprite - ldr r0, [r5] - ldr r0, [r0, 0x14] - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - adds r0, 0x3E - ldrb r1, [r0] - movs r3, 0x5 - negs r3, r3 - adds r2, r3, 0 - ands r1, r2 - strb r1, [r0] -_080DE74C: - adds r7, 0x1 - cmp r7, 0x3 - ble _080DE6AE - ldr r0, =sub_80DE794 - movs r1, 0x5 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - mov r0, r8 - strh r0, [r1, 0x8] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0] - ldrb r0, [r2, 0x7] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2, 0x7] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE69C - - thumb_func_start sub_80DE794 -sub_80DE794: @ 80DE794 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r2, =gSprites - ldr r3, =gContestResources - ldr r0, [r3] - ldr r0, [r0, 0x14] - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _080DE822 - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldrb r0, [r1, 0x8] - cmp r0, 0x1 - bne _080DE7EC - movs r4, 0 - adds r5, r2, 0 - movs r2, 0x4 -_080DE7CC: - ldr r0, [r3] - ldr r1, [r0, 0x14] - lsls r0, r4, 2 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - adds r4, 0x1 - cmp r4, 0x3 - ble _080DE7CC -_080DE7EC: - movs r4, 0 -_080DE7EE: - ldr r5, =gContestResources - ldr r0, [r5] - ldr r1, [r0, 0x14] - lsls r0, r4, 2 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl FreeSpriteOamMatrix - adds r4, 0x1 - cmp r4, 0x3 - ble _080DE7EE - ldr r0, [r5] - ldr r2, [r0] - ldrb r1, [r2, 0x7] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0x7] - adds r0, r6, 0 - bl DestroyTask -_080DE822: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE794 - - thumb_func_start sub_80DE834 -sub_80DE834: @ 80DE834 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - movs r0, 0xB1 - lsls r0, 1 - cmp r1, r0 - bls _080DE844 - movs r1, 0x1 -_080DE844: - adds r0, r1, 0 - pop {r1} - bx r1 - thumb_func_end sub_80DE834 - - thumb_func_start sub_80DE84C -sub_80DE84C: @ 80DE84C - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =0x0000019b - cmp r1, r0 - bls _080DE85A - movs r1, 0 -_080DE85A: - adds r0, r1, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DE84C - - thumb_func_start sub_80DE864 -sub_80DE864: @ 80DE864 - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r4, =gContestResources - ldr r0, [r4] - ldr r1, [r0, 0x4] - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0, 0x6] - bl sub_80DE834 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r1, =gContestMons - lsls r0, r7, 6 - adds r0, r1 - ldrh r0, [r0] - bl sub_80DE84C - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, [r4] - ldr r0, [r0, 0x18] - movs r1, 0 - movs r2, 0x14 - bl memset - bl ClearBattleAnimationVars - ldr r1, =gBattleMonForms - movs r2, 0 - adds r0, r1, 0x3 -_080DE8A8: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _080DE8A8 - cmp r5, 0x90 - beq _080DE920 - cmp r5, 0x90 - bgt _080DE8DE - cmp r5, 0x4C - beq _080DE978 - cmp r5, 0x4C - bgt _080DE8D4 - cmp r5, 0xD - beq _080DE978 - b _080DE9A2 - .pool -_080DE8D4: - cmp r5, 0x82 - beq _080DE978 - cmp r5, 0x8F - beq _080DE978 - b _080DE9A2 -_080DE8DE: - cmp r5, 0xD8 - beq _080DE960 - cmp r5, 0xD8 - bgt _080DE8EC - cmp r5, 0xAE - beq _080DE8FA - b _080DE9A2 -_080DE8EC: - cmp r5, 0xDA - beq _080DE96C - movs r0, 0x88 - lsls r0, 1 - cmp r5, r0 - beq _080DE920 - b _080DE9A2 -_080DE8FA: - ldr r0, =gBaseStats - lsls r1, r6, 3 - subs r1, r6 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x6] - cmp r0, 0x7 - beq _080DE910 - ldrb r0, [r1, 0x7] - cmp r0, 0x7 - bne _080DE99C -_080DE910: - ldr r1, =gAnimMoveTurn - movs r0, 0 - b _080DE9A0 - .pool -_080DE920: - ldr r6, =gContestResources - ldr r0, [r6] - ldr r1, [r0, 0x4] - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r4, [r0, 0x1B] - ldr r5, =gContestMons - lsls r4, 6 - adds r0, r4, r5 - ldrh r0, [r0] - bl sub_80DE84C - ldr r2, [r6] - ldr r1, [r2, 0x18] - strh r0, [r1, 0x2] - ldr r2, [r2, 0x18] - adds r5, 0x38 - adds r4, r5 - ldr r0, [r4] - str r0, [r2, 0x10] - ldrb r0, [r2, 0x4] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2, 0x4] - b _080DE9A2 - .pool -_080DE960: - ldr r1, =gAnimFriendship - movs r0, 0xFF - b _080DE9A0 - .pool -_080DE96C: - ldr r1, =gAnimFriendship - movs r0, 0 - b _080DE9A0 - .pool -_080DE978: - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0] - adds r2, r0, 0 - adds r2, 0x5A - ldrb r1, [r2] - cmp r1, 0 - bne _080DE99C - movs r0, 0x2 - strb r0, [r2] - ldr r0, =gAnimMoveTurn - strb r1, [r0] - b _080DE9A2 - .pool -_080DE99C: - ldr r1, =gAnimMoveTurn - movs r0, 0x1 -_080DE9A0: - strb r0, [r1] -_080DE9A2: - bl sub_80DEA5C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE864 - - thumb_func_start sub_80DE9B0 -sub_80DE9B0: @ 80DE9B0 - push {r4,lr} - ldr r4, =gContestResources - ldr r0, [r4] - ldr r0, [r0, 0x18] - movs r1, 0 - movs r2, 0x14 - bl memset - ldr r0, [r4] - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0x5A - ldrb r0, [r1] - cmp r0, 0 - beq _080DE9D2 - subs r0, 0x1 - strb r0, [r1] -_080DE9D2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE9B0 - - thumb_func_start sub_80DE9DC -sub_80DE9DC: @ 80DE9DC - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r6, =gContestResources - ldr r0, [r6] - ldr r0, [r0, 0x18] - strb r4, [r0, 0x5] - ldr r5, =gContestMons - lsls r4, 6 - adds r0, r4, r5 - ldrh r0, [r0] - bl sub_80DE84C - ldr r2, [r6] - ldr r1, [r2, 0x18] - strh r0, [r1] - ldr r1, [r2, 0x18] - adds r0, r5, 0 - adds r0, 0x38 - adds r0, r4, r0 - ldr r0, [r0] - str r0, [r1, 0x8] - adds r5, 0x3C - adds r4, r5 - ldr r0, [r4] - str r0, [r1, 0xC] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DE9DC - - thumb_func_start sub_80DEA20 -sub_80DEA20: @ 80DEA20 - push {lr} - ldr r0, =SpriteCallbackDummy - bl CreateInvisibleSpriteWithCallback - ldr r1, =gBattlerSpriteIds - strb r0, [r1, 0x3] - ldr r0, =gBattlerTarget - ldrb r0, [r0] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl InitSpriteAffineAnim - bl sub_80DEA5C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DEA20 - - thumb_func_start sub_80DEA5C -sub_80DEA5C: @ 80DEA5C - push {r4,lr} - ldr r0, =gBattlerSpriteIds - ldrb r0, [r0, 0x3] - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - movs r0, 0 - strh r0, [r4, 0x24] - strh r0, [r4, 0x26] - movs r0, 0x3 - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x20] - movs r0, 0x3 - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x22] - adds r4, 0x3E - ldrb r0, [r4] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DEA5C - - thumb_func_start sub_80DEAA8 -sub_80DEAA8: @ 80DEAA8 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r2, =gBattleMoves - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0x6] - cmp r0, 0x20 - bhi _080DEB60 - lsls r0, 2 - ldr r1, =_080DEAD0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080DEAD0: - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB54 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB54 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 - .4byte _080DEB60 -_080DEB54: - ldr r1, =gBattlerTarget - movs r0, 0x2 - b _080DEB64 - .pool -_080DEB60: - ldr r1, =gBattlerTarget - movs r0, 0x3 -_080DEB64: - strb r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DEAA8 - - thumb_func_start Contest_PrintTextToBg0WindowStd -Contest_PrintTextToBg0WindowStd: @ 80DEB70 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - str r1, [sp] - mov r0, sp - movs r2, 0 - strb r4, [r0, 0x4] - movs r1, 0x1 - strb r1, [r0, 0x5] - strb r2, [r0, 0x6] - strb r1, [r0, 0x7] - strb r2, [r0, 0x8] - strb r1, [r0, 0x9] - strb r2, [r0, 0xA] - strb r2, [r0, 0xB] - mov r3, sp - ldrb r2, [r3, 0xC] - subs r1, 0x11 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - mov r2, sp - movs r0, 0xF0 - 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 - movs r0, 0 - bl Contest_SetBgCopyFlags - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - thumb_func_end Contest_PrintTextToBg0WindowStd - - thumb_func_start Contest_PrintTextToBg0WindowAt -Contest_PrintTextToBg0WindowAt: @ 80DEBD0 - push {r4,r5,lr} - sub sp, 0x10 - adds r5, r0, 0 - ldr r4, [sp, 0x1C] - str r1, [sp] - mov r0, sp - movs r1, 0 - strb r5, [r0, 0x4] - strb r4, [r0, 0x5] - strb r2, [r0, 0x6] - strb r3, [r0, 0x7] - strb r2, [r0, 0x8] - strb r3, [r0, 0x9] - strb r1, [r0, 0xA] - strb r1, [r0, 0xB] - mov r3, sp - ldrb r2, [r3, 0xC] - subs r1, 0x10 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - mov r2, sp - movs r0, 0xF0 - 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 r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - bl PutWindowTilemap - movs r0, 0 - bl Contest_SetBgCopyFlags - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end Contest_PrintTextToBg0WindowAt - - thumb_func_start Contest_StartTextPrinter -Contest_StartTextPrinter: @ 80DEC30 - push {r4,r5,lr} - sub sp, 0x10 - str r0, [sp] - mov r2, sp - movs r3, 0 - movs r0, 0x4 - strb r0, [r2, 0x4] - mov r0, sp - movs r5, 0x1 - strb r5, [r0, 0x5] - strb r3, [r0, 0x6] - strb r5, [r0, 0x7] - strb r3, [r0, 0x8] - strb r5, [r0, 0x9] - strb r3, [r0, 0xA] - strb r3, [r0, 0xB] - mov r4, sp - ldrb r3, [r4, 0xC] - movs r2, 0x10 - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - strb r0, [r4, 0xC] - mov r3, sp - movs r0, 0x10 - strb r0, [r3, 0xC] - ldrb r0, [r3, 0xD] - ands r2, r0 - strb r2, [r3, 0xD] - mov r2, sp - movs r0, 0x80 - strb r0, [r2, 0xD] - cmp r1, 0 - bne _080DEC80 - mov r0, sp - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - b _080DECA4 -_080DEC80: - ldr r0, =gIsLinkContest - ldrb r1, [r0] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _080DEC94 - movs r1, 0x4 - b _080DEC9C - .pool -_080DEC94: - bl GetPlayerTextSpeedDelay - lsls r0, 24 - lsrs r1, r0, 24 -_080DEC9C: - mov r0, sp - movs r2, 0 - bl AddTextPrinter -_080DECA4: - movs r0, 0x4 - bl PutWindowTilemap - movs r0, 0 - bl Contest_SetBgCopyFlags - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end Contest_StartTextPrinter - - thumb_func_start ContestBG_FillBoxWithIncrementingTile -ContestBG_FillBoxWithIncrementingTile: @ 80DECB8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - mov r8, r0 - ldr r0, [sp, 0x28] - ldr r4, [sp, 0x2C] - ldr r5, [sp, 0x30] - ldr r6, [sp, 0x34] - mov r7, r8 - lsls r7, 24 - lsrs r7, 24 - mov r8, r7 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - str r0, [sp] - str r4, [sp, 0x4] - str r5, [sp, 0x8] - lsls r6, 16 - asrs r6, 16 - str r6, [sp, 0xC] - mov r0, r8 - bl WriteSequenceToBgTilemapBuffer - mov r0, r8 - bl Contest_SetBgCopyFlags - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ContestBG_FillBoxWithIncrementingTile - - thumb_func_start ContestBG_FillBoxWithTile -ContestBG_FillBoxWithTile: @ 80DED10 - push {r4-r6,lr} - sub sp, 0x10 - ldr r4, [sp, 0x20] - ldr r5, [sp, 0x24] - ldr r6, [sp, 0x28] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - str r4, [sp] - str r5, [sp, 0x4] - str r6, [sp, 0x8] - movs r4, 0 - str r4, [sp, 0xC] - bl ContestBG_FillBoxWithIncrementingTile - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end ContestBG_FillBoxWithTile - - thumb_func_start Contest_RunTextPrinters -Contest_RunTextPrinters: @ 80DED4C - push {lr} - bl RunTextPrinters - movs r0, 0x4 - bl IsTextPrinterActive - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - thumb_func_end Contest_RunTextPrinters - - thumb_func_start Contest_SetBgCopyFlags -Contest_SetBgCopyFlags: @ 80DED60 - ldr r2, =sContestBgCopyFlags - movs r1, 0x1 - lsls r1, r0 - ldrb r0, [r2] - orrs r1, r0 - strb r1, [r2] - bx lr - .pool - thumb_func_end Contest_SetBgCopyFlags - - thumb_func_start ResetContestLinkResults -ResetContestLinkResults: @ 80DED74 - push {r4-r6,lr} - movs r0, 0 - ldr r6, =gSaveBlock2Ptr - ldr r5, =0x00000624 - movs r4, 0 -_080DED7E: - adds r3, r0, 0x1 - lsls r1, r0, 3 - movs r2, 0x3 -_080DED84: - ldr r0, [r6] - adds r0, r5 - adds r0, r1 - strh r4, [r0] - adds r1, 0x2 - subs r2, 0x1 - cmp r2, 0 - bge _080DED84 - adds r0, r3, 0 - cmp r0, 0x4 - ble _080DED7E - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ResetContestLinkResults - - thumb_func_start sub_80DEDA8 -sub_80DEDA8: @ 80DEDA8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - ldr r1, =gContestFinalStandings - ldrb r0, [r1] - cmp r0, 0 - beq _080DEDE6 -_080DEDD8: - adds r5, 0x1 - cmp r5, 0x2 - bgt _080DEDE6 - adds r0, r5, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080DEDD8 -_080DEDE6: - ldr r0, [sp] - cmp r0, 0xFF - bne _080DEE00 - ldr r0, =gContestPlayerMonIndex - ldrb r0, [r0] - cmp r5, r0 - beq _080DEE00 - movs r0, 0 - b _080DEF90 - .pool -_080DEE00: - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - cmp r0, 0x4 - bhi _080DEE4C - lsls r0, 2 - ldr r1, =_080DEE1C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080DEE1C: - .4byte _080DEE4C - .4byte _080DEE30 - .4byte _080DEE36 - .4byte _080DEE3C - .4byte _080DEE42 -_080DEE30: - mov r0, r8 - adds r0, 0x3 - b _080DEE46 -_080DEE36: - mov r0, r8 - adds r0, 0x6 - b _080DEE46 -_080DEE3C: - mov r0, r8 - adds r0, 0x9 - b _080DEE46 -_080DEE42: - mov r0, r8 - adds r0, 0xC -_080DEE46: - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 -_080DEE4C: - ldr r1, [sp] - cmp r1, 0xFE - bne _080DEE54 - b _080DEF50 -_080DEE54: - adds r0, r1, 0 - movs r1, 0x1 - bl sub_80DEFA8 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r2, =gSaveBlock1Ptr - mov r10, r2 - ldr r0, [r2] - mov r3, r9 - lsls r7, r3, 5 - ldr r6, =0x00002e90 - adds r2, r0, r6 - adds r2, r7 - ldr r4, =gContestMons - lsls r5, 6 - adds r1, r4, 0 - adds r1, 0x38 - adds r1, r5, r1 - ldr r1, [r1] - str r1, [r2] - adds r1, r0, r7 - adds r2, r5, r4 - ldrh r2, [r2] - ldr r3, =0x00002e98 - adds r1, r3 - strh r2, [r1] - ldr r1, =0x00002e94 - adds r2, r0, r1 - adds r2, r7 - adds r1, r4, 0 - adds r1, 0x3C - adds r1, r5, r1 - ldr r1, [r1] - str r1, [r2] - adds r6, r7, r6 - adds r0, r6 - adds r0, 0xB - adds r1, r4, 0x2 - adds r1, r5, r1 - bl StringCopy - mov r2, r10 - ldr r0, [r2] - adds r0, r6 - adds r0, 0x16 - adds r4, 0xD - adds r5, r4 - adds r1, r5, 0 - bl StringCopy - ldr r0, =gIsLinkContest - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080DEEF4 - mov r3, r10 - ldr r0, [r3] - adds r0, r7 - ldr r1, =0x00002eae - adds r0, r1 - movs r1, 0x4 - b _080DEF02 - .pool -_080DEEF4: - mov r2, r10 - ldr r0, [r2] - adds r0, r7 - ldr r1, =gSpecialVar_ContestRank - ldrh r1, [r1] - ldr r3, =0x00002eae - adds r0, r3 -_080DEF02: - strb r1, [r0] - ldr r0, [sp] - cmp r0, 0xFF - beq _080DEF34 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - mov r2, r9 - lsls r1, r2, 5 - adds r0, r1 - ldr r1, =gSpecialVar_ContestCategory - ldrh r1, [r1] - ldr r3, =0x00002e9a - adds r0, r3 - strb r1, [r0] - b _080DEF8E - .pool -_080DEF34: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - mov r2, r9 - lsls r1, r2, 5 - adds r0, r1 - ldr r3, =0x00002e9a - adds r0, r3 - mov r1, r8 - strb r1, [r0] - b _080DEF8E - .pool -_080DEF50: - ldr r6, =gUnknown_02039F3C - ldr r4, =gContestMons - lsls r5, 6 - adds r0, r4, 0 - adds r0, 0x38 - adds r0, r5, r0 - ldr r0, [r0] - str r0, [r6] - adds r0, r4, 0 - adds r0, 0x3C - adds r0, r5, r0 - ldr r0, [r0] - str r0, [r6, 0x4] - adds r0, r5, r4 - ldrh r0, [r0] - strh r0, [r6, 0x8] - adds r0, r6, 0 - adds r0, 0xB - adds r1, r4, 0x2 - adds r1, r5, r1 - bl StringCopy - adds r0, r6, 0 - adds r0, 0x16 - adds r4, 0xD - adds r5, r4 - adds r1, r5, 0 - bl StringCopy - mov r2, r8 - strb r2, [r6, 0xA] -_080DEF8E: - movs r0, 0x1 -_080DEF90: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DEDA8 - - thumb_func_start sub_80DEFA8 -sub_80DEFA8: @ 80DEFA8 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r0, 0x3 - bgt _080DEFF8 - cmp r0, 0 - blt _080DEFF8 - cmp r1, 0 - beq _080DEFE6 - movs r2, 0x5 - ldr r0, =gSaveBlock1Ptr - mov r12, r0 - ldr r4, =0x00002e90 - ldr r3, =0x00002e70 -_080DEFC8: - mov r1, r12 - ldr r0, [r1] - lsls r1, r2, 5 - adds r1, r0 - adds r0, r1, r4 - adds r1, r3 - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldm r1!, {r5,r6} - stm r0!, {r5,r6} - subs r2, 0x1 - cmp r2, 0 - bgt _080DEFC8 -_080DEFE6: - movs r0, 0 - b _080DF03A - .pool -_080DEFF8: - ldr r0, =gSpecialVar_ContestCategory - ldrh r0, [r0] - cmp r0, 0x4 - bhi _080DF038 - lsls r0, 2 - ldr r1, =_080DF014 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080DF014: - .4byte _080DF028 - .4byte _080DF02C - .4byte _080DF030 - .4byte _080DF034 - .4byte _080DF038 -_080DF028: - movs r0, 0x8 - b _080DF03A -_080DF02C: - movs r0, 0x9 - b _080DF03A -_080DF030: - movs r0, 0xA - b _080DF03A -_080DF034: - movs r0, 0xB - b _080DF03A -_080DF038: - movs r0, 0xC -_080DF03A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80DEFA8 - - thumb_func_start ClearContestWinnerPicsInContestHall -ClearContestWinnerPicsInContestHall: @ 80DF040 - push {r4-r7,lr} - movs r2, 0 - ldr r0, =gSaveBlock1Ptr - mov r12, r0 - ldr r4, =0x00002e90 - ldr r3, =gUnknown_08587FA4 -_080DF04C: - mov r1, r12 - ldr r0, [r1] - lsls r1, r2, 5 - adds r0, r1 - adds r0, r4 - adds r1, r3, 0 - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldm r1!, {r5,r6} - stm r0!, {r5,r6} - adds r3, 0x20 - adds r2, 0x1 - cmp r2, 0x7 - ble _080DF04C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end ClearContestWinnerPicsInContestHall - thumb_func_start sub_80DF080 sub_80DF080: @ 80DF080 push {r4-r7,lr} diff --git a/data/contest.s b/data/contest.s index eaf3f8c95..48bfa1080 100644 --- a/data/contest.s +++ b/data/contest.s @@ -406,7 +406,7 @@ gSpriteTemplate_858998C:: @ 858998C spr_template 0x80eb, 0x80eb, gOamData_8589944, gDummySpriteAnimTable, NULL, gSpriteAffineAnimTable_8589984, SpriteCallbackDummy .align 2 -gUnknown_085899EC:: @ 85899EC +gContestExcitementTable:: @ 85899EC .2byte 0x0001, 0xffff, 0x0000, 0x0001, 0xffff, 0x00ff, 0x0001, 0xffff, 0x00ff, 0x0001, 0xff00, 0x00ff, 0x0001, 0x0000 diff --git a/data/text/contest_strings.inc b/data/text/contest_strings.inc index 737e4b862..1406ba3cb 100644 --- a/data/text/contest_strings.inc +++ b/data/text/contest_strings.inc @@ -665,19 +665,19 @@ gText_0827E817:: @ 827E817 .string "{STR_VAR_1}'s\n" .string "{STR_VAR_2} is ignored.{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}{PAUSE 0x0F}$" -gText_0827E837:: @ 827E837 +gText_Contest_Shyness:: @ 827E837 .string "shyness$" -gText_0827E83F:: @ 827E83F +gText_Contest_Anxiety:: @ 827E83F .string "anxiety$" -gText_0827E847:: @ 827E847 +gText_Contest_Laziness:: @ 827E847 .string "laziness$" -gText_0827E850:: @ 827E850 +gText_Contest_Hesitancy:: @ 827E850 .string "hesitancy$" -gText_0827E85A:: @ 827E85A +gText_Contest_Fear:: @ 827E85A .string "fear$" gText_0827E85F:: @ 827E85F diff --git a/include/contest.h b/include/contest.h index 4ab4d350c..65db7b0bc 100644 --- a/include/contest.h +++ b/include/contest.h @@ -429,9 +429,13 @@ extern struct ContestResources *gContestResources; #define shared19328 (*gContestResources->field_10) #define shared19338 (*gContestResources->field_14) + + #define shared15800 (gHeap + 0x18000) +#define shared16800 (gHeap + 0x19000) #define shared18000 (*(struct Shared18000 *)(gHeap + 0x1a000)) + extern u32 gContestRngValue; extern u8 gUnknown_02039F26[4]; @@ -445,7 +449,7 @@ bool8 sub_80DE1E8(u8 a); void SetStartledString(u8 a, u8 b); s8 Contest_GetMoveExcitement(u16); u8 sub_80DAE0C(struct Pokemon *); -void sub_80DEDA8(u8); +bool8 sub_80DEDA8(u8); void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); void sub_80DB09C(u8 contestCategory); void sub_80DCE58(u8); diff --git a/include/graphics.h b/include/graphics.h index 29719d1a0..4615facf9 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4745,9 +4745,13 @@ extern const u32 gBattleStatMask8_Pal[]; extern const u32 gUnknown_08D9A88C[]; extern const u32 gContestMiscGfx[]; extern const u32 gContestAudienceGfx[]; +extern const u8 gContestApplauseMeterGfx[]; +extern const u8 gContestNextTurnNumbersGfx[]; +extern const u8 gContestNextTurnRandomGfx[]; extern const u32 gUnknown_08C16FA8[]; extern const u32 gUnknown_08C16E90[]; extern const u32 gUnknown_08C17170[]; +extern const u32 gUnknown_08C17980[]; extern const u32 gUnknown_08D95E00[]; extern const u32 gUnknown_08D960D0[]; diff --git a/src/contest.c b/src/contest.c index a0b44e331..a74e2c96b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -103,7 +103,7 @@ u8 sub_80DB120(void); u8 sub_80DB174(u16, u32, u32, u32); void sub_80DB2BC(void); void prints_contest_move_description(u16); -u16 sub_80DE84C(u16); +u16 SanitizeSpecies(u16); void sub_80DB89C(void); u16 GetChosenMove(u8); void sub_80DB918(void); @@ -129,7 +129,7 @@ void sub_80DE424(u8); void sub_80DE69C(u8); void sub_80DEA20(void); void Contest_PrintTextToBg0WindowAt(u32, u8 *, s32, u8, u8); -void Contest_StartTextPrinter(const u8 *, u8); +void Contest_StartTextPrinter(const u8 *, u32); void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, u8); bool32 Contest_RunTextPrinters(void); void Contest_SetBgCopyFlags(u32); @@ -144,9 +144,9 @@ void sub_80DF750(void); void sub_80DE9DC(u8); void sub_80DCBE8(u8, u8); u8 sub_80DC9EC(u8); -u16 sub_80DE834(u16); +u16 SanitizeMove(u16); void sub_80DE864(u8); -void sub_80DEAA8(u16); +void SelectContestMoveBankTarget(u16); void sub_80DE9B0(u8); void sub_80DC674(u8); void sub_80DE12C(void); @@ -169,7 +169,7 @@ bool8 sub_80DC3C4(void); void sub_80DF9D4(u8 *); void sub_80DF9E0(u8 *, s32); void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8); -void Contest_PrintTextToBg0WindowStd(u8, const u8 *); +void Contest_PrintTextToBg0WindowStd(u32, const u8 *); s16 sub_80DBD34(u8); void DetermineFinalStandings(void); bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); @@ -180,7 +180,23 @@ void sub_80DC6A4(u8); void sub_80DC8D0(u8); void sub_80DC81C(u8); void sub_80DC87C(u8); - +void sub_80DCC84(struct Sprite *); +void sub_80DCCD8(struct Sprite *sprite); +u8 sub_80DDA20(void); +void c3_08130B10(u8); +void sub_80DDB6C(u8); +void task08_080CD1CC(u8); +void sub_80DDD20(u8); +void sub_80DDE30(u8); +void sub_80DDF80(u8); +const u8 *GetTurnOrderNumberGfx(u8); +void sub_80DE464(u8); +void sub_80DE4A8(u8); +void sub_80DE5F4(u8); +void sub_80DE65C(u8); +void sub_80DE794(u8); +void sub_80DEA5C(void); +u8 sub_80DEFA8(u8, u8); EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; @@ -228,6 +244,12 @@ extern const u8 gText_0827E817[]; extern const u8 gText_0827E58A[]; extern const u8 gText_0827D56F[]; extern const u8 gText_0827D597[]; +extern const u8 gText_Contest_Shyness[]; +extern const u8 gText_Contest_Anxiety[]; +extern const u8 gText_Contest_Laziness[]; +extern const u8 gText_Contest_Hesitancy[]; +extern const u8 gText_Contest_Fear[]; +extern const u8 *const gUnknown_08587E10[]; extern const struct ContestPokemon gContestOpponents[96]; extern const u8 gUnknown_085898A4[96]; extern const struct CompressedSpriteSheet gUnknown_08587C00; @@ -249,6 +271,10 @@ extern const struct SubspriteTable gSubspriteTables_8587B80[]; extern const struct CompressedSpriteSheet gUnknown_08587BB0; extern const struct SpritePalette gUnknown_08587BB8; extern const struct SpriteTemplate gSpriteTemplate_8587BC8; +extern bool8 gUnknown_020322D5; +extern void (*const gContestEffectFuncs[])(void); +extern const s8 gContestExcitementTable[][5]; +extern const struct ContestWinner gUnknown_08587FA4[]; void TaskDummy1(u8 taskId) { @@ -1071,11 +1097,11 @@ void sub_80D8B38(u8 taskId) return; case 7: { - u16 move = sub_80DE834(gContestResources->field_4[gContestResources->field_0->unk19215].currMove); + u16 move = SanitizeMove(gContestResources->field_4[gContestResources->field_0->unk19215].currMove); sub_80DE864(gContestResources->field_0->unk19215); sub_80DE9DC(gContestResources->field_0->unk19215); - sub_80DEAA8(move); + SelectContestMoveBankTarget(move); DoMoveAnim(move); gTasks[taskId].data[0] = 8; } @@ -2531,7 +2557,7 @@ u8 sub_80DB120(void) u8 sub_80DB174(u16 species, u32 otId, u32 personality, u32 index) { u8 spriteId; - species = sub_80DE84C(species); + species = SanitizeSpecies(species); if (index == gContestPlayerMonIndex) HandleLoadSpecialPokePic_2(gMonBackPicTable + species, gMonSpritesGfxPtr->sprites[0], species, personality); @@ -2776,9 +2802,9 @@ void sub_80DB884(void) void sub_80DB89C(void) { - FillWindowPixelBuffer(4, 0); - CopyWindowToVram(4, 2); - Contest_SetBgCopyFlags(0); + FillWindowPixelBuffer(4, 0); + CopyWindowToVram(4, 2); + Contest_SetBgCopyFlags(0); } u16 GetChosenMove(u8 a) @@ -2796,20 +2822,20 @@ u16 GetChosenMove(u8 a) ContestAI_ResetAI(a); moveChoice = ContestAI_GetActionToUse(); return gContestMons[a].moves[moveChoice]; - } + } } void sub_80DB918(void) { - s32 i; + s32 i; for (i = 0; i < 4; i++) - sContestantStatus[i].currMove = GetChosenMove(i); + sContestantStatus[i].currMove = GetChosenMove(i); } void sub_80DB944(void) { - s32 i; + s32 i; s32 j; s16 arr[4]; @@ -3016,7 +3042,7 @@ void DetermineFinalStandings(void) void sub_80DBED4(void) { - if ((gIsLinkContest & 1)) + if ((gIsLinkContest & 1)) { gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 0x270F) ? 0x270F : @@ -3027,7 +3053,7 @@ void sub_80DBED4(void) bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) { - bool8 retVal; + bool8 retVal; if (c[a].unk0 < c[b].unk0) retVal = TRUE; @@ -3046,15 +3072,15 @@ bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) void sub_80DBF68(void) { - gBattle_BG0_Y = 0; - gBattle_BG2_Y = 0; - sub_80DB89C(); - Contest_StartTextPrinter((u8*) &gUnknown_0827E8DA, 0); + gBattle_BG0_Y = 0; + gBattle_BG2_Y = 0; + sub_80DB89C(); + Contest_StartTextPrinter((u8*) &gUnknown_0827E8DA, 0); } void sub_80DBF90(void) { - int i; + int i; for(i = 0; i < 4; i++) { @@ -3106,7 +3132,7 @@ u8 sub_80DC028(s16 a, s16 b, u8 c) else gTasks[taskId].data[2] = -1; gTasks[taskId].data[3] = c; - return taskId; + return taskId; } void sub_80DC0F4(u8 taskId) @@ -3474,24 +3500,25 @@ extern const struct CompressedSpriteSheet gUnknown_08589904[]; extern const struct SpritePalette gUnknown_08589924[]; extern const struct SpriteTemplate gSpriteTemplate_858998C[]; +#ifdef NONMATCHING u8 sub_80DC9EC(u8 a) { - u8 r5 = gUnknown_02039F26[a] * 40 + 32; + u8 r5 = gUnknown_02039F26[a] * 40 + 32; u8 r8; u8 r6; volatile u8 zero; - + LoadCompressedObjectPic(&gUnknown_08589904[a]); LoadSpritePalette(&gUnknown_08589924[a]); r6 = CreateSprite(&gSpriteTemplate_858998C[a], 184, r5, 29); - gSprites[r8].oam.tileNum += 64; + gSprites[r8].oam.tileNum += 64; r8 = CreateSprite(&gSpriteTemplate_858998C[a], 248, r5, 29); CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x26), (u8 *)(VRAM + 0x10000 + gSprites[r6].oam.tileNum * 32)); CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32)); - CpuSet(&r8, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), 0x050000c0); + CpuSet(&r8, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), 0x050000c0); RequestDma3Copy((void *)(VRAM + 0x10000 + (0x28 + gSprites[r6].oam.tileNum) * 32), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32), 0x80, 1); @@ -3506,4 +3533,2661 @@ u8 sub_80DC9EC(u8 a) gSprites[r8].data[0] = r6; return r6; -} \ No newline at end of file +} +#else +NAKED +u8 sub_80DC9EC(u8 a) +{ + asm(".syntax 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, 0x10\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0xC]\n\ + ldr r6, =gUnknown_02039F26\n\ + adds r6, r0, r6\n\ + ldrb r0, [r6]\n\ + lsls r5, r0, 2\n\ + adds r5, r0\n\ + lsls r5, 27\n\ + movs r0, 0x80\n\ + lsls r0, 22\n\ + adds r5, r0\n\ + lsrs r5, 24\n\ + ldr r1, [sp, 0xC]\n\ + lsls r4, r1, 3\n\ + ldr r0, =gUnknown_08589904\n\ + adds r0, r4, r0\n\ + bl LoadCompressedObjectPic\n\ + ldr r0, =gUnknown_08589924\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + bl LoadSpritePalette\n\ + ldr r2, [sp, 0xC]\n\ + lsls r4, r2, 1\n\ + adds r4, r2\n\ + lsls r4, 3\n\ + ldr r0, =gSpriteTemplate_858998C\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xB8\n\ + adds r2, r5, 0\n\ + movs r3, 0x1D\n\ + bl CreateSprite\n\ + mov r9, r0\n\ + mov r3, r9\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + mov r9, r3\n\ + adds r0, r4, 0\n\ + movs r1, 0xF8\n\ + adds r2, r5, 0\n\ + movs r3, 0x1D\n\ + bl CreateSprite\n\ + mov r8, r0\n\ + mov r0, r8\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + lsls r5, r0, 4\n\ + add r5, r8\n\ + lsls r5, 2\n\ + ldr r1, =gSprites\n\ + adds r5, r1\n\ + ldrh r2, [r5, 0x4]\n\ + lsls r1, r2, 22\n\ + lsrs r1, 22\n\ + adds r1, 0x40\n\ + ldr r3, =0x000003ff\n\ + adds r0, r3, 0\n\ + ands r1, r0\n\ + ldr r0, =0xfffffc00\n\ + ands r0, r2\n\ + orrs r0, r1\n\ + strh r0, [r5, 0x4]\n\ + movs r4, 0xC0\n\ + lsls r4, 19\n\ + ldrb r0, [r6]\n\ + lsls r3, r0, 2\n\ + adds r3, r0\n\ + lsls r3, 6\n\ + ldr r0, =0x0600e026\n\ + adds r3, r0\n\ + ldr r7, =gContestResources\n\ + ldr r0, [r7]\n\ + ldr r0, [r0, 0x34]\n\ + str r0, [sp]\n\ + movs r0, 0\n\ + movs r1, 0x3\n\ + adds r2, r4, 0\n\ + bl CopySpriteTiles\n\ + ldrb r0, [r6]\n\ + lsls r3, r0, 2\n\ + adds r3, r0\n\ + lsls r3, 6\n\ + ldr r1, =0x0600e036\n\ + adds r3, r1\n\ + ldr r0, [r7]\n\ + ldr r0, [r0, 0x38]\n\ + str r0, [sp]\n\ + movs r0, 0\n\ + movs r1, 0x3\n\ + adds r2, r4, 0\n\ + bl CopySpriteTiles\n\ + movs r4, 0\n\ + str r4, [sp, 0x4]\n\ + ldr r0, [r7]\n\ + ldr r1, [r0, 0x34]\n\ + movs r6, 0xA0\n\ + lsls r6, 3\n\ + adds r1, r6\n\ + ldr r2, =0x050000c0\n\ + mov r10, r2\n\ + add r0, sp, 0x4\n\ + bl CpuSet\n\ + str r4, [sp, 0x8]\n\ + add r0, sp, 0x8\n\ + ldr r1, [r7]\n\ + ldr r1, [r1, 0x38]\n\ + adds r1, r6\n\ + mov r2, r10\n\ + bl CpuSet\n\ + ldr r0, [r7]\n\ + ldr r0, [r0, 0x34]\n\ + mov r3, r9\n\ + lsls r4, r3, 4\n\ + add r4, r9\n\ + lsls r4, 2\n\ + ldr r1, =gSprites\n\ + adds r4, r1\n\ + ldrh r1, [r4, 0x4]\n\ + lsls r1, 22\n\ + lsrs r1, 17\n\ + ldr r6, =0x06010000\n\ + adds r1, r6\n\ + movs r2, 0x80\n\ + lsls r2, 4\n\ + mov r10, r2\n\ + movs r3, 0x1\n\ + bl RequestDma3Copy\n\ + ldr r0, [r7]\n\ + ldr r0, [r0, 0x38]\n\ + ldrh r1, [r5, 0x4]\n\ + lsls r1, 22\n\ + lsrs r1, 17\n\ + adds r1, r6\n\ + mov r2, r10\n\ + movs r3, 0x1\n\ + bl RequestDma3Copy\n\ + mov r3, r8\n\ + strh r3, [r4, 0x2E]\n\ + mov r0, r9\n\ + strh r0, [r5, 0x2E]\n\ + mov r1, sp\n\ + ldrh r1, [r1, 0xC]\n\ + strh r1, [r4, 0x30]\n\ + mov r2, sp\n\ + ldrh r2, [r2, 0xC]\n\ + strh r2, [r5, 0x30]\n\ + mov r0, r9\n\ + add sp, 0x10\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_80DCB78(u8 spriteId) +{ + u8 spriteId2 = gSprites[spriteId].data[0]; + + FreeSpriteOamMatrix(&gSprites[spriteId2]); + DestroySprite(&gSprites[spriteId2]); + DestroySpriteAndFreeResources(&gSprites[spriteId]); +} + +void sub_80DCBB4(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x0907); +} + +void sub_80DCBD0(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); +} + +void sub_80DCBE8(u8 a, bool8 b) +{ + u8 r5; + + sub_80DCBB4(); + gContestResources->field_14[gSprites[a].data[1]].unk2_1 = 1; + r5 = gSprites[a].data[0]; + StartSpriteAffineAnim(&gSprites[a], 1); + StartSpriteAffineAnim(&gSprites[r5], 1); + gSprites[a].callback = sub_80DCC84; + gSprites[r5].callback = SpriteCallbackDummy; + if (b == FALSE) + PlaySE(SE_C_PIKON); + else + PlaySE(SE_PC_LOGIN); +} + +void sub_80DCC84(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + u8 r1 = sprite->data[0]; + + if (gSprites[r1].affineAnimEnded) + { + sprite->invisible = TRUE; + gSprites[r1].invisible = TRUE; + sprite->callback = sub_80DCCD8; + } + } +} + +void sub_80DCCD8(struct Sprite *sprite) +{ + gContestResources->field_14[sprite->data[1]].unk2_1 = 0; + sub_80DCB78(sprite->data[0]); + sub_80DCBD0(); +} + +void sub_80DCD08(void) +{ + if(gHeap[0x1A000] == 1) + gHeap[0x1A000] = 0; + else + gHeap[0x1A000] = 1; + + if(gHeap[0x1A000] == 0) + { + sub_80DAEA4(); + sub_80DB2BC(); + } + else + sub_80DCD48(); +} + +#ifdef NONMATCHING +void sub_80DCD48(void) +{ + u8 r5 = 0; + u8 sp8[8]; + + if (gUnknown_020322D5 != 0) + { + u8 i; + s16 r2; + + + for (i = 0; i < 4; i++) + { + r2 = sContestantStatus[i].unk4; + if (r2 < 0) + { + r2 = -r2; + sp8[0] = CHAR_HYPHEN; + r5++; + } + ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); + Text_InitWindowAndPrintText( + &gUnknown_03004210, + sp8, + 592 + gUnknown_02039F26[i] * 22, + gUnknown_083CA310[gUnknown_02039F26[i]][0], + gUnknown_083CA310[gUnknown_02039F26[i]][1]); + r5 = 0; + } + for (i = 0; i < 4; i++) + { + r2 = sContestantStatus[i].appeal2; + if (r2 < 0) + { + r2 = -r2; + sp8[0] = CHAR_HYPHEN; + r5++; + } + ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); + Text_InitWindowAndPrintText( + &gUnknown_03004210, + sp8, + 512 + gUnknown_02039F26[i] * 20, + gUnknown_083CA308[gUnknown_02039F26[i]][0], + gUnknown_083CA308[gUnknown_02039F26[i]][1]); + r5 = 0; + } + sub_80AEB30(); + } +} +#else +NAKED +void sub_80DCD48(void) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + sub sp, 0xC\n\ + ldr r0, =gUnknown_020322D5\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _080DCE44\n\ + ldr r0, =gHeap\n\ + movs r1, 0xD0\n\ + lsls r1, 9\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _080DCE44\n\ + cmp r0, 0\n\ + blt _080DCD7C\n\ + cmp r0, 0x3\n\ + bgt _080DCD7C\n\ + cmp r0, 0x2\n\ + blt _080DCD7C\n\ + bl sub_80DF750\n\ + b _080DCE44\n\ + .pool\n\ +_080DCD7C:\n\ + movs r5, 0\n\ +_080DCD7E:\n\ + adds r0, r5, 0\n\ + movs r1, 0\n\ + bl FillWindowPixelBuffer\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, 0x3\n\ + bls _080DCD7E\n\ + movs r5, 0\n\ +_080DCD92:\n\ + ldr r0, =gContestResources\n\ + ldr r0, [r0]\n\ + ldr r1, [r0, 0x4]\n\ + lsls r0, r5, 3\n\ + subs r0, r5\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + add r2, sp, 0x4\n\ + ldrh r4, [r0, 0x4]\n\ + movs r1, 0x4\n\ + ldrsh r0, [r0, r1]\n\ + cmp r0, 0\n\ + bge _080DCDBC\n\ + negs r0, r0\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r0, r2, 0\n\ + ldr r1, =gText_OneDash\n\ + bl StringCopy\n\ + adds r2, r0, 0\n\ +_080DCDBC:\n\ + lsls r1, r4, 16\n\ + asrs r1, 16\n\ + adds r0, r2, 0\n\ + movs r2, 0\n\ + movs r3, 0x4\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gUnknown_02039F26\n\ + adds r0, r5, r0\n\ + ldrb r0, [r0]\n\ + movs r1, 0x7\n\ + str r1, [sp]\n\ + add r1, sp, 0x4\n\ + movs r2, 0x37\n\ + movs r3, 0x1\n\ + bl Contest_PrintTextToBg0WindowAt\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, 0x3\n\ + bls _080DCD92\n\ + movs r5, 0\n\ +_080DCDEA:\n\ + ldr r0, =gContestResources\n\ + ldr r0, [r0]\n\ + ldr r1, [r0, 0x4]\n\ + lsls r0, r5, 3\n\ + subs r0, r5\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + add r2, sp, 0x4\n\ + ldrh r4, [r0, 0x2]\n\ + movs r1, 0x2\n\ + ldrsh r0, [r0, r1]\n\ + cmp r0, 0\n\ + bge _080DCE14\n\ + negs r0, r0\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r0, r2, 0\n\ + ldr r1, =gText_OneDash\n\ + bl StringCopy\n\ + adds r2, r0, 0\n\ +_080DCE14:\n\ + lsls r1, r4, 16\n\ + asrs r1, 16\n\ + adds r0, r2, 0\n\ + movs r2, 0\n\ + movs r3, 0x4\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gUnknown_02039F26\n\ + adds r0, r5, r0\n\ + ldrb r0, [r0]\n\ + movs r1, 0x7\n\ + str r1, [sp]\n\ + add r1, sp, 0x4\n\ + movs r2, 0x5\n\ + movs r3, 0x1\n\ + bl Contest_PrintTextToBg0WindowAt\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + cmp r5, 0x3\n\ + bls _080DCDEA\n\ + bl sub_80DB2BC\n\ +_080DCE44:\n\ + add sp, 0xC\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_80DCE58(u8 a) +{ + u8 sp0[4]; + u16 sp4[4] = {0}; + s32 i; + s32 r2; + s32 r4; + + for (i = 0; i < 4; i++) + { + sp4[i] = Random(); + for (r2 = 0; r2 < i; r2++) + { + if (sp4[i] == sp4[r2]) + { + i--; + break; + } + } + } + + if (a == 0) + { + for (i = 0; i < 4; i++) + { + gUnknown_02039F26[i] = i; + for (r4 = 0; r4 < i; r4++) + { + if (gContestMonConditions[gUnknown_02039F26[r4]] < gContestMonConditions[i] + || (gContestMonConditions[gUnknown_02039F26[r4]] == gContestMonConditions[i] && sp4[gUnknown_02039F26[r4]] < sp4[i])) + { + for (r2 = i; r2 > r4; r2--) + gUnknown_02039F26[r2] = gUnknown_02039F26[r2 - 1]; + gUnknown_02039F26[r4] = i; + break; + } + } + if (r4 == i) + gUnknown_02039F26[i] = i; + } + memcpy(sp0, gUnknown_02039F26, sizeof(sp0)); + for (i = 0; i < 4; i++) + gUnknown_02039F26[sp0[i]] = i; + } + else + { + memset(sp0, 0xFF, sizeof(sp0)); + for (i = 0; i < 4; i++) + { + u8 r2 = sContestantStatus[i].unkB_0; + + while (1) + { + u8 *ptr = &sp0[r2]; + if (*ptr == 0xFF) + { + *ptr = i; + gUnknown_02039F26[i] = r2; + break; + } + r2++; + } + } + for (i = 0; i < 3; i++) + { + for (r4 = 3; r4 > i; r4--) + { + if (sContestantStatus[r4 - 1].unkB_0 == sContestantStatus[r4].unkB_0 + && gUnknown_02039F26[r4 - 1] < gUnknown_02039F26[r4] + && sp4[r4 - 1] < sp4[r4]) + { + u8 temp = gUnknown_02039F26[r4]; + + gUnknown_02039F26[r4] = gUnknown_02039F26[r4 - 1]; + gUnknown_02039F26[r4 - 1] = temp; + } + } + } + } +} + +void sub_80DD04C(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + LoadPalette(&gHeap[0x1A004] + (i + 5) * 32, (gUnknown_02039F26[i] + 5) * 16, 32); + } + sub_80DAEA4(); +} + +#ifdef NONMATCHING +void sub_80DD080(u8 contestant) +{ + bool8 r8; + s32 i; + + sContestantStatus[contestant].appeal2 = 0; + sContestantStatus[contestant].appeal1 = 0; + r8 = sub_80DBA68(contestant); + if (r8) + { + u16 move = sContestantStatus[contestant].currMove; + u8 effect = gContestMoves[move].effect; + u8 rnd; + + sContestantStatus[contestant].moveCategory = gContestMoves[sContestantStatus[contestant].currMove].contestCategory; + if (sContestantStatus[contestant].currMove == sContestantStatus[contestant].prevMove && sContestantStatus[contestant].currMove != MOVE_NONE) + { + sContestantStatus[contestant].disappointedRepeat = TRUE; + sContestantStatus[contestant].moveRepeatCount++; + } + else + { + sContestantStatus[contestant].moveRepeatCount = 0; + } + sContestantStatus[contestant].appeal1 = gContestEffects[effect].appeal; + sContestantStatus[contestant].appeal2 = gContestEffects[effect].appeal; + shared192D0.jam = gContestEffects[effect].jam; + shared192D0.jam2 = shared192D0.jam; + shared192D0.jam2 = gContestEffects[effect].jam; + + shared192D0.contestant = contestant; + for (i = 0; i < 4; i++) + { + sContestantStatus[i].jam = 0; + shared192D0.unnervedPokes[i] = 0; + } + if (sContestantStatus[contestant].hasJudgesAttention && AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove) == 0) + sContestantStatus[contestant].hasJudgesAttention = 0; + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition; + gContestEffectFuncs[effect](); + if (sContestantStatus[contestant].conditionMod == 1) + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition - 10; + else if (sContestantStatus[contestant].appealTripleCondition) + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition * 3; + + + sContestantStatus[contestant].unk16 = 0; + sContestantStatus[contestant].unk15_6 = 0; + if (sub_80DE1E8(contestant)) + { + u8 r2 = AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove); + + if (r2 != 0 && sContestantStatus[contestant].hasJudgesAttention) + { + sContestantStatus[contestant].unk16 = r2; + sContestantStatus[contestant].unk15_6 = 1; + sContestantStatus[contestant].hasJudgesAttention = 0; + sContestantStatus[contestant].unk17 = sContestantStatus[contestant].appeal1 * sContestantStatus[contestant].unk16; + sContestantStatus[contestant].unk15_3 = 1; + } + else + { + if (gContestMoves[sContestantStatus[contestant].currMove].comboStarterId != 0) + { + sContestantStatus[contestant].hasJudgesAttention = 1; + sContestantStatus[contestant].unk15_6 = 1; + } + else + { + sContestantStatus[contestant].hasJudgesAttention = 0; + } + } + } + if (sContestantStatus[contestant].disappointedRepeat) + sContestantStatus[contestant].unk18 = (sContestantStatus[contestant].moveRepeatCount + 1) * 10; + if (sContestantStatus[contestant].nervous) + { + sContestantStatus[contestant].hasJudgesAttention = 0; + sContestantStatus[contestant].appeal2 = 0; + sContestantStatus[contestant].appeal1 = 0; + } + shared19328.bits_0 = Contest_GetMoveExcitement(sContestantStatus[contestant].currMove); + if (sContestantStatus[contestant].overrideCategoryExcitementMod) + shared19328.bits_0 = 1; + if (shared19328.bits_0 > 0) + { + if (sContest.applauseLevel + shared19328.bits_0 > 4) + shared19328.unk2 = 60; + else + shared19328.unk2 = 10; + } + else + { + shared19328.unk2 = 0; + } + + rnd = Random() % 3; + for (i = 0; i < 4; i++) + { + if (i != contestant) + { + if (rnd == 0) + break; + rnd--; + } + } + sContestantStatus[contestant].unk1B = i; + } +} + +#else +NAKED +void sub_80DD080(u8 contestant) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + ldr r4, =gContestResources\n\ + ldr r3, [r4]\n\ + ldr r1, [r3, 0x4]\n\ + lsls r7, r6, 3\n\ + subs r0, r7, r6\n\ + lsls r5, r0, 2\n\ + adds r1, r5, r1\n\ + movs r2, 0\n\ + strh r2, [r1, 0x2]\n\ + ldr r0, [r3, 0x4]\n\ + adds r0, r5, r0\n\ + strh r2, [r0]\n\ + adds r0, r6, 0\n\ + bl sub_80DBA68\n\ + lsls r0, 24\n\ + mov r8, r4\n\ + cmp r0, 0\n\ + bne _080DD0B4\n\ + b _080DD3C4\n\ +_080DD0B4:\n\ + ldr r0, [r4]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r5, r1\n\ + ldrh r0, [r1, 0x6]\n\ + ldr r2, =gContestMoves\n\ + lsls r0, 3\n\ + adds r0, r2\n\ + ldrb r2, [r0]\n\ + mov r9, r2\n\ + ldrb r0, [r0, 0x1]\n\ + lsls r0, 29\n\ + lsrs r0, 29\n\ + strb r0, [r1, 0xA]\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x4]\n\ + adds r2, r5, r0\n\ + ldrh r0, [r2, 0x6]\n\ + ldrh r1, [r2, 0x8]\n\ + cmp r0, r1\n\ + bne _080DD110\n\ + cmp r0, 0\n\ + beq _080DD110\n\ + ldrb r0, [r2, 0x15]\n\ + movs r1, 0x1\n\ + orrs r0, r1\n\ + strb r0, [r2, 0x15]\n\ + ldr r0, [r4]\n\ + ldr r2, [r0, 0x4]\n\ + adds r2, r5, r2\n\ + ldrb r3, [r2, 0xB]\n\ + lsls r1, r3, 25\n\ + lsrs r1, 29\n\ + adds r1, 0x1\n\ + movs r0, 0x7\n\ + ands r1, r0\n\ + lsls r1, 4\n\ + movs r0, 0x71\n\ + negs r0, r0\n\ + ands r0, r3\n\ + orrs r0, r1\n\ + strb r0, [r2, 0xB]\n\ + b _080DD12C\n\ + .pool\n\ +_080DD110:\n\ + ldr r4, =gContestResources\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x4]\n\ + lsls r3, r6, 3\n\ + subs r1, r3, r6\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r2, [r1, 0xB]\n\ + movs r0, 0x71\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1, 0xB]\n\ + mov r8, r4\n\ + adds r7, r3, 0\n\ +_080DD12C:\n\ + mov r2, r8\n\ + ldr r4, [r2]\n\ + ldr r2, [r4, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r0, 2\n\ + adds r2, r0, r2\n\ + ldr r3, =gContestEffects\n\ + mov r1, r9\n\ + lsls r5, r1, 2\n\ + adds r3, r5, r3\n\ + ldrb r1, [r3, 0x1]\n\ + strh r1, [r2]\n\ + ldr r1, [r4, 0x4]\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + strh r1, [r0, 0x2]\n\ + ldr r1, [r4, 0x8]\n\ + ldrb r0, [r3, 0x2]\n\ + strh r0, [r1, 0x4]\n\ + ldr r1, [r4, 0x8]\n\ + ldrh r0, [r1, 0x4]\n\ + strh r0, [r1, 0x6]\n\ + ldr r0, [r4, 0x8]\n\ + strb r6, [r0, 0x11]\n\ + movs r2, 0\n\ + mov r9, r5\n\ + mov r4, r8\n\ + movs r3, 0\n\ + movs r1, 0\n\ +_080DD166:\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x4]\n\ + adds r0, r1, r0\n\ + strb r3, [r0, 0xE]\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x8]\n\ + adds r0, 0xD\n\ + adds r0, r2\n\ + strb r3, [r0]\n\ + adds r1, 0x1C\n\ + adds r2, 0x1\n\ + cmp r2, 0x3\n\ + ble _080DD166\n\ + ldr r5, =gContestResources\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r4, r0, 2\n\ + adds r2, r4, r1\n\ + ldrb r1, [r2, 0x15]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD1B4\n\ + ldrh r0, [r2, 0x8]\n\ + ldrh r1, [r2, 0x6]\n\ + bl AreMovesContestCombo\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _080DD1B4\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r2, [r1, 0x15]\n\ + movs r0, 0x11\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x15]\n\ +_080DD1B4:\n\ + ldr r0, =gContestEffectFuncs\n\ + add r0, r9\n\ + ldr r0, [r0]\n\ + bl _call_via_r0\n\ + ldr r0, =gContestResources\n\ + ldr r0, [r0]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r0, 2\n\ + adds r2, r0, r1\n\ + ldrb r1, [r2, 0x10]\n\ + movs r0, 0x30\n\ + ands r0, r1\n\ + cmp r0, 0x10\n\ + bne _080DD1EC\n\ + ldrh r1, [r2, 0x2]\n\ + subs r1, 0xA\n\ + movs r0, 0xD\n\ + ldrsb r0, [r2, r0]\n\ + b _080DD206\n\ + .pool\n\ +_080DD1EC:\n\ + ldrb r1, [r2, 0x11]\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD200\n\ + movs r1, 0xD\n\ + ldrsb r1, [r2, r1]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + b _080DD204\n\ +_080DD200:\n\ + movs r0, 0xD\n\ + ldrsb r0, [r2, r0]\n\ +_080DD204:\n\ + ldrh r1, [r2, 0x2]\n\ +_080DD206:\n\ + adds r0, r1\n\ + strh r0, [r2, 0x2]\n\ + ldr r5, =gContestResources\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r4, r0, 2\n\ + adds r1, r4, r1\n\ + movs r0, 0\n\ + strb r0, [r1, 0x16]\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r2, [r1, 0x15]\n\ + movs r0, 0x41\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x15]\n\ + adds r0, r6, 0\n\ + bl sub_80DE1E8\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080DD2E2\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrh r0, [r1, 0x8]\n\ + ldrh r1, [r1, 0x6]\n\ + bl AreMovesContestCombo\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + cmp r3, 0\n\ + beq _080DD29C\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + adds r2, r4, r0\n\ + ldrb r1, [r2, 0x15]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD29C\n\ + strb r3, [r2, 0x16]\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r0, [r1, 0x15]\n\ + movs r2, 0x40\n\ + orrs r0, r2\n\ + strb r0, [r1, 0x15]\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r2, [r1, 0x15]\n\ + movs r0, 0x11\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x15]\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + adds r0, r4, r0\n\ + movs r1, 0\n\ + ldrsh r2, [r0, r1]\n\ + ldrb r1, [r0, 0x16]\n\ + muls r1, r2\n\ + strb r1, [r0, 0x17]\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r0, [r1, 0x15]\n\ + movs r2, 0x8\n\ + b _080DD2C8\n\ + .pool\n\ +_080DD29C:\n\ + ldr r2, =gContestMoves\n\ + ldr r5, =gContestResources\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r4, r0, 2\n\ + adds r3, r4, r1\n\ + ldrh r0, [r3, 0x6]\n\ + lsls r0, 3\n\ + adds r0, r2\n\ + ldrb r0, [r0, 0x2]\n\ + cmp r0, 0\n\ + beq _080DD2D8\n\ + ldrb r0, [r3, 0x15]\n\ + movs r1, 0x10\n\ + orrs r0, r1\n\ + strb r0, [r3, 0x15]\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + adds r1, r4, r1\n\ + ldrb r0, [r1, 0x15]\n\ + movs r2, 0x40\n\ +_080DD2C8:\n\ + orrs r0, r2\n\ + strb r0, [r1, 0x15]\n\ + b _080DD2E2\n\ + .pool\n\ +_080DD2D8:\n\ + ldrb r1, [r3, 0x15]\n\ + movs r0, 0x11\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r3, 0x15]\n\ +_080DD2E2:\n\ + ldr r5, =gContestResources\n\ + ldr r0, [r5]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r4, r0, 2\n\ + adds r2, r4, r1\n\ + ldrb r1, [r2, 0x15]\n\ + movs r0, 0x1\n\ + mov r8, r0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD30A\n\ + ldrb r0, [r2, 0xB]\n\ + lsls r0, 25\n\ + lsrs r0, 29\n\ + adds r0, 0x1\n\ + lsls r1, r0, 2\n\ + adds r1, r0\n\ + lsls r1, 1\n\ + strb r1, [r2, 0x18]\n\ +_080DD30A:\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + adds r2, r4, r0\n\ + ldrb r1, [r2, 0xC]\n\ + mov r0, r8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD334\n\ + ldrb r1, [r2, 0x15]\n\ + movs r0, 0x11\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r2, 0x15]\n\ + ldr r2, [r5]\n\ + ldr r0, [r2, 0x4]\n\ + adds r0, r4, r0\n\ + movs r1, 0\n\ + strh r1, [r0, 0x2]\n\ + ldr r0, [r2, 0x4]\n\ + adds r0, r4, r0\n\ + strh r1, [r0]\n\ +_080DD334:\n\ + ldr r0, [r5]\n\ + ldr r0, [r0, 0x4]\n\ + adds r0, r4, r0\n\ + ldrh r0, [r0, 0x6]\n\ + bl Contest_GetMoveExcitement\n\ + ldr r1, [r5]\n\ + ldr r1, [r1, 0x10]\n\ + strb r0, [r1]\n\ + ldr r2, [r5]\n\ + ldr r0, [r2, 0x4]\n\ + adds r0, r4, r0\n\ + ldrb r1, [r0, 0x11]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DD35C\n\ + ldr r0, [r2, 0x10]\n\ + mov r1, r8\n\ + strb r1, [r0]\n\ +_080DD35C:\n\ + ldr r1, [r5]\n\ + ldr r3, [r1, 0x10]\n\ + movs r0, 0\n\ + ldrsb r0, [r3, r0]\n\ + cmp r0, 0\n\ + ble _080DD388\n\ + ldr r0, [r1]\n\ + ldrb r0, [r0, 0x13]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + movs r1, 0\n\ + ldrsb r1, [r3, r1]\n\ + adds r0, r1\n\ + cmp r0, 0x4\n\ + ble _080DD384\n\ + movs r0, 0x3C\n\ + b _080DD38A\n\ + .pool\n\ +_080DD384:\n\ + movs r0, 0xA\n\ + b _080DD38A\n\ +_080DD388:\n\ + movs r0, 0\n\ +_080DD38A:\n\ + strb r0, [r3, 0x2]\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + movs r2, 0\n\ + b _080DD3AE\n\ +_080DD3A2:\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ +_080DD3A8:\n\ + adds r2, 0x1\n\ + cmp r2, 0x3\n\ + bgt _080DD3B6\n\ +_080DD3AE:\n\ + cmp r2, r6\n\ + beq _080DD3A8\n\ + cmp r0, 0\n\ + bne _080DD3A2\n\ +_080DD3B6:\n\ + ldr r0, =gContestResources\n\ + ldr r0, [r0]\n\ + ldr r1, [r0, 0x4]\n\ + subs r0, r7, r6\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + strb r2, [r0, 0x1B]\n\ +_080DD3C4:\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void SetContestantEffectStringID(u8 a, u8 b) +{ + sContestantStatus[a].effectStringId = b; +} + +void SetContestantEffectStringID2(u8 a, u8 b) +{ + sContestantStatus[a].effectStringId2 = b; +} + +void SetStartledString(u8 contestant, u8 jam) +{ + if (jam >= 60) + SetContestantEffectStringID(contestant, CONTEST_STRING_TRIPPED_OVER); + else if (jam >= 40) + SetContestantEffectStringID(contestant, CONTEST_STRING_LEAPT_UP); + else if (jam >= 30) + SetContestantEffectStringID(contestant, CONTEST_STRING_UTTER_CRY); + else if (jam >= 20) + SetContestantEffectStringID(contestant, CONTEST_STRING_TURNED_BACK); + else if (jam >= 10) + SetContestantEffectStringID(contestant, CONTEST_STRING_LOOKED_DOWN); +} + +void sub_80DD45C(u8 contestant, u8 stringId) +{ + StringCopy(gStringVar1, gContestMons[contestant].nickname); + StringCopy(gStringVar2, gMoveNames[sContestantStatus[contestant].currMove]); + if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_COOL) + StringCopy(gStringVar3, gText_Contest_Shyness); + else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_BEAUTY) + StringCopy(gStringVar3, gText_Contest_Anxiety); + else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_CUTE) + StringCopy(gStringVar3, gText_Contest_Laziness); + else if (gContestMoves[sContestantStatus[shared192D0.contestant].currMove].contestCategory == CONTEST_CATEGORY_SMART) + StringCopy(gStringVar3, gText_Contest_Hesitancy); + else + StringCopy(gStringVar3, gText_Contest_Fear); + StringExpandPlaceholders(gStringVar4, gUnknown_08587E10[stringId]); + sub_80DB89C(); + Contest_StartTextPrinter(gStringVar4, 1); +} + +void MakeContestantNervous(u8 p) +{ + sContestantStatus[p].nervous = 1; + sContestantStatus[p].currMove = MOVE_NONE; +} + +void sub_80DD590(void) +{ + u8 r12 = 0; + s32 i; + s32 j; + u8 sp0[4]; + u8 sp4[4]; + + for (i = 0; i < 4; i++) + { + sp0[i] = gUnknown_02039F26[i]; + sp4[i] = 0; + } + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + if (sContestantStatus[j].nextTurnOrder == i) + { + sp0[j] = i; + sp4[j] = 1; + break; + } + } + if (j == 4) + { + for (j = 0; j < 4; j++) + { + if (sp4[j] == 0 && sContestantStatus[j].nextTurnOrder == 0xFF) + { + r12 = j; + j++; + break; + } + } + for (; j < 4; j++) + { + if (sp4[j] == 0 && sContestantStatus[j].nextTurnOrder == 0xFF + && gUnknown_02039F26[r12] > gUnknown_02039F26[j]) + r12 = j; + } + sp0[r12] = i; + sp4[r12] = 1; + } + } + + for (i = 0; i < 4; i++) + { + shared192D0.turnOrder[i] = sp0[i]; + sContestantStatus[i].nextTurnOrder = 0xFF; + sContestantStatus[i].turnOrderMod = 0; + gUnknown_02039F26[i] = sp0[i]; + } +} + +void sub_80DD6DC(struct Sprite *sprite) +{ + if (sprite->data[1]++ > 84) + { + sprite->data[1] = 0; + sprite->invisible = TRUE; + sprite->callback = SpriteCallbackDummy; + sContest.unk1920A_4 = 0; + } +} + +void sub_80DD720(u8 a) +{ + u8 spriteId = sContest.unk19216; + + switch (a) + { + case 0: + case 1: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0]; + PlaySE(SE_HAZURE); + break; + case 2: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 4; + PlaySE(SE_SEIKAI); + break; + case 3: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 8; + PlaySE(SE_SEIKAI); + break; + case 4: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 12; + PlaySE(SE_TK_WARPIN); + break; + case 5: // exactly the same as case 4 + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 12; + PlaySE(SE_TK_WARPIN); + break; + case 6: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 16; + PlaySE(SE_TK_WARPIN); + break; + case 8: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 24; + PlaySE(SE_W215); + break; + case 7: + default: + gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 20; + PlaySE(SE_TK_WARPIN); + break; + } + gSprites[spriteId].data[1] = 0; + gSprites[spriteId].invisible = FALSE; + gSprites[spriteId].callback = sub_80DD6DC; + sContest.unk1920A_4 = 1; +} + +void sub_80DD940(void) +{ + s32 i; + + for (i = 0; i < 5; i++) + { + const u8 *src; + + if (i < sContest.applauseLevel) + src = gContestApplauseMeterGfx + 64; + else + src = gContestApplauseMeterGfx; + CpuSet(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 0x04000008); + CpuSet(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 0x04000008); + + if (sContest.applauseLevel > 4) + sub_80DDA20(); + } +} + +s8 Contest_GetMoveExcitement(u16 move) +{ + return gContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory]; +} + +u8 sub_80DDA20(void) +{ + u8 taskId = CreateTask(c3_08130B10, 10); + + gTasks[taskId].data[1] = 1; + gTasks[taskId].data[2] = IndexOfSpritePaletteTag(0x0ABE2); + return taskId; +} + +void c3_08130B10(u8 taskId) +{ + if (++gTasks[taskId].data[0] == 1) + { + gTasks[taskId].data[0] = 0; + if (gTasks[taskId].data[3] == 0) + gTasks[taskId].data[4]++; + else + gTasks[taskId].data[4]--; + BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, gTasks[taskId].data[4], RGB(31, 31, 31)); + if (gTasks[taskId].data[4] == 0 || gTasks[taskId].data[4] == 16) + { + gTasks[taskId].data[3] ^= 1; + if (sContest.applauseLevel < 5) + { + BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, 0, RGB(31, 0, 0)); + DestroyTask(taskId); + } + } + } +} + +void sub_80DDB0C(void) +{ + CreateTask(sub_80DDB6C, 10); + gSprites[sContest.applauseMeterSpriteId].pos2.x = -70; + gSprites[sContest.applauseMeterSpriteId].invisible = FALSE; + sContest.unk1920A_6 = 1; +} + +void sub_80DDB6C(u8 taskId) +{ + struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; + + gTasks[taskId].data[10] += 1664; + sprite->pos2.x += gTasks[taskId].data[10] >> 8; + gTasks[taskId].data[10] = gTasks[taskId].data[10] & 0xFF; + if (sprite->pos2.x > 0) + sprite->pos2.x = 0; + if (sprite->pos2.x == 0) + { + sContest.unk1920A_6 = 0; + DestroyTask(taskId); + } +} + +void sub_80DDBE8(void) +{ + if (gSprites[sContest.applauseMeterSpriteId].invisible == TRUE) + { + sContest.unk1920A_6 = 0; + } + else + { + CreateTask(task08_080CD1CC, 10); + gSprites[sContest.applauseMeterSpriteId].pos2.x = 0; + sContest.unk1920A_6 = 1; + } +} + +void task08_080CD1CC(u8 taskId) +{ + struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; + + gTasks[taskId].data[10] += 1664; + sprite->pos2.x -= gTasks[taskId].data[10] >> 8; + gTasks[taskId].data[10] = gTasks[taskId].data[10] & 0xFF; + if (sprite->pos2.x < -70) + sprite->pos2.x = -70; + if (sprite->pos2.x == -70) + { + sprite->invisible = TRUE; + sContest.unk1920A_6 = 0; + DestroyTask(taskId); + } +} + +void sub_80DDCDC(s8 a) +{ + u8 taskId = CreateTask(sub_80DDD20, 5); + + gTasks[taskId].data[0] = a; + sContest.unk1920A_5 = 1; +} + +void sub_80DDD20(u8 taskId) +{ + switch (gTasks[taskId].data[10]) + { + case 0: + sub_80DDB0C(); + gTasks[taskId].data[10]++; + break; + case 1: + if (!sContest.unk1920A_6) + { + gTasks[taskId].data[10]++; + } + break; + case 2: + if (gTasks[taskId].data[11]++ > 20) + { + gTasks[taskId].data[11] = 0; + sub_80DD940(); + sContest.unk1920A_5 = 0; + DestroyTask(taskId); + } + break; + } +} + +void unref_sub_80DDDA8(void) +{ + gSprites[sContest.applauseMeterSpriteId].pos2.x = 0; + gSprites[sContest.applauseMeterSpriteId].invisible = FALSE; +} + +void unref_sub_80DDDE4(void) +{ + gSprites[sContest.applauseMeterSpriteId].invisible = TRUE; +} + +void sub_80DDE0C(void) +{ + CreateTask(sub_80DDE30, 15); + sContest.unk1920A_7 = 1; +} + +void sub_80DDE30(u8 taskId) +{ + if (gTasks[taskId].data[10]++ > 6) + { + gTasks[taskId].data[10] = 0; + if (gTasks[taskId].data[11] == 0) + { + RequestDma3Copy(shared16800, (void *)(VRAM + 0x2000), 0x1000, 1); + } + else + { + RequestDma3Copy(shared15800, (void *)(VRAM + 0x2000), 0x1000, 1); + gTasks[taskId].data[12]++; + } + + gTasks[taskId].data[11] ^= 1; + + if (gTasks[taskId].data[12] == 9) + { + sContest.unk1920A_7 = 0; + DestroyTask(taskId); + } + } +} + +#define tBlendColor data[0] +#define tBlendCoeff data[1] + +void sub_80DDED0(s8 a, s8 b) +{ + u8 taskId = CreateTask(sub_80DDF80, 10); + u16 blendColor; + u8 blendCoeff; + u8 r3; + + if (a > 0) + { + blendColor = RGB(30, 27, 8); + if (b > 0) + { + blendCoeff = 0; + r3 = sContest.applauseLevel * 3; + } + else + { + blendCoeff = sContest.applauseLevel * 3; + r3 = 0; + } + } + else + { + blendColor = 0; + if (b > 0) + { + blendCoeff = 0; + r3 = 12; + } + else + { + blendCoeff = 12; + r3 = 0; + } + } + gTasks[taskId].tBlendColor = blendColor; + gTasks[taskId].tBlendCoeff = blendCoeff; + gTasks[taskId].data[2] = b; + gTasks[taskId].data[3] = r3; + sContest.unk1920B_0 = 0; +} + +void sub_80DDF80(u8 taskId) +{ + if (gTasks[taskId].data[10]++ >= 0) + { + gTasks[taskId].data[10] = 0; + if (gTasks[taskId].data[2] > 0) + gTasks[taskId].tBlendCoeff++; + else + gTasks[taskId].tBlendCoeff--; + BlendPalette(17, 1, gTasks[taskId].tBlendCoeff, gTasks[taskId].tBlendColor); + BlendPalette(26, 1, gTasks[taskId].tBlendCoeff, gTasks[taskId].tBlendColor); + if (gTasks[taskId].tBlendCoeff == gTasks[taskId].data[3]) + { + DestroyTask(taskId); + sContest.unk1920B_0 = 0; + } + } +} + +#undef tBlendColor +#undef tBlendCoeff + +void sub_80DE008(bool8 a) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (sContestantStatus[i].turnOrderMod != 0 && a) + { + CpuSet( + GetTurnOrderNumberGfx(i), + (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), + 0x04000008); + gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gUnknown_02039F26[i]]; + gSprites[gContestResources->field_14[i].unk1].invisible = FALSE; + } + else + { + gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; + } + } +} + +const u8 *GetTurnOrderNumberGfx(u8 contestant) +{ + if (sContestantStatus[contestant].turnOrderMod != 1) + return gContestNextTurnRandomGfx; + else + return gContestNextTurnNumbersGfx + sContestantStatus[contestant].nextTurnOrder * 32; +} + +void sub_80DE12C(void) +{ + s32 r7 = 0; + u32 r10 = 2; + u32 r8 = 1; + u32 r9 = 0x11; + + for(r7 = 0; r7 < 4; r7++) + { + u32 r6; + u16 var; + if(shared192D0.unnervedPokes[r7] != 0) + if(Contest_IsMonsTurnDisabled(r7) == FALSE) + { + r6 = gUnknown_02039F26[r7] * 5 + 2; + var = sub_80DB748(3); + ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6, r10, r8, r9, r8); + var += 16; + ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6 + 1, r10, r8, r9, r8); + PlaySE(SE_C_PASI); + } + } +} + +bool8 sub_80DE1E8(u8 a) +{ + if (sContestantStatus[a].disappointedRepeat || sContestantStatus[a].nervous) + return FALSE; + else + return TRUE; +} + +#ifdef NONMATCHING +void sub_80DE224(void) +{ + s32 i; + u16 bg0Cnt; + u16 bg1Cnt; + u16 bg2Cnt; + u16 var; + + bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + ((struct BgCnt *)&bg1Cnt)->priority = 0; + ((struct BgCnt *)&bg1Cnt)->screenSize = 2; + ((struct BgCnt *)&bg1Cnt)->areaOverflowMode = 0; + ((struct BgCnt *)&bg1Cnt)->charBaseBlock = 0; + + + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + + bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT); + ((struct BgCnt *)&bg0Cnt)->priority = 0; + + bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT); + ((struct BgCnt *)&bg2Cnt)->priority = 0; + + SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt); + SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt); + + gBattle_BG1_X = DISPLAY_WIDTH; + gBattle_BG1_Y = DISPLAY_HEIGHT; + SetGpuReg(REG_OFFSET_BG1HOFS, DISPLAY_WIDTH); + SetGpuReg(REG_OFFSET_BG1VOFS, DISPLAY_HEIGHT); + var = 0; + + CpuSet(&var, &sContest.unk19214, 0x05000400); + + CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); + Contest_SetBgCopyFlags(1); + + for (i = 0; i < 4; i++) + { + gSprites[gContestResources->field_14[i].unk0].oam.priority = 1; + gSprites[gContestResources->field_14[i].unk1].oam.priority = 1; + } + + /* ((vBgCnt *)®_BG1CNT)->priority = 0; + ((vBgCnt *)®_BG1CNT)->screenSize = 1; + ((vBgCnt *)®_BG1CNT)->areaOverflowMode = 0; + + + + DmaClear32(3, (void *)(VRAM + 0xF000), 0x1000); + LZDecompressVram(gUnknown_08D17C3C, (void *)(VRAM + 0xF000)); + + ((vBgCnt *)®_BG1CNT)->charBaseBlock = 0; + + for (i = 0; i < 4; i++) + { + gSprites[shared19338[i].unk0].oam.priority = 1; + gSprites[shared19338[i].unk1].oam.priority = 1; + } + + ((vBgCnt *)®_BG2CNT)->priority = 1; + ((vBgCnt *)®_BG0CNT)->priority = 1; + ((vBgCnt *)®_BG1CNT)->screenSize = 2; */ +} +#else +NAKED +void sub_80DE224(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0xC\n\ + movs r0, 0xA\n\ + bl GetGpuReg\n\ + mov r1, sp\n\ + strh r0, [r1]\n\ + mov r2, sp\n\ + ldrb r1, [r2]\n\ + movs r4, 0x4\n\ + negs r4, r4\n\ + adds r0, r4, 0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + ldrb r1, [r2, 0x1]\n\ + movs r0, 0x3F\n\ + ands r0, r1\n\ + movs r1, 0x80\n\ + orrs r0, r1\n\ + strb r0, [r2, 0x1]\n\ + ldrb r1, [r2, 0x1]\n\ + movs r0, 0x21\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r2, 0x1]\n\ + ldrb r1, [r2]\n\ + movs r0, 0xD\n\ + negs r0, r0\n\ + mov r8, r0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + mov r0, sp\n\ + ldrh r1, [r0]\n\ + movs r0, 0xA\n\ + bl SetGpuReg\n\ + movs r0, 0x8\n\ + bl GetGpuReg\n\ + mov r6, sp\n\ + adds r6, 0x2\n\ + strh r0, [r6]\n\ + movs r0, 0xC\n\ + bl GetGpuReg\n\ + add r5, sp, 0x4\n\ + strh r0, [r5]\n\ + ldrb r1, [r6]\n\ + adds r0, r4, 0\n\ + ands r0, r1\n\ + movs r1, 0x1\n\ + orrs r0, r1\n\ + strb r0, [r6]\n\ + ldrb r0, [r5]\n\ + ands r4, r0\n\ + orrs r4, r1\n\ + strb r4, [r5]\n\ + ldrh r1, [r6]\n\ + movs r0, 0x8\n\ + bl SetGpuReg\n\ + ldrh r1, [r5]\n\ + movs r0, 0xC\n\ + bl SetGpuReg\n\ + ldr r1, =gBattle_BG1_X\n\ + movs r0, 0xF0\n\ + strh r0, [r1]\n\ + ldr r4, =gBattle_BG1_Y\n\ + movs r0, 0xA0\n\ + strh r0, [r4]\n\ + movs r0, 0x14\n\ + movs r1, 0xF0\n\ + bl SetGpuReg\n\ + ldrh r1, [r4]\n\ + movs r0, 0x16\n\ + bl SetGpuReg\n\ + movs r0, 0\n\ + str r0, [sp, 0x8]\n\ + add r0, sp, 0x8\n\ + ldr r4, =gContestResources\n\ + ldr r1, [r4]\n\ + ldr r1, [r1, 0x28]\n\ + ldr r2, =0x05000400\n\ + bl CpuSet\n\ + ldr r1, =gUnknown_08C17980\n\ + movs r0, 0x1\n\ + movs r2, 0\n\ + movs r3, 0\n\ + bl CopyToBgTilemapBuffer\n\ + movs r0, 0x1\n\ + bl Contest_SetBgCopyFlags\n\ + movs r5, 0\n\ + ldr r7, =gSprites\n\ + movs r6, 0x4\n\ +_080DE2F0:\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x14]\n\ + lsls r3, r5, 2\n\ + adds r0, r3, r0\n\ + ldrb r0, [r0]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r7\n\ + ldrb r2, [r1, 0x5]\n\ + mov r0, r8\n\ + ands r0, r2\n\ + orrs r0, r6\n\ + strb r0, [r1, 0x5]\n\ + ldr r0, [r4]\n\ + ldr r0, [r0, 0x14]\n\ + adds r3, r0\n\ + ldrb r0, [r3, 0x1]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r7\n\ + ldrb r2, [r1, 0x5]\n\ + mov r0, r8\n\ + ands r0, r2\n\ + orrs r0, r6\n\ + strb r0, [r1, 0x5]\n\ + adds r5, 0x1\n\ + cmp r5, 0x3\n\ + ble _080DE2F0\n\ + add sp, 0xC\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_80DE350(void) +{ + s32 i; + s16 var; + u16 bg1Cnt; + u8 *spriteID; + u16 something; + + RequestDma3Fill(0,(void *)(VRAM + 0x8000), 0x2000, 0x1); + //DmaClearLarge32(3, (void *)(VRAM + 0x8000), 0x2000, 0x1000); + + /*bg1Cnt = 0; + something = 0; + var = bg1Cnt; + spriteID = (u8 *)&gContestResources;*/ + + var = 0; + + + CpuSet(&var, &gContestResources->field_24[1], 0x05000400); + //CpuSet(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) + Contest_SetBgCopyFlags(1); + + //DmaClear32(3, (void *)(VRAM + 0xF000), 0x1000); + + bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + something = bg1Cnt; + ((struct BgCnt *) &bg1Cnt)->priority = 1; + ((struct BgCnt *) &bg1Cnt)->screenSize = 1; + ((struct BgCnt *) &bg1Cnt)->areaOverflowMode = 0; + ((struct BgCnt *) &bg1Cnt)->charBaseBlock = 2; + + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + + for (i = 0; i < 4; i++) + { + gSprites[gContestResources->field_14[i].unk0].oam.priority = 0; + gSprites[gContestResources->field_14[i].unk1].oam.priority = 0; + } +} +#else +NAKED +void sub_80DE350(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + sub sp, 0x8\n\ + ldr r1, =0x06008000\n\ + movs r2, 0x80\n\ + lsls r2, 6\n\ + movs r0, 0\n\ + movs r3, 0x1\n\ + bl RequestDma3Fill\n\ + movs r5, 0\n\ + str r5, [sp]\n\ + ldr r6, =gContestResources\n\ + ldr r0, [r6]\n\ + ldr r1, [r0, 0x28]\n\ + ldr r2, =0x05000400\n\ + mov r0, sp\n\ + bl CpuSet\n\ + movs r0, 0x1\n\ + bl Contest_SetBgCopyFlags\n\ + movs r0, 0xA\n\ + bl GetGpuReg\n\ + add r3, sp, 0x4\n\ + strh r0, [r3]\n\ + ldrb r1, [r3]\n\ + movs r0, 0x4\n\ + negs r0, r0\n\ + ands r0, r1\n\ + movs r1, 0x1\n\ + orrs r0, r1\n\ + strb r0, [r3]\n\ + mov r1, sp\n\ + adds r1, 0x5\n\ + ldrb r2, [r1]\n\ + movs r0, 0x3F\n\ + ands r0, r2\n\ + strb r0, [r1]\n\ + ldrb r2, [r1]\n\ + movs r0, 0x21\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1]\n\ + ldrb r1, [r3]\n\ + movs r4, 0xD\n\ + negs r4, r4\n\ + adds r0, r4, 0\n\ + ands r0, r1\n\ + movs r1, 0x8\n\ + orrs r0, r1\n\ + strb r0, [r3]\n\ + ldrh r1, [r3]\n\ + movs r0, 0xA\n\ + bl SetGpuReg\n\ + ldr r0, =gBattle_BG1_X\n\ + strh r5, [r0]\n\ + ldr r0, =gBattle_BG1_Y\n\ + strh r5, [r0]\n\ + ldr r7, =gSprites\n\ +_080DE3CA:\n\ + ldr r0, [r6]\n\ + ldr r0, [r0, 0x14]\n\ + lsls r3, r5, 2\n\ + adds r0, r3, r0\n\ + ldrb r0, [r0]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r7\n\ + ldrb r2, [r1, 0x5]\n\ + adds r0, r4, 0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x5]\n\ + ldr r0, [r6]\n\ + ldr r0, [r0, 0x14]\n\ + adds r3, r0\n\ + ldrb r0, [r3, 0x1]\n\ + lsls r1, r0, 4\n\ + adds r1, r0\n\ + lsls r1, 2\n\ + adds r1, r7\n\ + ldrb r2, [r1, 0x5]\n\ + adds r0, r4, 0\n\ + ands r0, r2\n\ + strb r0, [r1, 0x5]\n\ + adds r5, 0x1\n\ + cmp r5, 0x3\n\ + ble _080DE3CA\n\ + add sp, 0x8\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_80DE424(u8 taskId) +{ + gBattle_BG1_X = 0; + gBattle_BG1_Y = DISPLAY_HEIGHT; + PlaySE12WithPanning(SE_C_MAKU_D, 0); + gTasks[taskId].func = sub_80DE464; +} + +void sub_80DE464(u8 taskId) +{ + if ((s16)(gBattle_BG1_Y -= 7) < 0) + gBattle_BG1_Y = 0; + if (gBattle_BG1_Y == 0) + { + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80DE4A8; + } +} + +void sub_80DE4A8(u8 taskId) +{ + s32 i; + + switch (gTasks[taskId].data[0]) + { + case 0: + for (i = 0; i < 4; i++) + sContest.unk19218[i] = gUnknown_02039F26[i]; + sub_80DBF90(); + sub_80DC864(); + sub_80DB69C(); + sub_80DD04C(); + sub_80DE008(TRUE); + sub_80DC44C(); + gTasks[taskId].data[0] = 1; + break; + case 1: + if (gIsLinkContest & 1) + { + u8 taskId2; + + sContest.unk1920B_2 = 1; + if (sub_80DA8A4()) + sub_80DBAA0(); + taskId2 = CreateTask(sub_80FCC88, 0); + SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); + sub_80DBF68(); + gTasks[taskId].data[0] = 2; + } + else + { + sub_80DBAA0(); + gTasks[taskId].data[0] = 3; + } + break; + case 2: + if (!sContest.unk1920B_2) + gTasks[taskId].data[0] = 3; + break; + case 3: + sub_80DB884(); + sub_80DB2BC(); + gTasks[taskId].data[0] = 0; + gTasks[taskId].func = sub_80DE5F4; + break; + } +} + +void sub_80DE5C0(u8 taskId) +{ + if ((s16)(gBattle_BG1_Y += 7) > DISPLAY_HEIGHT) + gTasks[taskId].func = sub_80DA4F4; +} + +void sub_80DE5F4(u8 taskId) +{ + if (gTasks[taskId].data[2] < 10) + { + gTasks[taskId].data[2]++; + } + else + { + if (gTasks[taskId].data[1] == 0) + { + if (gTasks[taskId].data[0] == 16) + gTasks[taskId].data[1]++; + else + gTasks[taskId].data[0]++; + } + else + { + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80DE65C; + } + else + { + gTasks[taskId].data[0]--; + } + } + } +} + +void sub_80DE65C(u8 taskId) +{ + if (gTasks[taskId].data[2] < 10) + { + gTasks[taskId].data[2]++; + } + else + { + gTasks[taskId].data[2] = 0; + PlaySE12WithPanning(SE_C_MAKU_U, 0); + gTasks[taskId].func = sub_80DE5C0; + } +} + +void sub_80DE69C(u8 a) +{ + s32 i; + u8 taskId; + + for (i = 0; i < 4; i++) + { + gSprites[gContestResources->field_14[i].unk0].oam.matrixNum = AllocOamMatrix(); + gSprites[gContestResources->field_14[i].unk0].oam.affineMode = 1; + StartSpriteAffineAnim(&gSprites[gContestResources->field_14[i].unk0], a); + if (a == 2) + { + AnimateSprite(&gSprites[gContestResources->field_14[i].unk0]); + gSprites[gContestResources->field_14[i].unk0].invisible = FALSE; + } + } + taskId = CreateTask(sub_80DE794, 5); + gTasks[taskId].data[0] = a; + sContest.unk1920B_1 = 1; +} + +void sub_80DE794(u8 taskId) +{ + s32 i; + + if (gSprites[gContestResources->field_14[0].unk0].affineAnimEnded) + { + if ((u8)gTasks[taskId].data[0] == 1) + { + for (i = 0; i < 4; i++) + gSprites[gContestResources->field_14[i].unk0].invisible = TRUE; + } + for (i = 0; i < 4; i++) + FreeSpriteOamMatrix(&gSprites[gContestResources->field_14[i].unk0]); + sContest.unk1920B_1 = 0; + DestroyTask(taskId); + } +} + +u16 SanitizeMove(u16 move) +{ + if (move >= MOVES_COUNT) + move = MOVE_POUND; + return move; +} + +u16 SanitizeSpecies(u16 species) +{ + if (species >= NUM_SPECIES) + species = SPECIES_NONE; + return species; +} + +void sub_80DE864(u8 a) +{ + s32 i; + u16 move = SanitizeMove(sContestantStatus[a].currMove); + u16 species = SanitizeSpecies(gContestMons[a].species); + u8 r5_2; + + memset(&gContestResources->field_18->species, 0, 0x14); + ClearBattleAnimationVars(); + for (i = 0; i < 4; i++) + gBattleMonForms[i] = 0; + switch (move) + { + case MOVE_CURSE: + if (gBaseStats[species].type1 == TYPE_GHOST || gBaseStats[species].type2 == TYPE_GHOST) + gAnimMoveTurn = 0; + else + gAnimMoveTurn = 1; + break; + case MOVE_TRANSFORM: + case MOVE_ROLE_PLAY: + r5_2 = sContestantStatus[a].unk1B; + gContestResources->field_18->unk2 = SanitizeSpecies(gContestMons[r5_2].species); + gContestResources->field_18->unk10 = gContestMons[r5_2].personality; + gContestResources->field_18->unk4_0 = 1; + break; + case MOVE_RETURN: + gAnimFriendship = 0xFF; + break; + case MOVE_FRUSTRATION: + gAnimFriendship = 0; + break; + case MOVE_SOLAR_BEAM: + case MOVE_RAZOR_WIND: + case MOVE_SKULL_BASH: + case MOVE_SKY_ATTACK: + if (sContest.unk1925E == 0) + { + sContest.unk1925E = 2; + gAnimMoveTurn = 0; + } + else + { + gAnimMoveTurn = 1; + } + break; + } + sub_80DEA5C(); +} + +void sub_80DE9B0(u8 unused) +{ + memset(&gContestResources->field_18->species, 0, 0x14); + if (sContest.unk1925E != 0) + sContest.unk1925E--; +} + +void sub_80DE9DC(u8 a) +{ + gContestResources->field_18->unk5 = a; + gContestResources->field_18->species = SanitizeSpecies(gContestMons[a].species); + gContestResources->field_18->unk8 = gContestMons[a].personality; + gContestResources->field_18->unkC = gContestMons[a].otId; +} + +void sub_80DEA20(void) +{ + gBattlerSpriteIds[3] = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + InitSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattlerTarget]]); + sub_80DEA5C(); +} + +void sub_80DEA5C(void) +{ + struct Sprite *sprite = &gSprites[gBattlerSpriteIds[3]]; + + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->pos1.x = GetBattlerSpriteCoord(3, 0); + sprite->pos1.y = GetBattlerSpriteCoord(3, 1); + sprite->invisible = TRUE; +} + +void SelectContestMoveBankTarget(u16 move) +{ + switch (gBattleMoves[move].target) + { + case MOVE_TARGET_USER_OR_SELECTED: + case MOVE_TARGET_USER: + gBattlerTarget = 2; + break; + case MOVE_TARGET_SELECTED: + case MOVE_TARGET_RANDOM: + case MOVE_TARGET_BOTH: + case MOVE_TARGET_FOES_AND_ALLY: + default: + gBattlerTarget = 3; + break; + } +} + +#ifdef NONMATCHING +void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) +{ + struct TextPrinterTemplate printerTemplate; + + printerTemplate.currentChar = b; + printerTemplate.windowId = a; + printerTemplate.fontId = 1; + printerTemplate.x = 0; + printerTemplate.y = 1; + printerTemplate.currentX = 0; + printerTemplate.currentY = 1; + printerTemplate.letterSpacing = 0; + printerTemplate.lineSpacing = 0; + + printerTemplate.unk = a & (1 - 0x11); + printerTemplate.unk = 0xF0; + printerTemplate.bgColor = a & (1 - 0x11) & 0x80; + + + + + AddTextPrinter(&printerTemplate, 0, 0); + PutWindowTilemap(a); + Contest_SetBgCopyFlags(0); +} +#else +NAKED +void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + sub sp, 0x10\n\ + adds r4, r0, 0\n\ + str r1, [sp]\n\ + mov r0, sp\n\ + movs r2, 0\n\ + strb r4, [r0, 0x4]\n\ + movs r1, 0x1\n\ + strb r1, [r0, 0x5]\n\ + strb r2, [r0, 0x6]\n\ + strb r1, [r0, 0x7]\n\ + strb r2, [r0, 0x8]\n\ + strb r1, [r0, 0x9]\n\ + strb r2, [r0, 0xA]\n\ + strb r2, [r0, 0xB]\n\ + mov r3, sp\n\ + ldrb r2, [r3, 0xC]\n\ + subs r1, 0x11\n\ + adds r0, r1, 0\n\ + ands r0, r2\n\ + strb r0, [r3, 0xC]\n\ + mov r2, sp\n\ + movs r0, 0xF0\n\ + strb r0, [r2, 0xC]\n\ + ldrb r0, [r2, 0xD]\n\ + ands r1, r0\n\ + strb r1, [r2, 0xD]\n\ + mov r1, sp\n\ + movs r0, 0x80\n\ + strb r0, [r1, 0xD]\n\ + mov r0, sp\n\ + movs r1, 0\n\ + movs r2, 0\n\ + bl AddTextPrinter\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + adds r0, r4, 0\n\ + bl PutWindowTilemap\n\ + movs r0, 0\n\ + bl Contest_SetBgCopyFlags\n\ + add sp, 0x10\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void Contest_PrintTextToBg0WindowAt(u32 a, u8 *b, s32 c, u8 d, u8 e) +{ + struct TextPrinterTemplate printerTemplate; + + printerTemplate.currentChar = b; + printerTemplate.windowId = a; + printerTemplate.fontId = 1; + printerTemplate.x = c; + printerTemplate.y = d; + printerTemplate.currentX = c; + printerTemplate.currentY = d; + printerTemplate.letterSpacing = 0; + printerTemplate.lineSpacing = 0; + + printerTemplate.unk = a & (1 - 0x10); + printerTemplate.unk = 0xF0; + printerTemplate.bgColor = a & (1 - 0x11) & 0x80; + + + + + AddTextPrinter(&printerTemplate, 0, 0); + PutWindowTilemap(a); + Contest_SetBgCopyFlags(0); +} +#else +NAKED +void Contest_PrintTextToBg0WindowAt(u32 a, u8 *b, s32 c, u8 d, u8 e) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + sub sp, 0x10\n\ + adds r5, r0, 0\n\ + ldr r4, [sp, 0x1C]\n\ + str r1, [sp]\n\ + mov r0, sp\n\ + movs r1, 0\n\ + strb r5, [r0, 0x4]\n\ + strb r4, [r0, 0x5]\n\ + strb r2, [r0, 0x6]\n\ + strb r3, [r0, 0x7]\n\ + strb r2, [r0, 0x8]\n\ + strb r3, [r0, 0x9]\n\ + strb r1, [r0, 0xA]\n\ + strb r1, [r0, 0xB]\n\ + mov r3, sp\n\ + ldrb r2, [r3, 0xC]\n\ + subs r1, 0x10\n\ + adds r0, r1, 0\n\ + ands r0, r2\n\ + strb r0, [r3, 0xC]\n\ + mov r2, sp\n\ + movs r0, 0xF0\n\ + strb r0, [r2, 0xC]\n\ + ldrb r0, [r2, 0xD]\n\ + ands r1, r0\n\ + strb r1, [r2, 0xD]\n\ + mov r1, sp\n\ + movs r0, 0x80\n\ + strb r0, [r1, 0xD]\n\ + mov r0, sp\n\ + movs r1, 0\n\ + movs r2, 0\n\ + bl AddTextPrinter\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + adds r0, r5, 0\n\ + bl PutWindowTilemap\n\ + movs r0, 0\n\ + bl Contest_SetBgCopyFlags\n\ + add sp, 0x10\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void Contest_StartTextPrinter(const u8 *a, u32 b) +{ + struct TextPrinterTemplate printerTemplate; + u8 var; + + printerTemplate.currentChar = a; + printerTemplate.windowId = b; + printerTemplate.fontId = 1; + printerTemplate.x = 0; + printerTemplate.y = 1; + printerTemplate.currentX = 0; + printerTemplate.currentY = 1; + printerTemplate.letterSpacing = 0; + printerTemplate.lineSpacing = 0; + + printerTemplate.unk = b & -0x10; + printerTemplate.unk = 0x10; + printerTemplate.bgColor = b & (1 - 0x10) & 0x80; + + if(!b) + { + var = 0; + AddTextPrinter(&printerTemplate, var, 0); + } + else + { + if(gIsLinkContest & 1) + { + var = 4; + AddTextPrinter(&printerTemplate, var, 0); + } + else + { + var = GetPlayerTextSpeedDelay(); + AddTextPrinter(&printerTemplate, var, 0); + } + } + + PutWindowTilemap(4); + Contest_SetBgCopyFlags(0); + +} +} +#else +NAKED +void Contest_StartTextPrinter(const u8 *a, u32 b) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + sub sp, 0x10\n\ + str r0, [sp]\n\ + mov r2, sp\n\ + movs r3, 0\n\ + movs r0, 0x4\n\ + strb r0, [r2, 0x4]\n\ + mov r0, sp\n\ + movs r5, 0x1\n\ + strb r5, [r0, 0x5]\n\ + strb r3, [r0, 0x6]\n\ + strb r5, [r0, 0x7]\n\ + strb r3, [r0, 0x8]\n\ + strb r5, [r0, 0x9]\n\ + strb r3, [r0, 0xA]\n\ + strb r3, [r0, 0xB]\n\ + mov r4, sp\n\ + ldrb r3, [r4, 0xC]\n\ + movs r2, 0x10\n\ + negs r2, r2\n\ + adds r0, r2, 0\n\ + ands r0, r3\n\ + strb r0, [r4, 0xC]\n\ + mov r3, sp\n\ + movs r0, 0x10\n\ + strb r0, [r3, 0xC]\n\ + ldrb r0, [r3, 0xD]\n\ + ands r2, r0\n\ + strb r2, [r3, 0xD]\n\ + mov r2, sp\n\ + movs r0, 0x80\n\ + strb r0, [r2, 0xD]\n\ + cmp r1, 0\n\ + bne _080DEC80\n\ + mov r0, sp\n\ + movs r1, 0\n\ + movs r2, 0\n\ + bl AddTextPrinter\n\ + b _080DECA4\n\ +_080DEC80:\n\ + ldr r0, =gIsLinkContest\n\ + ldrb r1, [r0]\n\ + adds r0, r5, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080DEC94\n\ + movs r1, 0x4\n\ + b _080DEC9C\n\ + .pool\n\ +_080DEC94:\n\ + bl GetPlayerTextSpeedDelay\n\ + lsls r0, 24\n\ + lsrs r1, r0, 24\n\ +_080DEC9C:\n\ + mov r0, sp\n\ + movs r2, 0\n\ + bl AddTextPrinter\n\ +_080DECA4:\n\ + movs r0, 0x4\n\ + bl PutWindowTilemap\n\ + movs r0, 0\n\ + bl Contest_SetBgCopyFlags\n\ + add sp, 0x10\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) +{ + s16 var = h; + WriteSequenceToBgTilemapBuffer(a, b, c, d, e, f, g, var); + Contest_SetBgCopyFlags(a); +} +#else +NAKED +void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x10\n\ + mov r8, r0\n\ + ldr r0, [sp, 0x28]\n\ + ldr r4, [sp, 0x2C]\n\ + ldr r5, [sp, 0x30]\n\ + ldr r6, [sp, 0x34]\n\ + mov r7, r8\n\ + lsls r7, 24\n\ + lsrs r7, 24\n\ + mov r8, r7\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + str r0, [sp]\n\ + str r4, [sp, 0x4]\n\ + str r5, [sp, 0x8]\n\ + lsls r6, 16\n\ + asrs r6, 16\n\ + str r6, [sp, 0xC]\n\ + mov r0, r8\n\ + bl WriteSequenceToBgTilemapBuffer\n\ + mov r0, r8\n\ + bl Contest_SetBgCopyFlags\n\ + add sp, 0x10\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +void ContestBG_FillBoxWithTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g) +{ + ContestBG_FillBoxWithIncrementingTile(a, b, c, d, e, f, g, 0); +} + +bool32 Contest_RunTextPrinters(void) +{ + RunTextPrinters(); + return IsTextPrinterActive(4); +} + +void Contest_SetBgCopyFlags(u32 var) +{ + sContestBgCopyFlags |= 1 << var; +} + +void ResetContestLinkResults(void) +{ + s32 i; + s32 j; + + for(i = 0; i < 5; i++) + for(j = 0; j < 4; j++) + gSaveBlock2Ptr->contestLinkResults[i][j] = 0; +} + +bool8 sub_80DEDA8(u8 a) +{ + s32 i; + u8 r7 = Random() % 3; + + for (i = 0; i < 3; i++) + { + if (gContestFinalStandings[i] == 0) + break; + } + if (a == 0xFF && i != gContestPlayerMonIndex) + return FALSE; + switch (gSpecialVar_ContestCategory) + { + case CONTEST_CATEGORY_COOL: + r7 += 0; + break; + case CONTEST_CATEGORY_BEAUTY: + r7 += 3; + break; + case CONTEST_CATEGORY_CUTE: + r7 += 6; + break; + case CONTEST_CATEGORY_SMART: + r7 += 9; + break; + case CONTEST_CATEGORY_TOUGH: + r7 += 12; + break; + } + if (a != 0xFE) + { + u8 r4 = sub_80DEFA8(a, 1); + + gSaveBlock1Ptr->contestWinners[r4].personality = gContestMons[i].personality; + gSaveBlock1Ptr->contestWinners[r4].species = gContestMons[i].species; + gSaveBlock1Ptr->contestWinners[r4].trainerId = gContestMons[i].otId; + StringCopy(gSaveBlock1Ptr->contestWinners[r4].monName, gContestMons[i].nickname); + StringCopy(gSaveBlock1Ptr->contestWinners[r4].trainerName, gContestMons[i].trainerName); + if(gIsLinkContest & 1) + gSaveBlock1Ptr->contestWinners[r4].contestRank = 4; + else + gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank; + + if (a != 0xFF) + gSaveBlock1Ptr->contestWinners[r4].contestCategory = gSpecialVar_ContestCategory; + else + gSaveBlock1Ptr->contestWinners[r4].contestCategory = r7; + } + else + { + gUnknown_02039F3C.personality = gContestMons[i].personality; + gUnknown_02039F3C.trainerId = gContestMons[i].otId; + gUnknown_02039F3C.species = gContestMons[i].species; + StringCopy(gUnknown_02039F3C.monName, gContestMons[i].nickname); + StringCopy(gUnknown_02039F3C.trainerName, gContestMons[i].trainerName); + gUnknown_02039F3C.contestCategory = r7; + } + return TRUE; +} + +u8 sub_80DEFA8(u8 a, u8 b) +{ + s32 i; + + switch (a) + { + case 0: + case 1: + case 2: + case 3: + if (b != 0) + { + for (i = 5; i >= 1; i--) + memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner)); + } + return 0; + default: + switch (gSpecialVar_ContestCategory) + { + case CONTEST_CATEGORY_COOL: + return 8; + case CONTEST_CATEGORY_BEAUTY: + return 9; + case CONTEST_CATEGORY_CUTE: + return 10; + case CONTEST_CATEGORY_SMART: + return 11; + case CONTEST_CATEGORY_TOUGH: + default: + return 12; + } + } +} + +void ClearContestWinnerPicsInContestHall(void) +{ + s32 i; + + for (i = 0; i < 8; i++) + gSaveBlock1Ptr->contestWinners[i] = gUnknown_08587FA4[i]; +} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/graphics.c b/src/graphics.c index 10efd5043..4786f1f22 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1023,8 +1023,8 @@ const u32 gBattleAnimSpriteSheet_262[] = INCBIN_U32("graphics/battle_anims/sprit const u32 gBattleAnimSpritePalette_262[] = INCBIN_U32("graphics/battle_anims/sprites/262.gbapal.lz"); const u32 gContestNextTurnGfx[] = INCBIN_U32("graphics/contest/nextturn.4bpp.lz"); -const u8 gUnknown_08D8E9B4[] = INCBIN_U8("graphics/contest/nextturn_numbers.4bpp"); -const u8 gUnknown_08D8EA34[] = INCBIN_U8("graphics/contest/nextturn_random.4bpp"); +const u8 gContestNextTurnNumbersGfx[] = INCBIN_U8("graphics/contest/nextturn_numbers.4bpp"); +const u8 gContestNextTurnRandomGfx[] = INCBIN_U8("graphics/contest/nextturn_random.4bpp"); const u32 gBattleAnimSpriteSheet_264[] = INCBIN_U32("graphics/battle_anims/sprites/264.4bpp.lz"); const u32 gBattleAnimSpritePalette_264[] = INCBIN_U32("graphics/battle_anims/sprites/264.gbapal.lz"); From b8ff71e65e6eae5e57e5ef53894f233f57a0c14d Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 6 Jan 2019 14:11:31 -0800 Subject: [PATCH 05/12] Fix build conflicts. --- src/contest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/contest.c b/src/contest.c index a74e2c96b..ccd8740a5 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3327,7 +3327,7 @@ void sub_80DC4F0(void) LoadSpritePalette(&gUnknown_08587B08); for (i = 0; i < 4; i++) { - LoadCompressedObjectPic(&gUnknown_08587AE8[i]); + LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); gContestResources->field_14[i].unk1 = CreateSprite( &gSpriteTemplate_8587B18[i], 204, gUnknown_08587A70[gUnknown_02039F26[i]], @@ -3341,7 +3341,7 @@ void CreateApplauseMeterSprite(void) { u8 spriteId; - LoadCompressedObjectPic(&gUnknown_08587BB0); + LoadCompressedSpriteSheet(&gUnknown_08587BB0); LoadSpritePalette(&gUnknown_08587BB8); spriteId = CreateSprite(&gSpriteTemplate_8587BC8, 30, 44, 1); gSprites[spriteId].invisible = TRUE; @@ -3509,7 +3509,7 @@ u8 sub_80DC9EC(u8 a) volatile u8 zero; - LoadCompressedObjectPic(&gUnknown_08589904[a]); + LoadCompressedSpriteSheet(&gUnknown_08589904[a]); LoadSpritePalette(&gUnknown_08589924[a]); r6 = CreateSprite(&gSpriteTemplate_858998C[a], 184, r5, 29); gSprites[r8].oam.tileNum += 64; @@ -3562,7 +3562,7 @@ u8 sub_80DC9EC(u8 a) lsls r4, r1, 3\n\ ldr r0, =gUnknown_08589904\n\ adds r0, r4, r0\n\ - bl LoadCompressedObjectPic\n\ + bl LoadCompressedSpriteSheet\n\ ldr r0, =gUnknown_08589924\n\ adds r4, r0\n\ adds r0, r4, 0\n\ From f828823bf0a959e39659d4e125bbd0937169a4bc Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 27 Jan 2019 20:21:30 -0800 Subject: [PATCH 06/12] Make changes --- src/contest.c | 62 ++++++++++++--------------------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/src/contest.c b/src/contest.c index ccd8740a5..9b69df98b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3045,7 +3045,7 @@ void sub_80DBED4(void) if ((gIsLinkContest & 1)) { gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = - ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 0x270F) ? 0x270F : + ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 9999) ? 9999 : (gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1); } @@ -3218,7 +3218,9 @@ void sub_80DC0F4(u8 taskId) m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, r10 * 256); } else + { PlaySE(SE_BOO); + } if (!r11 && !r5 && !r6) gTasks[taskId].data[2] = -gTasks[taskId].data[2]; @@ -3328,10 +3330,7 @@ void sub_80DC4F0(void) for (i = 0; i < 4; i++) { LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); - gContestResources->field_14[i].unk1 = CreateSprite( - &gSpriteTemplate_8587B18[i], - 204, gUnknown_08587A70[gUnknown_02039F26[i]], - 0); + gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], 204, gUnknown_08587A70[gUnknown_02039F26[i]], 0); SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; } @@ -3444,18 +3443,9 @@ void sub_80DC87C(u8 a) sub_80DC81C(a); r0 = a + 5; - DmaCopy16Defvars( - 3, - gPlttBufferUnfaded + r0 * 16 + 10, - gPlttBufferFaded + r0 * 16 + 10, - 2); - + DmaCopy16Defvars(3, gPlttBufferUnfaded + r0 * 16 + 10, gPlttBufferFaded + r0 * 16 + 10, 2); var = (a + 5) * 16 + 12 + a; - DmaCopy16Defvars( - 3, - gPlttBufferUnfaded + var, - gPlttBufferFaded + var, - 2); + DmaCopy16Defvars(3, gPlttBufferUnfaded + var, gPlttBufferFaded + var, 2); } void sub_80DC8D0(u8 taskId) @@ -3718,8 +3708,8 @@ void sub_80DCB78(u8 spriteId) void sub_80DCBB4(void) { - SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40); - SetGpuReg(REG_OFFSET_BLDALPHA, 0x0907); + SetGpuReg(REG_OFFSET_BLDCNT, BLDALPHA_BLEND(BLDCNT_EFFECT_BLEND, BLDCNT_TGT1_ALL)); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1| BLDCNT_TGT1_BG2, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG3)); } void sub_80DCBD0(void) @@ -3780,7 +3770,9 @@ void sub_80DCD08(void) sub_80DB2BC(); } else + { sub_80DCD48(); + } } #ifdef NONMATCHING @@ -4781,8 +4773,8 @@ void sub_80DD940(void) src = gContestApplauseMeterGfx + 64; else src = gContestApplauseMeterGfx; - CpuSet(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 0x04000008); - CpuSet(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 0x04000008); + CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); + CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); if (sContest.applauseLevel > 4) sub_80DDA20(); @@ -5031,10 +5023,7 @@ void sub_80DE008(bool8 a) { if (sContestantStatus[i].turnOrderMod != 0 && a) { - CpuSet( - GetTurnOrderNumberGfx(i), - (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), - 0x04000008); + CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), 32); gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gUnknown_02039F26[i]]; gSprites[gContestResources->field_14[i].unk1].invisible = FALSE; } @@ -6167,27 +6156,4 @@ void ClearContestWinnerPicsInContestHall(void) for (i = 0; i < 8; i++) gSaveBlock1Ptr->contestWinners[i] = gUnknown_08587FA4[i]; -} - - - - - - - - - - - - - - - - - - - - - - - +} \ No newline at end of file From d633ee6f585d4d0f1b7af806a7b72ffc1719844a Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 27 Jan 2019 20:48:18 -0800 Subject: [PATCH 07/12] Minor changes --- src/contest.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/contest.c b/src/contest.c index 9b69df98b..95a09ba58 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3218,9 +3218,9 @@ void sub_80DC0F4(u8 taskId) m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, r10 * 256); } else - { + { PlaySE(SE_BOO); - } + } if (!r11 && !r5 && !r6) gTasks[taskId].data[2] = -gTasks[taskId].data[2]; @@ -3330,7 +3330,10 @@ void sub_80DC4F0(void) for (i = 0; i < 4; i++) { LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); - gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], 204, gUnknown_08587A70[gUnknown_02039F26[i]], 0); + gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], + 204, + gUnknown_08587A70[gUnknown_02039F26[i]], + 0); SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; } @@ -3443,9 +3446,15 @@ void sub_80DC87C(u8 a) sub_80DC81C(a); r0 = a + 5; - DmaCopy16Defvars(3, gPlttBufferUnfaded + r0 * 16 + 10, gPlttBufferFaded + r0 * 16 + 10, 2); + DmaCopy16Defvars(3, + gPlttBufferUnfaded + r0 * 16 + 10, + gPlttBufferFaded + r0 * 16 + 10, + 2); var = (a + 5) * 16 + 12 + a; - DmaCopy16Defvars(3, gPlttBufferUnfaded + var, gPlttBufferFaded + var, 2); + DmaCopy16Defvars(3, + gPlttBufferUnfaded + var, + gPlttBufferFaded + var, + 2); } void sub_80DC8D0(u8 taskId) @@ -3708,7 +3717,7 @@ void sub_80DCB78(u8 spriteId) void sub_80DCBB4(void) { - SetGpuReg(REG_OFFSET_BLDCNT, BLDALPHA_BLEND(BLDCNT_EFFECT_BLEND, BLDCNT_TGT1_ALL)); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1| BLDCNT_TGT1_BG2, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG3)); } @@ -3770,9 +3779,9 @@ void sub_80DCD08(void) sub_80DB2BC(); } else - { + { sub_80DCD48(); - } + } } #ifdef NONMATCHING From 72720204da48a77132ce17c2429aaa9854497e2c Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 27 Jan 2019 20:54:21 -0800 Subject: [PATCH 08/12] Fix stuff --- src/contest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contest.c b/src/contest.c index 95a09ba58..04c64d709 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3718,7 +3718,7 @@ void sub_80DCB78(u8 spriteId) void sub_80DCBB4(void) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1| BLDCNT_TGT1_BG2, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG3)); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 9)); } void sub_80DCBD0(void) From 26a2a4f9e71e05638686bed9d42da126593400c9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 28 Jan 2019 12:29:47 +0100 Subject: [PATCH 09/12] Match all of contest functions --- src/contest.c | 2004 +++++++------------------------------------------ 1 file changed, 282 insertions(+), 1722 deletions(-) diff --git a/src/contest.c b/src/contest.c index 04c64d709..e6e96b5dd 100644 --- a/src/contest.c +++ b/src/contest.c @@ -128,9 +128,9 @@ void sub_80DE350(void); void sub_80DE424(u8); void sub_80DE69C(u8); void sub_80DEA20(void); -void Contest_PrintTextToBg0WindowAt(u32, u8 *, s32, u8, u8); +void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId); void Contest_StartTextPrinter(const u8 *, u32); -void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, u8); +void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16); bool32 Contest_RunTextPrinters(void); void Contest_SetBgCopyFlags(u32); void sub_80FC9F8(u8); @@ -662,7 +662,6 @@ void sub_80D80C8(u8 taskId) } } - void sub_80D8108(u8 taskId) { switch (gTasks[taskId].data[0]) @@ -2028,7 +2027,6 @@ bool8 sub_80DA8A4(void) return FALSE; } - void sub_80DA8C8(u8 partyIndex) { u8 name[20]; @@ -2164,48 +2162,41 @@ void sub_80DAB8C(u8 contestType, u8 rank) sub_80DA8C8(gContestMonPartyIndex); } -#ifdef NONMATCHING void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) { - s32 i; + s32 i, j; u8 opponentsCount = 0; u8 opponents[100]; - const u8 * r6; if (gNumLinkContestPlayers == 4) return; - r6 = gUnknown_085898A4; for (i = 0; i < ARRAY_COUNT(gContestOpponents); i++) { if (rank != gContestOpponents[i].whichRank) continue; + if (isPostgame == TRUE) { - if (r6[i] == 1) + if (gUnknown_085898A4[i] == 1) continue; } else { - if (r6[i] == 2) + if (gUnknown_085898A4[i] == 2) continue; } - if (contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool) - opponents[opponentsCount++] = i; - else if (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty) - opponents[opponentsCount++] = i; - else if (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute) - opponents[opponentsCount++] = i; - else if (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart) - opponents[opponentsCount++] = i; - else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough) + if ((contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool) + || (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty) + || (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute) + || (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart) + || (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)) opponents[opponentsCount++] = i; } opponents[opponentsCount] = 0xFF; for (i = 0; i < 4 - gNumLinkContestPlayers; i++) { u16 rnd = sub_80F903C() % opponentsCount; - s32 j; gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]]; sub_80DF9D4(gContestMons[gNumLinkContestPlayers + i].trainerName); @@ -2215,180 +2206,6 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) opponentsCount--; } } -#else -NAKED void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) -{ - asm_unified("\tpush {r4-r7,lr}\n" - "\tmov r7, r9\n" - "\tmov r6, r8\n" - "\tpush {r6,r7}\n" - "\tsub sp, 0x64\n" - "\tmov r8, r2\n" - "\tlsls r0, 24\n" - "\tlsrs r4, r0, 24\n" - "\tlsls r1, 24\n" - "\tlsrs r2, r1, 24\n" - "\tmovs r7, 0\n" - "\tldr r0, =gNumLinkContestPlayers\n" - "\tldrb r1, [r0]\n" - "\tmov r9, r0\n" - "\tcmp r1, 0x4\n" - "\tbne _080DACDE\n" - "\tb _080DADF6\n" - "_080DACDE:\n" - "\tmovs r5, 0\n" - "\tldr r3, =gContestOpponents\n" - "\tldr r6, =gUnknown_085898A4\n" - "_080DACE4:\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 30\n" - "\tlsrs r0, 30\n" - "\tcmp r2, r0\n" - "\tbne _080DAD56\n" - "\tmov r0, r8\n" - "\tcmp r0, 0x1\n" - "\tbne _080DAD08\n" - "\tldrb r0, [r6]\n" - "\tcmp r0, 0x1\n" - "\tbeq _080DAD56\n" - "\tb _080DAD0E\n" - "\t.pool\n" - "_080DAD08:\n" - "\tldrb r0, [r6]\n" - "\tcmp r0, 0x2\n" - "\tbeq _080DAD56\n" - "_080DAD0E:\n" - "\tcmp r4, 0\n" - "\tbne _080DAD1A\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 29\n" - "\tcmp r0, 0\n" - "\tblt _080DAD4A\n" - "_080DAD1A:\n" - "\tcmp r4, 0x1\n" - "\tbne _080DAD26\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 28\n" - "\tcmp r0, 0\n" - "\tblt _080DAD4A\n" - "_080DAD26:\n" - "\tcmp r4, 0x2\n" - "\tbne _080DAD32\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 27\n" - "\tcmp r0, 0\n" - "\tblt _080DAD4A\n" - "_080DAD32:\n" - "\tcmp r4, 0x3\n" - "\tbne _080DAD3E\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 26\n" - "\tcmp r0, 0\n" - "\tblt _080DAD4A\n" - "_080DAD3E:\n" - "\tcmp r4, 0x4\n" - "\tbne _080DAD56\n" - "\tldrb r0, [r3, 0x1C]\n" - "\tlsls r0, 25\n" - "\tcmp r0, 0\n" - "\tbge _080DAD56\n" - "_080DAD4A:\n" - "\tadds r0, r7, 0\n" - "\tadds r1, r0, 0x1\n" - "\tlsls r1, 24\n" - "\tlsrs r7, r1, 24\n" - "\tadd r0, sp\n" - "\tstrb r5, [r0]\n" - "_080DAD56:\n" - "\tadds r3, 0x40\n" - "\tadds r6, 0x1\n" - "\tadds r5, 0x1\n" - "\tcmp r5, 0x5F\n" - "\tbls _080DACE4\n" - "\tmov r3, sp\n" - "\tadds r1, r3, r7\n" - "\tmovs r0, 0xFF\n" - "\tstrb r0, [r1]\n" - "\tmovs r5, 0\n" - "\tmov r0, r9\n" - "\tldrb r1, [r0]\n" - "\tmovs r0, 0x4\n" - "\tsubs r0, r1\n" - "\tcmp r5, r0\n" - "\tbge _080DADF6\n" - "\tldr r3, =gContestMons\n" - "\tmov r8, r3\n" - "\tmov r6, r9\n" - "\tmovs r0, 0x2\n" - "\tadd r0, r8\n" - "\tmov r9, r0\n" - "_080DAD82:\n" - "\tbl sub_80F903C\n" - "\tlsls r0, 16\n" - "\tlsrs r0, 16\n" - "\tadds r1, r7, 0\n" - "\tbl __modsi3\n" - "\tadds r1, r0, 0\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tldrb r0, [r6]\n" - "\tadds r0, r5\n" - "\tlsls r0, 6\n" - "\tadd r0, r8\n" - "\tldr r2, =gContestOpponents\n" - "\tmov r3, sp\n" - "\tadds r4, r3, r1\n" - "\tldrb r1, [r4]\n" - "\tlsls r1, 6\n" - "\tadds r1, r2\n" - "\tmovs r2, 0x40\n" - "\tbl memcpy\n" - "\tldrb r0, [r6]\n" - "\tadds r0, r5\n" - "\tlsls r0, 6\n" - "\tmov r1, r8\n" - "\tadds r1, 0xD\n" - "\tadds r0, r1\n" - "\tbl sub_80DF9D4\n" - "\tldrb r0, [r6]\n" - "\tadds r0, r5\n" - "\tlsls r0, 6\n" - "\tadd r0, r9\n" - "\tmovs r1, 0x2\n" - "\tbl sub_80DF9E0\n" - "\tldrb r0, [r4]\n" - "\tadds r3, r5, 0x1\n" - "\tsubs r1, r7, 0x1\n" - "\tcmp r0, 0xFF\n" - "\tbeq _080DADE6\n" - "\tadds r2, r4, 0\n" - "_080DADDA:\n" - "\tldrb r0, [r2, 0x1]\n" - "\tstrb r0, [r2]\n" - "\tadds r2, 0x1\n" - "\tldrb r0, [r2]\n" - "\tcmp r0, 0xFF\n" - "\tbne _080DADDA\n" - "_080DADE6:\n" - "\tlsls r0, r1, 24\n" - "\tlsrs r7, r0, 24\n" - "\tadds r5, r3, 0\n" - "\tldrb r1, [r6]\n" - "\tmovs r0, 0x4\n" - "\tsubs r0, r1\n" - "\tcmp r5, r0\n" - "\tblt _080DAD82\n" - "_080DADF6:\n" - "\tadd sp, 0x64\n" - "\tpop {r3,r4}\n" - "\tmov r8, r3\n" - "\tmov r9, r4\n" - "\tpop {r4-r7}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.pool"); -} -#endif // GetContestAvailability? u8 sub_80DAE0C(struct Pokemon *pkmn) @@ -2445,7 +2262,7 @@ void sub_80DAEA4(void) } } -u8 * sub_80DAED4(const u8 * src, u8 color) +u8 *sub_80DAED4(const u8 *src, u8 color) { u8 * ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent); ptr[-1] = color; @@ -2822,7 +2639,7 @@ u16 GetChosenMove(u8 a) ContestAI_ResetAI(a); moveChoice = ContestAI_GetActionToUse(); return gContestMons[a].moves[moveChoice]; - } + } } void sub_80DB918(void) @@ -2830,7 +2647,7 @@ void sub_80DB918(void) s32 i; for (i = 0; i < 4; i++) - sContestantStatus[i].currMove = GetChosenMove(i); + sContestantStatus[i].currMove = GetChosenMove(i); } void sub_80DB944(void) @@ -3044,10 +2861,10 @@ void sub_80DBED4(void) { if ((gIsLinkContest & 1)) { - gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = + gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] = ((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 9999) ? 9999 : (gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1); - + } } @@ -3081,7 +2898,7 @@ void sub_80DBF68(void) void sub_80DBF90(void) { int i; - + for(i = 0; i < 4; i++) { ContestBG_FillBoxWithTile(0, 0, 0x16, 2 + i * 5, 8, 2, 0x11); @@ -3147,7 +2964,7 @@ void sub_80DC0F4(u8 taskId) u8 r5; u8 r10; u8 r11; - + gTasks[taskId].data[10] = 0; if (gTasks[taskId].data[1] == 0) { @@ -3204,7 +3021,7 @@ void sub_80DC0F4(u8 taskId) } r10 = r5; r11 = 0; - + if (r5 > 7) { r11 = 1; @@ -3221,7 +3038,7 @@ void sub_80DC0F4(u8 taskId) { PlaySE(SE_BOO); } - + if (!r11 && !r5 && !r6) gTasks[taskId].data[2] = -gTasks[taskId].data[2]; } @@ -3330,9 +3147,9 @@ void sub_80DC4F0(void) for (i = 0; i < 4; i++) { LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); - gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], - 204, - gUnknown_08587A70[gUnknown_02039F26[i]], + gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], + 204, + gUnknown_08587A70[gUnknown_02039F26[i]], 0); SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; @@ -3446,14 +3263,14 @@ void sub_80DC87C(u8 a) sub_80DC81C(a); r0 = a + 5; - DmaCopy16Defvars(3, - gPlttBufferUnfaded + r0 * 16 + 10, - gPlttBufferFaded + r0 * 16 + 10, + DmaCopy16Defvars(3, + gPlttBufferUnfaded + r0 * 16 + 10, + gPlttBufferFaded + r0 * 16 + 10, 2); var = (a + 5) * 16 + 12 + a; - DmaCopy16Defvars(3, - gPlttBufferUnfaded + var, - gPlttBufferFaded + var, + DmaCopy16Defvars(3, + gPlttBufferUnfaded + var, + gPlttBufferFaded + var, 2); } @@ -3499,212 +3316,49 @@ extern const struct CompressedSpriteSheet gUnknown_08589904[]; extern const struct SpritePalette gUnknown_08589924[]; extern const struct SpriteTemplate gSpriteTemplate_858998C[]; -#ifdef NONMATCHING u8 sub_80DC9EC(u8 a) { - u8 r5 = gUnknown_02039F26[a] * 40 + 32; - u8 r8; - u8 r6; - volatile u8 zero; - + u8 spriteId1, spriteId2; + u8 x = gUnknown_02039F26[a] * 40 + 32; LoadCompressedSpriteSheet(&gUnknown_08589904[a]); LoadSpritePalette(&gUnknown_08589924[a]); - r6 = CreateSprite(&gSpriteTemplate_858998C[a], 184, r5, 29); - gSprites[r8].oam.tileNum += 64; - r8 = CreateSprite(&gSpriteTemplate_858998C[a], 248, r5, 29); - + spriteId1 = CreateSprite(&gSpriteTemplate_858998C[a], 184, x, 29); + spriteId2 = CreateSprite(&gSpriteTemplate_858998C[a], 248, x, 29); + gSprites[spriteId2].oam.tileNum += 64; - CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x26), (u8 *)(VRAM + 0x10000 + gSprites[r6].oam.tileNum * 32)); - CopySpriteTiles(0, 3, (void *)VRAM, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32)); - CpuSet(&r8, (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), 0x050000c0); + CopySpriteTiles(0, + 3, + (void *)VRAM, + (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x26), + gContestResources->field_34); - RequestDma3Copy((void *)(VRAM + 0x10000 + (0x28 + gSprites[r6].oam.tileNum) * 32), (u8 *)(VRAM + 0x10000 + gSprites[r8].oam.tileNum * 32), 0x80, 1); + CopySpriteTiles(0, + 3, (void *)VRAM, + (u16 *)(VRAM + 0xE000 + gUnknown_02039F26[a] * 5 * 64 + 0x36), + gContestResources->field_38); - // What is this? - zero = 0; - zero = 0; + CpuFill32(0, gContestResources->field_34 + 0x500, 0x300); + CpuFill32(0, gContestResources->field_38 + 0x500, 0x300); - RequestDma3Copy((void *)(VRAM + 0x10000 + (0x28 + gSprites[r6].oam.tileNum) * 32), (u8 *)(VRAM + 0x10000 + gSprites[r6].oam.tileNum * 32), 0x80, 1); + RequestDma3Copy(gContestResources->field_34, + (u8 *)(VRAM + 0x10000 + gSprites[spriteId1].oam.tileNum * 32), + 0x800, + 1); + RequestDma3Copy(gContestResources->field_38, + (u8 *)(VRAM + 0x10000 + gSprites[spriteId2].oam.tileNum * 32), + 0x800, + 1); - gSprites[r6].data[0] = r8; - gSprites[r8].data[0] = r6; - - return r6; + gSprites[spriteId1].data[0] = spriteId2; + gSprites[spriteId2].data[0] = spriteId1; + + gSprites[spriteId1].data[1] = a; + gSprites[spriteId2].data[1] = a; + + return spriteId1; } -#else -NAKED -u8 sub_80DC9EC(u8 a) -{ - asm(".syntax 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, 0x10\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - str r0, [sp, 0xC]\n\ - ldr r6, =gUnknown_02039F26\n\ - adds r6, r0, r6\n\ - ldrb r0, [r6]\n\ - lsls r5, r0, 2\n\ - adds r5, r0\n\ - lsls r5, 27\n\ - movs r0, 0x80\n\ - lsls r0, 22\n\ - adds r5, r0\n\ - lsrs r5, 24\n\ - ldr r1, [sp, 0xC]\n\ - lsls r4, r1, 3\n\ - ldr r0, =gUnknown_08589904\n\ - adds r0, r4, r0\n\ - bl LoadCompressedSpriteSheet\n\ - ldr r0, =gUnknown_08589924\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - bl LoadSpritePalette\n\ - ldr r2, [sp, 0xC]\n\ - lsls r4, r2, 1\n\ - adds r4, r2\n\ - lsls r4, 3\n\ - ldr r0, =gSpriteTemplate_858998C\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - movs r1, 0xB8\n\ - adds r2, r5, 0\n\ - movs r3, 0x1D\n\ - bl CreateSprite\n\ - mov r9, r0\n\ - mov r3, r9\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - mov r9, r3\n\ - adds r0, r4, 0\n\ - movs r1, 0xF8\n\ - adds r2, r5, 0\n\ - movs r3, 0x1D\n\ - bl CreateSprite\n\ - mov r8, r0\n\ - mov r0, r8\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - lsls r5, r0, 4\n\ - add r5, r8\n\ - lsls r5, 2\n\ - ldr r1, =gSprites\n\ - adds r5, r1\n\ - ldrh r2, [r5, 0x4]\n\ - lsls r1, r2, 22\n\ - lsrs r1, 22\n\ - adds r1, 0x40\n\ - ldr r3, =0x000003ff\n\ - adds r0, r3, 0\n\ - ands r1, r0\n\ - ldr r0, =0xfffffc00\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strh r0, [r5, 0x4]\n\ - movs r4, 0xC0\n\ - lsls r4, 19\n\ - ldrb r0, [r6]\n\ - lsls r3, r0, 2\n\ - adds r3, r0\n\ - lsls r3, 6\n\ - ldr r0, =0x0600e026\n\ - adds r3, r0\n\ - ldr r7, =gContestResources\n\ - ldr r0, [r7]\n\ - ldr r0, [r0, 0x34]\n\ - str r0, [sp]\n\ - movs r0, 0\n\ - movs r1, 0x3\n\ - adds r2, r4, 0\n\ - bl CopySpriteTiles\n\ - ldrb r0, [r6]\n\ - lsls r3, r0, 2\n\ - adds r3, r0\n\ - lsls r3, 6\n\ - ldr r1, =0x0600e036\n\ - adds r3, r1\n\ - ldr r0, [r7]\n\ - ldr r0, [r0, 0x38]\n\ - str r0, [sp]\n\ - movs r0, 0\n\ - movs r1, 0x3\n\ - adds r2, r4, 0\n\ - bl CopySpriteTiles\n\ - movs r4, 0\n\ - str r4, [sp, 0x4]\n\ - ldr r0, [r7]\n\ - ldr r1, [r0, 0x34]\n\ - movs r6, 0xA0\n\ - lsls r6, 3\n\ - adds r1, r6\n\ - ldr r2, =0x050000c0\n\ - mov r10, r2\n\ - add r0, sp, 0x4\n\ - bl CpuSet\n\ - str r4, [sp, 0x8]\n\ - add r0, sp, 0x8\n\ - ldr r1, [r7]\n\ - ldr r1, [r1, 0x38]\n\ - adds r1, r6\n\ - mov r2, r10\n\ - bl CpuSet\n\ - ldr r0, [r7]\n\ - ldr r0, [r0, 0x34]\n\ - mov r3, r9\n\ - lsls r4, r3, 4\n\ - add r4, r9\n\ - lsls r4, 2\n\ - ldr r1, =gSprites\n\ - adds r4, r1\n\ - ldrh r1, [r4, 0x4]\n\ - lsls r1, 22\n\ - lsrs r1, 17\n\ - ldr r6, =0x06010000\n\ - adds r1, r6\n\ - movs r2, 0x80\n\ - lsls r2, 4\n\ - mov r10, r2\n\ - movs r3, 0x1\n\ - bl RequestDma3Copy\n\ - ldr r0, [r7]\n\ - ldr r0, [r0, 0x38]\n\ - ldrh r1, [r5, 0x4]\n\ - lsls r1, 22\n\ - lsrs r1, 17\n\ - adds r1, r6\n\ - mov r2, r10\n\ - movs r3, 0x1\n\ - bl RequestDma3Copy\n\ - mov r3, r8\n\ - strh r3, [r4, 0x2E]\n\ - mov r0, r9\n\ - strh r0, [r5, 0x2E]\n\ - mov r1, sp\n\ - ldrh r1, [r1, 0xC]\n\ - strh r1, [r4, 0x30]\n\ - mov r2, sp\n\ - ldrh r2, [r2, 0xC]\n\ - strh r2, [r5, 0x30]\n\ - mov r0, r9\n\ - add sp, 0x10\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_80DCB78(u8 spriteId) { @@ -3772,7 +3426,7 @@ void sub_80DCD08(void) gHeap[0x1A000] = 0; else gHeap[0x1A000] = 1; - + if(gHeap[0x1A000] == 0) { sub_80DAEA4(); @@ -3784,191 +3438,55 @@ void sub_80DCD08(void) } } -#ifdef NONMATCHING void sub_80DCD48(void) { - u8 r5 = 0; - u8 sp8[8]; + u8 i; + s16 value; + u8 *txtPtr; + u8 text[8]; - if (gUnknown_020322D5 != 0) + if (gUnknown_020322D5 == 0) + return; + + switch (gHeap[0x1A000]) { - u8 i; - s16 r2; - - + case 0: + break; + case 2: + case 3: + sub_80DF750(); + break; + default: + for (i = 0; i < 4; i++) + FillWindowPixelBuffer(i, 0); for (i = 0; i < 4; i++) { - r2 = sContestantStatus[i].unk4; - if (r2 < 0) + value = sContestantStatus[i].unk4; + txtPtr = text; + if (sContestantStatus[i].unk4 < 0) { - r2 = -r2; - sp8[0] = CHAR_HYPHEN; - r5++; + value *= -1; + txtPtr = StringCopy(txtPtr, gText_OneDash); } - ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); - Text_InitWindowAndPrintText( - &gUnknown_03004210, - sp8, - 592 + gUnknown_02039F26[i] * 22, - gUnknown_083CA310[gUnknown_02039F26[i]][0], - gUnknown_083CA310[gUnknown_02039F26[i]][1]); - r5 = 0; + ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text, 55, 1, 7); } for (i = 0; i < 4; i++) { - r2 = sContestantStatus[i].appeal2; - if (r2 < 0) + value = sContestantStatus[i].appeal2; + txtPtr = text; + if (sContestantStatus[i].appeal2 < 0) { - r2 = -r2; - sp8[0] = CHAR_HYPHEN; - r5++; + value *= -1; + txtPtr = StringCopy(txtPtr, gText_OneDash); } - ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); - Text_InitWindowAndPrintText( - &gUnknown_03004210, - sp8, - 512 + gUnknown_02039F26[i] * 20, - gUnknown_083CA308[gUnknown_02039F26[i]][0], - gUnknown_083CA308[gUnknown_02039F26[i]][1]); - r5 = 0; + ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text, 5, 1, 7); } - sub_80AEB30(); + sub_80DB2BC(); + break; } } -#else -NAKED -void sub_80DCD48(void) -{ - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - sub sp, 0xC\n\ - ldr r0, =gUnknown_020322D5\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - beq _080DCE44\n\ - ldr r0, =gHeap\n\ - movs r1, 0xD0\n\ - lsls r1, 9\n\ - adds r0, r1\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - beq _080DCE44\n\ - cmp r0, 0\n\ - blt _080DCD7C\n\ - cmp r0, 0x3\n\ - bgt _080DCD7C\n\ - cmp r0, 0x2\n\ - blt _080DCD7C\n\ - bl sub_80DF750\n\ - b _080DCE44\n\ - .pool\n\ -_080DCD7C:\n\ - movs r5, 0\n\ -_080DCD7E:\n\ - adds r0, r5, 0\n\ - movs r1, 0\n\ - bl FillWindowPixelBuffer\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x3\n\ - bls _080DCD7E\n\ - movs r5, 0\n\ -_080DCD92:\n\ - ldr r0, =gContestResources\n\ - ldr r0, [r0]\n\ - ldr r1, [r0, 0x4]\n\ - lsls r0, r5, 3\n\ - subs r0, r5\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - add r2, sp, 0x4\n\ - ldrh r4, [r0, 0x4]\n\ - movs r1, 0x4\n\ - ldrsh r0, [r0, r1]\n\ - cmp r0, 0\n\ - bge _080DCDBC\n\ - negs r0, r0\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - adds r0, r2, 0\n\ - ldr r1, =gText_OneDash\n\ - bl StringCopy\n\ - adds r2, r0, 0\n\ -_080DCDBC:\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - adds r0, r2, 0\n\ - movs r2, 0\n\ - movs r3, 0x4\n\ - bl ConvertIntToDecimalStringN\n\ - ldr r0, =gUnknown_02039F26\n\ - adds r0, r5, r0\n\ - ldrb r0, [r0]\n\ - movs r1, 0x7\n\ - str r1, [sp]\n\ - add r1, sp, 0x4\n\ - movs r2, 0x37\n\ - movs r3, 0x1\n\ - bl Contest_PrintTextToBg0WindowAt\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x3\n\ - bls _080DCD92\n\ - movs r5, 0\n\ -_080DCDEA:\n\ - ldr r0, =gContestResources\n\ - ldr r0, [r0]\n\ - ldr r1, [r0, 0x4]\n\ - lsls r0, r5, 3\n\ - subs r0, r5\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - add r2, sp, 0x4\n\ - ldrh r4, [r0, 0x2]\n\ - movs r1, 0x2\n\ - ldrsh r0, [r0, r1]\n\ - cmp r0, 0\n\ - bge _080DCE14\n\ - negs r0, r0\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - adds r0, r2, 0\n\ - ldr r1, =gText_OneDash\n\ - bl StringCopy\n\ - adds r2, r0, 0\n\ -_080DCE14:\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - adds r0, r2, 0\n\ - movs r2, 0\n\ - movs r3, 0x4\n\ - bl ConvertIntToDecimalStringN\n\ - ldr r0, =gUnknown_02039F26\n\ - adds r0, r5, r0\n\ - ldrb r0, [r0]\n\ - movs r1, 0x7\n\ - str r1, [sp]\n\ - add r1, sp, 0x4\n\ - movs r2, 0x5\n\ - movs r3, 0x1\n\ - bl Contest_PrintTextToBg0WindowAt\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x3\n\ - bls _080DCDEA\n\ - bl sub_80DB2BC\n\ -_080DCE44:\n\ - add sp, 0xC\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_80DCE58(u8 a) { @@ -4062,550 +3580,122 @@ void sub_80DD04C(void) sub_80DAEA4(); } -#ifdef NONMATCHING void sub_80DD080(u8 contestant) { + u16 move; + u8 effect; + u8 rnd; bool8 r8; s32 i; sContestantStatus[contestant].appeal2 = 0; sContestantStatus[contestant].appeal1 = 0; r8 = sub_80DBA68(contestant); - if (r8) + if (!r8) + return; + + move = sContestantStatus[contestant].currMove; + effect = gContestMoves[move].effect; + + sContestantStatus[contestant].moveCategory = gContestMoves[sContestantStatus[contestant].currMove].contestCategory; + if (sContestantStatus[contestant].currMove == sContestantStatus[contestant].prevMove && sContestantStatus[contestant].currMove != MOVE_NONE) { - u16 move = sContestantStatus[contestant].currMove; - u8 effect = gContestMoves[move].effect; - u8 rnd; - - sContestantStatus[contestant].moveCategory = gContestMoves[sContestantStatus[contestant].currMove].contestCategory; - if (sContestantStatus[contestant].currMove == sContestantStatus[contestant].prevMove && sContestantStatus[contestant].currMove != MOVE_NONE) - { - sContestantStatus[contestant].disappointedRepeat = TRUE; - sContestantStatus[contestant].moveRepeatCount++; - } - else - { - sContestantStatus[contestant].moveRepeatCount = 0; - } - sContestantStatus[contestant].appeal1 = gContestEffects[effect].appeal; - sContestantStatus[contestant].appeal2 = gContestEffects[effect].appeal; - shared192D0.jam = gContestEffects[effect].jam; - shared192D0.jam2 = shared192D0.jam; - shared192D0.jam2 = gContestEffects[effect].jam; - - shared192D0.contestant = contestant; - for (i = 0; i < 4; i++) - { - sContestantStatus[i].jam = 0; - shared192D0.unnervedPokes[i] = 0; - } - if (sContestantStatus[contestant].hasJudgesAttention && AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove) == 0) - sContestantStatus[contestant].hasJudgesAttention = 0; - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition; - gContestEffectFuncs[effect](); - if (sContestantStatus[contestant].conditionMod == 1) - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition - 10; - else if (sContestantStatus[contestant].appealTripleCondition) - sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition * 3; - - - sContestantStatus[contestant].unk16 = 0; - sContestantStatus[contestant].unk15_6 = 0; - if (sub_80DE1E8(contestant)) - { - u8 r2 = AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove); - - if (r2 != 0 && sContestantStatus[contestant].hasJudgesAttention) - { - sContestantStatus[contestant].unk16 = r2; - sContestantStatus[contestant].unk15_6 = 1; - sContestantStatus[contestant].hasJudgesAttention = 0; - sContestantStatus[contestant].unk17 = sContestantStatus[contestant].appeal1 * sContestantStatus[contestant].unk16; - sContestantStatus[contestant].unk15_3 = 1; - } - else - { - if (gContestMoves[sContestantStatus[contestant].currMove].comboStarterId != 0) - { - sContestantStatus[contestant].hasJudgesAttention = 1; - sContestantStatus[contestant].unk15_6 = 1; - } - else - { - sContestantStatus[contestant].hasJudgesAttention = 0; - } - } - } - if (sContestantStatus[contestant].disappointedRepeat) - sContestantStatus[contestant].unk18 = (sContestantStatus[contestant].moveRepeatCount + 1) * 10; - if (sContestantStatus[contestant].nervous) - { - sContestantStatus[contestant].hasJudgesAttention = 0; - sContestantStatus[contestant].appeal2 = 0; - sContestantStatus[contestant].appeal1 = 0; - } - shared19328.bits_0 = Contest_GetMoveExcitement(sContestantStatus[contestant].currMove); - if (sContestantStatus[contestant].overrideCategoryExcitementMod) - shared19328.bits_0 = 1; - if (shared19328.bits_0 > 0) - { - if (sContest.applauseLevel + shared19328.bits_0 > 4) - shared19328.unk2 = 60; - else - shared19328.unk2 = 10; - } - else - { - shared19328.unk2 = 0; - } - - rnd = Random() % 3; - for (i = 0; i < 4; i++) - { - if (i != contestant) - { - if (rnd == 0) - break; - rnd--; - } - } - sContestantStatus[contestant].unk1B = i; + sContestantStatus[contestant].disappointedRepeat = TRUE; + sContestantStatus[contestant].moveRepeatCount++; } -} + else + { + sContestantStatus[contestant].moveRepeatCount = 0; + } + sContestantStatus[contestant].appeal1 = gContestEffects[effect].appeal; + sContestantStatus[contestant].appeal2 = sContestantStatus[contestant].appeal1; + shared192D0.jam = gContestEffects[effect].jam; + shared192D0.jam2 = shared192D0.jam; -#else -NAKED -void sub_80DD080(u8 contestant) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldr r4, =gContestResources\n\ - ldr r3, [r4]\n\ - ldr r1, [r3, 0x4]\n\ - lsls r7, r6, 3\n\ - subs r0, r7, r6\n\ - lsls r5, r0, 2\n\ - adds r1, r5, r1\n\ - movs r2, 0\n\ - strh r2, [r1, 0x2]\n\ - ldr r0, [r3, 0x4]\n\ - adds r0, r5, r0\n\ - strh r2, [r0]\n\ - adds r0, r6, 0\n\ - bl sub_80DBA68\n\ - lsls r0, 24\n\ - mov r8, r4\n\ - cmp r0, 0\n\ - bne _080DD0B4\n\ - b _080DD3C4\n\ -_080DD0B4:\n\ - ldr r0, [r4]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r5, r1\n\ - ldrh r0, [r1, 0x6]\n\ - ldr r2, =gContestMoves\n\ - lsls r0, 3\n\ - adds r0, r2\n\ - ldrb r2, [r0]\n\ - mov r9, r2\n\ - ldrb r0, [r0, 0x1]\n\ - lsls r0, 29\n\ - lsrs r0, 29\n\ - strb r0, [r1, 0xA]\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x4]\n\ - adds r2, r5, r0\n\ - ldrh r0, [r2, 0x6]\n\ - ldrh r1, [r2, 0x8]\n\ - cmp r0, r1\n\ - bne _080DD110\n\ - cmp r0, 0\n\ - beq _080DD110\n\ - ldrb r0, [r2, 0x15]\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x15]\n\ - ldr r0, [r4]\n\ - ldr r2, [r0, 0x4]\n\ - adds r2, r5, r2\n\ - ldrb r3, [r2, 0xB]\n\ - lsls r1, r3, 25\n\ - lsrs r1, 29\n\ - adds r1, 0x1\n\ - movs r0, 0x7\n\ - ands r1, r0\n\ - lsls r1, 4\n\ - movs r0, 0x71\n\ - negs r0, r0\n\ - ands r0, r3\n\ - orrs r0, r1\n\ - strb r0, [r2, 0xB]\n\ - b _080DD12C\n\ - .pool\n\ -_080DD110:\n\ - ldr r4, =gContestResources\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x4]\n\ - lsls r3, r6, 3\n\ - subs r1, r3, r6\n\ - lsls r1, 2\n\ - adds r1, r0\n\ - ldrb r2, [r1, 0xB]\n\ - movs r0, 0x71\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1, 0xB]\n\ - mov r8, r4\n\ - adds r7, r3, 0\n\ -_080DD12C:\n\ - mov r2, r8\n\ - ldr r4, [r2]\n\ - ldr r2, [r4, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r0, 2\n\ - adds r2, r0, r2\n\ - ldr r3, =gContestEffects\n\ - mov r1, r9\n\ - lsls r5, r1, 2\n\ - adds r3, r5, r3\n\ - ldrb r1, [r3, 0x1]\n\ - strh r1, [r2]\n\ - ldr r1, [r4, 0x4]\n\ - adds r0, r1\n\ - ldrh r1, [r0]\n\ - strh r1, [r0, 0x2]\n\ - ldr r1, [r4, 0x8]\n\ - ldrb r0, [r3, 0x2]\n\ - strh r0, [r1, 0x4]\n\ - ldr r1, [r4, 0x8]\n\ - ldrh r0, [r1, 0x4]\n\ - strh r0, [r1, 0x6]\n\ - ldr r0, [r4, 0x8]\n\ - strb r6, [r0, 0x11]\n\ - movs r2, 0\n\ - mov r9, r5\n\ - mov r4, r8\n\ - movs r3, 0\n\ - movs r1, 0\n\ -_080DD166:\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x4]\n\ - adds r0, r1, r0\n\ - strb r3, [r0, 0xE]\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x8]\n\ - adds r0, 0xD\n\ - adds r0, r2\n\ - strb r3, [r0]\n\ - adds r1, 0x1C\n\ - adds r2, 0x1\n\ - cmp r2, 0x3\n\ - ble _080DD166\n\ - ldr r5, =gContestResources\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r4, r0, 2\n\ - adds r2, r4, r1\n\ - ldrb r1, [r2, 0x15]\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD1B4\n\ - ldrh r0, [r2, 0x8]\n\ - ldrh r1, [r2, 0x6]\n\ - bl AreMovesContestCombo\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _080DD1B4\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r2, [r1, 0x15]\n\ - movs r0, 0x11\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x15]\n\ -_080DD1B4:\n\ - ldr r0, =gContestEffectFuncs\n\ - add r0, r9\n\ - ldr r0, [r0]\n\ - bl _call_via_r0\n\ - ldr r0, =gContestResources\n\ - ldr r0, [r0]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r0, 2\n\ - adds r2, r0, r1\n\ - ldrb r1, [r2, 0x10]\n\ - movs r0, 0x30\n\ - ands r0, r1\n\ - cmp r0, 0x10\n\ - bne _080DD1EC\n\ - ldrh r1, [r2, 0x2]\n\ - subs r1, 0xA\n\ - movs r0, 0xD\n\ - ldrsb r0, [r2, r0]\n\ - b _080DD206\n\ - .pool\n\ -_080DD1EC:\n\ - ldrb r1, [r2, 0x11]\n\ - movs r0, 0x20\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD200\n\ - movs r1, 0xD\n\ - ldrsb r1, [r2, r1]\n\ - lsls r0, r1, 1\n\ - adds r0, r1\n\ - b _080DD204\n\ -_080DD200:\n\ - movs r0, 0xD\n\ - ldrsb r0, [r2, r0]\n\ -_080DD204:\n\ - ldrh r1, [r2, 0x2]\n\ -_080DD206:\n\ - adds r0, r1\n\ - strh r0, [r2, 0x2]\n\ - ldr r5, =gContestResources\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r4, r0, 2\n\ - adds r1, r4, r1\n\ - movs r0, 0\n\ - strb r0, [r1, 0x16]\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r2, [r1, 0x15]\n\ - movs r0, 0x41\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x15]\n\ - adds r0, r6, 0\n\ - bl sub_80DE1E8\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _080DD2E2\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrh r0, [r1, 0x8]\n\ - ldrh r1, [r1, 0x6]\n\ - bl AreMovesContestCombo\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - cmp r3, 0\n\ - beq _080DD29C\n\ - ldr r0, [r5]\n\ - ldr r0, [r0, 0x4]\n\ - adds r2, r4, r0\n\ - ldrb r1, [r2, 0x15]\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD29C\n\ - strb r3, [r2, 0x16]\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r0, [r1, 0x15]\n\ - movs r2, 0x40\n\ - orrs r0, r2\n\ - strb r0, [r1, 0x15]\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r2, [r1, 0x15]\n\ - movs r0, 0x11\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x15]\n\ - ldr r0, [r5]\n\ - ldr r0, [r0, 0x4]\n\ - adds r0, r4, r0\n\ - movs r1, 0\n\ - ldrsh r2, [r0, r1]\n\ - ldrb r1, [r0, 0x16]\n\ - muls r1, r2\n\ - strb r1, [r0, 0x17]\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r0, [r1, 0x15]\n\ - movs r2, 0x8\n\ - b _080DD2C8\n\ - .pool\n\ -_080DD29C:\n\ - ldr r2, =gContestMoves\n\ - ldr r5, =gContestResources\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r4, r0, 2\n\ - adds r3, r4, r1\n\ - ldrh r0, [r3, 0x6]\n\ - lsls r0, 3\n\ - adds r0, r2\n\ - ldrb r0, [r0, 0x2]\n\ - cmp r0, 0\n\ - beq _080DD2D8\n\ - ldrb r0, [r3, 0x15]\n\ - movs r1, 0x10\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x15]\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - adds r1, r4, r1\n\ - ldrb r0, [r1, 0x15]\n\ - movs r2, 0x40\n\ -_080DD2C8:\n\ - orrs r0, r2\n\ - strb r0, [r1, 0x15]\n\ - b _080DD2E2\n\ - .pool\n\ -_080DD2D8:\n\ - ldrb r1, [r3, 0x15]\n\ - movs r0, 0x11\n\ - negs r0, r0\n\ - ands r0, r1\n\ - strb r0, [r3, 0x15]\n\ -_080DD2E2:\n\ - ldr r5, =gContestResources\n\ - ldr r0, [r5]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r4, r0, 2\n\ - adds r2, r4, r1\n\ - ldrb r1, [r2, 0x15]\n\ - movs r0, 0x1\n\ - mov r8, r0\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD30A\n\ - ldrb r0, [r2, 0xB]\n\ - lsls r0, 25\n\ - lsrs r0, 29\n\ - adds r0, 0x1\n\ - lsls r1, r0, 2\n\ - adds r1, r0\n\ - lsls r1, 1\n\ - strb r1, [r2, 0x18]\n\ -_080DD30A:\n\ - ldr r0, [r5]\n\ - ldr r0, [r0, 0x4]\n\ - adds r2, r4, r0\n\ - ldrb r1, [r2, 0xC]\n\ - mov r0, r8\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD334\n\ - ldrb r1, [r2, 0x15]\n\ - movs r0, 0x11\n\ - negs r0, r0\n\ - ands r0, r1\n\ - strb r0, [r2, 0x15]\n\ - ldr r2, [r5]\n\ - ldr r0, [r2, 0x4]\n\ - adds r0, r4, r0\n\ - movs r1, 0\n\ - strh r1, [r0, 0x2]\n\ - ldr r0, [r2, 0x4]\n\ - adds r0, r4, r0\n\ - strh r1, [r0]\n\ -_080DD334:\n\ - ldr r0, [r5]\n\ - ldr r0, [r0, 0x4]\n\ - adds r0, r4, r0\n\ - ldrh r0, [r0, 0x6]\n\ - bl Contest_GetMoveExcitement\n\ - ldr r1, [r5]\n\ - ldr r1, [r1, 0x10]\n\ - strb r0, [r1]\n\ - ldr r2, [r5]\n\ - ldr r0, [r2, 0x4]\n\ - adds r0, r4, r0\n\ - ldrb r1, [r0, 0x11]\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DD35C\n\ - ldr r0, [r2, 0x10]\n\ - mov r1, r8\n\ - strb r1, [r0]\n\ -_080DD35C:\n\ - ldr r1, [r5]\n\ - ldr r3, [r1, 0x10]\n\ - movs r0, 0\n\ - ldrsb r0, [r3, r0]\n\ - cmp r0, 0\n\ - ble _080DD388\n\ - ldr r0, [r1]\n\ - ldrb r0, [r0, 0x13]\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - movs r1, 0\n\ - ldrsb r1, [r3, r1]\n\ - adds r0, r1\n\ - cmp r0, 0x4\n\ - ble _080DD384\n\ - movs r0, 0x3C\n\ - b _080DD38A\n\ - .pool\n\ -_080DD384:\n\ - movs r0, 0xA\n\ - b _080DD38A\n\ -_080DD388:\n\ - movs r0, 0\n\ -_080DD38A:\n\ - strb r0, [r3, 0x2]\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r1, 0x3\n\ - bl __umodsi3\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - movs r2, 0\n\ - b _080DD3AE\n\ -_080DD3A2:\n\ - subs r0, 0x1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ -_080DD3A8:\n\ - adds r2, 0x1\n\ - cmp r2, 0x3\n\ - bgt _080DD3B6\n\ -_080DD3AE:\n\ - cmp r2, r6\n\ - beq _080DD3A8\n\ - cmp r0, 0\n\ - bne _080DD3A2\n\ -_080DD3B6:\n\ - ldr r0, =gContestResources\n\ - ldr r0, [r0]\n\ - ldr r1, [r0, 0x4]\n\ - subs r0, r7, r6\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - strb r2, [r0, 0x1B]\n\ -_080DD3C4:\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); + shared192D0.contestant = contestant; + for (i = 0; i < 4; i++) + { + sContestantStatus[i].jam = 0; + shared192D0.unnervedPokes[i] = 0; + } + + if (sContestantStatus[contestant].hasJudgesAttention + && !AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove)) + sContestantStatus[contestant].hasJudgesAttention = 0; + + gContestEffectFuncs[effect](); + + if (sContestantStatus[contestant].conditionMod == 1) + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition - 10; + else if (sContestantStatus[contestant].appealTripleCondition) + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition * 3; + else + sContestantStatus[contestant].appeal2 += sContestantStatus[contestant].condition; + + sContestantStatus[contestant].unk16 = 0; + sContestantStatus[contestant].unk15_6 = 0; + if (sub_80DE1E8(contestant)) + { + u8 r2 = AreMovesContestCombo(sContestantStatus[contestant].prevMove, sContestantStatus[contestant].currMove); + + if (r2 != 0 && sContestantStatus[contestant].hasJudgesAttention) + { + sContestantStatus[contestant].unk16 = r2; + sContestantStatus[contestant].unk15_6 = 1; + sContestantStatus[contestant].hasJudgesAttention = 0; + sContestantStatus[contestant].unk17 = sContestantStatus[contestant].appeal1 * sContestantStatus[contestant].unk16; + sContestantStatus[contestant].unk15_3 = 1; + } + else + { + if (gContestMoves[sContestantStatus[contestant].currMove].comboStarterId != 0) + { + sContestantStatus[contestant].hasJudgesAttention = 1; + sContestantStatus[contestant].unk15_6 = 1; + } + else + { + sContestantStatus[contestant].hasJudgesAttention = 0; + } + } + } + if (sContestantStatus[contestant].disappointedRepeat) + sContestantStatus[contestant].unk18 = (sContestantStatus[contestant].moveRepeatCount + 1) * 10; + + if (sContestantStatus[contestant].nervous) + { + sContestantStatus[contestant].hasJudgesAttention = 0; + sContestantStatus[contestant].appeal2 = 0; + sContestantStatus[contestant].appeal1 = 0; + } + shared19328.bits_0 = Contest_GetMoveExcitement(sContestantStatus[contestant].currMove); + if (sContestantStatus[contestant].overrideCategoryExcitementMod) + shared19328.bits_0 = 1; + + if (shared19328.bits_0 > 0) + { + if (sContest.applauseLevel + shared19328.bits_0 > 4) + shared19328.unk2 = 60; + else + shared19328.unk2 = 10; + } + else + { + shared19328.unk2 = 0; + } + + rnd = Random() % 3; + for (i = 0; i < 4; i++) + { + if (i != contestant) + { + if (rnd == 0) + break; + rnd--; + } + } + sContestantStatus[contestant].unk1B = i; } -#endif void SetContestantEffectStringID(u8 a, u8 b) { @@ -4782,9 +3872,9 @@ void sub_80DD940(void) src = gContestApplauseMeterGfx + 64; else src = gContestApplauseMeterGfx; - CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); - CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); - + CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32); + CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32); + if (sContest.applauseLevel > 4) sub_80DDA20(); } @@ -5054,24 +4144,22 @@ const u8 *GetTurnOrderNumberGfx(u8 contestant) void sub_80DE12C(void) { s32 r7 = 0; - u32 r10 = 2; - u32 r8 = 1; - u32 r9 = 0x11; - - for(r7 = 0; r7 < 4; r7++) + u8 r10 = 2; + u8 r8 = 1; + u8 r9 = 0x11; + + for (r7 = 0; r7 < 4; r7++) { - u32 r6; - u16 var; - if(shared192D0.unnervedPokes[r7] != 0) - if(Contest_IsMonsTurnDisabled(r7) == FALSE) - { - r6 = gUnknown_02039F26[r7] * 5 + 2; - var = sub_80DB748(3); - ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6, r10, r8, r9, r8); - var += 16; - ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6 + 1, r10, r8, r9, r8); - PlaySE(SE_C_PASI); - } + if (shared192D0.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) + { + u32 r6 = gUnknown_02039F26[r7] * 5 + 2; + u16 var = sub_80DB748(3); + + ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6, r10, r8, r9, r8); + var += 16; + ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6 + 1, r10, r8, r9, r8); + PlaySE(SE_C_PASI); + } } } @@ -5083,242 +4171,58 @@ bool8 sub_80DE1E8(u8 a) return TRUE; } -#ifdef NONMATCHING void sub_80DE224(void) { s32 i; - u16 bg0Cnt; - u16 bg1Cnt; - u16 bg2Cnt; - u16 var; + u16 bg0Cnt, bg1Cnt, bg2Cnt; bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); - ((struct BgCnt *)&bg1Cnt)->priority = 0; - ((struct BgCnt *)&bg1Cnt)->screenSize = 2; - ((struct BgCnt *)&bg1Cnt)->areaOverflowMode = 0; - ((struct BgCnt *)&bg1Cnt)->charBaseBlock = 0; - - + ((vBgCnt *)&bg1Cnt)->priority = 0; + ((vBgCnt *)&bg1Cnt)->screenSize = 2; + ((vBgCnt *)&bg1Cnt)->areaOverflowMode = 0; + ((vBgCnt *)&bg1Cnt)->charBaseBlock = 0; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); - + bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT); - ((struct BgCnt *)&bg0Cnt)->priority = 0; - bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT); - ((struct BgCnt *)&bg2Cnt)->priority = 0; - + ((vBgCnt *)&bg0Cnt)->priority = 1; + ((vBgCnt *)&bg2Cnt)->priority = 1; + SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt); SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt); - + gBattle_BG1_X = DISPLAY_WIDTH; gBattle_BG1_Y = DISPLAY_HEIGHT; - SetGpuReg(REG_OFFSET_BG1HOFS, DISPLAY_WIDTH); - SetGpuReg(REG_OFFSET_BG1VOFS, DISPLAY_HEIGHT); - var = 0; - - CpuSet(&var, &sContest.unk19214, 0x05000400); - + SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); + SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); + + CpuFill32(0, gContestResources->field_24[1], 0x1000); + CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); Contest_SetBgCopyFlags(1); - + for (i = 0; i < 4; i++) { gSprites[gContestResources->field_14[i].unk0].oam.priority = 1; gSprites[gContestResources->field_14[i].unk1].oam.priority = 1; } - - /* ((vBgCnt *)®_BG1CNT)->priority = 0; - ((vBgCnt *)®_BG1CNT)->screenSize = 1; - ((vBgCnt *)®_BG1CNT)->areaOverflowMode = 0; - - - - DmaClear32(3, (void *)(VRAM + 0xF000), 0x1000); - LZDecompressVram(gUnknown_08D17C3C, (void *)(VRAM + 0xF000)); - - ((vBgCnt *)®_BG1CNT)->charBaseBlock = 0; - - for (i = 0; i < 4; i++) - { - gSprites[shared19338[i].unk0].oam.priority = 1; - gSprites[shared19338[i].unk1].oam.priority = 1; - } - - ((vBgCnt *)®_BG2CNT)->priority = 1; - ((vBgCnt *)®_BG0CNT)->priority = 1; - ((vBgCnt *)®_BG1CNT)->screenSize = 2; */ } -#else -NAKED -void sub_80DE224(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0xC\n\ - movs r0, 0xA\n\ - bl GetGpuReg\n\ - mov r1, sp\n\ - strh r0, [r1]\n\ - mov r2, sp\n\ - ldrb r1, [r2]\n\ - movs r4, 0x4\n\ - negs r4, r4\n\ - adds r0, r4, 0\n\ - ands r0, r1\n\ - strb r0, [r2]\n\ - ldrb r1, [r2, 0x1]\n\ - movs r0, 0x3F\n\ - ands r0, r1\n\ - movs r1, 0x80\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x1]\n\ - ldrb r1, [r2, 0x1]\n\ - movs r0, 0x21\n\ - negs r0, r0\n\ - ands r0, r1\n\ - strb r0, [r2, 0x1]\n\ - ldrb r1, [r2]\n\ - movs r0, 0xD\n\ - negs r0, r0\n\ - mov r8, r0\n\ - ands r0, r1\n\ - strb r0, [r2]\n\ - mov r0, sp\n\ - ldrh r1, [r0]\n\ - movs r0, 0xA\n\ - bl SetGpuReg\n\ - movs r0, 0x8\n\ - bl GetGpuReg\n\ - mov r6, sp\n\ - adds r6, 0x2\n\ - strh r0, [r6]\n\ - movs r0, 0xC\n\ - bl GetGpuReg\n\ - add r5, sp, 0x4\n\ - strh r0, [r5]\n\ - ldrb r1, [r6]\n\ - adds r0, r4, 0\n\ - ands r0, r1\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strb r0, [r6]\n\ - ldrb r0, [r5]\n\ - ands r4, r0\n\ - orrs r4, r1\n\ - strb r4, [r5]\n\ - ldrh r1, [r6]\n\ - movs r0, 0x8\n\ - bl SetGpuReg\n\ - ldrh r1, [r5]\n\ - movs r0, 0xC\n\ - bl SetGpuReg\n\ - ldr r1, =gBattle_BG1_X\n\ - movs r0, 0xF0\n\ - strh r0, [r1]\n\ - ldr r4, =gBattle_BG1_Y\n\ - movs r0, 0xA0\n\ - strh r0, [r4]\n\ - movs r0, 0x14\n\ - movs r1, 0xF0\n\ - bl SetGpuReg\n\ - ldrh r1, [r4]\n\ - movs r0, 0x16\n\ - bl SetGpuReg\n\ - movs r0, 0\n\ - str r0, [sp, 0x8]\n\ - add r0, sp, 0x8\n\ - ldr r4, =gContestResources\n\ - ldr r1, [r4]\n\ - ldr r1, [r1, 0x28]\n\ - ldr r2, =0x05000400\n\ - bl CpuSet\n\ - ldr r1, =gUnknown_08C17980\n\ - movs r0, 0x1\n\ - movs r2, 0\n\ - movs r3, 0\n\ - bl CopyToBgTilemapBuffer\n\ - movs r0, 0x1\n\ - bl Contest_SetBgCopyFlags\n\ - movs r5, 0\n\ - ldr r7, =gSprites\n\ - movs r6, 0x4\n\ -_080DE2F0:\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x14]\n\ - lsls r3, r5, 2\n\ - adds r0, r3, r0\n\ - ldrb r0, [r0]\n\ - lsls r1, r0, 4\n\ - adds r1, r0\n\ - lsls r1, 2\n\ - adds r1, r7\n\ - ldrb r2, [r1, 0x5]\n\ - mov r0, r8\n\ - ands r0, r2\n\ - orrs r0, r6\n\ - strb r0, [r1, 0x5]\n\ - ldr r0, [r4]\n\ - ldr r0, [r0, 0x14]\n\ - adds r3, r0\n\ - ldrb r0, [r3, 0x1]\n\ - lsls r1, r0, 4\n\ - adds r1, r0\n\ - lsls r1, 2\n\ - adds r1, r7\n\ - ldrb r2, [r1, 0x5]\n\ - mov r0, r8\n\ - ands r0, r2\n\ - orrs r0, r6\n\ - strb r0, [r1, 0x5]\n\ - adds r5, 0x1\n\ - cmp r5, 0x3\n\ - ble _080DE2F0\n\ - add sp, 0xC\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING void sub_80DE350(void) { s32 i; - s16 var; u16 bg1Cnt; - u8 *spriteID; - u16 something; RequestDma3Fill(0,(void *)(VRAM + 0x8000), 0x2000, 0x1); - //DmaClearLarge32(3, (void *)(VRAM + 0x8000), 0x2000, 0x1000); - - /*bg1Cnt = 0; - something = 0; - var = bg1Cnt; - spriteID = (u8 *)&gContestResources;*/ - - var = 0; - - - CpuSet(&var, &gContestResources->field_24[1], 0x05000400); - //CpuSet(src, (void *)(VRAM + 0x10000 + (gSprites[sContest.applauseMeterSpriteId].oam.tileNum + 17 + i) + CpuFill32(0, gContestResources->field_24[1], 0x1000); Contest_SetBgCopyFlags(1); - - //DmaClear32(3, (void *)(VRAM + 0xF000), 0x1000); - bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); - something = bg1Cnt; - ((struct BgCnt *) &bg1Cnt)->priority = 1; - ((struct BgCnt *) &bg1Cnt)->screenSize = 1; - ((struct BgCnt *) &bg1Cnt)->areaOverflowMode = 0; - ((struct BgCnt *) &bg1Cnt)->charBaseBlock = 2; - + ((vBgCnt *) &bg1Cnt)->priority = 1; + ((vBgCnt *) &bg1Cnt)->screenSize = 0; + ((vBgCnt *) &bg1Cnt)->areaOverflowMode = 0; + ((vBgCnt *) &bg1Cnt)->charBaseBlock = 2; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); gBattle_BG1_X = 0; @@ -5330,104 +4234,6 @@ void sub_80DE350(void) gSprites[gContestResources->field_14[i].unk1].oam.priority = 0; } } -#else -NAKED -void sub_80DE350(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - sub sp, 0x8\n\ - ldr r1, =0x06008000\n\ - movs r2, 0x80\n\ - lsls r2, 6\n\ - movs r0, 0\n\ - movs r3, 0x1\n\ - bl RequestDma3Fill\n\ - movs r5, 0\n\ - str r5, [sp]\n\ - ldr r6, =gContestResources\n\ - ldr r0, [r6]\n\ - ldr r1, [r0, 0x28]\n\ - ldr r2, =0x05000400\n\ - mov r0, sp\n\ - bl CpuSet\n\ - movs r0, 0x1\n\ - bl Contest_SetBgCopyFlags\n\ - movs r0, 0xA\n\ - bl GetGpuReg\n\ - add r3, sp, 0x4\n\ - strh r0, [r3]\n\ - ldrb r1, [r3]\n\ - movs r0, 0x4\n\ - negs r0, r0\n\ - ands r0, r1\n\ - movs r1, 0x1\n\ - orrs r0, r1\n\ - strb r0, [r3]\n\ - mov r1, sp\n\ - adds r1, 0x5\n\ - ldrb r2, [r1]\n\ - movs r0, 0x3F\n\ - ands r0, r2\n\ - strb r0, [r1]\n\ - ldrb r2, [r1]\n\ - movs r0, 0x21\n\ - negs r0, r0\n\ - ands r0, r2\n\ - strb r0, [r1]\n\ - ldrb r1, [r3]\n\ - movs r4, 0xD\n\ - negs r4, r4\n\ - adds r0, r4, 0\n\ - ands r0, r1\n\ - movs r1, 0x8\n\ - orrs r0, r1\n\ - strb r0, [r3]\n\ - ldrh r1, [r3]\n\ - movs r0, 0xA\n\ - bl SetGpuReg\n\ - ldr r0, =gBattle_BG1_X\n\ - strh r5, [r0]\n\ - ldr r0, =gBattle_BG1_Y\n\ - strh r5, [r0]\n\ - ldr r7, =gSprites\n\ -_080DE3CA:\n\ - ldr r0, [r6]\n\ - ldr r0, [r0, 0x14]\n\ - lsls r3, r5, 2\n\ - adds r0, r3, r0\n\ - ldrb r0, [r0]\n\ - lsls r1, r0, 4\n\ - adds r1, r0\n\ - lsls r1, 2\n\ - adds r1, r7\n\ - ldrb r2, [r1, 0x5]\n\ - adds r0, r4, 0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x5]\n\ - ldr r0, [r6]\n\ - ldr r0, [r0, 0x14]\n\ - adds r3, r0\n\ - ldrb r0, [r3, 0x1]\n\ - lsls r1, r0, 4\n\ - adds r1, r0\n\ - lsls r1, 2\n\ - adds r1, r7\n\ - ldrb r2, [r1, 0x5]\n\ - adds r0, r4, 0\n\ - ands r0, r2\n\ - strb r0, [r1, 0x5]\n\ - adds r5, 0x1\n\ - cmp r5, 0x3\n\ - ble _080DE3CA\n\ - add sp, 0x8\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_80DE424(u8 taskId) { @@ -5704,7 +4510,6 @@ void SelectContestMoveBankTarget(u16 move) } } -#ifdef NONMATCHING void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) { struct TextPrinterTemplate printerTemplate; @@ -5718,158 +4523,46 @@ void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) printerTemplate.currentY = 1; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - - printerTemplate.unk = a & (1 - 0x11); - printerTemplate.unk = 0xF0; - printerTemplate.bgColor = a & (1 - 0x11) & 0x80; - - - - + printerTemplate.unk = 0; + printerTemplate.fgColor = 15; + printerTemplate.bgColor = 0; + printerTemplate.shadowColor = 8; + AddTextPrinter(&printerTemplate, 0, 0); PutWindowTilemap(a); Contest_SetBgCopyFlags(0); } -#else -NAKED -void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) -{ - asm(".syntax unified\n\ - push {r4,lr}\n\ - sub sp, 0x10\n\ - adds r4, r0, 0\n\ - str r1, [sp]\n\ - mov r0, sp\n\ - movs r2, 0\n\ - strb r4, [r0, 0x4]\n\ - movs r1, 0x1\n\ - strb r1, [r0, 0x5]\n\ - strb r2, [r0, 0x6]\n\ - strb r1, [r0, 0x7]\n\ - strb r2, [r0, 0x8]\n\ - strb r1, [r0, 0x9]\n\ - strb r2, [r0, 0xA]\n\ - strb r2, [r0, 0xB]\n\ - mov r3, sp\n\ - ldrb r2, [r3, 0xC]\n\ - subs r1, 0x11\n\ - adds r0, r1, 0\n\ - ands r0, r2\n\ - strb r0, [r3, 0xC]\n\ - mov r2, sp\n\ - movs r0, 0xF0\n\ - strb r0, [r2, 0xC]\n\ - ldrb r0, [r2, 0xD]\n\ - ands r1, r0\n\ - strb r1, [r2, 0xD]\n\ - mov r1, sp\n\ - movs r0, 0x80\n\ - strb r0, [r1, 0xD]\n\ - mov r0, sp\n\ - movs r1, 0\n\ - movs r2, 0\n\ - bl AddTextPrinter\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - adds r0, r4, 0\n\ - bl PutWindowTilemap\n\ - movs r0, 0\n\ - bl Contest_SetBgCopyFlags\n\ - add sp, 0x10\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING -void Contest_PrintTextToBg0WindowAt(u32 a, u8 *b, s32 c, u8 d, u8 e) +void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId) { struct TextPrinterTemplate printerTemplate; - printerTemplate.currentChar = b; - printerTemplate.windowId = a; - printerTemplate.fontId = 1; - printerTemplate.x = c; - printerTemplate.y = d; - printerTemplate.currentX = c; - printerTemplate.currentY = d; + printerTemplate.currentChar = currChar; + printerTemplate.windowId = windowId; + printerTemplate.fontId = fontId; + printerTemplate.x = x; + printerTemplate.y = y; + printerTemplate.currentX = x; + printerTemplate.currentY = y; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - - printerTemplate.unk = a & (1 - 0x10); - printerTemplate.unk = 0xF0; - printerTemplate.bgColor = a & (1 - 0x11) & 0x80; - - - - + printerTemplate.unk = 0; + printerTemplate.fgColor = 15; + printerTemplate.bgColor = 0; + printerTemplate.shadowColor = 8; + AddTextPrinter(&printerTemplate, 0, 0); - PutWindowTilemap(a); + PutWindowTilemap(windowId); Contest_SetBgCopyFlags(0); } -#else -NAKED -void Contest_PrintTextToBg0WindowAt(u32 a, u8 *b, s32 c, u8 d, u8 e) -{ - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - sub sp, 0x10\n\ - adds r5, r0, 0\n\ - ldr r4, [sp, 0x1C]\n\ - str r1, [sp]\n\ - mov r0, sp\n\ - movs r1, 0\n\ - strb r5, [r0, 0x4]\n\ - strb r4, [r0, 0x5]\n\ - strb r2, [r0, 0x6]\n\ - strb r3, [r0, 0x7]\n\ - strb r2, [r0, 0x8]\n\ - strb r3, [r0, 0x9]\n\ - strb r1, [r0, 0xA]\n\ - strb r1, [r0, 0xB]\n\ - mov r3, sp\n\ - ldrb r2, [r3, 0xC]\n\ - subs r1, 0x10\n\ - adds r0, r1, 0\n\ - ands r0, r2\n\ - strb r0, [r3, 0xC]\n\ - mov r2, sp\n\ - movs r0, 0xF0\n\ - strb r0, [r2, 0xC]\n\ - ldrb r0, [r2, 0xD]\n\ - ands r1, r0\n\ - strb r1, [r2, 0xD]\n\ - mov r1, sp\n\ - movs r0, 0x80\n\ - strb r0, [r1, 0xD]\n\ - mov r0, sp\n\ - movs r1, 0\n\ - movs r2, 0\n\ - bl AddTextPrinter\n\ - lsls r5, 24\n\ - lsrs r5, 24\n\ - adds r0, r5, 0\n\ - bl PutWindowTilemap\n\ - movs r0, 0\n\ - bl Contest_SetBgCopyFlags\n\ - add sp, 0x10\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING -void Contest_StartTextPrinter(const u8 *a, u32 b) +void Contest_StartTextPrinter(const u8 *currChar, bool32 b) { struct TextPrinterTemplate printerTemplate; - u8 var; + u8 speed; - printerTemplate.currentChar = a; - printerTemplate.windowId = b; + printerTemplate.currentChar = currChar; + printerTemplate.windowId = 4; printerTemplate.fontId = 1; printerTemplate.x = 0; printerTemplate.y = 1; @@ -5877,166 +4570,33 @@ void Contest_StartTextPrinter(const u8 *a, u32 b) printerTemplate.currentY = 1; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - - printerTemplate.unk = b & -0x10; - printerTemplate.unk = 0x10; - printerTemplate.bgColor = b & (1 - 0x10) & 0x80; - - if(!b) + printerTemplate.unk = 0; + printerTemplate.fgColor = 1; + printerTemplate.bgColor = 0; + printerTemplate.shadowColor = 8; + + if (!b) { - var = 0; - AddTextPrinter(&printerTemplate, var, 0); + AddTextPrinter(&printerTemplate, 0, 0); } - else - { - if(gIsLinkContest & 1) - { - var = 4; - AddTextPrinter(&printerTemplate, var, 0); - } + else + { + if (gIsLinkContest & 1) + speed = 4; else - { - var = GetPlayerTextSpeedDelay(); - AddTextPrinter(&printerTemplate, var, 0); - } + speed = GetPlayerTextSpeedDelay(); + AddTextPrinter(&printerTemplate, speed, 0); } - + PutWindowTilemap(4); Contest_SetBgCopyFlags(0); - } -} -#else -NAKED -void Contest_StartTextPrinter(const u8 *a, u32 b) -{ - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - sub sp, 0x10\n\ - str r0, [sp]\n\ - mov r2, sp\n\ - movs r3, 0\n\ - movs r0, 0x4\n\ - strb r0, [r2, 0x4]\n\ - mov r0, sp\n\ - movs r5, 0x1\n\ - strb r5, [r0, 0x5]\n\ - strb r3, [r0, 0x6]\n\ - strb r5, [r0, 0x7]\n\ - strb r3, [r0, 0x8]\n\ - strb r5, [r0, 0x9]\n\ - strb r3, [r0, 0xA]\n\ - strb r3, [r0, 0xB]\n\ - mov r4, sp\n\ - ldrb r3, [r4, 0xC]\n\ - movs r2, 0x10\n\ - negs r2, r2\n\ - adds r0, r2, 0\n\ - ands r0, r3\n\ - strb r0, [r4, 0xC]\n\ - mov r3, sp\n\ - movs r0, 0x10\n\ - strb r0, [r3, 0xC]\n\ - ldrb r0, [r3, 0xD]\n\ - ands r2, r0\n\ - strb r2, [r3, 0xD]\n\ - mov r2, sp\n\ - movs r0, 0x80\n\ - strb r0, [r2, 0xD]\n\ - cmp r1, 0\n\ - bne _080DEC80\n\ - mov r0, sp\n\ - movs r1, 0\n\ - movs r2, 0\n\ - bl AddTextPrinter\n\ - b _080DECA4\n\ -_080DEC80:\n\ - ldr r0, =gIsLinkContest\n\ - ldrb r1, [r0]\n\ - adds r0, r5, 0\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080DEC94\n\ - movs r1, 0x4\n\ - b _080DEC9C\n\ - .pool\n\ -_080DEC94:\n\ - bl GetPlayerTextSpeedDelay\n\ - lsls r0, 24\n\ - lsrs r1, r0, 24\n\ -_080DEC9C:\n\ - mov r0, sp\n\ - movs r2, 0\n\ - bl AddTextPrinter\n\ -_080DECA4:\n\ - movs r0, 0x4\n\ - bl PutWindowTilemap\n\ - movs r0, 0\n\ - bl Contest_SetBgCopyFlags\n\ - add sp, 0x10\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING -void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) +void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, s16 h) { - s16 var = h; - WriteSequenceToBgTilemapBuffer(a, b, c, d, e, f, g, var); + WriteSequenceToBgTilemapBuffer(a, b, c, d, e, f, g, h); Contest_SetBgCopyFlags(a); } -#else -NAKED -void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0x10\n\ - mov r8, r0\n\ - ldr r0, [sp, 0x28]\n\ - ldr r4, [sp, 0x2C]\n\ - ldr r5, [sp, 0x30]\n\ - ldr r6, [sp, 0x34]\n\ - mov r7, r8\n\ - lsls r7, 24\n\ - lsrs r7, 24\n\ - mov r8, r7\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - lsls r5, 24\n\ - lsrs r5, 24\n\ - str r0, [sp]\n\ - str r4, [sp, 0x4]\n\ - str r5, [sp, 0x8]\n\ - lsls r6, 16\n\ - asrs r6, 16\n\ - str r6, [sp, 0xC]\n\ - mov r0, r8\n\ - bl WriteSequenceToBgTilemapBuffer\n\ - mov r0, r8\n\ - bl Contest_SetBgCopyFlags\n\ - add sp, 0x10\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} -#endif void ContestBG_FillBoxWithTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g) { @@ -6058,8 +4618,8 @@ void ResetContestLinkResults(void) { s32 i; s32 j; - - for(i = 0; i < 5; i++) + + for(i = 0; i < 5; i++) for(j = 0; j < 4; j++) gSaveBlock2Ptr->contestLinkResults[i][j] = 0; } @@ -6107,7 +4667,7 @@ bool8 sub_80DEDA8(u8 a) gSaveBlock1Ptr->contestWinners[r4].contestRank = 4; else gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank; - + if (a != 0xFF) gSaveBlock1Ptr->contestWinners[r4].contestCategory = gSpecialVar_ContestCategory; else @@ -6165,4 +4725,4 @@ void ClearContestWinnerPicsInContestHall(void) for (i = 0; i < 8; i++) gSaveBlock1Ptr->contestWinners[i] = gUnknown_08587FA4[i]; -} \ No newline at end of file +} From ad59811154093d63343528cccf59a5746dcca934 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 28 Jan 2019 18:13:07 +0100 Subject: [PATCH 10/12] Decompile whole contest --- asm/contest.s | 1324 --------------------------------------------- include/contest.h | 108 ++-- include/text.h | 5 + include/tv.h | 5 + ld_script.txt | 1 - src/contest.c | 1124 ++++++++++++++++++++++++++------------ 6 files changed, 860 insertions(+), 1707 deletions(-) delete mode 100644 asm/contest.s diff --git a/asm/contest.s b/asm/contest.s deleted file mode 100644 index f30eb3261..000000000 --- a/asm/contest.s +++ /dev/null @@ -1,1324 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80DF080 -sub_80DF080: @ 80DF080 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r2, =gContestResources - ldr r3, [r2] - ldr r5, [r3, 0x10] - ldrb r1, [r5, 0x1] - movs r7, 0x1 - adds r0, r7, 0 - ands r0, r1 - adds r6, r2, 0 - cmp r0, 0 - bne _080DF0D2 - movs r0, 0 - ldrsb r0, [r5, r0] - cmp r0, 0 - ble _080DF0D2 - ldr r1, [r3, 0x4] - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x15] - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - bne _080DF0D2 - ldr r1, [r3, 0x1C] - lsls r2, r4, 4 - adds r1, r2, r1 - ldrb r3, [r1, 0xC] - movs r0, 0x1 - orrs r0, r3 - strb r0, [r1, 0xC] - ldr r0, [r6] - ldr r0, [r0, 0x1C] - adds r2, r0 - ldrb r0, [r2, 0xE] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2, 0xE] -_080DF0D2: - ldr r3, [r6] - ldr r1, [r3, 0x4] - lsls r2, r4, 3 - subs r0, r2, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0xC] - movs r5, 0x1 - adds r0, r5, 0 - ands r0, r1 - adds r7, r2, 0 - cmp r0, 0 - beq _080DF0FA - ldr r0, [r3, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xC] - movs r0, 0x2 - orrs r0, r2 - strb r0, [r1, 0xC] -_080DF0FA: - ldr r3, [r6] - ldr r2, [r3, 0x10] - ldrb r1, [r2, 0x1] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - bne _080DF126 - movs r0, 0 - ldrsb r0, [r2, r0] - cmp r0, 0 - beq _080DF126 - movs r0, 0x2 - ldrsb r0, [r2, r0] - cmp r0, 0x3C - bne _080DF126 - ldr r0, [r3, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xC] - movs r0, 0x4 - orrs r0, r2 - strb r0, [r1, 0xC] -_080DF126: - ldr r3, [r6] - ldr r1, [r3, 0x4] - subs r0, r7, r4 - lsls r0, 2 - adds r2, r0, r1 - ldrb r1, [r2, 0x15] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080DF14E - ldrb r0, [r2, 0x16] - cmp r0, 0 - beq _080DF14E - ldr r0, [r3, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xC] - movs r0, 0x8 - orrs r0, r2 - strb r0, [r1, 0xC] -_080DF14E: - movs r3, 0 - movs r5, 0 -_080DF152: - cmp r3, r4 - beq _080DF180 - ldr r1, [r6] - ldr r0, [r1, 0x4] - adds r0, r5, r0 - ldrb r0, [r0, 0xE] - cmp r0, 0 - beq _080DF180 - ldr r0, [r1, 0x1C] - lsls r2, r4, 4 - adds r2, r0 - ldrb r0, [r2, 0xC] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r2, 0xC] - ldr r0, [r6] - ldr r0, [r0, 0x1C] - lsls r2, r3, 4 - adds r2, r0 - ldrb r0, [r2, 0xC] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2, 0xC] -_080DF180: - adds r5, 0x1C - adds r3, 0x1 - cmp r3, 0x3 - ble _080DF152 - ldr r2, [r6] - ldr r1, [r2, 0x4] - subs r0, r7, r4 - lsls r5, r0, 2 - adds r1, r5, r1 - ldrb r3, [r1, 0xC] - movs r0, 0x6 - ands r0, r3 - cmp r0, 0 - bne _080DF1A6 - ldrb r1, [r1, 0xB] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080DF1BC -_080DF1A6: - ldr r0, [r2, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xC] - movs r0, 0x20 - orrs r0, r2 - strb r0, [r1, 0xC] - b _080DF1F6 - .pool -_080DF1BC: - movs r0, 0x1 - ands r0, r3 - cmp r0, 0 - bne _080DF1F6 - ldr r2, [r2, 0x1C] - lsls r3, r4, 4 - adds r2, r3, r2 - ldrb r0, [r2, 0xC] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0xC] - ldr r0, [r6] - ldr r1, [r0, 0x1C] - adds r1, r3, r1 - ldrb r0, [r1, 0xE] - movs r2, 0x1 - orrs r0, r2 - strb r0, [r1, 0xE] - ldr r1, [r6] - ldr r0, [r1, 0x1C] - adds r3, r0 - ldr r0, [r1] - ldrb r0, [r0, 0x1] - lsls r0, 1 - adds r3, r0 - ldr r0, [r1, 0x4] - adds r0, r5, r0 - ldrh r0, [r0, 0x6] - strh r0, [r3] -_080DF1F6: - ldr r2, [r6] - ldr r1, [r2, 0x4] - subs r0, r7, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x15] - movs r5, 0x1 - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _080DF21A - ldr r0, [r2, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xD] - movs r0, 0x2 - orrs r0, r2 - strb r0, [r1, 0xD] -_080DF21A: - ldr r2, [r6] - ldr r0, [r2] - ldrb r0, [r0, 0x13] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x4 - bne _080DF24A - ldr r3, [r2, 0x10] - ldrb r1, [r3, 0x1] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - bne _080DF24A - movs r0, 0 - ldrsb r0, [r3, r0] - cmp r0, 0 - bge _080DF24A - ldr r0, [r2, 0x1C] - lsls r1, r4, 4 - adds r1, r0 - ldrb r2, [r1, 0xD] - movs r0, 0x20 - orrs r0, r2 - strb r0, [r1, 0xD] -_080DF24A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80DF080 - - thumb_func_start sub_80DF250 -sub_80DF250: @ 80DF250 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x38 - movs r1, 0 - movs r0, 0 - str r0, [sp, 0x20] - movs r4, 0 - ldr r6, =gContestResources - mov r2, sp - adds r2, 0xC - str r2, [sp, 0x28] - mov r3, sp - adds r3, 0x14 - str r3, [sp, 0x2C] - mov r7, sp - adds r7, 0x2 - str r7, [sp, 0x24] - ldr r5, =gContestFinalStandings - movs r2, 0 - movs r3, 0x80 - lsls r3, 17 -_080DF280: - adds r0, r4, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _080DF298 - lsrs r0, r2, 24 - str r0, [sp, 0x20] - b _080DF29E - .pool -_080DF298: - cmp r0, 0x3 - bne _080DF29E - lsrs r1, r2, 24 -_080DF29E: - adds r2, r3 - adds r4, 0x1 - cmp r4, 0x3 - ble _080DF280 - ldr r0, [r6] - ldr r0, [r0, 0x1C] - lsls r1, 4 - adds r1, r0 - ldrb r2, [r1, 0xD] - movs r0, 0x1 - orrs r0, r2 - strb r0, [r1, 0xD] - movs r4, 0 - ldr r1, [sp, 0x20] - lsls r1, 4 - str r1, [sp, 0x30] - mov r9, r4 - mov r10, r4 -_080DF2C2: - ldr r2, [sp, 0x20] - cmp r4, r2 - beq _080DF2EE - ldr r1, =gUnknown_02039F08 - lsls r0, r2, 1 - adds r0, r1 - movs r3, 0 - ldrsh r2, [r0, r3] - add r1, r10 - movs r6, 0 - ldrsh r0, [r1, r6] - subs r2, r0 - cmp r2, 0x32 - bgt _080DF2EE - ldr r7, =gContestResources - ldr r0, [r7] - ldr r2, [r0, 0x1C] - add r2, r9 - ldrb r0, [r2, 0xD] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2, 0xD] -_080DF2EE: - ldr r1, =gContestResources - ldr r0, [r1] - ldr r0, [r0, 0x1C] - mov r3, r9 - adds r2, r3, r0 - ldrb r1, [r2, 0xE] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _080DF30A - ldrb r0, [r2, 0xD] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r2, 0xD] -_080DF30A: - movs r5, 0 - ldr r2, =gContestMonConditions - add r2, r10 - movs r6, 0 - ldrsh r1, [r2, r6] - ldr r7, =gContestMonConditions - movs r3, 0 - ldrsh r0, [r7, r3] - cmp r1, r0 - blt _080DF336 - adds r3, r2, 0 - adds r2, r7, 0 -_080DF322: - adds r2, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - bgt _080DF336 - movs r6, 0 - ldrsh r1, [r3, r6] - movs r7, 0 - ldrsh r0, [r2, r7] - cmp r1, r0 - bge _080DF322 -_080DF336: - cmp r5, 0x4 - bne _080DF354 - ldr r1, =gContestFinalStandings - adds r0, r4, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080DF354 - ldr r2, =gContestResources - ldr r0, [r2] - ldr r2, [r0, 0x1C] - add r2, r9 - ldrb r0, [r2, 0xD] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r2, 0xD] -_080DF354: - movs r3, 0 - mov r12, r3 - mov r8, r3 - movs r5, 0 - ldr r0, =gContestMonConditions - add r0, r10 - movs r7, 0 - ldrsh r6, [r0, r7] - str r6, [sp, 0x34] - ldr r2, =gContestMonConditions - ldr r0, =gUnknown_02039F18 - mov r1, r10 - adds r6, r1, r0 - adds r3, r0, 0 -_080DF370: - movs r7, 0 - ldrsh r0, [r2, r7] - ldr r1, [sp, 0x34] - cmp r1, r0 - ble _080DF37E - movs r7, 0x1 - mov r12, r7 -_080DF37E: - movs r0, 0 - ldrsh r1, [r6, r0] - movs r7, 0 - ldrsh r0, [r3, r7] - cmp r1, r0 - ble _080DF38E - movs r0, 0x1 - mov r8, r0 -_080DF38E: - adds r2, 0x2 - adds r3, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _080DF370 - mov r1, r12 - cmp r1, 0 - bne _080DF3B4 - mov r2, r8 - cmp r2, 0 - bne _080DF3B4 - ldr r3, =gContestResources - ldr r0, [r3] - ldr r2, [r0, 0x1C] - add r2, r9 - ldrb r0, [r2, 0xD] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2, 0xD] -_080DF3B4: - ldr r6, =gContestResources - ldr r0, [r6] - ldr r0, [r0, 0x1C] - mov r7, r9 - adds r2, r7, r0 - ldrb r1, [r2, 0xE] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080DF3D0 - ldrb r0, [r2, 0xD] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0xD] -_080DF3D0: - movs r0, 0x10 - add r9, r0 - movs r1, 0x2 - add r10, r1 - adds r4, 0x1 - cmp r4, 0x3 - bgt _080DF3E0 - b _080DF2C2 -_080DF3E0: - movs r4, 0 - movs r5, 0 - movs r3, 0 - ldr r2, [sp, 0x28] - mov r1, sp -_080DF3EA: - strh r3, [r1] - adds r0, r2, r4 - strb r5, [r0] - adds r1, 0x2 - adds r4, 0x1 - cmp r4, 0x4 - ble _080DF3EA - mov r1, sp - ldr r0, =0x0000ffff - strh r0, [r1, 0xA] - movs r0, 0 - ldr r2, [sp, 0x28] - strb r0, [r2, 0x5] - movs r4, 0 - ldr r0, =gContestResources - ldr r0, [r0] - mov r8, r0 - ldr r7, [sp, 0x30] -_080DF40E: - mov r3, r8 - ldr r0, [r3, 0x1C] - adds r0, r7, r0 - lsls r1, r4, 1 - adds r0, r1 - ldrh r0, [r0] - adds r4, 0x1 - mov r12, r4 - cmp r0, 0 - beq _080DF450 - ldr r0, =gContestResources - ldr r6, [r0] - ldr r3, [sp, 0x28] - mov r4, sp - movs r5, 0x4 -_080DF42C: - ldr r0, [r6, 0x1C] - adds r0, r7, r0 - adds r0, r1 - ldrh r0, [r0] - ldrh r2, [r4] - cmp r0, r2 - beq _080DF440 - cmp r2, 0 - bne _080DF446 - strh r0, [r4] -_080DF440: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] -_080DF446: - adds r3, 0x1 - adds r4, 0x2 - subs r5, 0x1 - cmp r5, 0 - bge _080DF42C -_080DF450: - mov r4, r12 - cmp r4, 0x4 - ble _080DF40E - mov r0, sp - ldrh r0, [r0] - ldr r6, [sp, 0x2C] - strh r0, [r6] - ldr r7, [sp, 0x28] - ldrb r3, [r7] - movs r6, 0 - movs r4, 0x1 - ldr r1, [sp, 0x24] - ldrh r0, [r1] - ldr r1, =0x0000ffff - cmp r0, r1 - beq _080DF4C0 - ldr r5, [sp, 0x2C] - adds r7, r1, 0 - mov r2, sp - adds r2, 0x2 -_080DF478: - ldr r0, [sp, 0x28] - adds r1, r0, r4 - ldrb r0, [r1] - cmp r3, r0 - bcs _080DF4A4 - ldrh r0, [r2] - strh r0, [r5] - ldrb r3, [r1] - movs r6, 0x1 - b _080DF4B6 - .pool -_080DF4A4: - cmp r3, r0 - bne _080DF4B6 - lsls r0, r6, 1 - adds r0, r5, r0 - ldrh r1, [r2] - strh r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_080DF4B6: - adds r2, 0x2 - adds r4, 0x1 - ldrh r0, [r2] - cmp r0, r7 - bne _080DF478 -_080DF4C0: - bl Random - ldr r1, =gContestResources - ldr r1, [r1] - ldr r4, [r1, 0x1C] - ldr r1, [sp, 0x30] - adds r4, r1, r4 - lsls r0, 16 - lsrs r0, 16 - adds r1, r6, 0 - bl __modsi3 - lsls r0, 1 - ldr r2, [sp, 0x2C] - adds r0, r2, r0 - ldrh r0, [r0] - strh r0, [r4, 0xA] - add sp, 0x38 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DF250 - - thumb_func_start sub_80DF4F8 -sub_80DF4F8: @ 80DF4F8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - ldr r1, =gContestFinalStandings - ldr r0, =gContestPlayerMonIndex - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080DF514 - b _080DF6EE -_080DF514: - movs r7, 0 - movs r3, 0 - ldr r0, =gContestResources - mov r12, r0 -_080DF51C: - adds r0, r3, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080DF528 - lsls r0, r3, 24 - lsrs r7, r0, 24 -_080DF528: - adds r3, 0x1 - cmp r3, 0x3 - ble _080DF51C - movs r1, 0 - mov r9, r1 - mov r10, r1 - movs r3, 0 - lsls r2, r7, 1 - lsls r4, r7, 4 - mov r8, r4 - ldr r1, =gContestMonConditions - adds r0, r2, r1 - movs r6, 0 - ldrsh r5, [r0, r6] - str r5, [sp, 0x8] - adds r5, r1, 0 - ldr r0, =gUnknown_02039F18 - adds r2, r0 - adds r4, r0, 0 -_080DF54E: - movs r1, 0 - ldrsh r0, [r5, r1] - ldr r6, [sp, 0x8] - cmp r6, r0 - bge _080DF562 - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080DF562: - movs r0, 0 - ldrsh r1, [r2, r0] - movs r6, 0 - ldrsh r0, [r4, r6] - cmp r1, r0 - bge _080DF578 - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 -_080DF578: - adds r5, 0x2 - adds r4, 0x2 - adds r3, 0x1 - cmp r3, 0x3 - ble _080DF54E - mov r1, r12 - ldr r0, [r1] - ldr r0, [r0, 0x1C] - add r0, r8 - ldrb r1, [r0, 0xC] - movs r4, 0 - movs r2, 0x1 - movs r3, 0x7 -_080DF592: - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _080DF5A0 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080DF5A0: - lsrs r1, 1 - subs r3, 0x1 - cmp r3, 0 - bge _080DF592 - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r4, 0 - bl __modsi3 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x1C] - add r0, r8 - ldrb r1, [r0, 0xC] - movs r4, 0 - movs r2, 0 - movs r3, 0 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080DF5DC - cmp r5, 0 - beq _080DF5F6 -_080DF5D6: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080DF5DC: - lsrs r1, 1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - adds r3, 0x1 - cmp r3, 0x7 - bgt _080DF5F6 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080DF5DC - cmp r5, r4 - bne _080DF5D6 -_080DF5F6: - movs r1, 0x1 - adds r0, r1, 0 - lsls r0, r2 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r7, 0 - bne _080DF628 - mov r0, sp - strb r1, [r0] - ldr r1, =gContestResources - ldr r0, [r1] - ldr r0, [r0, 0x1C] - ldrb r4, [r0, 0x1D] - movs r3, 0x2 - b _080DF638 - .pool -_080DF628: - mov r1, sp - movs r0, 0 - strb r0, [r1] - ldr r1, =gContestResources - ldr r0, [r1] - ldr r0, [r0, 0x1C] - ldrb r4, [r0, 0xD] - movs r3, 0x1 -_080DF638: - mov r12, r1 - movs r5, 0x1 - lsls r2, 24 - str r2, [sp, 0x4] - cmp r3, 0x3 - bgt _080DF682 -_080DF644: - cmp r3, r7 - beq _080DF67C - mov r6, r12 - ldr r2, [r6] - ldr r0, [r2, 0x1C] - lsls r1, r3, 4 - adds r0, r1, r0 - ldrb r0, [r0, 0xD] - cmp r4, r0 - bcs _080DF66C - mov r0, sp - strb r3, [r0] - ldr r0, [r2, 0x1C] - adds r0, r1, r0 - ldrb r4, [r0, 0xD] - movs r5, 0x1 - b _080DF67C - .pool -_080DF66C: - cmp r4, r0 - bne _080DF67C - mov r1, sp - adds r0, r1, r5 - strb r3, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_080DF67C: - adds r3, 0x1 - cmp r3, 0x3 - ble _080DF644 -_080DF682: - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r5, 0 - bl __modsi3 - add r0, sp - ldrb r6, [r0] - movs r2, 0x80 - movs r3, 0 - ldr r5, =gContestResources - ldr r0, [r5] - ldr r0, [r0, 0x1C] - lsls r1, r6, 4 - adds r0, r1, r0 - ldrb r0, [r0, 0xD] - ands r0, r2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _080DF6C4 -_080DF6AE: - lsrs r2, 1 - adds r3, 0x1 - cmp r3, 0x7 - bgt _080DF6C4 - ldr r0, [r5] - ldr r0, [r0, 0x1C] - adds r0, r1, r0 - ldrb r4, [r0, 0xD] - ands r4, r2 - cmp r4, 0 - beq _080DF6AE -_080DF6C4: - mov r0, r9 - bl ContestLiveUpdates_BeforeInterview_1 - mov r0, r10 - bl ContestLiveUpdates_BeforeInterview_2 - ldr r5, [sp, 0x4] - lsrs r0, r5, 24 - bl ContestLiveUpdates_BeforeInterview_3 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x1C] - add r0, r8 - ldrh r0, [r0, 0xA] - bl ContestLiveUpdates_BeforeInterview_4 - adds r0, r4, 0 - adds r1, r6, 0 - bl ContestLiveUpdates_BeforeInterview_5 -_080DF6EE: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DF4F8 - - thumb_func_start sub_80DF704 -sub_80DF704: @ 80DF704 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, =gHeap - movs r1, 0xD0 - lsls r1, 9 - adds r2, r0, r1 - ldrb r1, [r2] - adds r4, r0, 0 - cmp r1, 0 - bne _080DF72C - cmp r3, 0 - bne _080DF728 - movs r0, 0x2 - b _080DF72E - .pool -_080DF728: - movs r0, 0x3 - b _080DF72E -_080DF72C: - movs r0, 0 -_080DF72E: - strb r0, [r2] - movs r1, 0xD0 - lsls r1, 9 - adds r0, r4, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080DF746 - bl sub_80DAEA4 - bl sub_80DB2BC - b _080DF74A -_080DF746: - bl sub_80DF750 -_080DF74A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80DF704 - - thumb_func_start sub_80DF750 -sub_80DF750: @ 80DF750 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x34 - ldr r0, =gUnknown_020322D5 - ldrb r0, [r0] - cmp r0, 0 - bne _080DF766 - b _080DF924 -_080DF766: - ldr r0, =gHeap - movs r1, 0xD0 - lsls r1, 9 - adds r0, r1 - ldrb r0, [r0] - subs r0, 0x2 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _080DF77C - b _080DF924 -_080DF77C: - movs r7, 0 - mov r2, sp - adds r2, 0x18 - str r2, [sp, 0x30] -_080DF784: - adds r0, r7, 0 - movs r1, 0 - bl FillWindowPixelBuffer - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _080DF784 - ldr r0, =gHeap - movs r1, 0xD0 - lsls r1, 9 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x2 - bne _080DF874 - movs r7, 0 - movs r2, 0x7 - mov r10, r2 - ldr r0, [sp, 0x30] - mov r9, r0 -_080DF7AE: - add r0, sp, 0x4 - ldr r1, =gText_CDot - bl StringCopy - adds r5, r0, 0 - ldr r0, =gUnknown_02039F26 - adds r0, r7, r0 - ldrb r0, [r0] - mov r1, r10 - str r1, [sp] - add r1, sp, 0x4 - movs r2, 0x5 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x1C] - lsls r0, r7, 4 - adds r0, r1 - ldrb r4, [r0, 0xC] - movs r6, 0x7 - adds r2, r7, 0x1 - mov r8, r2 -_080DF7DE: - movs r1, 0x1 - ands r1, r4 - adds r0, r5, 0 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - adds r5, r0, 0 - lsrs r4, 1 - lsls r0, r6, 24 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r6, r0, 24 - asrs r0, 24 - movs r2, 0x1 - negs r2, r2 - cmp r0, r2 - bgt _080DF7DE - movs r6, 0 - ldr r4, =gUnknown_02039F26 - ldr r3, [sp, 0x30] -_080DF80A: - lsls r0, r6, 24 - asrs r0, 24 - adds r2, r3, r0 - mov r1, sp - adds r1, r0 - adds r1, 0x4 - ldrb r1, [r1] - strb r1, [r2] - adds r0, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - asrs r5, r0, 24 - cmp r5, 0x4 - ble _080DF80A - mov r0, r9 - adds r1, r0, r5 - movs r0, 0xFF - strb r0, [r1] - adds r4, r7, r4 - ldrb r0, [r4] - mov r1, r10 - str r1, [sp] - mov r1, r9 - movs r2, 0x5 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - ldrb r0, [r4] - mov r1, sp - adds r1, r5 - adds r1, 0x4 - mov r2, r10 - str r2, [sp] - movs r2, 0x37 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - mov r1, r8 - lsls r0, r1, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _080DF7AE - b _080DF920 - .pool -_080DF874: - movs r7, 0 - mov r2, sp - adds r2, 0x6 - str r2, [sp, 0x2C] - ldr r0, [sp, 0x30] - mov r9, r0 - movs r1, 0x7 - mov r10, r1 -_080DF884: - add r0, sp, 0x4 - ldr r1, =gText_BDot - bl StringCopy - ldr r0, =gContestResources - ldr r0, [r0] - ldr r1, [r0, 0x1C] - lsls r0, r7, 4 - adds r0, r1 - ldrb r4, [r0, 0xD] - ldr r5, [sp, 0x2C] - movs r6, 0x7 - adds r2, r7, 0x1 - mov r8, r2 -_080DF8A0: - movs r1, 0x1 - ands r1, r4 - adds r0, r5, 0 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - adds r5, r0, 0 - lsrs r4, 1 - lsls r0, r6, 24 - movs r1, 0xFF - lsls r1, 24 - adds r0, r1 - lsrs r6, r0, 24 - asrs r0, 24 - movs r2, 0x1 - negs r2, r2 - cmp r0, r2 - bgt _080DF8A0 - movs r6, 0 - ldr r4, =gUnknown_02039F26 - ldr r3, [sp, 0x30] -_080DF8CC: - lsls r0, r6, 24 - asrs r0, 24 - adds r2, r3, r0 - mov r1, sp - adds r1, r0 - adds r1, 0x4 - ldrb r1, [r1] - strb r1, [r2] - adds r0, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - asrs r5, r0, 24 - cmp r5, 0x4 - ble _080DF8CC - mov r0, r9 - adds r1, r0, r5 - movs r0, 0xFF - strb r0, [r1] - adds r4, r7, r4 - ldrb r0, [r4] - mov r1, r10 - str r1, [sp] - mov r1, r9 - movs r2, 0x5 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - ldrb r0, [r4] - mov r1, sp - adds r1, r5 - adds r1, 0x4 - mov r2, r10 - str r2, [sp] - movs r2, 0x37 - movs r3, 0x1 - bl Contest_PrintTextToBg0WindowAt - mov r1, r8 - lsls r0, r1, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _080DF884 -_080DF920: - bl sub_80DB2BC -_080DF924: - add sp, 0x34 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DF750 - - thumb_func_start sub_80DF940 -sub_80DF940: @ 80DF940 - push {r4,r5,lr} - adds r4, r0, 0 - movs r5, 0x2 - ldrb r0, [r4] - cmp r0, 0xFC - bne _080DF956 - ldrb r0, [r4, 0x1] - cmp r0, 0x15 - bne _080DF956 - movs r0, 0x2 - b _080DF9CC -_080DF956: - adds r0, r4, 0 - bl StringLength - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bhi _080DF9CA - ldrb r0, [r4] - cmp r0, 0xFF - beq _080DF9CA -_080DF96A: - ldrb r1, [r4] - adds r0, r1, 0 - adds r0, 0x45 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x33 - bls _080DF9BE - adds r0, r1, 0 - adds r0, 0x5F - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bls _080DF9BE - adds r0, r1, 0 - cmp r0, 0 - beq _080DF9BE - cmp r0, 0xAD - beq _080DF9BE - cmp r0, 0xB8 - beq _080DF9BE - cmp r0, 0xAB - beq _080DF9BE - cmp r0, 0xAC - beq _080DF9BE - cmp r0, 0xB5 - beq _080DF9BE - cmp r0, 0xB6 - beq _080DF9BE - cmp r0, 0xBA - beq _080DF9BE - cmp r0, 0xAE - beq _080DF9BE - cmp r0, 0xB0 - beq _080DF9BE - cmp r0, 0xB1 - beq _080DF9BE - cmp r0, 0xB2 - beq _080DF9BE - cmp r0, 0xB3 - beq _080DF9BE - cmp r0, 0xB1 - bne _080DF9C8 -_080DF9BE: - adds r4, 0x1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _080DF96A - b _080DF9CA -_080DF9C8: - movs r5, 0x1 -_080DF9CA: - adds r0, r5, 0 -_080DF9CC: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80DF940 - - thumb_func_start sub_80DF9D4 -sub_80DF9D4: @ 80DF9D4 - ldrb r2, [r0, 0x5] - movs r1, 0xFF - strb r1, [r0, 0x5] - strb r2, [r0, 0x7] - bx lr - thumb_func_end sub_80DF9D4 - - thumb_func_start sub_80DF9E0 -sub_80DF9E0: @ 80DF9E0 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - bl StripExtCtrlCodes - cmp r4, 0x1 - bne _080DF9F8 - movs r0, 0xFF - strb r0, [r5, 0x5] - movs r0, 0xFC - strb r0, [r5, 0xA] - b _080DFA00 -_080DF9F8: - ldrb r1, [r5, 0x5] - movs r0, 0xFF - strb r0, [r5, 0x5] - strb r1, [r5, 0xA] -_080DFA00: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80DF9E0 - - thumb_func_start sub_80DFA08 -sub_80DFA08: @ 80DFA08 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - adds r4, r5, 0x2 - cmp r6, 0x1 - bne _080DFA28 - adds r0, r4, 0 - bl sub_80DF940 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl ConvertInternationalString - b _080DFA3E -_080DFA28: - ldrb r0, [r4, 0xA] - cmp r0, 0xFC - bne _080DFA38 - adds r0, r4, 0 - movs r1, 0x1 - bl ConvertInternationalString - b _080DFA3E -_080DFA38: - strb r0, [r4, 0x5] - movs r0, 0xFF - strb r0, [r4, 0xA] -_080DFA3E: - adds r4, r5, 0 - adds r4, 0xD - cmp r6, 0x1 - bne _080DFA68 - movs r0, 0xFF - strb r0, [r4, 0x7] - ldrb r0, [r4, 0x4] - strb r0, [r4, 0x6] - ldrb r0, [r4, 0x3] - strb r0, [r4, 0x5] - ldrb r0, [r4, 0x2] - strb r0, [r4, 0x4] - ldrb r0, [r4, 0x1] - strb r0, [r4, 0x3] - ldrb r0, [r5, 0xD] - strb r0, [r4, 0x2] - movs r0, 0x15 - strb r0, [r4, 0x1] - movs r0, 0xFC - strb r0, [r5, 0xD] - b _080DFA70 -_080DFA68: - ldrb r0, [r4, 0x7] - strb r0, [r4, 0x5] - movs r0, 0xFF - strb r0, [r4, 0x7] -_080DFA70: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80DFA08 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/contest.h b/include/contest.h index 65db7b0bc..35b88698e 100644 --- a/include/contest.h +++ b/include/contest.h @@ -221,22 +221,6 @@ struct ContestPokemon /*0x3C*/ u32 otId; // otId }; // wow -extern struct ContestPokemon gContestMons[4]; -extern u8 gContestMonPartyIndex; -extern u16 gSpecialVar_ContestCategory; -extern u16 gSpecialVar_ContestRank; -extern u8 gUnknown_02039F2B; -extern u8 gNumLinkContestPlayers; -extern u8 gHighestRibbonRank; -extern u8 gContestFinalStandings[4]; -extern u8 gContestPlayerMonIndex; -extern s16 gUnknown_02039F08[4]; -extern s16 gUnknown_02039F10[4]; -extern s16 gUnknown_02039F18[4]; -extern s16 gContestMonConditions[4]; -extern u8 gIsLinkContest; -extern struct ContestWinner gUnknown_02039F3C; - struct Shared18000 { /*0x18000*/ u8 unk18000; @@ -260,10 +244,10 @@ struct ContestStruct_field_18 struct Contest { - /*0x19204*/ u8 playerMoveChoice; - /*0x19205*/ u8 turnNumber; - /*0x19206*/ u8 unk19206[4]; // seems to only be used by an unref function - /*0x1920A*/ u16 unk1920A_0:1; // Task active flags? + /*0x0*/ u8 playerMoveChoice; + /*0x1*/ u8 turnNumber; + /*0x2*/ u8 unk19206[4]; // seems to only be used by an unref function + /*0x6*/ u16 unk1920A_0:1; // Task active flags? u16 unk1920A_1:1; u16 unk1920A_2:1; u16 unk1920A_3:1; @@ -271,18 +255,18 @@ struct Contest u16 unk1920A_5:1; u16 unk1920A_6:1; u16 unk1920A_7:1; - /*0x1920B*/ u16 unk1920B_0:1; + /*0x7*/ u16 unk1920B_0:1; u16 unk1920B_1:1; u16 unk1920B_2:1; - /*0x1920C*/ u8 mainTaskId; - /*0x1920D*/ u8 unk1920D[4]; - /*0x19211*/ u8 unk19211; - /*0x19212*/ u8 unk19212; - /*0x19213*/ u8 filler19213; - /*0x19214*/ u8 unk19214; - /*0x19215*/ u8 unk19215; - /*0x19216*/ u8 unk19216; // sprite ID - /*0x19217*/ s8 applauseLevel; + /*0x8*/ u8 mainTaskId; + /*0x9*/ u8 unk1920D[4]; + /*0xD*/ u8 unk19211; + /*0xE*/ u8 unk19212; + /*0xF*/ u8 filler19213; + /*0x10*/ u8 unk19214; + /*0x11*/ u8 unk19215; + /*0x12*/ u8 unk19216; // sprite ID + /*0x13*/ s8 applauseLevel; /*0x19218*/ u8 unk19218[4]; /*0x1921C*/ u32 unk1921C; // saved RNG value? u16 unk19220[5][4]; // move history? @@ -395,7 +379,12 @@ struct UnknownContestStruct6 struct ContestResourcesField1C { - u8 filler_00[0x40]; + u16 unk0[5]; + s16 unkA; + u8 unkC; + u8 unkD; + u8 unkE_1:1; + u8 unkE_2:1; }; struct ContestResourcesField20 @@ -420,42 +409,62 @@ struct ContestResources void * field_3c; }; -extern struct ContestResources *gContestResources; - #define sContest (*gContestResources->field_0) #define sContestantStatus (gContestResources->field_4) #define shared192D0 (*gContestResources->field_8) #define eContestAI (gContestResources->field_C) #define shared19328 (*gContestResources->field_10) #define shared19338 (*gContestResources->field_14) - - - #define shared15800 (gHeap + 0x18000) #define shared16800 (gHeap + 0x19000) #define shared18000 (*(struct Shared18000 *)(gHeap + 0x1a000)) +extern struct ContestPokemon gContestMons[4]; +extern s16 gContestMonConditions[4]; +extern s16 gUnknown_02039F08[4]; +extern s16 gUnknown_02039F10[4]; +extern s16 gUnknown_02039F18[4]; +extern u8 gContestFinalStandings[4]; +extern u8 gContestMonPartyIndex; +extern u8 gContestPlayerMonIndex; +extern u8 gUnknown_02039F26[4]; +extern u8 gIsLinkContest; +extern u8 gUnknown_02039F2B; +extern u16 gSpecialVar_ContestCategory; +extern u16 gSpecialVar_ContestRank; +extern u8 gNumLinkContestPlayers; +extern u8 gHighestRibbonRank; +extern struct ContestResources *gContestResources; +extern u8 sContestBgCopyFlags; +extern struct ContestWinner gUnknown_02039F3C; extern u32 gContestRngValue; -extern u8 gUnknown_02039F26[4]; -bool8 IsSpeciesNotUnown(u16 species); +// contest.c +void ResetLinkContestBoolean(void); void LoadContestBgAfterMoveAnim(void); +void sub_80D7B24(void); +void sub_80DA8C8(u8 partyIndex); +void sub_80DAB8C(u8 contestType, u8 rank); +void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); +u8 sub_80DAE0C(struct Pokemon *pkmn); +void sub_80DB09C(u8 contestCategory); +bool8 IsSpeciesNotUnown(u16 species); +bool8 Contest_IsMonsTurnDisabled(u8 a); +void sub_80DBED4(void); +void sub_80DCE58(u8 a); void SetContestantEffectStringID(u8 a, u8 b); void SetContestantEffectStringID2(u8 a, u8 b); +void SetStartledString(u8 contestant, u8 jam); void MakeContestantNervous(u8 p); -bool8 Contest_IsMonsTurnDisabled(u8 a); +s8 Contest_GetMoveExcitement(u16 move); bool8 sub_80DE1E8(u8 a); -void SetStartledString(u8 a, u8 b); -s8 Contest_GetMoveExcitement(u16); -u8 sub_80DAE0C(struct Pokemon *); -bool8 sub_80DEDA8(u8); -void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); -void sub_80DB09C(u8 contestCategory); -void sub_80DCE58(u8); -void sub_80DFA08(struct ContestPokemon *mon, int language); -void sub_80DBED4(void); -u8 sub_80DEFA8(u8, u8); +void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId); +void ResetContestLinkResults(void); +bool8 sub_80DEDA8(u8 a); +u8 sub_80DEFA8(u8 a, u8 b); +void ClearContestWinnerPicsInContestHall(void); +void sub_80DFA08(struct ContestPokemon *mon, s32 language); // contest link void sub_81D9DE4(u8 taskId); @@ -468,5 +477,4 @@ bool8 sub_80FC55C(void); bool8 sub_80FC530(u8); u8 sub_80F86E0(u8 *); - #endif //GUARD_CONTEST_H diff --git a/include/text.h b/include/text.h index d9c7a9a2e..aa499f558 100644 --- a/include/text.h +++ b/include/text.h @@ -13,10 +13,15 @@ #define CHAR_7 0xA8 #define CHAR_8 0xA9 #define CHAR_9 0xAA +#define CHAR_EXCL_MARK 0xAB #define CHAR_QUESTION_MARK 0xAC #define CHAR_PERIOD 0xAD #define CHAR_HYPHEN 0xAE #define CHAR_ELLIPSIS 0xB0 +#define CHAR_DOUBLE_QUOTATION_LEFT 0xB1 +#define CHAR_DOUBLE_QUOTATION_RIGHT 0xB2 +#define CHAR_SINGLE_QUOTATION_LEFT 0xB3 +#define CHAR_SINGLE_QUOTATION_RIGHT 0xB4 #define CHAR_MALE 0xB5 #define CHAR_FEMALE 0xB6 #define CHAR_CURRENCY 0xB7 diff --git a/include/tv.h b/include/tv.h index ea0226815..760d87522 100644 --- a/include/tv.h +++ b/include/tv.h @@ -56,5 +56,10 @@ void SaveRecordedItemPurchasesForTVShow(void); bool8 sub_80EE818(void); void sub_80EE8C8(u16 winStreak, u8 facilityAndMode); void BravoTrainerPokemonProfile_BeforeInterview2(u8 contestStandingPlace); +void ContestLiveUpdates_BeforeInterview_1(u8 a0); +void ContestLiveUpdates_BeforeInterview_2(u8 a0); +void ContestLiveUpdates_BeforeInterview_3(u8 a0); +void ContestLiveUpdates_BeforeInterview_4(u16 a0); +void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1); #endif //GUARD_TV_H diff --git a/ld_script.txt b/ld_script.txt index 844c64fb5..05c604feb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -136,7 +136,6 @@ SECTIONS { src/battle_anim_80D51AC.o(.text); src/item.o(.text); src/contest.o(.text); - asm/contest.o(.text); src/shop.o(.text); src/fldeff_escalator.o(.text); src/berry.o(.text); diff --git a/src/contest.c b/src/contest.c index e6e96b5dd..799a19030 100644 --- a/src/contest.c +++ b/src/contest.c @@ -21,6 +21,7 @@ #include "overworld.h" #include "palette.h" #include "random.h" +#include "new_game.h" #include "script.h" #include "sound.h" #include "sprite.h" @@ -44,161 +45,155 @@ #include "constants/rgb.h" #include "contest_ai.h" -extern void (*gFieldCallback)(void); - -void sub_80D782C(void); -void sub_80D7C7C(u8 taskId); -void sub_80D7CB4(u8 taskId); -void sub_80D7DAC(u8 taskId); -void sub_80D7DC8(u8 taskId); -void sub_80D7DE8(u8 taskId); -bool8 sub_80D7E44(u8 *); -void sub_80D80C8(u8 taskId); -void sub_80D8108(u8 taskId); -void vblank_cb_battle(void); -void sub_80D823C(void); -void sub_80D833C(u8 taskId); -void sub_80D8424(u8 taskId); -void sub_80D8610(u8 taskId); -void sub_80D8490(u8 taskId); -void sub_80D880C(s8); -void sub_80D883C(s8); -void sub_80D8894(u8 taskId); -void sub_80D892C(u8 taskId); -void sub_80D895C(u8 taskId); -void sub_80D8A04(u8 taskId); -void sub_80D8A50(u8 taskId); -void sub_80D8A88(u8 taskId); -void sub_80D8B38(u8 taskId); -void sub_80DA110(u8); -void sub_80DA134(struct Sprite *); -void sub_80DA164(struct Sprite *); -void sub_80DA198(u8); -void sub_80DA25C(u8); -void sub_80DA28C(u8); -void sub_80DA31C(u8); -void sub_80DA348(u8); -void sub_80DA38C(u8); -void sub_80DA3CC(u8); -void sub_80DA464(u8); -void sub_80DA49C(u8); -void sub_80DA4CC(u8); -void sub_80DA51C(u8); -void sub_80DA5B4(u8); -void sub_80DA5E8(u8); -void sub_80DA6B4(u8); -void sub_80DA700(u8); -void sub_80DA740(u8); -void sub_80DA7A0(u8); -void sub_80DA7EC(u8); -void sub_80DA830(u8); -void sub_80DA874(void); -bool8 sub_80DA8A4(void); -void sub_80DAF04(u8); -void sub_80DAF1C(u8 a0, u8 a1); -void sub_80DAF88(u8); -void sub_80DAFA0(u8, u8); -u8 sub_80DB0C4(void); -u8 sub_80DB120(void); -u8 sub_80DB174(u16, u32, u32, u32); -void sub_80DB2BC(void); -void prints_contest_move_description(u16); -u16 SanitizeSpecies(u16); -void sub_80DB89C(void); -u16 GetChosenMove(u8); -void sub_80DB918(void); -bool8 Contest_IsMonsTurnDisabled(u8); -void sub_80DBF68(void); -void sub_80DBF90(void); -void sub_80DC2BC(void); -void sub_80DC490(bool8); -void sub_80DC4F0(void); -void CreateApplauseMeterSprite(void); -void sub_80DC5E8(void); -void sub_80DC7EC(void); -void sub_80DCD48(void); -void sub_80DCE58(u8); -void sub_80DD04C(void); -void sub_80DD590(void); -void sub_80DDB0C(void); -void sub_80DDBE8(void); -bool8 sub_80DE1E8(u8); -void sub_80DE224(void); -void sub_80DE350(void); -void sub_80DE424(u8); -void sub_80DE69C(u8); -void sub_80DEA20(void); -void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId); -void Contest_StartTextPrinter(const u8 *, u32); -void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16); -bool32 Contest_RunTextPrinters(void); -void Contest_SetBgCopyFlags(u32); -void sub_80FC9F8(u8); -bool8 AreMovesContestCombo(u16, u16); -void sub_80DBD18(void); -void sub_80DF250(void); -void sub_80DF4F8(void); -void sub_80DD080(u8); -void sub_80DF080(u8); -void sub_80DF750(void); -void sub_80DE9DC(u8); -void sub_80DCBE8(u8, u8); -u8 sub_80DC9EC(u8); -u16 SanitizeMove(u16); -void sub_80DE864(u8); -void SelectContestMoveBankTarget(u16); -void sub_80DE9B0(u8); -void sub_80DC674(u8); -void sub_80DE12C(void); -void sub_80DD45C(u8, u8); -void sub_80DD720(u8); -void sub_80DE008(bool8); -u8 sub_80DC028(s16, s16, u8); -bool8 sub_80DB5B8(u8, u8); -bool8 sub_80DB798(u8); -void sub_80DB884(void); -void sub_80DC9B4(u8); -void sub_80DDED0(s8, s8); -void sub_80DDCDC(s8); -void sub_80DDE0C(void); -void sub_80DD940(void); -void sub_80DB944(void); -void sub_80DBA18(void); -void sub_80DC3AC(void); -bool8 sub_80DC3C4(void); -void sub_80DF9D4(u8 *); -void sub_80DF9E0(u8 *, s32); -void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8); -void Contest_PrintTextToBg0WindowStd(u32, const u8 *); -s16 sub_80DBD34(u8); -void DetermineFinalStandings(void); -bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); -void sub_80DC0F4(u8); -void sub_80DC408(struct Sprite *); -void sub_80DC728(u8); -void sub_80DC6A4(u8); -void sub_80DC8D0(u8); -void sub_80DC81C(u8); -void sub_80DC87C(u8); -void sub_80DCC84(struct Sprite *); -void sub_80DCCD8(struct Sprite *sprite); -u8 sub_80DDA20(void); -void c3_08130B10(u8); -void sub_80DDB6C(u8); -void task08_080CD1CC(u8); -void sub_80DDD20(u8); -void sub_80DDE30(u8); -void sub_80DDF80(u8); -const u8 *GetTurnOrderNumberGfx(u8); -void sub_80DE464(u8); -void sub_80DE4A8(u8); -void sub_80DE5F4(u8); -void sub_80DE65C(u8); -void sub_80DE794(u8); -void sub_80DEA5C(void); -u8 sub_80DEFA8(u8, u8); +extern void sub_80FC9F8(u8); // contest_link_80FC4F4.c +// This file's functions. +static void sub_80D782C(void); +static void sub_80D7C7C(u8 taskId); +static void sub_80D7CB4(u8 taskId); +static void sub_80D7DAC(u8 taskId); +static void sub_80D7DC8(u8 taskId); +static void sub_80D7DE8(u8 taskId); +static bool8 sub_80D7E44(u8 *); +static void sub_80D80C8(u8 taskId); +static void sub_80D8108(u8 taskId); +static void vblank_cb_battle(void); +static void sub_80D823C(void); +static void sub_80D833C(u8 taskId); +static void sub_80D8424(u8 taskId); +static void sub_80D8610(u8 taskId); +static void sub_80D8490(u8 taskId); +static void sub_80D880C(s8); +static void sub_80D883C(s8); +static void sub_80D8894(u8 taskId); +static void sub_80D892C(u8 taskId); +static void sub_80D895C(u8 taskId); +static void sub_80D8A04(u8 taskId); +static void sub_80D8A50(u8 taskId); +static void sub_80D8A88(u8 taskId); +static void sub_80D8B38(u8 taskId); +static void sub_80DA110(u8); +static void sub_80DA134(struct Sprite *); +static void sub_80DA164(struct Sprite *); +static void sub_80DA198(u8); +static void sub_80DA25C(u8); +static void sub_80DA28C(u8); +static void sub_80DA31C(u8); +static void sub_80DA348(u8); +static void sub_80DA38C(u8); +static void sub_80DA3CC(u8); +static void sub_80DA464(u8); +static void sub_80DA49C(u8); +static void sub_80DA4CC(u8); +static void sub_80DA51C(u8); +static void sub_80DA5B4(u8); +static void sub_80DA5E8(u8); +static void sub_80DA6B4(u8); +static void sub_80DA700(u8); +static void sub_80DA740(u8); +static void sub_80DA7A0(u8); +static void sub_80DA7EC(u8); +static void sub_80DA830(u8); +static void sub_80DA874(void); +static bool8 sub_80DA8A4(void); +static void sub_80DAF04(u8); +static void sub_80DAF1C(u8 a0, u8 a1); +static void sub_80DAF88(u8); +static void sub_80DAFA0(u8, u8); +static u8 sub_80DB0C4(void); +static u8 sub_80DB120(void); +static u8 sub_80DB174(u16, u32, u32, u32); +static void prints_contest_move_description(u16); +static u16 SanitizeSpecies(u16); +static void sub_80DB89C(void); +static u16 GetChosenMove(u8); +static void sub_80DB918(void); +static void sub_80DBF68(void); +static void sub_80DBF90(void); +static void sub_80DC2BC(void); +static void sub_80DC490(bool8); +static void sub_80DC4F0(void); +static void CreateApplauseMeterSprite(void); +static void sub_80DC5E8(void); +static void sub_80DC7EC(void); +static void sub_80DCD48(void); +static void sub_80DD04C(void); +static void sub_80DD590(void); +static void sub_80DDB0C(void); +static void sub_80DDBE8(void); +static void sub_80DE224(void); +static void sub_80DE350(void); +static void sub_80DE424(u8); +static void sub_80DE69C(u8); +static void sub_80DEA20(void); +static void Contest_StartTextPrinter(const u8 *, u32); +static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16); +static bool32 Contest_RunTextPrinters(void); +static void Contest_SetBgCopyFlags(u32); +static void sub_80DBD18(void); +static void sub_80DD080(u8); +static void sub_80DE9DC(u8); +static void sub_80DCBE8(u8, u8); +static u8 sub_80DC9EC(u8); +static u16 SanitizeMove(u16); +static void sub_80DE864(u8); +static void SelectContestMoveBankTarget(u16); +static void sub_80DE9B0(u8); +static void sub_80DC674(u8); +static void sub_80DE12C(void); +static void sub_80DD45C(u8, u8); +static void sub_80DD720(u8); +static void sub_80DE008(bool8); +static u8 sub_80DC028(s16, s16, u8); +static bool8 sub_80DB5B8(u8, u8); +static bool8 sub_80DB798(u8); +static void sub_80DB884(void); +static void sub_80DC9B4(u8); +static void sub_80DDED0(s8, s8); +static void sub_80DDCDC(s8); +static void sub_80DDE0C(void); +static void sub_80DD940(void); +static void sub_80DB944(void); +static void sub_80DBA18(void); +static void sub_80DC3AC(void); +static bool8 sub_80DC3C4(void); +static void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8); +static void Contest_PrintTextToBg0WindowStd(u32, const u8 *); +static s16 sub_80DBD34(u8); +static void DetermineFinalStandings(void); +static bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); +static void sub_80DC0F4(u8); +static void sub_80DC408(struct Sprite *); +static void sub_80DC728(u8); +static void sub_80DC6A4(u8); +static void sub_80DC8D0(u8); +static void sub_80DC81C(u8); +static void sub_80DC87C(u8); +static void sub_80DCC84(struct Sprite *); +static void sub_80DCCD8(struct Sprite *sprite); +static u8 sub_80DDA20(void); +static void c3_08130B10(u8); +static void sub_80DDB6C(u8); +static void task08_080CD1CC(u8); +static void sub_80DDD20(u8); +static void sub_80DDE30(u8); +static void sub_80DDF80(u8); +static const u8 *GetTurnOrderNumberGfx(u8); +static void sub_80DE464(u8); +static void sub_80DE4A8(u8); +static void sub_80DE5F4(u8); +static void sub_80DE65C(u8); +static void sub_80DE794(u8); +static void sub_80DEA5C(void); +static void sub_80DF250(void); +static void sub_80DF4F8(void); +static void sub_80DF080(u8); +static void sub_80DF750(void); +static void sub_80DF9D4(u8 *); +static void sub_80DF9E0(u8 *, s32); +static void sub_80DB2BC(void); +// EWRAM vars. EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA s16 gContestMonConditions[4] = {0}; EWRAM_DATA s16 gUnknown_02039F08[4] = {0}; @@ -216,10 +211,11 @@ EWRAM_DATA u16 gSpecialVar_ContestCategory = 0; EWRAM_DATA u16 gSpecialVar_ContestRank = 0; EWRAM_DATA u8 gNumLinkContestPlayers = 0; EWRAM_DATA u8 gHighestRibbonRank = 0; -EWRAM_DATA struct ContestResources * gContestResources = NULL; +EWRAM_DATA struct ContestResources *gContestResources = NULL; EWRAM_DATA u8 sContestBgCopyFlags = 0; EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0}; +// IWRAM common vars. u32 gContestRngValue; extern const u16 gUnknown_08587C30[]; @@ -249,6 +245,8 @@ extern const u8 gText_Contest_Anxiety[]; extern const u8 gText_Contest_Laziness[]; extern const u8 gText_Contest_Hesitancy[]; extern const u8 gText_Contest_Fear[]; +extern const u8 gText_BDot[]; +extern const u8 gText_CDot[]; extern const u8 *const gUnknown_08587E10[]; extern const struct ContestPokemon gContestOpponents[96]; extern const u8 gUnknown_085898A4[96]; @@ -271,12 +269,14 @@ extern const struct SubspriteTable gSubspriteTables_8587B80[]; extern const struct CompressedSpriteSheet gUnknown_08587BB0; extern const struct SpritePalette gUnknown_08587BB8; extern const struct SpriteTemplate gSpriteTemplate_8587BC8; -extern bool8 gUnknown_020322D5; extern void (*const gContestEffectFuncs[])(void); extern const s8 gContestExcitementTable[][5]; extern const struct ContestWinner gUnknown_08587FA4[]; +extern const struct CompressedSpriteSheet gUnknown_08589904[]; +extern const struct SpritePalette gUnknown_08589924[]; +extern const struct SpriteTemplate gSpriteTemplate_858998C[]; -void TaskDummy1(u8 taskId) +static void TaskDummy1(u8 taskId) { } @@ -285,7 +285,7 @@ void ResetLinkContestBoolean(void) gIsLinkContest = 0; } -void sub_80D7678(void) +static void sub_80D7678(void) { u16 savedIme; @@ -329,7 +329,7 @@ void LoadContestBgAfterMoveAnim(void) } } -void sub_80D779C(void) +static void sub_80D779C(void) { s32 i; @@ -342,7 +342,7 @@ void sub_80D779C(void) } } -void sub_80D77E4(void) +static void sub_80D77E4(void) { InitWindows(gUnknown_08587F44); DeactivateAllTextPrinters(); @@ -356,7 +356,7 @@ void sub_80D77E4(void) } } -void sub_80D782C(void) +static void sub_80D782C(void) { s32 i; @@ -367,7 +367,7 @@ void sub_80D782C(void) FillPalette(RGB(31, 17, 31), 0xF3, 2); } -void sub_80D787C(void) +static void sub_80D787C(void) { s32 i; @@ -398,10 +398,10 @@ void sub_80D787C(void) gContestResources->field_0->unk19218[i] = gUnknown_02039F26[i]; } sub_80DD590(); - *gContestResources->field_1c = (struct ContestResourcesField1C){}; + memset(gContestResources->field_1c, 0, sizeof(*gContestResources->field_1c) * 4); } -void sub_80D7988(void) +static void sub_80D7988(void) { gContestResources = AllocZeroed(sizeof(struct ContestResources)); gContestResources->field_0 = AllocZeroed(sizeof(struct Contest)); @@ -411,7 +411,7 @@ void sub_80D7988(void) gContestResources->field_10 = AllocZeroed(sizeof(struct UnknownContestStruct5) * 4); gContestResources->field_14 = AllocZeroed(sizeof(struct UnknownContestStruct4) * 4); gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18)); - gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C)); + gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C) * 4); gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20)); gContestResources->field_24[0] = AllocZeroed(0x1000); gContestResources->field_24[1] = AllocZeroed(0x1000); @@ -424,7 +424,7 @@ void sub_80D7988(void) gUnknown_02023060 = gContestResources->field_24[1]; } -void sub_80D7A5C(void) +static void sub_80D7A5C(void) { FREE_AND_SET_NULL(gContestResources->field_0); FREE_AND_SET_NULL(gContestResources->field_4); @@ -502,7 +502,7 @@ void sub_80D7B24(void) } } -void sub_80D7C7C(u8 taskId) +static void sub_80D7C7C(u8 taskId) { if (!gPaletteFade.active) { @@ -511,7 +511,7 @@ void sub_80D7C7C(u8 taskId) } } -void sub_80D7CB4(u8 taskId) +static void sub_80D7CB4(u8 taskId) { if (gIsLinkContest & 1) { @@ -554,18 +554,18 @@ void sub_80D7CB4(u8 taskId) } } -void sub_80D7DAC(u8 taskId) +static void sub_80D7DAC(u8 taskId) { SetTaskFuncWithFollowupFunc(taskId, sub_80FC998, sub_80D7DC8); } -void sub_80D7DC8(u8 taskId) +static void sub_80D7DC8(u8 taskId) { gTasks[taskId].data[0] = 1; gTasks[taskId].func = sub_80D7DE8; } -void sub_80D7DE8(u8 taskId) +static void sub_80D7DE8(u8 taskId) { gTasks[taskId].data[0]--; if (gTasks[taskId].data[0] <= 0) @@ -577,7 +577,7 @@ void sub_80D7DE8(u8 taskId) } } -u8 sub_80D7E44(u8 *a) +static u8 sub_80D7E44(u8 *a) { u16 sp0[16]; u16 sp20[16]; @@ -651,7 +651,7 @@ u8 sub_80D7E44(u8 *a) return 0; } -void sub_80D80C8(u8 taskId) +static void sub_80D80C8(u8 taskId) { gPaletteFade.bufferTransferDisabled = FALSE; if (!gPaletteFade.active) @@ -662,7 +662,7 @@ void sub_80D80C8(u8 taskId) } } -void sub_80D8108(u8 taskId) +static void sub_80D8108(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -706,7 +706,7 @@ void sub_80D8108(u8 taskId) } } -void sub_80D823C(void) +static void sub_80D823C(void) { s32 i; @@ -723,7 +723,7 @@ void sub_80D823C(void) sContestBgCopyFlags = 0; } -void vblank_cb_battle(void) +static void vblank_cb_battle(void) { SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y); @@ -743,7 +743,7 @@ void vblank_cb_battle(void) ScanlineEffect_InitHBlankDmaTransfer(); } -void sub_80D833C(u8 taskId) +static void sub_80D833C(u8 taskId) { if (gTasks[taskId].data[0] == 0) { @@ -771,7 +771,7 @@ void sub_80D833C(u8 taskId) } } -void sub_80D8424(u8 taskId) +static void sub_80D8424(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON)) { @@ -788,7 +788,7 @@ void sub_80D8424(u8 taskId) } } -void sub_80D8490(u8 taskId) +static void sub_80D8490(u8 taskId) { u8 i; u8 sp8[32]; @@ -826,7 +826,7 @@ void sub_80D8490(u8 taskId) gTasks[taskId].func = sub_80D8610; } -void sub_80D8610(u8 taskId) +static void sub_80D8610(u8 taskId) { u8 numMoves = 0; s32 i; @@ -890,18 +890,18 @@ void sub_80D8610(u8 taskId) } } -void sub_80D880C(s8 a0) +static void sub_80D880C(s8 a0) { ContestBG_FillBoxWithIncrementingTile(2, 55, 0, 31 + a0 * 2, 2, 2, 17, 1); } -void sub_80D883C(s8 a0) +static void sub_80D883C(s8 a0) { ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 31 + a0 * 2, 2, 1, 17, 1); ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 32 + a0 * 2, 2, 1, 17, 1); } -void sub_80D8894(u8 taskId) +static void sub_80D8894(u8 taskId) { if (gIsLinkContest & 1) { @@ -922,13 +922,13 @@ void sub_80D8894(u8 taskId) } } -void sub_80D892C(u8 taskId) +static void sub_80D892C(u8 taskId) { DestroyTask(taskId); gTasks[gContestResources->field_0->mainTaskId].func = sub_80D895C; } -void sub_80D895C(u8 taskId) +static void sub_80D895C(u8 taskId) { s32 i; @@ -952,7 +952,7 @@ void sub_80D895C(u8 taskId) gTasks[taskId].func = sub_80D8A04; } -void sub_80D8A04(u8 taskId) +static void sub_80D8A04(u8 taskId) { if (++gTasks[taskId].data[0] > 2) { @@ -966,13 +966,13 @@ void sub_80D8A04(u8 taskId) } } -void sub_80D8A50(u8 taskId) +static void sub_80D8A50(u8 taskId) { if (!gContestResources->field_0->unk1920A_6 && !gContestResources->field_0->unk1920B_1) gTasks[taskId].func = sub_80D8A88; } -void sub_80D8A88(u8 taskId) +static void sub_80D8A88(u8 taskId) { if (++gTasks[taskId].data[0] > 19) { @@ -992,7 +992,7 @@ void sub_80D8A88(u8 taskId) } } -void sub_80D8B38(u8 taskId) +static void sub_80D8B38(u8 taskId) { u8 spriteId; s32 i; @@ -1698,13 +1698,13 @@ void sub_80D8B38(u8 taskId) } } -void sub_80DA110(u8 taskId) +static void sub_80DA110(u8 taskId) { sContest.unk1920B_2 = 0; DestroyTask(taskId); } -void sub_80DA134(struct Sprite *sprite) +static void sub_80DA134(struct Sprite *sprite) { if (sprite->pos2.x != 0) { @@ -1720,7 +1720,7 @@ void sub_80DA134(struct Sprite *sprite) } } -void sub_80DA164(struct Sprite *sprite) +static void sub_80DA164(struct Sprite *sprite) { sprite->pos2.x -= 6; if (sprite->pos1.x + sprite->pos2.x < -32) @@ -1730,7 +1730,7 @@ void sub_80DA164(struct Sprite *sprite) } } -void sub_80DA198(u8 taskId) +static void sub_80DA198(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -1768,7 +1768,7 @@ void sub_80DA198(u8 taskId) } } -void sub_80DA25C(u8 taskId) +static void sub_80DA25C(u8 taskId) { sub_80DE008(FALSE); gTasks[taskId].data[0] = 0; @@ -1776,7 +1776,7 @@ void sub_80DA25C(u8 taskId) gTasks[taskId].func = sub_80DA28C; } -void sub_80DA28C(u8 taskId) +static void sub_80DA28C(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -1807,13 +1807,13 @@ void sub_80DA28C(u8 taskId) } } -void sub_80DA31C(u8 taskId) +static void sub_80DA31C(u8 taskId) { if (sub_80DC3C4()) gTasks[taskId].func = sub_80DA348; } -void sub_80DA348(u8 taskId) +static void sub_80DA348(u8 taskId) { DmaCopy32Defvars(3, shared18000.unk18204, gPlttBufferUnfaded, 0x400); gTasks[taskId].data[0] = 0; @@ -1821,7 +1821,7 @@ void sub_80DA348(u8 taskId) gTasks[taskId].func = sub_80DA38C; } -void sub_80DA38C(u8 taskId) +static void sub_80DA38C(u8 taskId) { if (++gTasks[taskId].data[0] > 2) { @@ -1831,7 +1831,7 @@ void sub_80DA38C(u8 taskId) } } -void sub_80DA3CC(u8 taskId) +static void sub_80DA3CC(u8 taskId) { if (gTasks[taskId].data[0] == 0) { @@ -1854,7 +1854,7 @@ void sub_80DA3CC(u8 taskId) } } -void sub_80DA464(u8 taskId) +static void sub_80DA464(u8 taskId) { if (gTasks[taskId].data[0]++ > 29) { @@ -1864,7 +1864,7 @@ void sub_80DA464(u8 taskId) } } -void sub_80DA49C(u8 taskId) +static void sub_80DA49C(u8 taskId) { if (sub_80DC3C4()) { @@ -1873,19 +1873,19 @@ void sub_80DA49C(u8 taskId) } } -void sub_80DA4CC(u8 taskId) +static void sub_80DA4CC(u8 taskId) { sub_80DE224(); gTasks[taskId].func = sub_80DE424; } -void sub_80DA4F4(u8 taskId) +static void sub_80DA4F4(u8 taskId) { sub_80DE350(); gTasks[taskId].func = sub_80DA51C; } -void sub_80DA51C(u8 taskId) +static void sub_80DA51C(u8 taskId) { vu16 sp0 = GetGpuReg(REG_OFFSET_BG0CNT); vu16 sp2 = GetGpuReg(REG_OFFSET_BG2CNT); @@ -1905,13 +1905,13 @@ void sub_80DA51C(u8 taskId) } } -void sub_80DA5B4(u8 taskId) +static void sub_80DA5B4(u8 taskId) { if (!sContest.unk1920A_6) gTasks[taskId].func = sub_80D833C; } -void sub_80DA5E8(u8 taskId) +static void sub_80DA5E8(u8 taskId) { s32 i; @@ -1936,7 +1936,7 @@ void sub_80DA5E8(u8 taskId) gTasks[taskId].func = sub_80DA6B4; } -void sub_80DA6B4(u8 taskId) +static void sub_80DA6B4(u8 taskId) { if (!Contest_RunTextPrinters()) { @@ -1949,7 +1949,7 @@ void sub_80DA6B4(u8 taskId) } } -void sub_80DA700(u8 taskId) +static void sub_80DA700(u8 taskId) { gBattle_BG1_Y -= 7; if ((s16)gBattle_BG1_Y < 0) @@ -1961,7 +1961,7 @@ void sub_80DA700(u8 taskId) } } -void sub_80DA740(u8 taskId) +static void sub_80DA740(u8 taskId) { if (gTasks[taskId].data[0]++ >= 50) { @@ -1978,7 +1978,7 @@ void sub_80DA740(u8 taskId) } } -void sub_80DA7A0(u8 taskId) +static void sub_80DA7A0(u8 taskId) { u8 taskId2 = CreateTask(sub_80FCACC, 0); @@ -1988,14 +1988,14 @@ void sub_80DA7A0(u8 taskId) sub_80DC490(FALSE); } -void sub_80DA7EC(u8 taskId) +static void sub_80DA7EC(u8 taskId) { DestroyTask(taskId); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); gTasks[sContest.mainTaskId].func = sub_80DA830; } -void sub_80DA830(u8 taskId) +static void sub_80DA830(u8 taskId) { if (!gPaletteFade.active) { @@ -2008,19 +2008,19 @@ void sub_80DA830(u8 taskId) } } -void sub_80DA874(void) +static void sub_80DA874(void) { ScriptContext2_Disable(); EnableBothScriptContexts(); } -void sub_80DA884(void) +static void sub_80DA884(void) { if (!(gIsLinkContest & 1)) gContestPlayerMonIndex = 3; } -bool8 sub_80DA8A4(void) +static bool8 sub_80DA8A4(void) { if (gContestPlayerMonIndex == gUnknown_02039F2B) return TRUE; @@ -2250,7 +2250,7 @@ u8 sub_80DAE0C(struct Pokemon *pkmn) return retVal; } -void sub_80DAEA4(void) +static void sub_80DAEA4(void) { s32 i; @@ -2262,7 +2262,7 @@ void sub_80DAEA4(void) } } -u8 *sub_80DAED4(const u8 *src, u8 color) +static u8 *sub_80DAED4(const u8 *src, u8 color) { u8 * ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent); ptr[-1] = color; @@ -2271,12 +2271,12 @@ u8 *sub_80DAED4(const u8 *src, u8 color) return ptr; } -void sub_80DAF04(u8 a0) +static void sub_80DAF04(u8 a0) { sub_80DAF1C(a0, a0 + 10); } -void sub_80DAF1C(u8 a0, u8 a1) +static void sub_80DAF1C(u8 a0, u8 a1) { u8 buffer[32]; s32 offset; @@ -2290,18 +2290,18 @@ void sub_80DAF1C(u8 a0, u8 a1) Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, offset, 1, 7); } -void sub_80DAF88(u8 a0) +static void sub_80DAF88(u8 a0) { sub_80DAFA0(a0, a0 + 10); } -void sub_80DAFA0(u8 a0, u8 a1) +static void sub_80DAFA0(u8 a0, u8 a1) { sub_80DAED4(gContestMons[a0].nickname, a1); Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, 5, 1, 7); } -u16 sub_80DAFE0(u8 who, u8 contestCategory) +static u16 sub_80DAFE0(u8 who, u8 contestCategory) { u8 statMain; u8 statSub1; @@ -2347,7 +2347,7 @@ void sub_80DB09C(u8 contestCategory) gContestMonConditions[i] = sub_80DAFE0(i, contestCategory); } -u8 sub_80DB0C4(void) +static u8 sub_80DB0C4(void) { u8 spriteId; @@ -2359,7 +2359,7 @@ u8 sub_80DB0C4(void) return spriteId; } -u8 sub_80DB120(void) +static u8 sub_80DB120(void) { u8 spriteId; @@ -2371,7 +2371,7 @@ u8 sub_80DB120(void) return spriteId; } -u8 sub_80DB174(u16 species, u32 otId, u32 personality, u32 index) +static u8 sub_80DB174(u16 species, u32 otId, u32 personality, u32 index) { u8 spriteId; species = SanitizeSpecies(species); @@ -2408,13 +2408,13 @@ bool8 IsSpeciesNotUnown(u16 species) return TRUE; } -void sub_80DB2BC(void) +static void sub_80DB2BC(void) { CpuCopy16(gContestResources->field_24[0], gContestResources->field_24[0] + 0x500, 0x280); CpuCopy16(gContestResources->field_24[2], gContestResources->field_24[2] + 0x500, 0x280); } -u16 sub_80DB2EC(u16 a0, u8 a1) +static u16 sub_80DB2EC(u16 a0, u8 a1) { u16 var; @@ -2437,7 +2437,7 @@ u16 sub_80DB2EC(u16 a0, u8 a1) return var; } -void prints_contest_move_description(u16 a) +static void prints_contest_move_description(u16 a) { u8 category; u16 categoryTile; @@ -2481,7 +2481,7 @@ void prints_contest_move_description(u16 a) Contest_PrintTextToBg0WindowStd(9, gText_Slash); } -void sub_80DB4E0(u16 move, u8 b) +static void sub_80DB4E0(u16 move, u8 b) { u8 r7 = gUnknown_02039F26[b] * 5 + 2; @@ -2498,7 +2498,7 @@ void sub_80DB4E0(u16 move, u8 b) } } -void sub_80DB584(void) +static void sub_80DB584(void) { s32 i; @@ -2506,12 +2506,12 @@ void sub_80DB584(void) sub_80DB4E0(gContestResources->field_4[i].currMove, i); } -u16 sub_80DB5B0(void) +static u16 sub_80DB5B0(void) { return 0x2034; } -bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) +static bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) { u8 r6; s32 r4; @@ -2541,7 +2541,7 @@ bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod) return TRUE; } -void sub_80DB69C(void) +static void sub_80DB69C(void) { s32 i; s32 r6; @@ -2557,7 +2557,7 @@ void sub_80DB69C(void) } } -u16 sub_80DB748(u8 status) +static u16 sub_80DB748(u8 status) { u16 var = 0; @@ -2583,7 +2583,7 @@ u16 sub_80DB748(u8 status) return var; } -bool8 sub_80DB798(u8 a) +static bool8 sub_80DB798(u8 a) { bool8 r9 = TRUE; u16 r8 = 0; @@ -2609,7 +2609,7 @@ bool8 sub_80DB798(u8 a) return r9; } -void sub_80DB884(void) +static void sub_80DB884(void) { s32 i; @@ -2617,14 +2617,14 @@ void sub_80DB884(void) sub_80DB798(i); } -void sub_80DB89C(void) +static void sub_80DB89C(void) { FillWindowPixelBuffer(4, 0); CopyWindowToVram(4, 2); Contest_SetBgCopyFlags(0); } -u16 GetChosenMove(u8 a) +static u16 GetChosenMove(u8 a) { if (Contest_IsMonsTurnDisabled(a)) return 0; @@ -2642,7 +2642,7 @@ u16 GetChosenMove(u8 a) } } -void sub_80DB918(void) +static void sub_80DB918(void) { s32 i; @@ -2650,7 +2650,7 @@ void sub_80DB918(void) sContestantStatus[i].currMove = GetChosenMove(i); } -void sub_80DB944(void) +static void sub_80DB944(void) { s32 i; s32 j; @@ -2689,7 +2689,7 @@ void sub_80DB944(void) sub_80DD590(); } -void sub_80DBA18(void) +static void sub_80DBA18(void) { s32 i; @@ -2714,7 +2714,7 @@ void sub_80DBA18(void) } } -bool8 sub_80DBA68(u8 a) +static bool8 sub_80DBA68(u8 a) { if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns) return FALSE; @@ -2722,7 +2722,7 @@ bool8 sub_80DBA68(u8 a) return TRUE; } -void sub_80DBAA0(void) +static void sub_80DBAA0(void) { s32 i; @@ -2777,13 +2777,13 @@ bool8 Contest_IsMonsTurnDisabled(u8 a) return FALSE; } -void sub_80DBCE0(u8 a) +static void sub_80DBCE0(u8 a) { gUnknown_02039F18[a] = sub_80DBD34(a); gUnknown_02039F08[a] = gContestMonConditions[a] + gUnknown_02039F18[a]; } -void sub_80DBD18(void) +static void sub_80DBD18(void) { s32 i; @@ -2792,12 +2792,12 @@ void sub_80DBD18(void) DetermineFinalStandings(); } -s16 sub_80DBD34(u8 a) +static s16 sub_80DBD34(u8 a) { return gUnknown_02039F10[a] * 2; } -void DetermineFinalStandings(void) +static void DetermineFinalStandings(void) { u16 sp0[4] = {0}; struct UnknownContestStruct6 sp8[4]; @@ -2868,7 +2868,7 @@ void sub_80DBED4(void) } } -bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) +static bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) { bool8 retVal; @@ -2887,7 +2887,7 @@ bool8 sub_80DBF30(s32 a, s32 b, struct UnknownContestStruct6 *c) return retVal; } -void sub_80DBF68(void) +static void sub_80DBF68(void) { gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; @@ -2895,7 +2895,7 @@ void sub_80DBF68(void) Contest_StartTextPrinter((u8*) &gUnknown_0827E8DA, 0); } -void sub_80DBF90(void) +static void sub_80DBF90(void) { int i; @@ -2905,7 +2905,7 @@ void sub_80DBF90(void) } } -u16 sub_80DBFC8(u8 a) +static u16 sub_80DBFC8(u8 a) { u16 var; @@ -2920,7 +2920,7 @@ u16 sub_80DBFC8(u8 a) return var + 1; } -s8 sub_80DBFFC(s16 a) +static s8 sub_80DBFFC(s16 a) { s8 retVal = a / 10; @@ -2931,7 +2931,7 @@ s8 sub_80DBFFC(s16 a) return retVal; } -u8 sub_80DC028(s16 a, s16 b, u8 c) +static u8 sub_80DC028(s16 a, s16 b, u8 c) { u8 taskId; s8 r4; @@ -2952,7 +2952,7 @@ u8 sub_80DC028(s16 a, s16 b, u8 c) return taskId; } -void sub_80DC0F4(u8 taskId) +static void sub_80DC0F4(u8 taskId) { u8 r7 = gTasks[taskId].data[3]; s16 r3 = gTasks[taskId].data[0]; @@ -3044,7 +3044,7 @@ void sub_80DC0F4(u8 taskId) } } -void sub_80DC2BC(void) +static void sub_80DC2BC(void) { s32 i; @@ -3057,7 +3057,7 @@ void sub_80DC2BC(void) } } -void sub_80DC308(u8 a) +static void sub_80DC308(u8 a) { u8 spriteId; s16 r5; @@ -3079,7 +3079,7 @@ void sub_80DC308(u8 a) gSprites[spriteId].callback = sub_80DC408; } -void sub_80DC3AC(void) +static void sub_80DC3AC(void) { s32 i; @@ -3087,7 +3087,7 @@ void sub_80DC3AC(void) sub_80DC308(i); } -bool8 sub_80DC3C4(void) +static bool8 sub_80DC3C4(void) { s32 i; @@ -3102,7 +3102,7 @@ bool8 sub_80DC3C4(void) return FALSE; } -void sub_80DC408(struct Sprite *sprite) +static void sub_80DC408(struct Sprite *sprite) { if (sprite->pos2.x == sprite->data[1]) { @@ -3115,7 +3115,7 @@ void sub_80DC408(struct Sprite *sprite) } } -void sub_80DC44C(void) +static void sub_80DC44C(void) { s32 i; @@ -3123,7 +3123,7 @@ void sub_80DC44C(void) gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gUnknown_02039F26[i]]; } -void sub_80DC490(bool8 a) +static void sub_80DC490(bool8 a) { s32 i; @@ -3139,7 +3139,7 @@ void sub_80DC490(bool8 a) } } -void sub_80DC4F0(void) +static void sub_80DC4F0(void) { s32 i; @@ -3156,7 +3156,7 @@ void sub_80DC4F0(void) } } -void CreateApplauseMeterSprite(void) +static void CreateApplauseMeterSprite(void) { u8 spriteId; @@ -3167,7 +3167,7 @@ void CreateApplauseMeterSprite(void) sContest.applauseMeterSpriteId = spriteId; } -void sub_80DC5E8(void) +static void sub_80DC5E8(void) { u8 i; u8 taskId = CreateTask(sub_80DC728, 30); @@ -3177,20 +3177,20 @@ void sub_80DC5E8(void) gTasks[taskId].data[i * 4] = 0xFF; } -void sub_80DC630(u8 a) +static void sub_80DC630(u8 a) { gTasks[sContest.unk19211].data[a * 4 + 0] = 0; gTasks[sContest.unk19211].data[a * 4 + 1] = 0; } -void sub_80DC674(u8 a) +static void sub_80DC674(u8 a) { u8 taskId = CreateTask(sub_80DC6A4, 31); gTasks[taskId].data[0] = a; } -void sub_80DC6A4(u8 taskId) +static void sub_80DC6A4(u8 taskId) { u8 r4 = gTasks[taskId].data[0]; @@ -3204,7 +3204,7 @@ void sub_80DC6A4(u8 taskId) } } -void sub_80DC728(u8 taskId) +static void sub_80DC728(u8 taskId) { u8 i; @@ -3232,7 +3232,7 @@ void sub_80DC728(u8 taskId) } } -void sub_80DC7EC(void) +static void sub_80DC7EC(void) { s32 i; @@ -3241,13 +3241,13 @@ void sub_80DC7EC(void) sub_80DC81C(i); } -void sub_80DC81C(u8 a) +static void sub_80DC81C(u8 a) { gTasks[sContest.unk19212].data[a * 4 + 0] = 0xFF; gTasks[sContest.unk19212].data[a * 4 + 1] = 0; } -void sub_80DC864(void) +static void sub_80DC864(void) { s32 i; @@ -3255,7 +3255,7 @@ void sub_80DC864(void) sub_80DC87C(i); } -void sub_80DC87C(u8 a) +static void sub_80DC87C(u8 a) { u32 var; u32 r0; @@ -3274,7 +3274,7 @@ void sub_80DC87C(u8 a) 2); } -void sub_80DC8D0(u8 taskId) +static void sub_80DC8D0(u8 taskId) { u8 i; @@ -3304,7 +3304,7 @@ void sub_80DC8D0(u8 taskId) } } -void sub_80DC9B4(u8 a) +static void sub_80DC9B4(u8 a) { if (sContestantStatus[a].hasJudgesAttention) sub_80DC630(a); @@ -3312,11 +3312,7 @@ void sub_80DC9B4(u8 a) sub_80DC674(a); } -extern const struct CompressedSpriteSheet gUnknown_08589904[]; -extern const struct SpritePalette gUnknown_08589924[]; -extern const struct SpriteTemplate gSpriteTemplate_858998C[]; - -u8 sub_80DC9EC(u8 a) +static u8 sub_80DC9EC(u8 a) { u8 spriteId1, spriteId2; u8 x = gUnknown_02039F26[a] * 40 + 32; @@ -3360,7 +3356,7 @@ u8 sub_80DC9EC(u8 a) return spriteId1; } -void sub_80DCB78(u8 spriteId) +static void sub_80DCB78(u8 spriteId) { u8 spriteId2 = gSprites[spriteId].data[0]; @@ -3369,19 +3365,19 @@ void sub_80DCB78(u8 spriteId) DestroySpriteAndFreeResources(&gSprites[spriteId]); } -void sub_80DCBB4(void) +static void sub_80DCBB4(void) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 9)); } -void sub_80DCBD0(void) +static void sub_80DCBD0(void) { SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); } -void sub_80DCBE8(u8 a, bool8 b) +static void sub_80DCBE8(u8 a, bool8 b) { u8 r5; @@ -3398,7 +3394,7 @@ void sub_80DCBE8(u8 a, bool8 b) PlaySE(SE_PC_LOGIN); } -void sub_80DCC84(struct Sprite *sprite) +static void sub_80DCC84(struct Sprite *sprite) { if (sprite->affineAnimEnded) { @@ -3413,14 +3409,14 @@ void sub_80DCC84(struct Sprite *sprite) } } -void sub_80DCCD8(struct Sprite *sprite) +static void sub_80DCCD8(struct Sprite *sprite) { gContestResources->field_14[sprite->data[1]].unk2_1 = 0; sub_80DCB78(sprite->data[0]); sub_80DCBD0(); } -void sub_80DCD08(void) +static void sub_80DCD08(void) { if(gHeap[0x1A000] == 1) gHeap[0x1A000] = 0; @@ -3438,7 +3434,7 @@ void sub_80DCD08(void) } } -void sub_80DCD48(void) +static void sub_80DCD48(void) { u8 i; s16 value; @@ -3569,7 +3565,7 @@ void sub_80DCE58(u8 a) } } -void sub_80DD04C(void) +static void sub_80DD04C(void) { s32 i; @@ -3580,7 +3576,7 @@ void sub_80DD04C(void) sub_80DAEA4(); } -void sub_80DD080(u8 contestant) +static void sub_80DD080(u8 contestant) { u16 move; u8 effect; @@ -3721,7 +3717,7 @@ void SetStartledString(u8 contestant, u8 jam) SetContestantEffectStringID(contestant, CONTEST_STRING_LOOKED_DOWN); } -void sub_80DD45C(u8 contestant, u8 stringId) +static void sub_80DD45C(u8 contestant, u8 stringId) { StringCopy(gStringVar1, gContestMons[contestant].nickname); StringCopy(gStringVar2, gMoveNames[sContestantStatus[contestant].currMove]); @@ -3746,7 +3742,7 @@ void MakeContestantNervous(u8 p) sContestantStatus[p].currMove = MOVE_NONE; } -void sub_80DD590(void) +static void sub_80DD590(void) { u8 r12 = 0; s32 i; @@ -3802,7 +3798,7 @@ void sub_80DD590(void) } } -void sub_80DD6DC(struct Sprite *sprite) +static void sub_80DD6DC(struct Sprite *sprite) { if (sprite->data[1]++ > 84) { @@ -3813,7 +3809,7 @@ void sub_80DD6DC(struct Sprite *sprite) } } -void sub_80DD720(u8 a) +static void sub_80DD720(u8 a) { u8 spriteId = sContest.unk19216; @@ -3860,7 +3856,7 @@ void sub_80DD720(u8 a) sContest.unk1920A_4 = 1; } -void sub_80DD940(void) +static void sub_80DD940(void) { s32 i; @@ -3885,7 +3881,7 @@ s8 Contest_GetMoveExcitement(u16 move) return gContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory]; } -u8 sub_80DDA20(void) +static u8 sub_80DDA20(void) { u8 taskId = CreateTask(c3_08130B10, 10); @@ -3894,7 +3890,7 @@ u8 sub_80DDA20(void) return taskId; } -void c3_08130B10(u8 taskId) +static void c3_08130B10(u8 taskId) { if (++gTasks[taskId].data[0] == 1) { @@ -3916,7 +3912,7 @@ void c3_08130B10(u8 taskId) } } -void sub_80DDB0C(void) +static void sub_80DDB0C(void) { CreateTask(sub_80DDB6C, 10); gSprites[sContest.applauseMeterSpriteId].pos2.x = -70; @@ -3924,7 +3920,7 @@ void sub_80DDB0C(void) sContest.unk1920A_6 = 1; } -void sub_80DDB6C(u8 taskId) +static void sub_80DDB6C(u8 taskId) { struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; @@ -3940,7 +3936,7 @@ void sub_80DDB6C(u8 taskId) } } -void sub_80DDBE8(void) +static void sub_80DDBE8(void) { if (gSprites[sContest.applauseMeterSpriteId].invisible == TRUE) { @@ -3954,7 +3950,7 @@ void sub_80DDBE8(void) } } -void task08_080CD1CC(u8 taskId) +static void task08_080CD1CC(u8 taskId) { struct Sprite *sprite = &gSprites[sContest.applauseMeterSpriteId]; @@ -3971,7 +3967,7 @@ void task08_080CD1CC(u8 taskId) } } -void sub_80DDCDC(s8 a) +static void sub_80DDCDC(s8 a) { u8 taskId = CreateTask(sub_80DDD20, 5); @@ -3979,7 +3975,7 @@ void sub_80DDCDC(s8 a) sContest.unk1920A_5 = 1; } -void sub_80DDD20(u8 taskId) +static void sub_80DDD20(u8 taskId) { switch (gTasks[taskId].data[10]) { @@ -4016,13 +4012,13 @@ void unref_sub_80DDDE4(void) gSprites[sContest.applauseMeterSpriteId].invisible = TRUE; } -void sub_80DDE0C(void) +static void sub_80DDE0C(void) { CreateTask(sub_80DDE30, 15); sContest.unk1920A_7 = 1; } -void sub_80DDE30(u8 taskId) +static void sub_80DDE30(u8 taskId) { if (gTasks[taskId].data[10]++ > 6) { @@ -4050,7 +4046,7 @@ void sub_80DDE30(u8 taskId) #define tBlendColor data[0] #define tBlendCoeff data[1] -void sub_80DDED0(s8 a, s8 b) +static void sub_80DDED0(s8 a, s8 b) { u8 taskId = CreateTask(sub_80DDF80, 10); u16 blendColor; @@ -4092,7 +4088,7 @@ void sub_80DDED0(s8 a, s8 b) sContest.unk1920B_0 = 0; } -void sub_80DDF80(u8 taskId) +static void sub_80DDF80(u8 taskId) { if (gTasks[taskId].data[10]++ >= 0) { @@ -4114,7 +4110,7 @@ void sub_80DDF80(u8 taskId) #undef tBlendColor #undef tBlendCoeff -void sub_80DE008(bool8 a) +static void sub_80DE008(bool8 a) { s32 i; @@ -4133,7 +4129,7 @@ void sub_80DE008(bool8 a) } } -const u8 *GetTurnOrderNumberGfx(u8 contestant) +static const u8 *GetTurnOrderNumberGfx(u8 contestant) { if (sContestantStatus[contestant].turnOrderMod != 1) return gContestNextTurnRandomGfx; @@ -4141,7 +4137,7 @@ const u8 *GetTurnOrderNumberGfx(u8 contestant) return gContestNextTurnNumbersGfx + sContestantStatus[contestant].nextTurnOrder * 32; } -void sub_80DE12C(void) +static void sub_80DE12C(void) { s32 r7 = 0; u8 r10 = 2; @@ -4171,7 +4167,7 @@ bool8 sub_80DE1E8(u8 a) return TRUE; } -void sub_80DE224(void) +static void sub_80DE224(void) { s32 i; u16 bg0Cnt, bg1Cnt, bg2Cnt; @@ -4209,7 +4205,7 @@ void sub_80DE224(void) } } -void sub_80DE350(void) +static void sub_80DE350(void) { s32 i; u16 bg1Cnt; @@ -4235,7 +4231,7 @@ void sub_80DE350(void) } } -void sub_80DE424(u8 taskId) +static void sub_80DE424(u8 taskId) { gBattle_BG1_X = 0; gBattle_BG1_Y = DISPLAY_HEIGHT; @@ -4243,7 +4239,7 @@ void sub_80DE424(u8 taskId) gTasks[taskId].func = sub_80DE464; } -void sub_80DE464(u8 taskId) +static void sub_80DE464(u8 taskId) { if ((s16)(gBattle_BG1_Y -= 7) < 0) gBattle_BG1_Y = 0; @@ -4256,7 +4252,7 @@ void sub_80DE464(u8 taskId) } } -void sub_80DE4A8(u8 taskId) +static void sub_80DE4A8(u8 taskId) { s32 i; @@ -4305,13 +4301,13 @@ void sub_80DE4A8(u8 taskId) } } -void sub_80DE5C0(u8 taskId) +static void sub_80DE5C0(u8 taskId) { if ((s16)(gBattle_BG1_Y += 7) > DISPLAY_HEIGHT) gTasks[taskId].func = sub_80DA4F4; } -void sub_80DE5F4(u8 taskId) +static void sub_80DE5F4(u8 taskId) { if (gTasks[taskId].data[2] < 10) { @@ -4342,7 +4338,7 @@ void sub_80DE5F4(u8 taskId) } } -void sub_80DE65C(u8 taskId) +static void sub_80DE65C(u8 taskId) { if (gTasks[taskId].data[2] < 10) { @@ -4356,7 +4352,7 @@ void sub_80DE65C(u8 taskId) } } -void sub_80DE69C(u8 a) +static void sub_80DE69C(u8 a) { s32 i; u8 taskId; @@ -4377,7 +4373,7 @@ void sub_80DE69C(u8 a) sContest.unk1920B_1 = 1; } -void sub_80DE794(u8 taskId) +static void sub_80DE794(u8 taskId) { s32 i; @@ -4395,21 +4391,21 @@ void sub_80DE794(u8 taskId) } } -u16 SanitizeMove(u16 move) +static u16 SanitizeMove(u16 move) { if (move >= MOVES_COUNT) move = MOVE_POUND; return move; } -u16 SanitizeSpecies(u16 species) +static u16 SanitizeSpecies(u16 species) { if (species >= NUM_SPECIES) species = SPECIES_NONE; return species; } -void sub_80DE864(u8 a) +static void sub_80DE864(u8 a) { s32 i; u16 move = SanitizeMove(sContestantStatus[a].currMove); @@ -4459,14 +4455,14 @@ void sub_80DE864(u8 a) sub_80DEA5C(); } -void sub_80DE9B0(u8 unused) +static void sub_80DE9B0(u8 unused) { memset(&gContestResources->field_18->species, 0, 0x14); if (sContest.unk1925E != 0) sContest.unk1925E--; } -void sub_80DE9DC(u8 a) +static void sub_80DE9DC(u8 a) { gContestResources->field_18->unk5 = a; gContestResources->field_18->species = SanitizeSpecies(gContestMons[a].species); @@ -4474,14 +4470,14 @@ void sub_80DE9DC(u8 a) gContestResources->field_18->unkC = gContestMons[a].otId; } -void sub_80DEA20(void) +static void sub_80DEA20(void) { gBattlerSpriteIds[3] = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); InitSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattlerTarget]]); sub_80DEA5C(); } -void sub_80DEA5C(void) +static void sub_80DEA5C(void) { struct Sprite *sprite = &gSprites[gBattlerSpriteIds[3]]; @@ -4492,7 +4488,7 @@ void sub_80DEA5C(void) sprite->invisible = TRUE; } -void SelectContestMoveBankTarget(u16 move) +static void SelectContestMoveBankTarget(u16 move) { switch (gBattleMoves[move].target) { @@ -4510,7 +4506,7 @@ void SelectContestMoveBankTarget(u16 move) } } -void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) +static void Contest_PrintTextToBg0WindowStd(u32 a, const u8 *b) { struct TextPrinterTemplate printerTemplate; @@ -4556,7 +4552,7 @@ void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s3 Contest_SetBgCopyFlags(0); } -void Contest_StartTextPrinter(const u8 *currChar, bool32 b) +static void Contest_StartTextPrinter(const u8 *currChar, bool32 b) { struct TextPrinterTemplate printerTemplate; u8 speed; @@ -4592,24 +4588,24 @@ void Contest_StartTextPrinter(const u8 *currChar, bool32 b) Contest_SetBgCopyFlags(0); } -void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, s16 h) +static void ContestBG_FillBoxWithIncrementingTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g, s16 h) { WriteSequenceToBgTilemapBuffer(a, b, c, d, e, f, g, h); Contest_SetBgCopyFlags(a); } -void ContestBG_FillBoxWithTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g) +static void ContestBG_FillBoxWithTile(u8 a, u16 b, u8 c, u8 d, u8 e, u8 f, u8 g) { ContestBG_FillBoxWithIncrementingTile(a, b, c, d, e, f, g, 0); } -bool32 Contest_RunTextPrinters(void) +static bool32 Contest_RunTextPrinters(void) { RunTextPrinters(); return IsTextPrinterActive(4); } -void Contest_SetBgCopyFlags(u32 var) +static void Contest_SetBgCopyFlags(u32 var) { sContestBgCopyFlags |= 1 << var; } @@ -4726,3 +4722,467 @@ void ClearContestWinnerPicsInContestHall(void) for (i = 0; i < 8; i++) gSaveBlock1Ptr->contestWinners[i] = gUnknown_08587FA4[i]; } + +// The functions below are probably related to Contests in TV. +static void sub_80DF080(u8 contestant) +{ + s32 i; + + if (!gContestResources->field_10->excitementFrozen + && gContestResources->field_10->bits_0 > 0 + && !gContestResources->field_4[contestant].disappointedRepeat) + { + gContestResources->field_1c[contestant].unkC |= 1; + gContestResources->field_1c[contestant].unkE_2 = 1; + } + + if (gContestResources->field_4[contestant].nervous) + gContestResources->field_1c[contestant].unkC |= 2; + + if (!gContestResources->field_10->excitementFrozen + && gContestResources->field_10->bits_0 != 0 + && gContestResources->field_10->unk2 == 60) + { + gContestResources->field_1c[contestant].unkC |= 4; + } + + if (gContestResources->field_4[contestant].unk15_6 + && gContestResources->field_4[contestant].unk16 != 0) + { + gContestResources->field_1c[contestant].unkC |= 8; + } + + for (i = 0; i < 4; i++) + { + if (i != contestant && gContestResources->field_4[i].jam != 0) + { + gContestResources->field_1c[contestant].unkC |= 0x10; + gContestResources->field_1c[i].unkC |= 0x40; + } + } + + if (gContestResources->field_4[contestant].numTurnsSkipped != 0 + || gContestResources->field_4[contestant].noMoreTurns) + { + gContestResources->field_1c[contestant].unkC |= 0x20; + } + else if (!gContestResources->field_4[contestant].nervous) + { + gContestResources->field_1c[contestant].unkC |= 0x80; + gContestResources->field_1c[contestant].unkE_1 = 1; + gContestResources->field_1c[contestant].unk0[gContestResources->field_0->turnNumber] = gContestResources->field_4[contestant].currMove; + } + + if (gContestResources->field_4[contestant].disappointedRepeat) + gContestResources->field_1c[contestant].unkD |= 2; + + if (gContestResources->field_0->applauseLevel == 4 + && !gContestResources->field_10->excitementFrozen + && gContestResources->field_10->bits_0 < 0) + { + gContestResources->field_1c[contestant].unkD |= 0x20; + } +} + +static void sub_80DF250(void) +{ + u8 r1; + s32 i, j; + bool32 r12, r8; + u16 sp0[6]; + u8 spC[6]; + u16 sp14[5]; + u8 var_38; + u8 r3; + u8 count; + + r1 = 0; + var_38 = 0; + + for (i = 0; i < 4; i++) + { + if (gContestFinalStandings[i] == 0) + var_38 = i; + else if (gContestFinalStandings[i] == 3) + r1 = i; + } + + gContestResources->field_1c[r1].unkD |= 1; + for (i = 0; i < 4; i++) + { + if (i != var_38 && gUnknown_02039F08[var_38] - gUnknown_02039F08[i] <= 50) + gContestResources->field_1c[i].unkD |= 4; + + if (!gContestResources->field_1c[i].unkE_2) + gContestResources->field_1c[i].unkD |= 8; + + for (j = 0; j < 4; j++) + { + if (gContestMonConditions[i] < gContestMonConditions[j]) + break; + } + if (j == 4 && gContestFinalStandings[i] != 0) + gContestResources->field_1c[i].unkD |= 0x10; + + r12 = FALSE; + r8 = FALSE; + for (j = 0; j < 4; j++) + { + if (gContestMonConditions[i] > gContestMonConditions[j]) + r12 = TRUE; + if (gUnknown_02039F18[i] > gUnknown_02039F18[j]) + r8 = TRUE; + } + if (!r12 && !r8) + gContestResources->field_1c[i].unkD |= 0x40; + + if (!gContestResources->field_1c[i].unkE_1) + gContestResources->field_1c[i].unkD |= 0x80; + } + + for (i = 0; i < 5; i++) + { + sp0[i] = 0; + spC[i] = 0; + } + sp0[5] = 0xFFFF; + spC[5] = 0; + + for (i = 0; i < 5; i++) + { + if (gContestResources->field_1c[var_38].unk0[i] != 0) + { + for (j = 0; j < 5; j++) + { + if (gContestResources->field_1c[var_38].unk0[i] != sp0[j]) + { + if (sp0[j] == 0) + { + sp0[j] = gContestResources->field_1c[var_38].unk0[i]; + spC[j]++; + } + } + else + { + spC[j]++; + } + } + } + } + + sp14[0] = sp0[0]; + r3 = spC[0]; + count = 0; + for (i = 1; sp0[i] != 0xFFFF; i++) + { + if (r3 < spC[i]) + { + sp14[0] = sp0[i]; + r3 = spC[i]; + count = 1; + } + else if (r3 == spC[i]) + { + sp14[count] = sp0[i]; + count++; + } + } + + gContestResources->field_1c[var_38].unkA = sp14[Random() % count]; +} + +static void sub_80DF4F8(void) +{ + s32 i; + u32 bits; + u8 r7; + u8 r9, r10; + u8 count; + u8 r5; + u8 r2; + u16 var; + u8 r4; + u8 r6; + u8 sp0[4]; + + if (gContestFinalStandings[gContestPlayerMonIndex] != 0) + return; + + r7 = 0; + for (i = 0; i < 4; i++) + { + if (gContestFinalStandings[i] == 0) + r7 = i; + } + + r9 = 0; + r10 = 0; + for (i = 0; i < 4; i++) + { + if (gContestMonConditions[r7] < gContestMonConditions[i]) + r9++; + if (gUnknown_02039F18[r7] < gUnknown_02039F18[i]) + r10++; + } + + bits = gContestResources->field_1c[r7].unkC; + count = 0; + for (i = 0; i < 8; bits >>= 1, i++) + { + if (bits & 1) + count++; + } + + r5 = Random() % count; + bits = gContestResources->field_1c[r7].unkC; + count = 0; + r2 = 0; + for (i = 0; i < 8; bits >>= 1, r2++, i++) + { + if (!(bits & 1)) + continue; + if (r5 == count) + break; + count++; + } + + var = 1 << r2; + if (r7 == 0) + { + sp0[0] = 1; + r4 = gContestResources->field_1c[1].unkD; + i = 2; + } + else + { + sp0[0] = 0; + r4 = gContestResources->field_1c[0].unkD; + i = 1; + } + + r5 = 1; + for (; i < 4; i++) + { + if (i != r7) + { + if (r4 < gContestResources->field_1c[i].unkD) + { + sp0[0] = i; + r4 = gContestResources->field_1c[i].unkD; + r5 = 1; + } + else if (r4 == gContestResources->field_1c[i].unkD) + { + sp0[r5] = i; + r5++; + } + } + } + + r6 = sp0[Random() % r5]; + r2 = 0x80; + for (i = 0; i < 8; r2 >>= 1, i++) + { + r4 = gContestResources->field_1c[r6].unkD & r2; + if (r4) + break; + } + + ContestLiveUpdates_BeforeInterview_1(r9); + ContestLiveUpdates_BeforeInterview_2(r10); + ContestLiveUpdates_BeforeInterview_3(var); + ContestLiveUpdates_BeforeInterview_4(gContestResources->field_1c[r7].unkA); + ContestLiveUpdates_BeforeInterview_5(r4, r6); +} + +// Unused +void sub_80DF704(u8 arg0) +{ + if (gHeap[0x1A000] == 0) + { + if (arg0 == 0) + gHeap[0x1A000] = 2; + else + gHeap[0x1A000] = 3; + } + else + { + gHeap[0x1A000] = 0; + } + + if (gHeap[0x1A000] == 0) + { + sub_80DAEA4(); + sub_80DB2BC(); + } + else + { + sub_80DF750(); + } +} + +static void sub_80DF750(void) +{ + u8 i; + s8 j; + u8 text1[20]; + u8 text2[20]; + u8 *txtPtr; + u32 bits; + + if (gUnknown_020322D5 == 0) + return; + if (gHeap[0x1A000] != 2 && gHeap[0x1A000] != 3) + return; + + for (i = 0; i < 4; i++) + FillWindowPixelBuffer(i, 0); + + if (gHeap[0x1A000] == 2) + { + for (i = 0; i < 4; i++) + { + txtPtr = StringCopy(text1, gText_CDot); + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1, 5, 1, 7); + bits = gContestResources->field_1c[i].unkC; + for (j = 7; j > -1; j--) // Weird loop. + { + txtPtr = ConvertIntToDecimalStringN(txtPtr, bits & 1, STR_CONV_MODE_LEFT_ALIGN, 1); + bits >>= 1; + } + + for (j = 0; j < 5; j++) + text2[j] = text1[j]; + + text2[j] = EOS; + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text2, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1 + j, 55, 1, 7); + } + } + else + { + for (i = 0; i < 4; i++) + { + StringCopy(text1, gText_BDot); + bits = gContestResources->field_1c[i].unkD; + txtPtr = &text1[2]; + for (j = 7; j > -1; j--) // Weird loop. + { + txtPtr = ConvertIntToDecimalStringN(txtPtr, bits & 1, STR_CONV_MODE_LEFT_ALIGN, 1); + bits >>= 1; + } + + for (j = 0; j < 5; j++) + text2[j] = text1[j]; + + text2[j] = EOS; + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text2, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[i], text1 + j, 55, 1, 7); + } + } + sub_80DB2BC(); +} + +static u8 sub_80DF940(u8 *nickname) +{ + u8 ret = GAME_LANGUAGE; + + if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN) + return LANGUAGE_ENGLISH; + + if (StringLength(nickname) < 6) + { + while (*nickname != EOS) + { + if ((*nickname >= CHAR_A && *nickname <= CHAR_z) + || (*nickname >= CHAR_0 && *nickname <= CHAR_9) + || *nickname == CHAR_SPACE + || *nickname == CHAR_PERIOD + || *nickname == CHAR_COMMA + || *nickname == CHAR_EXCL_MARK + || *nickname == CHAR_QUESTION_MARK + || *nickname == CHAR_MALE + || *nickname == CHAR_FEMALE + || *nickname == CHAR_SLASH + || *nickname == CHAR_HYPHEN + || *nickname == CHAR_ELLIPSIS + || *nickname == CHAR_DOUBLE_QUOTATION_LEFT + || *nickname == CHAR_DOUBLE_QUOTATION_RIGHT + || *nickname == CHAR_SINGLE_QUOTATION_LEFT + || *nickname == CHAR_DOUBLE_QUOTATION_LEFT) // Most likely a typo, CHAR_SINGLE_QUOTATION_RIGHT should be here instead. + { + nickname++; + } + else + { + ret = LANGUAGE_JAPANESE; + break; + } + } + } + + return ret; +} + +static void sub_80DF9D4(u8 *playerName) +{ + u8 chr = playerName[5]; + + playerName[5] = EOS; + playerName[PLAYER_NAME_LENGTH] = chr; +} + +static void sub_80DF9E0(u8 *monName, s32 language) +{ + u8 chr; + + StripExtCtrlCodes(monName); + if (language == LANGUAGE_JAPANESE) + { + monName[5] = EOS; + monName[POKEMON_NAME_LENGTH] = EXT_CTRL_CODE_BEGIN; + } + else + { + chr = monName[5]; + monName[5] = EOS; + monName[POKEMON_NAME_LENGTH] = chr; + } +} + +void sub_80DFA08(struct ContestPokemon *mon, s32 language) +{ + u8 *name = mon->nickname; + + if (language == LANGUAGE_JAPANESE) + { + ConvertInternationalString(name, sub_80DF940(name)); + } + else if (name[POKEMON_NAME_LENGTH] == EXT_CTRL_CODE_BEGIN) + { + ConvertInternationalString(name, LANGUAGE_JAPANESE); + } + else + { + name[5] = name[POKEMON_NAME_LENGTH]; + name[POKEMON_NAME_LENGTH] = EOS; + } + + name = mon->trainerName; + if (language == LANGUAGE_JAPANESE) + { + name[PLAYER_NAME_LENGTH] = EOS; + name[6] = name[4]; + name[5] = name[3]; + name[4] = name[2]; + name[3] = name[1]; + name[2] = mon->trainerName[0]; + name[1] = EXT_CTRL_CODE_JPN; + name[0] = EXT_CTRL_CODE_BEGIN; + } + else + { + name[5] = name[PLAYER_NAME_LENGTH]; + name[PLAYER_NAME_LENGTH] = EOS; + } +} From 922726ff3d5c5257881d305dd72650b6a76b8995 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 28 Jan 2019 18:19:58 +0100 Subject: [PATCH 11/12] contest --- src/contest.c | 1738 ++++++++++++++++++++++++------------------------- 1 file changed, 869 insertions(+), 869 deletions(-) diff --git a/src/contest.c b/src/contest.c index 799a19030..5b7363ec0 100644 --- a/src/contest.c +++ b/src/contest.c @@ -451,54 +451,54 @@ void sub_80D7B24(void) { switch (gMain.state) { - case 0: - sContestBgCopyFlags = 0; - sub_80D7988(); - AllocateMonSpritesGfx(); - FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed); - gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000); - SetVBlankCallback(NULL); - sub_80D779C(); - sub_80D77E4(); - sub_80D7678(); - ScanlineEffect_Clear(); - ResetPaletteFade(); - gPaletteFade.bufferTransferDisabled = TRUE; - ResetSpriteData(); - ResetTasks(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 4; - //shared18000.unk18000 = 0; - gHeap[0x1a000] = 0; - ClearBattleMonForms(); - sub_80D787C(); + case 0: + sContestBgCopyFlags = 0; + sub_80D7988(); + AllocateMonSpritesGfx(); + FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed); + gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000); + SetVBlankCallback(NULL); + sub_80D779C(); + sub_80D77E4(); + sub_80D7678(); + ScanlineEffect_Clear(); + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = TRUE; + ResetSpriteData(); + ResetTasks(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + //shared18000.unk18000 = 0; + gHeap[0x1a000] = 0; + ClearBattleMonForms(); + sub_80D787C(); + gMain.state++; + break; + case 1: + gMain.state++; + break; + case 2: + if (sub_80D7E44(&gContestResources->field_0->unk1925D)) + { + gContestResources->field_0->unk1925D = 0; gMain.state++; - break; - case 1: - gMain.state++; - break; - case 2: - if (sub_80D7E44(&gContestResources->field_0->unk1925D)) - { - gContestResources->field_0->unk1925D = 0; - gMain.state++; - } - break; - case 3: - sub_80DE224(); - gBattle_BG1_X = 0; - gBattle_BG1_Y = 0; - BeginFastPaletteFade(2); - gPaletteFade.bufferTransferDisabled = FALSE; - SetVBlankCallback(vblank_cb_battle); - gContestResources->field_0->mainTaskId = CreateTask(sub_80D7C7C, 10); - SetMainCallback2(sub_80D823C); - if (gIsLinkContest & 2) - { - sub_800E0E8(); - CreateWirelessStatusIndicatorSprite(8, 8); - } - break; + } + break; + case 3: + sub_80DE224(); + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + BeginFastPaletteFade(2); + gPaletteFade.bufferTransferDisabled = FALSE; + SetVBlankCallback(vblank_cb_battle); + gContestResources->field_0->mainTaskId = CreateTask(sub_80D7C7C, 10); + SetMainCallback2(sub_80D823C); + if (gIsLinkContest & 2) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(8, 8); + } + break; } } @@ -519,22 +519,22 @@ static void sub_80D7CB4(u8 taskId) { switch (gTasks[taskId].data[0]) { - case 0: - sub_80DBF68(); + case 0: + sub_80DBF68(); + gTasks[taskId].data[0]++; + // fallthrough + case 1: + if (IsLinkTaskFinished()) + { + sub_800ADF8(); gTasks[taskId].data[0]++; - // fallthrough - case 1: - if (IsLinkTaskFinished()) - { - sub_800ADF8(); - gTasks[taskId].data[0]++; - } + } + return; + case 2: + if (IsLinkTaskFinished() != TRUE) return; - case 2: - if (IsLinkTaskFinished() != TRUE) - return; - gTasks[taskId].data[0]++; - break; + gTasks[taskId].data[0]++; + break; } } @@ -584,67 +584,67 @@ static u8 sub_80D7E44(u8 *a) switch (*a) { - case 0: - gPaletteFade.bufferTransferDisabled = TRUE; - RequestDma3Fill(0, (void *)VRAM, 0x8000, 1); - RequestDma3Fill(0, (void *)VRAM + 0x8000, 0x8000, 1); - RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1); - break; - case 1: - LZDecompressVram(gContestMiscGfx, (void *)VRAM); - break; - case 2: - LZDecompressVram(gContestAudienceGfx, (void *)(VRAM + 0x2000)); - DmaCopyLarge32(3, (void *)(VRAM + 0x2000), shared15800, 0x2000, 0x1000); - break; - case 3: - CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0); - CopyBgTilemapBufferToVram(3); - break; - case 4: - CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); - CopyBgTilemapBufferToVram(2); - DmaCopy32Defvars(3, gContestResources->field_24[2], shared18000.unk18A04, 0x800); - break; - case 5: - LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); - CpuCopy32(gPlttBufferUnfaded + 128, sp0, 16 * sizeof(u16)); - CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); - CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); - CpuCopy32(sp0, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); - DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18004, 0x200); - sub_80D782C(); - break; - case 6: - sub_80DD04C(); - sub_80DBF90(); - sub_80DB2BC(); - gContestResources->field_0->unk19216 = sub_80DB120(); - sub_80DC2BC(); - sub_80DC4F0(); - CreateApplauseMeterSprite(); - sub_80DC5E8(); - sub_80DC7EC(); - gBattlerPositions[0] = 0; - gBattlerPositions[1] = 1; - gBattlerPositions[2] = 3; - gBattlerPositions[3] = 2; - gBattleTypeFlags = 0; - gBattlerAttacker = 2; - gBattlerTarget = 3; - gBattlerSpriteIds[gBattlerAttacker] = sub_80DB0C4(); - sub_80DEA20(); - CopyBgTilemapBufferToVram(3); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(1); - ShowBg(3); - ShowBg(2); - ShowBg(0); - ShowBg(1); - break; - default: - *a = 0; - return 1; + case 0: + gPaletteFade.bufferTransferDisabled = TRUE; + RequestDma3Fill(0, (void *)VRAM, 0x8000, 1); + RequestDma3Fill(0, (void *)VRAM + 0x8000, 0x8000, 1); + RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1); + break; + case 1: + LZDecompressVram(gContestMiscGfx, (void *)VRAM); + break; + case 2: + LZDecompressVram(gContestAudienceGfx, (void *)(VRAM + 0x2000)); + DmaCopyLarge32(3, (void *)(VRAM + 0x2000), shared15800, 0x2000, 0x1000); + break; + case 3: + CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0); + CopyBgTilemapBufferToVram(3); + break; + case 4: + CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); + CopyBgTilemapBufferToVram(2); + DmaCopy32Defvars(3, gContestResources->field_24[2], shared18000.unk18A04, 0x800); + break; + case 5: + LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200); + CpuCopy32(gPlttBufferUnfaded + 128, sp0, 16 * sizeof(u16)); + CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16)); + CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); + CpuCopy32(sp0, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); + DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18004, 0x200); + sub_80D782C(); + break; + case 6: + sub_80DD04C(); + sub_80DBF90(); + sub_80DB2BC(); + gContestResources->field_0->unk19216 = sub_80DB120(); + sub_80DC2BC(); + sub_80DC4F0(); + CreateApplauseMeterSprite(); + sub_80DC5E8(); + sub_80DC7EC(); + gBattlerPositions[0] = 0; + gBattlerPositions[1] = 1; + gBattlerPositions[2] = 3; + gBattlerPositions[3] = 2; + gBattleTypeFlags = 0; + gBattlerAttacker = 2; + gBattlerTarget = 3; + gBattlerSpriteIds[gBattlerAttacker] = sub_80DB0C4(); + sub_80DEA20(); + CopyBgTilemapBufferToVram(3); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(1); + ShowBg(3); + ShowBg(2); + ShowBg(0); + ShowBg(1); + break; + default: + *a = 0; + return 1; } (*a)++; @@ -666,43 +666,43 @@ static void sub_80D8108(u8 taskId) { switch (gTasks[taskId].data[0]) { - case 0: - if (gTasks[taskId].data[1]++ <= 60) - break; - gTasks[taskId].data[1] = 0; - PlaySE12WithPanning(SE_C_MAKU_U, 0); - gTasks[taskId].data[0]++; + case 0: + if (gTasks[taskId].data[1]++ <= 60) break; - case 1: - (s16)gBattle_BG1_Y += 7; - if ((s16)gBattle_BG1_Y <= 160) - break; - gTasks[taskId].data[0]++; + gTasks[taskId].data[1] = 0; + PlaySE12WithPanning(SE_C_MAKU_U, 0); + gTasks[taskId].data[0]++; + break; + case 1: + (s16)gBattle_BG1_Y += 7; + if ((s16)gBattle_BG1_Y <= 160) break; - case 2: - sub_80DE350(); - gTasks[taskId].data[0]++; - break; - case 3: - { - u16 bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT); - u16 bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT); - ((struct BgCnt *)&bg0Cnt)->priority = 0; - ((struct BgCnt *)&bg2Cnt)->priority = 0; - SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt); - SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt); - sub_80DDB0C(); - gTasks[taskId].data[0]++; - break; - } - case 4: - default: - if (gContestResources->field_0->unk1920A_6) - break; - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_80D833C; + gTasks[taskId].data[0]++; + break; + case 2: + sub_80DE350(); + gTasks[taskId].data[0]++; + break; + case 3: + { + u16 bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT); + u16 bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT); + ((struct BgCnt *)&bg0Cnt)->priority = 0; + ((struct BgCnt *)&bg2Cnt)->priority = 0; + SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt); + SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt); + sub_80DDB0C(); + gTasks[taskId].data[0]++; + break; + } + case 4: + default: + if (gContestResources->field_0->unk1920A_6) break; + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].func = sub_80D833C; + break; } } @@ -846,46 +846,46 @@ static void sub_80D8610(u8 taskId) { switch (gMain.newAndRepeatedKeys) { - case B_BUTTON: + case B_BUTTON: + PlaySE(SE_SELECT); + sub_80DC490(FALSE); + ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); + if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) + StringCopy(gDisplayedStringBattle, gText_0827D507); + else + StringCopy(gDisplayedStringBattle, gText_0827D531); + sub_80DB89C(); + StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); + Contest_StartTextPrinter(gStringVar4, 0); + gBattle_BG0_Y = 0; + gBattle_BG2_Y = 0; + gTasks[taskId].func = sub_80D8424; + break; + case DPAD_LEFT: + case DPAD_RIGHT: + break; + case DPAD_UP: + sub_80D883C(gContestResources->field_0->playerMoveChoice); + if (gContestResources->field_0->playerMoveChoice == 0) + gContestResources->field_0->playerMoveChoice = numMoves - 1; + else + gContestResources->field_0->playerMoveChoice--; + sub_80D880C(gContestResources->field_0->playerMoveChoice); + prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); + if (numMoves > 1) PlaySE(SE_SELECT); - sub_80DC490(FALSE); - ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); - if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) - StringCopy(gDisplayedStringBattle, gText_0827D507); - else - StringCopy(gDisplayedStringBattle, gText_0827D531); - sub_80DB89C(); - StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); - Contest_StartTextPrinter(gStringVar4, 0); - gBattle_BG0_Y = 0; - gBattle_BG2_Y = 0; - gTasks[taskId].func = sub_80D8424; - break; - case DPAD_LEFT: - case DPAD_RIGHT: - break; - case DPAD_UP: - sub_80D883C(gContestResources->field_0->playerMoveChoice); - if (gContestResources->field_0->playerMoveChoice == 0) - gContestResources->field_0->playerMoveChoice = numMoves - 1; - else - gContestResources->field_0->playerMoveChoice--; - sub_80D880C(gContestResources->field_0->playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); - if (numMoves > 1) - PlaySE(SE_SELECT); - break; - case DPAD_DOWN: - sub_80D883C(gContestResources->field_0->playerMoveChoice); - if (gContestResources->field_0->playerMoveChoice == numMoves - 1) - gContestResources->field_0->playerMoveChoice = 0; - else - gContestResources->field_0->playerMoveChoice++; - sub_80D880C(gContestResources->field_0->playerMoveChoice); - prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); - if (numMoves > 1) - PlaySE(SE_SELECT); - break; + break; + case DPAD_DOWN: + sub_80D883C(gContestResources->field_0->playerMoveChoice); + if (gContestResources->field_0->playerMoveChoice == numMoves - 1) + gContestResources->field_0->playerMoveChoice = 0; + else + gContestResources->field_0->playerMoveChoice++; + sub_80D880C(gContestResources->field_0->playerMoveChoice); + prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]); + if (numMoves > 1) + PlaySE(SE_SELECT); + break; } } } @@ -1001,100 +1001,100 @@ static void sub_80D8B38(u8 taskId) switch (gTasks[taskId].data[0]) { - case 0: - sub_80DCD48(); - for (i = 0; gContestResources->field_0->unk19214 != gContestResources->field_8->turnOrder[i]; i++) - ; - gContestResources->field_0->unk19215 = i; - r6 = gContestResources->field_0->unk19215; - if (gIsLinkContest & 1) - { - u8 taskId2; + case 0: + sub_80DCD48(); + for (i = 0; gContestResources->field_0->unk19214 != gContestResources->field_8->turnOrder[i]; i++) + ; + gContestResources->field_0->unk19215 = i; + r6 = gContestResources->field_0->unk19215; + if (gIsLinkContest & 1) + { + u8 taskId2; - gContestResources->field_0->unk1920B_2 = 1; - if (sub_80DA8A4()) - sub_80DD080(gContestResources->field_0->unk19215); - taskId2 = CreateTask(sub_80FCC88, 0); - SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); - sub_80DBF68(); - gTasks[taskId].data[0] = 1; - } - else - { + gContestResources->field_0->unk1920B_2 = 1; + if (sub_80DA8A4()) sub_80DD080(gContestResources->field_0->unk19215); - gTasks[taskId].data[0] = 2; - } - return; - case 1: - if (!gContestResources->field_0->unk1920B_2) - gTasks[taskId].data[0] = 2; - return; - case 2: - sub_80DF080(r6); - sub_80DF750(); - if (gContestResources->field_4[r6].numTurnsSkipped != 0 - || gContestResources->field_4[r6].noMoreTurns) - { - gTasks[taskId].data[0] = 31; - } + taskId2 = CreateTask(sub_80FCC88, 0); + SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110); + sub_80DBF68(); + gTasks[taskId].data[0] = 1; + } + else + { + sub_80DD080(gContestResources->field_0->unk19215); + gTasks[taskId].data[0] = 2; + } + return; + case 1: + if (!gContestResources->field_0->unk1920B_2) + gTasks[taskId].data[0] = 2; + return; + case 2: + sub_80DF080(r6); + sub_80DF750(); + if (gContestResources->field_4[r6].numTurnsSkipped != 0 + || gContestResources->field_4[r6].noMoreTurns) + { + gTasks[taskId].data[0] = 31; + } + else + { + sub_80DB89C(); + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 3; + } + return; + case 3: + for (i = 0; i < 4; i++) + gBattleMonForms[i] = 0; + memset(gContestResources->field_18, 0, sizeof(*gContestResources->field_18)); + sub_80DE9DC(gContestResources->field_0->unk19215); + spriteId = sub_80DB174( + gContestMons[gContestResources->field_0->unk19215].species, + gContestMons[gContestResources->field_0->unk19215].otId, + gContestMons[gContestResources->field_0->unk19215].personality, + gContestResources->field_0->unk19215); + gSprites[spriteId].pos2.x = 120; + gSprites[spriteId].callback = sub_80DA134; + gTasks[taskId].data[2] = spriteId; + gBattlerSpriteIds[gBattlerAttacker] = spriteId; + sub_80DCBE8(sub_80DC9EC(gContestResources->field_0->unk19215), FALSE); + gTasks[taskId].data[0] = 4; + return; + case 4: + spriteId = gTasks[taskId].data[2]; + if (gSprites[spriteId].callback == SpriteCallbackDummy) + { + if (!gContestResources->field_14[r6].unk2_1) + gTasks[taskId].data[0] = 5; + } + return; + case 5: + if (gContestResources->field_4[r6].nervous) + { + gTasks[taskId].data[0] = 33; + } + else + { + sub_80DB89C(); + StringCopy(gStringVar1, gContestMons[r6].nickname); + if (gContestResources->field_4[r6].currMove < MOVES_COUNT) + StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); else - { - sub_80DB89C(); - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 3; - } - return; - case 3: - for (i = 0; i < 4; i++) - gBattleMonForms[i] = 0; - memset(gContestResources->field_18, 0, sizeof(*gContestResources->field_18)); - sub_80DE9DC(gContestResources->field_0->unk19215); - spriteId = sub_80DB174( - gContestMons[gContestResources->field_0->unk19215].species, - gContestMons[gContestResources->field_0->unk19215].otId, - gContestMons[gContestResources->field_0->unk19215].personality, - gContestResources->field_0->unk19215); - gSprites[spriteId].pos2.x = 120; - gSprites[spriteId].callback = sub_80DA134; - gTasks[taskId].data[2] = spriteId; - gBattlerSpriteIds[gBattlerAttacker] = spriteId; - sub_80DCBE8(sub_80DC9EC(gContestResources->field_0->unk19215), FALSE); - gTasks[taskId].data[0] = 4; - return; - case 4: - spriteId = gTasks[taskId].data[2]; - if (gSprites[spriteId].callback == SpriteCallbackDummy) - { - if (!gContestResources->field_14[r6].unk2_1) - gTasks[taskId].data[0] = 5; - } - return; - case 5: - if (gContestResources->field_4[r6].nervous) - { - gTasks[taskId].data[0] = 33; - } - else - { - sub_80DB89C(); - StringCopy(gStringVar1, gContestMons[r6].nickname); - if (gContestResources->field_4[r6].currMove < MOVES_COUNT) - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); - else - StringCopy(gStringVar2, gUnknown_08587F1C[gContestResources->field_4[r6].moveCategory]); - StringExpandPlaceholders(gStringVar4, gText_0827D55A); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[0] = 6; - } - return; - case 6: - if (!Contest_RunTextPrinters()) - { - gContestResources->field_0->unk1925E = 0; - gTasks[taskId].data[0] = 7; - } - return; - case 7: + StringCopy(gStringVar2, gUnknown_08587F1C[gContestResources->field_4[r6].moveCategory]); + StringExpandPlaceholders(gStringVar4, gText_0827D55A); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[0] = 6; + } + return; + case 6: + if (!Contest_RunTextPrinters()) + { + gContestResources->field_0->unk1925E = 0; + gTasks[taskId].data[0] = 7; + } + return; + case 7: { u16 move = SanitizeMove(gContestResources->field_4[gContestResources->field_0->unk19215].currMove); @@ -1104,144 +1104,144 @@ static void sub_80D8B38(u8 taskId) DoMoveAnim(move); gTasks[taskId].data[0] = 8; } - return; - case 8: - gAnimScriptCallback(); - if (!gAnimScriptActive) - { - sub_80DE9B0(r6); - if (gContestResources->field_0->unk1925E != 0) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 9; - } - else - { - if (!gContestResources->field_4[r6].hasJudgesAttention) - sub_80DC674(r6); - sub_80DE12C(); - gTasks[taskId].data[0] = 23; - } - } - return; - case 9: - if (gTasks[taskId].data[10]++ > 30) + return; + case 8: + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + sub_80DE9B0(r6); + if (gContestResources->field_0->unk1925E != 0) { gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 7; - } - return; - case 23: - gTasks[taskId].data[1] = 0; - if (gContestResources->field_4[r6].effectStringId != CONTEST_STRING_NONE) - { - sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId); - gContestResources->field_4[r6].effectStringId = CONTEST_STRING_NONE; - gTasks[taskId].data[0] = 24; + gTasks[taskId].data[0] = 9; } else { - if (gContestResources->field_4[r6].effectStringId2 != CONTEST_STRING_NONE) + if (!gContestResources->field_4[r6].hasJudgesAttention) + sub_80DC674(r6); + sub_80DE12C(); + gTasks[taskId].data[0] = 23; + } + } + return; + case 9: + if (gTasks[taskId].data[10]++ > 30) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 7; + } + return; + case 23: + gTasks[taskId].data[1] = 0; + if (gContestResources->field_4[r6].effectStringId != CONTEST_STRING_NONE) + { + sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId); + gContestResources->field_4[r6].effectStringId = CONTEST_STRING_NONE; + gTasks[taskId].data[0] = 24; + } + else + { + if (gContestResources->field_4[r6].effectStringId2 != CONTEST_STRING_NONE) + { + for (i = 0; i < 4; i++) { - for (i = 0; i < 4; i++) - { - if (i != r6 && gContestResources->field_4[i].effectStringId != CONTEST_STRING_NONE) - break; - } - if (i == 4) - { - sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId2); - gContestResources->field_4[r6].effectStringId2 = CONTEST_STRING_NONE; - gTasks[taskId].data[0] = 24; - } - else - { - gTasks[taskId].data[0] = 48; - } + if (i != r6 && gContestResources->field_4[i].effectStringId != CONTEST_STRING_NONE) + break; + } + if (i == 4) + { + sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId2); + gContestResources->field_4[r6].effectStringId2 = CONTEST_STRING_NONE; + gTasks[taskId].data[0] = 24; } else { gTasks[taskId].data[0] = 48; } } - return; - case 24: - if (!Contest_RunTextPrinters()) - gTasks[taskId].data[0] = 23; - return; - case 48: - if (gContestResources->field_4[r6].turnOrderModAction == 1) - { - sub_80DD720(5); - } - else if (gContestResources->field_4[r6].turnOrderModAction == 2) - { - sub_80DD720(6); - } - else if (gContestResources->field_4[r6].turnOrderModAction == 3) - { - sub_80DD720(7); - } else { - gTasks[taskId].data[0] = 47; - return; + gTasks[taskId].data[0] = 48; } - gTasks[taskId].data[0] = 49; + } + return; + case 24: + if (!Contest_RunTextPrinters()) + gTasks[taskId].data[0] = 23; + return; + case 48: + if (gContestResources->field_4[r6].turnOrderModAction == 1) + { + sub_80DD720(5); + } + else if (gContestResources->field_4[r6].turnOrderModAction == 2) + { + sub_80DD720(6); + } + else if (gContestResources->field_4[r6].turnOrderModAction == 3) + { + sub_80DD720(7); + } + else + { + gTasks[taskId].data[0] = 47; return; - case 49: - if (!gContestResources->field_0->unk1920A_4) - gTasks[taskId].data[0] = 47; - return; - case 47: - sub_80DE008(TRUE); - gTasks[taskId].data[0] = 12; - return; - case 12: - sub_80DC028(0, gContestResources->field_4[r6].appeal2, r6); - gTasks[taskId].data[0] = 13; - return; - case 13: - if (!gContestResources->field_14[gContestResources->field_0->unk19215].unk2_2) - gTasks[taskId].data[0] = 35; - return; - case 35: - if (gContestResources->field_4[r6].conditionMod == 1) - sub_80DD720(8); - gTasks[taskId].data[0] = 36; - return; - case 36: - if (!gContestResources->field_0->unk1920A_4) - gTasks[taskId].data[0] = 37; - return; - case 37: - if (sub_80DB5B8(r6, 1)) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 38; - } - else - { - gTasks[taskId].data[0] = 50; - } - return; - case 38: - if (++gTasks[taskId].data[10] > 20) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 50; - } - return; - case 50: - if (sub_80DB798(r6)) - PlaySE(SE_C_PASI); - gTasks[taskId].data[0] = 25; - return; - case 25: - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[0] = 26; - return; - case 26: + } + gTasks[taskId].data[0] = 49; + return; + case 49: + if (!gContestResources->field_0->unk1920A_4) + gTasks[taskId].data[0] = 47; + return; + case 47: + sub_80DE008(TRUE); + gTasks[taskId].data[0] = 12; + return; + case 12: + sub_80DC028(0, gContestResources->field_4[r6].appeal2, r6); + gTasks[taskId].data[0] = 13; + return; + case 13: + if (!gContestResources->field_14[gContestResources->field_0->unk19215].unk2_2) + gTasks[taskId].data[0] = 35; + return; + case 35: + if (gContestResources->field_4[r6].conditionMod == 1) + sub_80DD720(8); + gTasks[taskId].data[0] = 36; + return; + case 36: + if (!gContestResources->field_0->unk1920A_4) + gTasks[taskId].data[0] = 37; + return; + case 37: + if (sub_80DB5B8(r6, 1)) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 38; + } + else + { + gTasks[taskId].data[0] = 50; + } + return; + case 38: + if (++gTasks[taskId].data[10] > 20) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 50; + } + return; + case 50: + if (sub_80DB798(r6)) + PlaySE(SE_C_PASI); + gTasks[taskId].data[0] = 25; + return; + case 25: + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[0] = 26; + return; + case 26: { s32 r2 = 0; @@ -1276,425 +1276,425 @@ static void sub_80D8B38(u8 taskId) sub_80DB884(); } } - return; - case 27: - if (!Contest_RunTextPrinters()) - gTasks[taskId].data[0] = 28; - return; - case 28: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) - ; - sub_80DC028(gContestResources->field_4[i].appeal2 + gContestResources->field_4[i].jam, -gContestResources->field_4[i].jam, i); - gTasks[taskId].data[0] = 29; - return; - case 29: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) - ; - if (!gContestResources->field_14[i].unk2_2) - gTasks[taskId].data[0] = 39; - return; - case 39: - for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) - ; - if (sub_80DB5B8(i, 1)) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 40; - } - else - { - gTasks[taskId].data[0] = 30; - } - return; - case 40: - if (++gTasks[taskId].data[10] > 20) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 30; - } - return; - case 30: - for (i = 0; i < 4; i++) - { - if (gUnknown_02039F26[i] == gTasks[taskId].data[1]) - break; - } - if (sub_80DB798(i)) - PlaySE(SE_C_PASI); - else - PlaySE(SE_C_SYU); - if (gContestResources->field_4[i].judgesAttentionWasRemoved) - { - sub_80DC674(i); - gContestResources->field_4[i].judgesAttentionWasRemoved = 0; - } - gTasks[taskId].data[1]++; - gTasks[taskId].data[0] = 26; - return; - case 51: - if (gTasks[taskId].data[10]++ > 9) - { - gTasks[taskId].data[10] = 0; - if (gContestResources->field_4[r6].numTurnsSkipped != 0 - || gContestResources->field_4[r6].turnSkipped) - { - sub_80DB89C(); - StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E793); - Contest_StartTextPrinter(gStringVar4, 1); - } - gTasks[taskId].data[0] = 52; - } - return; - case 52: - if (!Contest_RunTextPrinters()) - { - if (!gContestResources->field_4[r6].unk15_6) - gTasks[taskId].data[0] = 17; - else - gTasks[taskId].data[0] = 14; - } - return; - case 14: - r3 = gContestResources->field_4[r6].unk16; - if (gContestResources->field_4[r6].unk16 != 0) - { - sub_80DB89C(); - if (r3 == 1) - Contest_StartTextPrinter(gText_0827E32E, 1); - else if (r3 == 2) - Contest_StartTextPrinter(gText_0827E35B, 1); - else - Contest_StartTextPrinter(gText_0827E38D, 1); - sub_80DD720(3); - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 45; - } - else - { - sub_80DB89C(); - StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E2FE); - Contest_StartTextPrinter(gStringVar4, 1); - sub_80DD720(2); - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 45; - } - return; - case 45: - if (!gContestResources->field_0->unk1920A_4) - { - sub_80DC9B4(gContestResources->field_0->unk19215); - gTasks[taskId].data[0] = 15; - } - return; - case 15: - if (!Contest_RunTextPrinters()) - { - if (++gTasks[taskId].data[10] > 50) - { - if (!gContestResources->field_4[r6].hasJudgesAttention) - { - sub_80DC028( - gContestResources->field_4[r6].appeal2, - gContestResources->field_4[r6].unk17, - r6); - gContestResources->field_4[r6].appeal2 += gContestResources->field_4[r6].unk17; - } - gTasks[taskId].data[0] = 16; - } - } - return; - case 16: - if (!gContestResources->field_14[r6].unk2_2) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 17; - } - return; - case 17: - if (gContestResources->field_4[r6].disappointedRepeat) - { - sub_80DB89C(); - StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E6E3); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[10] = 0; - sub_80DD720(0); - gTasks[taskId].data[0] = 46; - } - else - { - gTasks[taskId].data[0] = 41; - } - return; - case 46: - if (!gContestResources->field_0->unk1920A_4) - gTasks[taskId].data[0] = 19; - return; - case 19: - if (!Contest_RunTextPrinters()) - { - sub_80DC028(gContestResources->field_4[r6].appeal2, -gContestResources->field_4[r6].unk18, r6); - gContestResources->field_4[r6].appeal2 -= gContestResources->field_4[r6].unk18; - gTasks[taskId].data[0] = 18; - } - return; - case 18: - sub_80DCD48(); - if (!gContestResources->field_14[r6].unk2_2) - { - gTasks[taskId].data[10] = 0; - sub_80DB89C(); - gTasks[taskId].data[0] = 41; - } - return; - case 41: - if (gContestResources->field_10->excitementFrozen && r6 != gContestResources->field_10->excitementFreezer) - { - gTasks[taskId].data[0] = 57; - } - else - { - r3 = gContestResources->field_10->bits_0; - if (gContestResources->field_4[r6].overrideCategoryExcitementMod) - { - r3 = 1; - StringCopy(gStringVar3, gMoveNames[gContestResources->field_4[r6].currMove]); - } - else - { - StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[gContestResources->field_4[r6].currMove].contestCategory]); - } - if (r3 > 0) - { - if (gContestResources->field_4[r6].disappointedRepeat) - r3 = 0; - } - sub_80DB89C(); - StringCopy(gStringVar1, gContestMons[r6].nickname); - gContestResources->field_0->applauseLevel += r3; - if (gContestResources->field_0->applauseLevel < 0) - gContestResources->field_0->applauseLevel = 0; - if (r3 == 0) - { - gTasks[taskId].data[0] = 55; - } - else - { - if (r3 < 0) - StringExpandPlaceholders(gStringVar4, gText_0827E73C); - else if (r3 > 0 && gContestResources->field_0->applauseLevel <= 4) - StringExpandPlaceholders(gStringVar4, gText_0827E717); - else - StringExpandPlaceholders(gStringVar4, gText_0827E76A); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[11] = 0; - if (r3 < 0) - gTasks[taskId].data[0] = 53; - else - gTasks[taskId].data[0] = 54; - } - } - return; - case 53: - switch (gTasks[taskId].data[10]) - { - case 0: - sub_80DDED0(-1, 1); - PlayFanfare(MUS_ME_ZANNEN); - gTasks[taskId].data[10]++; - break; - case 1: - if (!gContestResources->field_0->unk1920B_0 && !Contest_RunTextPrinters()) - { - sub_80DDCDC(-1); - gTasks[taskId].data[10]++; - } - break; - case 2: - if (!gContestResources->field_0->unk1920A_5) - { - if (gTasks[taskId].data[11]++ > 29) - { - gTasks[taskId].data[11] = 0; - sub_80DDED0(-1, -1); - gTasks[taskId].data[10]++; - } - } - break; - case 3: - if (!gPaletteFade.active) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[11] = 0; - gTasks[taskId].data[0] = 43; - } - break; - } - return; - case 54: - switch (gTasks[taskId].data[10]) - { - case 0: - if (!Contest_RunTextPrinters()) - { - sub_80DDED0(1, 1); - gTasks[taskId].data[10]++; - } - break; - case 1: - if (!gContestResources->field_0->unk1920B_0) - { - sub_80DDE0C(); - PlaySE(SE_W227B); - sub_80DDCDC(1); - gTasks[taskId].data[10]++; - } - break; - case 2: - if (!gContestResources->field_0->unk1920A_5) - { - if (gTasks[taskId].data[11]++ > 29) - { - gTasks[taskId].data[11] = 0; - sub_80DC028(gContestResources->field_4[r6].appeal2, gContestResources->field_10->unk2, r6); - gContestResources->field_4[r6].appeal2 += gContestResources->field_10->unk2; - gTasks[taskId].data[10]++; - } - } - break; - case 3: - if (!gContestResources->field_14[r6].unk2_2) - { - if (!gContestResources->field_0->unk1920A_7) - { - sub_80DDED0(1, -1); - gTasks[taskId].data[10]++; - } - } - break; - case 4: - if (!gPaletteFade.active) - { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[11] = 0; - gTasks[taskId].data[0] = 43; - } - break; - } - return; - case 43: - if (!gContestResources->field_14[r6].unk2_2) - { - sub_80DB89C(); - gTasks[taskId].data[0] = 55; - } - return; - case 57: - sub_80DB89C(); - StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname); - StringCopy(gStringVar1, gContestMons[r6].nickname); - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); - StringExpandPlaceholders(gStringVar4, gText_0827E7EA); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[0] = 58; - return; - case 58: - if (!Contest_RunTextPrinters()) - { - sub_80DB89C(); - StringExpandPlaceholders(gStringVar4, gText_0827E817); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[0] = 59; - } - return; - case 59: - if (!Contest_RunTextPrinters()) - { - sub_80DB89C(); - gTasks[taskId].data[0] = 55; - } - return; - case 33: - if (gContestResources->field_4[r6].hasJudgesAttention) - gContestResources->field_4[r6].hasJudgesAttention = 0; - sub_80DC9B4(r6); - StringCopy(gStringVar1, gContestMons[r6].nickname); - StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); - StringExpandPlaceholders(gStringVar4, gText_0827E58A); - Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[0] = 34; - return; - case 34: - if (!Contest_RunTextPrinters()) - gTasks[taskId].data[0] = 55; - return; - case 55: - sub_80DDBE8(); - gTasks[taskId].data[0] = 56; - return; - case 56: - if (!gContestResources->field_0->unk1920A_6) - { - if (gContestResources->field_0->applauseLevel > 4) - { - gContestResources->field_0->applauseLevel = 0; - sub_80DD940(); - } - gTasks[taskId].data[0] = 10; - } - return; - case 10: - spriteId = gTasks[taskId].data[2]; - gSprites[spriteId].callback = sub_80DA164; - gTasks[taskId].data[0] = 11; - return; - case 11: - spriteId = gTasks[taskId].data[2]; - if (gSprites[spriteId].invisible) - { - FreeSpriteOamMatrix(&gSprites[spriteId]); - DestroySprite(&gSprites[spriteId]); - gTasks[taskId].data[0] = 20; - } - return; - case 20: + return; + case 27: + if (!Contest_RunTextPrinters()) + gTasks[taskId].data[0] = 28; + return; + case 28: + for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + ; + sub_80DC028(gContestResources->field_4[i].appeal2 + gContestResources->field_4[i].jam, -gContestResources->field_4[i].jam, i); + gTasks[taskId].data[0] = 29; + return; + case 29: + for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + ; + if (!gContestResources->field_14[i].unk2_2) + gTasks[taskId].data[0] = 39; + return; + case 39: + for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++) + ; + if (sub_80DB5B8(i, 1)) + { gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 21; - return; - case 31: + gTasks[taskId].data[0] = 40; + } + else + { + gTasks[taskId].data[0] = 30; + } + return; + case 40: + if (++gTasks[taskId].data[10] > 20) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 30; + } + return; + case 30: + for (i = 0; i < 4; i++) + { + if (gUnknown_02039F26[i] == gTasks[taskId].data[1]) + break; + } + if (sub_80DB798(i)) + PlaySE(SE_C_PASI); + else + PlaySE(SE_C_SYU); + if (gContestResources->field_4[i].judgesAttentionWasRemoved) + { + sub_80DC674(i); + gContestResources->field_4[i].judgesAttentionWasRemoved = 0; + } + gTasks[taskId].data[1]++; + gTasks[taskId].data[0] = 26; + return; + case 51: + if (gTasks[taskId].data[10]++ > 9) + { + gTasks[taskId].data[10] = 0; + if (gContestResources->field_4[r6].numTurnsSkipped != 0 + || gContestResources->field_4[r6].turnSkipped) + { + sub_80DB89C(); + StringCopy(gStringVar1, gContestMons[r6].nickname); + StringExpandPlaceholders(gStringVar4, gText_0827E793); + Contest_StartTextPrinter(gStringVar4, 1); + } + gTasks[taskId].data[0] = 52; + } + return; + case 52: + if (!Contest_RunTextPrinters()) + { + if (!gContestResources->field_4[r6].unk15_6) + gTasks[taskId].data[0] = 17; + else + gTasks[taskId].data[0] = 14; + } + return; + case 14: + r3 = gContestResources->field_4[r6].unk16; + if (gContestResources->field_4[r6].unk16 != 0) + { + sub_80DB89C(); + if (r3 == 1) + Contest_StartTextPrinter(gText_0827E32E, 1); + else if (r3 == 2) + Contest_StartTextPrinter(gText_0827E35B, 1); + else + Contest_StartTextPrinter(gText_0827E38D, 1); + sub_80DD720(3); + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 45; + } + else + { sub_80DB89C(); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827D56F); + StringExpandPlaceholders(gStringVar4, gText_0827E2FE); Contest_StartTextPrinter(gStringVar4, 1); - gTasks[taskId].data[0] = 32; - return; - case 32: - if (!Contest_RunTextPrinters()) - gTasks[taskId].data[0] = 21; - return; - case 21: - if (++gTasks[taskId].data[10] > 29) + sub_80DD720(2); + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 45; + } + return; + case 45: + if (!gContestResources->field_0->unk1920A_4) + { + sub_80DC9B4(gContestResources->field_0->unk19215); + gTasks[taskId].data[0] = 15; + } + return; + case 15: + if (!Contest_RunTextPrinters()) + { + if (++gTasks[taskId].data[10] > 50) { - gTasks[taskId].data[10] = 0; - gTasks[taskId].data[0] = 22; + if (!gContestResources->field_4[r6].hasJudgesAttention) + { + sub_80DC028( + gContestResources->field_4[r6].appeal2, + gContestResources->field_4[r6].unk17, + r6); + gContestResources->field_4[r6].appeal2 += gContestResources->field_4[r6].unk17; + } + gTasks[taskId].data[0] = 16; } - return; - case 22: - if (++gContestResources->field_0->unk19214 == 4) + } + return; + case 16: + if (!gContestResources->field_14[r6].unk2_2) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 17; + } + return; + case 17: + if (gContestResources->field_4[r6].disappointedRepeat) + { + sub_80DB89C(); + StringCopy(gStringVar1, gContestMons[r6].nickname); + StringExpandPlaceholders(gStringVar4, gText_0827E6E3); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[10] = 0; + sub_80DD720(0); + gTasks[taskId].data[0] = 46; + } + else + { + gTasks[taskId].data[0] = 41; + } + return; + case 46: + if (!gContestResources->field_0->unk1920A_4) + gTasks[taskId].data[0] = 19; + return; + case 19: + if (!Contest_RunTextPrinters()) + { + sub_80DC028(gContestResources->field_4[r6].appeal2, -gContestResources->field_4[r6].unk18, r6); + gContestResources->field_4[r6].appeal2 -= gContestResources->field_4[r6].unk18; + gTasks[taskId].data[0] = 18; + } + return; + case 18: + sub_80DCD48(); + if (!gContestResources->field_14[r6].unk2_2) + { + gTasks[taskId].data[10] = 0; + sub_80DB89C(); + gTasks[taskId].data[0] = 41; + } + return; + case 41: + if (gContestResources->field_10->excitementFrozen && r6 != gContestResources->field_10->excitementFreezer) + { + gTasks[taskId].data[0] = 57; + } + else + { + r3 = gContestResources->field_10->bits_0; + if (gContestResources->field_4[r6].overrideCategoryExcitementMod) { - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_80DA198; + r3 = 1; + StringCopy(gStringVar3, gMoveNames[gContestResources->field_4[r6].currMove]); } else { - gTasks[taskId].data[0] = 0; + StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[gContestResources->field_4[r6].currMove].contestCategory]); } - return; + if (r3 > 0) + { + if (gContestResources->field_4[r6].disappointedRepeat) + r3 = 0; + } + sub_80DB89C(); + StringCopy(gStringVar1, gContestMons[r6].nickname); + gContestResources->field_0->applauseLevel += r3; + if (gContestResources->field_0->applauseLevel < 0) + gContestResources->field_0->applauseLevel = 0; + if (r3 == 0) + { + gTasks[taskId].data[0] = 55; + } + else + { + if (r3 < 0) + StringExpandPlaceholders(gStringVar4, gText_0827E73C); + else if (r3 > 0 && gContestResources->field_0->applauseLevel <= 4) + StringExpandPlaceholders(gStringVar4, gText_0827E717); + else + StringExpandPlaceholders(gStringVar4, gText_0827E76A); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[11] = 0; + if (r3 < 0) + gTasks[taskId].data[0] = 53; + else + gTasks[taskId].data[0] = 54; + } + } + return; + case 53: + switch (gTasks[taskId].data[10]) + { + case 0: + sub_80DDED0(-1, 1); + PlayFanfare(MUS_ME_ZANNEN); + gTasks[taskId].data[10]++; + break; + case 1: + if (!gContestResources->field_0->unk1920B_0 && !Contest_RunTextPrinters()) + { + sub_80DDCDC(-1); + gTasks[taskId].data[10]++; + } + break; + case 2: + if (!gContestResources->field_0->unk1920A_5) + { + if (gTasks[taskId].data[11]++ > 29) + { + gTasks[taskId].data[11] = 0; + sub_80DDED0(-1, -1); + gTasks[taskId].data[10]++; + } + } + break; + case 3: + if (!gPaletteFade.active) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[0] = 43; + } + break; + } + return; + case 54: + switch (gTasks[taskId].data[10]) + { + case 0: + if (!Contest_RunTextPrinters()) + { + sub_80DDED0(1, 1); + gTasks[taskId].data[10]++; + } + break; + case 1: + if (!gContestResources->field_0->unk1920B_0) + { + sub_80DDE0C(); + PlaySE(SE_W227B); + sub_80DDCDC(1); + gTasks[taskId].data[10]++; + } + break; + case 2: + if (!gContestResources->field_0->unk1920A_5) + { + if (gTasks[taskId].data[11]++ > 29) + { + gTasks[taskId].data[11] = 0; + sub_80DC028(gContestResources->field_4[r6].appeal2, gContestResources->field_10->unk2, r6); + gContestResources->field_4[r6].appeal2 += gContestResources->field_10->unk2; + gTasks[taskId].data[10]++; + } + } + break; + case 3: + if (!gContestResources->field_14[r6].unk2_2) + { + if (!gContestResources->field_0->unk1920A_7) + { + sub_80DDED0(1, -1); + gTasks[taskId].data[10]++; + } + } + break; + case 4: + if (!gPaletteFade.active) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[0] = 43; + } + break; + } + return; + case 43: + if (!gContestResources->field_14[r6].unk2_2) + { + sub_80DB89C(); + gTasks[taskId].data[0] = 55; + } + return; + case 57: + sub_80DB89C(); + StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname); + StringCopy(gStringVar1, gContestMons[r6].nickname); + StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); + StringExpandPlaceholders(gStringVar4, gText_0827E7EA); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[0] = 58; + return; + case 58: + if (!Contest_RunTextPrinters()) + { + sub_80DB89C(); + StringExpandPlaceholders(gStringVar4, gText_0827E817); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[0] = 59; + } + return; + case 59: + if (!Contest_RunTextPrinters()) + { + sub_80DB89C(); + gTasks[taskId].data[0] = 55; + } + return; + case 33: + if (gContestResources->field_4[r6].hasJudgesAttention) + gContestResources->field_4[r6].hasJudgesAttention = 0; + sub_80DC9B4(r6); + StringCopy(gStringVar1, gContestMons[r6].nickname); + StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]); + StringExpandPlaceholders(gStringVar4, gText_0827E58A); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[0] = 34; + return; + case 34: + if (!Contest_RunTextPrinters()) + gTasks[taskId].data[0] = 55; + return; + case 55: + sub_80DDBE8(); + gTasks[taskId].data[0] = 56; + return; + case 56: + if (!gContestResources->field_0->unk1920A_6) + { + if (gContestResources->field_0->applauseLevel > 4) + { + gContestResources->field_0->applauseLevel = 0; + sub_80DD940(); + } + gTasks[taskId].data[0] = 10; + } + return; + case 10: + spriteId = gTasks[taskId].data[2]; + gSprites[spriteId].callback = sub_80DA164; + gTasks[taskId].data[0] = 11; + return; + case 11: + spriteId = gTasks[taskId].data[2]; + if (gSprites[spriteId].invisible) + { + FreeSpriteOamMatrix(&gSprites[spriteId]); + DestroySprite(&gSprites[spriteId]); + gTasks[taskId].data[0] = 20; + } + return; + case 20: + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 21; + return; + case 31: + sub_80DB89C(); + StringCopy(gStringVar1, gContestMons[r6].nickname); + StringExpandPlaceholders(gStringVar4, gText_0827D56F); + Contest_StartTextPrinter(gStringVar4, 1); + gTasks[taskId].data[0] = 32; + return; + case 32: + if (!Contest_RunTextPrinters()) + gTasks[taskId].data[0] = 21; + return; + case 21: + if (++gTasks[taskId].data[10] > 29) + { + gTasks[taskId].data[10] = 0; + gTasks[taskId].data[0] = 22; + } + return; + case 22: + if (++gContestResources->field_0->unk19214 == 4) + { + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80DA198; + } + else + { + gTasks[taskId].data[0] = 0; + } + return; } } @@ -2309,32 +2309,32 @@ static u16 sub_80DAFE0(u8 who, u8 contestCategory) switch (contestCategory) { - case CONTEST_CATEGORY_COOL: - statMain = gContestMons[who].cool; - statSub1 = gContestMons[who].tough; - statSub2 = gContestMons[who].beauty; - break; - case CONTEST_CATEGORY_BEAUTY: - statMain = gContestMons[who].beauty; - statSub1 = gContestMons[who].cool; - statSub2 = gContestMons[who].cute; - break; - case CONTEST_CATEGORY_CUTE: - statMain = gContestMons[who].cute; - statSub1 = gContestMons[who].beauty; - statSub2 = gContestMons[who].smart; - break; - case CONTEST_CATEGORY_SMART: - statMain = gContestMons[who].smart; - statSub1 = gContestMons[who].cute; - statSub2 = gContestMons[who].tough; - break; - case CONTEST_CATEGORY_TOUGH: - default: - statMain = gContestMons[who].tough; - statSub1 = gContestMons[who].smart; - statSub2 = gContestMons[who].cool; - break; + case CONTEST_CATEGORY_COOL: + statMain = gContestMons[who].cool; + statSub1 = gContestMons[who].tough; + statSub2 = gContestMons[who].beauty; + break; + case CONTEST_CATEGORY_BEAUTY: + statMain = gContestMons[who].beauty; + statSub1 = gContestMons[who].cool; + statSub2 = gContestMons[who].cute; + break; + case CONTEST_CATEGORY_CUTE: + statMain = gContestMons[who].cute; + statSub1 = gContestMons[who].beauty; + statSub2 = gContestMons[who].smart; + break; + case CONTEST_CATEGORY_SMART: + statMain = gContestMons[who].smart; + statSub1 = gContestMons[who].cute; + statSub2 = gContestMons[who].tough; + break; + case CONTEST_CATEGORY_TOUGH: + default: + statMain = gContestMons[who].tough; + statSub1 = gContestMons[who].smart; + statSub2 = gContestMons[who].cool; + break; } return statMain + (statSub1 + statSub2 + gContestMons[who].sheen) / 2; } @@ -2420,18 +2420,18 @@ static u16 sub_80DB2EC(u16 a0, u8 a1) switch (gContestEffects[gContestMoves[a0].effect].effectType) { - case 0: - case 1: - case 8: - var = 0x9082; - break; - case 2: - case 3: - var = 0x9088; - break; - default: - var = 0x9086; - break; + case 0: + case 1: + case 8: + var = 0x9082; + break; + case 2: + case 3: + var = 0x9088; + break; + default: + var = 0x9086; + break; } var += 0x9000 + (a1 << 12); return var; @@ -2563,21 +2563,21 @@ static u16 sub_80DB748(u8 status) switch (status) { - case 0: - var = 0x80; - break; - case 1: - var = 0x84; - break; - case 2: - var = 0x86; - break; - case 3: - var = 0x88; - break; - case 4: - var = 0x82; - break; + case 0: + var = 0x80; + break; + case 1: + var = 0x84; + break; + case 2: + var = 0x86; + break; + case 3: + var = 0x88; + break; + case 4: + var = 0x82; + break; } var += 0x9000; return var; From 73d919fa0f798c14ca8e4097bb1d4fe06500ac18 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 28 Jan 2019 19:02:34 +0100 Subject: [PATCH 12/12] Define double single left right qutoation marks char --- include/text.h | 8 ++++---- src/contest.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/text.h b/include/text.h index aa499f558..96c5a4507 100644 --- a/include/text.h +++ b/include/text.h @@ -18,10 +18,10 @@ #define CHAR_PERIOD 0xAD #define CHAR_HYPHEN 0xAE #define CHAR_ELLIPSIS 0xB0 -#define CHAR_DOUBLE_QUOTATION_LEFT 0xB1 -#define CHAR_DOUBLE_QUOTATION_RIGHT 0xB2 -#define CHAR_SINGLE_QUOTATION_LEFT 0xB3 -#define CHAR_SINGLE_QUOTATION_RIGHT 0xB4 +#define CHAR_DBL_QUOT_LEFT 0xB1 +#define CHAR_DBL_QUOT_RIGHT 0xB2 +#define CHAR_SGL_QUOT_LEFT 0xB3 +#define CHAR_SGL_QUOT_RIGHT 0xB4 #define CHAR_MALE 0xB5 #define CHAR_FEMALE 0xB6 #define CHAR_CURRENCY 0xB7 diff --git a/src/contest.c b/src/contest.c index 5b7363ec0..b24036f39 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5106,10 +5106,10 @@ static u8 sub_80DF940(u8 *nickname) || *nickname == CHAR_SLASH || *nickname == CHAR_HYPHEN || *nickname == CHAR_ELLIPSIS - || *nickname == CHAR_DOUBLE_QUOTATION_LEFT - || *nickname == CHAR_DOUBLE_QUOTATION_RIGHT - || *nickname == CHAR_SINGLE_QUOTATION_LEFT - || *nickname == CHAR_DOUBLE_QUOTATION_LEFT) // Most likely a typo, CHAR_SINGLE_QUOTATION_RIGHT should be here instead. + || *nickname == CHAR_DBL_QUOT_LEFT + || *nickname == CHAR_DBL_QUOT_RIGHT + || *nickname == CHAR_SGL_QUOT_LEFT + || *nickname == CHAR_DBL_QUOT_LEFT) // Most likely a typo, CHAR_SGL_QUOT_RIGHT should be here instead. { nickname++; }