diff --git a/asm/berry_crush.s b/asm/berry_crush.s index cd70df741b..ebf8191889 100755 --- a/asm/berry_crush.s +++ b/asm/berry_crush.s @@ -5,2533 +5,6 @@ .text - thumb_func_start sub_8021A28 -sub_8021A28: @ 8021A28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - str r0, [sp, 0xC] - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0x10] - lsls r2, 24 - lsrs r2, 24 - str r2, [sp, 0x14] - lsls r3, 24 - movs r0, 0 - str r0, [sp, 0x18] - movs r1, 0 - str r1, [sp, 0x1C] - ldr r2, [sp, 0xC] - adds r2, 0x68 - str r2, [sp, 0x20] - movs r4, 0xF0 - lsls r4, 24 - adds r3, r4 - lsrs r3, 24 - ldr r0, [sp, 0x10] - cmp r0, 0x2 - bne _08021A68 - adds r0, r3, 0 - subs r0, 0x2A - lsls r0, 24 - lsrs r3, r0, 24 -_08021A68: - ldr r2, [sp, 0xC] - ldrb r1, [r2, 0x9] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 1 - subs r6, r3, r0 - cmp r6, 0 - ble _08021A84 - lsrs r0, r6, 31 - adds r0, r6, r0 - asrs r0, 1 - adds r6, r0, 0 - adds r6, 0x10 - b _08021A86 -_08021A84: - movs r6, 0x10 -_08021A86: - movs r5, 0 - ldr r3, [sp, 0xC] - ldrb r3, [r3, 0x9] - cmp r5, r3 - bcc _08021A92 - b _08021D14 -_08021A92: - ldr r4, [sp, 0x10] - lsls r4, 2 - str r4, [sp, 0x24] -_08021A98: - bl DynamicPlaceholderTextUtil_Reset - ldr r0, [sp, 0x10] - cmp r0, 0x1 - beq _08021B48 - cmp r0, 0x1 - bgt _08021AC0 - cmp r0, 0 - beq _08021ADE - ldr r4, [sp, 0x14] - subs r4, 0x4 - lsls r1, r6, 24 - mov r10, r1 - ldr r2, [sp, 0x1C] - adds r2, 0xA2 - mov r9, r2 - ldr r3, [sp, 0x18] - lsls r3, 5 - mov r8, r3 - b _08021C5A -_08021AC0: - ldr r4, [sp, 0x10] - cmp r4, 0x2 - bne _08021AC8 - b _08021C1C -_08021AC8: - ldr r4, [sp, 0x14] - subs r4, 0x4 - lsls r0, r6, 24 - mov r10, r0 - ldr r1, [sp, 0x1C] - adds r1, 0xA2 - mov r9, r1 - ldr r2, [sp, 0x18] - lsls r2, 5 - mov r8, r2 - b _08021C5A -_08021ADE: - ldr r0, [sp, 0x20] - adds r0, 0x20 - adds r0, r5 - ldrb r0, [r0] - str r0, [sp, 0x18] - lsls r3, r5, 1 - ldr r2, [sp, 0x20] - adds r2, 0xC - cmp r5, 0 - beq _08021B04 - adds r0, r2, r3 - subs r1, r5, 0x1 - lsls r1, 1 - adds r1, r2, r1 - ldrh r0, [r0] - ldrh r1, [r1] - cmp r0, r1 - beq _08021B04 - str r5, [sp, 0x1C] -_08021B04: - ldr r4, [sp, 0x24] - ldr r1, [sp, 0x10] - adds r0, r4, r1 - lsls r0, 1 - adds r0, r3, r0 - adds r0, r2, r0 - ldrh r1, [r0] - ldr r0, =gStringVar4 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r0, =gUnknown_082F43B4 - adds r0, r4, r0 - ldr r1, [r0] - ldr r0, =gStringVar4 - bl StringAppend - ldr r4, [sp, 0x14] - subs r4, 0x4 - lsls r2, r6, 24 - mov r10, r2 - ldr r3, [sp, 0x1C] - adds r3, 0xA2 - mov r9, r3 - ldr r0, [sp, 0x18] - lsls r0, 5 - mov r8, r0 - b _08021C5A - .pool -_08021B48: - ldr r1, [sp, 0x20] - adds r0, r1, r5 - adds r0, 0x28 - ldrb r0, [r0] - str r0, [sp, 0x18] - lsls r3, r5, 1 - adds r2, r1, 0 - adds r2, 0xC - cmp r5, 0 - beq _08021B72 - adds r0, r3, 0 - adds r0, 0xA - adds r0, r2, r0 - adds r1, r3, 0 - adds r1, 0x8 - adds r1, r2, r1 - ldrh r0, [r0] - ldrh r1, [r1] - cmp r0, r1 - beq _08021B72 - str r5, [sp, 0x1C] -_08021B72: - ldr r0, [sp, 0x24] - ldr r1, [sp, 0x10] - adds r4, r0, r1 - lsls r4, 1 - adds r4, r3, r4 - adds r4, r2, r4 - ldrh r1, [r4] - lsrs r1, 4 - ldr r0, =gStringVar1 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r7, 0 - ldrb r0, [r4] - movs r3, 0xF - ands r3, r0 - movs r2, 0 - ldr r4, [sp, 0x10] - lsls r4, 2 - str r4, [sp, 0x28] - ldr r4, [sp, 0x14] - subs r4, 0x4 - lsls r0, r6, 24 - mov r10, r0 - ldr r1, [sp, 0x1C] - adds r1, 0xA2 - mov r9, r1 - ldr r0, [sp, 0x18] - lsls r0, 5 - mov r8, r0 - adds r6, 0xE - adds r5, 0x1 - ldr r1, =gUnknown_082F334C - mov r12, r1 -_08021BB8: - movs r0, 0x3 - subs r1, r0, r2 - adds r0, r3, 0 - asrs r0, r1 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08021BD0 - lsls r0, r2, 2 - add r0, r12 - ldr r0, [r0] - adds r7, r0 -_08021BD0: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _08021BB8 - adds r0, r7, 0 - ldr r1, =0x000f4240 - bl __udivsi3 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, =gStringVar2 - adds r1, r3, 0 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, =gUnknown_082F43B4 - ldr r2, [sp, 0x28] - adds r0, r2, r0 - ldr r1, [r0] - ldr r0, =gStringVar4 - bl StringExpandPlaceholders - b _08021C5E - .pool -_08021C1C: - str r5, [sp, 0x18] - str r5, [sp, 0x1C] - lsls r7, r5, 5 - ldr r3, [sp, 0xC] - adds r0, r3, r7 - adds r0, 0xA4 - ldrb r2, [r0] - cmp r2, 0x2B - bls _08021C30 - movs r2, 0 -_08021C30: - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - ldr r0, =gBerries - adds r1, r0 - ldr r0, =gStringVar1 - bl StringCopy - ldr r0, =gUnknown_082F43B4 - ldr r1, [r0, 0x8] - ldr r0, =gStringVar4 - bl StringExpandPlaceholders - ldr r4, [sp, 0x14] - subs r4, 0x4 - lsls r0, r6, 24 - mov r10, r0 - movs r1, 0xA2 - adds r1, r5 - mov r9, r1 - mov r8, r7 -_08021C5A: - adds r6, 0xE - adds r5, 0x1 -_08021C5E: - movs r0, 0x2 - ldr r1, =gStringVar4 - adds r2, r4, 0 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - ldr r3, [sp, 0xC] - movs r4, 0xDD - lsls r4, 1 - adds r0, r3, r4 - ldrb r0, [r0] - lsls r2, 24 - lsrs r2, 24 - mov r1, r10 - lsrs r3, r1, 24 - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - movs r4, 0 - str r4, [sp, 0x4] - ldr r1, =gStringVar4 - str r1, [sp, 0x8] - movs r1, 0x2 - bl AddTextPrinterParameterized3 - ldr r3, [sp, 0x18] - ldr r2, [sp, 0xC] - ldrb r2, [r2, 0x8] - cmp r3, r2 - bne _08021CC0 - ldr r0, =gStringVar3 - ldr r1, =gText_1DotBlueF700 - bl StringCopy - b _08021CC8 - .pool -_08021CC0: - ldr r0, =gStringVar3 - ldr r1, =gText_1DotF700 - bl StringCopy -_08021CC8: - ldr r4, =gStringVar3 - mov r3, r9 - strb r3, [r4] - mov r1, r8 - adds r1, 0x98 - ldr r0, [sp, 0xC] - adds r1, r0, r1 - movs r0, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - ldr r0, =gStringVar4 - adds r1, r4, 0 - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - ldr r1, [sp, 0xC] - movs r2, 0xDD - lsls r2, 1 - adds r0, r1, r2 - ldrb r0, [r0] - mov r4, r10 - lsrs r3, r4, 24 - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - ldr r2, =gStringVar4 - str r2, [sp, 0x8] - movs r1, 0x2 - movs r2, 0x4 - bl AddTextPrinterParameterized3 - lsls r0, r5, 24 - lsrs r5, r0, 24 - ldr r3, [sp, 0xC] - ldrb r3, [r3, 0x9] - cmp r5, r3 - bcs _08021D14 - b _08021A98 -_08021D14: - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8021A28 - - thumb_func_start sub_8021D34 -sub_8021D34: @ 8021D34 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - mov r8, r0 - movs r0, 0 - mov r10, r0 - movs r6, 0 - movs r1, 0 - str r1, [sp, 0xC] - mov r2, r8 - adds r2, 0x68 - str r2, [sp, 0x10] - movs r4, 0xDD - lsls r4, 1 - add r4, r8 - mov r9, r4 - ldrb r0, [r4] - movs r1, 0x4 - bl GetWindowAttribute - lsls r0, 27 - movs r1, 0xD6 - lsls r1, 24 - adds r0, r1 - lsrs r7, r0, 24 - movs r0, 0x9C - lsls r0, 1 - add r0, r8 - ldr r2, [sp, 0x10] - ldrh r1, [r2, 0x4] - bl sub_8021944 - ldrb r0, [r4] - ldr r4, =sBerryCrushTextColors1 - str r4, [sp] - str r6, [sp, 0x4] - ldr r1, =gText_TimeColon - str r1, [sp, 0x8] - movs r1, 0x2 - movs r2, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - ldr r4, =gText_SpaceSec - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - movs r1, 0xB0 - subs r0, r1, r0 - lsls r0, 24 - lsrs r6, r0, 24 - mov r2, r9 - ldrb r0, [r2] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - mov r2, r10 - str r2, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - movs r0, 0x9F - lsls r0, 1 - add r0, r8 - movs r4, 0 - ldrsh r1, [r0, r4] - ldr r0, =gStringVar1 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, =gStringVar2 - movs r1, 0xA0 - lsls r1, 1 - add r1, r8 - movs r2, 0 - ldrsh r1, [r1, r2] - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r5, =gStringVar4 - ldr r1, =gText_XDotY2 - adds r0, r5, 0 - bl StringExpandPlaceholders - movs r0, 0x2 - adds r1, r5, 0 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - subs r0, r6, r0 - lsls r0, 24 - lsrs r6, r0, 24 - mov r4, r9 - ldrb r0, [r4] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - mov r2, r10 - str r2, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - ldr r4, =gText_SpaceMin - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - subs r0, r6, r0 - lsls r0, 24 - lsrs r6, r0, 24 - mov r1, r9 - ldrb r0, [r1] - ldr r2, =sBerryCrushTextColors1 - str r2, [sp] - mov r1, r10 - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - movs r0, 0x9E - lsls r0, 1 - add r0, r8 - movs r2, 0 - ldrsh r1, [r0, r2] - ldr r0, =gStringVar1 - movs r2, 0x2 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - ldr r1, =gText_StrVar1 - adds r0, r5, 0 - bl StringExpandPlaceholders - movs r0, 0x2 - adds r1, r5, 0 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - subs r0, r6, r0 - lsls r0, 24 - lsrs r6, r0, 24 - mov r4, r9 - ldrb r0, [r4] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - mov r2, r10 - str r2, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - adds r0, r7, 0 - adds r0, 0xE - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r4] - ldr r4, =sBerryCrushTextColors1 - str r4, [sp] - mov r1, r10 - str r1, [sp, 0x4] - ldr r1, =gText_PressingSpeed - str r1, [sp, 0x8] - movs r1, 0x2 - movs r2, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - ldr r4, =gText_TimesPerSec - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - movs r2, 0xB0 - subs r0, r2, r0 - lsls r0, 24 - str r0, [sp, 0x18] - lsrs r6, r0, 24 - mov r1, r9 - ldrb r0, [r1] - ldr r2, =sBerryCrushTextColors1 - str r2, [sp] - mov r1, r10 - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - mov r4, r8 - ldrb r2, [r4, 0x16] - ldrh r0, [r4, 0x16] - mov r12, r0 - movs r1, 0x7 - mov r9, r1 - movs r5, 0x1 - ldr r3, =gUnknown_082F334C -_08021EEC: - mov r4, r9 - mov r0, r10 - subs r1, r4, r0 - adds r0, r2, 0 - asrs r0, r1 - ands r0, r5 - cmp r0, 0 - beq _08021F0A - mov r1, r10 - lsls r0, r1, 2 - adds r0, r3 - ldr r0, [r0] - ldr r4, [sp, 0xC] - adds r4, r0 - str r4, [sp, 0xC] -_08021F0A: - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - cmp r0, 0x7 - bls _08021EEC - ldr r0, =gStringVar1 - mov r2, r12 - lsrs r1, r2, 8 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar2 - ldr r1, =0x000f4240 - ldr r0, [sp, 0xC] - bl __udivsi3 - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_XDotY3 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r2, 0x1 - negs r2, r2 - movs r0, 0x2 - adds r1, r4, 0 - bl GetStringWidth - subs r0, r6, r0 - lsls r0, 24 - lsrs r6, r0, 24 - mov r0, r8 - adds r0, 0x25 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - beq _08021FC4 - movs r0, 0xDD - lsls r0, 1 - add r0, r8 - ldrb r0, [r0] - ldr r1, =sBerryCrushTextColors4 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - b _08021FDE - .pool -_08021FC4: - movs r0, 0xDD - lsls r0, 1 - add r0, r8 - ldrb r0, [r0] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - str r2, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 -_08021FDE: - adds r0, r7, 0 - adds r0, 0xE - lsls r0, 24 - lsrs r7, r0, 24 - movs r4, 0xDD - lsls r4, 1 - add r8, r4 - mov r1, r8 - ldrb r0, [r1] - ldr r2, =sBerryCrushTextColors1 - mov r9, r2 - str r2, [sp] - movs r5, 0 - str r5, [sp, 0x4] - ldr r1, =gText_Silkiness - str r1, [sp, 0x8] - movs r1, 0x2 - movs r2, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - ldr r0, =gStringVar1 - ldr r4, [sp, 0x10] - ldrh r1, [r4, 0x8] - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_Var1Percent - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r2, 0x1 - negs r2, r2 - movs r0, 0x2 - adds r1, r4, 0 - bl GetStringWidth - movs r1, 0xB0 - subs r1, r0 - lsls r1, 24 - lsrs r6, r1, 24 - mov r1, r8 - ldrb r0, [r1] - mov r2, r9 - str r2, [sp] - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x2 - adds r2, r6, 0 - adds r3, r7, 0 - bl AddTextPrinterParameterized3 - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8021D34 - - thumb_func_start sub_8022070 -sub_8022070: @ 8022070 - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r6, r1, 0 - adds r0, r6, 0 - adds r0, 0x80 - ldrb r0, [r0] - cmp r0, 0x5 - bls _08022084 - b _08022218 -_08022084: - lsls r0, 2 - ldr r1, =_08022094 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08022094: - .4byte _080220AC - .4byte _080220F8 - .4byte _0802210C - .4byte _08022130 - .4byte _080221F8 - .4byte _08022200 -_080220AC: - ldrb r0, [r4, 0x9] - subs r0, 0x2 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r6, 0 - bl sub_8022554 - ldrh r0, [r4, 0x12] - lsls r0, 3 - ldr r2, =gUnknown_082F32CC - mov r1, sp - adds r0, r2 - ldm r0!, {r2,r3} - stm r1!, {r2,r3} - ldrh r0, [r4, 0x12] - cmp r0, 0xD - bne _080220DC - ldr r0, =gUnknown_082F3344 - adds r0, 0x4 - b _080220DE - .pool -_080220DC: - ldr r0, =gUnknown_082F3344 -_080220DE: - adds r0, r5, r0 - ldrb r1, [r0] - mov r0, sp - strb r1, [r0, 0x4] - mov r0, sp - bl AddWindow - adds r1, r6, 0 - adds r1, 0x82 - strb r0, [r1] - b _08022218 - .pool -_080220F8: - adds r4, r6, 0 - adds r4, 0x82 - ldrb r0, [r4] - bl PutWindowTilemap - ldrb r0, [r4] - movs r1, 0 - bl FillWindowPixelBuffer - b _08022218 -_0802210C: - adds r5, r6, 0 - adds r5, 0x82 - ldrb r0, [r5] - ldr r4, =0x0000021d - adds r1, r4, 0 - movs r2, 0xD0 - bl LoadUserWindowBorderGfx_ - ldrb r0, [r5] - movs r1, 0 - adds r2, r4, 0 - movs r3, 0xD - bl DrawStdFrameWithCustomTileAndPalette - b _08022218 - .pool -_08022130: - ldrb r0, [r4, 0x9] - subs r0, 0x2 - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r4, 0x12] - cmp r0, 0xC - beq _08022184 - cmp r0, 0xC - bgt _08022148 - cmp r0, 0xB - beq _0802214E - b _08022218 -_08022148: - cmp r0, 0xD - beq _080221C8 - b _08022218 -_0802214E: - adds r0, r6, 0 - adds r0, 0x82 - ldrb r0, [r0] - ldr r3, =gText_PressesRankings - movs r1, 0x14 - movs r2, 0x3 - bl sub_80219C8 - ldr r0, =gUnknown_082F3344 - adds r0, r5, r0 - ldrb r3, [r0] - lsls r3, 27 - lsrs r3, 24 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0xA0 - bl sub_8021A28 - adds r1, r6, 0 - adds r1, 0x80 - movs r0, 0x5 - b _08022220 - .pool -_08022184: - adds r0, r6, 0 - adds r0, 0x82 - ldrb r0, [r0] - ldr r2, =gUnknown_082F43B4 - adds r1, r4, 0 - adds r1, 0x8F - ldrb r1, [r1] - adds r1, 0x3 - lsls r1, 2 - adds r1, r2 - ldr r3, [r1] - movs r1, 0x14 - movs r2, 0x4 - bl sub_80219C8 - ldr r0, =gUnknown_082F3344 - adds r0, r5, r0 - ldrb r3, [r0] - lsls r3, 27 - lsrs r3, 24 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0xA0 - bl sub_8021A28 - adds r1, r6, 0 - adds r1, 0x80 - movs r0, 0x5 - b _08022220 - .pool -_080221C8: - adds r0, r6, 0 - adds r0, 0x82 - ldrb r0, [r0] - ldr r3, =gText_CrushingResults - movs r1, 0x16 - movs r2, 0x3 - bl sub_80219C8 - ldr r0, =gUnknown_082F3344 - adds r0, 0x4 - adds r0, r5, r0 - ldrb r3, [r0] - lsls r3, 27 - lsrs r3, 24 - adds r0, r4, 0 - movs r1, 0x2 - movs r2, 0xB0 - bl sub_8021A28 - b _08022218 - .pool -_080221F8: - adds r0, r4, 0 - bl sub_8021D34 - b _08022218 -_08022200: - adds r0, r6, 0 - adds r0, 0x82 - ldrb r0, [r0] - movs r1, 0x3 - bl CopyWindowToVram - adds r1, r6, 0 - adds r1, 0x80 - movs r0, 0 - strb r0, [r1] - movs r0, 0x1 - b _08022224 -_08022218: - adds r1, r6, 0 - adds r1, 0x80 - ldrb r0, [r1] - adds r0, 0x1 -_08022220: - strb r0, [r1] - movs r0, 0 -_08022224: - add sp, 0x8 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8022070 - - thumb_func_start sub_802222C -sub_802222C: @ 802222C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xDD - lsls r0, 1 - adds r5, r4, r0 - ldrb r0, [r5] - movs r1, 0x1 - bl ClearStdWindowAndFrameToTransparent - ldrb r0, [r5] - bl RemoveWindow - adds r0, r4, 0 - bl sub_8022600 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_802222C - - thumb_func_start sub_8022250 -sub_8022250: @ 8022250 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0 - mov r9, r0 - movs r1, 0 - str r1, [sp, 0xC] - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0x1 - beq _080222D0 - cmp r0, 0x1 - bgt _08022288 - cmp r0, 0 - beq _08022296 - b _080224BA - .pool -_08022288: - cmp r0, 0x2 - bne _0802228E - b _08022480 -_0802228E: - cmp r0, 0x3 - bne _08022294 - b _08022494 -_08022294: - b _080224BA -_08022296: - ldr r0, =gUnknown_082F32EC - bl AddWindow - strh r0, [r6, 0x2] - lsls r0, 24 - lsrs r0, 24 - bl PutWindowTilemap - ldrb r0, [r6, 0x2] - movs r1, 0 - bl FillWindowPixelBuffer - ldrb r0, [r6, 0x2] - ldr r4, =0x0000021d - adds r1, r4, 0 - movs r2, 0xD0 - bl LoadUserWindowBorderGfx_ - ldrb r0, [r6, 0x2] - movs r1, 0 - adds r2, r4, 0 - movs r3, 0xD - bl DrawStdFrameWithCustomTileAndPalette - b _080224BA - .pool -_080222D0: - ldr r0, =gText_BerryCrush2 - mov r10, r0 - movs r1, 0x1 - negs r1, r1 - mov r8, r1 - movs r0, 0x1 - mov r1, r10 - mov r2, r8 - bl GetStringWidth - lsrs r0, 1 - movs r4, 0x60 - subs r0, r4, r0 - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r6, 0x2] - ldr r5, =sBerryCrushTextColorTable - str r5, [sp] - mov r1, r9 - str r1, [sp, 0x4] - mov r1, r10 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - movs r3, 0x1 - bl AddTextPrinterParameterized3 - ldr r0, =gText_PressingSpeedRankings - mov r10, r0 - movs r0, 0x1 - mov r1, r10 - mov r2, r8 - bl GetStringWidth - lsrs r0, 1 - subs r4, r0 - lsls r4, 24 - lsrs r7, r4, 24 - ldrb r0, [r6, 0x2] - str r5, [sp] - mov r1, r9 - str r1, [sp, 0x4] - mov r1, r10 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - movs r3, 0x11 - bl AddTextPrinterParameterized3 - movs r0, 0x29 - mov r10, r0 -_08022336: - mov r1, r9 - adds r1, 0x2 - ldr r0, =gStringVar1 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - ldr r0, =gStringVar4 - ldr r1, =gText_Var1Players - bl StringExpandPlaceholders - ldrb r0, [r6, 0x2] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - ldr r1, =gStringVar4 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r2, 0 - mov r3, r10 - bl AddTextPrinterParameterized3 - movs r0, 0x1 - ldr r1, =gText_TimesPerSec - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - movs r1, 0xC0 - subs r1, r0 - lsls r1, 24 - lsrs r7, r1, 24 - ldrb r0, [r6, 0x2] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - ldr r1, =gText_TimesPerSec - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - mov r3, r10 - bl AddTextPrinterParameterized3 - movs r2, 0 - mov r0, r9 - lsls r4, r0, 1 - mov r1, r10 - adds r1, 0x10 - str r1, [sp, 0x10] - movs r0, 0x1 - add r9, r0 - adds r0, r4, r6 - ldrb r3, [r0, 0x4] - movs r1, 0x7 - mov r12, r1 - movs r0, 0x1 - mov r8, r0 - ldr r5, =gUnknown_082F334C -_080223AE: - mov r0, r12 - subs r1, r0, r2 - adds r0, r3, 0 - asrs r0, r1 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _080223CA - lsls r0, r2, 2 - adds r0, r5 - ldr r0, [r0] - ldr r1, [sp, 0xC] - adds r1, r0 - str r1, [sp, 0xC] -_080223CA: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x7 - bls _080223AE - adds r0, r4, r6 - ldrh r1, [r0, 0x4] - lsrs r1, 8 - ldr r0, =gStringVar1 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r0, [sp, 0xC] - ldr r1, =0x000f4240 - bl __udivsi3 - adds r1, r0, 0 - ldr r0, =gStringVar2 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, =gStringVar4 - ldr r1, =gText_XDotY3 - bl StringExpandPlaceholders - movs r0, 0x1 - ldr r1, =gStringVar4 - movs r2, 0x1 - negs r2, r2 - bl GetStringWidth - subs r0, r7, r0 - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r6, 0x2] - ldr r1, =sBerryCrushTextColors1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - ldr r1, =gStringVar4 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - mov r3, r10 - bl AddTextPrinterParameterized3 - ldr r1, [sp, 0x10] - lsls r0, r1, 24 - lsrs r0, 24 - mov r10, r0 - movs r0, 0 - str r0, [sp, 0xC] - mov r1, r9 - lsls r0, r1, 24 - lsrs r0, 24 - mov r9, r0 - cmp r0, 0x3 - bhi _08022444 - b _08022336 -_08022444: - ldrb r0, [r6, 0x2] - movs r1, 0x3 - bl CopyWindowToVram - b _080224BA - .pool -_08022480: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080224BA - b _080224C0 - .pool -_08022494: - ldrb r0, [r6, 0x2] - movs r1, 0x1 - bl ClearStdWindowAndFrameToTransparent - ldrb r0, [r6, 0x2] - bl ClearWindowTilemap - ldrb r0, [r6, 0x2] - bl RemoveWindow - adds r0, r4, 0 - bl DestroyTask - bl EnableBothScriptContexts - bl ScriptContext2_Disable - mov r0, r9 - b _080224BE -_080224BA: - ldrh r0, [r6] - adds r0, 0x1 -_080224BE: - strh r0, [r6] -_080224C0: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8022250 - - thumb_func_start ShowBerryCrushRankings -ShowBerryCrushRankings: @ 80224D0 - push {lr} - bl ScriptContext2_Enable - ldr r0, =sub_8022250 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - movs r3, 0xF6 - lsls r3, 1 - adds r0, r2, r3 - ldrh r0, [r0] - strh r0, [r1, 0xC] - adds r3, 0x2 - adds r0, r2, r3 - ldrh r0, [r0] - strh r0, [r1, 0xE] - adds r3, 0x2 - adds r0, r2, r3 - ldrh r0, [r0] - strh r0, [r1, 0x10] - adds r3, 0x2 - adds r0, r2, r3 - ldrh r0, [r0] - strh r0, [r1, 0x12] - pop {r0} - bx r0 - .pool - thumb_func_end ShowBerryCrushRankings - - thumb_func_start sub_8022524 -sub_8022524: @ 8022524 - push {r4,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - bl sub_8021944 - movs r0, 0x4 - ldrsh r1, [r4, r0] - movs r0, 0 - bl sub_8035044 - movs r0, 0x6 - ldrsh r1, [r4, r0] - movs r0, 0x1 - bl sub_8035044 - movs r0, 0x8 - ldrsh r1, [r4, r0] - movs r0, 0x2 - bl sub_8035044 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8022524 - - thumb_func_start sub_8022554 -sub_8022554: @ 8022554 - push {lr} - ldr r2, [r0, 0x78] - adds r2, 0x3E - ldrb r1, [r2] - movs r3, 0x4 - orrs r1, r3 - strb r1, [r2] - ldr r1, [r0, 0x7C] - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r3 - strb r0, [r1] - movs r0, 0x2 - movs r1, 0x1 - bl sub_803547C - movs r0, 0x1 - movs r1, 0x1 - bl sub_803547C - movs r0, 0 - movs r1, 0x1 - bl sub_803547C - pop {r0} - bx r0 - thumb_func_end sub_8022554 - - thumb_func_start sub_8022588 -sub_8022588: @ 8022588 - push {r4-r7,lr} - adds r5, r0, 0 - movs r6, 0 - ldrb r0, [r5, 0x9] - cmp r6, r0 - bcs _080225E8 - ldr r7, =gUnknown_082F417C -_08022596: - lsls r0, r6, 2 - movs r1, 0xA2 - lsls r1, 1 - adds r2, r5, r1 - adds r2, r0 - ldrb r1, [r5, 0x9] - subs r1, 0x2 - lsls r0, r1, 2 - adds r0, r1 - adds r0, r6, r0 - adds r0, r7 - ldrb r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - ldr r1, =gUnknown_082F4190 - adds r0, r1 - str r0, [r2] - ldrb r0, [r0] - lsls r0, 3 - ldr r1, =gUnknown_082F32F4 - adds r0, r1 - bl AddWindow - ldr r1, =0x000001bb - adds r4, r5, r1 - adds r4, r6 - strb r0, [r4] - ldrb r0, [r4] - bl PutWindowTilemap - ldrb r0, [r4] - movs r1, 0 - bl FillWindowPixelBuffer - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - ldrb r0, [r5, 0x9] - cmp r6, r0 - bcc _08022596 -_080225E8: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022588 - - thumb_func_start sub_8022600 -sub_8022600: @ 8022600 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - adds r6, r0, 0 - movs r7, 0 - ldrb r0, [r6, 0x9] - cmp r7, r0 - bcs _080226B6 - movs r1, 0 - mov r8, r1 -_08022616: - ldr r1, =0x000001bb - adds r0, r6, r1 - adds r5, r0, r7 - ldrb r0, [r5] - bl PutWindowTilemap - ldrb r0, [r6, 0x8] - cmp r7, r0 - bne _08022668 - lsls r4, r7, 5 - adds r4, 0x98 - adds r4, r6, r4 - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0 - bl GetStringWidth - lsrs r0, 1 - movs r2, 0x24 - subs r2, r0 - lsls r2, 24 - lsrs r2, 24 - ldrb r0, [r5] - mov r1, r8 - str r1, [sp] - str r1, [sp, 0x4] - ldr r1, =sBerryCrushTextColors2 - str r1, [sp, 0x8] - mov r1, r8 - str r1, [sp, 0xC] - str r4, [sp, 0x10] - movs r1, 0x2 - movs r3, 0x1 - bl AddTextPrinterParameterized4 - b _0802269C - .pool -_08022668: - lsls r4, r7, 5 - adds r4, 0x98 - adds r4, r6, r4 - movs r0, 0x2 - adds r1, r4, 0 - movs r2, 0 - bl GetStringWidth - lsrs r0, 1 - movs r2, 0x24 - subs r2, r0 - lsls r2, 24 - lsrs r2, 24 - ldrb r0, [r5] - mov r1, r8 - str r1, [sp] - str r1, [sp, 0x4] - ldr r1, =sBerryCrushTextColors3 - str r1, [sp, 0x8] - mov r1, r8 - str r1, [sp, 0xC] - str r4, [sp, 0x10] - movs r1, 0x2 - movs r3, 0x1 - bl AddTextPrinterParameterized4 -_0802269C: - ldr r1, =0x000001bb - adds r0, r6, r1 - adds r0, r7 - ldrb r0, [r0] - movs r1, 0x3 - bl CopyWindowToVram - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r6, 0x9] - cmp r7, r0 - bcc _08022616 -_080226B6: - movs r0, 0 - bl CopyBgTilemapBufferToVram - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022600 - - thumb_func_start sub_80226D0 -sub_80226D0: @ 80226D0 - push {r4-r6,lr} - sub sp, 0x8 - adds r6, r0, 0 - movs r5, 0 - ldr r0, =gUnknown_08DE3FD4 - ldr r4, =gDecompressionBuffer - adds r1, r4, 0 - bl LZ77UnCompWram - b _0802271A - .pool -_080226EC: - lsls r1, r5, 2 - movs r2, 0xA2 - lsls r2, 1 - adds r0, r6, r2 - adds r0, r1 - ldr r3, [r0] - ldrb r0, [r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r4, r1 - ldrb r2, [r3, 0x1] - ldrb r3, [r3, 0x2] - movs r0, 0xA - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x3 - bl CopyToBgTilemapBufferRect - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_0802271A: - ldrb r0, [r6, 0x9] - cmp r5, r0 - bcc _080226EC - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80226D0 - - thumb_func_start sub_8022730 -sub_8022730: @ 8022730 - push {r4-r7,lr} - adds r6, r0, 0 - movs r5, 0 - ldr r0, =0x0000ff98 - strh r0, [r6, 0x2A] - strh r5, [r6, 0x2C] - ldr r1, =gSpriteCoordOffsetX - strh r5, [r1] - ldr r1, =gSpriteCoordOffsetY - strh r0, [r1] - ldr r4, =gUnknown_082F41F4 -_08022746: - lsls r0, r5, 3 - adds r0, r4 - bl LoadCompressedSpriteSheet - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _08022746 - ldr r0, =gUnknown_082F421C - bl LoadSpritePalettes - ldr r0, =gUnknown_082F430C - movs r1, 0x78 - movs r2, 0x58 - movs r3, 0x5 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - movs r0, 0xAC - lsls r0, 1 - adds r3, r6, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r3] - ldrb r1, [r0, 0x5] - movs r2, 0xC - orrs r1, r2 - strb r1, [r0, 0x5] - ldr r1, [r3] - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1] - ldr r1, [r3] - adds r1, 0x2C - ldrb r0, [r1] - movs r2, 0x40 - orrs r0, r2 - strb r0, [r1] - movs r5, 0 - ldrb r1, [r6, 0x9] - cmp r5, r1 - bcs _08022822 - movs r7, 0x4 -_080227AA: - lsls r4, r5, 2 - movs r3, 0xA2 - lsls r3, 1 - adds r0, r6, r3 - adds r0, r4 - ldr r0, [r0] - ldrh r1, [r0, 0x4] - adds r1, 0x78 - lsls r1, 16 - asrs r1, 16 - ldrh r2, [r0, 0x6] - adds r2, 0x20 - lsls r2, 16 - asrs r2, 16 - ldr r0, =gUnknown_082F4324 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - movs r0, 0xAE - lsls r0, 1 - adds r3, r6, r0 - adds r3, r4 - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - str r1, [r3] - ldrb r0, [r1, 0x5] - movs r4, 0xD - negs r4, r4 - adds r2, r4, 0 - ands r0, r2 - orrs r0, r7 - strb r0, [r1, 0x5] - ldr r1, [r3] - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r7 - strb r0, [r1] - ldr r2, [r3] - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - ldr r2, [r3] - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r6, 0x9] - cmp r5, r0 - bcc _080227AA -_08022822: - movs r5, 0 - ldr r4, =gUnknown_082F41CC+6 - adds r7, r4, 0x1 -_08022828: - lsls r2, r5, 1 - adds r0, r2, r4 - movs r1, 0 - ldrsb r1, [r0, r1] - adds r1, 0x78 - adds r2, r7 - ldrb r2, [r2] - lsls r2, 24 - asrs r2, 24 - adds r2, 0x88 - ldr r0, =gUnknown_082F433C - movs r3, 0x6 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r5, 2 - movs r1, 0xC2 - lsls r1, 1 - adds r3, r6, r1 - adds r3, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r3] - ldrb r1, [r0, 0x5] - movs r2, 0xC - orrs r1, r2 - strb r1, [r0, 0x5] - ldr r2, [r3] - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r2, [r3] - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - ldr r0, [r3] - strh r5, [r0, 0x2E] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xA - bls _08022828 - movs r5, 0 -_0802288E: - lsls r1, r5, 1 - adds r1, r5 - lsls r1, 19 - movs r3, 0xB0 - lsls r3, 16 - adds r1, r3 - asrs r1, 16 - ldr r0, =gUnknown_082F4354 - movs r2, 0x8 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r5, 2 - movs r4, 0xD8 - lsls r4, 1 - adds r3, r6, r4 - adds r3, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r3] - ldrb r1, [r0, 0x5] - movs r4, 0xD - negs r4, r4 - adds r2, r4, 0 - ands r1, r2 - strb r1, [r0, 0x5] - ldr r2, [r3] - adds r2, 0x3E - ldrb r0, [r2] - adds r4, 0x8 - adds r1, r4, 0 - ands r0, r1 - strb r0, [r2] - ldr r2, [r3] - adds r2, 0x2C - ldrb r0, [r2] - movs r3, 0x41 - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - strb r0, [r2] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x1 - bls _0802288E - ldr r4, =gUnknown_082F4384 - movs r0, 0 - movs r1, 0 - adds r2, r4, 0 - bl sub_8034D14 - adds r2, r4, 0 - adds r2, 0x10 - movs r0, 0x1 - movs r1, 0 - bl sub_8034D14 - adds r4, 0x20 - movs r0, 0x2 - movs r1, 0 - adds r2, r4, 0 - bl sub_8034D14 - ldrh r0, [r6, 0x12] - cmp r0, 0x1 - bne _08022928 - movs r4, 0x9C - lsls r4, 1 - adds r0, r6, r4 - bl sub_8022554 -_08022928: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022730 - - thumb_func_start sub_8022960 -sub_8022960: @ 8022960 - push {r4-r6,lr} - adds r5, r0, 0 - movs r4, 0 - movs r0, 0x4 - bl FreeSpriteTilesByTag - movs r0, 0x3 - bl FreeSpriteTilesByTag - movs r0, 0x2 - bl FreeSpriteTilesByTag - movs r0, 0x1 - bl FreeSpriteTilesByTag - movs r0, 0x4 - bl FreeSpritePaletteByTag - movs r0, 0x2 - bl FreeSpritePaletteByTag - movs r0, 0x1 - bl FreeSpritePaletteByTag - movs r0, 0xD8 - lsls r0, 1 - adds r6, r5, r0 -_08022996: - lsls r0, r4, 2 - adds r0, r6, r0 - ldr r0, [r0] - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bls _08022996 - movs r0, 0x2 - bl sub_80353DC - movs r0, 0x1 - bl sub_80353DC - movs r0, 0 - bl sub_80353DC - movs r4, 0 - movs r1, 0xC2 - lsls r1, 1 - adds r6, r5, r1 -_080229C4: - lsls r0, r4, 2 - adds r0, r6, r0 - ldr r0, [r0] - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xA - bls _080229C4 - movs r4, 0 - ldrb r2, [r5, 0x9] - cmp r4, r2 - bcs _080229FC -_080229E0: - lsls r1, r4, 2 - movs r2, 0xAE - lsls r2, 1 - adds r0, r5, r2 - adds r0, r1 - ldr r0, [r0] - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - ldrb r0, [r5, 0x9] - cmp r4, r0 - bcc _080229E0 -_080229FC: - movs r1, 0xAC - lsls r1, 1 - adds r0, r5, r1 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08022A18 - adds r0, r2, 0 - bl DestroySprite -_08022A18: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8022960 - - thumb_func_start sub_8022A20 -sub_8022A20: @ 8022A20 - push {lr} - adds r3, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08022A46 - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - subs r2, 0x12 - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] -_08022A46: - pop {r0} - bx r0 - thumb_func_end sub_8022A20 - - thumb_func_start sub_8022A4C -sub_8022A4C: @ 8022A4C - push {r4,r5,lr} - adds r3, r0, 0 - movs r1, 0 - ldr r5, =SpriteCallbackDummy - adds r2, r3, 0 - adds r2, 0x2E - movs r4, 0 -_08022A5A: - lsls r0, r1, 1 - adds r0, r2, r0 - strh r4, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x7 - bls _08022A5A - movs r0, 0 - strh r0, [r3, 0x24] - strh r0, [r3, 0x26] - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - subs r2, 0x12 - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - str r5, [r3, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022A4C - - thumb_func_start sub_8022A94 -sub_8022A94: @ 8022A94 - push {r4-r6,lr} - adds r5, r0, 0 - adds r4, r5, 0 - adds r4, 0x2E - ldrh r0, [r4, 0x4] - ldrh r1, [r4, 0x2] - adds r0, r1 - strh r0, [r4, 0x2] - lsls r0, 16 - asrs r0, 24 - ldrh r2, [r5, 0x26] - adds r0, r2 - strh r0, [r5, 0x26] - movs r1, 0xE - ldrsh r0, [r4, r1] - movs r6, 0x80 - lsls r6, 8 - ands r0, r6 - cmp r0, 0 - beq _08022AFA - ldrh r0, [r4, 0x6] - ldrh r2, [r5, 0x2E] - adds r0, r2 - strh r0, [r5, 0x2E] - ldrh r0, [r4, 0xA] - ldrh r1, [r4, 0x8] - adds r0, r1 - strh r0, [r4, 0x8] - lsls r0, 16 - asrs r0, 23 - movs r2, 0xC - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r5, 0x24] - movs r1, 0xE - ldrsh r0, [r4, r1] - ands r0, r6 - cmp r0, 0 - beq _08022AFA - ldrh r0, [r4, 0x8] - lsls r0, 16 - asrs r0, 23 - cmp r0, 0x7E - ble _08022AFA - movs r0, 0 - strh r0, [r5, 0x24] - ldrh r1, [r4, 0xE] - ldr r0, =0x00007fff - ands r0, r1 - strh r0, [r4, 0xE] -_08022AFA: - ldrh r0, [r4] - lsls r0, 16 - asrs r0, 23 - strh r0, [r5, 0x20] - movs r2, 0x22 - ldrsh r1, [r5, r2] - movs r2, 0x26 - ldrsh r0, [r5, r2] - adds r1, r0 - ldrh r2, [r4, 0xE] - ldr r0, =0x00007fff - ands r0, r2 - cmp r1, r0 - ble _08022B1A - ldr r0, =sub_8022A4C - str r0, [r5, 0x1C] -_08022B1A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022A94 - - thumb_func_start sub_8022B28 -sub_8022B28: @ 8022B28 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r7, r6, 0 - adds r7, 0x2E - movs r0, 0 - mov r8, r0 - movs r2, 0xA0 - lsls r2, 2 - strh r2, [r7, 0x2] - movs r0, 0x20 - strh r0, [r7, 0x4] - movs r1, 0xA8 - strh r1, [r7, 0xE] - movs r0, 0x24 - ldrsh r4, [r6, r0] - lsls r4, 23 - lsrs r4, 16 - ldrh r0, [r6, 0x22] - subs r1, r0 - lsls r1, 23 - asrs r1, 16 - adds r2, 0x20 - asrs r2, 1 - movs r0, 0x7 - bl sub_81515D4 - adds r5, r0, 0 - ldrh r0, [r6, 0x20] - lsls r0, 7 - strh r0, [r6, 0x2E] - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - movs r0, 0x7 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_81515D4 - strh r0, [r7, 0x6] - movs r0, 0x7 - adds r1, r5, 0 - movs r2, 0x55 - bl sub_8151550 - adds r2, r0, 0 - mov r1, r8 - strh r1, [r7, 0x8] - movs r1, 0xFE - lsls r1, 6 - lsls r2, 16 - asrs r2, 16 - movs r0, 0x7 - bl sub_81515D4 - strh r0, [r7, 0xA] - movs r2, 0x24 - ldrsh r0, [r6, r2] - cmp r0, 0 - bge _08022BA6 - adds r0, 0x3 -_08022BA6: - asrs r0, 2 - strh r0, [r7, 0xC] - ldrh r0, [r7, 0xE] - ldr r2, =0xffff8000 - adds r1, r2, 0 - orrs r0, r1 - strh r0, [r7, 0xE] - mov r0, r8 - strh r0, [r6, 0x26] - strh r0, [r6, 0x24] - ldr r0, =sub_8022A94 - str r0, [r6, 0x1C] - adds r2, r6, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - adds r2, 0x12 - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022B28 - - thumb_func_start sub_8022BEC -sub_8022BEC: @ 8022BEC - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r2, 0 - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - mov r8, r4 - bl sub_8020C00 - adds r6, r0, 0 - cmp r5, 0x19 - bls _08022C0A - movs r5, 0 -_08022C0A: - cmp r4, 0 - beq _08022C14 - cmp r4, 0x1 - beq _08022C40 - b _08022C4A -_08022C14: - cmp r5, 0 - beq _08022C28 - ldr r0, =gUnknown_082F43CC - lsls r1, r5, 2 - adds r1, r0 - ldr r2, [r1] - adds r0, r6, 0 - adds r1, r7, 0 - bl _call_via_r2 -_08022C28: - ldrb r0, [r6, 0xE] - cmp r0, 0x19 - bls _08022C32 - mov r0, r8 - strb r0, [r6, 0xE] -_08022C32: - ldr r0, =gUnknown_082F43CC - ldrb r1, [r6, 0xE] - lsls r1, 2 - b _08022C44 - .pool -_08022C40: - ldr r0, =gUnknown_082F43CC - lsls r1, r5, 2 -_08022C44: - adds r1, r0 - ldr r0, [r1] - str r0, [r6, 0x4] -_08022C4A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8022BEC - - thumb_func_start sub_8022C58 -sub_8022C58: @ 8022C58 - push {r4-r6,lr} - sub sp, 0x4 - adds r6, r0, 0 - ldrb r2, [r1] - ldrb r3, [r1, 0x1] - lsls r3, 8 - orrs r2, r3 - ldrb r3, [r1, 0x2] - lsls r3, 16 - orrs r2, r3 - ldrb r3, [r1, 0x3] - lsls r3, 24 - adds r0, r2, 0 - orrs r0, r3 - ldrb r2, [r1, 0x9] - strb r2, [r1] - ldrb r4, [r1, 0x8] - lsls r4, 8 - ldrb r2, [r1, 0x7] - orrs r4, r2 - ldr r5, =gPaletteFade - ldrb r3, [r5, 0x8] - movs r2, 0x7F - ands r2, r3 - strb r2, [r5, 0x8] - movs r5, 0x4 - ldrsb r5, [r1, r5] - ldrb r2, [r1, 0x5] - ldrb r3, [r1, 0x6] - str r4, [sp] - adds r1, r5, 0 - bl BeginNormalPaletteFade - bl UpdatePaletteFade - movs r0, 0x2 - strb r0, [r6, 0xE] - movs r0, 0 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8022C58 - - thumb_func_start sub_8022CB0 -sub_8022CB0: @ 8022CB0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0xC] - cmp r0, 0x1 - beq _08022CE4 - cmp r0, 0x1 - bgt _08022CC6 - cmp r0, 0 - beq _08022CD0 - b _08022D06 -_08022CC6: - cmp r0, 0x2 - beq _08022CEA - cmp r0, 0x3 - beq _08022CF6 - b _08022D06 -_08022CD0: - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _08022D0C - ldrb r0, [r5] - cmp r0, 0 - bne _08022D06 - movs r0, 0x3 - b _08022D0A -_08022CE4: - bl sub_8010434 - b _08022D06 -_08022CEA: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - bne _08022D06 - b _08022D0C -_08022CF6: - ldrb r0, [r4, 0xF] - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r0, 0 - strb r0, [r4, 0xC] - b _08022D0E -_08022D06: - ldrb r0, [r4, 0xC] - adds r0, 0x1 -_08022D0A: - strb r0, [r4, 0xC] -_08022D0C: - movs r0, 0 -_08022D0E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8022CB0 - - thumb_func_start sub_8022D14 -sub_8022D14: @ 8022D14 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - adds r7, r0, 0 - adds r5, r1, 0 - ldrb r4, [r5, 0x3] - lsls r4, 8 - ldrb r0, [r5, 0x2] - orrs r4, r0 - ldrb r6, [r7, 0xC] - cmp r6, 0x1 - beq _08022DC0 - cmp r6, 0x1 - bgt _08022D38 - cmp r6, 0 - beq _08022D42 - b _08022E08 -_08022D38: - cmp r6, 0x2 - beq _08022DD8 - cmp r6, 0x3 - beq _08022DE8 - b _08022E08 -_08022D42: - movs r0, 0 - movs r1, 0 - bl DrawDialogueFrame - ldrb r1, [r5, 0x1] - movs r0, 0x2 - mov r8, r0 - ands r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08022D90 - ldr r4, =gStringVar4 - ldr r1, =gUnknown_082F32A4 - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl StringExpandPlaceholders - ldrb r3, [r7, 0xB] - str r6, [sp] - mov r0, r8 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParameterized2 - b _08022DB2 - .pool -_08022D90: - ldr r1, =gUnknown_082F32A4 - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - ldrb r3, [r7, 0xB] - str r4, [sp] - mov r0, r8 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - bl AddTextPrinterParameterized2 -_08022DB2: - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - b _08022E08 - .pool -_08022DC0: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _08022E0E - cmp r4, 0 - bne _08022E08 - ldrb r0, [r7, 0xC] - adds r0, 0x1 - strb r0, [r7, 0xC] - b _08022E08 -_08022DD8: - ldr r0, =gMain - ldrh r0, [r0, 0x2E] - ands r4, r0 - cmp r4, 0 - bne _08022E08 - b _08022E0E - .pool -_08022DE8: - ldrb r1, [r5, 0x1] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08022DFA - movs r0, 0 - movs r1, 0x1 - bl ClearDialogWindowAndFrame -_08022DFA: - ldrb r0, [r7, 0xE] - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - ldrb r0, [r5, 0x4] - b _08022E0C -_08022E08: - ldrb r0, [r7, 0xC] - adds r0, 0x1 -_08022E0C: - strb r0, [r7, 0xC] -_08022E0E: - movs r0, 0 - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8022D14 - - thumb_func_start sub_8022E1C -sub_8022E1C: @ 8022E1C - push {r4,lr} - adds r4, r0, 0 - bl sub_802104C - cmp r0, 0 - beq _08022E34 - ldrb r0, [r4, 0xE] - adds r2, r4, 0 - adds r2, 0x36 - movs r1, 0 - bl sub_8022BEC -_08022E34: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8022E1C - - thumb_func_start sub_8022E3C -sub_8022E3C: @ 8022E3C - push {r4,lr} - adds r4, r0, 0 - bl sub_802130C - cmp r0, 0 - beq _08022E54 - ldrb r0, [r4, 0xE] - adds r2, r4, 0 - adds r2, 0x36 - movs r1, 0 - bl sub_8022BEC -_08022E54: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8022E3C - - thumb_func_start sub_8022E5C -sub_8022E5C: @ 8022E5C - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0xC] - cmp r0, 0 - beq _08022E6C - cmp r0, 0x1 - beq _08022E72 - b _08022E9C -_08022E6C: - bl sub_8010434 - b _08022E9C -_08022E72: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08022EA2 - ldr r0, =0x000001e5 - bl PlayNewMapMusic - movs r0, 0x7 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r1, 0 - movs r0, 0x3 - strh r0, [r4, 0x12] - strb r1, [r4, 0xC] - b _08022EA2 - .pool -_08022E9C: - ldrb r0, [r4, 0xC] - adds r0, 0x1 - strb r0, [r4, 0xC] -_08022EA2: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8022E5C - - thumb_func_start sub_8022EAC -sub_8022EAC: @ 8022EAC - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0xC] - cmp r0, 0 - beq _08022EC2 - cmp r0, 0x1 - beq _08022EE8 - adds r0, 0x1 - b _08022EF8 -_08022EC2: - adds r0, r4, 0 - bl sub_8024578 - movs r0, 0x1 - str r0, [sp] - adds r0, r5, 0 - movs r1, 0 - movs r2, 0x1 - movs r3, 0 - bl sub_8024644 - movs r0, 0x7 - strb r0, [r4, 0xE] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - b _08022EFA -_08022EE8: - movs r0, 0x8 - strb r0, [r4, 0xE] - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r0, 0x2 -_08022EF8: - strb r0, [r4, 0xC] -_08022EFA: - movs r0, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8022EAC - - thumb_func_start sub_8022F04 -sub_8022F04: @ 8022F04 - push {lr} - movs r1, 0 - str r1, [r0, 0x4] - ldr r0, =sub_8020E1C - bl SetMainCallback2 - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8022F04 - thumb_func_start sub_8022F1C sub_8022F1C: @ 8022F1C push {r4-r7,lr} diff --git a/src/berry_crush.c b/src/berry_crush.c index 5303da11a7..11028b0afc 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -1,26 +1,33 @@ #include "global.h" -#include "malloc.h" +#include "berry.h" #include "berry_powder.h" #include "bg.h" +#include "decompress.h" +#include "dynamic_placeholder_text_util.h" #include "event_data.h" #include "gpu_regs.h" #include "graphics.h" +#include "international_string_util.h" #include "item_icon.h" #include "item_menu.h" #include "link.h" #include "link_rfu.h" #include "main.h" +#include "malloc.h" #include "math_util.h" #include "menu.h" #include "overworld.h" #include "palette.h" #include "rom_8034C54.h" #include "scanline_effect.h" +#include "script.h" #include "sound.h" #include "sprite.h" #include "string_util.h" +#include "strings.h" #include "task.h" #include "text.h" +#include "text_window.h" #include "trig.h" #include "window.h" #include "constants/items.h" @@ -30,8 +37,9 @@ struct BerryCrushGame_Player { u16 unk0; - u8 filler2[0x12]; - u8 unk14[0xC]; + u8 filler2[2]; + u8 unk4[16]; + u8 unk14[12]; }; struct BerryCrushGame_PlayersSeparate @@ -48,7 +56,12 @@ typedef union BerryCrushGame_Players struct BerryCrushGame_138_C { - u8 filler0[0x8]; + u8 unk0; + u8 unk1; + u8 unk2; + u8 filler3; + u16 unk4; + u16 unk6; s16 unk8; u16 unkA; }; @@ -56,16 +69,19 @@ struct BerryCrushGame_138_C struct BerryCrushGame_138 { u8 filler0[0x4]; - u16 unk4; - u16 unk6; - u16 unk8; - struct BerryCrushGame_138_C *unkC[5]; - u8 filler1C[0x4]; + s16 unk4; + s16 unk6; + s16 unk8; + const struct BerryCrushGame_138_C *unkC[5]; + struct Sprite *unk20; struct Sprite *unk24[5]; struct Sprite *unk38[5]; - struct Sprite *unk4C[5]; - struct Sprite *unk60[5]; - struct Sprite *unk74[5]; + struct Sprite *unk4C[11]; + struct Sprite *unk78[2]; + u8 unk80; + u8 filler81; + u8 unk82; + u8 unk83[5]; }; struct BerryCrushGame_4E @@ -83,10 +99,22 @@ struct __attribute__((packed)) BerryCrushGame_40 struct BerryCrushGame_4E unkE; }; +struct BerryCrushGame_68 +{ + int unk00; + u16 unk04; + u8 filler06[2]; + u16 unk08; + u16 unk0A; + u16 unk0C[8]; // TODO: Resolve the type of the field. + BerryCrushGame_Players unk1C; + u8 fillerBC[20]; +}; + struct BerryCrushGame { MainCallback unk0; - void (* unk4)(struct BerryCrushGame *, u8 *); + u32 (* unk4)(struct BerryCrushGame *, u8 *); u8 unk8; u8 unk9; u8 unkA; @@ -113,13 +141,7 @@ struct BerryCrushGame u8 unk36[0xA]; struct BerryCrushGame_40 unk40; u8 filler60[0x8]; - int unk68; - u16 unk6C; - u8 filler6E[0x4]; - u16 unk72; - u8 filler74[0x10]; - BerryCrushGame_Players unk84; - u8 filler124[0x14]; + struct BerryCrushGame_68 unk68; struct BerryCrushGame_138 unk138; u8 unk1C0[0x1000]; u8 unk11C0[0x1000]; @@ -141,6 +163,9 @@ void sub_8022730(struct BerryCrushGame *); void sub_8022960(struct BerryCrushGame *); void sub_8022524(struct BerryCrushGame_138 *, u16); void sub_8022B28(struct Sprite *); +void sub_8022554(struct BerryCrushGame_138 *r0); +void sub_8024578(struct BerryCrushGame *); +void sub_8024644(u8 *, u32, u32, u32, u32); static EWRAM_DATA struct BerryCrushGame *gUnknown_02022C90 = NULL; @@ -154,6 +179,46 @@ extern const s8 gUnknown_082F41CC[][2]; extern const s8 gUnknown_082F41D2[][2]; extern const u32 gUnknown_082F334C[]; extern const u8 sBerryCrushTextColors1[][3]; +extern const u8 *gUnknown_082F43B4[]; +extern const u8 gText_Var1Berry[]; +extern const u8 gText_XDotY[]; +extern const u8 gText_1DotBlueF700[]; +extern const u8 gText_1DotF700[]; +extern const u8 gText_TimeColon[]; +extern const u8 gText_SpaceSec[]; +extern const u8 gText_XDotY2[]; +extern const u8 gText_SpaceMin[]; +extern const u8 gText_StrVar1[]; +extern const u8 gText_PressingSpeed[]; +extern const u8 gText_TimesPerSec[]; +extern const u8 gText_XDotY3[]; +extern const u8 sBerryCrushTextColors4[]; +extern const u8 gText_Silkiness[]; +extern const u8 gText_Var1Percent[]; +extern const struct WindowTemplate gUnknown_082F32CC[]; +extern const u8 gUnknown_082F3344[][4]; +extern const u8 gText_PressesRankings[]; +extern const u8 gText_CrushingResults[]; +extern const struct WindowTemplate gUnknown_082F32EC; +extern const u8 gText_BerryCrush2[]; +extern const u8 sBerryCrushTextColorTable[][3]; +extern const u8 gText_PressingSpeedRankings[]; +extern const u8 gText_Var1Players[]; +extern const struct WindowTemplate gUnknown_082F32F4[]; +extern const u8 gUnknown_082F417C[][5]; +extern const struct BerryCrushGame_138_C gUnknown_082F4190[]; +extern const u8 sBerryCrushTextColors2[][3]; +extern const u8 sBerryCrushTextColors3[][3]; +extern const u32 gUnknown_08DE3FD4[]; +extern const struct CompressedSpriteSheet gUnknown_082F41F4[]; +extern const struct SpritePalette gUnknown_082F421C; +extern const struct SpriteTemplate gUnknown_082F430C; +extern const struct SpriteTemplate gUnknown_082F4324; +extern const struct SpriteTemplate gUnknown_082F433C; +extern const struct SpriteTemplate gUnknown_082F4354; +extern const struct UnkStruct3 gUnknown_082F4384[]; +extern u32 (*const gUnknown_082F43CC[])(struct BerryCrushGame *, u8 *); +extern const u8 *const gUnknown_082F32A4[]; struct BerryCrushGame *sub_8020C00(void) { @@ -237,7 +302,7 @@ static void sub_8020D8C(void) else RemoveBagItem(gSpecialVar_ItemId, 1); - gUnknown_02022C90->unk84.separate.others[gUnknown_02022C90->unk8].unk0 = gSpecialVar_ItemId - FIRST_BERRY_INDEX; + gUnknown_02022C90->unk68.unk1C.separate.others[gUnknown_02022C90->unk8].unk0 = gSpecialVar_ItemId - FIRST_BERRY_INDEX; gUnknown_02022C90->unkE = 1; gUnknown_02022C90->unkF = 9; sub_8024604(gUnknown_02022C90->unk36, 0, -1, 0, 16, 0, 0); @@ -266,10 +331,10 @@ void sub_8020E58(void) { u32 var0, var1; - var0 = gUnknown_02022C90->unk6C; + var0 = gUnknown_02022C90->unk68.unk04; var0 <<= 8; var0 = sub_81515FC(var0, 60 << 8); - var1 = gUnknown_02022C90->unk72; + var1 = gUnknown_02022C90->unk68.unk0A; var1 <<= 8; var1 = sub_81515FC(var1, var0) & 0xFFFF; gUnknown_02022C90->unk16 = var1; @@ -305,7 +370,7 @@ void sub_8020E58(void) break; } - gUnknown_02022C90->unk1C = gUnknown_02022C90->unk68; + gUnknown_02022C90->unk1C = gUnknown_02022C90->unk68.unk00; if (GiveBerryPowder(gUnknown_02022C90->unk1C)) return; @@ -335,18 +400,23 @@ static void sub_8020FA0(u8 taskId) sub_8021450(gUnknown_02022C90); } -#ifdef NONMATCHING +#define PLAYER_UNK14(game, i) \ + ((u8 *)(game) \ + + offsetof(struct BerryCrushGame, unk68) \ + + offsetof(struct BerryCrushGame_68, unk1C) \ + + offsetof(struct BerryCrushGame_Player, unk14) \ + + sizeof(struct BerryCrushGame_Player) * (i)) + void sub_8020FC4(struct BerryCrushGame *arg0) { u8 i; for (i = 0; i < arg0->unk9; i++) - StringCopy(arg0->unk84.players[i].unk14, gLinkPlayers[i].name); - + StringCopy(PLAYER_UNK14(arg0, i), gLinkPlayers[i].name); for (; i < 5; i++) { - memset(arg0->unk84.players[i].unk14, 1, PLAYER_NAME_LENGTH); - arg0->unk84.players[i].unk14[PLAYER_NAME_LENGTH] = EOS; + memset(PLAYER_UNK14(arg0, i), 1, PLAYER_NAME_LENGTH); + arg0->unk68.unk1C.players[i].unk14[PLAYER_NAME_LENGTH] = EOS; } switch (gSaveBlock2Ptr->optionsTextSpeed) @@ -362,85 +432,6 @@ void sub_8020FC4(struct BerryCrushGame *arg0) break; } } -#else -NAKED -void sub_8020FC4(struct BerryCrushGame *arg0) -{ - asm_unified("\n\ - push {r4-r6,lr}\n\ - adds r6, r0, 0\n\ - movs r5, 0\n\ - b _08020FE6\n\ -LOOP_1:\n\ - lsls r0, r5, 5\n\ - adds r0, 0x98\n\ - adds r0, r6, r0\n\ - lsls r1, r5, 3\n\ - subs r1, r5\n\ - lsls r1, 2\n\ - ldr r2, =gLinkPlayers + 8\n\ - adds r1, r2\n\ - bl StringCopy\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ -_08020FE6:\n\ - ldrb r0, [r6, 0x9]\n\ - cmp r5, r0\n\ - bcc LOOP_1\n\ - cmp r5, 0x4\n\ - bhi _08021012\n\ -_08020FF0:\n\ - lsls r4, r5, 5\n\ - adds r0, r4, 0\n\ - adds r0, 0x98\n\ - adds r0, r6, r0\n\ - movs r1, 0x1\n\ - movs r2, 0x7\n\ - bl memset\n\ - adds r4, r6, r4\n\ - adds r4, 0x9F\n\ - movs r0, 0xFF\n\ - strb r0, [r4]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - cmp r5, 0x4\n\ - bls _08020FF0\n\ -_08021012:\n\ - ldr r0, =gSaveBlock2Ptr\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x14]\n\ - lsls r0, 29\n\ - lsrs r0, 29\n\ - cmp r0, 0x1\n\ - beq _0802103E\n\ - cmp r0, 0x1\n\ - bgt _08021034\n\ - cmp r0, 0\n\ - beq _0802103A\n\ - b _08021046\n\ - .pool\n\ -_08021034:\n\ - cmp r0, 0x2\n\ - beq _08021042\n\ - b _08021046\n\ -_0802103A:\n\ - movs r0, 0x8\n\ - b _08021044\n\ -_0802103E:\n\ - movs r0, 0x4\n\ - b _08021044\n\ -_08021042:\n\ - movs r0, 0x1\n\ -_08021044:\n\ - strb r0, [r6, 0xB]\n\ -_08021046:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0"); -} -#endif // NONMATCHING int sub_802104C(void) { @@ -636,7 +627,7 @@ void sub_80214A8(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1) &gUnknown_082F436C, gUnknown_082F41E8[i], gUnknown_082F41E8[i], - arg0->unk84.separate.others[i].unk0 + 133); + arg0->unk68.unk1C.separate.others[i].unk0 + 133); arg1->unk38[i] = &gSprites[spriteId]; arg1->unk38[i]->oam.priority = 3; arg1->unk38[i]->affineAnimPaused = 1; @@ -823,3 +814,1459 @@ void sub_80219C8(u8 windowId, u8 left, u8 colorId, const u8 *string) left = (left * 4) - (GetStringWidth(2, string, -1) / 2u); AddTextPrinterParameterized3(windowId, 2, left, 0, sBerryCrushTextColors1[colorId], 0, string); } + +#ifdef NONMATCHING +void sub_8021A28(struct BerryCrushGame *sp0C, u8 sp10, u8 sp14, u8 r3) +{ + s32 r6; + u8 i, j; + u8 sp18 = 0; + u8 sp1C = 0; + struct BerryCrushGame_68 *sp20 = &sp0C->unk68; + u32 xOffset; + u32 r8, r9, r4, r7, r3_; + u8 r10, r2; + + r3 -= 16; + if (sp10 == 2) + r3 -= 42; + r6 = r3 - 14 * sp0C->unk9; + if (r6 > 0) + r6 = r6 / 2 + 16; + else + r6 = 16; + i = 0; + while (i < sp0C->unk9) + { + DynamicPlaceholderTextUtil_Reset(); + switch (sp10) + { + default: // how can you write this twice?????? + r4 = sp14 - 4; + r10 = r6; + r9 = sp1C + 0xA2; + r8 = sp18; + r6 += 14; // should be tail merged, but not + ++i; + break; + case 0: + sp18 = sp20->unk1C.separate.player.unk4[i]; + if (i != 0 && sp20->unk0C[i] != sp20->unk0C[i - 1]) + sp1C = i; + ConvertIntToDecimalStringN( + gStringVar4, + sp20->unk0C[5 * sp10 + i], // ~ line 145. 2 * i was stored in temp variable + 1, + 4 + ); + StringAppend(gStringVar4, gUnknown_082F43B4[sp10]); + r4 = sp14 - 4; + r10 = r6; // shift right should happen after the switch + r9 = sp1C + 0xA2; + r8 = sp18; + r6 += 14; + ++i; + break; + case 1: + sp18 = sp20->unk1C.separate.player.unk4[i + 8]; + if (i != 0 && sp20->unk0C[i + 5] != sp20->unk0C[i + 4]) // damn, access to unk0C is weird again + sp1C = i; + ConvertIntToDecimalStringN( + gStringVar1, + sp20->unk0C[5 * sp10 + i] >> 4, + 1, + 3 + ); + j = 0; + r3_ = 15 & (u8)sp20->unk0C[5 * sp10 + i]; + r4 = sp14 - 4; + r10 = r6; + r9 = sp1C + 0xA2; + r8 = sp18; + r6 += 14; + ++i; + for (; j < 4; ++j) + if (((r3_ >> (3 - j)) & 1) != 0) // why does it load constant 1 into r10? + r7 += gUnknown_082F334C[j]; + ConvertIntToDecimalStringN( + gStringVar2, + (u8)(r7 / 1000000), + 2, + 2 + ); + StringExpandPlaceholders(gStringVar4, gText_XDotY); + break; + case 2: + sp18 = i; + sp1C = i; + r2 = sp0C->unk68.unk1C.separate.others[i].unk0; + if (r2 > 43) + r2 = 0; + StringCopy(gStringVar1,gBerries[r2].name); + StringExpandPlaceholders(gStringVar4, gText_Var1Berry); + r4 = sp14 - 4; + r10 = r6; + r9 = sp1C + 0xA2; + r8 = i; + r6 += 14; + ++i; + break; + } + xOffset = GetStringRightAlignXOffset(2, gStringVar4, r4); + AddTextPrinterParameterized3( + sp0C->unk138.unk82, + 2, + xOffset, + r10, + sBerryCrushTextColors1[0], + 0, + gStringVar4 + ); + if (sp18 == sp0C->unk8) + StringCopy(gStringVar3, gText_1DotBlueF700); + else + StringCopy(gStringVar3, gText_1DotF700); + gStringVar3[0] = r9; + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, PLAYER_UNK14(sp0C, r8)); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gStringVar3); + AddTextPrinterParameterized3( + sp0C->unk138.unk82, + 2, + 4, + r10, + sBerryCrushTextColors1[0], + 0, + gStringVar4 + ); + } +} +#else +NAKED +void sub_8021A28(struct BerryCrushGame *sp0C, u8 sp10, u8 sp14, u8 r3) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x2C\n\ + str r0, [sp, 0xC]\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + str r1, [sp, 0x10]\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + str r2, [sp, 0x14]\n\ + lsls r3, 24\n\ + movs r0, 0\n\ + str r0, [sp, 0x18]\n\ + movs r1, 0\n\ + str r1, [sp, 0x1C]\n\ + ldr r2, [sp, 0xC]\n\ + adds r2, 0x68\n\ + str r2, [sp, 0x20]\n\ + movs r4, 0xF0\n\ + lsls r4, 24\n\ + adds r3, r4\n\ + lsrs r3, 24\n\ + ldr r0, [sp, 0x10]\n\ + cmp r0, 0x2\n\ + bne _08021A68\n\ + adds r0, r3, 0\n\ + subs r0, 0x2A\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + _08021A68:\n\ + ldr r2, [sp, 0xC]\n\ + ldrb r1, [r2, 0x9]\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + lsls r0, 1\n\ + subs r6, r3, r0\n\ + cmp r6, 0\n\ + ble _08021A84\n\ + lsrs r0, r6, 31\n\ + adds r0, r6, r0\n\ + asrs r0, 1\n\ + adds r6, r0, 0\n\ + adds r6, 0x10\n\ + b _08021A86\n\ + _08021A84:\n\ + movs r6, 0x10\n\ + _08021A86:\n\ + movs r5, 0\n\ + ldr r3, [sp, 0xC]\n\ + ldrb r3, [r3, 0x9]\n\ + cmp r5, r3\n\ + bcc _08021A92\n\ + b _08021D14\n\ + _08021A92:\n\ + ldr r4, [sp, 0x10]\n\ + lsls r4, 2\n\ + str r4, [sp, 0x24]\n\ + _08021A98:\n\ + bl DynamicPlaceholderTextUtil_Reset\n\ + ldr r0, [sp, 0x10]\n\ + cmp r0, 0x1\n\ + beq _08021B48\n\ + cmp r0, 0x1\n\ + bgt _08021AC0\n\ + cmp r0, 0\n\ + beq _08021ADE\n\ + ldr r4, [sp, 0x14]\n\ + subs r4, 0x4\n\ + lsls r1, r6, 24\n\ + mov r10, r1\n\ + ldr r2, [sp, 0x1C]\n\ + adds r2, 0xA2\n\ + mov r9, r2\n\ + ldr r3, [sp, 0x18]\n\ + lsls r3, 5\n\ + mov r8, r3\n\ + b _08021C5A\n\ + _08021AC0:\n\ + ldr r4, [sp, 0x10]\n\ + cmp r4, 0x2\n\ + bne _08021AC8\n\ + b _08021C1C\n\ + _08021AC8:\n\ + ldr r4, [sp, 0x14]\n\ + subs r4, 0x4\n\ + lsls r0, r6, 24\n\ + mov r10, r0\n\ + ldr r1, [sp, 0x1C]\n\ + adds r1, 0xA2\n\ + mov r9, r1\n\ + ldr r2, [sp, 0x18]\n\ + lsls r2, 5\n\ + mov r8, r2\n\ + b _08021C5A\n\ + _08021ADE:\n\ + ldr r0, [sp, 0x20]\n\ + adds r0, 0x20\n\ + adds r0, r5\n\ + ldrb r0, [r0]\n\ + str r0, [sp, 0x18]\n\ + lsls r3, r5, 1\n\ + ldr r2, [sp, 0x20]\n\ + adds r2, 0xC\n\ + cmp r5, 0\n\ + beq _08021B04\n\ + adds r0, r2, r3\n\ + subs r1, r5, 0x1\n\ + lsls r1, 1\n\ + adds r1, r2, r1\n\ + ldrh r0, [r0]\n\ + ldrh r1, [r1]\n\ + cmp r0, r1\n\ + beq _08021B04\n\ + str r5, [sp, 0x1C]\n\ + _08021B04:\n\ + ldr r4, [sp, 0x24]\n\ + ldr r1, [sp, 0x10]\n\ + adds r0, r4, r1\n\ + lsls r0, 1\n\ + adds r0, r3, r0\n\ + adds r0, r2, r0\n\ + ldrh r1, [r0]\n\ + ldr r0, =gStringVar4\n\ + movs r2, 0x1\n\ + movs r3, 0x4\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gUnknown_082F43B4\n\ + adds r0, r4, r0\n\ + ldr r1, [r0]\n\ + ldr r0, =gStringVar4\n\ + bl StringAppend\n\ + ldr r4, [sp, 0x14]\n\ + subs r4, 0x4\n\ + lsls r2, r6, 24\n\ + mov r10, r2\n\ + ldr r3, [sp, 0x1C]\n\ + adds r3, 0xA2\n\ + mov r9, r3\n\ + ldr r0, [sp, 0x18]\n\ + lsls r0, 5\n\ + mov r8, r0\n\ + b _08021C5A\n\ + .pool\n\ + _08021B48:\n\ + ldr r1, [sp, 0x20]\n\ + adds r0, r1, r5\n\ + adds r0, 0x28\n\ + ldrb r0, [r0]\n\ + str r0, [sp, 0x18]\n\ + lsls r3, r5, 1\n\ + adds r2, r1, 0\n\ + adds r2, 0xC\n\ + cmp r5, 0\n\ + beq _08021B72\n\ + adds r0, r3, 0\n\ + adds r0, 0xA\n\ + adds r0, r2, r0\n\ + adds r1, r3, 0\n\ + adds r1, 0x8\n\ + adds r1, r2, r1\n\ + ldrh r0, [r0]\n\ + ldrh r1, [r1]\n\ + cmp r0, r1\n\ + beq _08021B72\n\ + str r5, [sp, 0x1C]\n\ + _08021B72:\n\ + ldr r0, [sp, 0x24]\n\ + ldr r1, [sp, 0x10]\n\ + adds r4, r0, r1\n\ + lsls r4, 1\n\ + adds r4, r3, r4\n\ + adds r4, r2, r4\n\ + ldrh r1, [r4]\n\ + lsrs r1, 4\n\ + ldr r0, =gStringVar1\n\ + movs r2, 0x1\n\ + movs r3, 0x3\n\ + bl ConvertIntToDecimalStringN\n\ + movs r7, 0\n\ + ldrb r0, [r4]\n\ + movs r3, 0xF\n\ + ands r3, r0\n\ + movs r2, 0\n\ + ldr r4, [sp, 0x10]\n\ + lsls r4, 2\n\ + str r4, [sp, 0x28]\n\ + ldr r4, [sp, 0x14]\n\ + subs r4, 0x4\n\ + lsls r0, r6, 24\n\ + mov r10, r0\n\ + ldr r1, [sp, 0x1C]\n\ + adds r1, 0xA2\n\ + mov r9, r1\n\ + ldr r0, [sp, 0x18]\n\ + lsls r0, 5\n\ + mov r8, r0\n\ + adds r6, 0xE\n\ + adds r5, 0x1\n\ + ldr r1, =gUnknown_082F334C\n\ + mov r12, r1\n\ + _08021BB8:\n\ + movs r0, 0x3\n\ + subs r1, r0, r2\n\ + adds r0, r3, 0\n\ + asrs r0, r1\n\ + movs r1, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08021BD0\n\ + lsls r0, r2, 2\n\ + add r0, r12\n\ + ldr r0, [r0]\n\ + adds r7, r0\n\ + _08021BD0:\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0x3\n\ + bls _08021BB8\n\ + adds r0, r7, 0\n\ + ldr r1, =0x000f4240\n\ + bl __udivsi3\n\ + lsls r0, 24\n\ + lsrs r3, r0, 24\n\ + ldr r0, =gStringVar2\n\ + adds r1, r3, 0\n\ + movs r2, 0x2\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gUnknown_082F43B4\n\ + ldr r2, [sp, 0x28]\n\ + adds r0, r2, r0\n\ + ldr r1, [r0]\n\ + ldr r0, =gStringVar4\n\ + bl StringExpandPlaceholders\n\ + b _08021C5E\n\ + .pool\n\ + _08021C1C:\n\ + str r5, [sp, 0x18]\n\ + str r5, [sp, 0x1C]\n\ + lsls r7, r5, 5\n\ + ldr r3, [sp, 0xC]\n\ + adds r0, r3, r7\n\ + adds r0, 0xA4\n\ + ldrb r2, [r0]\n\ + cmp r2, 0x2B\n\ + bls _08021C30\n\ + movs r2, 0\n\ + _08021C30:\n\ + lsls r1, r2, 3\n\ + subs r1, r2\n\ + lsls r1, 2\n\ + ldr r0, =gBerries\n\ + adds r1, r0\n\ + ldr r0, =gStringVar1\n\ + bl StringCopy\n\ + ldr r0, =gUnknown_082F43B4\n\ + ldr r1, [r0, 0x8]\n\ + ldr r0, =gStringVar4\n\ + bl StringExpandPlaceholders\n\ + ldr r4, [sp, 0x14]\n\ + subs r4, 0x4\n\ + lsls r0, r6, 24\n\ + mov r10, r0\n\ + movs r1, 0xA2\n\ + adds r1, r5\n\ + mov r9, r1\n\ + mov r8, r7\n\ + _08021C5A:\n\ + adds r6, 0xE\n\ + adds r5, 0x1\n\ + _08021C5E:\n\ + movs r0, 0x2\n\ + ldr r1, =gStringVar4\n\ + adds r2, r4, 0\n\ + bl GetStringRightAlignXOffset\n\ + adds r2, r0, 0\n\ + ldr r3, [sp, 0xC]\n\ + movs r4, 0xDD\n\ + lsls r4, 1\n\ + adds r0, r3, r4\n\ + ldrb r0, [r0]\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + mov r1, r10\n\ + lsrs r3, r1, 24\n\ + ldr r1, =sBerryCrushTextColors1\n\ + str r1, [sp]\n\ + movs r4, 0\n\ + str r4, [sp, 0x4]\n\ + ldr r1, =gStringVar4\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x2\n\ + bl AddTextPrinterParameterized3\n\ + ldr r3, [sp, 0x18]\n\ + ldr r2, [sp, 0xC]\n\ + ldrb r2, [r2, 0x8]\n\ + cmp r3, r2\n\ + bne _08021CC0\n\ + ldr r0, =gStringVar3\n\ + ldr r1, =gText_1DotBlueF700\n\ + bl StringCopy\n\ + b _08021CC8\n\ + .pool\n\ + _08021CC0:\n\ + ldr r0, =gStringVar3\n\ + ldr r1, =gText_1DotF700\n\ + bl StringCopy\n\ + _08021CC8:\n\ + ldr r4, =gStringVar3\n\ + mov r3, r9\n\ + strb r3, [r4]\n\ + mov r1, r8\n\ + adds r1, 0x98\n\ + ldr r0, [sp, 0xC]\n\ + adds r1, r0, r1\n\ + movs r0, 0\n\ + bl DynamicPlaceholderTextUtil_SetPlaceholderPtr\n\ + ldr r0, =gStringVar4\n\ + adds r1, r4, 0\n\ + bl DynamicPlaceholderTextUtil_ExpandPlaceholders\n\ + ldr r1, [sp, 0xC]\n\ + movs r2, 0xDD\n\ + lsls r2, 1\n\ + adds r0, r1, r2\n\ + ldrb r0, [r0]\n\ + mov r4, r10\n\ + lsrs r3, r4, 24\n\ + ldr r1, =sBerryCrushTextColors1\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + ldr r2, =gStringVar4\n\ + str r2, [sp, 0x8]\n\ + movs r1, 0x2\n\ + movs r2, 0x4\n\ + bl AddTextPrinterParameterized3\n\ + lsls r0, r5, 24\n\ + lsrs r5, r0, 24\n\ + ldr r3, [sp, 0xC]\n\ + ldrb r3, [r3, 0x9]\n\ + cmp r5, r3\n\ + bcs _08021D14\n\ + b _08021A98\n\ + _08021D14:\n\ + add sp, 0x2C\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"); +} +#endif + +void sub_8021D34(struct BerryCrushGame *r8) +{ + u8 r10 = 0; + u8 r6 = 0; + u32 sp0C = 0; + struct BerryCrushGame_68 *sp10 = &r8->unk68; + u8 r7 = GetWindowAttribute(r8->unk138.unk82, WINDOW_HEIGHT) * 8 - 42; + + sub_8021944(&r8->unk138, sp10->unk04); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gText_TimeColon); + r6 = 176 - (u8)GetStringWidth(2, gText_SpaceSec, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gText_SpaceSec); + ConvertIntToDecimalStringN(gStringVar1, r8->unk138.unk6, 2, 2); + ConvertIntToDecimalStringN(gStringVar2, r8->unk138.unk8, 2, 2); + StringExpandPlaceholders(gStringVar4, gText_XDotY2); + r6 -= GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gStringVar4); + r6 -= GetStringWidth(2, gText_SpaceMin, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gText_SpaceMin); + ConvertIntToDecimalStringN(gStringVar1, r8->unk138.unk4, 2, 1); + StringExpandPlaceholders(gStringVar4, gText_StrVar1); + r6 -= GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gStringVar4); + r7 += 14; + AddTextPrinterParameterized3(r8->unk138.unk82, 2, 0, r7, sBerryCrushTextColors1[0], 0, gText_PressingSpeed); + r6 = 176 - (u8)GetStringWidth(2, gText_TimesPerSec, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gText_TimesPerSec); + for (; r10 < 8; ++r10) + if (((u8)r8->unk16 >> (7 - r10)) & 1) + sp0C += *(r10 + gUnknown_082F334C); // It's accessed in a different way here for unknown reason + ConvertIntToDecimalStringN(gStringVar1, r8->unk16 >> 8, 1, 3); + ConvertIntToDecimalStringN(gStringVar2, sp0C / 1000000, 2, 2); + StringExpandPlaceholders(gStringVar4, gText_XDotY3); + r6 -= GetStringWidth(2, gStringVar4, -1); + if (r8->unk25_1) + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors4, 0, gStringVar4); + else + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gStringVar4); + r7 += 14; + AddTextPrinterParameterized3(r8->unk138.unk82, 2, 0, r7, sBerryCrushTextColors1[0], 0, gText_Silkiness); + ConvertIntToDecimalStringN(gStringVar1, sp10->unk08, 1, 3); + StringExpandPlaceholders(gStringVar4, gText_Var1Percent); + r6 = 176 - (u8)GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColors1[0], 0, gStringVar4); +} + +bool32 sub_8022070(struct BerryCrushGame *r4, struct BerryCrushGame_138 *r6) +{ + u8 r5; + struct WindowTemplate template; + + switch (r6->unk80) + { + case 0: + r5 = r4->unk9 - 2; + sub_8022554(r6); + memcpy(&template, &gUnknown_082F32CC[r4->unk12], sizeof(struct WindowTemplate)); + if (r4->unk12 == 13) + template.height = gUnknown_082F3344[1][r5]; + else + template.height = gUnknown_082F3344[0][r5]; + r6->unk82 = AddWindow(&template); + break; + case 1: + PutWindowTilemap(r6->unk82); + FillWindowPixelBuffer(r6->unk82, PIXEL_FILL(0)); + break; + case 2: + LoadUserWindowBorderGfx_(r6->unk82, 541, 208); + DrawStdFrameWithCustomTileAndPalette(r6->unk82, 0, 541, 13); + break; + case 3: + r5 = r4->unk9 - 2; + switch (r4->unk12) + { + case 11: + sub_80219C8(r6->unk82, 20, 3, gText_PressesRankings); + sub_8021A28(r4, 0, 0xA0, 8 * gUnknown_082F3344[0][r5]); + r6->unk80 = 5; + return FALSE; + case 12: + sub_80219C8(r6->unk82, 20, 4, gUnknown_082F43B4[r4->unk68.unk1C.separate.player.unk4[7] + 3]); + sub_8021A28(r4, 1, 0xA0, 8 * gUnknown_082F3344[0][r5]); + r6->unk80 = 5; + return FALSE; + case 13: + sub_80219C8(r6->unk82, 22, 3, gText_CrushingResults); + sub_8021A28(r4, 2, 0xB0, 8 * gUnknown_082F3344[1][r5]); + break; + } + break; + case 4: + sub_8021D34(r4); + break; + case 5: + CopyWindowToVram(r6->unk82, 3); + r6->unk80 = 0; + return TRUE; + } + ++r6->unk80; + return FALSE; +} + +void sub_802222C(struct BerryCrushGame *r4) +{ + ClearStdWindowAndFrameToTransparent(r4->unk138.unk82, 1); + RemoveWindow(r4->unk138.unk82); + sub_8022600(r4); +} + +#ifdef NONMATCHING +void sub_8022250(u8 r4) +{ + u8 r9 = 0, r2, r7, r10; + u32 sp0C = 0; + s16 *r6 = gTasks[r4].data; + + switch (r6[0]) + { + case 0: + r6[1] = AddWindow(&gUnknown_082F32EC); + PutWindowTilemap((u8)r6[1]); + FillWindowPixelBuffer((u8)r6[1], PIXEL_FILL(0)); + LoadUserWindowBorderGfx_((u8)r6[1], 541, 208); + DrawStdFrameWithCustomTileAndPalette((u8)r6[1], 0, 541, 13); + break; + case 1: + // r5/r10 register swap + r7 = 96 - GetStringWidth(1, gText_BerryCrush2, -1) / 2u; + AddTextPrinterParameterized3( + (u8)r6[1], + 1, + r7, + 1, + sBerryCrushTextColorTable[0], + 0, + gText_BerryCrush2 + ); + r7 = 96 - GetStringWidth(1, gText_PressingSpeedRankings, -1) / 2u; + AddTextPrinterParameterized3( + (u8)r6[1], + 1, + r7, + 17, + sBerryCrushTextColorTable[0], + 0, + gText_PressingSpeedRankings + ); + + for (r10 = 41; r9 < 4; ++r9) + { + ConvertIntToDecimalStringN(gStringVar1, r9 + 2, 0, 1); + StringExpandPlaceholders(gStringVar4, gText_Var1Players); + AddTextPrinterParameterized3( + (u8)r6[1], + 1, + 0, + r10, + sBerryCrushTextColors1[0], + 0, + gStringVar4 + ); + r7 = 192 - (u8)GetStringWidth(1, gText_TimesPerSec, -1); + AddTextPrinterParameterized3( + (u8)r6[1], + 1, + r7, + r10, + sBerryCrushTextColors1[0], + 0, + gText_TimesPerSec + ); + for (r2 = 0; r2 < 8; ++r2) + if (((u8)r6[r9 + 2] >> (7 - r2)) & 1) + sp0C += gUnknown_082F334C[r2]; + ConvertIntToDecimalStringN(gStringVar1, (u16)r6[r9 + 2] >> 8, 1, 3); + ConvertIntToDecimalStringN(gStringVar2, sp0C / 1000000, 2, 2); + StringExpandPlaceholders(gStringVar4, gText_XDotY3); + r7 -= GetStringWidth(1, gStringVar4, -1); + AddTextPrinterParameterized3( + (u8)r6[1], + 1, + r7, + r10, + sBerryCrushTextColors1[0], + 0, + gStringVar4 + ); + r10 += 16; + sp0C = 0; + } + CopyWindowToVram((u8)r6[1], 3); + break; + case 2: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + break; + else + return; + case 3: + ClearStdWindowAndFrameToTransparent((u8)r6[1], 1); + ClearWindowTilemap((u8)r6[1]); + RemoveWindow((u8)r6[1]); + DestroyTask(r4); + EnableBothScriptContexts(); + ScriptContext2_Disable(); + r6[0] = 0; + return; + } + ++r6[0]; +} +#else +NAKED +void sub_8022250(u8 r4) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x14\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + movs r0, 0\n\ + mov r9, r0\n\ + movs r1, 0\n\ + str r1, [sp, 0xC]\n\ + lsls r0, r4, 2\n\ + adds r0, r4\n\ + lsls r0, 3\n\ + ldr r1, =gTasks + 0x8\n\ + adds r6, r0, r1\n\ + movs r1, 0\n\ + ldrsh r0, [r6, r1]\n\ + cmp r0, 0x1\n\ + beq _080222D0_case_1\n\ + cmp r0, 0x1\n\ + bgt _08022288\n\ + cmp r0, 0\n\ + beq _08022296_case_0\n\ + b _080224BA_case_def\n\ + .pool\n\ + _08022288:\n\ + cmp r0, 0x2\n\ + bne _0802228E\n\ + b _08022480_case_2\n\ + _0802228E:\n\ + cmp r0, 0x3\n\ + bne _08022294\n\ + b _08022494_case_3\n\ + _08022294:\n\ + b _080224BA_case_def\n\ + _08022296_case_0:\n\ + ldr r0, =gUnknown_082F32EC\n\ + bl AddWindow\n\ + strh r0, [r6, 0x2]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl PutWindowTilemap\n\ + ldrb r0, [r6, 0x2]\n\ + movs r1, 0\n\ + bl FillWindowPixelBuffer\n\ + ldrb r0, [r6, 0x2]\n\ + ldr r4, =0x0000021d\n\ + adds r1, r4, 0\n\ + movs r2, 0xD0\n\ + bl LoadUserWindowBorderGfx_\n\ + ldrb r0, [r6, 0x2]\n\ + movs r1, 0\n\ + adds r2, r4, 0\n\ + movs r3, 0xD\n\ + bl DrawStdFrameWithCustomTileAndPalette\n\ + b _080224BA_case_def\n\ + .pool\n\ + _080222D0_case_1:\n\ + ldr r0, =gText_BerryCrush2\n\ + mov r10, r0\n\ + movs r1, 0x1\n\ + negs r1, r1\n\ + mov r8, r1\n\ + movs r0, 0x1\n\ + mov r1, r10\n\ + mov r2, r8\n\ + bl GetStringWidth\n\ + lsrs r0, 1\n\ + movs r4, 0x60\n\ + subs r0, r4, r0\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldrb r0, [r6, 0x2]\n\ + ldr r5, =sBerryCrushTextColorTable\n\ + str r5, [sp]\n\ + mov r1, r9\n\ + str r1, [sp, 0x4]\n\ + mov r1, r10\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x1\n\ + adds r2, r7, 0\n\ + movs r3, 0x1\n\ + bl AddTextPrinterParameterized3\n\ + ldr r0, =gText_PressingSpeedRankings\n\ + mov r10, r0\n\ + movs r0, 0x1\n\ + mov r1, r10\n\ + mov r2, r8\n\ + bl GetStringWidth\n\ + lsrs r0, 1\n\ + subs r4, r0\n\ + lsls r4, 24\n\ + lsrs r7, r4, 24\n\ + ldrb r0, [r6, 0x2]\n\ + str r5, [sp]\n\ + mov r1, r9\n\ + str r1, [sp, 0x4]\n\ + mov r1, r10\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x1\n\ + adds r2, r7, 0\n\ + movs r3, 0x11\n\ + bl AddTextPrinterParameterized3\n\ + movs r0, 0x29\n\ + mov r10, r0\n\ + _08022336:\n\ + mov r1, r9\n\ + adds r1, 0x2\n\ + ldr r0, =gStringVar1\n\ + movs r2, 0\n\ + movs r3, 0x1\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gStringVar4\n\ + ldr r1, =gText_Var1Players\n\ + bl StringExpandPlaceholders\n\ + ldrb r0, [r6, 0x2]\n\ + ldr r1, =sBerryCrushTextColors1\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + ldr r1, =gStringVar4\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x1\n\ + movs r2, 0\n\ + mov r3, r10\n\ + bl AddTextPrinterParameterized3\n\ + movs r0, 0x1\n\ + ldr r1, =gText_TimesPerSec\n\ + movs r2, 0x1\n\ + negs r2, r2\n\ + bl GetStringWidth\n\ + movs r1, 0xC0\n\ + subs r1, r0\n\ + lsls r1, 24\n\ + lsrs r7, r1, 24\n\ + ldrb r0, [r6, 0x2]\n\ + ldr r1, =sBerryCrushTextColors1\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + ldr r1, =gText_TimesPerSec\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x1\n\ + adds r2, r7, 0\n\ + mov r3, r10\n\ + bl AddTextPrinterParameterized3\n\ + movs r2, 0\n\ + mov r0, r9\n\ + lsls r4, r0, 1\n\ + mov r1, r10\n\ + adds r1, 0x10\n\ + str r1, [sp, 0x10]\n\ + movs r0, 0x1\n\ + add r9, r0\n\ + adds r0, r4, r6\n\ + ldrb r3, [r0, 0x4]\n\ + movs r1, 0x7\n\ + mov r12, r1\n\ + movs r0, 0x1\n\ + mov r8, r0\n\ + ldr r5, =gUnknown_082F334C\n\ + _080223AE:\n\ + mov r0, r12\n\ + subs r1, r0, r2\n\ + adds r0, r3, 0\n\ + asrs r0, r1\n\ + mov r1, r8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080223CA\n\ + lsls r0, r2, 2\n\ + adds r0, r5\n\ + ldr r0, [r0]\n\ + ldr r1, [sp, 0xC]\n\ + adds r1, r0\n\ + str r1, [sp, 0xC]\n\ + _080223CA:\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0x7\n\ + bls _080223AE\n\ + adds r0, r4, r6\n\ + ldrh r1, [r0, 0x4]\n\ + lsrs r1, 8\n\ + ldr r0, =gStringVar1\n\ + movs r2, 0x1\n\ + movs r3, 0x3\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, [sp, 0xC]\n\ + ldr r1, =0x000f4240\n\ + bl __udivsi3\n\ + adds r1, r0, 0\n\ + ldr r0, =gStringVar2\n\ + movs r2, 0x2\n\ + movs r3, 0x2\n\ + bl ConvertIntToDecimalStringN\n\ + ldr r0, =gStringVar4\n\ + ldr r1, =gText_XDotY3\n\ + bl StringExpandPlaceholders\n\ + movs r0, 0x1\n\ + ldr r1, =gStringVar4\n\ + movs r2, 0x1\n\ + negs r2, r2\n\ + bl GetStringWidth\n\ + subs r0, r7, r0\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldrb r0, [r6, 0x2]\n\ + ldr r1, =sBerryCrushTextColors1\n\ + str r1, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + ldr r1, =gStringVar4\n\ + str r1, [sp, 0x8]\n\ + movs r1, 0x1\n\ + adds r2, r7, 0\n\ + mov r3, r10\n\ + bl AddTextPrinterParameterized3\n\ + ldr r1, [sp, 0x10]\n\ + lsls r0, r1, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + movs r0, 0\n\ + str r0, [sp, 0xC]\n\ + mov r1, r9\n\ + lsls r0, r1, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + cmp r0, 0x3\n\ + bhi _08022444\n\ + b _08022336\n\ + _08022444:\n\ + ldrb r0, [r6, 0x2]\n\ + movs r1, 0x3\n\ + bl CopyWindowToVram\n\ + b _080224BA_case_def\n\ + .pool\n\ + _08022480_case_2:\n\ + ldr r0, =gMain\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x3\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080224BA_case_def\n\ + b _080224C0\n\ + .pool\n\ + _08022494_case_3:\n\ + ldrb r0, [r6, 0x2]\n\ + movs r1, 0x1\n\ + bl ClearStdWindowAndFrameToTransparent\n\ + ldrb r0, [r6, 0x2]\n\ + bl ClearWindowTilemap\n\ + ldrb r0, [r6, 0x2]\n\ + bl RemoveWindow\n\ + adds r0, r4, 0\n\ + bl DestroyTask\n\ + bl EnableBothScriptContexts\n\ + bl ScriptContext2_Disable\n\ + mov r0, r9\n\ + b _080224BE\n\ + _080224BA_case_def:\n\ + ldrh r0, [r6]\n\ + adds r0, 0x1\n\ + _080224BE:\n\ + strh r0, [r6]\n\ + _080224C0:\n\ + add sp, 0x14\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} +#endif + +void ShowBerryCrushRankings(void) +{ + u8 taskId; + + ScriptContext2_Enable(); + taskId = CreateTask(sub_8022250, 0); + gTasks[taskId].data[2] = gSaveBlock2Ptr->berryCrush.berryCrushResults[0]; + gTasks[taskId].data[3] = gSaveBlock2Ptr->berryCrush.berryCrushResults[1]; + gTasks[taskId].data[4] = gSaveBlock2Ptr->berryCrush.berryCrushResults[2]; + gTasks[taskId].data[5] = gSaveBlock2Ptr->berryCrush.berryCrushResults[3]; +} + +void sub_8022524(struct BerryCrushGame_138 *r4, u16 r1) +{ + sub_8021944(r4, r1); + sub_8035044(0, r4->unk4); + sub_8035044(1, r4->unk6); + sub_8035044(2, r4->unk8); +} + +void sub_8022554(struct BerryCrushGame_138 *r0) +{ + r0->unk78[0]->invisible = TRUE; + r0->unk78[1]->invisible = TRUE; + sub_803547C(2, 1); + sub_803547C(1, 1); + sub_803547C(0, 1); +} + +void sub_8022588(struct BerryCrushGame *r5) +{ + u8 r6; + + for (r6 = 0; r6 < r5->unk9; ++r6) + { + r5->unk138.unkC[r6] = &gUnknown_082F4190[gUnknown_082F417C[r5->unk9 - 2][r6]]; + r5->unk138.unk83[r6] = AddWindow(&gUnknown_082F32F4[r5->unk138.unkC[r6]->unk0]); + PutWindowTilemap(r5->unk138.unk83[r6]); + FillWindowPixelBuffer(r5->unk138.unk83[r6], 0); + } +} + +void sub_8022600(struct BerryCrushGame *r6) +{ + u8 r7, r2; + u8 *r4; + + for (r7 = 0; r7 < r6->unk9; ++r7) + { + PutWindowTilemap(r6->unk138.unk83[r7]); + if (r7 == r6->unk8) + { + AddTextPrinterParameterized4( + r6->unk138.unk83[r7], + 2, + 36 - GetStringWidth(2, PLAYER_UNK14(r6, r7), 0) / 2u, + 1, + 0, + 0, + sBerryCrushTextColors2[0], + 0, + PLAYER_UNK14(r6, r7) + ); + } + else + { + AddTextPrinterParameterized4( + r6->unk138.unk83[r7], + 2, + 36 - GetStringWidth(2, PLAYER_UNK14(r6, r7), 0) / 2u, + 1, + 0, + 0, + sBerryCrushTextColors3[0], + 0, + PLAYER_UNK14(r6, r7) + ); + } + CopyWindowToVram(r6->unk138.unk83[r7], 3); + } + CopyBgTilemapBufferToVram(0); +} + +void sub_80226D0(struct BerryCrushGame *r6) +{ + u8 r5 = 0; + const u32 *r0 = gUnknown_08DE3FD4; +#ifndef NONMATCHING // r4, r5, r6 register roulette + register u8 *r4 asm("r4") = gDecompressionBuffer; + register u32 r0_ asm("r0"); +#else + u8 *r4 = gDecompressionBuffer; + u32 r0_; +#endif + + LZ77UnCompWram(r0, r4); + for (; r5 < r6->unk9; ++r5) + { + r0_ = r6->unk138.unkC[r5]->unk0; + CopyToBgTilemapBufferRect( + 3, + &r4[r0_ * 40], + r6->unk138.unkC[r5]->unk1, + r6->unk138.unkC[r5]->unk2, + 10, + 2 + ); + } + CopyBgTilemapBufferToVram(3); +} + +void sub_8022730(struct BerryCrushGame *r6) +{ + u8 r5 = 0; + u8 r2; + + r6->unk2A = -104; + r6->unk2C = 0; + gSpriteCoordOffsetX = 0; + gSpriteCoordOffsetY = -104; + for (; r5 < 4; ++r5) + LoadCompressedSpriteSheet(&gUnknown_082F41F4[r5]); + LoadSpritePalettes(&gUnknown_082F421C); + r2 = CreateSprite(&gUnknown_082F430C, 120, 88, 5); + r6->unk138.unk20 = &gSprites[r2]; + r6->unk138.unk20->oam.priority = 3; + r6->unk138.unk20->coordOffsetEnabled = TRUE; + r6->unk138.unk20->animPaused = TRUE; + for (r5 = 0; r5 < r6->unk9; ++r5) + { + r2 = CreateSprite( + &gUnknown_082F4324, + r6->unk138.unkC[r5]->unk4 + 120, + r6->unk138.unkC[r5]->unk6 + 32, + 0 + ); + r6->unk138.unk24[r5] = &gSprites[r2]; + r6->unk138.unk24[r5]->oam.priority = 1; + r6->unk138.unk24[r5]->invisible = TRUE; + r6->unk138.unk24[r5]->coordOffsetEnabled = TRUE; + r6->unk138.unk24[r5]->animPaused = TRUE; + } + for (r5 = 0; r5 < ARRAY_COUNT(r6->unk138.unk4C); ++r5) + { + r2 = CreateSprite( + &gUnknown_082F433C, + gUnknown_082F41D2[r5][0] + 120, + gUnknown_082F41D2[r5][1] + 136, + 6 + ); + r6->unk138.unk4C[r5] = &gSprites[r2]; + r6->unk138.unk4C[r5]->oam.priority = 3; + r6->unk138.unk4C[r5]->invisible = TRUE; + r6->unk138.unk4C[r5]->animPaused = TRUE; + r6->unk138.unk4C[r5]->data[0] = r5; + } + for (r5 = 0; r5 < ARRAY_COUNT(r6->unk138.unk78); ++r5) + { + r2 = CreateSprite( + &gUnknown_082F4354, + 24 * r5 + 176, + 8, + 0 + ); + r6->unk138.unk78[r5] = &gSprites[r2]; + r6->unk138.unk78[r5]->oam.priority = 0; + r6->unk138.unk78[r5]->invisible = FALSE; + r6->unk138.unk78[r5]->animPaused = FALSE; + } + sub_8034D14(0, 0, &gUnknown_082F4384[0]); + sub_8034D14(1, 0, &gUnknown_082F4384[1]); + sub_8034D14(2, 0, &gUnknown_082F4384[2]); + if (r6->unk12 == 1) + sub_8022554(&r6->unk138); +} + +void sub_8022960(struct BerryCrushGame *r5) +{ + u8 r4 = 0; + + FreeSpriteTilesByTag(4); + FreeSpriteTilesByTag(3); + FreeSpriteTilesByTag(2); + FreeSpriteTilesByTag(1); + FreeSpritePaletteByTag(4); + FreeSpritePaletteByTag(2); + FreeSpritePaletteByTag(1); + for (; r4 < ARRAY_COUNT(r5->unk138.unk78); ++r4) + DestroySprite(r5->unk138.unk78[r4]); + sub_80353DC(2); + sub_80353DC(1); + sub_80353DC(0); + for (r4 = 0; r4 < ARRAY_COUNT(r5->unk138.unk4C); ++r4) + DestroySprite(r5->unk138.unk4C[r4]); + for (r4 = 0; r4 < r5->unk9; ++r4) + DestroySprite(r5->unk138.unk24[r4]); + if (r5->unk138.unk20->inUse) + DestroySprite(r5->unk138.unk20); +} + +void sub_8022A20(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sprite->invisible = TRUE; + sprite->animPaused = TRUE; + } +} + +void sub_8022A4C(struct Sprite *sprite) +{ + u8 r1 = 0; + SpriteCallback r5 = SpriteCallbackDummy; + + for (; r1 < ARRAY_COUNT(sprite->data); ++r1) + sprite->data[r1] = 0; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->invisible = TRUE; + sprite->animPaused = TRUE; + sprite->callback = r5; +} + +void sub_8022A94(struct Sprite *sprite) +{ + s16 *r4 = sprite->data; + + r4[1] += r4[2]; + sprite->pos2.y += r4[1] >> 8; + if (r4[7] & 0x8000) + { + sprite->data[0] += r4[3]; + r4[4] += r4[5]; + sprite->pos2.x = Sin(r4[4] >> 7, r4[6]); + if (r4[7] & 0x8000 && r4[4] >> 7 > 126) + { + sprite->pos2.x = 0; + r4[7] &= 0x7FFF; + } + } + sprite->pos1.x = r4[0] >> 7; + if (sprite->pos1.y + sprite->pos2.y > (r4[7] & 0x7FFF)) + sprite->callback = sub_8022A4C; +} + +void sub_8022B28(struct Sprite *sprite) +{ + s16 *r7 = sprite->data; + s16 r4, r5; + s32 r2; + u32 r8 = 0; + + r7 = sprite->data; + r2 = 640; + r7[1] = r2; + r7[2] = 32; + r7[7] = 168; + r4 = sprite->pos2.x * 128; + r5 = sub_81515D4(7, (168 - sprite->pos1.y) << 7, (r2 + 32) >> 1); + sprite->data[0] = sprite->pos1.x << 7; + r7[3] = sub_81515D4(7, r4, r5); + r2 = sub_8151550(7, r5, 85); + r7[4] = r8; + r7[5] = sub_81515D4(7, 0x3F80, r2); + r7[6] = sprite->pos2.x / 4; + r7[7] |= 0x8000; + sprite->pos2.y = r8; + sprite->pos2.x = r8; + sprite->callback = sub_8022A94; + sprite->animPaused = FALSE; + sprite->invisible = FALSE; +} + +void sub_8022BEC(u16 r5, u8 r4, u8 *r7) +{ + struct BerryCrushGame *r6 = sub_8020C00(); + + if (r5 > 25) + r5 = 0; + switch (r4) + { + case 0: + if (r5 != 0) + gUnknown_082F43CC[r5](r6, r7); + if (r6->unkE > 25) + r6->unkE = r4; + r6->unk4 = gUnknown_082F43CC[r6->unkE]; + break; + case 1: + r6->unk4 = gUnknown_082F43CC[r5]; + break; + } +} + +u32 sub_8022C58(struct BerryCrushGame *r6, u8 *r1) +{ + u16 r4; + u32 r0; +#ifndef NONMATCHING // fake match, nobody can write such code + register u32 r2 asm("r2"); + register u32 r3 asm("r3"); + + r2 = r1[0]; + r3 = r1[1]; + r3 <<= 8; + r2 |= r3; + r3 = r1[2]; + r3 <<= 16; + r2 |= r3; + r3 = r1[3]; + r3 <<= 24; + r0 = r2; + r0 |= r3; +#else + u32 r2; + + r0 = T1_READ_32(r1); +#endif + r2 = r1[9]; + r1[0] = r2; + r4 = r1[8] << 8; + r2 = r1[7]; + r4 |= r2; + gPaletteFade.bufferTransferDisabled = FALSE; + BeginNormalPaletteFade(r0, r1[4], r1[5], r1[6], r4); + UpdatePaletteFade(); + r6->unkE = 2; + return 0; +} + +u32 sub_8022CB0(struct BerryCrushGame *r4, u8 *r5) +{ + switch (r4->unkC) + { + case 0: + if (UpdatePaletteFade()) + return 0; + if(r5[0] != 0) + ++r4->unkC; + else + r4->unkC = 3; + return 0; + case 1: + sub_8010434(); + ++r4->unkC; + return 0; + case 2: + if (IsLinkTaskFinished()) + { + ++r4->unkC; + return 0; + } + return 0; + case 3: + sub_8022BEC(r4->unkF, 1, NULL); + r4->unkC = 0; + return 0; + default: + ++r4->unkC; + return 0; + } +} + +u32 sub_8022D14(struct BerryCrushGame *r7, u8 *r5) +{ + u16 r4 = r5[3]; + + r4 <<= 8; + r4 |= r5[2]; + switch (r7->unkC) + { + case 0: + DrawDialogueFrame(0, 0); + if (r5[1] & 2) + { + StringExpandPlaceholders(gStringVar4, gUnknown_082F32A4[r5[0]]); + AddTextPrinterParameterized2(0, 1, gStringVar4, r7->unkB, 0, 2, 1, 3); + } + else + { + AddTextPrinterParameterized2(0, 1, gUnknown_082F32A4[r5[0]], r7->unkB, 0, 2, 1, 3); + } + CopyWindowToVram(0, 3); + break; + case 1: + if (!IsTextPrinterActive(0)) + { + if (r4 == 0) + ++r7->unkC; + break; + } + return 0; + case 2: + if (!(r4 & gMain.newKeys)) + return 0; + break; + case 3: + if (r5[1] & 1) + ClearDialogWindowAndFrame(0, 1); + sub_8022BEC(r7->unkE, 1, NULL); + r7->unkC = r5[4]; + return 0; + } + ++r7->unkC; + return 0; +} + +u32 sub_8022E1C(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +{ + if (sub_802104C() != 0) + sub_8022BEC(r4->unkE, 0, r4->unk36); + return 0; +} + +u32 sub_8022E3C(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +{ + if (sub_802130C() != 0) + sub_8022BEC(r4->unkE, 0, r4->unk36); + return 0; +} + +u32 sub_8022E5C(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +{ + switch (r4->unkC) + { + case 0: + sub_8010434(); + break; + case 1: + if (IsLinkTaskFinished()) + { + PlayNewMapMusic(MUS_RG_SLOT); + sub_8022BEC(7, 1, NULL); + r4->unk12 = 3; + r4->unkC = 0; + } + return 0; + } + ++r4->unkC; + return 0; +} + +u32 sub_8022EAC(struct BerryCrushGame *r4, u8 *r5) +{ + switch (r4->unkC) + { + default: + ++r4->unkC; + break; + case 0: + sub_8024578(r4); + sub_8024644(r5, 0, 1, 0, 1); + r4->unkE = 7; + sub_8022BEC(3, 1, NULL); + break; + case 1: + r4->unkE = 8; + sub_8022BEC(5, 1, NULL); + r4->unkC = 2; + break; + } + return 0; +} + +u32 sub_8022F04(struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1) +{ + r0->unk4 = NULL; + SetMainCallback2(sub_8020E1C); + return 0; +}