Merge pull request #1079 from GriffinRichards/doc-confetti

Document Contest Util and confetti effects
This commit is contained in:
PikalaxALT 2020-07-08 16:01:27 -04:00 committed by GitHub
commit ebade7affb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 1271 additions and 1132 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

@ -45,7 +45,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_OpponentEnter:: @ 8241BC3
BattleFrontier_BattleTower_EventScript_WarpToLobbyLost:: @ 8241C03
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_LOST
tower_set TOWER_DATA_LVL_MODE
setvar VAR_0x8004, 3
setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
@ -134,7 +134,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_ContinueChallenge:: @ 8241DDC
BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobbyWon:: @ 8241DF6
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_WON
tower_set TOWER_DATA_LVL_MODE
setvar VAR_0x8004, 3
setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby

View File

@ -103,7 +103,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_DoTowerBattle:: @ 8249069
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyLost:: @ 824907E
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_LOST
tower_set TOWER_DATA_LVL_MODE
setvar VAR_0x8004, 3
setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
@ -208,7 +208,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallenge:: @ 8249
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyWon:: @ 82492AF
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_WON
tower_set TOWER_DATA_LVL_MODE
setvar VAR_0x8004, 3
setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby

View File

@ -54,7 +54,7 @@ EverGrandeCity_DrakesRoom_EventScript_PostBattleSpeech:: @ 822871A
end
EverGrandeCity_DrakesRoom_EventScript_Defeated:: @ 8228724
setvar VAR_0x8004, 0
setvar VAR_0x8004, FANCOUNTER_DEFEATED_DRAKE
special Script_TryGainNewFanFromCounter
setflag FLAG_DEFEATED_ELITE_4_DRAKE
call PokemonLeague_EliteFour_SetAdvanceToNextRoomMetatiles

View File

@ -43,7 +43,7 @@ LilycoveCity_ContestLobby_EventScript_ContestArtist:: @ 821A264
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 0
showcontestwinner CONTEST_WINNER_ARTIST
lockall
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES
@ -217,7 +217,7 @@ LilycoveCity_ContestLobby_EventScript_LinkContestArtist:: @ 821A436
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 0
showcontestwinner CONTEST_WINNER_ARTIST
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq LilycoveCity_ContestLobby_EventScript_TakePaintingToMuseumLink
@ -505,42 +505,42 @@ LilycoveCity_ContestLobby_EventScript_NinjaBoy:: @ 821A735
LilycoveCity_ContestLobby_EventScript_ContestWinner1:: @ 821A73E
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 1
showcontestwinner CONTEST_WINNER_HALL_1
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner2:: @ 821A745
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 2
showcontestwinner CONTEST_WINNER_HALL_2
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner3:: @ 821A74C
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 3
showcontestwinner CONTEST_WINNER_HALL_3
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner4:: @ 821A753
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 4
showcontestwinner CONTEST_WINNER_HALL_4
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner5:: @ 821A75A
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 5
showcontestwinner CONTEST_WINNER_HALL_5
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner6:: @ 821A761
lockall
fadescreen FADE_TO_BLACK
showcontestwinner 6
showcontestwinner CONTEST_WINNER_HALL_6
releaseall
end

View File

@ -183,35 +183,35 @@ LilycoveCity_LilycoveMuseum_2F_EventScript_RichBoy:: @ 821999C
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowCoolPainting:: @ 82199A5
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
showcontestwinner 9
showcontestwinner CONTEST_WINNER_MUSEUM_COOL
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowBeautyPainting:: @ 82199B3
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
showcontestwinner 10
showcontestwinner CONTEST_WINNER_MUSEUM_BEAUTY
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowCutePainting:: @ 82199C1
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
showcontestwinner 11
showcontestwinner CONTEST_WINNER_MUSEUM_CUTE
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowSmartPainting:: @ 82199CF
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
showcontestwinner 12
showcontestwinner CONTEST_WINNER_MUSEUM_SMART
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowToughPainting:: @ 82199DD
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
showcontestwinner 13
showcontestwinner CONTEST_WINNER_MUSEUM_TOUGH
releaseall
end

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

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

33
include/confetti_util.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef GUARD_CONFETTI_UTIL_H
#define GUARD_CONFETTI_UTIL_H
struct ConfettiUtil
{
struct OamData oam;
s16 x;
s16 y;
s16 xDelta;
s16 yDelta;
u16 tileTag;
u16 palTag;
u16 tileNum;
u8 id;
u8 filler;
u8 animNum;
u8 active:1;
u8 allowUpdates:1;
u8 dummied:1;
u8 priority:2;
s16 data[8];
void (*callback)(struct ConfettiUtil *);
};
bool32 ConfettiUtil_Init(u8 count);
bool32 ConfettiUtil_Free(void);
bool32 ConfettiUtil_Update(void);
u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *));
u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue);
u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority);
u8 ConfettiUtil_Remove(u8 id);
#endif // GUARD_CONFETTI_UTIL_H

View File

@ -29,6 +29,23 @@
#define CONTEST_CATEGORY_TOUGH 4
#define CONTEST_CATEGORIES_COUNT 5
#define CONTEST_WINNER_ARTIST 0 // Winner shown by the artist, painting not necessarily saved
#define CONTEST_WINNER_HALL_1 1
#define CONTEST_WINNER_HALL_2 2
#define CONTEST_WINNER_HALL_3 3
#define CONTEST_WINNER_HALL_4 4
#define CONTEST_WINNER_HALL_5 5
#define CONTEST_WINNER_HALL_6 6
#define NUM_CONTEST_HALL_WINNERS 6
#define CONTEST_WINNER_7 7
#define CONTEST_WINNER_8 8
#define CONTEST_WINNER_MUSEUM_COOL 9
#define CONTEST_WINNER_MUSEUM_BEAUTY 10
#define CONTEST_WINNER_MUSEUM_CUTE 11
#define CONTEST_WINNER_MUSEUM_SMART 12
#define CONTEST_WINNER_MUSEUM_TOUGH 13
// NUM_CONTEST_WINNERS in constants/global.h
#define CANT_ENTER_CONTEST 0
#define CAN_ENTER_CONTEST_EQUAL_RANK 1
#define CAN_ENTER_CONTEST_HIGH_RANK 2

View File

@ -75,4 +75,9 @@
#define FANCLUB_MEMBER7 14
#define FANCLUB_MEMBER8 15
#define FANCOUNTER_DEFEATED_DRAKE 0
#define FANCOUNTER_BATTLED_AT_BASE 1
#define FANCOUNTER_FINISHED_CONTEST 2
#define FANCOUNTER_USED_BATTLE_TOWER 3
#endif // GUARD_CONSTANTS_FIELD_SPECIALS_H

View File

@ -52,6 +52,7 @@
#define APPRENTICE_COUNT 4
#define APPRENTICE_MAX_QUESTIONS 9
#define MAX_REMATCH_ENTRIES 100 // only REMATCH_TABLE_ENTRIES (78) are used
#define NUM_CONTEST_WINNERS 13
#define UNION_ROOM_KB_ROW_COUNT 10
#define PYRAMID_BAG_ITEMS_COUNT 10

View File

@ -430,9 +430,9 @@ struct ContestResources
extern struct ContestPokemon gContestMons[CONTESTANT_COUNT];
extern s16 gContestMonConditions[CONTESTANT_COUNT];
extern s16 gUnknown_02039F08[CONTESTANT_COUNT];
extern s16 gContestMonTotalPoints[CONTESTANT_COUNT];
extern s16 gUnknown_02039F10[CONTESTANT_COUNT];
extern s16 gUnknown_02039F18[CONTESTANT_COUNT];
extern s16 gContestMonRound2Points[CONTESTANT_COUNT];
extern u8 gContestFinalStandings[CONTESTANT_COUNT];
extern u8 gContestMonPartyIndex;
extern u8 gContestPlayerMonIndex;
@ -448,7 +448,6 @@ extern u8 sContestBgCopyFlags;
extern struct ContestWinner gCurContestWinner;
extern u8 gUnknown_02039F5C;
extern u8 gUnknown_02039F5D;
extern u32 gContestRngValue;
// contest.c

View File

@ -1,5 +1,5 @@
#ifndef GUARD_CONTEST_LINK_80FC4F4_H
#define GUARD_CONTEST_LINK_80FC4F4_H
#ifndef GUARD_CONTEST_LINK_H
#define GUARD_CONTEST_LINK_H
void sub_80FCC88(u8);
void sub_80FCC88(u8);
@ -10,4 +10,4 @@ void sub_80FC804(u8);
void sub_80FCE48(u8);
void sub_80FC894(u8);
#endif //GUARD_CONTEST_LINK_80FC4F4_H
#endif //GUARD_CONTEST_LINK_H

View File

@ -1,12 +1,12 @@
#ifndef GUARD_CONTEST_LINK_80F57C4_H
#define GUARD_CONTEST_LINK_80F57C4_H
#ifndef GUARD_CONTEST_UTIL_H
#define GUARD_CONTEST_UTIL_H
void BufferContestantTrainerName(void);
void BufferContestantMonNickname(void);
void StartContest(void);
void BufferContestantMonSpecies(void);
void sub_80F8484(void);
void sub_80F84C4(u8);
void ShowContestResults(void);
void ContestLinkTransfer(u8);
void sub_80FC998(u8 taskId);
#endif // GUARD_CONTEST_LINK_80F57C4_H
#endif // GUARD_CONTEST_UTIL_H

View File

@ -960,7 +960,7 @@ struct SaveBlock1
/*0x2E20*/ u8 additionalPhrases[8]; // bitfield for 33 additional phrases in easy chat system
/*0x2E28*/ OldMan oldMan;
/*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
/*0x2e90*/ struct ContestWinner contestWinners[13]; // 0 - 5 used in contest hall, 6 - 7 unused?, 8 - 12 museum
/*0x2e90*/ struct ContestWinner contestWinners[NUM_CONTEST_WINNERS]; // see CONTEST_WINNER_*
/*0x3030*/ struct DayCare daycare;
/*0x3150*/ struct LinkBattleRecords linkBattleRecords;
/*0x31A8*/ u8 giftRibbons[52];

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[];
@ -4927,23 +4927,23 @@ extern const u32 gRouletteCreditTiles[];
extern const u32 gRouletteNumbersTiles[];
extern const u32 gRouletteMultiplierTiles[];
// Contest Link
extern const u32 gUnknown_08C19588[];
// Contest util
extern const u32 gContestResults_Gfx[];
extern const u32 gUnknown_08C19EEC[];
extern const u32 gUnknown_08C1A000[];
extern const u32 gUnknown_08C1A12C[];
extern const u32 gUnknown_08C1A2B4[];
extern const u16 gUnknown_08DC6498[];
extern const u16 gUnknown_08DC63F8[];
extern const u16 gUnknown_08DC6420[];
extern const u16 gUnknown_08DC6448[];
extern const u16 gUnknown_08DC6470[];
extern const u16 gUnknown_08DC64AC[];
extern const u16 gUnknown_08DC64C0[];
extern const u16 gUnknown_08DC64D4[];
extern const u16 gUnknown_08DC64E8[];
extern const u16 gUnknown_08DC64FC[];
extern const u16 gUnknown_08DC6510[];
extern const u32 gContestResults_Pal[];
extern const u16 gLinkContestResults_Tilemap[];
extern const u16 gNormalContestResults_Tilemap[];
extern const u16 gSuperContestResults_Tilemap[];
extern const u16 gHyperContestResults_Tilemap[];
extern const u16 gMasterContestResults_Tilemap[];
extern const u16 gCoolContestResults_Tilemap[];
extern const u16 gBeautyContestResults_Tilemap[];
extern const u16 gCuteContestResults_Tilemap[];
extern const u16 gSmartContestResults_Tilemap[];
extern const u16 gToughContestResults_Tilemap[];
extern const u16 gContestResults_Tilemap[];
// Trainer Card.
extern const u16 gHoennTrainerCard0Star_Pal[];

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,33 +0,0 @@
#ifndef GUARD_ROM_81520A8_H
#define GUARD_ROM_81520A8_H
struct UnkStruct_81520A8
{
struct OamData oam;
s16 x;
s16 y;
s16 xDelta;
s16 yDelta;
u16 tileTag;
u16 palTag;
u16 tileNum;
u8 id;
u8 filler17; // Unused.
u8 unk18;
u8 unk19_0:1;
u8 unk19_1:1;
u8 unk19_2:1;
u8 priority:2;
s16 data[8];
void (*callback)(struct UnkStruct_81520A8 *);
};
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);
#endif // GUARD_ROM_81520A8_H

View File

@ -2494,7 +2494,7 @@ extern const u8 gText_CommunicationStandby[];
extern const u8 gText_AnnouncingResults[];
extern const u8 gText_PreliminaryResults[];
extern const u8 gText_Round2Results[];
extern const u8 gText_Var1sVar2Won[];
extern const u8 gText_ContestantsMonWon[];
// Trainer Card
extern const u8 gText_LinkCableBattles[];

View File

@ -169,7 +169,7 @@ SECTIONS {
src/record_mixing.o(.text);
src/secret_base.o(.text);
src/tv.o(.text);
src/contest_link_80F57C4.o(.text);
src/contest_util.o(.text);
src/script_pokemon_util_80F87D8.o(.text);
src/field_poison.o(.text);
src/pokemon_size_record.o(.text);
@ -177,7 +177,7 @@ SECTIONS {
src/field_special_scene.o(.text);
src/rotating_gate.o(.text);
src/safari_zone.o(.text);
src/contest_link_80FC4F4.o(.text);
src/contest_link.o(.text);
src/item_use.o(.text);
src/battle_anim_effects_1.o(.text);
src/battle_anim_effects_2.o(.text);
@ -238,7 +238,7 @@ SECTIONS {
src/cable_car.o(.text);
src/math_util.o(.text);
src/roulette_util.o(.text);
src/rom_81520A8.o(.text);
src/confetti_util.o(.text);
src/save.o(.text);
src/mystery_event_script.o(.text);
src/field_effect_helpers.o(.text);
@ -329,7 +329,7 @@ SECTIONS {
src/trainer_hill.o(.text);
src/rayquaza_scene.o(.text);
src/walda_phrase.o(.text);
src/contest_link_81D9DE4.o(.text);
src/contest_link_util.o(.text);
src/gym_leader_rematch.o(.text);
src/unk_transition.o(.text);
src/international_string_util.o(.text);
@ -544,13 +544,13 @@ SECTIONS {
src/record_mixing.o(.rodata);
src/secret_base.o(.rodata);
src/tv.o(.rodata);
src/contest_link_80F57C4.o(.rodata);
src/contest_util.o(.rodata);
src/script_pokemon_util_80F87D8.o(.rodata);
src/pokemon_size_record.o(.rodata)
src/fldeff_misc.o(.rodata);
src/field_special_scene.o(.rodata);
src/rotating_gate.o(.rodata);
src/contest_link_80FC4F4.o(.rodata);
src/contest_link.o(.rodata);
src/item_use.o(.rodata);
src/battle_anim_effects_1.o(.rodata);
src/battle_anim_effects_2.o(.rodata);

218
src/confetti_util.c Normal file
View File

@ -0,0 +1,218 @@
#include "global.h"
#include "confetti_util.h"
#include "malloc.h"
#include "main.h"
#include "digit_obj_util.h"
static EWRAM_DATA struct
{
u8 count;
struct ConfettiUtil *array;
} *sWork = NULL;
static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
for (i = 0, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = value;
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
const u16 *_src;
for (i = 0, _src = src, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++);
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
bool32 ConfettiUtil_Init(u8 count)
{
u8 i = 0;
if (count == 0)
return FALSE;
if (count > 64)
count = 64;
sWork = AllocZeroed(sizeof(*sWork));
if (sWork == NULL)
return FALSE;
sWork->array = AllocZeroed(count * sizeof(struct ConfettiUtil));
if (sWork->array == NULL)
{
FREE_AND_SET_NULL(sWork);
return FALSE;
}
sWork->count = count;
for (i = 0; i < count; i++)
{
memcpy(&sWork->array[i].oam, &gDummyOamData, sizeof(struct OamData));
sWork->array[i].dummied = TRUE;
}
return TRUE;
}
bool32 ConfettiUtil_Free(void)
{
u8 i = 0;
if (sWork == NULL)
return FALSE;
for (i = 0; i < sWork->count; i++)
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
memset(sWork->array, 0, sWork->count * sizeof(struct ConfettiUtil));
FREE_AND_SET_NULL(sWork->array);
memset(sWork, 0, sizeof(*sWork));
FREE_AND_SET_NULL(sWork);
return TRUE;
}
bool32 ConfettiUtil_Update(void)
{
u8 i = 0;
if (sWork == NULL || sWork->array == NULL)
return FALSE;
for (i = 0; i < sWork->count; i++)
{
if (sWork->array[i].active && sWork->array[i].allowUpdates)
{
if (sWork->array[i].callback != NULL)
sWork->array[i].callback(&sWork->array[i]);
if (sWork->array[i].dummied)
{
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
}
else
{
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));
}
}
}
return TRUE;
}
static bool32 SetAnimAndTileNum(struct ConfettiUtil *structPtr, u8 animNum)
{
u16 tileStart;
if (structPtr == NULL)
return FALSE;
tileStart = GetSpriteTileStartByTag(structPtr->tileTag);
if (tileStart == 0xFFFF)
return FALSE;
structPtr->animNum = animNum;
structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * animNum) + tileStart;
return TRUE;
}
u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *))
{
if (sWork == NULL || id >= sWork->count)
return 0xFF;
else if (!sWork->array[id].active)
return 0xFF;
sWork->array[id].callback = func;
return id;
}
u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
{
if (sWork == NULL || id >= sWork->count)
return 0xFF;
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;
sWork->array[id].data[dataArrayId] = dataValue;
return id;
}
u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority)
{
struct ConfettiUtil *structPtr = NULL;
u8 i;
if (sWork == NULL || oam == NULL)
return 0xFF;
for (i = 0; i < sWork->count; i++)
{
if (!sWork->array[i].active)
{
structPtr = &sWork->array[i];
memset(structPtr, 0, sizeof(*structPtr));
structPtr->id = i;
structPtr->active = TRUE;
structPtr->allowUpdates = TRUE;
break;
}
}
if (structPtr == NULL)
return 0xFF;
memcpy(&structPtr->oam, oam, sizeof(*oam));
structPtr->tileTag = tileTag;
structPtr->palTag = palTag;
structPtr->x = x;
structPtr->y = y;
structPtr->oam.paletteNum = IndexOfSpritePaletteTag(palTag);
if (priority < 4)
{
structPtr->priority = priority;
structPtr->oam.priority = priority;
}
SetAnimAndTileNum(structPtr, animNum);
return structPtr->id;
}
u8 ConfettiUtil_Remove(u8 id)
{
if (sWork == NULL || !sWork->array[id].active)
return 0xFF;
memset(&sWork->array[id], 0, sizeof(struct ConfettiUtil));
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;
}

View File

@ -31,14 +31,14 @@
#include "tv.h"
#include "scanline_effect.h"
#include "util.h"
#include "contest_link_80F57C4.h"
#include "contest_util.h"
#include "dma3.h"
#include "battle_message.h"
#include "event_scripts.h"
#include "event_data.h"
#include "strings.h"
#include "contest_effect.h"
#include "contest_link_80FC4F4.h"
#include "contest_link.h"
#include "script_pokemon_util_80F87D8.h"
#include "international_string_util.h"
#include "data.h"
@ -155,7 +155,7 @@ static void Contest_StartTextPrinter(const u8 *, u32);
static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16);
static bool32 Contest_RunTextPrinters(void);
static void Contest_SetBgCopyFlags(u32 flagIndex);
static void sub_80DBD18(void);
static void CalculateFinalScores(void);
static void sub_80DD080(u8);
static void sub_80DE9DC(u8);
static void sub_80DCBE8(u8, u8);
@ -184,7 +184,7 @@ static void sub_80DC3AC(void);
static bool8 sub_80DC3C4(void);
static void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8);
static void Contest_PrintTextToBg0WindowStd(u32, const u8 *);
static s16 sub_80DBD34(u8);
static s16 GetContestantRound2Points(u8);
static void DetermineFinalStandings(void);
static bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *);
static void sub_80DC0F4(u8);
@ -221,9 +221,9 @@ static void SwapMoveDescAndContestTilemaps(void);
// EWRAM vars.
EWRAM_DATA struct ContestPokemon gContestMons[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gContestMonConditions[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gUnknown_02039F08[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gContestMonTotalPoints[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gUnknown_02039F10[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gUnknown_02039F18[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gContestMonRound2Points[CONTESTANT_COUNT] = {0};
EWRAM_DATA u8 gContestFinalStandings[CONTESTANT_COUNT] = {0};
EWRAM_DATA u8 gContestMonPartyIndex = 0;
EWRAM_DATA u8 gContestPlayerMonIndex = 0;
@ -239,7 +239,7 @@ EWRAM_DATA u8 gHighestRibbonRank = 0;
EWRAM_DATA struct ContestResources *gContestResources = NULL;
EWRAM_DATA u8 sContestBgCopyFlags = 0;
EWRAM_DATA struct ContestWinner gCurContestWinner = {0};
EWRAM_DATA u8 gUnknown_02039F5C = 0;
EWRAM_DATA bool8 gUnknown_02039F5C = 0;
EWRAM_DATA u8 gUnknown_02039F5D = 0;
// IWRAM common vars.
@ -2490,7 +2490,7 @@ static void sub_80DA5E8(u8 taskId)
gBattle_BG2_Y = 0;
for (i = 0; i < CONTESTANT_COUNT; i++)
gUnknown_02039F10[i] = eContestantStatus[i].pointTotal;
sub_80DBD18();
CalculateFinalScores();
ContestClearGeneralTextWindow();
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove);
@ -3367,22 +3367,22 @@ bool8 Contest_IsMonsTurnDisabled(u8 a)
return FALSE;
}
static void sub_80DBCE0(u8 contestant)
static void CalculateTotalPointsForContestant(u8 contestant)
{
gUnknown_02039F18[contestant] = sub_80DBD34(contestant);
gUnknown_02039F08[contestant] = gContestMonConditions[contestant] + gUnknown_02039F18[contestant];
gContestMonRound2Points[contestant] = GetContestantRound2Points(contestant);
gContestMonTotalPoints[contestant] = gContestMonConditions[contestant] + gContestMonRound2Points[contestant];
}
static void sub_80DBD18(void)
static void CalculateFinalScores(void)
{
s32 i;
for (i = 0; i < CONTESTANT_COUNT; i++)
sub_80DBCE0(i);
CalculateTotalPointsForContestant(i);
DetermineFinalStandings();
}
static s16 sub_80DBD34(u8 contestant)
static s16 GetContestantRound2Points(u8 contestant)
{
return gUnknown_02039F10[contestant] * 2;
}
@ -3411,7 +3411,7 @@ static void DetermineFinalStandings(void)
for (i = 0; i < CONTESTANT_COUNT; i++)
{
sp8[i].unk0 = gUnknown_02039F08[i];
sp8[i].unk0 = gContestMonTotalPoints[i];
sp8[i].unk4 = gContestMonConditions[i];
sp8[i].unk8 = randomOrdering[i];
sp8[i].unkC = i;
@ -5313,22 +5313,22 @@ bool8 sub_80DEDA8(u8 rank)
}
if (rank != 0xFE)
{
u8 r4 = sub_80DEFA8(rank, 1);
u8 id = sub_80DEFA8(rank, 1);
gSaveBlock1Ptr->contestWinners[r4].personality = gContestMons[i].personality;
gSaveBlock1Ptr->contestWinners[r4].species = gContestMons[i].species;
gSaveBlock1Ptr->contestWinners[r4].trainerId = gContestMons[i].otId;
StringCopy(gSaveBlock1Ptr->contestWinners[r4].monName, gContestMons[i].nickname);
StringCopy(gSaveBlock1Ptr->contestWinners[r4].trainerName, gContestMons[i].trainerName);
gSaveBlock1Ptr->contestWinners[id].personality = gContestMons[i].personality;
gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species;
gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId;
StringCopy(gSaveBlock1Ptr->contestWinners[id].monName, gContestMons[i].nickname);
StringCopy(gSaveBlock1Ptr->contestWinners[id].trainerName, gContestMons[i].trainerName);
if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
gSaveBlock1Ptr->contestWinners[r4].contestRank = CONTEST_RANK_LINK;
gSaveBlock1Ptr->contestWinners[id].contestRank = CONTEST_RANK_LINK;
else
gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank;
gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank;
if (rank != 0xFF)
gSaveBlock1Ptr->contestWinners[r4].contestCategory = gSpecialVar_ContestCategory;
gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory;
else
gSaveBlock1Ptr->contestWinners[r4].contestCategory = r7;
gSaveBlock1Ptr->contestWinners[id].contestCategory = r7;
}
else
{
@ -5354,24 +5354,24 @@ u8 sub_80DEFA8(u8 rank, u8 b)
case CONTEST_RANK_MASTER:
if (b != 0)
{
for (i = 5; i >= 1; i--)
for (i = NUM_CONTEST_HALL_WINNERS - 1; i >= 1; i--)
memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner));
}
return 0;
default: // CONTEST_RANK_LINK
default:
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
return 8;
return CONTEST_WINNER_MUSEUM_COOL - 1;
case CONTEST_CATEGORY_BEAUTY:
return 9;
return CONTEST_WINNER_MUSEUM_BEAUTY - 1;
case CONTEST_CATEGORY_CUTE:
return 10;
return CONTEST_WINNER_MUSEUM_CUTE - 1;
case CONTEST_CATEGORY_SMART:
return 11;
return CONTEST_WINNER_MUSEUM_SMART - 1;
case CONTEST_CATEGORY_TOUGH:
default:
return 12;
return CONTEST_WINNER_MUSEUM_TOUGH - 1;
}
}
}
@ -5471,7 +5471,7 @@ static void sub_80DF250(void)
gContestResources->field_1c[r1].unkD |= 1;
for (i = 0; i < CONTESTANT_COUNT; i++)
{
if (i != var_38 && gUnknown_02039F08[var_38] - gUnknown_02039F08[i] <= 50)
if (i != var_38 && gContestMonTotalPoints[var_38] - gContestMonTotalPoints[i] <= 50)
gContestResources->field_1c[i].unkD |= 4;
if (!gContestResources->field_1c[i].unkE_2)
@ -5491,7 +5491,7 @@ static void sub_80DF250(void)
{
if (gContestMonConditions[i] > gContestMonConditions[j])
r12 = TRUE;
if (gUnknown_02039F18[i] > gUnknown_02039F18[j])
if (gContestMonRound2Points[i] > gContestMonRound2Points[j])
r8 = TRUE;
}
if (!r12 && !r8)
@ -5582,7 +5582,7 @@ static void sub_80DF4F8(void)
{
if (gContestMonConditions[r7] < gContestMonConditions[i])
r9++;
if (gUnknown_02039F18[r7] < gUnknown_02039F18[i])
if (gContestMonRound2Points[r7] < gContestMonRound2Points[i])
r10++;
}

View File

@ -6,6 +6,7 @@
#include "pokemon.h"
#include "random.h"
#include "task.h"
#include "contest_link.h"
#include "constants/flags.h"
static void sub_80FC5C0(u8);
@ -296,14 +297,14 @@ void sub_80FCACC(u8 taskId)
case 0:
if (IsLinkTaskFinished())
{
if (sub_80FC4F4(gUnknown_02039F08, sizeof(gUnknown_02039F08)) == 1)
if (sub_80FC4F4(gContestMonTotalPoints, sizeof(gContestMonTotalPoints)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC55C())
{
memcpy(gUnknown_02039F08, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F08));
memcpy(gContestMonTotalPoints, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonTotalPoints));
gTasks[taskId].data[0]++;
}
break;
@ -334,14 +335,14 @@ void sub_80FCACC(u8 taskId)
case 6:
if (IsLinkTaskFinished())
{
if (sub_80FC4F4(gUnknown_02039F18, sizeof(gUnknown_02039F18)) == 1)
if (sub_80FC4F4(gContestMonRound2Points, sizeof(gContestMonRound2Points)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 7:
if (sub_80FC55C())
{
memcpy(gUnknown_02039F18, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F18));
memcpy(gContestMonRound2Points, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonRound2Points));
gTasks[taskId].data[0]++;
}
break;

View File

@ -170,7 +170,7 @@ void SetContestWinnerForPainting(int contestWinnerId)
u8 *ptr2 = &gUnknown_02039F5C;
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
*ptr1 = contestWinnerId - 1;
*ptr2 = 0;
*ptr2 = FALSE;
}
void CB2_ContestPainting(void)
@ -281,7 +281,7 @@ static void InitContestPaintingWindow(void)
ShowBg(1);
}
static void PrintContestPaintingCaption(u8 contestType, u8 arg1)
static void PrintContestPaintingCaption(u8 contestType, bool8 arg1)
{
int x;
u8 category;
@ -519,12 +519,14 @@ _081303F8:\n\
}
#endif
static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
{
u8 x, y;
LoadPalette(gPictureFramePalettes, 0, 0x100);
if (arg1 == 1)
if (arg1 == TRUE)
{
switch (gContestPaintingWinner->contestCategory / 3)
{
@ -550,8 +552,6 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
break;
}
#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
// Set the background
for (y = 0; y < 20; y++)
{
@ -569,8 +569,6 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
// Re-set the entire top row to the first top frame part
for (x = 0; x < 16; x++)
VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7];
#undef VRAM_PICTURE_DATA
}
else if (contestWinnerId < 8)
{
@ -605,6 +603,8 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
}
}
#undef VRAM_PICTURE_DATA
static void InitPaintingMonOamData(u8 contestWinnerId)
{
//Some hacks just to get the asm to match
@ -692,7 +692,7 @@ static void DoContestPaintingImageProcessing(u8 imageEffect)
LoadPalette(gContestPaintingMonPalette, 0x100, 0x200);
}
static void CreateContestPaintingPicture(u8 contestWinnerId, u8 arg1)
static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 arg1)
{
AllocPaintingResources();
InitContestMonPixels(gContestPaintingWinner->species, 0);

File diff suppressed because it is too large Load Diff

View File

@ -4095,11 +4095,17 @@ void UpdateTrainerFanClubGameClear(void)
}
// If the player has < 3 fans, gain a new fan whenever the counter reaches 20+
// Defeating Drake or participating in a Link Contest increments the counter by 2
// Defeating Drake or participating in a Contest increments the counter by 2
// Participating at Battle Tower or in a Secret Base battle increments the counter by 1
u8 TryGainNewFanFromCounter(u8 incrementId)
{
static const u8 sCounterIncrements[] = { 2, 1, 2, 1 };
static const u8 sCounterIncrements[] =
{
[FANCOUNTER_DEFEATED_DRAKE] = 2,
[FANCOUNTER_BATTLED_AT_BASE] = 1,
[FANCOUNTER_FINISHED_CONTEST] = 2,
[FANCOUNTER_USED_BATTLE_TOWER] = 1
};
if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
{

View File

@ -471,13 +471,11 @@ const u8 gTiles_8C19450[] = INCBIN_U8("graphics/contest/heart.4bpp");
const u32 gUnknownGfx_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.4bpp.lz");
const u32 gUnknownPal_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.gbapal.lz");
const u32 gUnknown_08C19588[] = INCBIN_U32("graphics/contest/misc_2.4bpp.lz");
const u32 gContestResults_Gfx[] = INCBIN_U32("graphics/contest/results_screen.4bpp.lz");
const u32 gUnknown_08C19EEC[] = INCBIN_U32("graphics/contest/misc_2_tilemap_1.bin.lz");
const u32 gUnknown_08C1A000[] = INCBIN_U32("graphics/contest/misc_2_tilemap_2.bin.lz");
const u32 gUnknown_08C1A12C[] = INCBIN_U32("graphics/contest/misc_2_tilemap_3.bin.lz");
const u32 gUnknown_08C1A2B4[] = INCBIN_U32("graphics/contest/misc_2.gbapal.lz");
const u32 gContestResults_Pal[] = INCBIN_U32("graphics/contest/results_screen.gbapal.lz");
const u32 gBattleAnimSpriteGfx_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.4bpp.lz");
const u32 gBattleAnimSpritePal_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.gbapal.lz");
@ -875,8 +873,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");
@ -1298,19 +1296,19 @@ const u8 gFireRedMenuElements_Gfx[] = INCBIN_U8("graphics/interface_fr/menu.4bpp
const u8 gBagMenuHMIcon_Gfx[] = INCBIN_U8("graphics/interface/hm.4bpp");
// contest link stuff, appears to be a set of tilemaps
// contest results screen
const u16 gUnknown_08DC63F8[] = INCBIN_U16("graphics/contest/clink_tilemap1.bin");
const u16 gUnknown_08DC6420[] = INCBIN_U16("graphics/contest/clink_tilemap2.bin");
const u16 gUnknown_08DC6448[] = INCBIN_U16("graphics/contest/clink_tilemap3.bin");
const u16 gUnknown_08DC6470[] = INCBIN_U16("graphics/contest/clink_tilemap4.bin");
const u16 gUnknown_08DC6498[] = INCBIN_U16("graphics/contest/clink_tilemap5.bin");
const u16 gUnknown_08DC64AC[] = INCBIN_U16("graphics/contest/clink_tilemap6.bin");
const u16 gUnknown_08DC64C0[] = INCBIN_U16("graphics/contest/clink_tilemap7.bin");
const u16 gUnknown_08DC64D4[] = INCBIN_U16("graphics/contest/clink_tilemap8.bin");
const u16 gUnknown_08DC64E8[] = INCBIN_U16("graphics/contest/clink_tilemap9.bin");
const u16 gUnknown_08DC64FC[] = INCBIN_U16("graphics/contest/clink_tilemap10.bin");
const u16 gUnknown_08DC6510[] = INCBIN_U16("graphics/contest/clink_tilemap11.bin");
const u16 gNormalContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_normal.bin");
const u16 gSuperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_super.bin");
const u16 gHyperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_hyper.bin");
const u16 gMasterContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_master.bin");
const u16 gLinkContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_link.bin");
const u16 gCoolContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cool.bin");
const u16 gBeautyContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_beauty.bin");
const u16 gCuteContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cute.bin");
const u16 gSmartContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_smart.bin");
const u16 gToughContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_tough.bin");
const u16 gContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen.bin");
// pokenav

View File

@ -33,9 +33,12 @@
#include "fldeff_misc.h"
#include "trainer_pokemon_sprites.h"
#include "data.h"
#include "rom_81520A8.h"
#include "confetti_util.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 ConfettiUtil
#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);
ConfettiUtil_Free();
FreeSpriteTilesByTag(TAG_CONFETTI);
FreeSpritePaletteByTag(TAG_CONFETTI);
}
static void sub_81752F4(struct UnkStruct_81520A8 *structPtr)
static void UpdateDomeConfetti(struct ConfettiUtil *util)
{
if (structPtr->yDelta > 110)
if (util->yDelta > 110)
{
gTasks[structPtr->data[7]].data[15]--;
sub_81525D0(structPtr->id);
// Destroy confetti after it falls far enough
gTasks[util->data[CONFETTI_TASK_ID]].tConfettiCount--;
ConfettiUtil_Remove(util->id);
}
else
{
u8 var;
// Move confetti down
u8 sineIdx;
s32 rand;
structPtr->yDelta++;
structPtr->yDelta += structPtr->data[1];
util->yDelta++;
util->yDelta += util->data[CONFETTI_EXTRA_Y];
var = structPtr->data[0];
sineIdx = util->data[CONFETTI_SINE_IDX];
rand = Random();
rand &= 3;
rand += 8;
structPtr->xDelta = (rand) * ((gSineTable[var])) / 256;
util->xDelta = (rand) * ((gSineTable[sineIdx])) / 256;
structPtr->data[0] += 4;
util->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 (!ConfettiUtil_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 = ConfettiUtil_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]++;
ConfettiUtil_SetCallback(id, UpdateDomeConfetti);
// 1/4 of the confetti move an extra y coord every frame
if ((Random() % 4) == 0)
ConfettiUtil_SetData(id, CONFETTI_EXTRA_Y, 1);
ConfettiUtil_SetData(id, CONFETTI_TASK_ID, taskId);
tConfettiCount++;
}
}
sub_81522D4();
if (data[1] != 0)
data[1]--;
else if (data[15] == 0)
data[0] = 0xFF;
ConfettiUtil_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

@ -1,218 +0,0 @@
#include "global.h"
#include "rom_81520A8.h"
#include "malloc.h"
#include "main.h"
#include "digit_obj_util.h"
static EWRAM_DATA struct
{
u8 count;
struct UnkStruct_81520A8 *unk4;
} *sUnknown_0203ABB8 = NULL;
void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
for (i = 0, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = value;
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
const u16 *_src;
for (i = 0, _src = src, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++);
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
bool32 sub_81521C0(u8 count)
{
u8 i = 0;
if (count == 0)
return FALSE;
if (count > 64)
count = 64;
sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8));
if (sUnknown_0203ABB8 == NULL)
return FALSE;
sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8));
if (sUnknown_0203ABB8->unk4 == NULL)
{
FREE_AND_SET_NULL(sUnknown_0203ABB8);
return FALSE;
}
sUnknown_0203ABB8->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;
}
return TRUE;
}
bool32 sub_8152254(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL)
return FALSE;
for (i = 0; i < sUnknown_0203ABB8->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);
return TRUE;
}
bool32 sub_81522D4(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL)
return FALSE;
for (i = 0; i < sUnknown_0203ABB8->count; i++)
{
if (sUnknown_0203ABB8->unk4[i].unk19_0 && sUnknown_0203ABB8->unk4[i].unk19_1)
{
if (sUnknown_0203ABB8->unk4[i].callback != NULL)
sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]);
if (sUnknown_0203ABB8->unk4[i].unk19_2)
{
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));
}
}
}
return TRUE;
}
static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
{
u16 tileStart;
if (structPtr == NULL)
return FALSE;
tileStart = GetSpriteTileStartByTag(structPtr->tileTag);
if (tileStart == 0xFFFF)
return FALSE;
structPtr->unk18 = arg1;
structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart;
return TRUE;
}
u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *))
{
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0)
return 0xFF;
sUnknown_0203ABB8->unk4[id].callback = func;
return id;
}
u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue)
{
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0 || dataArrayId >= ARRAY_COUNT(sUnknown_0203ABB8->unk4[id].data))
return 0xFF;
sUnknown_0203ABB8->unk4[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)
{
struct UnkStruct_81520A8 *structPtr = NULL;
u8 i;
if (sUnknown_0203ABB8 == NULL || oam == NULL)
return 0xFF;
for (i = 0; i < sUnknown_0203ABB8->count; i++)
{
if (!sUnknown_0203ABB8->unk4[i].unk19_0)
{
structPtr = &sUnknown_0203ABB8->unk4[i];
memset(structPtr, 0, sizeof(*structPtr));
structPtr->id = i;
structPtr->unk19_0 = TRUE;
structPtr->unk19_1 = TRUE;
break;
}
}
if (structPtr == NULL)
return 0xFF;
memcpy(&structPtr->oam, oam, sizeof(*oam));
structPtr->tileTag = tileTag;
structPtr->palTag = palTag;
structPtr->x = x;
structPtr->y = y;
structPtr->oam.paletteNum = IndexOfSpritePaletteTag(palTag);
if (priority < 4)
{
structPtr->priority = priority;
structPtr->oam.priority = priority;
}
sub_81523F4(structPtr, arg5);
return structPtr->id;
}
u8 sub_81525D0(u8 id)
{
if (sUnknown_0203ABB8 == NULL || !sUnknown_0203ABB8->unk4[id].unk19_0)
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;
memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
return id;
}

View File

@ -5,7 +5,7 @@
#include "clock.h"
#include "coins.h"
#include "contest.h"
#include "contest_link_80F57C4.h"
#include "contest_util.h"
#include "contest_painting.h"
#include "data.h"
#include "decoration.h"
@ -1469,7 +1469,9 @@ bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
{
u8 contestWinnerId = ScriptReadByte(ctx);
if (contestWinnerId)
// Don't save artist's painting yet
if (contestWinnerId != CONTEST_WINNER_ARTIST)
SetContestWinnerForPainting(contestWinnerId);
ShowContestWinner();
@ -1953,14 +1955,14 @@ bool8 ScrCmd_startcontest(struct ScriptContext *ctx)
bool8 ScrCmd_showcontestresults(struct ScriptContext *ctx)
{
sub_80F8484();
ShowContestResults();
ScriptContext1_Stop();
return TRUE;
}
bool8 ScrCmd_contestlinktransfer(struct ScriptContext *ctx)
{
sub_80F84C4(gSpecialVar_ContestCategory);
ContestLinkTransfer(gSpecialVar_ContestCategory);
ScriptContext1_Stop();
return TRUE;
}

View File

@ -3,7 +3,7 @@
#include "battle_gfx_sfx_util.h"
#include "berry.h"
#include "contest.h"
#include "contest_link_80F57C4.h"
#include "contest_util.h"
#include "contest_painting.h"
#include "data.h"
#include "daycare.h"
@ -122,7 +122,7 @@ void ShouldReadyContestArtist(void)
{
if (gContestFinalStandings[gContestPlayerMonIndex] == 0
&& gSpecialVar_ContestRank == CONTEST_RANK_MASTER
&& gUnknown_02039F08[gContestPlayerMonIndex] >= 800)
&& gContestMonTotalPoints[gContestPlayerMonIndex] >= 800)
{
gSpecialVar_0x8004 = TRUE;
}
@ -304,7 +304,7 @@ u8 GiveMonArtistRibbon(void)
if (!hasArtistRibbon
&& gContestFinalStandings[gContestPlayerMonIndex] == 0
&& gSpecialVar_ContestRank == CONTEST_RANK_MASTER
&& gUnknown_02039F08[gContestPlayerMonIndex] >= 800)
&& gContestMonTotalPoints[gContestPlayerMonIndex] >= 800)
{
hasArtistRibbon = 1;
SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon);

View File

@ -37,6 +37,7 @@
#include "constants/event_bg.h"
#include "constants/decorations.h"
#include "constants/event_objects.h"
#include "constants/field_specials.h"
#include "constants/items.h"
#include "constants/maps.h"
#include "constants/map_types.h"
@ -1120,7 +1121,7 @@ const u8 *GetSecretBaseTrainerLoseText(void)
void PrepSecretBaseBattleFlags(void)
{
TryGainNewFanFromCounter(1);
TryGainNewFanFromCounter(FANCOUNTER_BATTLED_AT_BASE);
gTrainerBattleOpponent_A = TRAINER_SECRET_BASE;
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_SECRET_BASE;
}

View File

@ -1236,7 +1236,7 @@ const u8 gText_BDot[] = _("B.");
const u8 gText_AnnouncingResults[] = _("Announcing the results!");
const u8 gText_PreliminaryResults[] = _("The preliminary results!");
const u8 gText_Round2Results[] = _("Round 2 results!");
const u8 gText_Var1sVar2Won[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
const u8 gText_CommunicationStandby[] = _("Communication standby…");
const u8 gText_ColorDarkGrey[] = _("{COLOR DARK_GREY}");
const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused

View File

@ -75,7 +75,7 @@
.include "src/record_mixing.o"
.include "src/secret_base.o"
.include "src/tv.o"
.include "src/contest_link_80F57C4.o"
.include "src/contest_util.o"
.include "src/rotating_gate.o"
.include "src/safari_zone.o"
.include "src/item_use.o"
@ -104,7 +104,7 @@
.include "src/battle_transition.o"
.include "src/battle_message.o"
.include "src/cable_car.o"
.include "src/rom_81520A8.o"
.include "src/confetti_util.o"
.include "src/save.o"
.include "src/mystery_event_script.o"
.include "src/move_relearner.o"