Some more pokenav

This commit is contained in:
DizzyEggg 2019-07-25 21:41:02 +02:00
parent fd07c608fc
commit 56b124fdec
6 changed files with 132 additions and 227 deletions

View File

@ -5,219 +5,7 @@
@ File centered around AllocSubstruct(7)
thumb_func_start sub_81CEF3C
sub_81CEF3C: @ 81CEF3C
push {r4,lr}
movs r0, 0x7
movs r1, 0x24
bl AllocSubstruct
adds r4, r0, 0
cmp r4, 0
beq _081CEF90
ldr r1, =0x000006ac
movs r0, 0x12
bl AllocSubstruct
str r0, [r4, 0x20]
cmp r0, 0
beq _081CEF90
ldr r0, =sub_81CF010
str r0, [r4]
ldr r0, =sub_81CF11C
movs r1, 0x1
bl CreateLoopedTask
str r0, [r4, 0x4]
movs r0, 0
str r0, [r4, 0x18]
bl sub_81C76AC
ldr r1, =gUnknown_086233A0
lsls r0, 2
adds r0, r1
ldr r0, [r0]
str r0, [r4, 0x14]
movs r0, 0x1
b _081CEF92
.pool
_081CEF90:
movs r0, 0
_081CEF92:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81CEF3C
thumb_func_start sub_81CEF98
sub_81CEF98: @ 81CEF98
push {r4,lr}
movs r0, 0x7
movs r1, 0x24
bl AllocSubstruct
adds r4, r0, 0
cmp r4, 0
beq _081CEFD4
movs r0, 0x12
bl GetSubstructPtr
str r0, [r4, 0x20]
ldr r0, =sub_81CF030
str r0, [r4]
movs r0, 0x1
str r0, [r4, 0x18]
bl sub_81C76AC
ldr r1, =gUnknown_086233A0
lsls r0, 2
adds r0, r1
ldr r0, [r0]
str r0, [r4, 0x14]
movs r0, 0x1
b _081CEFD6
.pool
_081CEFD4:
movs r0, 0
_081CEFD6:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81CEF98
thumb_func_start sub_81CEFDC
sub_81CEFDC: @ 81CEFDC
push {lr}
movs r0, 0x7
bl GetSubstructPtr
ldr r1, [r0]
bl _call_via_r1
pop {r1}
bx r1
thumb_func_end sub_81CEFDC
thumb_func_start sub_81CEFF0
sub_81CEFF0: @ 81CEFF0
push {lr}
movs r0, 0x7
bl GetSubstructPtr
ldr r0, [r0, 0x1C]
cmp r0, 0
bne _081CF004
movs r0, 0x12
bl FreePokenavSubstruct
_081CF004:
movs r0, 0x7
bl FreePokenavSubstruct
pop {r0}
bx r0
thumb_func_end sub_81CEFF0
thumb_func_start sub_81CF010
sub_81CF010: @ 81CF010
push {r4,lr}
adds r4, r0, 0
ldr r0, [r4, 0x4]
bl IsLoopedTaskActive
cmp r0, 0
bne _081CF022
ldr r0, =sub_81CF030
str r0, [r4]
_081CF022:
movs r0, 0
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_81CF010
thumb_func_start sub_81CF030
sub_81CF030: @ 81CF030
push {r4,r5,lr}
adds r4, r0, 0
ldr r2, =gMain
ldrh r1, [r2, 0x30]
movs r0, 0x40
ands r0, r1
cmp r0, 0
beq _081CF048
movs r0, 0x1
b _081CF0A6
.pool
_081CF048:
movs r0, 0x80
ands r0, r1
cmp r0, 0
beq _081CF054
movs r0, 0x2
b _081CF0A6
_081CF054:
ldrh r1, [r2, 0x2E]
movs r0, 0x20
ands r0, r1
cmp r0, 0
beq _081CF062
movs r0, 0x3
b _081CF0A6
_081CF062:
movs r0, 0x10
ands r0, r1
lsls r0, 16
lsrs r2, r0, 16
cmp r2, 0
beq _081CF072
movs r0, 0x4
b _081CF0A6
_081CF072:
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _081CF088
str r2, [r4, 0x1C]
ldr r0, =sub_81CF0B0
str r0, [r4]
movs r0, 0x5
b _081CF0A6
.pool
_081CF088:
movs r5, 0x1
adds r0, r5, 0
ands r0, r1
cmp r0, 0
bne _081CF096
movs r0, 0
b _081CF0A6
_081CF096:
bl GetSelectedMatchCall
ldr r1, [r4, 0x20]
strh r0, [r1, 0x2]
str r5, [r4, 0x1C]
ldr r0, =sub_81CF0B8
str r0, [r4]
movs r0, 0x6
_081CF0A6:
pop {r4,r5}
pop {r1}
bx r1
.pool
thumb_func_end sub_81CF030
thumb_func_start sub_81CF0B0
sub_81CF0B0: @ 81CF0B0
ldr r0, =0x000186a3
bx lr
.pool
thumb_func_end sub_81CF0B0
thumb_func_start sub_81CF0B8
sub_81CF0B8: @ 81CF0B8
ldr r0, =0x000186a9
bx lr
.pool
thumb_func_end sub_81CF0B8
thumb_func_start sub_81CF0C0
sub_81CF0C0: @ 81CF0C0
push {lr}
movs r0, 0x7
bl GetSubstructPtr
ldr r0, [r0, 0x18]
pop {r1}
bx r1
thumb_func_end sub_81CF0C0
thumb_func_start sub_81CF0D0
sub_81CF0D0: @ 81CF0D0

View File

@ -3,9 +3,22 @@
#include "bg.h"
#include "main.h"
#include "pokemon_storage_system.h"
typedef u32 (*LoopedTask)(s32 state);
struct PokenavSub18
{
u16 unk0;
u16 unk2;
struct
{
u8 boxId;
u8 monId;
u16 unk6;
} unk4[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
};
// Return values of LoopedTask functions.
#define LT_INC_AND_PAUSE 0
#define LT_INC_AND_CONTINUE 1
@ -43,7 +56,7 @@ enum
// pokenav.c
void sub_81C7694(u32);
u16 sub_81C76AC(void);
u32 sub_81C76AC(void);
void CB2_InitPokeNav(void);
u32 CreateLoopedTask(LoopedTask loopedTask, u32 priority);

View File

@ -318,6 +318,7 @@ SECTIONS {
src/pokenav_unk_5.o(.text*);
src/pokenav_unk_6.o(.text*);
src/pokenav_unk_7.o(.text*);
src/pokenav_unk_8.o(.text*);
asm/pokenav_unk_8.o(.text*);
asm/pokenav_unk_9.o(.text*);
asm/pokenav_unk_10.o(.text*);

View File

@ -605,7 +605,7 @@ void sub_81C7694(u32 a0)
gPokenavResources->fieldA = value;
}
u16 sub_81C76AC(void)
u32 sub_81C76AC(void)
{
return gPokenavResources->fieldA;
}

View File

@ -35,18 +35,6 @@ struct PokenavSub11
u8 unk678A;
};
struct PokenavSub18
{
u16 unk0;
u16 unk2;
struct
{
u8 boxId;
u8 monId;
u16 unk6;
} unk4[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
};
void sub_81CD970(void);
void sub_81CD9F8(void);
u32 sub_81CD08C(struct PokenavSub11 *structPtr);

115
src/pokenav_unk_8.c Normal file
View File

@ -0,0 +1,115 @@
#include "global.h"
#include "pokenav.h"
struct PokenavSub7
{
u32 (*unk0)(struct PokenavSub7 *);
u32 loopedTaskId;
u8 fill1[12];
u32 unk14;
u32 unk18;
u32 unk1C;
struct PokenavSub18 *unkPtr;
};
extern const u32 gUnknown_086233A0[];
u32 sub_81CF010(struct PokenavSub7 *structPtr);
u32 sub_81CF030(struct PokenavSub7 *structPtr);
u32 sub_81CF0B8(struct PokenavSub7 *structPtr);
u32 sub_81CF0B0(struct PokenavSub7 *structPtr);
u32 sub_81CF11C(s32 state);
bool32 sub_81CEF3C(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL)
return FALSE;
structPtr->unkPtr = AllocSubstruct(18, sizeof(struct PokenavSub18));
if (structPtr->unkPtr == NULL)
return FALSE;
structPtr->unk0 = sub_81CF010;
structPtr->loopedTaskId = CreateLoopedTask(sub_81CF11C, 1);
structPtr->unk18 = 0;
structPtr->unk14 = gUnknown_086233A0[sub_81C76AC()];
return TRUE;
}
bool32 sub_81CEF98(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL)
return FALSE;
structPtr->unkPtr = GetSubstructPtr(18);
structPtr->unk0 = sub_81CF030;
structPtr->unk18 = 1;
structPtr->unk14 = gUnknown_086233A0[sub_81C76AC()];
return TRUE;
}
u32 sub_81CEFDC(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(7);
return structPtr->unk0(structPtr);
}
void sub_81CEFF0(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(7);
if (structPtr->unk1C == 0)
FreePokenavSubstruct(18);
FreePokenavSubstruct(7);
}
bool32 sub_81CF010(struct PokenavSub7 *structPtr)
{
if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->unk0 = sub_81CF030;
return FALSE;
}
u32 sub_81CF030(struct PokenavSub7 *structPtr)
{
if (gMain.newAndRepeatedKeys & DPAD_UP)
return 1;
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
return 2;
else if (gMain.newKeys & DPAD_LEFT)
return 3;
else if (gMain.newKeys & DPAD_RIGHT)
return 4;
else if (gMain.newKeys & B_BUTTON)
{
structPtr->unk1C = 0;
structPtr->unk0 = sub_81CF0B0;
return 5;
}
else if (gMain.newKeys & A_BUTTON)
{
structPtr->unkPtr->unk2 = GetSelectedMatchCall();
structPtr->unk1C = 1;
structPtr->unk0 = sub_81CF0B8;
return 6;
}
else
return 0;
}
u32 sub_81CF0B0(struct PokenavSub7 *structPtr)
{
return 0x186A3;
}
u32 sub_81CF0B8(struct PokenavSub7 *structPtr)
{
return 0x186A9;
}
u32 sub_81CF0C0(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(7);
return structPtr->unk18;
}