diff --git a/.gitignore b/.gitignore index 15cc865df..93385ea51 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ build/ porymap.project.cfg .vscode/ *.a +.fuse_hidden* diff --git a/asm/berry_crush.s b/asm/berry_crush.s deleted file mode 100755 index 3857a9b90..000000000 --- a/asm/berry_crush.s +++ /dev/null @@ -1,807 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8024048 -sub_8024048: @ 8024048 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldrb r0, [r5, 0xC] - cmp r0, 0x4 - bhi _08024124 - lsls r0, 2 - ldr r1, =_08024064 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08024064: - .4byte _08024078 - .4byte _0802408A - .4byte _0802409C - .4byte _080240CC - .4byte _080240DC -_08024078: - movs r0, 0x9C - lsls r0, 1 - adds r1, r5, r0 - adds r0, r5, 0 - bl sub_8022070 - cmp r0, 0 - bne _08024124 - b _0802412A -_0802408A: - movs r0, 0 - bl CopyBgTilemapBufferToVram - movs r0, 0x9C - lsls r0, 1 - adds r1, r5, r0 - movs r0, 0x1E - strb r0, [r1] - b _08024124 -_0802409C: - movs r0, 0x9C - lsls r0, 1 - adds r1, r5, r0 - ldrb r0, [r1] - cmp r0, 0 - beq _080240AE - subs r0, 0x1 - strb r0, [r1] - b _0802412A -_080240AE: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0802412A - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_802222C - b _08024124 - .pool -_080240CC: - ldrh r0, [r5, 0x12] - cmp r0, 0xC - bhi _08024124 - adds r0, 0x1 - movs r1, 0 - strh r0, [r5, 0x12] - strb r1, [r5, 0xC] - b _0802412A -_080240DC: - ldr r0, =gStringVar1 - ldr r1, [r5, 0x1C] - movs r2, 0 - movs r3, 0x6 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar2 - bl GetBerryPowder - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - movs r3, 0x6 - bl ConvertIntToDecimalStringN - movs r4, 0 - str r4, [sp] - adds r0, r6, 0 - movs r1, 0x2 - movs r2, 0x3 - movs r3, 0 - bl sub_8024644 - movs r0, 0x13 - strb r0, [r5, 0xE] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - strb r4, [r5, 0xC] - b _0802412A - .pool -_08024124: - ldrb r0, [r5, 0xC] - adds r0, 0x1 - strb r0, [r5, 0xC] -_0802412A: - movs r0, 0 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8024048 - - thumb_func_start sub_8024134 -sub_8024134: @ 8024134 - push {r4,r5,lr} - sub sp, 0x10 - adds r5, r0, 0 - adds r4, r1, 0 - ldrb r0, [r5, 0xC] - cmp r0, 0x4 - bhi _08024218 - lsls r0, 2 - ldr r1, =_08024150 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08024150: - .4byte _08024164 - .4byte _080241A0 - .4byte _080241A6 - .4byte _080241F0 - .4byte _08024204 -_08024164: - ldrh r1, [r5, 0x28] - ldr r0, =0x00008c9f - cmp r1, r0 - bls _08024176 - movs r1, 0x9C - lsls r1, 1 - adds r0, r5, r1 - bl sub_8022554 -_08024176: - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0x8 - movs r2, 0 - movs r3, 0 - bl sub_8024644 - movs r4, 0 - movs r0, 0x13 - strb r0, [r5, 0xE] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - strb r4, [r5, 0xC] - b _0802421E - .pool -_080241A0: - bl sub_8010434 - b _08024218 -_080241A6: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0802421E - movs r0, 0 - movs r1, 0 - bl DrawDialogueFrame - ldr r2, =gText_SavingDontTurnOffPower - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized2 - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r0, =sub_8153688 - movs r1, 0 - bl CreateTask - b _08024218 - .pool -_080241F0: - ldr r0, =sub_8153688 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _08024218 - b _0802421E - .pool -_08024204: - movs r0, 0x14 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r1, 0 - movs r0, 0xF - strh r0, [r5, 0x12] - strb r1, [r5, 0xC] - b _0802421E -_08024218: - ldrb r0, [r5, 0xC] - adds r0, 0x1 - strb r0, [r5, 0xC] -_0802421E: - movs r0, 0 - add sp, 0x10 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8024134 - - thumb_func_start sub_8024228 -sub_8024228: @ 8024228 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldrb r0, [r5, 0xC] - cmp r0, 0x1 - beq _0802426A - cmp r0, 0x1 - bgt _08024240 - cmp r0, 0 - beq _08024246 - b _080242D0 -_08024240: - cmp r0, 0x2 - beq _08024270 - b _080242D0 -_08024246: - movs r0, 0x1 - str r0, [sp] - adds r0, r6, 0 - movs r1, 0x4 - movs r2, 0 - movs r3, 0 - bl sub_8024644 - movs r0, 0x14 - strb r0, [r5, 0xE] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r0, 0 - strb r0, [r5, 0xC] - b _080242D8 -_0802426A: - bl DisplayYesNoMenuDefaultYes - b _080242D0 -_08024270: - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _080242D6 - adds r0, r5, 0 - adds r0, 0x42 - movs r1, 0 - movs r2, 0xC - bl memset - cmp r4, 0 - bne _080242A2 - bl HasAtLeastOneBerry - lsls r0, 24 - cmp r0, 0 - beq _0802429E - strh r4, [r5, 0x14] - b _080242A6 -_0802429E: - movs r0, 0x3 - b _080242A4 -_080242A2: - movs r0, 0x1 -_080242A4: - strh r0, [r5, 0x14] -_080242A6: - movs r0, 0 - movs r1, 0x1 - bl ClearDialogWindowAndFrame - movs r4, 0 - str r4, [sp] - adds r0, r6, 0 - movs r1, 0x8 - movs r2, 0 - movs r3, 0 - bl sub_8024644 - movs r0, 0x15 - strb r0, [r5, 0xE] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - strb r4, [r5, 0xC] - b _080242D6 -_080242D0: - ldrb r0, [r5, 0xC] - adds r0, 0x1 - strb r0, [r5, 0xC] -_080242D6: - movs r0, 0 -_080242D8: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8024228 - - thumb_func_start sub_80242E0 -sub_80242E0: @ 80242E0 - push {r4-r7,lr} - adds r4, r0, 0 - movs r5, 0 - ldrb r0, [r4, 0xC] - cmp r0, 0x1 - beq _08024306 - cmp r0, 0x1 - bgt _080242F6 - cmp r0, 0 - beq _08024300 - b _080243AC -_080242F6: - cmp r0, 0x2 - beq _08024328 - cmp r0, 0x3 - beq _08024336 - b _080243AC -_08024300: - bl sub_8010434 - b _080243AC -_08024306: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _080243B2 - ldrh r0, [r4, 0x14] - adds r1, r4, 0 - adds r1, 0x42 - strh r0, [r1] - adds r0, r4, 0 - adds r0, 0x4E - strh r5, [r0] - movs r0, 0 - movs r2, 0x2 - bl SendBlock - b _080243AC -_08024328: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _080243B2 - strh r5, [r4, 0x10] - b _080243AC -_08024336: - bl GetBlockReceivedStatus - ldr r2, =gUnknown_082F4448 - ldrb r3, [r4, 0x9] - subs r1, r3, 0x2 - adds r1, r2 - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _080243B2 - adds r7, r4, 0 - adds r7, 0x42 - adds r6, r4, 0 - adds r6, 0x4E - cmp r5, r3 - bcs _08024374 - adds r1, r6, 0 - ldr r2, =gBlockRecvBuffer -_0802435C: - lsls r0, r5, 8 - adds r0, r2 - ldrh r0, [r0] - ldrh r3, [r1] - adds r0, r3 - strh r0, [r1] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r4, 0x9] - cmp r5, r0 - bcc _0802435C -_08024374: - ldrh r0, [r6] - cmp r0, 0 - beq _08024390 - movs r0, 0x17 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - b _0802439A - .pool -_08024390: - movs r0, 0x16 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC -_0802439A: - bl ResetBlockReceivedFlags - movs r1, 0 - movs r0, 0 - strh r0, [r7] - strh r0, [r6] - strh r0, [r4, 0x10] - strb r1, [r4, 0xC] - b _080243B4 -_080243AC: - ldrb r0, [r4, 0xC] - adds r0, 0x1 - strb r0, [r4, 0xC] -_080243B2: - movs r0, 0 -_080243B4: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80242E0 - - thumb_func_start sub_80243BC -sub_80243BC: @ 80243BC - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - ldrb r4, [r5, 0xC] - cmp r4, 0x1 - beq _080243EA - cmp r4, 0x1 - bgt _080243D2 - cmp r4, 0 - beq _080243DC - b _08024434 -_080243D2: - cmp r4, 0x2 - beq _080243F6 - cmp r4, 0x3 - beq _0802441A - b _08024434 -_080243DC: - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0x1 - movs r2, 0 - movs r3, 0x10 - b _08024410 -_080243EA: - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - beq _08024434 - b _0802443A -_080243F6: - movs r0, 0 - movs r1, 0x1 - bl ClearDialogWindowAndFrame - adds r0, r5, 0 - bl sub_8021488 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 -_08024410: - bl BeginNormalPaletteFade - bl UpdatePaletteFade - b _08024434 -_0802441A: - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _0802443A - movs r0, 0x7 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - movs r0, 0 - strh r4, [r5, 0x12] - b _08024438 -_08024434: - ldrb r0, [r5, 0xC] - adds r0, 0x1 -_08024438: - strb r0, [r5, 0xC] -_0802443A: - movs r0, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80243BC - - thumb_func_start sub_8024444 -sub_8024444: @ 8024444 - push {r4,r5,lr} - sub sp, 0x10 - adds r5, r0, 0 - ldrb r4, [r5, 0xC] - cmp r4, 0x1 - beq _080244BC - cmp r4, 0x1 - bgt _0802445A - cmp r4, 0 - beq _08024460 - b _080244F6 -_0802445A: - cmp r4, 0x2 - beq _080244D4 - b _080244F6 -_08024460: - movs r0, 0 - movs r1, 0 - bl DrawDialogueFrame - ldrh r1, [r5, 0x14] - cmp r1, 0x3 - bne _08024490 - ldr r0, =gUnknown_082F32A4 - ldr r2, [r0, 0x14] - ldrb r3, [r5, 0xB] - str r4, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - str r1, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - bl AddTextPrinterParameterized2 - b _080244AC - .pool -_08024490: - ldr r0, =gUnknown_082F32A4 - ldr r2, [r0, 0x18] - ldrb r3, [r5, 0xB] - str r4, [sp] - movs r0, 0x2 - 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 -_080244AC: - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - b _080244F6 - .pool -_080244BC: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _080244FC - movs r0, 0x9C - lsls r0, 1 - adds r1, r5, r0 - movs r0, 0x78 - strb r0, [r1] - b _080244F6 -_080244D4: - movs r0, 0x9C - lsls r0, 1 - adds r1, r5, r0 - ldrb r0, [r1] - adds r4, r0, 0 - cmp r4, 0 - beq _080244E8 - subs r0, 0x1 - strb r0, [r1] - b _080244FC -_080244E8: - movs r0, 0x18 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - strb r4, [r5, 0xC] - b _080244FC -_080244F6: - ldrb r0, [r5, 0xC] - adds r0, 0x1 - strb r0, [r5, 0xC] -_080244FC: - movs r0, 0 - add sp, 0x10 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8024444 - - thumb_func_start sub_8024508 -sub_8024508: @ 8024508 - push {r4,r5,lr} - adds r5, r0, 0 - ldrb r4, [r5, 0xC] - cmp r4, 0x1 - beq _08024528 - cmp r4, 0x1 - bgt _0802451C - cmp r4, 0 - beq _08024522 - b _08024558 -_0802451C: - cmp r4, 0x2 - beq _08024538 - b _08024558 -_08024522: - bl sub_8010434 - b _08024558 -_08024528: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0802455E - bl sub_800AC34 - b _08024558 -_08024538: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0802455E - movs r0, 0x19 - strb r0, [r5, 0xE] - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0 - bl sub_8022BEC - strb r4, [r5, 0xC] - b _0802455E - .pool -_08024558: - ldrb r0, [r5, 0xC] - adds r0, 0x1 - strb r0, [r5, 0xC] -_0802455E: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8024508 - - thumb_func_start sub_8024568 -sub_8024568: @ 8024568 - push {lr} - movs r0, 0 - bl sub_8020C0C - movs r0, 0 - pop {r1} - bx r1 - thumb_func_end sub_8024568 - - thumb_func_start sub_8024578 -sub_8024578: @ 8024578 - push {r4-r6,lr} - adds r4, r0, 0 - movs r5, 0 - movs r0, 0x33 - bl IncrementGameStat - strb r5, [r4, 0xD] - movs r1, 0 - strh r5, [r4, 0x10] - movs r0, 0x2 - strh r0, [r4, 0x12] - strh r5, [r4, 0x14] - str r5, [r4, 0x1C] - strh r5, [r4, 0x18] - strh r5, [r4, 0x1A] - str r5, [r4, 0x20] - adds r0, r4, 0 - adds r0, 0x24 - strb r1, [r0] - adds r1, r4, 0 - adds r1, 0x25 - movs r0, 0 - strb r0, [r1] - strh r5, [r4, 0x26] - strh r5, [r4, 0x28] - strh r5, [r4, 0x2E] - ldr r0, =0x0000ffff - strh r0, [r4, 0x32] - strh r5, [r4, 0x30] - strh r5, [r4, 0x34] - movs r6, 0 - movs r3, 0 -_080245B8: - lsls r0, r5, 5 - adds r2, r4, r0 - adds r1, r2, 0 - adds r1, 0xA4 - ldr r0, =0x0000ffff - strh r0, [r1] - adds r0, r2, 0 - adds r0, 0xA6 - strh r3, [r0] - adds r0, 0x2 - strh r3, [r0] - adds r1, 0x6 - movs r0, 0x1 - strh r0, [r1] - adds r0, r2, 0 - adds r0, 0xAC - strh r3, [r0] - adds r0, 0x2 - strh r3, [r0] - adds r0, 0x2 - strh r3, [r0] - adds r0, 0x2 - strh r3, [r0] - adds r0, 0x2 - strb r6, [r0] - adds r0, 0x1 - strb r6, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x4 - bls _080245B8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8024578 - - thumb_func_start sub_8024604 -sub_8024604: @ 8024604 - push {r4-r6,lr} - sub sp, 0x8 - str r2, [sp, 0x4] - ldr r5, [sp, 0x18] - ldr r6, [sp, 0x1C] - ldr r4, [sp, 0x20] - mov r2, sp - strh r4, [r2] - add r4, sp, 0x4 - ldrb r2, [r4] - strb r2, [r0] - ldrb r2, [r4, 0x1] - strb r2, [r0, 0x1] - ldrb r2, [r4, 0x2] - strb r2, [r0, 0x2] - ldrb r2, [r4, 0x3] - strb r2, [r0, 0x3] - strb r3, [r0, 0x4] - strb r5, [r0, 0x5] - strb r6, [r0, 0x6] - mov r2, sp - ldrb r2, [r2] - strb r2, [r0, 0x7] - mov r2, sp - ldrb r2, [r2, 0x1] - strb r2, [r0, 0x8] - strb r1, [r0, 0x9] - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8024604 - - thumb_func_start sub_8024644 -sub_8024644: @ 8024644 - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, [sp, 0x10] - mov r4, sp - strh r3, [r4] - strb r1, [r0] - strb r2, [r0, 0x1] - mov r1, sp - ldrb r1, [r1] - strb r1, [r0, 0x2] - mov r1, sp - ldrb r1, [r1, 0x1] - strb r1, [r0, 0x3] - strb r5, [r0, 0x4] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8024644 - - .align 2, 0 @ don't pad with nop diff --git a/include/strings.h b/include/strings.h index d97d435f6..f8d77c73e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2864,6 +2864,27 @@ extern const u8 gText_JumpsInARow[]; extern const u8 gText_BestScore2[]; extern const u8 gText_ExcellentsInARow[]; +// Berry crush +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 gText_Silkiness[]; +extern const u8 gText_Var1Percent[]; +extern const u8 gText_PressesRankings[]; +extern const u8 gText_CrushingResults[]; +extern const u8 gText_BerryCrush2[]; +extern const u8 gText_PressingSpeedRankings[]; +extern const u8 gText_Var1Players[]; + // Lilycove Lady extern const u8 gText_ContestLady_Handsome[]; extern const u8 gText_ContestLady_Vinny[]; diff --git a/ld_script.txt b/ld_script.txt index 2f6137773..7e0eeac3d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -72,7 +72,6 @@ SECTIONS { src/mevent_news.o(.text); src/union_room_chat.o(.text); src/berry_crush.o(.text); - asm/berry_crush.o(.text); src/berry_powder.o(.text); src/dodrio_berry_picking.o(.text); src/pokemon_jump.o(.text); diff --git a/src/berry_crush.c b/src/berry_crush.c index 1764d7573..c61d4eeed 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -21,6 +21,7 @@ #include "pokemon_jump.h" #include "random.h" #include "rom_8034C54.h" +#include "save.h" #include "scanline_effect.h" #include "script.h" #include "sound.h" @@ -50,7 +51,8 @@ struct BerryCrushGame_Player struct __attribute__((packed, aligned(2))) BerryCrushGame_4E { - u8 filler0[0x4]; + u16 unk0; + u16 filler2; u8 unk4_0:1; u8 unk4_1:1; s8 unk5; @@ -112,7 +114,6 @@ struct BerryCrushGame_138_C u8 unk0; u8 unk1; u8 unk2; - u8 filler3; u16 unk4; u16 unk6; s16 unk8; @@ -149,12 +150,12 @@ struct BerryCrushGame u8 unkA; u8 unkB; u8 unkC; - u8 fillerD[0x1]; + u8 unkD; u8 unkE; u8 unkF; u16 unk10; u16 unk12; - u8 filler14[0x2]; + u16 unk14; u16 unk16; s16 unk18; s16 unk1A; @@ -191,7 +192,7 @@ static void sub_8020F88(void); static void sub_8020FA0(u8); void sub_8020FC4(struct BerryCrushGame *); void sub_8022BEC(u16, u8, u8 *); -void sub_8024604(u8 *, u8, s8, u8, u8, u8, u8); +void sub_8024604(u8 *, u32, s32, u32, u32, u32, u32); static int sub_8021450(struct BerryCrushGame *); void sub_8022588(struct BerryCrushGame *); void sub_8022600(struct BerryCrushGame *); @@ -217,30 +218,11 @@ 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[]; @@ -269,7 +251,7 @@ struct BerryCrushGame *sub_8020C00(void) return gUnknown_02022C90; } -int sub_8020C0C(MainCallback callback) +u32 sub_8020C0C(MainCallback callback) { if (!gUnknown_02022C90) return 2; @@ -282,7 +264,7 @@ int sub_8020C0C(MainCallback callback) SetMainCallback2(callback); if (callback == CB2_ReturnToField) { - gTextFlags.autoScroll = 1; + gTextFlags.autoScroll = TRUE; PlayNewMapMusic(MUS_POKECEN); SetMainCallback1(CB1_Overworld); } @@ -537,7 +519,7 @@ int sub_802104C(void) sub_8197200(); sub_8022588(var0); sub_8022600(var0); - gPaletteFade.bufferTransferDisabled = 1; + gPaletteFade.bufferTransferDisabled = TRUE; break; case 7: LoadPalette(gUnknown_08DE3398, 0, 0x180); @@ -558,7 +540,7 @@ int sub_802104C(void) ChangeBgY(1, 0, 0); break; case 9: - gPaletteFade.bufferTransferDisabled = 0; + gPaletteFade.bufferTransferDisabled = FALSE; BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK); ShowBg(0); ShowBg(1); @@ -904,7 +886,7 @@ void sub_8021A28(struct BerryCrushGame *sp0C, u8 sp10, u8 sp14, u8 r3) ); StringAppend(gStringVar4, gUnknown_082F43B4[sp10]); r4 = sp14 - 4; - r10 = r6; // shift right should happen after the switch + r10 = r6; r9 = sp1C + 0xA2; r8 = sp18; r6 += 14; @@ -2826,3 +2808,376 @@ u32 sub_8023CAC(struct BerryCrushGame *r7, __attribute__((unused)) u8 *r1) ++r7->unkC; return 0; } + +u32 sub_8024048(struct BerryCrushGame *r5, u8 *r6) +{ + switch (r5->unkC) + { + case 0: + if (!sub_8022070(r5, &r5->unk138)) + return 0; + break; + case 1: + CopyBgTilemapBufferToVram(0); + r5->unk138.unk0 = 30; + break; + case 2: + if (r5->unk138.unk0 != 0) + { + --r5->unk138.unk0; + return 0; + } + if (!(gMain.newKeys & A_BUTTON)) + return 0; + PlaySE(SE_SELECT); + sub_802222C(r5); + break; + case 3: + if (r5->unk12 <= 12) + { + ++r5->unk12; + r5->unkC = 0; + return 0; + } + break; + case 4: + ConvertIntToDecimalStringN(gStringVar1, r5->unk1C, 0, 6); + ConvertIntToDecimalStringN(gStringVar2, GetBerryPowder(), 0, 6); + sub_8024644(r6, 2, 3, 0, 0); + r5->unkE = 19; + sub_8022BEC(3, 1, NULL); + r5->unkC = 0; + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_8024134(struct BerryCrushGame *r5, u8 *r4) +{ + switch (r5->unkC) + { + case 0: + if (r5->unk28 >= 36000) + sub_8022554(&r5->unk138); + sub_8024644(r4, 8, 0, 0, 1); + r5->unkE = 19; + sub_8022BEC(3, 1, NULL); + r5->unkC = 0; + return 0; + case 1: + sub_8010434(); + break; + case 2: + if (!IsLinkTaskFinished()) + return 0; + DrawDialogueFrame(0, 0); + AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3); + CopyWindowToVram(0, 3); + CreateTask(sub_8153688, 0); + break; + case 3: + if (FuncIsActiveTask(sub_8153688)) + return 0; + break; + case 4: + sub_8022BEC(20, 1, NULL); + r5->unk12 = 15; + r5->unkC = 0; + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_8024228(struct BerryCrushGame *r5, u8 *r6) +{ + s32 r4; +#ifndef NONMATCHING + register s32 r0 asm("r0"); +#else + s32 r0; +#endif + + switch (r5->unkC) + { + case 0: + sub_8024644(r6, 4, 0, 0, 1); + r5->unkE = 20; + sub_8022BEC(3, 1, NULL); + r0 = 0; + r5->unkC = r0; // dunno what it's doing because it's already in case 0 + return 0; + case 1: + DisplayYesNoMenuDefaultYes(); + break; + case 2: + if ((r4 = Menu_ProcessInputNoWrapClearOnChoose()) != -2) + { + memset(r5->unk40.unk2, 0, sizeof(r5->unk40.unk2)); + if (r4 == 0) + { + if (HasAtLeastOneBerry()) + r5->unk14 = 0; + else + r5->unk14 = 3; + } + else + { + r5->unk14 = 1; + } + ClearDialogWindowAndFrame(0, 1); + sub_8024644(r6, 8, 0, 0, 0); + r5->unkE = 21; + sub_8022BEC(3, 1, NULL); + r5->unkC = 0; + } + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_80242E0(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +{ + u8 r5 = 0; + + switch (r4->unkC) + { + case 0: + sub_8010434(); + break; + case 1: + if (!IsLinkTaskFinished()) + return 0; + r4->unk40.unk2[0] = r4->unk14; + r4->unk40.unkE.unk0 = 0; + SendBlock(0, r4->unk40.unk2, sizeof(u16)); + break; + case 2: + if (!IsLinkTaskFinished()) + return 0; + r4->unk10 = 0; + break; + case 3: + if (GetBlockReceivedStatus() != gUnknown_082F4448[r4->unk9 - 2]) + return 0; + for (; r5 < r4->unk9; ++r5) + r4->unk40.unkE.unk0 += gBlockRecvBuffer[r5][0]; + if (r4->unk40.unkE.unk0 != 0) + sub_8022BEC(23, 1, NULL); + else + sub_8022BEC(22, 1, NULL); + ResetBlockReceivedFlags(); + r4->unk40.unk2[0] = 0; + r4->unk40.unkE.unk0 = 0; + r4->unk10 = 0; + r4->unkC = 0; + return 0; + } + ++r4->unkC; + return 0; +} + +u32 sub_80243BC(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +{ + switch (r5->unkC) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 0x10, RGB_BLACK); + UpdatePaletteFade(); + break; + case 1: + if (UpdatePaletteFade()) + return 0; + break; + case 2: + ClearDialogWindowAndFrame(0, 1); + sub_8021488(r5); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + UpdatePaletteFade(); + break; + case 3: + if (UpdatePaletteFade()) + return 0; + sub_8022BEC(7, 1, NULL); + r5->unk12 = 3; + r5->unkC = 0; + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_8024444(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +{ + switch (r5->unkC) + { + case 0: + DrawDialogueFrame(0, 0); + if (r5->unk14 == 3) + AddTextPrinterParameterized2(0, 1, gUnknown_082F32A4[5], r5->unkB, 0, 2, 1, 3); + else + AddTextPrinterParameterized2(0, 1, gUnknown_082F32A4[6], r5->unkB, 0, 2, 1, 3); + CopyWindowToVram(0, 3); + break; + case 1: + if (IsTextPrinterActive(0)) + return 0; + r5->unk138.unk0 = 120; + break; + case 2: + if (r5->unk138.unk0 != 0) + --r5->unk138.unk0; + else + { + sub_8022BEC(24, 1, NULL); + r5->unkC = 0; + } + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_8024508(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +{ + switch (r5->unkC) + { + case 0: + sub_8010434(); + break; + case 1: + if (!IsLinkTaskFinished()) + return 0; + sub_800AC34(); + break; + case 2: + if (gReceivedRemoteLinkPlayers != 0) + return 0; + r5->unkE = 25; + sub_8022BEC(5, 1, NULL); + r5->unkC = 2; // ??? + return 0; + } + ++r5->unkC; + return 0; +} + +u32 sub_8024568(__attribute__((unused)) struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1) +{ + sub_8020C0C(NULL); + return 0; +} + +void sub_8024578(struct BerryCrushGame *r4) +{ + u8 r5 = 0; + + IncrementGameStat(GAME_STAT_51); + r4->unkD = 0; + r4->unk10 = 0; + r4->unk12 = 2; + r4->unk14 = 0; + r4->unk1C = 0; + r4->unk18 = 0; + r4->unk1A = 0; + r4->unk20 = 0; + r4->unk24 = 0; + r4->unk25_0 = 0; + r4->unk25_1 = 0; + r4->unk25_2 = 0; + r4->unk25_3 = 0; + r4->unk25_4 = 0; + r4->unk25_5 = 0; + r4->unk26 = 0; + r4->unk28 = 0; + r4->unk2E = 0; + r4->unk32 = -1; + r4->unk30 = 0; + r4->unk34 = 0; + for (; r5 < 5; ++r5) // why is it 5 instead of 4? fillerBC isn't sufficient for one player + { + r4->unk68.as_four_players.others[r5].unk0 = -1; + r4->unk68.as_four_players.others[r5].unk2 = 0; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[0] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[1] = 1; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[2] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[3] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[4] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_hwords[5] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_2d_bytes[1][4] = 0; + r4->unk68.as_four_players.others[r5].unk4.as_2d_bytes[1][5] = 0; + } +} + +#ifdef NONMATCHING +void sub_8024604(u8 *r0, u32 r1, s32 r2, u32 r3, u32 r5, u32 r6, u32 r4) +{ + u8 sp[8]; + u8 *p; + + 1[(u32 *)sp] = r2; + 0[(u16 *)sp] = r4; + p = &sp[4]; + r0[0] = p[0]; + r0[1] = p[1]; + r0[2] = p[2]; + r0[3] = p[3]; + r0[4] = r3; + r0[5] = r5; + r0[6] = r6; + r0[7] = sp[0]; + r0[8] = sp[1]; + r0[9] = r1; +} +#else +NAKED +void sub_8024604(u8 *r0, u32 r1, s32 r2, u32 r3, u32 r5, u32 r6, u32 r4) +{ + asm_unified("\n\ + push {r4-r6,lr}\n\ + sub sp, 0x8\n\ + str r2, [sp, 0x4]\n\ + ldr r5, [sp, 0x18]\n\ + ldr r6, [sp, 0x1C]\n\ + ldr r4, [sp, 0x20]\n\ + mov r2, sp\n\ + strh r4, [r2]\n\ + add r4, sp, 0x4\n\ + ldrb r2, [r4]\n\ + strb r2, [r0]\n\ + ldrb r2, [r4, 0x1]\n\ + strb r2, [r0, 0x1]\n\ + ldrb r2, [r4, 0x2]\n\ + strb r2, [r0, 0x2]\n\ + ldrb r2, [r4, 0x3]\n\ + strb r2, [r0, 0x3]\n\ + strb r3, [r0, 0x4]\n\ + strb r5, [r0, 0x5]\n\ + strb r6, [r0, 0x6]\n\ + mov r2, sp\n\ + ldrb r2, [r2]\n\ + strb r2, [r0, 0x7]\n\ + mov r2, sp\n\ + ldrb r2, [r2, 0x1]\n\ + strb r2, [r0, 0x8]\n\ + strb r1, [r0, 0x9]\n\ + add sp, 0x8\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0"); +} +#endif + +void sub_8024644(u8 *r0, u32 r1, u32 r2, u32 r3, u32 r5) +{ + u8 sp[4]; + + 0[(u16 *)sp] = r3; + r0[0] = r1; + r0[1] = r2; + r0[2] = sp[0]; + r0[3] = sp[1]; + r0[4] = r5; +}