Decompile pokenav_unk_4.c through sub_81CB678()

This commit is contained in:
Marcus Huderle 2019-04-15 19:24:32 -05:00 committed by huderlem
parent 394c0f5546
commit c7954e1212
4 changed files with 264 additions and 483 deletions

View File

@ -5,483 +5,6 @@
@ File centered around AllocSubstruct(6)
thumb_func_start sub_81CB324
sub_81CB324: @ 81CB324
push {r4,r5,lr}
sub sp, 0x8
adds r4, r0, 0
movs r0, 0x6
bl GetSubstructPtr
adds r5, r0, 0
cmp r4, 0x7
bls _081CB338
b _081CB504
_081CB338:
lsls r0, r4, 2
ldr r1, =_081CB348
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081CB348:
.4byte _081CB368
.4byte _081CB3D4
.4byte _081CB424
.4byte _081CB468
.4byte _081CB482
.4byte _081CB494
.4byte _081CB4A6
.4byte _081CB4EA
_081CB368:
ldr r0, =gUnknown_0862278C
movs r1, 0x3
bl InitBgTemplates
movs r0, 0x2
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0x2
movs r1, 0
movs r2, 0
bl ChangeBgY
ldr r1, =gUnknown_08622530
movs r0, 0
str r0, [sp]
movs r0, 0x2
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
ldr r0, =0x00001024
adds r1, r5, r0
movs r0, 0x2
bl SetBgTilemapBuffer
ldr r1, =gUnknown_086225D4
movs r0, 0x2
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
movs r0, 0x2
bl CopyBgTilemapBufferToVram
ldr r0, =gUnknown_08622510
movs r1, 0x20
movs r2, 0x20
bl CopyPaletteIntoBufferUnfaded
movs r0, 0x2
b _081CB418
.pool
_081CB3D4:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
beq _081CB3E0
b _081CB4FA
_081CB3E0:
movs r0, 0x1
movs r1, 0
movs r2, 0
movs r3, 0x1
bl sub_8199DF0
adds r1, r5, 0
adds r1, 0x24
movs r0, 0x1
bl SetBgTilemapBuffer
movs r1, 0x80
lsls r1, 5
movs r0, 0x20
str r0, [sp]
movs r0, 0x14
str r0, [sp, 0x4]
movs r0, 0x1
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
ldr r0, =gUnknown_086226E0
movs r1, 0x10
movs r2, 0x20
bl CopyPaletteIntoBufferUnfaded
movs r0, 0x1
_081CB418:
bl CopyBgTilemapBufferToVram
movs r0, 0
b _081CB506
.pool
_081CB424:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
bne _081CB4FA
adds r0, r5, 0
bl sub_81CC034
ldr r1, =gUnknown_08622760
str r4, [sp]
movs r0, 0x3
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
ldr r0, =gUnknown_08622700
movs r1, 0x30
movs r2, 0x20
bl CopyPaletteIntoBufferUnfaded
ldr r0, =gUnknown_08622720
movs r1, 0x50
movs r2, 0x20
bl CopyPaletteIntoBufferUnfaded
movs r0, 0
b _081CB506
.pool
_081CB468:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
bne _081CB4FA
bl sub_81CAE28
cmp r0, 0
beq _081CB4FA
bl sub_81CBBB8
movs r0, 0
b _081CB506
_081CB482:
bl sub_81C8224
cmp r0, 0
bne _081CB4FA
adds r0, r5, 0
bl sub_81CBD78
movs r0, 0
b _081CB506
_081CB494:
adds r0, r5, 0
bl sub_81CBDC0
adds r0, r5, 0
movs r1, 0
bl sub_81CBEF8
movs r0, 0
b _081CB506
_081CB4A6:
movs r0, 0x1
movs r1, 0
movs r2, 0
bl ChangeBgX
movs r0, 0x1
movs r1, 0
movs r2, 0
bl ChangeBgY
movs r0, 0x2
bl ShowBg
movs r0, 0x3
bl ShowBg
movs r0, 0x1
bl ShowBg
bl sub_81CC214
movs r0, 0x3
bl LoadLeftHeaderGfxForIndex
movs r0, 0x3
movs r1, 0x1
movs r2, 0
bl sub_81C7FA0
movs r0, 0x1
bl sub_81C7AC0
movs r0, 0
b _081CB506
_081CB4EA:
bl IsPaletteFadeActive
cmp r0, 0
bne _081CB4FA
bl sub_81C8010
cmp r0, 0
beq _081CB4FE
_081CB4FA:
movs r0, 0x2
b _081CB506
_081CB4FE:
movs r0, 0x1
bl sub_81CBC38
_081CB504:
movs r0, 0x4
_081CB506:
add sp, 0x8
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81CB324
thumb_func_start sub_81CB510
sub_81CB510: @ 81CB510
push {r4,r5,lr}
adds r4, r0, 0
movs r0, 0x6
bl GetSubstructPtr
adds r5, r0, 0
cmp r4, 0x1
beq _081CB55E
cmp r4, 0x1
bgt _081CB52A
cmp r4, 0
beq _081CB534
b _081CB580
_081CB52A:
cmp r4, 0x2
beq _081CB566
cmp r4, 0x3
beq _081CB572
b _081CB580
_081CB534:
bl MatchCall_MoveCursorDown
cmp r0, 0x1
beq _081CB54C
cmp r0, 0x1
bgt _081CB546
cmp r0, 0
beq _081CB580
b _081CB56E
_081CB546:
cmp r0, 0x2
beq _081CB556
b _081CB56E
_081CB54C:
movs r0, 0x5
bl PlaySE
movs r0, 0x7
b _081CB582
_081CB556:
movs r0, 0x5
bl PlaySE
b _081CB56E
_081CB55E:
bl sub_81C8630
cmp r0, 0
bne _081CB57C
_081CB566:
adds r0, r5, 0
movs r1, 0
bl sub_81CBEF8
_081CB56E:
movs r0, 0
b _081CB582
_081CB572:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
beq _081CB580
_081CB57C:
movs r0, 0x2
b _081CB582
_081CB580:
movs r0, 0x4
_081CB582:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81CB510
thumb_func_start sub_81CB588
sub_81CB588: @ 81CB588
push {r4,r5,lr}
adds r4, r0, 0
movs r0, 0x6
bl GetSubstructPtr
adds r5, r0, 0
cmp r4, 0x1
beq _081CB5D6
cmp r4, 0x1
bgt _081CB5A2
cmp r4, 0
beq _081CB5AC
b _081CB5F8
_081CB5A2:
cmp r4, 0x2
beq _081CB5DE
cmp r4, 0x3
beq _081CB5EA
b _081CB5F8
_081CB5AC:
bl MatchCall_MoveCursorUp
cmp r0, 0x1
beq _081CB5C4
cmp r0, 0x1
bgt _081CB5BE
cmp r0, 0
beq _081CB5F8
b _081CB5E6
_081CB5BE:
cmp r0, 0x2
beq _081CB5CE
b _081CB5E6
_081CB5C4:
movs r0, 0x5
bl PlaySE
movs r0, 0x7
b _081CB5FA
_081CB5CE:
movs r0, 0x5
bl PlaySE
b _081CB5E6
_081CB5D6:
bl sub_81C8630
cmp r0, 0
bne _081CB5F4
_081CB5DE:
adds r0, r5, 0
movs r1, 0
bl sub_81CBEF8
_081CB5E6:
movs r0, 0
b _081CB5FA
_081CB5EA:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
beq _081CB5F8
_081CB5F4:
movs r0, 0x2
b _081CB5FA
_081CB5F8:
movs r0, 0x4
_081CB5FA:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81CB588
thumb_func_start sub_81CB600
sub_81CB600: @ 81CB600
push {r4,r5,lr}
adds r4, r0, 0
movs r0, 0x6
bl GetSubstructPtr
adds r5, r0, 0
cmp r4, 0x1
beq _081CB64E
cmp r4, 0x1
bgt _081CB61A
cmp r4, 0
beq _081CB624
b _081CB670
_081CB61A:
cmp r4, 0x2
beq _081CB656
cmp r4, 0x3
beq _081CB662
b _081CB670
_081CB624:
bl MatchCall_PageDown
cmp r0, 0x1
beq _081CB63C
cmp r0, 0x1
bgt _081CB636
cmp r0, 0
beq _081CB670
b _081CB65E
_081CB636:
cmp r0, 0x2
beq _081CB646
b _081CB65E
_081CB63C:
movs r0, 0x5
bl PlaySE
movs r0, 0x7
b _081CB672
_081CB646:
movs r0, 0x5
bl PlaySE
b _081CB65E
_081CB64E:
bl sub_81C8630
cmp r0, 0
bne _081CB66C
_081CB656:
adds r0, r5, 0
movs r1, 0
bl sub_81CBEF8
_081CB65E:
movs r0, 0
b _081CB672
_081CB662:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
beq _081CB670
_081CB66C:
movs r0, 0x2
b _081CB672
_081CB670:
movs r0, 0x4
_081CB672:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81CB600
thumb_func_start sub_81CB678
sub_81CB678: @ 81CB678
push {r4,r5,lr}
adds r4, r0, 0
movs r0, 0x6
bl GetSubstructPtr
adds r5, r0, 0
cmp r4, 0x1
beq _081CB6C6
cmp r4, 0x1
bgt _081CB692
cmp r4, 0
beq _081CB69C
b _081CB6E8
_081CB692:
cmp r4, 0x2
beq _081CB6CE
cmp r4, 0x3
beq _081CB6DA
b _081CB6E8
_081CB69C:
bl MatchCall_PageUp
cmp r0, 0x1
beq _081CB6B4
cmp r0, 0x1
bgt _081CB6AE
cmp r0, 0
beq _081CB6E8
b _081CB6D6
_081CB6AE:
cmp r0, 0x2
beq _081CB6BE
b _081CB6D6
_081CB6B4:
movs r0, 0x5
bl PlaySE
movs r0, 0x7
b _081CB6EA
_081CB6BE:
movs r0, 0x5
bl PlaySE
b _081CB6D6
_081CB6C6:
bl sub_81C8630
cmp r0, 0
bne _081CB6E4
_081CB6CE:
adds r0, r5, 0
movs r1, 0
bl sub_81CBEF8
_081CB6D6:
movs r0, 0
b _081CB6EA
_081CB6DA:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
beq _081CB6E8
_081CB6E4:
movs r0, 0x2
b _081CB6EA
_081CB6E8:
movs r0, 0x4
_081CB6EA:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_81CB678
thumb_func_start sub_81CB6F0
sub_81CB6F0: @ 81CB6F0
push {r4,r5,lr}

View File

@ -1,6 +1,8 @@
#ifndef GUARD_POKENAV_H
#define GUARD_POKENAV_H
#include "bg.h"
typedef u32 (*LoopedTask)(int state);
// Return values of LoopedTask functions.
@ -56,6 +58,12 @@ bool32 CanViewRibbonsMenu(void);
// pokenav_match_call_ui.c
u32 GetSelectedMatchCall(void);
bool32 sub_81C8224(void);
int MatchCall_MoveCursorUp(void);
int MatchCall_MoveCursorDown(void);
int MatchCall_PageDown(void);
int MatchCall_PageUp(void);
bool32 sub_81C8630(void);
// pokenav_match_call_data.c
bool32 sub_81D17E8(u32 idx);
@ -74,6 +82,12 @@ bool32 InitPokenavMainMenu(void);
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size);
void sub_81C7850(u32 a0);
u32 sub_81C786C(void);
void LoadLeftHeaderGfxForIndex(u32 arg0);
void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2);
void sub_81C7AC0(int a0);
bool32 sub_81C8010(void);
void InitBgTemplates(const struct BgTemplate *templates, int count);
bool32 IsPaletteFadeActive(void);
// pokenav_unk_1.c
bool32 sub_81C9298(void);

View File

@ -505,7 +505,7 @@ struct MatchCallWindowState *GetMatchCallWindowStruct(void)
return &structPtr->unk888;
}
u32 MatchCall_MoveCursorUp(void)
int MatchCall_MoveCursorUp(void)
{
struct MatchCallWindowState *structPtr;
structPtr = GetMatchCallWindowStruct();
@ -529,7 +529,7 @@ u32 MatchCall_MoveCursorUp(void)
}
}
u32 MatchCall_MoveCursorDown(void)
int MatchCall_MoveCursorDown(void)
{
struct MatchCallWindowState *structPtr;
structPtr = GetMatchCallWindowStruct();
@ -554,7 +554,7 @@ u32 MatchCall_MoveCursorDown(void)
return 2;
}
u32 MatchCall_PageUp(void)
int MatchCall_PageUp(void)
{
struct MatchCallWindowState *structPtr;
s32 scroll;
@ -580,7 +580,7 @@ u32 MatchCall_PageUp(void)
}
}
u32 MatchCall_PageDown(void)
int MatchCall_PageDown(void)
{
struct MatchCallWindowState *structPtr;
structPtr = GetMatchCallWindowStruct();

View File

@ -1,6 +1,10 @@
#include "global.h"
#include "bg.h"
#include "menu.h"
#include "pokenav.h"
#include "sound.h"
#include "window.h"
#include "constants/songs.h"
struct Pokenav4Struct
{
@ -14,15 +18,34 @@ struct Pokenav4Struct
u8 unk14;
u8 filler15[0x4];
u8 unk19;
u8 filler1A[0x202E];
u8 filler1A[0xA];
u8 unk24[0x800];
u8 unk824[0x800];
u8 unk1024[0x800];
u8 unk1824[0x824];
};
static bool32 sub_81CB310(void);
u32 sub_81CB324(int);
static u32 sub_81CB324(int);
void sub_81CBC1C(void);
void sub_81CC2B4(void);
void sub_81CC034(struct Pokenav4Struct *);
void sub_81CBBB8(void);
void sub_81CBD78(struct Pokenav4Struct *);
void sub_81CBDC0(struct Pokenav4Struct *);
void sub_81CBEF8(struct Pokenav4Struct *, int);
void sub_81CC214(void);
void sub_81CBC38(int);
extern const LoopedTask gUnknown_08622798[];
extern const struct BgTemplate gUnknown_0862278C[3];
extern const u16 gUnknown_08622510[];
extern const u32 gUnknown_08622530[];
extern const u32 gUnknown_08622760[];
extern const u16 gUnknown_08622700[];
extern const u16 gUnknown_08622720[];
extern const u8 gUnknown_086225D4[];
extern const u16 gUnknown_086226E0[];
bool32 sub_81CB260(void)
{
@ -65,3 +88,224 @@ static bool32 sub_81CB310(void)
struct Pokenav4Struct *state = GetSubstructPtr(6);
return IsLoopedTaskActive(state->unk4);
}
static u32 sub_81CB324(int taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
{
case 0:
InitBgTemplates(gUnknown_0862278C, ARRAY_COUNT(gUnknown_0862278C));
ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0);
decompress_and_copy_tile_data_to_vram(2, gUnknown_08622530, 0, 0, 0);
SetBgTilemapBuffer(2, state->unk1024);
CopyToBgTilemapBuffer(2, gUnknown_086225D4, 0, 0);
CopyBgTilemapBufferToVram(2);
CopyPaletteIntoBufferUnfaded(gUnknown_08622510, 0x20, 0x20);
CopyBgTilemapBufferToVram(2);
return 0;
case 1:
if (free_temp_tile_data_buffers_if_possible())
return 2;
sub_8199DF0(1, 0, 0, 1);
SetBgTilemapBuffer(1, state->unk24);
FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20);
CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20);
CopyBgTilemapBufferToVram(1);
return 0;
case 2:
if (free_temp_tile_data_buffers_if_possible())
return 2;
sub_81CC034(state);
decompress_and_copy_tile_data_to_vram(3, gUnknown_08622760, 0, 0, 0);
CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20);
CopyPaletteIntoBufferUnfaded(gUnknown_08622720, 0x50, 0x20);
return 0;
case 3:
if (free_temp_tile_data_buffers_if_possible() || !sub_81CAE28())
return 2;
sub_81CBBB8();
return 0;
case 4:
if (sub_81C8224())
return 2;
sub_81CBD78(state);
return 0;
case 5:
sub_81CBDC0(state);
sub_81CBEF8(state, 0);
return 0;
case 6:
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ShowBg(2);
ShowBg(3);
ShowBg(1);
sub_81CC214();
LoadLeftHeaderGfxForIndex(3);
sub_81C7FA0(3, 1, 0);
sub_81C7AC0(1);
return 0;
case 7:
if (IsPaletteFadeActive() || sub_81C8010())
return 2;
sub_81CBC38(1);
return 4;
default:
return 4;
}
}
u32 sub_81CB510(int taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
{
case 0:
switch (MatchCall_MoveCursorDown())
{
case 0:
break;
case 1:
PlaySE(SE_SELECT);
return 7;
case 2:
PlaySE(SE_SELECT);
// fall through
default:
return 0;
}
break;
case 1:
if (sub_81C8630())
return 2;
sub_81CBEF8(state, 0);
return 0;
case 2:
sub_81CBEF8(state, 0);
return 0;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return 2;
break;
}
return 4;
}
u32 sub_81CB588(int taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
{
case 0:
switch (MatchCall_MoveCursorUp())
{
case 0:
break;
case 1:
PlaySE(SE_SELECT);
return 7;
case 2:
PlaySE(SE_SELECT);
// fall through
default:
return 0;
}
break;
case 1:
if (sub_81C8630())
return 2;
sub_81CBEF8(state, 0);
return 0;
case 2:
sub_81CBEF8(state, 0);
return 0;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return 2;
break;
}
return 4;
}
u32 sub_81CB600(int taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
{
case 0:
switch (MatchCall_PageDown())
{
case 0:
break;
case 1:
PlaySE(SE_SELECT);
return 7;
case 2:
PlaySE(SE_SELECT);
// fall through
default:
return 0;
}
break;
case 1:
if (sub_81C8630())
return 2;
sub_81CBEF8(state, 0);
return 0;
case 2:
sub_81CBEF8(state, 0);
return 0;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return 2;
break;
}
return 4;
}
u32 sub_81CB678(int taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
{
case 0:
switch (MatchCall_PageUp())
{
case 0:
break;
case 1:
PlaySE(SE_SELECT);
return 7;
case 2:
PlaySE(SE_SELECT);
// fall through
default:
return 0;
}
break;
case 1:
if (sub_81C8630())
return 2;
sub_81CBEF8(state, 0);
return 0;
case 2:
sub_81CBEF8(state, 0);
return 0;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return 2;
break;
}
return 4;
}