Decompile 4 berry crush functions

This commit is contained in:
DizzyEggg 2019-07-03 11:28:44 +02:00 committed by huderlem
parent 11fb13d635
commit c3733f4b95
2 changed files with 119 additions and 499 deletions

View File

@ -5,438 +5,8 @@
.text
thumb_func_start sub_80216E0
sub_80216E0: @ 80216E0
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x10
adds r6, r0, 0
str r1, [sp]
movs r0, 0
str r0, [sp, 0x4]
movs r1, 0x4E
adds r1, r6
mov r10, r1
mov r9, r0
ldrb r2, [r6, 0x9]
cmp r0, r2
bcs _080217AE
ldr r7, =gUnknown_082F41CC
_08021704:
mov r3, r10
ldrh r0, [r3, 0xA]
mov r4, r9
lsls r1, r4, 1
add r1, r9
asrs r0, r1
lsls r0, 16
movs r1, 0xE0
lsls r1, 11
ands r1, r0
lsrs r1, 16
mov r8, r1
cmp r1, 0
beq _0802179E
ldr r0, [sp, 0x4]
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x4]
movs r0, 0x4
ands r0, r1
cmp r0, 0
beq _08021748
lsls r4, 2
ldr r5, [sp]
adds r5, 0x24
adds r0, r5, r4
ldr r0, [r0]
movs r1, 0x1
bl StartSpriteAnim
b _0802175A
.pool
_08021748:
mov r0, r9
lsls r4, r0, 2
ldr r5, [sp]
adds r5, 0x24
adds r0, r5, r4
ldr r0, [r0]
movs r1, 0
bl StartSpriteAnim
_0802175A:
adds r3, r5, r4
ldr r2, [r3]
adds r2, 0x3E
ldrb r0, [r2]
movs r4, 0x5
negs r4, r4
adds r1, r4, 0
ands r0, r1
strb r0, [r2]
ldr r2, [r3]
adds r2, 0x2C
ldrb r0, [r2]
subs r4, 0x3C
adds r1, r4, 0
ands r0, r1
strb r0, [r2]
ldr r2, [r3]
movs r0, 0x3
mov r1, r8
ands r1, r0
mov r8, r1
subs r1, 0x1
lsls r1, 1
adds r0, r1, r7
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
strh r0, [r2, 0x24]
ldr r2, [r3]
ldr r3, =gUnknown_082F41CC+1
adds r1, r3
movs r0, 0
ldrsb r0, [r1, r0]
strh r0, [r2, 0x26]
_0802179E:
mov r0, r9
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
mov r9, r0
ldrb r4, [r6, 0x9]
cmp r9, r4
bcc _08021704
_080217AE:
ldr r0, [sp, 0x4]
cmp r0, 0
bne _080217C0
adds r2, r6, 0
adds r2, 0x25
ldrb r1, [r2]
b _0802189C
.pool
_080217C0:
ldrh r0, [r6, 0x28]
movs r1, 0x3
bl __umodsi3
lsls r0, 24
lsrs r0, 24
mov r8, r0
mov r1, r8
str r1, [sp, 0x8]
movs r2, 0
mov r9, r2
mov r3, r10
ldrh r1, [r3, 0xC]
lsls r0, r1, 1
adds r0, 0x3
adds r6, 0x25
str r6, [sp, 0xC]
adds r3, r1, 0
cmp r9, r0
bge _08021890
_080217E8:
mov r4, r9
lsls r1, r4, 2
ldr r0, [sp]
adds r0, 0x4C
adds r7, r0, r1
ldr r2, [r7]
adds r0, r2, 0
adds r0, 0x3E
ldrb r1, [r0]
movs r0, 0x4
ands r0, r1
cmp r0, 0
beq _0802187E
ldr r0, =sub_8022B28
str r0, [r2, 0x1C]
lsls r1, r4, 1
ldr r3, =gUnknown_082F41CC+6
adds r0, r1, r3
movs r4, 0
ldrsb r4, [r0, r4]
adds r0, r4, 0
adds r0, 0x78
strh r0, [r2, 0x20]
ldr r2, [r7]
ldr r0, =gUnknown_082F41CC+7
adds r1, r0
movs r6, 0
ldrsb r6, [r1, r6]
mov r1, r8
lsls r0, r1, 2
subs r0, 0x88
subs r0, r6, r0
strh r0, [r2, 0x22]
ldr r5, [r7]
ldr r2, [sp, 0x8]
lsls r1, r2, 2
adds r0, r4, 0
bl __divsi3
adds r4, r0
strh r4, [r5, 0x24]
ldr r0, [r7]
strh r6, [r0, 0x26]
mov r3, r10
ldrb r1, [r3, 0x4]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _08021860
ldr r0, [r7]
movs r1, 0x1
bl StartSpriteAnim
b _08021868
.pool
_08021860:
ldr r0, [r7]
movs r1, 0
bl StartSpriteAnim
_08021868:
mov r0, r8
adds r0, 0x1
lsls r0, 16
lsrs r0, 16
mov r8, r0
mov r4, r10
ldrh r3, [r4, 0xC]
cmp r0, 0x3
bls _0802187E
movs r0, 0
mov r8, r0
_0802187E:
mov r0, r9
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
mov r9, r0
lsls r0, r3, 1
adds r0, 0x3
cmp r9, r0
blt _080217E8
_08021890:
ldr r2, [sp, 0xC]
ldrb r1, [r2]
movs r0, 0x4
ands r0, r1
cmp r0, 0
beq _080218A6
_0802189C:
movs r0, 0x5
negs r0, r0
ands r0, r1
strb r0, [r2]
b _080218C4
_080218A6:
ldr r3, [sp, 0x4]
cmp r3, 0x1
bne _080218B4
movs r0, 0x4E
bl PlaySE
b _080218BA
_080218B4:
movs r0, 0x4D
bl PlaySE
_080218BA:
ldr r4, [sp, 0xC]
ldrb r0, [r4]
movs r1, 0x4
orrs r0, r1
strb r0, [r4]
_080218C4:
add sp, 0x10
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_80216E0
thumb_func_start sub_80218D4
sub_80218D4: @ 80218D4
push {r4-r7,lr}
adds r5, r0, 0
adds r6, r1, 0
movs r2, 0
ldrb r0, [r5, 0x9]
cmp r2, r0
bcs _08021906
adds r4, r6, 0
adds r4, 0x24
movs r7, 0x4
adds r3, r0, 0
_080218EA:
lsls r0, r2, 2
adds r0, r4, r0
ldr r0, [r0]
adds r0, 0x3E
ldrb r1, [r0]
adds r0, r7, 0
ands r0, r1
cmp r0, 0
beq _08021920
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, r3
bcc _080218EA
_08021906:
movs r2, 0
adds r3, r6, 0
adds r3, 0x4C
movs r4, 0x4
_0802190E:
lsls r0, r2, 2
adds r0, r3, r0
ldr r0, [r0]
adds r0, 0x3E
ldrb r1, [r0]
adds r0, r4, 0
ands r0, r1
cmp r0, 0
bne _08021924
_08021920:
movs r0, 0
b _0802193C
_08021924:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0xA
bls _0802190E
movs r1, 0x2C
ldrsh r0, [r5, r1]
cmp r0, 0
beq _0802193A
movs r0, 0
strh r0, [r5, 0x2C]
_0802193A:
movs r0, 0x1
_0802193C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80218D4
thumb_func_start sub_8021944
sub_8021944: @ 8021944
push {r4-r7,lr}
adds r6, r0, 0
lsls r4, r1, 16
lsrs r4, 16
movs r7, 0
movs r5, 0xE1
lsls r5, 4
adds r0, r4, 0
adds r1, r5, 0
bl __udivsi3
strh r0, [r6, 0x4]
adds r0, r4, 0
adds r1, r5, 0
bl __umodsi3
lsls r0, 16
lsrs r0, 16
movs r1, 0x3C
bl __udivsi3
strh r0, [r6, 0x6]
adds r0, r4, 0
movs r1, 0x3C
bl __umodsi3
lsls r0, 24
asrs r0, 16
movs r1, 0x4
bl sub_8151534
adds r2, r7, 0
lsls r0, 16
asrs r3, r0, 16
movs r0, 0x7
mov r12, r0
ldr r5, =gUnknown_082F334C
movs r4, 0x1
_08021990:
mov r0, r12
subs r1, r0, r2
adds r0, r3, 0
asrs r0, r1
ands r0, r4
cmp r0, 0
beq _080219A6
lsls r0, r2, 2
adds r0, r5
ldr r0, [r0]
adds r7, r0
_080219A6:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x7
bls _08021990
ldr r1, =0x000f4240
adds r0, r7, 0
bl __udivsi3
strh r0, [r6, 0x8]
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8021944
thumb_func_start sub_80219C8
sub_80219C8: @ 80219C8
push {r4-r6,lr}
mov r6, r8
push {r6}
sub sp, 0xC
adds r6, r0, 0
adds r4, r1, 0
adds r5, r2, 0
mov r8, r3
lsls r6, 24
lsrs r6, 24
lsls r4, 24
lsrs r4, 24
lsls r5, 24
lsrs r5, 24
movs r2, 0x1
negs r2, r2
movs r0, 0x2
mov r1, r8
bl GetStringWidth
lsls r4, 2
lsrs r0, 1
subs r4, r0
lsls r4, 24
lsrs r4, 24
lsls r0, r5, 1
adds r0, r5
ldr r1, =gUnknown_082F32D8
adds r0, r1
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
mov r0, r8
str r0, [sp, 0x8]
adds r0, r6, 0
movs r1, 0x2
adds r2, r4, 0
movs r3, 0
bl AddTextPrinterParameterized3
add sp, 0xC
pop {r3}
mov r8, r3
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80219C8
thumb_func_start sub_8021A28
sub_8021A28: @ 8021A28

View File

@ -55,7 +55,10 @@ struct BerryCrushGame_138_C
struct BerryCrushGame_138
{
u8 filler0[0xC];
u8 filler0[0x4];
u16 unk4;
u16 unk6;
u16 unk8;
struct BerryCrushGame_138_C *unkC[5];
u8 filler1C[0x4];
struct Sprite *unk24[5];
@ -105,7 +108,7 @@ struct BerryCrushGame
u8 filler26[0x2];
u16 unk28;
u16 unk2A;
u16 unk2C;
s16 unk2C;
u8 filler2E[0x8];
u8 unk36[0xA];
struct BerryCrushGame_40 unk40;
@ -149,6 +152,8 @@ extern const struct SpriteTemplate gUnknown_082F436C;
extern const u16 gUnknown_082F41E8[];
extern const s8 gUnknown_082F41CC[][2];
extern const s8 gUnknown_082F41D2[][2];
extern const u32 gUnknown_082F334C[];
extern const u8 gUnknown_082F32D8[][3];
struct BerryCrushGame *sub_8020C00(void)
{
@ -700,76 +705,121 @@ void sub_80216A8(struct BerryCrushGame *arg0)
}
}
// void sub_80216E0(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1)
// {
// u8 sp4;
// struct BerryCrushGame_4E *var4E;
// u8 i;
// u16 var0;
void sub_80216E0(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1)
{
u8 sp4;
struct BerryCrushGame_4E *var4E;
u8 i;
u16 var, var2;
// sp4 = 0;
// var4E = &arg0->unk40.unkE;
// for (i = 0; i < arg0->unk9; i++)
// {
// var0 = var4E->unkA >> (i * 3);
// var0 &= 7;
// if (var0)
// {
// int offset;
// sp4++;
// if (var0 & 0x4)
// StartSpriteAnim(arg1->unk24[i], 1);
// else
// StartSpriteAnim(arg1->unk24[i], 0);
sp4 = 0;
var4E = &arg0->unk40.unkE;
for (i = 0; i < arg0->unk9; i++)
{
var = var4E->unkA >> (i * 3);
var &= 7;
if (var)
{
sp4++;
if (var & 0x4)
StartSpriteAnim(arg1->unk24[i], 1);
else
StartSpriteAnim(arg1->unk24[i], 0);
// arg1->unk24[i]->invisible = 0;
// arg1->unk24[i]->animPaused = 0;
// offset = (var0 % 4) - 1;
// arg1->unk24[i]->pos2.x = gUnknown_082F41CC[offset][0];
// arg1->unk24[i]->pos2.y = gUnknown_082F41CC[offset][1];
// }
// }
arg1->unk24[i]->invisible = 0;
arg1->unk24[i]->animPaused = 0;
arg1->unk24[i]->pos2.x = gUnknown_082F41CC[(var % 4) - 1][0];
arg1->unk24[i]->pos2.y = gUnknown_082F41CC[(var % 4) - 1][1];
}
}
// if (sp4 == 0)
// {
// arg0->unk25_2 = 0;
// }
// else
// {
// u8 var3 = arg0->unk28 % 3;
// u16 var2 = var3;
// for (i = 0; i < var4E->unkC * 2 + 3; i++)
// {
// if (arg1->unk4C[i]->invisible)
// {
// arg1->unk4C[i]->callback = sub_8022B28;
// arg1->unk4C[i]->pos1.x = gUnknown_082F41D2[i][0] + 120;
// arg1->unk4C[i]->pos1.y = gUnknown_082F41D2[i][1] + (136 - var2 * 4);
// arg1->unk4C[i]->pos2.x = gUnknown_082F41D2[i][0] / (var3 * 4);
// arg1->unk4C[i]->pos2.y = gUnknown_082F41D2[i][1];
// if (var4E->unk4 & 0x2)
// StartSpriteAnim(arg1->unk4C[i], 1);
// else
// StartSpriteAnim(arg1->unk4C[i], 0);
if (sp4 == 0)
{
arg0->unk25_2 = 0;
}
else
{
var = (u8)(arg0->unk28 % 3);
var2 = var;
for (i = 0; i < var4E->unkC * 2 + 3; i++)
{
if (arg1->unk4C[i]->invisible)
{
arg1->unk4C[i]->callback = sub_8022B28;
arg1->unk4C[i]->pos1.x = gUnknown_082F41D2[i][0] + 120;
arg1->unk4C[i]->pos1.y = gUnknown_082F41D2[i][1] + 136 - (var * 4);
arg1->unk4C[i]->pos2.x = gUnknown_082F41D2[i][0] + (gUnknown_082F41D2[i][0] / (var2 * 4));
arg1->unk4C[i]->pos2.y = gUnknown_082F41D2[i][1];
if (var4E->unk4 & 0x2)
StartSpriteAnim(arg1->unk4C[i], 1);
else
StartSpriteAnim(arg1->unk4C[i], 0);
// var2++;
// if (var2 > 3)
// var2 = 0;
// }
// }
var++;
if (var > 3)
var = 0;
}
}
// if (arg0->unk25_2)
// {
// arg0->unk25_2 = 0;
// }
// else
// {
// if (sp4 == 1)
// PlaySE(SE_TOY_DANGO);
// else
// PlaySE(SE_TOY_KABE);
if (arg0->unk25_2)
{
arg0->unk25_2 = 0;
}
else
{
if (sp4 == 1)
PlaySE(SE_TOY_DANGO);
else
PlaySE(SE_TOY_KABE);
// arg0->unk25_2 = 1;
// }
// }
// }
arg0->unk25_2 = 1;
}
}
}
bool32 sub_80218D4(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1)
{
u8 i;
for (i = 0; i < arg0->unk9; i++)
{
if (!arg1->unk24[i]->invisible)
return FALSE;
}
for (i = 0; i < 11; i++)
{
if (!arg1->unk4C[i]->invisible)
return FALSE;
}
if (arg0->unk2C != 0)
arg0->unk2C = 0;
return TRUE;
}
void sub_8021944(struct BerryCrushGame_138 *arg0, u16 arg1)
{
u8 i = 0;
u32 r7 = 0;
s16 r3 = 0;
arg0->unk4 = arg1 / 3600;
arg0->unk6 = (arg1 % 3600) / 60;
r3 = sub_8151534((arg1 % 60) << 8, 4);
for (i = 0; i < 8; i++)
{
if ((r3 >> (7 - i)) & 1)
r7 += gUnknown_082F334C[i];
}
arg0->unk8 = r7 / 1000000;
}
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, gUnknown_082F32D8[colorId], 0, string);
}