New function!

This commit is contained in:
Egor Ananyin 2020-05-05 12:00:52 +03:00
parent 2fdeda29a4
commit 18d2ffcb35
5 changed files with 45 additions and 67 deletions

View File

@ -5,65 +5,6 @@
.text
thumb_func_start sub_08152DD8
sub_08152DD8: @ 0x08152DD8
push {r4, lr}
lsls r0, r0, #0x10
lsrs r2, r0, #0x10
adds r0, r2, #3
lsrs r2, r0, #2
cmp r2, #0
beq _08152E38
lsls r0, r2, #0x12
movs r1, #0x80
lsls r1, r1, #0xb
adds r0, r0, r1
lsrs r2, r0, #0x10
ldr r3, _08152E24 @ =gUnk_03003A20
_08152DF2:
lsls r0, r2, #0x10
asrs r0, r0, #0x10
movs r4, #2
ldrsh r1, [r3, r4]
cmp r0, r1
bgt _08152E28
cmp r0, r1
beq _08152E1A
adds r0, r2, #4
lsls r0, r0, #0x10
asrs r0, r0, #0x10
cmp r0, r1
bgt _08152E28
adds r1, r3, r2
ldrh r0, [r3]
strh r0, [r1]
ldrh r0, [r3, #2]
subs r0, r0, r2
strh r0, [r1, #2]
strh r1, [r3]
_08152E1A:
rsbs r0, r2, #0
strh r0, [r3, #2]
adds r0, r3, #4
b _08152E3A
.align 2, 0
_08152E24: .4byte gUnk_03003A20
_08152E28:
ldrh r1, [r3]
movs r0, #0xc0
lsls r0, r0, #0x12
adds r1, r1, r0
cmp r1, r0
beq _08152E38
adds r3, r1, #0
b _08152DF2
_08152E38:
movs r0, #0
_08152E3A:
pop {r4}
pop {r1}
bx r1
thumb_func_start sub_08152E40
sub_08152E40: @ 0x08152E40
push {r4, r5, lr}

0
asmdiff.sh Normal file → Executable file
View File

View File

@ -9,7 +9,7 @@ void sub_08030E44(void);
u32 sub_08030FE0(void);
void sub_08032E98(void);
u32 sub_08152A18(void);
u16 sub_08152DD8(u16);
struct Unk_03003A20* sub_08152DD8(u16);
void sub_08158870(void);
void nullsub_2(void);
void sub_08159074(void);

View File

@ -21,7 +21,7 @@ struct GameState {
struct Unk_03003A20 {
u16 unk0;
u16 unk2;
s16 unk2;
};
extern u32 gUnk_0203ADE4;
@ -35,7 +35,7 @@ extern s32 gUnk_03002E7C;
extern struct GameState* gUnk_03002E98;
extern struct GameState* gUnk_03002EBC;
extern struct GameState* gUnk_030035D0;
extern struct Unk_03003A20 gUnk_03003A20;
extern struct Unk_03003A20 gUnk_03003A20[];
extern u8 gUnk_030068D4;
extern u32 gUnk_03006CC4;

View File

@ -48,8 +48,8 @@ u32 sub_08152A18(void) {
gUnk_03002500.unk2 = 0;
gUnk_03002500.unk4 = 0;
gUnk_03002500.unk6 = gUnk_03006CC4;
gUnk_03003A20.unk0 = 0;
gUnk_03003A20.unk2 = 0x2604;
gUnk_03003A20[0].unk0 = 0;
gUnk_03003A20[0].unk2 = 0x2604;
return 1;
}
@ -96,11 +96,11 @@ struct GameState* sub_08152B00(GameStateFunc arg0, u16 arg1, u16 arg2, u16 arg3,
if (*r3_2 == r1) {
r4->unk12 &= ~0x10;
r4->unk6 = sub_08152DD8(arg1);
r4->unk6 = (u32)sub_08152DD8(arg1);
}
}
else {
r4->unk6 = sub_08152DD8(arg1);
r4->unk6 = (u32)sub_08152DD8(arg1);
if ((arg1 != 0) && (r4->unk6 == 0)) {
r4->unk12 |= 0x10;
r4->unk6 = (sub_08159088(arg1) - EWRAM_START) >> 2;
@ -200,7 +200,7 @@ void sub_08152CF4(void) {
if ((gUnk_030035D0->unk12 & 5) == 4) {
gUnk_030035D0->unk8();
}
gUnk_030035D0 = gUnk_03002EBC;
if (gUnk_030068D4 != 0) {
m4aSoundMain();
@ -211,3 +211,40 @@ void sub_08152CF4(void) {
gUnk_030035D0 = NULL;
gUnk_03002EBC = NULL;
}
struct Unk_03003A20* sub_08152DD8(u16 arg0) {
struct Unk_03003A20 *r3, *r1;
s16 r0;
u16 r2 = arg0;
r2 = (r2 + 3) >> 2;
if (r2 == 0) {
return NULL;
}
r2 = (r2 << 2) + 4;
r3 = gUnk_03003A20;
do {
r0 = r2;
if (r0 <= r3->unk2) {
if (r0 != r3->unk2) {
r0 = r2 + 4;
if (r0 > r3->unk2) {
if ((r3->unk0 + IWRAM_START) == IWRAM_START) {
return NULL;
}
r3 = (struct Unk_03003A20*)(r3->unk0 + IWRAM_START);
continue;
}
r1 = (struct Unk_03003A20*)((u8*)r3 + r2);
r1->unk0 = r3->unk0;
r1->unk2 = r3->unk2 - r2;
r3->unk0 = (u32)r1;
}
r3->unk2 = -r2;
return r3 + 1;
}
if ((r3->unk0 + IWRAM_START) == IWRAM_START) {
return NULL;
}
r3 = (struct Unk_03003A20*)(r3->unk0 + IWRAM_START);
} while(1);
}