more code_0800ECAC

This commit is contained in:
Zhengwen Jiang 2023-12-01 13:11:01 -06:00 committed by Egor Ananyin
parent daa9c778bd
commit accaf5add9
4 changed files with 163 additions and 686 deletions

View File

@ -3,690 +3,6 @@
.syntax unified
thumb_func_start sub_08013F48
sub_08013F48: @ 0x08013F48
push {r4, r5, r6, r7, lr}
sub sp, #4
adds r6, r0, #0
lsls r4, r1, #0x10
lsrs r4, r4, #0x10
mov r5, sp
adds r5, #1
adds r0, r4, #0
mov r1, sp
adds r2, r5, #0
bl sub_08002D40
mov r0, sp
ldrb r2, [r0]
ldrb r3, [r5]
ldr r1, _08013FA8 @ =gUnk_08D6CD0C
lsls r0, r4, #2
adds r0, r0, r1
ldr r7, [r0]
ldr r0, [r6, #0x14]
movs r5, #0xbf
lsls r5, r5, #3
adds r0, r0, r5
ldrh r0, [r0]
lsls r0, r0, #2
adds r0, r0, r1
ldr r5, [r0]
ldr r0, [r6, #0x40]
adds r1, r4, #0
bl sub_080551FC
lsls r0, r0, #0x18
cmp r0, #0
beq _08013FB8
adds r0, r5, #0
adds r0, #0x46
adds r1, r7, #0
adds r1, #0x46
ldrb r0, [r0]
ldrb r1, [r1]
cmp r0, r1
bne _08013FAC
adds r1, r6, #0
adds r1, #0xb0
ldrh r0, [r1]
adds r0, #1
b _08013FB2
.align 2, 0
_08013FA8: .4byte gUnk_08D6CD0C
_08013FAC:
adds r1, r6, #0
adds r1, #0xb0
movs r0, #0
_08013FB2:
strh r0, [r1]
movs r0, #1
b _08013FBA
_08013FB8:
movs r0, #0
_08013FBA:
add sp, #4
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
thumb_func_start sub_08013FC4
sub_08013FC4: @ 0x08013FC4
push {r4, r5, r6, r7, lr}
mov r7, sb
mov r6, r8
push {r6, r7}
lsls r1, r1, #0x10
lsrs r6, r1, #0x10
ldr r1, _08014018 @ =gUnk_08D6CD0C
lsls r0, r6, #2
adds r0, r0, r1
ldr r0, [r0]
ldr r1, _0801401C @ =gUnk_08D6DCAC
adds r0, #0x46
ldrb r0, [r0]
lsls r0, r0, #2
adds r0, r0, r1
ldr r5, [r0]
movs r2, #0
ldrh r3, [r5, #4]
cmp r2, r3
bhs _0801400C
ldr r0, [r5]
ldrh r1, [r0]
adds r4, r0, #0
cmp r1, r6
beq _0801400C
adds r1, r4, #0
_08013FF8:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, r3
bhs _0801400C
lsls r0, r2, #2
adds r0, r0, r1
ldrh r0, [r0]
cmp r0, r6
bne _08013FF8
_0801400C:
ldrh r3, [r5, #4]
adds r7, r3, #0
cmp r2, r7
bne _08014024
ldr r0, _08014020 @ =0x0000FFFF
b _080140A2
.align 2, 0
_08014018: .4byte gUnk_08D6CD0C
_0801401C: .4byte gUnk_08D6DCAC
_08014020: .4byte 0x0000FFFF
_08014024:
ldr r2, _08014084 @ =gRngVal
ldr r1, [r2]
ldr r0, _08014088 @ =0x00196225
muls r0, r1, r0
ldr r1, _0801408C @ =0x3C6EF35F
adds r0, r0, r1
str r0, [r2]
lsrs r1, r0, #0x10
movs r0, #0x1f
ldr r2, _08014090 @ =0x0000FFFF
ands r1, r0
ldr r4, [r5]
cmp r1, r2
beq _0801409C
adds r5, r7, #0
mov sb, r2
mov r8, r4
lsls r3, r3, #0x10
mov ip, r3
_0801404A:
subs r7, r1, #1
_0801404C:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, r5
bhs _0801407E
lsls r0, r2, #2
add r0, r8
ldrh r0, [r0]
cmp r0, r6
beq _0801407A
mov r0, ip
lsrs r3, r0, #0x10
adds r1, r4, #0
_08014066:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, r3
bhs _0801407E
lsls r0, r2, #2
adds r0, r0, r1
ldrh r0, [r0]
cmp r0, r6
bne _08014066
_0801407A:
cmp r2, r5
blo _08014094
_0801407E:
ldr r2, _08014090 @ =0x0000FFFF
b _0801404C
.align 2, 0
_08014084: .4byte gRngVal
_08014088: .4byte 0x00196225
_0801408C: .4byte 0x3C6EF35F
_08014090: .4byte 0x0000FFFF
_08014094:
lsls r0, r7, #0x10
lsrs r1, r0, #0x10
cmp r1, sb
bne _0801404A
_0801409C:
lsls r0, r2, #2
adds r0, r0, r4
ldrh r0, [r0, #2]
_080140A2:
pop {r3, r4}
mov r8, r3
mov sb, r4
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
thumb_func_start sub_080140B0
sub_080140B0: @ 0x080140B0
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
mov r5, r8
push {r5, r6, r7}
sub sp, #4
str r0, [sp]
lsls r1, r1, #0x10
lsrs r7, r1, #0x10
ldr r1, _08014130 @ =gUnk_08D6CD0C
lsls r0, r7, #2
adds r0, r0, r1
ldr r4, [r0]
movs r2, #0
adds r0, r4, #0
adds r0, #0x48
ldrb r0, [r0]
cmp r2, r0
bhs _0801410C
mov sb, r1
ldr r6, [r4]
adds r5, r0, #0
movs r0, #0x80
mov r8, r0
_080140E0:
lsls r0, r2, #2
adds r0, r0, r6
ldr r1, [r0]
ldrh r0, [r1]
lsls r0, r0, #2
add r0, sb
ldr r3, [r0]
ldrh r0, [r1, #2]
cmp r0, #1
bls _08014102
adds r0, r3, #0
adds r0, #0x47
ldrb r1, [r0]
mov r0, r8
ands r0, r1
cmp r0, #0
beq _0801410C
_08014102:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, r5
blo _080140E0
_0801410C:
adds r0, r4, #0
adds r0, #0x48
mov sl, r0
ldrb r1, [r0]
cmp r2, r1
bne _0801413E
ldr r0, [sp]
adds r1, r7, #0
bl sub_08013FC4
lsls r0, r0, #0x10
lsrs r1, r0, #0x10
ldr r0, _08014134 @ =0x0000FFFF
cmp r1, r0
beq _08014138
adds r0, r1, #0
b _080141D8
.align 2, 0
_08014130: .4byte gUnk_08D6CD0C
_08014134: .4byte 0x0000FFFF
_08014138:
ldr r1, [sp]
ldrh r0, [r1, #0x18]
b _080141D8
_0801413E:
ldr r2, _080141B0 @ =gRngVal
ldr r1, [r2]
ldr r0, _080141B4 @ =0x00196225
muls r0, r1, r0
ldr r1, _080141B8 @ =0x3C6EF35F
adds r0, r0, r1
str r0, [r2]
lsrs r1, r0, #0x10
movs r0, #0x1f
ldr r2, _080141BC @ =0x0000FFFF
ands r1, r0
ldr r4, [r4]
mov r8, r4
cmp r1, r2
beq _080141D0
mov r7, sl
ldrb r0, [r7]
mov sb, r0
_08014162:
subs r1, #1
mov ip, r1
_08014166:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, sb
bhs _080141AA
mov r4, r8
ldr r6, _080141C0 @ =gUnk_08D6CD0C
mov r1, sl
ldrb r3, [r1]
movs r5, #0x80
_0801417A:
lsls r0, r2, #2
adds r0, r0, r4
ldr r1, [r0]
ldrh r0, [r1, #2]
cmp r0, #1
bls _0801419A
ldrh r0, [r1]
lsls r0, r0, #2
adds r0, r0, r6
ldr r0, [r0]
adds r0, #0x47
ldrb r1, [r0]
adds r0, r5, #0
ands r0, r1
cmp r0, #0
beq _080141A4
_0801419A:
adds r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, r3
blo _0801417A
_080141A4:
ldrb r0, [r7]
cmp r2, r0
blo _080141C4
_080141AA:
ldr r2, _080141BC @ =0x0000FFFF
b _08014166
.align 2, 0
_080141B0: .4byte gRngVal
_080141B4: .4byte 0x00196225
_080141B8: .4byte 0x3C6EF35F
_080141BC: .4byte 0x0000FFFF
_080141C0: .4byte gUnk_08D6CD0C
_080141C4:
mov r1, ip
lsls r0, r1, #0x10
lsrs r1, r0, #0x10
ldr r0, _080141E8 @ =0x0000FFFF
cmp r1, r0
bne _08014162
_080141D0:
lsls r0, r2, #2
add r0, r8
ldr r0, [r0]
ldrh r0, [r0]
_080141D8:
add sp, #4
pop {r3, r4, r5}
mov r8, r3
mov sb, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
_080141E8: .4byte 0x0000FFFF
thumb_func_start sub_080141EC
sub_080141EC: @ 0x080141EC
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
mov r5, r8
push {r5, r6, r7}
sub sp, #8
mov r8, r0
adds r5, r2, #0
lsls r1, r1, #0x10
lsrs r1, r1, #0x10
mov sb, r1
ldr r1, _080142A0 @ =gUnk_08D6CD0C
mov r2, sb
lsls r0, r2, #2
adds r0, r0, r1
ldr r7, [r0]
movs r4, #0
ldrh r1, [r5]
ldr r0, _080142A4 @ =0x0000FFFF
cmp r1, r0
bne _08014254
mov r3, r8
adds r3, #0xa8
ldr r0, [r3]
cmp r0, #0
bne _0801423A
mov r1, r8
ldr r0, [r1, #0x40]
adds r0, #0x56
ldrb r0, [r0]
adds r0, #1
movs r1, #3
ands r0, r1
movs r1, #0xd4
lsls r1, r1, #1
muls r0, r1, r0
ldr r1, _080142A8 @ =gKirbys
adds r0, r0, r1
str r0, [r3]
_0801423A:
ldr r2, _080142AC @ =gCurLevelInfo
ldr r0, [r3]
adds r0, #0x56
ldrb r1, [r0]
movs r0, #0xcd
lsls r0, r0, #3
muls r0, r1, r0
adds r0, r0, r2
movs r2, #0xbf
lsls r2, r2, #3
adds r0, r0, r2
ldrh r0, [r0]
strh r0, [r5]
_08014254:
adds r0, r7, #0
adds r0, #0x47
ldrb r1, [r0]
movs r0, #8
ands r0, r1
cmp r0, #0
beq _080142D2
movs r3, #0
ldr r0, _080142B0 @ =gUnk_082DE074
adds r2, r0, #0
ldrh r0, [r2]
cmp sb, r0
bne _08014276
ldrh r0, [r5]
ldrh r1, [r2, #2]
cmp r0, r1
beq _08014296
_08014276:
adds r0, r3, #1
lsls r0, r0, #0x10
lsrs r3, r0, #0x10
cmp r3, #7
bhi _08014296
lsls r1, r3, #2
adds r0, r1, r2
ldrh r0, [r0]
cmp sb, r0
bne _08014276
adds r0, r2, #2
adds r0, r1, r0
ldrh r1, [r5]
ldrh r0, [r0]
cmp r1, r0
bne _08014276
_08014296:
cmp r3, #8
bne _080142B4
mov r2, r8
ldrh r4, [r2, #0x18]
b _080142DE
.align 2, 0
_080142A0: .4byte gUnk_08D6CD0C
_080142A4: .4byte 0x0000FFFF
_080142A8: .4byte gKirbys
_080142AC: .4byte gCurLevelInfo
_080142B0: .4byte gUnk_082DE074
_080142B4:
adds r1, r3, #1
lsls r1, r1, #0x18
lsrs r1, r1, #0x18
movs r0, #1
movs r2, #0
bl sub_08002888
ldr r0, [r0]
cmp r0, #0
beq _080142CE
mov r0, r8
ldrh r4, [r0, #0x18]
b _080142DE
_080142CE:
ldrh r4, [r5]
b _080142E0
_080142D2:
movs r0, #0x87
ands r0, r1
cmp r0, #0
beq _080142E0
mov r1, r8
ldrh r4, [r1, #0x18]
_080142DE:
strh r4, [r5]
_080142E0:
cmp r4, #0
beq _080142E6
b _08014440
_080142E6:
movs r3, #0
adds r0, r7, #0
adds r0, #0x48
ldrb r6, [r0]
mov sl, r0
cmp r4, r6
bhs _08014318
ldr r2, [r7]
ldr r0, [r2]
ldrh r0, [r0]
ldrh r1, [r5]
cmp r0, r1
beq _08014318
adds r4, r6, #0
_08014302:
adds r0, r3, #1
lsls r0, r0, #0x10
lsrs r3, r0, #0x10
cmp r3, r4
bhs _08014318
lsls r0, r3, #2
adds r0, r0, r2
ldr r0, [r0]
ldrh r0, [r0]
cmp r0, r1
bne _08014302
_08014318:
mov r2, sl
ldrb r2, [r2]
cmp r3, r2
beq _08014332
ldr r0, [r7]
lsls r1, r3, #2
adds r1, r1, r0
ldr r1, [r1]
ldrh r0, [r1, #2]
cmp r0, #0
beq _08014332
ldrh r4, [r1, #6]
b _08014440
_08014332:
ldr r0, _080143BC @ =gUnk_08D6CD0C
mov ip, r0
ldrh r0, [r5]
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
adds r2, r7, #0
adds r2, #0x46
adds r0, #0x46
mov sl, r0
ldrb r0, [r2]
mov r1, sl
ldrb r1, [r1]
str r1, [sp, #4]
cmp r0, r1
beq _08014426
ldr r1, _080143C0 @ =gUnk_08D6DCAC
ldrb r0, [r2]
lsls r0, r0, #2
adds r0, r0, r1
ldr r6, [r0]
movs r3, #0
ldrh r2, [r6, #4]
adds r4, r2, #0
cmp r3, r4
bhs _080143CA
ldr r1, [r6]
ldrh r0, [r1, #2]
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
adds r0, #0x46
ldrb r0, [r0]
mov r7, sp
strh r2, [r7]
ldr r2, [sp, #4]
cmp r0, r2
beq _080143A6
str r4, [sp, #4]
adds r4, r1, #0
mov r2, sl
_08014384:
adds r0, r3, #1
lsls r0, r0, #0x10
lsrs r3, r0, #0x10
ldr r7, [sp, #4]
cmp r3, r7
bhs _080143CA
lsls r0, r3, #2
adds r0, r0, r4
ldrh r0, [r0, #2]
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
adds r0, #0x46
ldrb r0, [r0]
ldrb r7, [r2]
cmp r0, r7
bne _08014384
_080143A6:
mov r0, sp
ldrh r0, [r0]
cmp r3, r0
bhs _080143CA
lsls r0, r3, #2
adds r0, r0, r1
ldrh r2, [r0]
cmp r2, sb
bne _080143C4
ldrh r4, [r0, #2]
b _08014440
.align 2, 0
_080143BC: .4byte gUnk_08D6CD0C
_080143C0: .4byte gUnk_08D6DCAC
_080143C4:
strh r2, [r5]
mov r4, sb
b _08014440
_080143CA:
ldrh r4, [r6, #4]
cmp r4, #0
beq _0801441C
ldr r2, _0801440C @ =gRngVal
ldr r1, [r2]
ldr r0, _08014410 @ =0x00196225
muls r0, r1, r0
ldr r1, _08014414 @ =0x3C6EF35F
adds r0, r0, r1
str r0, [r2]
lsrs r0, r0, #0x10
movs r1, #0x1f
ands r0, r1
adds r2, r0, #1
ldr r3, _08014418 @ =0x0000FFFF
ldr r1, [r6]
cmp r2, #0
beq _08014404
_080143EE:
adds r0, r3, #1
lsls r0, r0, #0x10
lsrs r3, r0, #0x10
cmp r3, r4
blo _080143FA
movs r3, #0
_080143FA:
subs r0, r2, #1
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
cmp r2, #0
bne _080143EE
_08014404:
lsls r0, r3, #2
adds r0, r0, r1
ldrh r0, [r0]
b _08014420
.align 2, 0
_0801440C: .4byte gRngVal
_08014410: .4byte 0x00196225
_08014414: .4byte 0x3C6EF35F
_08014418: .4byte 0x0000FFFF
_0801441C:
mov r2, r8
ldrh r0, [r2, #0x18]
_08014420:
strh r0, [r5]
ldrh r4, [r5]
b _08014440
_08014426:
mov r0, r8
mov r1, sb
bl sub_080140B0
strh r0, [r5]
mov r7, r8
ldrh r1, [r7, #0x18]
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
mov r4, sb
cmp r1, r0
bne _08014440
adds r4, r1, #0
_08014440:
adds r0, r4, #0
add sp, #8
pop {r3, r4, r5}
mov r8, r3
mov sb, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
thumb_func_start sub_08014454
sub_08014454: @ 0x08014454
push {r4, r5, r6, r7, lr}

View File

@ -438,7 +438,7 @@ struct Unk_02038590 {
u16 unkA0;
u16 unkA2;
u16 unkA4;
u32 unkA8;
struct Kirby *unkA8;
u16 unkAC;
u16 unkAE;
u16 unkB0;
@ -821,7 +821,8 @@ extern void (*const gUnk_082D8D60[2])(struct Unk_08002E48 *, struct LevelInfo *)
struct Unk_08D6CD0C {
const u16 *const *unk0; // TODO: not really sure
u8 filler4[0x42];
u8 filler4[0x40];
u16 roomId;
u8 unk46;
u8 unk47;
u8 unk48;

View File

@ -111,6 +111,7 @@ void sub_08052E2C(struct Kirby *);
void sub_080531B4(struct Kirby *, const struct Unk_08353510 *);
void sub_080547C4(struct Kirby *, u8);
void sub_08054C0C(struct Kirby *);
bool8 sub_080551FC(struct Kirby *, u16, u8, u8);
void sub_0805545C(struct Kirby *);
void sub_08059810(struct Kirby *);
bool32 sub_0805BEC4(struct Kirby *);

View File

@ -2275,3 +2275,162 @@ struct Kirby *sub_08013DB4(u8 a1) {
}
return gKirbys + r2;
}
bool32 sub_08013F48(struct Unk_02038590 *a1, u16 a2) {
u8 a, b;
const struct Unk_08D6CD0C *c, *d;
u8 a_, b_;
sub_08002D40(a2, &a, &b);
a_ = a;
b_ = b;
c = gUnk_08D6CD0C[a2];
d = gUnk_08D6CD0C[a1->unk14->currentRoom];
if (sub_080551FC(a1->unk40, a2, a_, b_)) {
if (d->unk46 == c->unk46)
++a1->unkB0;
else
a1->unkB0 = 0;
return TRUE;
} else {
return FALSE;
}
}
u16 sub_08013FC4(struct Unk_02038590 *a1, u16 a2) {
const struct Unk_08D6CD0C *b = gUnk_08D6CD0C[a2];
const struct Unk_08D6DCAC *a = gUnk_08D6DCAC[b->unk46];
u16 i;
u16 r;
u32 mask;
for (i = 0; i < a->unk4 && a->unk0[2*i] != a2; ++i)
;
if (i == a->unk4)
return 0xFFFF;
r = Rand16();
mask = 0x1F;
i = 0xFFFF;
for (r &= mask; r != 0xFFFF; --r) {
while (1) {
for (++i; i < a->unk4; ++i) {
if (a->unk0[2*i] == a2)
break;
}
if (i < a->unk4)
break;
i = 0xFFFF;
}
}
return a->unk0[2*i + 1];
}
u16 sub_080140B0(struct Unk_02038590 *a1, u16 a2) {
const struct Unk_08D6CD0C *b = gUnk_08D6CD0C[a2];
u16 i;
u16 r;
u32 mask;
u32 var;
for (i = 0; i < b->unk48; ++i) {
const struct Unk_08D6CD0C *r3 = gUnk_08D6CD0C[b->unk0[i][0]];
if (b->unk0[i][1] > 1 && !(r3->unk47 & 0x80))
break;
}
if (i == b->unk48) {
u16 ret = sub_08013FC4(a1, a2);
if (ret != 0xFFFF)
return ret;
else
return a1->unk18;
}
r = Rand16();
mask = 0x1F;
i = 0xFFFF;
var = 0xFFFF; // permuter
for (r &= mask; r != var; --r) {
while (1) {
for (++i; i < b->unk48; ++i) {
if (b->unk0[i][1] > 1 && !(gUnk_08D6CD0C[b->unk0[i][0]]->unk47 & 0x80))
break;
}
if (i < b->unk48)
break;
i = 0xFFFF;
}
}
return b->unk0[i][0];
}
u16 sub_080141EC(struct Unk_02038590 *a1, u16 a2, u16 *a3) {
const struct Unk_08D6DCAC *a;
const struct Unk_08D6CD0C *b = gUnk_08D6CD0C[a2];
const struct Unk_08D6CD0C *c;
u16 i;
u16 r;
u16 r4 = 0;
if (*a3 == 0xFFFF) {
if (!a1->unkA8)
a1->unkA8 = &gKirbys[(a1->unk40->base.base.base.unk56 + 1) & 3];
*a3 = gCurLevelInfo[a1->unkA8->base.base.base.unk56].currentRoom;
}
if (b->unk47 & 8) {
for (i = 0; i < 8 && (a2 != gUnk_082DE074[i][0] || *a3 != gUnk_082DE074[i][1]); ++i)
;
if (i == 8)
*a3 = r4 = a1->unk18;
else if (*sub_08002888(1, i + 1, 0))
*a3 = r4 = a1->unk18;
else
r4 = *a3;
} else {
if (b->unk47 & 0x87)
*a3 = r4 = a1->unk18;
}
if (r4) return r4;
for (i = 0; i < b->unk48 && b->unk0[i][0] != *a3; ++i)
;
if (i != b->unk48 && b->unk0[i][1]) {
r4 = b->unk0[i][3];
return r4;
}
c = gUnk_08D6CD0C[*a3];
if (b->unk46 != c->unk46) {
a = gUnk_08D6DCAC[b->unk46];
for (i = 0; i < a->unk4; ++i) {
if (gUnk_08D6CD0C[a->unk0[2*i + 1]]->unk46 == c->unk46)
break;
}
if (i < a->unk4) {
if (a->unk0[2*i] == a2)
r4 = a->unk0[2*i + 1];
else {
*a3 = a->unk0[2*i];
r4 = a2;
}
return r4;
}
if (a->unk4) {
r = (Rand16() & 0x1F) + 1;
i = 0xFFFF;
for (; r; --r) {
if (++i >= a->unk4)
i = 0;
}
*a3 = a->unk0[2 * i];
} else {
*a3 = a1->unk18;
}
r4 = *a3;
} else {
*a3 = sub_080140B0(a1, a2);
if (a1->unk18 == *a3)
r4 = a1->unk18;
else
r4 = a2;
}
return r4;
}