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
msgbox BattleFrontier_BattleDomeBattleRoom_Text_PlayerIsLvOpenChamp, MSGBOX_DEFAULT
BattleFrontier_BattleDomeBattleRoom_EventScript_CelebrateWin:: @ 824BF9E
special DoConfettiEffect
special DoDomeConfetti
playse SE_W227B
call BattleFrontier_BattleDomeBattleRoom_EventScript_AudienceLookAround
delay 60

View File

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

View File

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

View File

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

View File

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

View File

@ -43,6 +43,8 @@
#include "constants/vars.h"
#include "contest.h"
#define TAG_CONFETTI 3017
struct ContestLinkUnk0
{
u8 unk0;
@ -139,7 +141,7 @@ static void sub_80F85BC(u8);
static void sub_80F86B8(u8);
static void sub_80F878C(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 u8 sUnknown_0858D6D0[] = INCBIN_U8("graphics/unknown/unknown_58D6D0.4bpp");
@ -191,7 +193,7 @@ static const struct SpritePalette sUnknown_0858D850 =
.tag = 3009,
};
static const struct OamData sOamData_858D858 =
static const struct OamData sOamData_Confetti =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@ -208,29 +210,29 @@ static const struct OamData sOamData_858D858 =
.affineParam = 0,
};
static const struct SpriteTemplate sSpriteTemplate_858D860 =
static const struct SpriteTemplate sSpriteTemplate_Confetti =
{
.tileTag = 3017,
.paletteTag = 3017,
.oam = &sOamData_858D858,
.tileTag = TAG_CONFETTI,
.paletteTag = TAG_CONFETTI,
.oam = &sOamData_Confetti,
.anims = gDummySpriteAnimTable,
.images = NULL,
.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,
.tag = 3017
.tag = TAG_CONFETTI
};
static const struct CompressedSpritePalette sUnknown_0858D880 =
static const struct CompressedSpritePalette sSpritePalette_Confetti =
{
.data = gContestConfetti_Pal,
.tag = 3017
.data = gConfetti_Pal,
.tag = TAG_CONFETTI
};
static const struct BgTemplate sUnknown_0858D888[] =
@ -869,8 +871,8 @@ static void sub_80F6404(u8 taskId)
gSprites[spriteId].oam.priority = 0;
gSprites[spriteId].callback = sub_80F75A8;
gUnknown_0203A034->unk0->spriteId = spriteId;
LoadCompressedSpriteSheet(&sUnknown_0858D878);
LoadCompressedSpritePalette(&sUnknown_0858D880);
LoadCompressedSpriteSheet(&sSpriteSheet_Confetti);
LoadCompressedSpritePalette(&sSpritePalette_Confetti);
CreateTask(sub_80F7670, 10);
gTasks[taskId].data[0]++;
break;
@ -1829,7 +1831,7 @@ static void sub_80F7670(u8 taskId)
gTasks[taskId].data[0] = 0;
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[1] = (Random() % 24) + 16;
gSprites[spriteId].data[2] = (Random() % 256) + 48;
@ -1842,7 +1844,7 @@ static void sub_80F7670(u8 taskId)
DestroyTask(taskId);
}
static void sub_80F7768(struct Sprite *sprite)
static void SpriteCB_Confetti(struct Sprite *sprite)
{
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 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 gContestConfetti_Pal[] = INCBIN_U32("graphics/misc/confetti.gbapal.lz");
const u32 gConfetti_Gfx[] = INCBIN_U32("graphics/misc/confetti.4bpp.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 gBattleAnimSpritePal_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.gbapal.lz");

View File

@ -36,6 +36,9 @@
#include "rom_81520A8.h"
#include "constants/rgb.h"
#define HALL_OF_FAME_MAX_TEAMS 50
#define TAG_CONFETTI 1001
struct HallofFameMon
{
u32 tid;
@ -58,33 +61,31 @@ struct HofGfx
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 HofGfx *sHofGfxPtr = NULL;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
#define HALL_OF_FAME_MAX_TEAMS 50
// this file's functions
static void ClearVramOamPltt_LoadHofPal(void);
static void sub_8174F70(void);
static void sub_8174FAC(void);
static bool8 sub_81751FC(void);
static void LoadHofGfx(void);
static void InitHofBgs(void);
static bool8 CreateHofConfettiSprite(void);
static void SetCallback2AfterHallOfFameDisplay(void);
static bool8 sub_8175024(void);
static void Task_Hof_InitMonData(u8 taskId);
static void Task_Hof_InitTeamSaveData(u8 taskId);
static void Task_Hof_SetMonDisplayTask(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_PrintMonInfoAfterAnimating(u8 taskId);
static void Task_Hof_TryDisplayAnotherMon(u8 taskId);
static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId);
static void sub_8173DC0(u8 taskId);
static void sub_8173EA4(u8 taskId);
static void sub_8173EE4(u8 taskId);
static void Task_Hof_DoConfetti(u8 taskId);
static void Task_Hof_WaitToDisplayPlayer(u8 taskId);
static void Task_Hof_DisplayPlayer(u8 taskId);
static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId);
static void Task_Hof_ExitOnKeyPressed(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_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2);
static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2);
static void Task_DoConfettiEffect(u8 taskId);
static void sub_81751A4(struct Sprite* sprite);
static void Task_DoDomeConfetti(u8 taskId);
static void SpriteCB_HofConfetti(struct Sprite* sprite);
// const rom data
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 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}
};
static const struct OamData sOamData_85E53FC =
static const struct OamData sOamData_Confetti =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@ -189,126 +190,138 @@ static const struct OamData sOamData_85E53FC =
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_85E5404[] =
static const union AnimCmd sAnim_PinkConfettiA[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E540C[] =
static const union AnimCmd sAnim_RedConfettiA[] =
{
ANIMCMD_FRAME(1, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5414[] =
static const union AnimCmd sAnim_BlueConfettiA[] =
{
ANIMCMD_FRAME(2, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E541C[] =
static const union AnimCmd sAnim_RedConfettiB[] =
{
ANIMCMD_FRAME(3, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5424[] =
static const union AnimCmd sAnim_BlueConfettiB[] =
{
ANIMCMD_FRAME(4, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E542C[] =
static const union AnimCmd sAnim_YellowConfettiA[] =
{
ANIMCMD_FRAME(5, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5434[] =
static const union AnimCmd sAnim_WhiteConfettiA[] =
{
ANIMCMD_FRAME(6, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E543C[] =
static const union AnimCmd sAnim_GreenConfettiA[] =
{
ANIMCMD_FRAME(7, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5444[] =
static const union AnimCmd sAnim_PinkConfettiB[] =
{
ANIMCMD_FRAME(8, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E544C[] =
static const union AnimCmd sAnim_BlueConfettiC[] =
{
ANIMCMD_FRAME(9, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5454[] =
static const union AnimCmd sAnim_YellowConfettiB[] =
{
ANIMCMD_FRAME(10, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E545C[] =
static const union AnimCmd sAnim_WhiteConfettiB[] =
{
ANIMCMD_FRAME(11, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5464[] =
static const union AnimCmd sAnim_GreenConfettiB[] =
{
ANIMCMD_FRAME(12, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E546C[] =
static const union AnimCmd sAnim_PinkConfettiC[] =
{
ANIMCMD_FRAME(13, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5474[] =
static const union AnimCmd sAnim_RedConfettiC[] =
{
ANIMCMD_FRAME(14, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E547C[] =
static const union AnimCmd sAnim_YellowConfettiC[] =
{
ANIMCMD_FRAME(15, 30),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_85E5484[] =
static const union AnimCmd sAnim_WhiteConfettiC[] =
{
ANIMCMD_FRAME(16, 30),
ANIMCMD_END
};
static const union AnimCmd * const sSpriteAnimTable_85E548C[] =
static const union AnimCmd * const sAnims_Confetti[] =
{
sSpriteAnim_85E5404, sSpriteAnim_85E540C, sSpriteAnim_85E5414, sSpriteAnim_85E541C,
sSpriteAnim_85E5424, sSpriteAnim_85E542C, sSpriteAnim_85E5434, sSpriteAnim_85E543C,
sSpriteAnim_85E5444, sSpriteAnim_85E544C, sSpriteAnim_85E5454, sSpriteAnim_85E545C,
sSpriteAnim_85E5464, sSpriteAnim_85E546C, sSpriteAnim_85E5474, sSpriteAnim_85E547C,
sSpriteAnim_85E5484
sAnim_PinkConfettiA,
sAnim_RedConfettiA,
sAnim_BlueConfettiA,
sAnim_RedConfettiB,
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,
.paletteTag = 1001,
.oam = &sOamData_85E53FC,
.anims = sSpriteAnimTable_85E548C,
.tileTag = TAG_CONFETTI,
.paletteTag = TAG_CONFETTI,
.oam = &sOamData_Confetti,
.anims = sAnims_Confetti,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_81751A4
.callback = SpriteCB_HofConfetti
};
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 =
{
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
static void VBlankCB_HallOfFame(void)
@ -350,14 +372,14 @@ static bool8 InitHallOfFameScreen(void)
gMain.state = 1;
break;
case 1:
sub_8174F70();
LoadHofGfx();
gMain.state++;
break;
case 2:
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7));
SetGpuReg(REG_OFFSET_BLDY, 0);
sub_8174FAC();
InitHofBgs();
sHofGfxPtr->state = 0;
gMain.state++;
break;
@ -433,7 +455,7 @@ static void Task_Hof_InitMonData(u8 taskId)
}
else
{
sHofMonPtr->mon[i].species = 0;
sHofMonPtr->mon[i].species = SPECIES_NONE;
sHofMonPtr->mon[i].tid = 0;
sHofMonPtr->mon[i].personality = 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].tPlayerSpriteID = 0xFF;
@ -514,12 +536,12 @@ static void Task_Hof_TrySaveData(u8 taskId)
else
{
PlaySE(SE_SAVE);
gTasks[taskId].func = Task_Hof_WaitForFrames;
gTasks[taskId].func = Task_Hof_WaitToDisplayMon;
gTasks[taskId].tFrameCount = 32;
}
}
static void Task_Hof_WaitForFrames(u8 taskId)
static void Task_Hof_WaitToDisplayMon(u8 taskId)
{
if (gTasks[taskId].tFrameCount)
gTasks[taskId].tFrameCount--;
@ -539,32 +561,32 @@ static void Task_Hof_SetMonDisplayTask(u8 taskId)
static void Task_Hof_DisplayMon(u8 taskId)
{
u8 spriteId;
s16 xPos, yPos, field4, field6;
s16 startX, startY, destX, destY;
u16 currMonId = gTasks[taskId].tDisplayedMonId;
struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId];
if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2)
{
xPos = sHallOfFame_MonFullTeamPositions[currMonId][0];
yPos = sHallOfFame_MonFullTeamPositions[currMonId][1];
field4 = sHallOfFame_MonFullTeamPositions[currMonId][2];
field6 = sHallOfFame_MonFullTeamPositions[currMonId][3];
startX = sHallOfFame_MonFullTeamPositions[currMonId][0];
startY = sHallOfFame_MonFullTeamPositions[currMonId][1];
destX = sHallOfFame_MonFullTeamPositions[currMonId][2];
destY = sHallOfFame_MonFullTeamPositions[currMonId][3];
}
else
{
xPos = sHallOfFame_MonHalfTeamPositions[currMonId][0];
yPos = sHallOfFame_MonHalfTeamPositions[currMonId][1];
field4 = sHallOfFame_MonHalfTeamPositions[currMonId][2];
field6 = sHallOfFame_MonHalfTeamPositions[currMonId][3];
startX = sHallOfFame_MonHalfTeamPositions[currMonId][0];
startY = sHallOfFame_MonHalfTeamPositions[currMonId][1];
destX = sHallOfFame_MonHalfTeamPositions[currMonId][2];
destY = sHallOfFame_MonHalfTeamPositions[currMonId][3];
}
if (currMon->species == SPECIES_EGG)
field6 += 10;
destY += 10;
spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF);
gSprites[spriteId].tDestinationX = field4;
gSprites[spriteId].tDestinationY = field6;
spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, startX, startY, currMonId, 0xFFFF);
gSprites[spriteId].tDestinationX = destX;
gSprites[spriteId].tDestinationY = destY;
gSprites[spriteId].data[0] = 0;
gSprites[spriteId].tSpecies = currMon->species;
gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate;
@ -599,11 +621,11 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId)
}
else
{
sUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum);
if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display
sHofFadePalettes |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum);
if (gTasks[taskId].tDisplayedMonId < PARTY_SIZE - 1 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display
{
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;
gTasks[taskId].func = Task_Hof_DisplayMon;
}
@ -628,16 +650,19 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
HallOfFame_PrintWelcomeText(0, 15);
PlaySE(SE_DENDOU);
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)
{
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)
sub_81751FC();
CreateHofConfettiSprite();
}
else
{
@ -647,19 +672,19 @@ static void sub_8173DC0(u8 taskId)
if (gTasks[taskId].tMonSpriteId(i) != 0xFF)
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));
CopyWindowToVram(0, 3);
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)
{
gTasks[taskId].func = sub_8173EE4;
gTasks[taskId].func = Task_Hof_DisplayPlayer;
}
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);
ShowBg(0);
@ -784,14 +809,14 @@ void CB2_DoHallOfFamePC(void)
gMain.state = 1;
break;
case 1:
sub_8174F70();
LoadHofGfx();
gMain.state++;
break;
case 2:
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
sub_8174FAC();
InitHofBgs();
gMain.state++;
break;
case 3:
@ -874,7 +899,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
savedTeams++;
currMon = &savedTeams->mon[0];
sUnknown_0203BCD4 = 0;
sHofFadePalettes = 0;
gTasks[taskId].tCurrMonId = 0;
gTasks[taskId].tMonNo = 0;
@ -949,8 +974,8 @@ static void Task_HofPC_PrintMonInfo(u8 taskId)
currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId);
gSprites[currMonID].oam.priority = 0;
sUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000;
BlendPalettesUnfaded(sUnknown_0203BCD4, 0xC, RGB(16, 29, 24));
sHofFadePalettes = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000;
BlendPalettesUnfaded(sHofFadePalettes, 0xC, RGB(16, 29, 24));
currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId];
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
{
gTasks[taskId].tCurrTeamNo--;
for (i = 0; i < 6; i++)
for (i = 0; i < PARTY_SIZE; i++)
{
u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF)
@ -1250,7 +1275,7 @@ static void ClearVramOamPltt_LoadHofPal(void)
LoadPalette(sHallOfFame_Pal, 0, 0x20);
}
static void sub_8174F70(void)
static void LoadHofGfx(void)
{
ScanlineEffect_Stop();
ResetTasks();
@ -1259,11 +1284,11 @@ static void sub_8174F70(void)
ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
LoadCompressedSpritePalette(sSpritePalette_Confetti);
}
static void sub_8174FAC(void)
static void InitHofBgs(void)
{
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates));
@ -1344,7 +1369,10 @@ static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite)
#undef tDestinationY
#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)
{
@ -1353,20 +1381,20 @@ static void sub_81751A4(struct Sprite* sprite)
else
{
u16 rand;
u8 tableID;
u8 sineIdx;
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;
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;
struct Sprite* sprite;
@ -1374,110 +1402,136 @@ static bool8 sub_81751FC(void)
s16 posX = Random() % 240;
s16 posY = -(Random() % 8);
spriteID = CreateSprite(&sSpriteTemplate_85E54D0, posX, posY, 0);
spriteID = CreateSprite(&sSpriteTemplate_HofConfetti, posX, posY, 0);
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)
sprite->data[1] = 0;
sprite->sExtraY = 0;
else
sprite->data[1] = 1;
sprite->sExtraY = 1;
return FALSE;
}
// Used when a Battle Dome tourney is won
void DoConfettiEffect(void)
// The below confetti functions are used when a Battle Dome tourney is won
// 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;
gSpecialVar_0x8004 = 180;
taskId = CreateTask(Task_DoConfettiEffect, 0);
taskId = CreateTask(Task_DoDomeConfetti, 0);
if (taskId != 0xFF)
{
gTasks[taskId].data[1] = gSpecialVar_0x8004;
gTasks[taskId].tTimer = gSpecialVar_0x8004;
gSpecialVar_0x8005 = taskId;
}
}
static void StopConfettiEffect(void)
static void StopDomeConfetti(void)
{
u8 taskId;
if ((taskId = FindTaskIdByFunc(Task_DoConfettiEffect)) != 0xFF)
if ((taskId = FindTaskIdByFunc(Task_DoDomeConfetti)) != 0xFF)
DestroyTask(taskId);
sub_8152254();
FreeSpriteTilesByTag(0x3E9);
FreeSpritePaletteByTag(0x3E9);
OamUtil_Free();
FreeSpriteTilesByTag(TAG_CONFETTI);
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]--;
sub_81525D0(structPtr->id);
// Destroy confetti after it falls far enough
gTasks[oamUtil->data[CONFETTI_TASK_ID]].tConfettiCount--;
OamUtil_Remove(oamUtil->id);
}
else
{
u8 var;
// Move confetti down
u8 sineIdx;
s32 rand;
structPtr->yDelta++;
structPtr->yDelta += structPtr->data[1];
oamUtil->yDelta++;
oamUtil->yDelta += oamUtil->data[CONFETTI_EXTRA_Y];
var = structPtr->data[0];
sineIdx = oamUtil->data[CONFETTI_SINE_IDX];
rand = Random();
rand &= 3;
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;
switch (data[0])
switch (tState)
{
case 0:
if (!sub_81521C0(0x40))
if (!OamUtil_Init(64))
{
// Init failed
DestroyTask(taskId);
gSpecialVar_0x8004 = var;
gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF;
}
LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
data[0]++;
LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
LoadCompressedSpritePalette(sSpritePalette_Confetti);
tState++;
break;
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);
if (var != 0xFF)
// Create new confetti every 3 frames
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);
if ((Random() & 3) == 0)
sub_8152474(var, 1, 1);
sub_8152474(var, 7, taskId);
data[15]++;
OamUtil_SetCallback(id, UpdateDomeConfetti);
// 1/4 of the confetti move an extra y coord every frame
if ((Random() % 4) == 0)
OamUtil_SetData(id, CONFETTI_EXTRA_Y, 1);
OamUtil_SetData(id, CONFETTI_TASK_ID, taskId);
tConfettiCount++;
}
}
sub_81522D4();
if (data[1] != 0)
data[1]--;
else if (data[15] == 0)
data[0] = 0xFF;
OamUtil_Update();
if (tTimer != 0)
tTimer--;
else if (tConfettiCount == 0)
tState = 0xFF;
break;
case 0xFF:
StopConfettiEffect();
gSpecialVar_0x8004 = var;
StopDomeConfetti();
gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF;
break;
}

View File

@ -7,10 +7,10 @@
static EWRAM_DATA struct
{
u8 count;
struct UnkStruct_81520A8 *unk4;
} *sUnknown_0203ABB8 = NULL;
struct OamUtil *array;
} *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 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 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;
@ -56,69 +56,69 @@ bool32 sub_81521C0(u8 count)
if (count > 64)
count = 64;
sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8));
if (sUnknown_0203ABB8 == NULL)
sWork = AllocZeroed(sizeof(*sWork));
if (sWork == NULL)
return FALSE;
sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8));
if (sUnknown_0203ABB8->unk4 == NULL)
sWork->array = AllocZeroed(count * sizeof(struct OamUtil));
if (sWork->array == NULL)
{
FREE_AND_SET_NULL(sUnknown_0203ABB8);
FREE_AND_SET_NULL(sWork);
return FALSE;
}
sUnknown_0203ABB8->count = count;
sWork->count = count;
for (i = 0; i < count; i++)
{
memcpy(&sUnknown_0203ABB8->unk4[i].oam, &gDummyOamData, sizeof(struct OamData));
sUnknown_0203ABB8->unk4[i].unk19_2 = TRUE;
memcpy(&sWork->array[i].oam, &gDummyOamData, sizeof(struct OamData));
sWork->array[i].dummied = TRUE;
}
return TRUE;
}
bool32 sub_8152254(void)
bool32 OamUtil_Free(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL)
if (sWork == NULL)
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));
memset(sUnknown_0203ABB8->unk4, 0, sUnknown_0203ABB8->count * sizeof(struct UnkStruct_81520A8));
FREE_AND_SET_NULL(sUnknown_0203ABB8->unk4);
memset(sUnknown_0203ABB8, 0, sizeof(*sUnknown_0203ABB8));
FREE_AND_SET_NULL(sUnknown_0203ABB8);
memset(sWork->array, 0, sWork->count * sizeof(struct OamUtil));
FREE_AND_SET_NULL(sWork->array);
memset(sWork, 0, sizeof(*sWork));
FREE_AND_SET_NULL(sWork);
return TRUE;
}
bool32 sub_81522D4(void)
bool32 OamUtil_Update(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL)
if (sWork == NULL || sWork->array == NULL)
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)
sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]);
if (sWork->array[i].callback != NULL)
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));
}
else
{
sUnknown_0203ABB8->unk4[i].oam.y = sUnknown_0203ABB8->unk4[i].y + sUnknown_0203ABB8->unk4[i].yDelta;
sUnknown_0203ABB8->unk4[i].oam.x = sUnknown_0203ABB8->unk4[i].x + sUnknown_0203ABB8->unk4[i].xDelta;
sUnknown_0203ABB8->unk4[i].oam.priority = sUnknown_0203ABB8->unk4[i].priority;
sUnknown_0203ABB8->unk4[i].oam.tileNum = sUnknown_0203ABB8->unk4[i].tileNum;
memcpy(&gMain.oamBuffer[i + 64], &sUnknown_0203ABB8->unk4[i], sizeof(struct OamData));
sWork->array[i].oam.y = sWork->array[i].y + sWork->array[i].yDelta;
sWork->array[i].oam.x = sWork->array[i].x + sWork->array[i].xDelta;
sWork->array[i].oam.priority = sWork->array[i].priority;
sWork->array[i].oam.tileNum = sWork->array[i].tileNum;
memcpy(&gMain.oamBuffer[i + 64], &sWork->array[i], sizeof(struct OamData));
}
}
}
@ -126,7 +126,7 @@ bool32 sub_81522D4(void)
return TRUE;
}
static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
static bool32 SetAnimAndTileNum(struct OamUtil *structPtr, u8 animNum)
{
u16 tileStart;
@ -137,50 +137,50 @@ static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
if (tileStart == 0xFFFF)
return FALSE;
structPtr->unk18 = arg1;
structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart;
structPtr->animNum = animNum;
structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * animNum) + tileStart;
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;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0)
else if (!sWork->array[id].active)
return 0xFF;
sUnknown_0203ABB8->unk4[id].callback = func;
sWork->array[id].callback = func;
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;
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;
sUnknown_0203ABB8->unk4[id].data[dataArrayId] = dataValue;
sWork->array[id].data[dataArrayId] = dataValue;
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;
if (sUnknown_0203ABB8 == NULL || oam == NULL)
if (sWork == NULL || oam == NULL)
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));
structPtr->id = i;
structPtr->unk19_0 = TRUE;
structPtr->unk19_1 = TRUE;
structPtr->active = TRUE;
structPtr->allowUpdates = TRUE;
break;
}
}
@ -199,20 +199,20 @@ u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y,
structPtr->priority = priority;
structPtr->oam.priority = priority;
}
sub_81523F4(structPtr, arg5);
SetAnimAndTileNum(structPtr, animNum);
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;
memset(&sUnknown_0203ABB8->unk4[id], 0, sizeof(struct UnkStruct_81520A8));
sUnknown_0203ABB8->unk4[id].oam.y = 160;
sUnknown_0203ABB8->unk4[id].oam.x = 240;
sUnknown_0203ABB8->unk4[id].unk19_2 = TRUE;
memset(&sWork->array[id], 0, sizeof(struct OamUtil));
sWork->array[id].oam.y = 160;
sWork->array[id].oam.x = 240;
sWork->array[id].dummied = TRUE;
memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
return id;
}