Document confetti

This commit is contained in:
GriffinR 2020-06-17 03:39:03 -04:00
parent 46f4a4bbf7
commit 76f6d05173
9 changed files with 292 additions and 237 deletions

View File

@ -172,7 +172,7 @@ BattleFrontier_BattleDomeBattleRoom_EventScript_WonTourney:: @ 824BF62
BattleFrontier_BattleDomeBattleRoom_EventScript_WonLvOpenTourney:: @ 824BF96 BattleFrontier_BattleDomeBattleRoom_EventScript_WonLvOpenTourney:: @ 824BF96
msgbox BattleFrontier_BattleDomeBattleRoom_Text_PlayerIsLvOpenChamp, MSGBOX_DEFAULT msgbox BattleFrontier_BattleDomeBattleRoom_Text_PlayerIsLvOpenChamp, MSGBOX_DEFAULT
BattleFrontier_BattleDomeBattleRoom_EventScript_CelebrateWin:: @ 824BF9E BattleFrontier_BattleDomeBattleRoom_EventScript_CelebrateWin:: @ 824BF9E
special DoConfettiEffect special DoDomeConfetti
playse SE_W227B playse SE_W227B
call BattleFrontier_BattleDomeBattleRoom_EventScript_AudienceLookAround call BattleFrontier_BattleDomeBattleRoom_EventScript_AudienceLookAround
delay 60 delay 60

View File

@ -498,7 +498,7 @@ gSpecials:: @ 81DBA64
def_special GetPCBoxToSendMon def_special GetPCBoxToSendMon
def_special ShouldShowBoxWasFullMessage def_special ShouldShowBoxWasFullMessage
def_special SetMatchCallRegisteredFlag def_special SetMatchCallRegisteredFlag
def_special DoConfettiEffect def_special DoDomeConfetti
def_special CreateAbnormalWeatherEvent def_special CreateAbnormalWeatherEvent
def_special GetAbnormalWeatherMapNameAndType def_special GetAbnormalWeatherMapNameAndType
def_special GetMartEmployeeObjectEventId def_special GetMartEmployeeObjectEventId

View File

@ -4082,8 +4082,8 @@ extern const u8 gNamingScreenUnderscoreTiles[];
extern const u32 gUnknown_08D9BA44[]; extern const u32 gUnknown_08D9BA44[];
extern const u32 gContestConfetti_Gfx[]; extern const u32 gConfetti_Gfx[];
extern const u32 gContestConfetti_Pal[]; extern const u32 gConfetti_Pal[];
extern const u32 gUnknown_08C093F0[]; extern const u32 gUnknown_08C093F0[];
extern const u32 gSubstituteDollTilemap[]; extern const u32 gSubstituteDollTilemap[];

View File

@ -4,7 +4,6 @@
void CB2_DoHallOfFameScreen(void); void CB2_DoHallOfFameScreen(void);
void CB2_DoHallOfFameScreenDontSaveData(void); void CB2_DoHallOfFameScreenDontSaveData(void);
void CB2_DoHallOfFamePC(void); void CB2_DoHallOfFamePC(void);
void DoConfettiEffect(void);
// hof_pc.c // hof_pc.c
void ReturnFromHallOfFamePC(void); void ReturnFromHallOfFamePC(void);

View File

@ -1,7 +1,7 @@
#ifndef GUARD_ROM_81520A8_H #ifndef GUARD_ROM_81520A8_H
#define GUARD_ROM_81520A8_H #define GUARD_ROM_81520A8_H
struct UnkStruct_81520A8 struct OamUtil
{ {
struct OamData oam; struct OamData oam;
s16 x; s16 x;
@ -12,22 +12,22 @@ struct UnkStruct_81520A8
u16 palTag; u16 palTag;
u16 tileNum; u16 tileNum;
u8 id; u8 id;
u8 filler17; // Unused. u8 filler;
u8 unk18; u8 animNum;
u8 unk19_0:1; u8 active:1;
u8 unk19_1:1; u8 allowUpdates:1;
u8 unk19_2:1; u8 dummied:1;
u8 priority:2; u8 priority:2;
s16 data[8]; s16 data[8];
void (*callback)(struct UnkStruct_81520A8 *); void (*callback)(struct OamUtil *);
}; };
bool32 sub_81521C0(u8 count); bool32 OamUtil_Init(u8 count);
bool32 sub_8152254(void); bool32 OamUtil_Free(void);
bool32 sub_81522D4(void); bool32 OamUtil_Update(void);
u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *)); u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *));
u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue); u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue);
u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 arg5, u8 priority); u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority);
u8 sub_81525D0(u8 id); u8 OamUtil_Remove(u8 id);
#endif // GUARD_ROM_81520A8_H #endif // GUARD_ROM_81520A8_H

View File

@ -43,6 +43,8 @@
#include "constants/vars.h" #include "constants/vars.h"
#include "contest.h" #include "contest.h"
#define TAG_CONFETTI 3017
struct ContestLinkUnk0 struct ContestLinkUnk0
{ {
u8 unk0; u8 unk0;
@ -139,7 +141,7 @@ static void sub_80F85BC(u8);
static void sub_80F86B8(u8); static void sub_80F86B8(u8);
static void sub_80F878C(u8); static void sub_80F878C(u8);
static void sub_80F87B4(u8); static void sub_80F87B4(u8);
static void sub_80F7768(struct Sprite *sprite); static void SpriteCB_Confetti(struct Sprite *sprite);
static const u16 sUnknown_0858D6B0[] = INCBIN_U16("graphics/unknown/unknown_58D6B0.gbapal"); static const u16 sUnknown_0858D6B0[] = INCBIN_U16("graphics/unknown/unknown_58D6B0.gbapal");
static const u8 sUnknown_0858D6D0[] = INCBIN_U8("graphics/unknown/unknown_58D6D0.4bpp"); static const u8 sUnknown_0858D6D0[] = INCBIN_U8("graphics/unknown/unknown_58D6D0.4bpp");
@ -191,7 +193,7 @@ static const struct SpritePalette sUnknown_0858D850 =
.tag = 3009, .tag = 3009,
}; };
static const struct OamData sOamData_858D858 = static const struct OamData sOamData_Confetti =
{ {
.y = 0, .y = 0,
.affineMode = ST_OAM_AFFINE_OFF, .affineMode = ST_OAM_AFFINE_OFF,
@ -208,29 +210,29 @@ static const struct OamData sOamData_858D858 =
.affineParam = 0, .affineParam = 0,
}; };
static const struct SpriteTemplate sSpriteTemplate_858D860 = static const struct SpriteTemplate sSpriteTemplate_Confetti =
{ {
.tileTag = 3017, .tileTag = TAG_CONFETTI,
.paletteTag = 3017, .paletteTag = TAG_CONFETTI,
.oam = &sOamData_858D858, .oam = &sOamData_Confetti,
.anims = gDummySpriteAnimTable, .anims = gDummySpriteAnimTable,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_80F7768 .callback = SpriteCB_Confetti
}; };
static const struct CompressedSpriteSheet sUnknown_0858D878 = static const struct CompressedSpriteSheet sSpriteSheet_Confetti =
{ {
.data = gContestConfetti_Gfx, .data = gConfetti_Gfx,
.size = 0x220, .size = 0x220,
.tag = 3017 .tag = TAG_CONFETTI
}; };
static const struct CompressedSpritePalette sUnknown_0858D880 = static const struct CompressedSpritePalette sSpritePalette_Confetti =
{ {
.data = gContestConfetti_Pal, .data = gConfetti_Pal,
.tag = 3017 .tag = TAG_CONFETTI
}; };
static const struct BgTemplate sUnknown_0858D888[] = static const struct BgTemplate sUnknown_0858D888[] =
@ -869,8 +871,8 @@ static void sub_80F6404(u8 taskId)
gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.priority = 0;
gSprites[spriteId].callback = sub_80F75A8; gSprites[spriteId].callback = sub_80F75A8;
gUnknown_0203A034->unk0->spriteId = spriteId; gUnknown_0203A034->unk0->spriteId = spriteId;
LoadCompressedSpriteSheet(&sUnknown_0858D878); LoadCompressedSpriteSheet(&sSpriteSheet_Confetti);
LoadCompressedSpritePalette(&sUnknown_0858D880); LoadCompressedSpritePalette(&sSpritePalette_Confetti);
CreateTask(sub_80F7670, 10); CreateTask(sub_80F7670, 10);
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
break; break;
@ -1829,7 +1831,7 @@ static void sub_80F7670(u8 taskId)
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
if (gUnknown_0203A034->unk0->unk7 < 40) if (gUnknown_0203A034->unk0->unk7 < 40)
{ {
u8 spriteId = CreateSprite(&sSpriteTemplate_858D860, (Random() % 240) - 20, 44, 5); u8 spriteId = CreateSprite(&sSpriteTemplate_Confetti, (Random() % 240) - 20, 44, 5);
gSprites[spriteId].data[0] = Random() % 512; gSprites[spriteId].data[0] = Random() % 512;
gSprites[spriteId].data[1] = (Random() % 24) + 16; gSprites[spriteId].data[1] = (Random() % 24) + 16;
gSprites[spriteId].data[2] = (Random() % 256) + 48; gSprites[spriteId].data[2] = (Random() % 256) + 48;
@ -1842,7 +1844,7 @@ static void sub_80F7670(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
} }
static void sub_80F7768(struct Sprite *sprite) static void SpriteCB_Confetti(struct Sprite *sprite)
{ {
s16 delta; s16 delta;

View File

@ -875,8 +875,8 @@ const u32 gSubstituteDollTilemap[] = INCBIN_U32("graphics/battle_anims/sprites/s
const u32 gBattleAnimSpriteGfx_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.4bpp.lz"); const u32 gBattleAnimSpriteGfx_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.4bpp.lz");
const u32 gBattleAnimSpritePal_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.gbapal.lz"); const u32 gBattleAnimSpritePal_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.gbapal.lz");
const u32 gContestConfetti_Gfx[] = INCBIN_U32("graphics/misc/confetti.4bpp.lz"); const u32 gConfetti_Gfx[] = INCBIN_U32("graphics/misc/confetti.4bpp.lz");
const u32 gContestConfetti_Pal[] = INCBIN_U32("graphics/misc/confetti.gbapal.lz"); const u32 gConfetti_Pal[] = INCBIN_U32("graphics/misc/confetti.gbapal.lz");
const u32 gBattleAnimSpriteGfx_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.4bpp.lz"); const u32 gBattleAnimSpriteGfx_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.4bpp.lz");
const u32 gBattleAnimSpritePal_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.gbapal.lz"); const u32 gBattleAnimSpritePal_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.gbapal.lz");

View File

@ -36,6 +36,9 @@
#include "rom_81520A8.h" #include "rom_81520A8.h"
#include "constants/rgb.h" #include "constants/rgb.h"
#define HALL_OF_FAME_MAX_TEAMS 50
#define TAG_CONFETTI 1001
struct HallofFameMon struct HallofFameMon
{ {
u32 tid; u32 tid;
@ -58,33 +61,31 @@ struct HofGfx
u8 tilemap2[0x1000]; u8 tilemap2[0x1000];
}; };
static EWRAM_DATA u32 sUnknown_0203BCD4 = 0; static EWRAM_DATA u32 sHofFadePalettes = 0;
static EWRAM_DATA struct HallofFameTeam *sHofMonPtr = NULL; static EWRAM_DATA struct HallofFameTeam *sHofMonPtr = NULL;
static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL; static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL;
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
#define HALL_OF_FAME_MAX_TEAMS 50
// this file's functions // this file's functions
static void ClearVramOamPltt_LoadHofPal(void); static void ClearVramOamPltt_LoadHofPal(void);
static void sub_8174F70(void); static void LoadHofGfx(void);
static void sub_8174FAC(void); static void InitHofBgs(void);
static bool8 sub_81751FC(void); static bool8 CreateHofConfettiSprite(void);
static void SetCallback2AfterHallOfFameDisplay(void); static void SetCallback2AfterHallOfFameDisplay(void);
static bool8 sub_8175024(void); static bool8 sub_8175024(void);
static void Task_Hof_InitMonData(u8 taskId); static void Task_Hof_InitMonData(u8 taskId);
static void Task_Hof_InitTeamSaveData(u8 taskId); static void Task_Hof_InitTeamSaveData(u8 taskId);
static void Task_Hof_SetMonDisplayTask(u8 taskId); static void Task_Hof_SetMonDisplayTask(u8 taskId);
static void Task_Hof_TrySaveData(u8 taskId); static void Task_Hof_TrySaveData(u8 taskId);
static void Task_Hof_WaitForFrames(u8 taskId); static void Task_Hof_WaitToDisplayMon(u8 taskId);
static void Task_Hof_DisplayMon(u8 taskId); static void Task_Hof_DisplayMon(u8 taskId);
static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId); static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId);
static void Task_Hof_TryDisplayAnotherMon(u8 taskId); static void Task_Hof_TryDisplayAnotherMon(u8 taskId);
static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId); static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId);
static void sub_8173DC0(u8 taskId); static void Task_Hof_DoConfetti(u8 taskId);
static void sub_8173EA4(u8 taskId); static void Task_Hof_WaitToDisplayPlayer(u8 taskId);
static void sub_8173EE4(u8 taskId); static void Task_Hof_DisplayPlayer(u8 taskId);
static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId); static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId);
static void Task_Hof_ExitOnKeyPressed(u8 taskId); static void Task_Hof_ExitOnKeyPressed(u8 taskId);
static void Task_Hof_HandlePaletteOnExit(u8 taskId); static void Task_Hof_HandlePaletteOnExit(u8 taskId);
@ -101,8 +102,8 @@ static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite);
static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2); static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2);
static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2); static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2);
static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2); static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2);
static void Task_DoConfettiEffect(u8 taskId); static void Task_DoDomeConfetti(u8 taskId);
static void sub_81751A4(struct Sprite* sprite); static void SpriteCB_HofConfetti(struct Sprite* sprite);
// const rom data // const rom data
static const struct BgTemplate sHof_BgTemplates[] = static const struct BgTemplate sHof_BgTemplates[] =
@ -143,15 +144,15 @@ static const u8 sPlayerInfoTextColors[4] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_D
static const u8 sUnused_085E538C[] = {4, 5, 0, 0}; static const u8 sUnused_085E538C[] = {4, 5, 0, 0};
static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet[] = static const struct CompressedSpriteSheet sSpriteSheet_Confetti[] =
{ {
{gContestConfetti_Gfx, 0x220, 1001}, {.data = gConfetti_Gfx, .size = 0x220, .tag = TAG_CONFETTI},
{}, {},
}; };
static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[] = static const struct CompressedSpritePalette sSpritePalette_Confetti[] =
{ {
{gContestConfetti_Pal, 1001}, {.data = gConfetti_Pal, .tag = TAG_CONFETTI},
{}, {},
}; };
@ -172,7 +173,7 @@ static const s16 sHallOfFame_MonHalfTeamPositions[PARTY_SIZE / 2][4] =
{-86, 244, 184, 64} {-86, 244, 184, 64}
}; };
static const struct OamData sOamData_85E53FC = static const struct OamData sOamData_Confetti =
{ {
.y = 0, .y = 0,
.affineMode = ST_OAM_AFFINE_OFF, .affineMode = ST_OAM_AFFINE_OFF,
@ -189,126 +190,138 @@ static const struct OamData sOamData_85E53FC =
.affineParam = 0, .affineParam = 0,
}; };
static const union AnimCmd sSpriteAnim_85E5404[] = static const union AnimCmd sAnim_PinkConfettiA[] =
{ {
ANIMCMD_FRAME(0, 30), ANIMCMD_FRAME(0, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E540C[] = static const union AnimCmd sAnim_RedConfettiA[] =
{ {
ANIMCMD_FRAME(1, 30), ANIMCMD_FRAME(1, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5414[] = static const union AnimCmd sAnim_BlueConfettiA[] =
{ {
ANIMCMD_FRAME(2, 30), ANIMCMD_FRAME(2, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E541C[] = static const union AnimCmd sAnim_RedConfettiB[] =
{ {
ANIMCMD_FRAME(3, 30), ANIMCMD_FRAME(3, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5424[] = static const union AnimCmd sAnim_BlueConfettiB[] =
{ {
ANIMCMD_FRAME(4, 30), ANIMCMD_FRAME(4, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E542C[] = static const union AnimCmd sAnim_YellowConfettiA[] =
{ {
ANIMCMD_FRAME(5, 30), ANIMCMD_FRAME(5, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5434[] = static const union AnimCmd sAnim_WhiteConfettiA[] =
{ {
ANIMCMD_FRAME(6, 30), ANIMCMD_FRAME(6, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E543C[] = static const union AnimCmd sAnim_GreenConfettiA[] =
{ {
ANIMCMD_FRAME(7, 30), ANIMCMD_FRAME(7, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5444[] = static const union AnimCmd sAnim_PinkConfettiB[] =
{ {
ANIMCMD_FRAME(8, 30), ANIMCMD_FRAME(8, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E544C[] = static const union AnimCmd sAnim_BlueConfettiC[] =
{ {
ANIMCMD_FRAME(9, 30), ANIMCMD_FRAME(9, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5454[] = static const union AnimCmd sAnim_YellowConfettiB[] =
{ {
ANIMCMD_FRAME(10, 30), ANIMCMD_FRAME(10, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E545C[] = static const union AnimCmd sAnim_WhiteConfettiB[] =
{ {
ANIMCMD_FRAME(11, 30), ANIMCMD_FRAME(11, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5464[] = static const union AnimCmd sAnim_GreenConfettiB[] =
{ {
ANIMCMD_FRAME(12, 30), ANIMCMD_FRAME(12, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E546C[] = static const union AnimCmd sAnim_PinkConfettiC[] =
{ {
ANIMCMD_FRAME(13, 30), ANIMCMD_FRAME(13, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5474[] = static const union AnimCmd sAnim_RedConfettiC[] =
{ {
ANIMCMD_FRAME(14, 30), ANIMCMD_FRAME(14, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E547C[] = static const union AnimCmd sAnim_YellowConfettiC[] =
{ {
ANIMCMD_FRAME(15, 30), ANIMCMD_FRAME(15, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd sSpriteAnim_85E5484[] = static const union AnimCmd sAnim_WhiteConfettiC[] =
{ {
ANIMCMD_FRAME(16, 30), ANIMCMD_FRAME(16, 30),
ANIMCMD_END ANIMCMD_END
}; };
static const union AnimCmd * const sSpriteAnimTable_85E548C[] = static const union AnimCmd * const sAnims_Confetti[] =
{ {
sSpriteAnim_85E5404, sSpriteAnim_85E540C, sSpriteAnim_85E5414, sSpriteAnim_85E541C, sAnim_PinkConfettiA,
sSpriteAnim_85E5424, sSpriteAnim_85E542C, sSpriteAnim_85E5434, sSpriteAnim_85E543C, sAnim_RedConfettiA,
sSpriteAnim_85E5444, sSpriteAnim_85E544C, sSpriteAnim_85E5454, sSpriteAnim_85E545C, sAnim_BlueConfettiA,
sSpriteAnim_85E5464, sSpriteAnim_85E546C, sSpriteAnim_85E5474, sSpriteAnim_85E547C, sAnim_RedConfettiB,
sSpriteAnim_85E5484 sAnim_BlueConfettiB,
sAnim_YellowConfettiA,
sAnim_WhiteConfettiA,
sAnim_GreenConfettiA,
sAnim_PinkConfettiB,
sAnim_BlueConfettiC,
sAnim_YellowConfettiB,
sAnim_WhiteConfettiB,
sAnim_GreenConfettiB,
sAnim_PinkConfettiC,
sAnim_RedConfettiC,
sAnim_YellowConfettiC,
sAnim_WhiteConfettiC
}; };
static const struct SpriteTemplate sSpriteTemplate_85E54D0 = static const struct SpriteTemplate sSpriteTemplate_HofConfetti =
{ {
.tileTag = 1001, .tileTag = TAG_CONFETTI,
.paletteTag = 1001, .paletteTag = TAG_CONFETTI,
.oam = &sOamData_85E53FC, .oam = &sOamData_Confetti,
.anims = sSpriteAnimTable_85E548C, .anims = sAnims_Confetti,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_81751A4 .callback = SpriteCB_HofConfetti
}; };
static const u16 sHallOfFame_Pal[] = INCBIN_U16("graphics/misc/japanese_hof.gbapal"); static const u16 sHallOfFame_Pal[] = INCBIN_U16("graphics/misc/japanese_hof.gbapal");
@ -317,10 +330,19 @@ static const u32 sHallOfFame_Gfx[] = INCBIN_U32("graphics/misc/japanese_hof.4bpp
static const struct HallofFameMon sDummyFameMon = static const struct HallofFameMon sDummyFameMon =
{ {
0x3EA03EA, 0, 0, 0, {0} .tid = 0x3EA03EA,
.personality = 0,
.species = SPECIES_NONE,
.lvl = 0,
.nick = {0}
}; };
static const u8 sUnused2[] = {2, 1, 3, 6, 4, 5, 0, 0}; // Unused, order of party slots on Hall of Fame screen
static const u8 sHallOfFame_SlotOrder[] = {
2, 1, 3,
6, 4, 5,
0, 0
};
// code // code
static void VBlankCB_HallOfFame(void) static void VBlankCB_HallOfFame(void)
@ -350,14 +372,14 @@ static bool8 InitHallOfFameScreen(void)
gMain.state = 1; gMain.state = 1;
break; break;
case 1: case 1:
sub_8174F70(); LoadHofGfx();
gMain.state++; gMain.state++;
break; break;
case 2: case 2:
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7)); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7));
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
sub_8174FAC(); InitHofBgs();
sHofGfxPtr->state = 0; sHofGfxPtr->state = 0;
gMain.state++; gMain.state++;
break; break;
@ -433,7 +455,7 @@ static void Task_Hof_InitMonData(u8 taskId)
} }
else else
{ {
sHofMonPtr->mon[i].species = 0; sHofMonPtr->mon[i].species = SPECIES_NONE;
sHofMonPtr->mon[i].tid = 0; sHofMonPtr->mon[i].tid = 0;
sHofMonPtr->mon[i].personality = 0; sHofMonPtr->mon[i].personality = 0;
sHofMonPtr->mon[i].lvl = 0; sHofMonPtr->mon[i].lvl = 0;
@ -441,7 +463,7 @@ static void Task_Hof_InitMonData(u8 taskId)
} }
} }
sUnknown_0203BCD4 = 0; sHofFadePalettes = 0;
gTasks[taskId].tDisplayedMonId = 0; gTasks[taskId].tDisplayedMonId = 0;
gTasks[taskId].tPlayerSpriteID = 0xFF; gTasks[taskId].tPlayerSpriteID = 0xFF;
@ -514,12 +536,12 @@ static void Task_Hof_TrySaveData(u8 taskId)
else else
{ {
PlaySE(SE_SAVE); PlaySE(SE_SAVE);
gTasks[taskId].func = Task_Hof_WaitForFrames; gTasks[taskId].func = Task_Hof_WaitToDisplayMon;
gTasks[taskId].tFrameCount = 32; gTasks[taskId].tFrameCount = 32;
} }
} }
static void Task_Hof_WaitForFrames(u8 taskId) static void Task_Hof_WaitToDisplayMon(u8 taskId)
{ {
if (gTasks[taskId].tFrameCount) if (gTasks[taskId].tFrameCount)
gTasks[taskId].tFrameCount--; gTasks[taskId].tFrameCount--;
@ -539,32 +561,32 @@ static void Task_Hof_SetMonDisplayTask(u8 taskId)
static void Task_Hof_DisplayMon(u8 taskId) static void Task_Hof_DisplayMon(u8 taskId)
{ {
u8 spriteId; u8 spriteId;
s16 xPos, yPos, field4, field6; s16 startX, startY, destX, destY;
u16 currMonId = gTasks[taskId].tDisplayedMonId; u16 currMonId = gTasks[taskId].tDisplayedMonId;
struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId]; struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId];
if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2) if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2)
{ {
xPos = sHallOfFame_MonFullTeamPositions[currMonId][0]; startX = sHallOfFame_MonFullTeamPositions[currMonId][0];
yPos = sHallOfFame_MonFullTeamPositions[currMonId][1]; startY = sHallOfFame_MonFullTeamPositions[currMonId][1];
field4 = sHallOfFame_MonFullTeamPositions[currMonId][2]; destX = sHallOfFame_MonFullTeamPositions[currMonId][2];
field6 = sHallOfFame_MonFullTeamPositions[currMonId][3]; destY = sHallOfFame_MonFullTeamPositions[currMonId][3];
} }
else else
{ {
xPos = sHallOfFame_MonHalfTeamPositions[currMonId][0]; startX = sHallOfFame_MonHalfTeamPositions[currMonId][0];
yPos = sHallOfFame_MonHalfTeamPositions[currMonId][1]; startY = sHallOfFame_MonHalfTeamPositions[currMonId][1];
field4 = sHallOfFame_MonHalfTeamPositions[currMonId][2]; destX = sHallOfFame_MonHalfTeamPositions[currMonId][2];
field6 = sHallOfFame_MonHalfTeamPositions[currMonId][3]; destY = sHallOfFame_MonHalfTeamPositions[currMonId][3];
} }
if (currMon->species == SPECIES_EGG) if (currMon->species == SPECIES_EGG)
field6 += 10; destY += 10;
spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF); spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, startX, startY, currMonId, 0xFFFF);
gSprites[spriteId].tDestinationX = field4; gSprites[spriteId].tDestinationX = destX;
gSprites[spriteId].tDestinationY = field6; gSprites[spriteId].tDestinationY = destY;
gSprites[spriteId].data[0] = 0; gSprites[spriteId].data[0] = 0;
gSprites[spriteId].tSpecies = currMon->species; gSprites[spriteId].tSpecies = currMon->species;
gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate; gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate;
@ -599,11 +621,11 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId)
} }
else else
{ {
sUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum); sHofFadePalettes |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum);
if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display if (gTasks[taskId].tDisplayedMonId < PARTY_SIZE - 1 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display
{ {
gTasks[taskId].tDisplayedMonId++; gTasks[taskId].tDisplayedMonId++;
BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24)); BeginNormalPaletteFade(sHofFadePalettes, 0, 12, 12, RGB(16, 29, 24));
gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.priority = 1; gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.priority = 1;
gTasks[taskId].func = Task_Hof_DisplayMon; gTasks[taskId].func = Task_Hof_DisplayMon;
} }
@ -628,16 +650,19 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
HallOfFame_PrintWelcomeText(0, 15); HallOfFame_PrintWelcomeText(0, 15);
PlaySE(SE_DENDOU); PlaySE(SE_DENDOU);
gTasks[taskId].tFrameCount = 400; gTasks[taskId].tFrameCount = 400;
gTasks[taskId].func = sub_8173DC0; gTasks[taskId].func = Task_Hof_DoConfetti;
} }
static void sub_8173DC0(u8 taskId) static void Task_Hof_DoConfetti(u8 taskId)
{ {
if (gTasks[taskId].tFrameCount != 0) if (gTasks[taskId].tFrameCount != 0)
{ {
gTasks[taskId].tFrameCount--; gTasks[taskId].tFrameCount--;
// Create new confetti every 4th frame for the first 290 frames
// For the last 110 frames wait for the existing confetti to fall offscreen
if ((gTasks[taskId].tFrameCount & 3) == 0 && gTasks[taskId].tFrameCount > 110) if ((gTasks[taskId].tFrameCount & 3) == 0 && gTasks[taskId].tFrameCount > 110)
sub_81751FC(); CreateHofConfettiSprite();
} }
else else
{ {
@ -647,19 +672,19 @@ static void sub_8173DC0(u8 taskId)
if (gTasks[taskId].tMonSpriteId(i) != 0xFF) if (gTasks[taskId].tMonSpriteId(i) != 0xFF)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1;
} }
BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24)); BeginNormalPaletteFade(sHofFadePalettes, 0, 12, 12, RGB(16, 29, 24));
FillWindowPixelBuffer(0, PIXEL_FILL(0)); FillWindowPixelBuffer(0, PIXEL_FILL(0));
CopyWindowToVram(0, 3); CopyWindowToVram(0, 3);
gTasks[taskId].tFrameCount = 7; gTasks[taskId].tFrameCount = 7;
gTasks[taskId].func = sub_8173EA4; gTasks[taskId].func = Task_Hof_WaitToDisplayPlayer;
} }
} }
static void sub_8173EA4(u8 taskId) static void Task_Hof_WaitToDisplayPlayer(u8 taskId)
{ {
if (gTasks[taskId].tFrameCount >= 16) if (gTasks[taskId].tFrameCount >= 16)
{ {
gTasks[taskId].func = sub_8173EE4; gTasks[taskId].func = Task_Hof_DisplayPlayer;
} }
else else
{ {
@ -668,7 +693,7 @@ static void sub_8173EA4(u8 taskId)
} }
} }
static void sub_8173EE4(u8 taskId) static void Task_Hof_DisplayPlayer(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0); ShowBg(0);
@ -784,14 +809,14 @@ void CB2_DoHallOfFamePC(void)
gMain.state = 1; gMain.state = 1;
break; break;
case 1: case 1:
sub_8174F70(); LoadHofGfx();
gMain.state++; gMain.state++;
break; break;
case 2: case 2:
SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
sub_8174FAC(); InitHofBgs();
gMain.state++; gMain.state++;
break; break;
case 3: case 3:
@ -874,7 +899,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
savedTeams++; savedTeams++;
currMon = &savedTeams->mon[0]; currMon = &savedTeams->mon[0];
sUnknown_0203BCD4 = 0; sHofFadePalettes = 0;
gTasks[taskId].tCurrMonId = 0; gTasks[taskId].tCurrMonId = 0;
gTasks[taskId].tMonNo = 0; gTasks[taskId].tMonNo = 0;
@ -949,8 +974,8 @@ static void Task_HofPC_PrintMonInfo(u8 taskId)
currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId); currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId);
gSprites[currMonID].oam.priority = 0; gSprites[currMonID].oam.priority = 0;
sUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000; sHofFadePalettes = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000;
BlendPalettesUnfaded(sUnknown_0203BCD4, 0xC, RGB(16, 29, 24)); BlendPalettesUnfaded(sHofFadePalettes, 0xC, RGB(16, 29, 24));
currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId]; currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId];
if (currMon->species != SPECIES_EGG) if (currMon->species != SPECIES_EGG)
@ -972,7 +997,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view
{ {
gTasks[taskId].tCurrTeamNo--; gTasks[taskId].tCurrTeamNo--;
for (i = 0; i < 6; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u8 spriteId = gTasks[taskId].tMonSpriteId(i); u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != 0xFF)
@ -1250,7 +1275,7 @@ static void ClearVramOamPltt_LoadHofPal(void)
LoadPalette(sHallOfFame_Pal, 0, 0x20); LoadPalette(sHallOfFame_Pal, 0, 0x20);
} }
static void sub_8174F70(void) static void LoadHofGfx(void)
{ {
ScanlineEffect_Stop(); ScanlineEffect_Stop();
ResetTasks(); ResetTasks();
@ -1259,11 +1284,11 @@ static void sub_8174F70(void)
ResetAllPicSprites(); ResetAllPicSprites();
FreeAllSpritePalettes(); FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8; gReservedSpritePaletteCount = 8;
LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet); LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette); LoadCompressedSpritePalette(sSpritePalette_Confetti);
} }
static void sub_8174FAC(void) static void InitHofBgs(void)
{ {
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates)); InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates));
@ -1344,7 +1369,10 @@ static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite)
#undef tDestinationY #undef tDestinationY
#undef tSpecies #undef tSpecies
static void sub_81751A4(struct Sprite* sprite) #define sSineIdx data[0]
#define sExtraY data[1]
static void SpriteCB_HofConfetti(struct Sprite* sprite)
{ {
if (sprite->pos2.y > 120) if (sprite->pos2.y > 120)
{ {
@ -1353,20 +1381,20 @@ static void sub_81751A4(struct Sprite* sprite)
else else
{ {
u16 rand; u16 rand;
u8 tableID; u8 sineIdx;
sprite->pos2.y++; sprite->pos2.y++;
sprite->pos2.y += sprite->data[1]; sprite->pos2.y += sprite->sExtraY;
tableID = sprite->data[0]; sineIdx = sprite->sSineIdx;
rand = (Random() % 4) + 8; rand = (Random() % 4) + 8;
sprite->pos2.x = rand * gSineTable[tableID] / 256; sprite->pos2.x = rand * gSineTable[sineIdx] / 256;
sprite->data[0] += 4; sprite->sSineIdx += 4;
} }
} }
static bool8 sub_81751FC(void) static bool8 CreateHofConfettiSprite(void)
{ {
u8 spriteID; u8 spriteID;
struct Sprite* sprite; struct Sprite* sprite;
@ -1374,110 +1402,136 @@ static bool8 sub_81751FC(void)
s16 posX = Random() % 240; s16 posX = Random() % 240;
s16 posY = -(Random() % 8); s16 posY = -(Random() % 8);
spriteID = CreateSprite(&sSpriteTemplate_85E54D0, posX, posY, 0); spriteID = CreateSprite(&sSpriteTemplate_HofConfetti, posX, posY, 0);
sprite = &gSprites[spriteID]; sprite = &gSprites[spriteID];
StartSpriteAnim(sprite, Random() % 17); StartSpriteAnim(sprite, Random() % ARRAY_COUNT(sAnims_Confetti));
// 1/4 confetti sprites move an extra Y coord each frame
if (Random() & 3) if (Random() & 3)
sprite->data[1] = 0; sprite->sExtraY = 0;
else else
sprite->data[1] = 1; sprite->sExtraY = 1;
return FALSE; return FALSE;
} }
// Used when a Battle Dome tourney is won // The below confetti functions are used when a Battle Dome tourney is won
void DoConfettiEffect(void) // For the Hall of Fame confetti see Task_Hof_DoConfetti
// The end result is essentially the same, just a very different way of handling it
#define tState data[0]
#define tTimer data[1]
#define tConfettiCount data[15]
// Indexes into the data array of the struct OamUtil tracking confetti
#define CONFETTI_SINE_IDX 0
#define CONFETTI_EXTRA_Y 1
#define CONFETTI_TASK_ID 7
void DoDomeConfetti(void)
{ {
u8 taskId; u8 taskId;
gSpecialVar_0x8004 = 180; gSpecialVar_0x8004 = 180;
taskId = CreateTask(Task_DoConfettiEffect, 0); taskId = CreateTask(Task_DoDomeConfetti, 0);
if (taskId != 0xFF) if (taskId != 0xFF)
{ {
gTasks[taskId].data[1] = gSpecialVar_0x8004; gTasks[taskId].tTimer = gSpecialVar_0x8004;
gSpecialVar_0x8005 = taskId; gSpecialVar_0x8005 = taskId;
} }
} }
static void StopConfettiEffect(void) static void StopDomeConfetti(void)
{ {
u8 taskId; u8 taskId;
if ((taskId = FindTaskIdByFunc(Task_DoConfettiEffect)) != 0xFF) if ((taskId = FindTaskIdByFunc(Task_DoDomeConfetti)) != 0xFF)
DestroyTask(taskId); DestroyTask(taskId);
sub_8152254(); OamUtil_Free();
FreeSpriteTilesByTag(0x3E9); FreeSpriteTilesByTag(TAG_CONFETTI);
FreeSpritePaletteByTag(0x3E9); FreeSpritePaletteByTag(TAG_CONFETTI);
} }
static void sub_81752F4(struct UnkStruct_81520A8 *structPtr) static void UpdateDomeConfetti(struct OamUtil *oamUtil)
{ {
if (structPtr->yDelta > 110) if (oamUtil->yDelta > 110)
{ {
gTasks[structPtr->data[7]].data[15]--; // Destroy confetti after it falls far enough
sub_81525D0(structPtr->id); gTasks[oamUtil->data[CONFETTI_TASK_ID]].tConfettiCount--;
OamUtil_Remove(oamUtil->id);
} }
else else
{ {
u8 var; // Move confetti down
u8 sineIdx;
s32 rand; s32 rand;
structPtr->yDelta++; oamUtil->yDelta++;
structPtr->yDelta += structPtr->data[1]; oamUtil->yDelta += oamUtil->data[CONFETTI_EXTRA_Y];
var = structPtr->data[0]; sineIdx = oamUtil->data[CONFETTI_SINE_IDX];
rand = Random(); rand = Random();
rand &= 3; rand &= 3;
rand += 8; rand += 8;
structPtr->xDelta = (rand) * ((gSineTable[var])) / 256; oamUtil->xDelta = (rand) * ((gSineTable[sineIdx])) / 256;
structPtr->data[0] += 4; oamUtil->data[CONFETTI_SINE_IDX] += 4;
} }
} }
static void Task_DoConfettiEffect(u8 taskId) static void Task_DoDomeConfetti(u8 taskId)
{ {
u32 var = 0; u32 id = 0;
u16 *data = gTasks[taskId].data; u16 *data = gTasks[taskId].data;
switch (data[0]) switch (tState)
{ {
case 0: case 0:
if (!sub_81521C0(0x40)) if (!OamUtil_Init(64))
{ {
// Init failed
DestroyTask(taskId); DestroyTask(taskId);
gSpecialVar_0x8004 = var; gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF; gSpecialVar_0x8005 = 0xFFFF;
} }
LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet); LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette); LoadCompressedSpritePalette(sSpritePalette_Confetti);
data[0]++; tState++;
break; break;
case 1: case 1:
if (data[1] != 0 && data[1] % 3 == 0) if (tTimer != 0 && tTimer % 3 == 0)
{ {
var = sub_81524C4(&sOamData_85E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var); // Create new confetti every 3 frames
if (var != 0xFF) id = OamUtil_AddNew(&sOamData_Confetti,
TAG_CONFETTI,
TAG_CONFETTI,
Random() % 240,
-(Random() % 8),
Random() % ARRAY_COUNT(sAnims_Confetti),
id);
if (id != 0xFF)
{ {
sub_8152438(var, sub_81752F4); OamUtil_SetCallback(id, UpdateDomeConfetti);
if ((Random() & 3) == 0)
sub_8152474(var, 1, 1); // 1/4 of the confetti move an extra y coord every frame
sub_8152474(var, 7, taskId); if ((Random() % 4) == 0)
data[15]++; OamUtil_SetData(id, CONFETTI_EXTRA_Y, 1);
OamUtil_SetData(id, CONFETTI_TASK_ID, taskId);
tConfettiCount++;
} }
} }
sub_81522D4();
if (data[1] != 0) OamUtil_Update();
data[1]--; if (tTimer != 0)
else if (data[15] == 0) tTimer--;
data[0] = 0xFF; else if (tConfettiCount == 0)
tState = 0xFF;
break; break;
case 0xFF: case 0xFF:
StopConfettiEffect(); StopDomeConfetti();
gSpecialVar_0x8004 = var; gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF; gSpecialVar_0x8005 = 0xFFFF;
break; break;
} }

View File

@ -7,10 +7,10 @@
static EWRAM_DATA struct static EWRAM_DATA struct
{ {
u8 count; u8 count;
struct UnkStruct_81520A8 *unk4; struct OamUtil *array;
} *sUnknown_0203ABB8 = NULL; } *sWork = NULL;
void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused. static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
{ {
u8 i; u8 i;
u8 j; u8 j;
@ -28,7 +28,7 @@ void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) //
} }
} }
void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused. static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
{ {
u8 i; u8 i;
u8 j; u8 j;
@ -47,7 +47,7 @@ void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 heigh
} }
} }
bool32 sub_81521C0(u8 count) bool32 OamUtil_Init(u8 count)
{ {
u8 i = 0; u8 i = 0;
@ -56,69 +56,69 @@ bool32 sub_81521C0(u8 count)
if (count > 64) if (count > 64)
count = 64; count = 64;
sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8)); sWork = AllocZeroed(sizeof(*sWork));
if (sUnknown_0203ABB8 == NULL) if (sWork == NULL)
return FALSE; return FALSE;
sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8)); sWork->array = AllocZeroed(count * sizeof(struct OamUtil));
if (sUnknown_0203ABB8->unk4 == NULL) if (sWork->array == NULL)
{ {
FREE_AND_SET_NULL(sUnknown_0203ABB8); FREE_AND_SET_NULL(sWork);
return FALSE; return FALSE;
} }
sUnknown_0203ABB8->count = count; sWork->count = count;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
memcpy(&sUnknown_0203ABB8->unk4[i].oam, &gDummyOamData, sizeof(struct OamData)); memcpy(&sWork->array[i].oam, &gDummyOamData, sizeof(struct OamData));
sUnknown_0203ABB8->unk4[i].unk19_2 = TRUE; sWork->array[i].dummied = TRUE;
} }
return TRUE; return TRUE;
} }
bool32 sub_8152254(void) bool32 OamUtil_Free(void)
{ {
u8 i = 0; u8 i = 0;
if (sUnknown_0203ABB8 == NULL) if (sWork == NULL)
return FALSE; return FALSE;
for (i = 0; i < sUnknown_0203ABB8->count; i++) for (i = 0; i < sWork->count; i++)
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData)); memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
memset(sUnknown_0203ABB8->unk4, 0, sUnknown_0203ABB8->count * sizeof(struct UnkStruct_81520A8)); memset(sWork->array, 0, sWork->count * sizeof(struct OamUtil));
FREE_AND_SET_NULL(sUnknown_0203ABB8->unk4); FREE_AND_SET_NULL(sWork->array);
memset(sUnknown_0203ABB8, 0, sizeof(*sUnknown_0203ABB8)); memset(sWork, 0, sizeof(*sWork));
FREE_AND_SET_NULL(sUnknown_0203ABB8); FREE_AND_SET_NULL(sWork);
return TRUE; return TRUE;
} }
bool32 sub_81522D4(void) bool32 OamUtil_Update(void)
{ {
u8 i = 0; u8 i = 0;
if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL) if (sWork == NULL || sWork->array == NULL)
return FALSE; return FALSE;
for (i = 0; i < sUnknown_0203ABB8->count; i++) for (i = 0; i < sWork->count; i++)
{ {
if (sUnknown_0203ABB8->unk4[i].unk19_0 && sUnknown_0203ABB8->unk4[i].unk19_1) if (sWork->array[i].active && sWork->array[i].allowUpdates)
{ {
if (sUnknown_0203ABB8->unk4[i].callback != NULL) if (sWork->array[i].callback != NULL)
sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]); sWork->array[i].callback(&sWork->array[i]);
if (sUnknown_0203ABB8->unk4[i].unk19_2) if (sWork->array[i].dummied)
{ {
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData)); memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
} }
else else
{ {
sUnknown_0203ABB8->unk4[i].oam.y = sUnknown_0203ABB8->unk4[i].y + sUnknown_0203ABB8->unk4[i].yDelta; sWork->array[i].oam.y = sWork->array[i].y + sWork->array[i].yDelta;
sUnknown_0203ABB8->unk4[i].oam.x = sUnknown_0203ABB8->unk4[i].x + sUnknown_0203ABB8->unk4[i].xDelta; sWork->array[i].oam.x = sWork->array[i].x + sWork->array[i].xDelta;
sUnknown_0203ABB8->unk4[i].oam.priority = sUnknown_0203ABB8->unk4[i].priority; sWork->array[i].oam.priority = sWork->array[i].priority;
sUnknown_0203ABB8->unk4[i].oam.tileNum = sUnknown_0203ABB8->unk4[i].tileNum; sWork->array[i].oam.tileNum = sWork->array[i].tileNum;
memcpy(&gMain.oamBuffer[i + 64], &sUnknown_0203ABB8->unk4[i], sizeof(struct OamData)); memcpy(&gMain.oamBuffer[i + 64], &sWork->array[i], sizeof(struct OamData));
} }
} }
} }
@ -126,7 +126,7 @@ bool32 sub_81522D4(void)
return TRUE; return TRUE;
} }
static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1) static bool32 SetAnimAndTileNum(struct OamUtil *structPtr, u8 animNum)
{ {
u16 tileStart; u16 tileStart;
@ -137,50 +137,50 @@ static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
if (tileStart == 0xFFFF) if (tileStart == 0xFFFF)
return FALSE; return FALSE;
structPtr->unk18 = arg1; structPtr->animNum = animNum;
structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart; structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * animNum) + tileStart;
return TRUE; return TRUE;
} }
u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *)) u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *))
{ {
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count) if (sWork == NULL || id >= sWork->count)
return 0xFF; return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0) else if (!sWork->array[id].active)
return 0xFF; return 0xFF;
sUnknown_0203ABB8->unk4[id].callback = func; sWork->array[id].callback = func;
return id; return id;
} }
u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue) u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
{ {
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count) if (sWork == NULL || id >= sWork->count)
return 0xFF; return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0 || dataArrayId >= ARRAY_COUNT(sUnknown_0203ABB8->unk4[id].data)) else if (!sWork->array[id].active || dataArrayId > ARRAY_COUNT(sWork->array[id].data) - 1) // - 1 b/c last slot is reserved for taskId
return 0xFF; return 0xFF;
sUnknown_0203ABB8->unk4[id].data[dataArrayId] = dataValue; sWork->array[id].data[dataArrayId] = dataValue;
return id; return id;
} }
u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 arg5, u8 priority) u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority)
{ {
struct UnkStruct_81520A8 *structPtr = NULL; struct OamUtil *structPtr = NULL;
u8 i; u8 i;
if (sUnknown_0203ABB8 == NULL || oam == NULL) if (sWork == NULL || oam == NULL)
return 0xFF; return 0xFF;
for (i = 0; i < sUnknown_0203ABB8->count; i++) for (i = 0; i < sWork->count; i++)
{ {
if (!sUnknown_0203ABB8->unk4[i].unk19_0) if (!sWork->array[i].active)
{ {
structPtr = &sUnknown_0203ABB8->unk4[i]; structPtr = &sWork->array[i];
memset(structPtr, 0, sizeof(*structPtr)); memset(structPtr, 0, sizeof(*structPtr));
structPtr->id = i; structPtr->id = i;
structPtr->unk19_0 = TRUE; structPtr->active = TRUE;
structPtr->unk19_1 = TRUE; structPtr->allowUpdates = TRUE;
break; break;
} }
} }
@ -199,20 +199,20 @@ u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y,
structPtr->priority = priority; structPtr->priority = priority;
structPtr->oam.priority = priority; structPtr->oam.priority = priority;
} }
sub_81523F4(structPtr, arg5); SetAnimAndTileNum(structPtr, animNum);
return structPtr->id; return structPtr->id;
} }
u8 sub_81525D0(u8 id) u8 OamUtil_Remove(u8 id)
{ {
if (sUnknown_0203ABB8 == NULL || !sUnknown_0203ABB8->unk4[id].unk19_0) if (sWork == NULL || !sWork->array[id].active)
return 0xFF; return 0xFF;
memset(&sUnknown_0203ABB8->unk4[id], 0, sizeof(struct UnkStruct_81520A8)); memset(&sWork->array[id], 0, sizeof(struct OamUtil));
sUnknown_0203ABB8->unk4[id].oam.y = 160; sWork->array[id].oam.y = 160;
sUnknown_0203ABB8->unk4[id].oam.x = 240; sWork->array[id].oam.x = 240;
sUnknown_0203ABB8->unk4[id].unk19_2 = TRUE; sWork->array[id].dummied = TRUE;
memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData)); memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
return id; return id;
} }