2019-02-11 20:59:44 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "alloc.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "overworld.h"
|
2019-02-12 07:39:27 +01:00
|
|
|
#include "field_weather.h"
|
2019-02-12 08:23:08 +01:00
|
|
|
#include "palette.h"
|
2019-02-12 09:48:32 +01:00
|
|
|
#include "pokemon_storage_system.h"
|
2019-02-13 06:07:48 +01:00
|
|
|
#include "sound.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "window.h"
|
2019-02-13 08:31:24 +01:00
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "graphics.h"
|
2019-02-14 03:37:34 +01:00
|
|
|
#include "gba/macro.h"
|
2019-02-14 23:26:34 +01:00
|
|
|
#include "decompress.h"
|
2019-02-15 05:25:07 +01:00
|
|
|
#include "strings.h"
|
2019-02-18 06:16:27 +01:00
|
|
|
#include "constants/rgb.h"
|
2019-02-12 08:23:08 +01:00
|
|
|
|
2019-02-13 02:57:51 +01:00
|
|
|
#define UNKNOWN_OFFSET 100000
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
struct UnknownStruct_0203CF40
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 (*field0)(void);
|
|
|
|
u32 field4;
|
|
|
|
u16 field8;
|
|
|
|
u16 fieldA;
|
|
|
|
u32 fieldC;
|
|
|
|
void *field10[19];
|
2019-02-13 09:19:27 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
struct UnknownStruct_sub_81C76C4
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 data[523];
|
2019-02-13 04:35:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 04:18:47 +01:00
|
|
|
extern u32 sub_81C9430(void);
|
2019-02-13 06:07:48 +01:00
|
|
|
extern void sub_81CAADC(void);
|
2019-02-15 04:18:47 +01:00
|
|
|
extern u32 sub_81C99D4(void);
|
2019-02-13 08:31:24 +01:00
|
|
|
extern void sub_8199D98(void);
|
|
|
|
extern void sub_81C7D28(void);
|
2019-02-15 04:18:47 +01:00
|
|
|
extern u32 sub_81C9298(void);
|
|
|
|
extern u32 sub_81C941C(void);
|
|
|
|
extern u32 sub_81C9924(void);
|
|
|
|
extern u32 sub_81C99C0(void);
|
|
|
|
extern u32 sub_81C9990(void);
|
|
|
|
extern u32 sub_81C9940(void);
|
|
|
|
extern u32 sub_81C9338(void);
|
|
|
|
extern u32 sub_81C9368(void);
|
|
|
|
extern u32 sub_81C92CC(void);
|
|
|
|
extern u32 sub_81C9304(void);
|
|
|
|
extern u32 sub_81CC4D4(void);
|
|
|
|
extern u32 sub_81CC554(void);
|
|
|
|
extern u32 sub_81CC5F4(void);
|
|
|
|
extern u32 sub_81CC62C(void);
|
|
|
|
extern u32 sub_81CC65C(void);
|
|
|
|
extern u32 sub_81CC524(void);
|
|
|
|
extern u32 sub_81CC670(void);
|
|
|
|
extern u32 sub_81CCFD8(void);
|
|
|
|
extern u32 sub_81CD070(void);
|
|
|
|
extern u32 sub_81CDDD4(void);
|
|
|
|
extern u32 sub_81CDE2C(void);
|
|
|
|
extern u32 sub_81CDE64(void);
|
|
|
|
extern u32 sub_81CD1C0(void);
|
|
|
|
extern u32 sub_81CECA0(void);
|
|
|
|
extern u32 sub_81CEF3C(void);
|
|
|
|
extern u32 sub_81CEFDC(void);
|
|
|
|
extern u32 sub_81CF330(void);
|
|
|
|
extern u32 sub_81CF3A0(void);
|
|
|
|
extern u32 sub_81CF3D0(void);
|
|
|
|
extern u32 sub_81CEFF0(void);
|
|
|
|
extern u32 sub_81CF3F8(void);
|
|
|
|
extern u32 sub_81CD024(void);
|
|
|
|
extern u32 sub_81CEF98(void);
|
|
|
|
extern u32 sub_81CF368(void);
|
|
|
|
extern u32 sub_81CAAE8(void);
|
|
|
|
extern u32 sub_81CAB24(void);
|
|
|
|
extern u32 sub_81CB260(void);
|
|
|
|
extern u32 sub_81CB29C(void);
|
|
|
|
extern u32 sub_81CB2CC(void);
|
|
|
|
extern u32 sub_81CAB38(void);
|
|
|
|
extern u32 sub_81CB2E0(void);
|
|
|
|
extern u32 sub_81CF9BC(void);
|
|
|
|
extern u32 sub_81CFA34(void);
|
|
|
|
extern u32 sub_81CFDD0(void);
|
|
|
|
extern u32 sub_81CFE40(void);
|
|
|
|
extern u32 sub_81CFE70(void);
|
|
|
|
extern u32 sub_81CFA48(void);
|
|
|
|
extern u32 sub_81CFE98(void);
|
|
|
|
extern u32 sub_81D0450(void);
|
|
|
|
extern u32 sub_81D04A0(void);
|
|
|
|
extern u32 sub_81D0978(void);
|
|
|
|
extern u32 sub_81D09B0(void);
|
|
|
|
extern u32 sub_81D09E0(void);
|
|
|
|
extern u32 sub_81D04B8(void);
|
|
|
|
extern u32 sub_81D09F4(void);
|
|
|
|
extern u32 sub_81CFA04(void);
|
|
|
|
extern u32 sub_81CFE08(void);
|
2019-02-13 04:35:07 +01:00
|
|
|
|
2019-02-14 03:37:34 +01:00
|
|
|
u32 sub_81C791C(s32 a0);
|
2019-02-13 02:57:51 +01:00
|
|
|
bool32 sub_81C756C(u32 a0);
|
2019-02-13 04:35:07 +01:00
|
|
|
bool32 sub_81C76C4(void);
|
2019-02-13 02:20:15 +01:00
|
|
|
u32 AnyMonHasRibbon(void);
|
2019-02-13 03:33:15 +01:00
|
|
|
u32 sub_81C75E0(void);
|
|
|
|
u32 sub_81C75D4(void);
|
2019-02-13 06:07:48 +01:00
|
|
|
u32 sub_81C76FC(void);
|
2019-02-13 09:19:27 +01:00
|
|
|
u32 sub_81C786C(void);
|
2019-02-13 08:31:24 +01:00
|
|
|
u32 sub_81C7764(s32 a0);
|
2019-02-14 03:37:34 +01:00
|
|
|
u32 atk47_cmd47(s32 a0);
|
2019-02-13 06:07:48 +01:00
|
|
|
bool32 sub_81C7738(void);
|
2019-02-15 06:00:01 +01:00
|
|
|
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 a1, u32 a2);
|
2019-02-13 09:19:27 +01:00
|
|
|
void sub_81C7834(u32 (*a0)(void), u32(*a1)(void));
|
2019-02-13 04:18:12 +01:00
|
|
|
void sub_81C7360(struct UnknownStruct_0203CF40 *a0);
|
|
|
|
void sub_81C7650(u32 index);
|
2019-02-13 09:19:27 +01:00
|
|
|
void sub_81C7850(u32 a0);
|
2019-02-14 23:26:34 +01:00
|
|
|
void sub_81C7BF8(u32 a0);
|
2019-02-13 02:20:15 +01:00
|
|
|
void sub_81C71E4(u8 a0);
|
|
|
|
void sub_81C7170(u8 a0);
|
2019-02-13 04:18:12 +01:00
|
|
|
void sub_81C742C(u8 taskId);
|
2019-02-13 06:07:48 +01:00
|
|
|
void sub_81C7710(void);
|
2019-02-13 04:18:12 +01:00
|
|
|
void sub_81C75F4(void);
|
|
|
|
void sub_81C7334(void);
|
2019-02-13 02:20:15 +01:00
|
|
|
void sub_81C7418(void);
|
|
|
|
void sub_81C7400(void);
|
2019-02-14 23:26:34 +01:00
|
|
|
void sub_81C7C28(void);
|
2019-02-12 08:23:08 +01:00
|
|
|
void sub_81C72BC(void);
|
2019-02-14 22:30:52 +01:00
|
|
|
void sub_81C7B74(void);
|
2019-02-15 03:03:52 +01:00
|
|
|
void sub_81C7C94(void);
|
2019-02-12 08:23:08 +01:00
|
|
|
|
2019-02-15 04:18:47 +01:00
|
|
|
|
2019-02-15 05:25:07 +01:00
|
|
|
u32 (*const gUnknown_0861F3EC[15][7])(void) =
|
2019-02-15 04:18:47 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
2019-02-18 06:16:27 +01:00
|
|
|
sub_81C9298,
|
2019-02-15 06:29:32 +01:00
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9924,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81C9298,
|
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9940,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81C9338,
|
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9940,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81C9368,
|
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9940,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81C92CC,
|
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9940,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81C9304,
|
|
|
|
sub_81C941C,
|
|
|
|
sub_81C9940,
|
|
|
|
sub_81C9990,
|
|
|
|
sub_81C99C0,
|
|
|
|
sub_81C9430,
|
|
|
|
sub_81C99D4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CC4D4,
|
|
|
|
sub_81CC554,
|
|
|
|
sub_81CC5F4,
|
|
|
|
sub_81CC62C,
|
|
|
|
sub_81CC65C,
|
|
|
|
sub_81CC524,
|
|
|
|
sub_81CC670,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CCFD8,
|
|
|
|
sub_81CD070,
|
|
|
|
sub_81CDDD4,
|
|
|
|
sub_81CDE2C,
|
|
|
|
sub_81CDE64,
|
|
|
|
sub_81CD1C0,
|
|
|
|
sub_81CECA0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CEF3C,
|
|
|
|
sub_81CEFDC,
|
|
|
|
sub_81CF330,
|
|
|
|
sub_81CF3A0,
|
|
|
|
sub_81CF3D0,
|
|
|
|
sub_81CEFF0,
|
|
|
|
sub_81CF3F8,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CD024,
|
|
|
|
sub_81CD070,
|
|
|
|
sub_81CDDD4,
|
|
|
|
sub_81CDE2C,
|
|
|
|
sub_81CDE64,
|
|
|
|
sub_81CD1C0,
|
|
|
|
sub_81CECA0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CEF98,
|
|
|
|
sub_81CEFDC,
|
|
|
|
sub_81CF368,
|
|
|
|
sub_81CF3A0,
|
|
|
|
sub_81CF3D0,
|
|
|
|
sub_81CEFF0,
|
|
|
|
sub_81CF3F8,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CAAE8,
|
|
|
|
sub_81CAB24,
|
|
|
|
sub_81CB260,
|
|
|
|
sub_81CB29C,
|
|
|
|
sub_81CB2CC,
|
|
|
|
sub_81CAB38,
|
|
|
|
sub_81CB2E0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CF9BC,
|
|
|
|
sub_81CFA34,
|
|
|
|
sub_81CFDD0,
|
|
|
|
sub_81CFE40,
|
|
|
|
sub_81CFE70,
|
|
|
|
sub_81CFA48,
|
|
|
|
sub_81CFE98,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81D0450,
|
|
|
|
sub_81D04A0,
|
|
|
|
sub_81D0978,
|
|
|
|
sub_81D09B0,
|
|
|
|
sub_81D09E0,
|
|
|
|
sub_81D04B8,
|
|
|
|
sub_81D09F4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sub_81CFA04,
|
|
|
|
sub_81CFA34,
|
|
|
|
sub_81CFE08,
|
|
|
|
sub_81CFE40,
|
|
|
|
sub_81CFE70,
|
|
|
|
sub_81CFA48,
|
|
|
|
sub_81CFE98,
|
|
|
|
},
|
2019-02-15 04:18:47 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 05:25:07 +01:00
|
|
|
const u16 gUnknown_0861F590[] = INCBIN_U16("graphics/pokenav/icon2.gbapal");
|
|
|
|
const u32 gUnknown_0861F5B0[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz");
|
|
|
|
const u32 gUnknown_0861F994[] = INCBIN_U32("graphics/pokenav/icon2_unused.4bpp.lz");
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const struct BgTemplate gUnknown_0861FA04 =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 5,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0,
|
2019-02-15 05:25:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const struct WindowTemplate gUnknown_0861FA08[2] =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2019-02-18 06:16:27 +01:00
|
|
|
.tilemapTop = 22,
|
|
|
|
.width = 16,
|
|
|
|
.height = 2,
|
2019-02-15 06:29:32 +01:00
|
|
|
.paletteNum = 0,
|
|
|
|
.baseBlock = 0x36,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0xFF,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 0,
|
|
|
|
.height = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.baseBlock = 0,
|
|
|
|
},
|
2019-02-15 05:25:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const u8 *const (MenuButtonReminders[12]) =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
gText_Navgear_ClearButtonList,
|
|
|
|
gText_NavgearMap_ZoomedOutButtons,
|
|
|
|
gText_NavgearMap_ZoomedInButtons,
|
|
|
|
gText_NavgearCondition_MonListButtons,
|
|
|
|
gText_NavgearCondition_MonStatusButtons,
|
|
|
|
gText_NavgearCondition_MarkingButtons,
|
|
|
|
gText_NavgearMatchCall_TrainerListButtons,
|
|
|
|
gText_NavgearMatchCall_CallMenuButtons,
|
|
|
|
gText_NavgearMatchCall_CheckTrainerButtons,
|
|
|
|
gText_NavgearRibbons_MonListButtons,
|
|
|
|
gText_NavgearRibbons_RibbonListButtons,
|
|
|
|
gText_NavgearRibbons_RibbonCheckButtons,
|
2019-02-15 05:25:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const u8 gMenuButtonReminderColor[4] =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
4, 1, 2, 0
|
2019-02-15 05:25:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const struct CompressedSpriteSheet gUnknown_0861FA4C[1] =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
|
|
|
.data = gUnknown_0861F5B0,
|
|
|
|
.size = 0x1000,
|
|
|
|
.tag = 0,
|
|
|
|
}
|
2019-02-15 05:25:07 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const struct SpritePalette gUnknown_0861FA54[2] =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
|
|
|
.data = gUnknown_0861F590,
|
|
|
|
.tag = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = NULL,
|
|
|
|
.tag = 0,
|
|
|
|
}
|
2019-02-15 06:00:01 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
const struct CompressedSpriteSheet gUnknown_0861FA64 =
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0xC00,
|
|
|
|
.tag = 2
|
2019-02-15 06:00:01 +01:00
|
|
|
};
|
|
|
|
|
2019-02-15 04:18:47 +01:00
|
|
|
extern struct UnknownStruct_0203CF40 *gUnknown_0203CF40;
|
|
|
|
extern u8 gUnknown_0203CF3C;
|
|
|
|
extern const struct SpriteTemplate gUnknown_0861FB04;
|
|
|
|
|
2019-02-13 08:31:24 +01:00
|
|
|
u32 sub_81C7078(u32 (*a0)(s32), u32 a1)
|
2019-02-11 20:59:44 +01:00
|
|
|
{
|
|
|
|
u16 taskId;
|
|
|
|
|
2019-02-11 22:06:46 +01:00
|
|
|
if (!is_c1_link_related_active())
|
2019-02-11 20:59:44 +01:00
|
|
|
taskId = CreateTask(sub_81C7170, a1);
|
2019-02-15 06:29:32 +01:00
|
|
|
else
|
2019-02-11 20:59:44 +01:00
|
|
|
taskId = CreateTask(sub_81C71E4, a1);
|
|
|
|
|
2019-02-12 06:51:54 +01:00
|
|
|
SetWordTaskArg(taskId, 1, (u32)a0);
|
2019-02-11 20:59:44 +01:00
|
|
|
|
|
|
|
gTasks[taskId].data[3] = gUnknown_0203CF3C;
|
|
|
|
return ((gUnknown_0203CF3C++) << 16) | taskId;
|
|
|
|
}
|
|
|
|
|
2019-02-13 06:07:48 +01:00
|
|
|
bool32 sub_81C70D8(u32 a0)
|
2019-02-11 22:35:02 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 v1 = a0 & 0xFFFF;
|
|
|
|
u32 v2 = a0 >> 16;
|
|
|
|
if (gTasks[v1].isActive
|
|
|
|
&& (gTasks[v1].func == sub_81C7170 || gTasks[v1].func == sub_81C71E4)
|
|
|
|
&& gTasks[v1].data[3] == v2)
|
|
|
|
{
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return FALSE;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-11 22:06:46 +01:00
|
|
|
}
|
|
|
|
|
2019-02-11 22:35:02 +01:00
|
|
|
bool32 sub_81C7124(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s32 i;
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
if (gTasks[i].isActive
|
|
|
|
&& (gTasks[i].func == sub_81C7170 || gTasks[i].func == sub_81C71E4))
|
|
|
|
{
|
|
|
|
u32 arg = GetWordTaskArg((u8)i, 1);
|
|
|
|
if (arg == a0)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
2019-02-12 06:51:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81C7170(u8 taskId)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s16 *dataPtr;
|
|
|
|
u32 (*func)(u32);
|
|
|
|
bool32 exitLoop;
|
|
|
|
|
|
|
|
func = (u32 (*)(u32))GetWordTaskArg(taskId, 1);
|
|
|
|
dataPtr = gTasks[taskId].data;
|
|
|
|
exitLoop = FALSE;
|
|
|
|
while (!exitLoop)
|
|
|
|
{
|
|
|
|
u32 v1 =((u32 (*)(u32))func)(dataPtr[0]);
|
2019-02-16 18:09:27 +01:00
|
|
|
switch (v1)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
case 1:
|
|
|
|
dataPtr[0] = dataPtr[0] + 1;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
dataPtr[0]++;
|
|
|
|
return;
|
|
|
|
case 4:
|
|
|
|
DestroyTask(taskId);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
dataPtr[0] = v1 - 5;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-02-12 07:30:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C71E4(u8 taskId)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 (*func)(u32);
|
|
|
|
s16 *data;
|
|
|
|
u32 v1;
|
|
|
|
|
|
|
|
if (sub_8087598())
|
|
|
|
return;
|
|
|
|
func = (u32 (*)(u32))GetWordTaskArg(taskId, 1);
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
v1 = func(data[0]);
|
|
|
|
switch (v1)
|
|
|
|
{
|
2019-02-16 18:09:27 +01:00
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
data[0]++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
data[0] = v1 - 5;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2019-02-18 06:16:27 +01:00
|
|
|
break;
|
2019-02-15 06:29:32 +01:00
|
|
|
}
|
2019-02-12 07:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CB2_PokeNav(void)
|
|
|
|
{
|
2019-02-12 08:23:08 +01:00
|
|
|
gUnknown_0203CF40 = Alloc(sizeof(struct UnknownStruct_0203CF40));
|
2019-02-16 18:09:27 +01:00
|
|
|
if (gUnknown_0203CF40 == NULL)
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-12 07:34:43 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-16 18:09:27 +01:00
|
|
|
else
|
|
|
|
{
|
2019-02-12 08:59:17 +01:00
|
|
|
sub_81C7360(gUnknown_0203CF40);
|
2019-02-12 07:34:43 +01:00
|
|
|
ResetTasks();
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
CreateTask(sub_81C742C, 0);
|
|
|
|
SetMainCallback2(sub_81C7400);
|
|
|
|
SetVBlankCallback(sub_81C7418);
|
|
|
|
}
|
2019-02-12 07:39:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C72A4()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
SetMainCallback2(sub_81C72BC);
|
|
|
|
FadeScreen(1, 0);
|
2019-02-12 08:23:08 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C72BC()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
UpdatePaletteFade();
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gUnknown_0203CF40 = Alloc(sizeof(struct UnknownStruct_0203CF40));
|
|
|
|
if (gUnknown_0203CF40 == NULL)
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-15 06:29:32 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_81C7360(gUnknown_0203CF40);
|
|
|
|
gUnknown_0203CF40->field8 = 1;
|
|
|
|
ResetTasks();
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
CreateTask(sub_81C742C, 0);
|
|
|
|
SetMainCallback2(sub_81C7400);
|
|
|
|
SetVBlankCallback(sub_81C7418);
|
|
|
|
}
|
|
|
|
}
|
2019-02-12 08:28:46 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7334()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s32 i;
|
|
|
|
for (i = 0; i < 19; i++)
|
|
|
|
{
|
|
|
|
sub_81C7650(i);
|
|
|
|
}
|
2019-02-12 08:28:46 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
Free(gUnknown_0203CF40);
|
|
|
|
gUnknown_0203CF40 = NULL;
|
|
|
|
InitKeys();
|
2019-02-12 08:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clears UnknownStruct_0203CF40
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7360(struct UnknownStruct_0203CF40 *a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s32 i;
|
|
|
|
void **arrayPtr;
|
|
|
|
void *fill;
|
|
|
|
|
|
|
|
fill = NULL;
|
|
|
|
i = 18;
|
|
|
|
arrayPtr = &(a0->field10[18]);
|
|
|
|
for (i; i >= 0; i--)
|
|
|
|
{
|
|
|
|
*arrayPtr = fill;
|
|
|
|
arrayPtr -= 1;
|
|
|
|
}
|
|
|
|
a0->field8 = 0;
|
|
|
|
a0->field4 = 0;
|
|
|
|
a0->fieldC = AnyMonHasRibbon();
|
|
|
|
a0->field0 = NULL;
|
2019-02-12 09:48:32 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 AnyMonHasRibbon()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s32 i;
|
|
|
|
s32 j;
|
|
|
|
|
2019-02-18 06:16:27 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_EGG)
|
|
|
|
&& GetMonData(&gPlayerParty[i], MON_DATA_RIBBON_COUNT) != 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-18 06:16:27 +01:00
|
|
|
for (j = 0; j < TOTAL_BOXES_COUNT; j++)
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
2019-02-18 06:16:27 +01:00
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
2019-02-15 06:29:32 +01:00
|
|
|
{
|
|
|
|
if (CheckBoxMonSanityAt(j, i)
|
|
|
|
&& GetBoxMonDataAt(j, i, MON_DATA_RIBBON_COUNT) != 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2019-02-12 09:51:48 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7400()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
2019-02-12 09:54:35 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7418()
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
TransferPlttBuffer();
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
2019-02-13 02:20:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C742C(u8 taskId)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s16 *dataPtr;
|
|
|
|
u32 v1;
|
|
|
|
bool32 v2;
|
|
|
|
|
|
|
|
dataPtr = gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (dataPtr[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_81C76C4();
|
|
|
|
dataPtr[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (sub_81C76FC())
|
|
|
|
break;
|
|
|
|
sub_81C756C(UNKNOWN_OFFSET);
|
|
|
|
dataPtr[0] = 4;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (sub_81C786C())
|
|
|
|
break;
|
|
|
|
dataPtr[0] = 3;
|
|
|
|
case 3:
|
|
|
|
v1 = sub_81C75E0();
|
|
|
|
if (v1 == -1)
|
|
|
|
{
|
|
|
|
sub_81C7710();
|
|
|
|
dataPtr[0] = 5;
|
|
|
|
}
|
|
|
|
else if (v1 >= UNKNOWN_OFFSET)
|
|
|
|
{
|
|
|
|
gUnknown_0861F3EC[gUnknown_0203CF40->field4][6]();
|
|
|
|
gUnknown_0861F3EC[gUnknown_0203CF40->field4][5]();
|
|
|
|
if (sub_81C756C(v1))
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
dataPtr[0] = 4;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-15 06:29:32 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_81C7710();
|
|
|
|
dataPtr[0] = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (v1 != 0)
|
|
|
|
{
|
|
|
|
sub_81C7850(v1);
|
|
|
|
if (sub_81C786C())
|
|
|
|
dataPtr[0] = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!sub_81C75D4())
|
|
|
|
dataPtr[0] = 3;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!sub_81C7738())
|
|
|
|
{
|
|
|
|
v2 = gUnknown_0203CF40->field8 != 0;
|
|
|
|
sub_81C9430();
|
|
|
|
sub_81C7334();
|
|
|
|
if (v2)
|
|
|
|
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
|
|
|
else
|
|
|
|
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
|
|
|
|
}
|
2019-02-18 06:16:27 +01:00
|
|
|
break;
|
2019-02-15 06:29:32 +01:00
|
|
|
}
|
2019-02-13 02:57:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 sub_81C756C(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 index;
|
|
|
|
|
|
|
|
index = a0 - UNKNOWN_OFFSET;
|
|
|
|
sub_81C75F4();
|
|
|
|
if (!gUnknown_0861F3EC[index][0]())
|
|
|
|
return FALSE;
|
|
|
|
if (!gUnknown_0861F3EC[index][2]())
|
|
|
|
return FALSE;
|
|
|
|
sub_81C7834(gUnknown_0861F3EC[index][3], gUnknown_0861F3EC[index][4]);
|
|
|
|
gUnknown_0203CF40->field0 = gUnknown_0861F3EC[index][1];
|
|
|
|
gUnknown_0203CF40->field4 = index;
|
|
|
|
return TRUE;
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C75D4(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return sub_81C786C();
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C75E0(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->field0();
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C75F4(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
InitKeys();
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void IndirectSetVBlankCallback(IntrCallback callback)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
SetVBlankCallback(callback);
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C760C(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
SetVBlankCallback(sub_81C7418);
|
2019-02-13 03:33:15 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:20:24 +01:00
|
|
|
void *sub_81C761C(u32 index, u32 size)
|
2019-02-15 06:07:57 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->field10[index] = (void*)Alloc(size);
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:20:24 +01:00
|
|
|
void *sub_81C763C(u32 index)
|
2019-02-15 06:07:57 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->field10[index];
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7650(u32 index)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
if (gUnknown_0203CF40->field10[index] != NULL)
|
2019-02-18 06:16:27 +01:00
|
|
|
FREE_AND_SET_NULL(gUnknown_0203CF40->field10[index]);
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u16 sub_81C767C(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->field8;
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7688(u16 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
gUnknown_0203CF40->field8 = a0;
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7694(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 value;
|
|
|
|
value = a0;
|
|
|
|
if (a0 > 4)
|
|
|
|
value = 0;
|
|
|
|
gUnknown_0203CF40->fieldA = value;
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u16 sub_81C76AC(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->fieldA;
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C76B8(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gUnknown_0203CF40->fieldC;
|
2019-02-13 04:18:12 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 sub_81C76C4(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
struct UnknownStruct_sub_81C76C4 *v1;
|
|
|
|
|
|
|
|
v1 = (struct UnknownStruct_sub_81C76C4*)sub_81C761C(0, sizeof(struct UnknownStruct_sub_81C76C4));
|
|
|
|
if (v1 == NULL)
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return FALSE;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-15 06:29:32 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
v1->data[3] = sub_81C7078(sub_81C7764, 1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-13 06:07:48 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C76FC(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
return sub_81C70D8(v1[3]);
|
2019-02-13 06:07:48 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7710(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
PlaySE(SE_PN_OFF);
|
|
|
|
sub_81CAADC();
|
2019-02-18 06:16:27 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK);
|
2019-02-13 06:07:48 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 sub_81C7738(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
sub_81C99D4();
|
|
|
|
sub_81C7C94();
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
return FALSE;
|
|
|
|
} else
|
2019-02-18 06:16:27 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return TRUE;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-13 08:31:24 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C7764(s32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
|
|
|
|
|
|
|
switch (a0)
|
|
|
|
{
|
|
|
|
case 0:
|
2019-02-18 06:16:27 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
2019-02-15 06:29:32 +01:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
|
|
|
InitBgsFromTemplates(0, &gUnknown_0861FA04, 1);
|
|
|
|
sub_8199D98();
|
|
|
|
reset_temp_tile_data_buffers();
|
|
|
|
return 1;
|
|
|
|
case 1:
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
decompress_and_copy_tile_data_to_vram(0, &gPokenavHeader_Gfx, 0, 0, 0);
|
|
|
|
SetBgTilemapBuffer(0, &v1[11]);
|
|
|
|
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
|
|
|
|
CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
return 0;
|
|
|
|
case 2:
|
|
|
|
if (free_temp_tile_data_buffers_if_possible())
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
sub_81C7B74();
|
|
|
|
return 0;
|
|
|
|
case 3:
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
sub_81C7C28();
|
|
|
|
sub_81C7D28();
|
|
|
|
ShowBg(0);
|
|
|
|
return 4;
|
|
|
|
default:
|
|
|
|
return 4;
|
|
|
|
}
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7834(u32 (*a0)(void), u32(*a1)(void))
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 (**v1)(void);
|
2019-02-13 09:19:27 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
v1[0] = a0;
|
|
|
|
v1[1] = a1;
|
|
|
|
v1[2] = NULL;
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7850(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
void (**v1)(u32);
|
2019-02-13 09:19:27 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
v1[2] = NULL;
|
|
|
|
v1[0](a0);
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 sub_81C786C(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 (**v1)(void);
|
2019-02-13 09:19:27 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
return v1[1]();
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7880(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
|
|
|
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
v1[3] = sub_81C7078(atk47_cmd47, 4);
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C78A0(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
2019-02-13 09:19:27 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
v1[3] = sub_81C7078(sub_81C791C, 4);
|
2019-02-13 09:19:27 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 sub_81C78C0(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
2019-02-13 09:19:27 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
return sub_81C70D8(v1[3]);
|
2019-02-14 03:37:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
u32 atk47_cmd47(s32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
switch (a0)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return 4;
|
|
|
|
case 1:
|
|
|
|
return 0;
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
case 2:
|
|
|
|
if ((u32)ChangeBgY(0, 384, 1) >= 0x2000)
|
|
|
|
{
|
|
|
|
ChangeBgY(0, 0x2000, 0);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
2019-02-14 03:37:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 18:09:27 +01:00
|
|
|
u32 sub_81C791C(s32 a0)
|
|
|
|
{
|
|
|
|
if (ChangeBgY(0, 384, 2) <= 0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
ChangeBgY(0, 0, 0);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
return 2;
|
2019-02-14 03:37:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:00:01 +01:00
|
|
|
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size) {
|
2019-02-15 06:29:32 +01:00
|
|
|
CpuCopy16(palette, gPlttBufferUnfaded + bufferOffset, size);
|
2019-02-14 03:37:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C795C(const struct SpritePalette *palettes)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
const struct SpritePalette *current;
|
2019-02-14 05:58:49 +01:00
|
|
|
u32 index;
|
|
|
|
|
2019-02-15 06:00:01 +01:00
|
|
|
for (current = palettes; current->data != NULL; current++)
|
2019-02-14 05:58:49 +01:00
|
|
|
{
|
|
|
|
index = AllocSpritePalette(current->tag);
|
2019-02-18 06:16:27 +01:00
|
|
|
if (index == 0xFF)
|
|
|
|
{
|
2019-02-14 05:58:49 +01:00
|
|
|
break;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|
2019-02-14 05:58:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
index = (index * 16) + 0x100;
|
2019-02-15 06:00:01 +01:00
|
|
|
CopyPaletteIntoBufferUnfaded(current->data, index, 0x20);
|
2019-02-14 05:58:49 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-14 17:55:58 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7990(u32 a0, u16 a1)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16));
|
2019-02-14 17:55:58 +01:00
|
|
|
}
|
2019-02-14 22:30:52 +01:00
|
|
|
|
|
|
|
__attribute__((naked))
|
2019-02-15 06:20:24 +01:00
|
|
|
void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 unused, u32 a5, u32 a6)
|
2019-02-15 06:07:57 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
asm(".syntax unified\n\
|
|
|
|
push {r4-r7,lr}\n\
|
|
|
|
mov r7, r10\n\
|
|
|
|
mov r6, r9\n\
|
|
|
|
mov r5, r8\n\
|
|
|
|
push {r5-r7}\n\
|
|
|
|
sub sp, 0xC\n\
|
|
|
|
str r0, [sp]\n\
|
|
|
|
str r1, [sp, 0x4]\n\
|
|
|
|
mov r10, r2\n\
|
|
|
|
str r3, [sp, 0x8]\n\
|
|
|
|
ldr r0, [sp, 0x2C]\n\
|
|
|
|
cmp r0, 0\n\
|
|
|
|
bne _081C79E4\n\
|
|
|
|
ldr r2, =0x001fffff\n\
|
|
|
|
mov r1, r10\n\
|
|
|
|
ands r2, r1\n\
|
|
|
|
ldr r0, [sp]\n\
|
|
|
|
b _081C79F4\n\
|
|
|
|
.pool\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C79E4:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
ldr r2, [sp, 0x2C]\n\
|
|
|
|
ldr r0, [sp, 0x8]\n\
|
|
|
|
cmp r2, r0\n\
|
|
|
|
blt _081C7A00\n\
|
|
|
|
ldr r2, =0x001fffff\n\
|
|
|
|
mov r1, r10\n\
|
|
|
|
ands r2, r1\n\
|
|
|
|
ldr r0, [sp, 0x4]\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C79F4:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
ldr r1, [sp, 0x30]\n\
|
|
|
|
bl CpuSet\n\
|
|
|
|
b _081C7AAE\n\
|
|
|
|
.pool\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C7A00:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
movs r2, 0x1\n\
|
|
|
|
negs r2, r2\n\
|
|
|
|
add r10, r2\n\
|
|
|
|
b _081C7AA6\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C7A08:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
ldr r1, [sp]\n\
|
|
|
|
ldrh r0, [r1]\n\
|
|
|
|
movs r2, 0x1F\n\
|
|
|
|
mov r9, r2\n\
|
|
|
|
mov r1, r9\n\
|
|
|
|
ands r1, r0\n\
|
|
|
|
mov r9, r1\n\
|
|
|
|
lsls r0, 16\n\
|
|
|
|
lsrs r2, r0, 21\n\
|
|
|
|
movs r1, 0x1F\n\
|
|
|
|
ands r1, r2\n\
|
|
|
|
mov r8, r1\n\
|
|
|
|
lsrs r7, r0, 26\n\
|
|
|
|
movs r2, 0x1F\n\
|
|
|
|
ands r7, r2\n\
|
|
|
|
ldr r0, [sp, 0x4]\n\
|
|
|
|
ldrh r4, [r0]\n\
|
|
|
|
movs r0, 0x1F\n\
|
|
|
|
ands r0, r4\n\
|
|
|
|
mov r1, r9\n\
|
|
|
|
subs r0, r1\n\
|
|
|
|
lsls r0, 8\n\
|
|
|
|
ldr r1, [sp, 0x8]\n\
|
|
|
|
bl __divsi3\n\
|
|
|
|
ldr r2, [sp, 0x2C]\n\
|
|
|
|
adds r6, r0, 0\n\
|
|
|
|
muls r6, r2\n\
|
|
|
|
asrs r6, 8\n\
|
|
|
|
lsls r4, 16\n\
|
|
|
|
lsrs r0, r4, 21\n\
|
|
|
|
movs r1, 0x1F\n\
|
|
|
|
ands r0, r1\n\
|
|
|
|
mov r2, r8\n\
|
|
|
|
subs r0, r2\n\
|
|
|
|
lsls r0, 8\n\
|
|
|
|
ldr r1, [sp, 0x8]\n\
|
|
|
|
bl __divsi3\n\
|
|
|
|
ldr r1, [sp, 0x2C]\n\
|
|
|
|
adds r5, r0, 0\n\
|
|
|
|
muls r5, r1\n\
|
|
|
|
asrs r5, 8\n\
|
|
|
|
lsrs r4, 26\n\
|
|
|
|
movs r2, 0x1F\n\
|
|
|
|
ands r4, r2\n\
|
|
|
|
subs r4, r7\n\
|
|
|
|
lsls r4, 8\n\
|
|
|
|
adds r0, r4, 0\n\
|
|
|
|
ldr r1, [sp, 0x8]\n\
|
|
|
|
bl __divsi3\n\
|
|
|
|
ldr r1, [sp, 0x2C]\n\
|
|
|
|
muls r0, r1\n\
|
|
|
|
asrs r0, 8\n\
|
|
|
|
add r6, r9\n\
|
|
|
|
movs r2, 0x1F\n\
|
|
|
|
ands r6, r2\n\
|
|
|
|
add r5, r8\n\
|
|
|
|
ands r5, r2\n\
|
|
|
|
adds r0, r7, r0\n\
|
|
|
|
ands r0, r2\n\
|
|
|
|
lsls r0, 10\n\
|
|
|
|
lsls r5, 5\n\
|
|
|
|
orrs r0, r5\n\
|
|
|
|
orrs r0, r6\n\
|
|
|
|
ldr r1, [sp, 0x30]\n\
|
|
|
|
strh r0, [r1]\n\
|
|
|
|
ldr r2, [sp]\n\
|
|
|
|
adds r2, 0x2\n\
|
|
|
|
str r2, [sp]\n\
|
|
|
|
ldr r0, [sp, 0x4]\n\
|
|
|
|
adds r0, 0x2\n\
|
|
|
|
str r0, [sp, 0x4]\n\
|
|
|
|
adds r1, 0x2\n\
|
|
|
|
str r1, [sp, 0x30]\n\
|
|
|
|
movs r1, 0x1\n\
|
|
|
|
negs r1, r1\n\
|
|
|
|
add r10, r1\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C7AA6:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
movs r0, 0x1\n\
|
|
|
|
negs r0, r0\n\
|
|
|
|
cmp r10, r0\n\
|
|
|
|
bne _081C7A08\n\
|
2019-02-14 22:30:52 +01:00
|
|
|
_081C7AAE:\n\
|
2019-02-15 06:29:32 +01:00
|
|
|
add sp, 0xC\n\
|
|
|
|
pop {r3-r5}\n\
|
|
|
|
mov r8, r3\n\
|
|
|
|
mov r9, r4\n\
|
|
|
|
mov r10, r5\n\
|
|
|
|
pop {r4-r7}\n\
|
|
|
|
pop {r0}\n\
|
|
|
|
bx r0\n\
|
|
|
|
.syntax divided");
|
2019-02-14 22:30:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7AC0(s32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
switch (a0)
|
|
|
|
{
|
2019-02-16 18:09:27 +01:00
|
|
|
case 0:
|
|
|
|
BeginNormalPaletteFade(v1[5], -2, 0, 16, a0);
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-02-18 06:16:27 +01:00
|
|
|
BeginNormalPaletteFade(v1[5], -2, 16, 0, RGB_BLACK);
|
2019-02-16 18:09:27 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-02-18 06:16:27 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, RGB_BLACK);
|
2019-02-16 18:09:27 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2019-02-18 06:16:27 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, -2, 16, 0, RGB_BLACK);
|
2019-02-16 18:09:27 +01:00
|
|
|
break;
|
2019-02-15 06:29:32 +01:00
|
|
|
}
|
2019-02-14 22:30:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool32 IsPaletteFadeActive(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return gPaletteFade.active;
|
2019-02-14 22:30:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7B40(void)
|
|
|
|
{
|
2019-02-18 06:16:27 +01:00
|
|
|
BlendPalettes(0xFFFEFFFE, 16, RGB_BLACK);
|
2019-02-14 22:30:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7B54(const struct BgTemplate *a0, s32 a1)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
s32 i;
|
|
|
|
if (a1 <= 0)
|
|
|
|
return;
|
|
|
|
for (i = a1; i != 0; i--)
|
|
|
|
{
|
|
|
|
InitBgFromTemplate(a0++);
|
|
|
|
}
|
2019-02-14 22:30:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7B74(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
2019-02-14 22:30:52 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
InitWindows(&gUnknown_0861FA08[0]);
|
|
|
|
v1[4] = 0;
|
|
|
|
sub_81C7BF8(0);
|
|
|
|
PutWindowTilemap(v1[4]);
|
|
|
|
CopyWindowToVram(v1[4], 3); // TODO: Use a defined constant here.
|
2019-02-14 23:26:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7BA4(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
2019-02-14 23:26:34 +01:00
|
|
|
|
2019-02-15 06:29:32 +01:00
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
sub_81C7BF8(v1[4]);
|
|
|
|
AddTextPrinterParameterized3(v1[4], 1, 0, 1, gMenuButtonReminderColor, 0, MenuButtonReminders[a0]);
|
2019-02-14 23:26:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
bool8 sub_81C7BE8(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
2019-02-14 23:26:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7BF8(u32 a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
FillWindowPixelBuffer(a0, 0x44);
|
|
|
|
FillWindowPixelRect(a0, 0x55, 0, 0, 0x80, 1);
|
2019-02-14 23:26:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7C28(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 *v1;
|
|
|
|
u32 i;
|
|
|
|
u8 v2;
|
|
|
|
u32 v3;
|
|
|
|
u32 v4;
|
|
|
|
u8 spriteId;
|
|
|
|
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
for (i = 0; i == 0; i++)
|
|
|
|
{
|
|
|
|
LoadCompressedSpriteSheet(&gUnknown_0861FA4C[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub_81C795C(gUnknown_0861FA54);
|
|
|
|
v2 = IndexOfSpritePaletteTag(0);
|
2019-02-18 06:16:27 +01:00
|
|
|
v1[5] = ~1 & ~(0x10000 << v2);
|
|
|
|
spriteId = CreateSprite(&gUnknown_0861FB04, 220, 12, 0);
|
2019-02-15 06:29:32 +01:00
|
|
|
v1[6] = (u32)(&gSprites[spriteId]);
|
2019-02-15 03:03:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7C94(void)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
void **v1;
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
DestroySprite(v1[6]);
|
|
|
|
FreeSpriteTilesByTag(0);
|
|
|
|
FreeSpritePaletteByTag(0);
|
2019-02-15 03:03:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:07:57 +01:00
|
|
|
void sub_81C7CB4(u16 *a0)
|
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
u32 v1;
|
|
|
|
v1 = GetBgY(0);
|
|
|
|
a0[19] = (v1 >> 8) * -1;
|
2019-02-15 03:03:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 06:20:24 +01:00
|
|
|
struct Sprite *sub_81C7CCC(void)
|
2019-02-15 06:07:57 +01:00
|
|
|
{
|
2019-02-15 06:29:32 +01:00
|
|
|
struct Sprite **v1;
|
|
|
|
struct Sprite *v2;
|
|
|
|
v1 = sub_81C763C(0);
|
|
|
|
v2 = v1[6];
|
|
|
|
v2->callback = SpriteCallbackDummy;
|
|
|
|
return v2;
|
2019-02-18 06:16:27 +01:00
|
|
|
}
|