Decompiled 5 functions

Was unable to decompile sub_81C79BC.
This commit is contained in:
Phlosioneer 2019-02-14 16:30:52 -05:00
parent d41c597f90
commit cb800e4708
2 changed files with 202 additions and 278 deletions

View File

@ -5,267 +5,6 @@
.text
thumb_func_start sub_81C79BC
sub_81C79BC: @ 81C79BC
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
str r0, [sp]
str r1, [sp, 0x4]
mov r10, r2
str r3, [sp, 0x8]
ldr r0, [sp, 0x2C]
cmp r0, 0
bne _081C79E4
ldr r2, =0x001fffff
mov r1, r10
ands r2, r1
ldr r0, [sp]
b _081C79F4
.pool
_081C79E4:
ldr r2, [sp, 0x2C]
ldr r0, [sp, 0x8]
cmp r2, r0
blt _081C7A00
ldr r2, =0x001fffff
mov r1, r10
ands r2, r1
ldr r0, [sp, 0x4]
_081C79F4:
ldr r1, [sp, 0x30]
bl CpuSet
b _081C7AAE
.pool
_081C7A00:
movs r2, 0x1
negs r2, r2
add r10, r2
b _081C7AA6
_081C7A08:
ldr r1, [sp]
ldrh r0, [r1]
movs r2, 0x1F
mov r9, r2
mov r1, r9
ands r1, r0
mov r9, r1
lsls r0, 16
lsrs r2, r0, 21
movs r1, 0x1F
ands r1, r2
mov r8, r1
lsrs r7, r0, 26
movs r2, 0x1F
ands r7, r2
ldr r0, [sp, 0x4]
ldrh r4, [r0]
movs r0, 0x1F
ands r0, r4
mov r1, r9
subs r0, r1
lsls r0, 8
ldr r1, [sp, 0x8]
bl __divsi3
ldr r2, [sp, 0x2C]
adds r6, r0, 0
muls r6, r2
asrs r6, 8
lsls r4, 16
lsrs r0, r4, 21
movs r1, 0x1F
ands r0, r1
mov r2, r8
subs r0, r2
lsls r0, 8
ldr r1, [sp, 0x8]
bl __divsi3
ldr r1, [sp, 0x2C]
adds r5, r0, 0
muls r5, r1
asrs r5, 8
lsrs r4, 26
movs r2, 0x1F
ands r4, r2
subs r4, r7
lsls r4, 8
adds r0, r4, 0
ldr r1, [sp, 0x8]
bl __divsi3
ldr r1, [sp, 0x2C]
muls r0, r1
asrs r0, 8
add r6, r9
movs r2, 0x1F
ands r6, r2
add r5, r8
ands r5, r2
adds r0, r7, r0
ands r0, r2
lsls r0, 10
lsls r5, 5
orrs r0, r5
orrs r0, r6
ldr r1, [sp, 0x30]
strh r0, [r1]
ldr r2, [sp]
adds r2, 0x2
str r2, [sp]
ldr r0, [sp, 0x4]
adds r0, 0x2
str r0, [sp, 0x4]
adds r1, 0x2
str r1, [sp, 0x30]
movs r1, 0x1
negs r1, r1
add r10, r1
_081C7AA6:
movs r0, 0x1
negs r0, r0
cmp r10, r0
bne _081C7A08
_081C7AAE:
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81C79BC
thumb_func_start sub_81C7AC0
sub_81C7AC0: @ 81C7AC0
push {r4,lr}
sub sp, 0x4
adds r4, r0, 0
movs r0, 0
bl sub_81C763C
cmp r4, 0x1
beq _081C7AF0
cmp r4, 0x1
bgt _081C7ADA
cmp r4, 0
beq _081C7AE4
b _081C7B2C
_081C7ADA:
cmp r4, 0x2
beq _081C7B04
cmp r4, 0x3
beq _081C7B18
b _081C7B2C
_081C7AE4:
ldr r0, [r0, 0x14]
movs r1, 0x2
negs r1, r1
str r4, [sp]
movs r2, 0
b _081C7B10
_081C7AF0:
ldr r0, [r0, 0x14]
movs r1, 0x2
negs r1, r1
movs r2, 0
str r2, [sp]
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
b _081C7B2C
_081C7B04:
movs r0, 0x1
negs r0, r0
movs r1, 0x2
negs r1, r1
movs r2, 0
str r2, [sp]
_081C7B10:
movs r3, 0x10
bl BeginNormalPaletteFade
b _081C7B2C
_081C7B18:
movs r0, 0x1
negs r0, r0
movs r1, 0x2
negs r1, r1
movs r2, 0
str r2, [sp]
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
_081C7B2C:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_81C7AC0
thumb_func_start sub_81C7B34
sub_81C7B34: @ 81C7B34
ldr r0, =gPaletteFade
ldrb r0, [r0, 0x7]
lsrs r0, 7
bx lr
.pool
thumb_func_end sub_81C7B34
thumb_func_start sub_81C7B40
sub_81C7B40: @ 81C7B40
push {lr}
ldr r0, =0xfffefffe
movs r1, 0x10
movs r2, 0
bl BlendPalettes
pop {r0}
bx r0
.pool
thumb_func_end sub_81C7B40
thumb_func_start sub_81C7B54
sub_81C7B54: @ 81C7B54
push {r4,r5,lr}
adds r5, r0, 0
cmp r1, 0
ble _081C7B6C
adds r4, r1, 0
_081C7B5E:
adds r0, r5, 0
adds r5, 0x4
bl InitBgFromTemplate
subs r4, 0x1
cmp r4, 0
bne _081C7B5E
_081C7B6C:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_81C7B54
thumb_func_start sub_81C7B74
sub_81C7B74: @ 81C7B74
push {r4,lr}
movs r0, 0
bl sub_81C763C
adds r4, r0, 0
ldr r0, =gUnknown_0861FA08
bl InitWindows
movs r0, 0
str r0, [r4, 0x10]
bl sub_81C7BF8
ldrb r0, [r4, 0x10]
bl PutWindowTilemap
ldrb r0, [r4, 0x10]
movs r1, 0x3
bl CopyWindowToVram
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81C7B74
thumb_func_start sub_81C7BA4
sub_81C7BA4: @ 81C7BA4
push {r4,r5,lr}
@ -4420,7 +4159,7 @@ _081C9C06:
bl sub_81C7DFC
b _081C9AD6
_081C9C0E:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081C9C5C
bl sub_81C9894
@ -4884,7 +4623,7 @@ _081C9F96:
movs r0, 0
b _081C9FBE
_081C9FB0:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
beq _081C9FBC
_081C9FB8:
@ -7624,7 +7363,7 @@ _081CB4A6:
movs r0, 0
b _081CB506
_081CB4EA:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CB4FA
bl sub_81C8010
@ -8517,7 +8256,7 @@ _081CBB80:
movs r0, 0
b _081CBBB4
_081CBB9A:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CBBAA
bl sub_81C78C0
@ -10104,7 +9843,7 @@ _081CC812:
bl sub_81C7AC0
b _081CC77C
_081CC82A:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CC83A
bl sub_81C8010
@ -10290,7 +10029,7 @@ _081CC972:
movs r0, 0
b _081CC9BA
_081CC982:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CC99E
bl sub_81C7FDC
@ -13258,7 +12997,7 @@ _081CE1FC:
bl sub_81C7FA0
b _081CDFB0
_081CE218:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CE2C0
bl sub_81CDD5C
@ -13387,7 +13126,7 @@ _081CE33A:
movs r0, 0
b _081CE376
_081CE33E:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CE34E
bl sub_81C78C0
@ -15607,7 +15346,7 @@ _081CF552:
bl sub_81C7AC0
b _081CF498
_081CF55A:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CF56A
bl sub_81C8010
@ -15914,7 +15653,7 @@ _081CF764:
movs r0, 0
b _081CF792
_081CF778:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CF788
bl sub_81C78C0
@ -15948,7 +15687,7 @@ _081CF7A4:
movs r0, 0
b _081CF7C2
_081CF7B4:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
beq _081CF7C0
movs r0, 0x2
@ -16981,7 +16720,7 @@ _081CFFA4:
bl sub_81C7FA0
b _081CFF32
_081CFFDE:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081CFFEE
bl sub_81C8010
@ -17288,7 +17027,7 @@ _081D01E8:
movs r0, 0
b _081D0216
_081D01FC:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
bne _081D020C
bl sub_81C78C0
@ -17322,7 +17061,7 @@ _081D0228:
movs r0, 0
b _081D0246
_081D0238:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
beq _081D0244
movs r0, 0x2
@ -18583,7 +18322,7 @@ _081D0BE8:
movs r0, 0
b _081D0C4A
_081D0C3C:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
beq _081D0C48
_081D0C44:
@ -18614,7 +18353,7 @@ _081D0C60:
movs r0, 0
b _081D0C7E
_081D0C70:
bl sub_81C7B34
bl IsPaletteFadeActive
cmp r0, 0
beq _081D0C7C
movs r0, 0x2

View File

@ -45,6 +45,7 @@ struct UnknownStruct_sub_81C76C4 {
};
extern struct BgTemplate gUnknown_0861FA04;
extern struct WindowTemplate gUnknown_0861FA08;
extern struct UnknownStruct_0203CF40 *gUnknown_0203CF40;
extern u8 gUnknown_0203CF3C;
@ -55,9 +56,9 @@ extern void sub_81CAADC(void);
extern void sub_81C99D4(void);
extern void sub_81C7C94(void);
extern void sub_8199D98(void);
extern void sub_81C7B74(void);
extern void sub_81C7C28(void);
extern void sub_81C7D28(void);
extern void sub_81C7BF8(void);
u32 sub_81C791C(s32 a0);
@ -85,6 +86,7 @@ void sub_81C7334(void);
void sub_81C7418(void);
void sub_81C7400(void);
void sub_81C72BC(void);
void sub_81C7B74(void);
u32 sub_81C7078(u32 (*a0)(s32), u32 a1)
{
@ -627,3 +629,186 @@ void sub_81C795C(struct PaletteDescriptor *palettes) {
void sub_81C7990(u32 a0, u16 a1) {
CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16));
}
__attribute__((naked))
void sub_81C79BC(u16* a0, u16* a1, u32 a2, u32 a3, u32 unused, u32 a5, u32 a6) {
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0xC\n\
str r0, [sp]\n\
str r1, [sp, 0x4]\n\
mov r10, r2\n\
str r3, [sp, 0x8]\n\
ldr r0, [sp, 0x2C]\n\
cmp r0, 0\n\
bne _081C79E4\n\
ldr r2, =0x001fffff\n\
mov r1, r10\n\
ands r2, r1\n\
ldr r0, [sp]\n\
b _081C79F4\n\
.pool\n\
_081C79E4:\n\
ldr r2, [sp, 0x2C]\n\
ldr r0, [sp, 0x8]\n\
cmp r2, r0\n\
blt _081C7A00\n\
ldr r2, =0x001fffff\n\
mov r1, r10\n\
ands r2, r1\n\
ldr r0, [sp, 0x4]\n\
_081C79F4:\n\
ldr r1, [sp, 0x30]\n\
bl CpuSet\n\
b _081C7AAE\n\
.pool\n\
_081C7A00:\n\
movs r2, 0x1\n\
negs r2, r2\n\
add r10, r2\n\
b _081C7AA6\n\
_081C7A08:\n\
ldr r1, [sp]\n\
ldrh r0, [r1]\n\
movs r2, 0x1F\n\
mov r9, r2\n\
mov r1, r9\n\
ands r1, r0\n\
mov r9, r1\n\
lsls r0, 16\n\
lsrs r2, r0, 21\n\
movs r1, 0x1F\n\
ands r1, r2\n\
mov r8, r1\n\
lsrs r7, r0, 26\n\
movs r2, 0x1F\n\
ands r7, r2\n\
ldr r0, [sp, 0x4]\n\
ldrh r4, [r0]\n\
movs r0, 0x1F\n\
ands r0, r4\n\
mov r1, r9\n\
subs r0, r1\n\
lsls r0, 8\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r2, [sp, 0x2C]\n\
adds r6, r0, 0\n\
muls r6, r2\n\
asrs r6, 8\n\
lsls r4, 16\n\
lsrs r0, r4, 21\n\
movs r1, 0x1F\n\
ands r0, r1\n\
mov r2, r8\n\
subs r0, r2\n\
lsls r0, 8\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r1, [sp, 0x2C]\n\
adds r5, r0, 0\n\
muls r5, r1\n\
asrs r5, 8\n\
lsrs r4, 26\n\
movs r2, 0x1F\n\
ands r4, r2\n\
subs r4, r7\n\
lsls r4, 8\n\
adds r0, r4, 0\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r1, [sp, 0x2C]\n\
muls r0, r1\n\
asrs r0, 8\n\
add r6, r9\n\
movs r2, 0x1F\n\
ands r6, r2\n\
add r5, r8\n\
ands r5, r2\n\
adds r0, r7, r0\n\
ands r0, r2\n\
lsls r0, 10\n\
lsls r5, 5\n\
orrs r0, r5\n\
orrs r0, r6\n\
ldr r1, [sp, 0x30]\n\
strh r0, [r1]\n\
ldr r2, [sp]\n\
adds r2, 0x2\n\
str r2, [sp]\n\
ldr r0, [sp, 0x4]\n\
adds r0, 0x2\n\
str r0, [sp, 0x4]\n\
adds r1, 0x2\n\
str r1, [sp, 0x30]\n\
movs r1, 0x1\n\
negs r1, r1\n\
add r10, r1\n\
_081C7AA6:\n\
movs r0, 0x1\n\
negs r0, r0\n\
cmp r10, r0\n\
bne _081C7A08\n\
_081C7AAE:\n\
add sp, 0xC\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\
.syntax divided");
}
void sub_81C7AC0(s32 a0) {
u32 *v1;
v1 = sub_81C763C(0);
switch (a0) {
case 0:
BeginNormalPaletteFade(v1[5], -2, 0, 16, a0);
break;
case 1:
BeginNormalPaletteFade(v1[5], -2, 16, 0, 0);
break;
case 2:
BeginNormalPaletteFade(-1, -2, 0, 16, 0);
break;
case 3:
BeginNormalPaletteFade(-1, -2, 16, 0, 0);
break;
}
}
bool32 IsPaletteFadeActive(void) {
return gPaletteFade.active;
}
void sub_81C7B40(void) {
BlendPalettes(0xFFFEFFFE, 16, 0);
}
void sub_81C7B54(const struct BgTemplate *a0, s32 a1) {
s32 i;
if (a1 <= 0) {
return;
}
for (i = a1; i != 0; i--) {
InitBgFromTemplate(a0++);
}
}
void sub_81C7B74(void) {
u32 *v1;
v1 = sub_81C763C(0);
InitWindows(&gUnknown_0861FA08);
v1[4] = 0;
sub_81C7BF8();
PutWindowTilemap(v1[4]);
CopyWindowToVram(v1[4], 3); // TODO: Use a defined constant here.
}