Finish decompiling pokenav_unk_1.c

This commit is contained in:
Marcus Huderle 2019-04-13 14:46:46 -05:00 committed by huderlem
parent cb9d471a2a
commit 1268691410
6 changed files with 147 additions and 226 deletions

View File

@ -1,112 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
thumb_func_start sub_81C9814
sub_81C9814: @ 81C9814
push {r4,r5,lr}
adds r4, r0, 0
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x40
ands r0, r1
lsls r0, 16
lsrs r5, r0, 16
cmp r5, 0
beq _081C9848
ldrh r0, [r4, 0x2]
subs r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
ldrh r3, [r4]
cmp r0, 0
bge _081C986A
ldr r0, =gUnknown_0861FC54
adds r0, r3, r0
ldrb r0, [r0]
strh r0, [r4, 0x2]
b _081C986A
.pool
_081C9848:
movs r0, 0x80
ands r0, r1
cmp r0, 0
beq _081C988C
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
movs r0, 0x2
ldrsh r2, [r4, r0]
ldr r0, =gUnknown_0861FC54
ldrh r1, [r4]
adds r0, r1, r0
adds r3, r1, 0
ldrb r0, [r0]
cmp r2, r0
ble _081C986A
strh r5, [r4, 0x2]
_081C986A:
ldr r2, =gUnknown_0861FC59
movs r0, 0x2
ldrsh r1, [r4, r0]
lsls r0, r3, 1
adds r0, r3
lsls r0, 1
adds r1, r0
adds r1, r2
ldrb r0, [r1]
strh r0, [r4, 0x4]
movs r0, 0x1
b _081C988E
.pool
_081C988C:
movs r0, 0
_081C988E:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81C9814
thumb_func_start sub_81C9894
sub_81C9894: @ 81C9894
push {lr}
movs r0, 0x1
bl GetSubstructPtr
ldrh r0, [r0]
pop {r1}
bx r1
thumb_func_end sub_81C9894
thumb_func_start sub_81C98A4
sub_81C98A4: @ 81C98A4
push {lr}
movs r0, 0x1
bl GetSubstructPtr
movs r1, 0x2
ldrsh r0, [r0, r1]
pop {r1}
bx r1
thumb_func_end sub_81C98A4
thumb_func_start sub_81C98B4
sub_81C98B4: @ 81C98B4
push {lr}
movs r0, 0x1
bl GetSubstructPtr
ldrh r0, [r0, 0x4]
pop {r1}
bx r1
thumb_func_end sub_81C98B4
thumb_func_start sub_81C98C4
sub_81C98C4: @ 81C98C4
push {lr}
movs r0, 0x1
bl GetSubstructPtr
ldrh r0, [r0, 0x6]
pop {r1}
bx r1
thumb_func_end sub_81C98C4
.align 2, 0 @ Don't pad with nop.

View File

@ -3,17 +3,6 @@
.section .rodata
// pokenav_unk_1.s
gUnknown_0861FC54:: @ 861FC54
.byte 2
.byte 3
.byte 4
.byte 2
.byte 5
gUnknown_0861FC59:: @ 861FC59
.byte 0, 1, 4, 4, 4, 4, 0, 1, 2, 4, 4, 4, 0, 1, 2, 3, 4, 4, 5, 6, 7, 4, 4, 4, 8, 9, 10, 11, 12, 13, 0
// pokenav_unk_2.s
gUnknown_0861FC78:: @ 861FC78
.incbin "graphics/pokenav/bg.gbapal"

View File

@ -14,7 +14,8 @@ typedef u32 (*LoopedTask)(s32 state);
#define UNKNOWN_POKENAV_OFFSET 100000
// pokenav.c
extern u32 sub_81C99D4(void);
void sub_81C7694(u32);
u16 sub_81C76AC(void);
void CB2_InitPokeNav(void);
u32 CreateLoopedTask(LoopedTask loopedTask, u32 priority);
@ -31,13 +32,17 @@ bool32 CanViewRibbonsMenu(void);
// pokenav_match_call_ui.c
// pokenav_unk_1.c
u32 sub_81C9298(void);
u32 sub_81C92CC(void);
u32 sub_81C9304(void);
u32 sub_81C9338(void);
u32 sub_81C9368(void);
bool32 sub_81C9298(void);
bool32 sub_81C92CC(void);
bool32 sub_81C9304(void);
bool32 sub_81C9338(void);
bool32 sub_81C9368(void);
u32 sub_81C941C(void);
void sub_81C9430(void);
int sub_81C9894(void);
// pokenav_unk_2.c
u32 sub_81C99D4(void);
#endif //GUARD_POKENAV_H

View File

@ -304,7 +304,6 @@ SECTIONS {
src/pokenav_main_menu.o(.text);
src/pokenav_match_call_ui.o(.text);
src/pokenav_unk_1.o(.text);
asm/pokenav_unk_1.o(.text);
asm/pokenav_unk_2.o(.text);
asm/pokenav_unk_3.o(.text);
asm/pokenav_unk_4.o(.text);

View File

@ -596,7 +596,8 @@ void SetPokenavVBlankCallback(void)
void *AllocSubstruct(u32 index, u32 size)
{
return gPokenavResources->field10[index] = Alloc(size);
gPokenavResources->field10[index] = Alloc(size);
return gPokenavResources->field10[index];
}
void *GetSubstructPtr(u32 index)

View File

@ -15,126 +15,116 @@ struct Pokenav1Struct
u32 (*unkC)(struct Pokenav1Struct*);
};
static bool32 sub_81C9814(struct Pokenav1Struct *a0);
static void sub_81C97F8(struct Pokenav1Struct *a0);
static void sub_81C97C0(struct Pokenav1Struct *a0);
static u32 sub_81C97BC(struct Pokenav1Struct *a0);
static void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1);
static u32 sub_81C97A4(struct Pokenav1Struct *a0);
static u32 sub_81C9798(struct Pokenav1Struct *a0);
static u32 sub_81C96FC(struct Pokenav1Struct *a0);
static u32 sub_81C963C(struct Pokenav1Struct *a0);
static u32 sub_81C9600(struct Pokenav1Struct *a0);
static u32 sub_81C9588(struct Pokenav1Struct *a0);
static u32 sub_81C9520(struct Pokenav1Struct *a0);
static u32 sub_81C943C(struct Pokenav1Struct *a0);
static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*);
static void sub_81C939C(struct Pokenav1Struct *state);
extern u32 sub_81C76AC(void);
extern void sub_81C7694(u32 a0);
static const u8 sUnknown_0861FC54[] = {2, 3, 4, 2, 5};
u32 sub_81C9814(void);
void sub_81C97F8(struct Pokenav1Struct *a0);
void sub_81C97C0(struct Pokenav1Struct *a0);
u32 sub_81C97BC(struct Pokenav1Struct *a0);
void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1);
u32 sub_81C97A4(struct Pokenav1Struct *a0);
u32 sub_81C9798(struct Pokenav1Struct *a0);
u32 sub_81C96FC(struct Pokenav1Struct *a0);
u32 sub_81C963C(struct Pokenav1Struct *a0);
u32 sub_81C9600(struct Pokenav1Struct *a0);
u32 sub_81C9588(struct Pokenav1Struct *a0);
u32 sub_81C9520(struct Pokenav1Struct *a0);
u32 sub_81C943C(struct Pokenav1Struct *a0);
u32 (*sub_81C93EC(void))(struct Pokenav1Struct*);
void sub_81C939C(struct Pokenav1Struct *state);
extern u8 gUnknown_0861FC54[];
extern u8 gUnknown_0861FC59[];
u8 sub_81C9268(void)
static const u8 sUnknown_0861FC59[][6] =
{
u32 ret = 0;
{ 0, 1, 4, 4, 4, 4 },
{ 0, 1, 2, 4, 4, 4 },
{ 0, 1, 2, 3, 4, 4 },
{ 5, 6, 7, 4, 4, 4 },
{ 8, 9, 10, 11, 12, 13 },
};
static u8 sub_81C9268(void)
{
u8 retVal = 0;
if (FlagGet(FLAG_ADDED_MATCH_CALL_TO_POKENAV))
{
ret = 1;
retVal = 1;
if (FlagGet(FLAG_SYS_RIBBON_GET))
ret = 2;
retVal = 2;
}
return ret;
return retVal;
}
u32 sub_81C9298(void)
bool32 sub_81C9298(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (state == NULL)
return 0;
if (!state)
return FALSE;
state->unk0 = sub_81C9268();
state->unk2 = 0;
state->unk4 = 0;
state->unk6 = 0;
sub_81C939C(state);
return 1;
return TRUE;
}
u32 sub_81C92CC(void)
bool32 sub_81C92CC(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
u8 v0;
if (state == NULL)
return 0;
if (!state)
return FALSE;
state->unk0 = sub_81C9268();
state->unk2 = 2;
state->unk4 = 2;
state->unk6 = 0;
sub_81C939C(state);
return 1;
return TRUE;
}
u32 sub_81C9304(void)
bool32 sub_81C9304(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
u8 v0;
if (state == NULL)
return 0;
if (!state)
return FALSE;
state->unk0 = sub_81C9268();
state->unk2 = 3;
state->unk4 = 3;
sub_81C939C(state);
return 1;
return TRUE;
}
u32 sub_81C9338(void)
bool32 sub_81C9338(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
u8 v0;
if (state == NULL)
return 0;
if (!state)
return FALSE;
state->unk0 = 3;
state->unk2 = 0;
state->unk4 = 5;
state->unk6 = 0;
sub_81C939C(state);
return 1;
return TRUE;
}
u32 sub_81C9368(void)
bool32 sub_81C9368(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
u8 v0;
if (state == NULL)
return 0;
if (!state)
return FALSE;
state->unk0 = 4;
state->unk2 = sub_81C76AC();
state->unk4 = 8 + state->unk2;
state->unk4 = state->unk2 + 8;
state->unk6 = 0;
sub_81C939C(state);
return 1;
return TRUE;
}
void sub_81C939C(struct Pokenav1Struct *state)
static void sub_81C939C(struct Pokenav1Struct *state)
{
switch (state->unk0)
{
@ -154,7 +144,7 @@ void sub_81C939C(struct Pokenav1Struct *state)
}
}
u32 (*sub_81C93EC(void))(struct Pokenav1Struct*)
static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*)
{
switch (GetPokenavMode())
{
@ -179,14 +169,14 @@ void sub_81C9430(void)
FreePokenavSubstruct(1);
}
u32 sub_81C943C(struct Pokenav1Struct *a0)
static u32 sub_81C943C(struct Pokenav1Struct *a0)
{
if (sub_81C9814() != 0)
if (sub_81C9814(a0))
return 1;
if (gMain.newKeys & A_BUTTON)
{
switch (gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6])
switch (sUnknown_0861FC59[a0->unk0][a0->unk2])
{
case 0:
a0->unk6 = gSaveBlock2Ptr->regionMapZoom ? 2 : 1;
@ -195,7 +185,7 @@ u32 sub_81C943C(struct Pokenav1Struct *a0)
case 1:
a0->unk0 = 3;
a0->unk2 = 0;
a0->unk4 = gUnknown_0861FC59[18];
a0->unk4 = sUnknown_0861FC59[3][0];
a0->unkC = sub_81C963C;
return 2;
case 2:
@ -225,14 +215,14 @@ u32 sub_81C943C(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C9520(struct Pokenav1Struct *a0)
static u32 sub_81C9520(struct Pokenav1Struct *a0)
{
if (sub_81C9814() != 0)
if (sub_81C9814(a0))
return 1;
if (gMain.newKeys & A_BUTTON)
{
if (gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6] == 2)
if (sUnknown_0861FC59[a0->unk0][a0->unk2] == 2)
{
a0->unk6 = 6;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 11);
@ -254,14 +244,14 @@ u32 sub_81C9520(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C9588(struct Pokenav1Struct *a0)
static u32 sub_81C9588(struct Pokenav1Struct *a0)
{
if (sub_81C9814() != 0)
if (sub_81C9814(a0))
return 1;
if (gMain.newKeys & A_BUTTON)
{
u32 v0 = gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6];
u32 v0 = sUnknown_0861FC59[a0->unk0][a0->unk2];
if (v0 != 2 && v0 != 4)
{
PlaySE(SE_HAZURE);
@ -285,9 +275,9 @@ u32 sub_81C9588(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C9600(struct Pokenav1Struct *a0)
static u32 sub_81C9600(struct Pokenav1Struct *a0)
{
if (sub_81C9814() != 0)
if (sub_81C9814(a0))
{
a0->unkC = sub_81C93EC();
return 1;
@ -302,20 +292,20 @@ u32 sub_81C9600(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C963C(struct Pokenav1Struct *a0)
static u32 sub_81C963C(struct Pokenav1Struct *a0)
{
u32 v0 = sub_81C9814();
u32 v0 = sub_81C9814(a0);
if (v0)
return 1;
if (gMain.newKeys & A_BUTTON)
{
switch (gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6])
switch (sUnknown_0861FC59[a0->unk0][a0->unk2])
{
case 6:
a0->unk0 = 4;
a0->unk2 = v0;
a0->unk4 = gUnknown_0861FC59[24];
a0->unk4 = sUnknown_0861FC59[4][0];
a0->unkC = sub_81C96FC;
return 4;
case 5:
@ -330,9 +320,9 @@ u32 sub_81C963C(struct Pokenav1Struct *a0)
}
if (gMain.newKeys & B_BUTTON)
{
if (a0->unk2 != gUnknown_0861FC54[a0->unk0])
if (a0->unk2 != sUnknown_0861FC54[a0->unk0])
{
a0->unk2 = gUnknown_0861FC54[a0->unk0];
a0->unk2 = sUnknown_0861FC54[a0->unk0];
a0->unkC = sub_81C9798;
return 1;
}
@ -347,14 +337,14 @@ u32 sub_81C963C(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C96FC(struct Pokenav1Struct *a0)
static u32 sub_81C96FC(struct Pokenav1Struct *a0)
{
if (sub_81C9814())
if (sub_81C9814(a0))
return 1;
if (gMain.newKeys & A_BUTTON)
{
u8 v0 = gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6];
u8 v0 = sUnknown_0861FC59[a0->unk0][a0->unk2];
if (v0 != 13)
{
sub_81C7694(v0 - 8);
@ -371,9 +361,9 @@ u32 sub_81C96FC(struct Pokenav1Struct *a0)
}
if (gMain.newKeys & B_BUTTON)
{
if (a0->unk2 != gUnknown_0861FC54[a0->unk0])
if (a0->unk2 != sUnknown_0861FC54[a0->unk0])
{
a0->unk2 = gUnknown_0861FC54[a0->unk0];
a0->unk2 = sUnknown_0861FC54[a0->unk0];
a0->unkC = sub_81C97A4;
return 1;
}
@ -387,41 +377,90 @@ u32 sub_81C96FC(struct Pokenav1Struct *a0)
return 0;
}
u32 sub_81C9798(struct Pokenav1Struct *a0)
static u32 sub_81C9798(struct Pokenav1Struct *a0)
{
sub_81C97C0(a0);
return 3;
}
u32 sub_81C97A4(struct Pokenav1Struct *a0)
static u32 sub_81C97A4(struct Pokenav1Struct *a0)
{
sub_81C97F8(a0);
return 5;
}
void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1)
static void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1)
{
a0->unk8 = a1;
a0->unkC = sub_81C97BC;
}
u32 sub_81C97BC(struct Pokenav1Struct *a0)
static u32 sub_81C97BC(struct Pokenav1Struct *a0)
{
return a0->unk8;
}
void sub_81C97C0(struct Pokenav1Struct *a0)
static void sub_81C97C0(struct Pokenav1Struct *a0)
{
a0->unk0 = sub_81C9268();
a0->unk2 = 1;
a0->unk4 = gUnknown_0861FC59[a0->unk2 + a0->unk0 * 6];
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2];
a0->unkC = sub_81C943C;
}
void sub_81C97F8(struct Pokenav1Struct *a0)
static void sub_81C97F8(struct Pokenav1Struct *a0)
{
a0->unk0 = 3;
a0->unk2 = 1;
a0->unk4 = gUnknown_0861FC59[19];
a0->unk4 = sUnknown_0861FC59[3][1];
a0->unkC = sub_81C963C;
}
}
static bool32 sub_81C9814(struct Pokenav1Struct *a0)
{
if (gMain.newKeys & DPAD_UP)
{
if (--a0->unk2 < 0)
a0->unk2 = sUnknown_0861FC54[a0->unk0];
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2];
return TRUE;
}
else if (gMain.newKeys & DPAD_DOWN)
{
a0->unk2++;
if (a0->unk2 > sUnknown_0861FC54[a0->unk0])
a0->unk2 = 0;
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2];
return TRUE;
}
else
{
return FALSE;
}
}
int sub_81C9894(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk0;
}
int sub_81C98A4(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk2;
}
int sub_81C98B4(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk4;
}
int sub_81C98C4(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk6;
}