summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-04-21 20:04:12 -0400
committerGriffinR <griffin.g.richards@gmail.com>2021-04-21 20:04:12 -0400
commitdbe24f0baa560aaa30f3084f1dfb21fb3cfb04db (patch)
treedd92c367cd3bdb11c26674db9b64f019646089d7 /src
parenta2a9f226129317c2557b908883903df47701324c (diff)
Clean up contest_painting
Diffstat (limited to 'src')
-rw-r--r--src/contest.c60
-rw-r--r--src/contest_painting.c252
-rw-r--r--src/contest_util.c24
-rw-r--r--src/data/contest_opponents.h16
-rw-r--r--src/scrcmd.c6
5 files changed, 188 insertions, 170 deletions
diff --git a/src/contest.c b/src/contest.c
index 246fc1e50..59f50fcfc 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -350,8 +350,8 @@ EWRAM_DATA u8 gHighestRibbonRank = 0;
EWRAM_DATA struct ContestResources *gContestResources = NULL;
EWRAM_DATA u8 sContestBgCopyFlags = 0;
EWRAM_DATA struct ContestWinner gCurContestWinner = {0};
-EWRAM_DATA bool8 gUnknown_02039F5C = 0;
-EWRAM_DATA u8 gUnknown_02039F5D = 0;
+EWRAM_DATA bool8 gCurContestWinnerIsForArtist = 0;
+EWRAM_DATA u8 gCurContestWinnerSaveIdx = 0;
// IWRAM common vars.
u32 gContestRngValue;
@@ -5516,40 +5516,47 @@ void ResetContestLinkResults(void)
gSaveBlock2Ptr->contestLinkResults[i][j] = 0;
}
-bool8 sub_80DEDA8(u8 rank)
+bool8 SaveContestWinner(u8 rank)
{
s32 i;
- u8 r7 = Random() % 3;
+ u8 captionId = Random() % NUM_PAINTING_CAPTIONS;
+ // Get the index of the winner among the contestants
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
- {
if (gContestFinalStandings[i] == 0)
break;
- }
- if (rank == 0xFF && i != gContestPlayerMonIndex)
+
+ // Exit if attempting to save a Pokémon other than the player's to the museum
+ if (rank == CONTEST_SAVE_FOR_MUSEUM && i != gContestPlayerMonIndex)
return FALSE;
+
+
+ // Adjust the random painting caption depending on the category
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
- r7 += 0;
+ captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL;
break;
case CONTEST_CATEGORY_BEAUTY:
- r7 += 3;
+ captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY;
break;
case CONTEST_CATEGORY_CUTE:
- r7 += 6;
+ captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE;
break;
case CONTEST_CATEGORY_SMART:
- r7 += 9;
+ captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART;
break;
case CONTEST_CATEGORY_TOUGH:
- r7 += 12;
+ captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH;
break;
}
- if (rank != 0xFE)
- {
- u8 id = sub_80DEFA8(rank, 1);
+ if (rank != CONTEST_SAVE_FOR_ARTIST)
+ {
+ // Save winner in the saveblock
+ // Used to save any winner for the Contest Hall or the Museum
+ // but excludes the temporary save used by the artist
+ u8 id = GetContestWinnerSaveIdx(rank, TRUE);
gSaveBlock1Ptr->contestWinners[id].personality = gContestMons[i].personality;
gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species;
gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId;
@@ -5560,24 +5567,29 @@ bool8 sub_80DEDA8(u8 rank)
else
gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank;
- if (rank != 0xFF)
+ if (rank != CONTEST_SAVE_FOR_MUSEUM)
gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory;
else
- gSaveBlock1Ptr->contestWinners[id].contestCategory = r7;
+ gSaveBlock1Ptr->contestWinners[id].contestCategory = captionId;
}
else
{
+ // Set the most recent winner so the artist can show the player their painting
gCurContestWinner.personality = gContestMons[i].personality;
gCurContestWinner.trainerId = gContestMons[i].otId;
gCurContestWinner.species = gContestMons[i].species;
StringCopy(gCurContestWinner.monName, gContestMons[i].nickname);
StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName);
- gCurContestWinner.contestCategory = r7;
+ gCurContestWinner.contestCategory = captionId;
}
return TRUE;
}
-u8 sub_80DEFA8(u8 rank, u8 b)
+// Rank is either a regular contest rank (for saving winners to show in the Contest Hall)
+// Or one of two special IDs listed below (for saving winners to show in Museum, or from the artist)
+// If just retrieving the index where the winner *would* go, shift is FALSE
+// If actually preparing to insert the winner into the saveblock, shift is TRUE
+u8 GetContestWinnerSaveIdx(u8 rank, bool8 shift)
{
s32 i;
@@ -5587,13 +5599,15 @@ u8 sub_80DEFA8(u8 rank, u8 b)
case CONTEST_RANK_SUPER:
case CONTEST_RANK_HYPER:
case CONTEST_RANK_MASTER:
- if (b != 0)
+ if (shift)
{
- for (i = NUM_CONTEST_HALL_WINNERS - 1; i >= 1; i--)
+ for (i = NUM_CONTEST_HALL_WINNERS - 1; i > 0; i--)
memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner));
}
- return 0;
+ return CONTEST_WINNER_HALL_1 - 1;
default:
+// case CONTEST_SAVE_FOR_MUSEUM:
+// case CONTEST_SAVE_FOR_ARTIST:
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
@@ -5615,7 +5629,7 @@ void ClearContestWinnerPicsInContestHall(void)
{
s32 i;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < MUSEUM_CONTEST_WINNERS_START; i++)
gSaveBlock1Ptr->contestWinners[i] = gDefaultContestWinners[i];
}
diff --git a/src/contest_painting.c b/src/contest_painting.c
index 4f0bf9245..ca5d8c0a9 100644
--- a/src/contest_painting.c
+++ b/src/contest_painting.c
@@ -21,18 +21,16 @@
#include "window.h"
#include "constants/rgb.h"
-// IWRAM common
u16 (*gContestMonPixels)[][32];
struct ImageProcessingContext gImageProcessingContext;
struct ContestWinner *gContestPaintingWinner;
u16 *gContestPaintingMonPalette;
-// IWRAM bss
-static u8 gContestPaintingState;
-static u16 gContestPaintingMosaicVal;
-static u16 gContestPaintingFadeCounter;
-static bool8 gUnknown_030011F6;
-static u8 gContestPaintingWindowId;
+static u8 sHoldState;
+static u16 sMosaicVal;
+static u16 sFadeCounter;
+static bool8 sVarsInitialized;
+static u8 sWindowId;
static void ShowContestPainting(void);
static void HoldContestPainting(void);
@@ -44,7 +42,7 @@ static void PrintContestPaintingCaption(u8, u8);
static void VBlankCB_ContestPainting(void);
static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]);
-extern const u8 gContestPaintingCaption[];
+extern const u8 gContestHallPaintingCaption[];
extern const u8 gContestCoolness[];
extern const u8 gContestBeauty[];
extern const u8 gContestCuteness[];
@@ -71,39 +69,39 @@ extern const u8 gContestPaintingTough1[];
extern const u8 gContestPaintingTough2[];
extern const u8 gContestPaintingTough3[];
-const u16 gPictureFramePalettes[] = INCBIN_U16("graphics/picture_frame/bg.gbapal");
-const u8 gPictureFrameTiles_0[] = INCBIN_U8("graphics/picture_frame/frame0.4bpp.rl");
-const u8 gPictureFrameTiles_1[] = INCBIN_U8("graphics/picture_frame/frame1.4bpp.rl");
-const u8 gPictureFrameTiles_2[] = INCBIN_U8("graphics/picture_frame/frame2.4bpp.rl");
-const u8 gPictureFrameTiles_3[] = INCBIN_U8("graphics/picture_frame/frame3.4bpp.rl");
-const u8 gPictureFrameTiles_4[] = INCBIN_U8("graphics/picture_frame/frame4.4bpp.rl");
-const u8 gPictureFrameTiles_5[] = INCBIN_U8("graphics/picture_frame/frame5.4bpp.rl");
-const u8 gPictureFrameTilemap_0[] = INCBIN_U8("graphics/picture_frame/frame0_map.bin.rl");
-const u8 gPictureFrameTilemap_1[] = INCBIN_U8("graphics/picture_frame/frame1_map.bin.rl");
-const u8 gPictureFrameTilemap_2[] = INCBIN_U8("graphics/picture_frame/frame2_map.bin.rl");
-const u8 gPictureFrameTilemap_3[] = INCBIN_U8("graphics/picture_frame/frame3_map.bin.rl");
-const u8 gPictureFrameTilemap_4[] = INCBIN_U8("graphics/picture_frame/frame4_map.bin.rl");
-const u8 gPictureFrameTilemap_5[] = INCBIN_U8("graphics/picture_frame/frame5_map.bin.rl");
+static const u16 sPictureFramePalettes[] = INCBIN_U16("graphics/picture_frame/bg.gbapal");
+static const u8 sPictureFrameTiles_Cool[] = INCBIN_U8("graphics/picture_frame/cool.4bpp.rl");
+static const u8 sPictureFrameTiles_Beauty[] = INCBIN_U8("graphics/picture_frame/beauty.4bpp.rl");
+static const u8 sPictureFrameTiles_Cute[] = INCBIN_U8("graphics/picture_frame/cute.4bpp.rl");
+static const u8 sPictureFrameTiles_Smart[] = INCBIN_U8("graphics/picture_frame/smart.4bpp.rl");
+static const u8 sPictureFrameTiles_Tough[] = INCBIN_U8("graphics/picture_frame/tough.4bpp.rl");
+static const u8 sPictureFrameTiles_HallLobby[] = INCBIN_U8("graphics/picture_frame/lobby.4bpp.rl");
+static const u8 sPictureFrameTilemap_Cool[] = INCBIN_U8("graphics/picture_frame/cool_map.bin.rl");
+static const u8 sPictureFrameTilemap_Beauty[] = INCBIN_U8("graphics/picture_frame/beauty_map.bin.rl");
+static const u8 sPictureFrameTilemap_Cute[] = INCBIN_U8("graphics/picture_frame/cute_map.bin.rl");
+static const u8 sPictureFrameTilemap_Smart[] = INCBIN_U8("graphics/picture_frame/smart_map.bin.rl");
+static const u8 sPictureFrameTilemap_Tough[] = INCBIN_U8("graphics/picture_frame/tough_map.bin.rl");
+static const u8 sPictureFrameTilemap_HallLobby[] = INCBIN_U8("graphics/picture_frame/lobby_map.bin.rl");
static const u8 *const sContestCategoryNames_Unused[] =
{
- gContestCoolness,
- gContestBeauty,
- gContestCuteness,
- gContestSmartness,
- gContestToughness,
+ [CONTEST_CATEGORY_COOL] = gContestCoolness,
+ [CONTEST_CATEGORY_BEAUTY] = gContestBeauty,
+ [CONTEST_CATEGORY_CUTE] = gContestCuteness,
+ [CONTEST_CATEGORY_SMART] = gContestSmartness,
+ [CONTEST_CATEGORY_TOUGH] = gContestToughness,
};
static const u8 *const sContestRankNames[] =
{
- gContestRankNormal,
- gContestRankSuper,
- gContestRankHyper,
- gContestRankMaster,
- gContestLink,
+ [CONTEST_RANK_NORMAL] = gContestRankNormal,
+ [CONTEST_RANK_SUPER] = gContestRankSuper,
+ [CONTEST_RANK_HYPER] = gContestRankHyper,
+ [CONTEST_RANK_MASTER] = gContestRankMaster,
+ [CONTEST_RANK_LINK] = gContestLink,
};
-static const struct BgTemplate sContestPaintingBgTemplates[] =
+static const struct BgTemplate sBgTemplates[] =
{
{
.bg = 1,
@@ -116,7 +114,7 @@ static const struct BgTemplate sContestPaintingBgTemplates[] =
},
};
-static const struct WindowTemplate sContestPaintingWindowTemplate =
+static const struct WindowTemplate sWindowTemplate =
{
.bg = 1,
.tilemapLeft = 2,
@@ -127,23 +125,23 @@ static const struct WindowTemplate sContestPaintingWindowTemplate =
.baseBlock = 1,
};
-static const u8 *const sContestPaintingDescriptionPointers[] =
+static const u8 *const sMuseumCaptions[NUM_PAINTING_CAPTIONS * CONTEST_CATEGORIES_COUNT] =
{
- gContestPaintingCool1,
- gContestPaintingCool2,
- gContestPaintingCool3,
- gContestPaintingBeauty1,
- gContestPaintingBeauty2,
- gContestPaintingBeauty3,
- gContestPaintingCute1,
- gContestPaintingCute2,
- gContestPaintingCute3,
- gContestPaintingSmart1,
- gContestPaintingSmart2,
- gContestPaintingSmart3,
- gContestPaintingTough1,
- gContestPaintingTough2,
- gContestPaintingTough3,
+ [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool1,
+ [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool2,
+ [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool3,
+ [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty1,
+ [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty2,
+ [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty3,
+ [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute1,
+ [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute2,
+ [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute3,
+ [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart1,
+ [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart2,
+ [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart3,
+ [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough1,
+ [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough2,
+ [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough3,
};
static const struct OamData sContestPaintingMonOamData =
@@ -161,15 +159,15 @@ static const struct OamData sContestPaintingMonOamData =
.paletteNum = 0,
};
-const u16 gUnknown_085B0838[] = {RGB(0, 0, 0), RGB(0, 0, 0)};
+static const u16 sBg_Palette[] = {RGB_BLACK, RGB_BLACK};
void SetContestWinnerForPainting(int contestWinnerId)
{
- u8 *ptr1 = &gUnknown_02039F5D;
- u8 *ptr2 = &gUnknown_02039F5C;
+ u8 *saveIdx = &gCurContestWinnerSaveIdx;
+ u8 *isForArtist = &gCurContestWinnerIsForArtist;
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
- *ptr1 = contestWinnerId - 1;
- *ptr2 = FALSE;
+ *saveIdx = contestWinnerId - 1;
+ *isForArtist = FALSE;
}
void CB2_ContestPainting(void)
@@ -189,7 +187,7 @@ static void CB2_QuitContestPainting(void)
SetMainCallback2(gMain.savedCallback);
FREE_AND_SET_NULL(gContestPaintingMonPalette);
FREE_AND_SET_NULL(gContestMonPixels);
- RemoveWindow(gContestPaintingWindowId);
+ RemoveWindow(sWindowId);
Free(GetBgTilemapBuffer(1));
FreeMonSpritesGfx();
}
@@ -203,13 +201,13 @@ static void ShowContestPainting(void)
SetVBlankCallback(NULL);
AllocateMonSpritesGfx();
gContestPaintingWinner = &gCurContestWinner;
- InitContestPaintingVars(1);
+ InitContestPaintingVars(TRUE);
InitContestPaintingBg();
gMain.state++;
break;
case 1:
ResetPaletteFade();
- DmaFillLarge32(3, 0, (void *)BG_VRAM, 0x18000, 0x1000);
+ DmaFillLarge32(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
ResetSpriteData();
gMain.state++;
break;
@@ -220,16 +218,16 @@ static void ShowContestPainting(void)
gMain.state++;
break;
case 3:
- CreateContestPaintingPicture(gUnknown_02039F5D, gUnknown_02039F5C);
+ CreateContestPaintingPicture(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
gMain.state++;
break;
case 4:
- PrintContestPaintingCaption(gUnknown_02039F5D, gUnknown_02039F5C);
- LoadPalette(gUnknown_085B0838, 0, 1 * 2);
+ PrintContestPaintingCaption(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
+ LoadPalette(sBg_Palette, 0, 1 * 2);
DmaClear32(3, PLTT, PLTT_SIZE);
BeginFastPaletteFade(2);
SetVBlankCallback(VBlankCB_ContestPainting);
- gContestPaintingState = 0;
+ sHoldState = 0;
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON);
SetMainCallback2(CB2_HoldContestPainting);
break;
@@ -238,29 +236,29 @@ static void ShowContestPainting(void)
static void HoldContestPainting(void)
{
- switch (gContestPaintingState)
+ switch (sHoldState)
{
case 0:
if (!gPaletteFade.active)
- gContestPaintingState = 1;
- if (gUnknown_030011F6 && gContestPaintingFadeCounter)
- gContestPaintingFadeCounter--;
+ sHoldState = 1;
+ if (sVarsInitialized && sFadeCounter)
+ sFadeCounter--;
break;
case 1:
if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{
- gContestPaintingState++;
+ sHoldState++;
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0));
}
- if (gUnknown_030011F6)
- gContestPaintingFadeCounter = 0;
+ if (sVarsInitialized)
+ sFadeCounter = 0;
break;
case 2:
if (!gPaletteFade.active)
SetMainCallback2(CB2_QuitContestPainting);
- if (gUnknown_030011F6 && gContestPaintingFadeCounter < 30)
- gContestPaintingFadeCounter++;
+ if (sVarsInitialized && sFadeCounter < 30)
+ sFadeCounter++;
break;
}
}
@@ -268,45 +266,47 @@ static void HoldContestPainting(void)
static void InitContestPaintingWindow(void)
{
ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, sContestPaintingBgTemplates, ARRAY_COUNT(sContestPaintingBgTemplates));
+ InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE));
- gContestPaintingWindowId = AddWindow(&sContestPaintingWindowTemplate);
+ sWindowId = AddWindow(&sWindowTemplate);
DeactivateAllTextPrinters();
- FillWindowPixelBuffer(gContestPaintingWindowId, PIXEL_FILL(0));
- PutWindowTilemap(gContestPaintingWindowId);
- CopyWindowToVram(gContestPaintingWindowId, 3);
+ FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0));
+ PutWindowTilemap(sWindowId);
+ CopyWindowToVram(sWindowId, 3);
ShowBg(1);
}
-static void PrintContestPaintingCaption(u8 contestType, bool8 arg1)
+static void PrintContestPaintingCaption(u8 contestType, bool8 noCaption)
{
int x;
u8 category;
- if (arg1 == TRUE)
+ if (noCaption == TRUE)
return;
category = gContestPaintingWinner->contestCategory;
- if (contestType < 8)
+ if (contestType < MUSEUM_CONTEST_WINNERS_START)
{
+ // Contest Hall caption
BufferContestName(gStringVar1, category);
StringAppend(gStringVar1, gText_Space);
StringAppend(gStringVar1, sContestRankNames[gContestPaintingWinner->contestRank]);
StringCopy(gStringVar2, gContestPaintingWinner->trainerName);
sub_81DB5AC(gStringVar2);
StringCopy(gStringVar3, gContestPaintingWinner->monName);
- StringExpandPlaceholders(gStringVar4, gContestPaintingCaption);
+ StringExpandPlaceholders(gStringVar4, gContestHallPaintingCaption);
}
else
{
+ // Museum caption
StringCopy(gStringVar1, gContestPaintingWinner->monName);
- StringExpandPlaceholders(gStringVar4, sContestPaintingDescriptionPointers[category]);
+ StringExpandPlaceholders(gStringVar4, sMuseumCaptions[category]);
}
x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
- AddTextPrinterParameterized(gContestPaintingWindowId, 1, gStringVar4, x, 1, 0, 0);
+ AddTextPrinterParameterized(sWindowId, 1, gStringVar4, x, 1, 0, 0);
CopyBgTilemapBufferToVram(1);
}
@@ -321,33 +321,34 @@ static void InitContestPaintingBg(void)
SetGpuReg(REG_OFFSET_BLDY, 0);
}
-static void InitContestPaintingVars(bool8 arg0)
+static void InitContestPaintingVars(bool8 reset)
{
- if (arg0 == FALSE)
+ if (reset == FALSE)
{
- gUnknown_030011F6 = FALSE;
- gContestPaintingMosaicVal = 0;
- gContestPaintingFadeCounter = 0;
+ // Never reached
+ sVarsInitialized = FALSE;
+ sMosaicVal = 0;
+ sFadeCounter = 0;
}
else
{
- gUnknown_030011F6 = TRUE;
- gContestPaintingMosaicVal = 15;
- gContestPaintingFadeCounter = 30;
+ sVarsInitialized = TRUE;
+ sMosaicVal = 15;
+ sFadeCounter = 30;
}
}
static void UpdateContestPaintingMosaicEffect(void)
{
- if (!gUnknown_030011F6)
+ if (!sVarsInitialized)
{
SetGpuReg(REG_OFFSET_MOSAIC, 0);
}
else
{
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256);
- gContestPaintingMosaicVal = gContestPaintingFadeCounter / 2;
- SetGpuReg(REG_OFFSET_MOSAIC, (gContestPaintingMosaicVal << 12) | (gContestPaintingMosaicVal << 8) | (gContestPaintingMosaicVal << 4) | (gContestPaintingMosaicVal << 0));
+ sMosaicVal = sFadeCounter / 2;
+ SetGpuReg(REG_OFFSET_MOSAIC, (sMosaicVal << 12) | (sMosaicVal << 8) | (sMosaicVal << 4) | (sMosaicVal << 0));
}
}
@@ -414,34 +415,35 @@ static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)
#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
-static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
+static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 isForArtist)
{
u8 x, y;
- LoadPalette(gPictureFramePalettes, 0, 0x100);
- if (arg1 == TRUE)
+ LoadPalette(sPictureFramePalettes, 0, 0x100);
+ if (isForArtist == TRUE)
{
- switch (gContestPaintingWinner->contestCategory / 3)
+ // Load Artist's frame
+ switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
{
case CONTEST_CATEGORY_COOL:
- RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM);
- RLUnCompWram(gPictureFrameTilemap_0, gContestMonPixels);
+ RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
+ RLUnCompWram(sPictureFrameTilemap_Cool, gContestMonPixels);
break;
case CONTEST_CATEGORY_BEAUTY:
- RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM);
- RLUnCompWram(gPictureFrameTilemap_1, gContestMonPixels);
+ RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
+ RLUnCompWram(sPictureFrameTilemap_Beauty, gContestMonPixels);
break;
case CONTEST_CATEGORY_CUTE:
- RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM);
- RLUnCompWram(gPictureFrameTilemap_2, gContestMonPixels);
+ RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
+ RLUnCompWram(sPictureFrameTilemap_Cute, gContestMonPixels);
break;
case CONTEST_CATEGORY_SMART:
- RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM);
- RLUnCompWram(gPictureFrameTilemap_3, gContestMonPixels);
+ RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
+ RLUnCompWram(sPictureFrameTilemap_Smart, gContestMonPixels);
break;
case CONTEST_CATEGORY_TOUGH:
- RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM);
- RLUnCompWram(gPictureFrameTilemap_4, gContestMonPixels);
+ RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
+ RLUnCompWram(sPictureFrameTilemap_Tough, gContestMonPixels);
break;
}
@@ -463,34 +465,36 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
for (x = 0; x < 16; x++)
VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7];
}
- else if (contestWinnerId < 8)
+ else if (contestWinnerId < MUSEUM_CONTEST_WINNERS_START)
{
- RLUnCompVram(gPictureFrameTiles_5, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_5, (void *)(BG_SCREEN_ADDR(12)));
+ // Load Contest Hall lobby frame
+ RLUnCompVram(sPictureFrameTiles_HallLobby, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_HallLobby, (void *)(BG_SCREEN_ADDR(12)));
}
else
{
- switch (gContestPaintingWinner->contestCategory / 3)
+ // Load Museum frame
+ switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
{
case CONTEST_CATEGORY_COOL:
- RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_0, (void *)(BG_SCREEN_ADDR(12)));
+ RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_Cool, (void *)(BG_SCREEN_ADDR(12)));
break;
case CONTEST_CATEGORY_BEAUTY:
- RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_1, (void *)(BG_SCREEN_ADDR(12)));
+ RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_Beauty, (void *)(BG_SCREEN_ADDR(12)));
break;
case CONTEST_CATEGORY_CUTE:
- RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_2, (void *)(BG_SCREEN_ADDR(12)));
+ RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_Cute, (void *)(BG_SCREEN_ADDR(12)));
break;
case CONTEST_CATEGORY_SMART:
- RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_3, (void *)(BG_SCREEN_ADDR(12)));
+ RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_Smart, (void *)(BG_SCREEN_ADDR(12)));
break;
case CONTEST_CATEGORY_TOUGH:
- RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM);
- RLUnCompVram(gPictureFrameTilemap_4, (void *)(BG_SCREEN_ADDR(12)));
+ RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
+ RLUnCompVram(sPictureFrameTilemap_Tough, (void *)(BG_SCREEN_ADDR(12)));
break;
}
}
@@ -519,10 +523,10 @@ static u8 GetImageEffectForContestWinner(u8 contestWinnerId)
{
u8 contestCategory;
- if (contestWinnerId < 8)
+ if (contestWinnerId < MUSEUM_CONTEST_WINNERS_START)
contestCategory = gContestPaintingWinner->contestCategory;
else
- contestCategory = gContestPaintingWinner->contestCategory / 3;
+ contestCategory = gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS;
switch (contestCategory)
{
@@ -584,12 +588,12 @@ static void DoContestPaintingImageProcessing(u8 imageEffect)
LoadPalette(gContestPaintingMonPalette, 0x100, 0x200);
}
-static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 arg1)
+static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 isForArtist)
{
AllocPaintingResources();
InitContestMonPixels(gContestPaintingWinner->species, 0);
DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId));
InitPaintingMonOamData(contestWinnerId);
- LoadContestPaintingFrame(contestWinnerId, arg1);
+ LoadContestPaintingFrame(contestWinnerId, isForArtist);
}
diff --git a/src/contest_util.c b/src/contest_util.c
index 700e44606..c490a2f0e 100644
--- a/src/contest_util.c
+++ b/src/contest_util.c
@@ -606,10 +606,10 @@ static void Task_ShowContestResults(u8 taskId)
}
TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
- sub_80DEDA8(gSpecialVar_ContestRank);
- sub_80DEDA8(0xFE);
- gUnknown_02039F5C = TRUE;
- gUnknown_02039F5D = sub_80DEFA8(0xFE, 0);
+ SaveContestWinner(gSpecialVar_ContestRank); // Save for lobby painting
+ SaveContestWinner(CONTEST_SAVE_FOR_ARTIST);
+ gCurContestWinnerIsForArtist = TRUE;
+ gCurContestWinnerSaveIdx = GetContestWinnerSaveIdx(CONTEST_SAVE_FOR_ARTIST, FALSE);
var = VarGet(VAR_CONTEST_HALL_STATE);
VarSet(VAR_CONTEST_HALL_STATE, 0);
SetContinueGameWarpStatusToDynamicWarp();
@@ -656,10 +656,10 @@ static void Task_ShowContestResults(u8 taskId)
if (gContestFinalStandings[gContestPlayerMonIndex] == 0)
IncrementGameStat(GAME_STAT_WON_CONTEST);
- sub_80DEDA8(gSpecialVar_ContestRank);
- sub_80DEDA8(0xFE);
- gUnknown_02039F5C = TRUE;
- gUnknown_02039F5D = sub_80DEFA8(0xFE, 0);
+ SaveContestWinner(gSpecialVar_ContestRank); // Save for lobby painting
+ SaveContestWinner(CONTEST_SAVE_FOR_ARTIST);
+ gCurContestWinnerIsForArtist = TRUE;
+ gCurContestWinnerSaveIdx = GetContestWinnerSaveIdx(CONTEST_SAVE_FOR_ARTIST, FALSE);
TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
gTasks[taskId].func = Task_AnnouncePreliminaryResults;
}
@@ -2349,7 +2349,7 @@ void DoesContestCategoryHaveWinner(void)
void SaveMuseumContestPainting(void)
{
- sub_80DEDA8(0xFF);
+ SaveContestWinner(CONTEST_SAVE_FOR_MUSEUM);
}
void ShouldReadyContestArtist(void)
@@ -2449,15 +2449,15 @@ void sub_80F8970(void)
gSpecialVar_0x8006 = r7 + 4;
}
-static void ExitContestWinnerPainting(void)
+static void ExitContestPainting(void)
{
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
-void ShowContestWinnerPainting(void)
+void ShowContestPainting(void)
{
SetMainCallback2(CB2_ContestPainting);
- gMain.savedCallback = ExitContestWinnerPainting;
+ gMain.savedCallback = ExitContestPainting;
}
void SetLinkContestPlayerGfx(void)
diff --git a/src/data/contest_opponents.h b/src/data/contest_opponents.h
index 127457bbe..a3d19c36c 100644
--- a/src/data/contest_opponents.h
+++ b/src/data/contest_opponents.h
@@ -138,7 +138,7 @@
const struct ContestWinner gDefaultContestWinners[] =
{
- {
+ [CONTEST_WINNER_HALL_1 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_ELECTRIKE,
@@ -147,7 +147,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("EZRA"),
.contestRank = CONTEST_RANK_NORMAL
},
- {
+ [CONTEST_WINNER_HALL_2 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_TROPIUS,
@@ -156,7 +156,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("ALLAN"),
.contestRank = CONTEST_RANK_HYPER
},
- {
+ [CONTEST_WINNER_HALL_3 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_XATU,
@@ -165,7 +165,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("JULIET"),
.contestRank = CONTEST_RANK_NORMAL
},
- {
+ [CONTEST_WINNER_HALL_4 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_PLUSLE,
@@ -174,7 +174,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("BAILY"),
.contestRank = CONTEST_RANK_MASTER
},
- {
+ [CONTEST_WINNER_HALL_5 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_SHUPPET,
@@ -183,7 +183,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("MELANY"),
.contestRank = CONTEST_RANK_SUPER
},
- {
+ [CONTEST_WINNER_HALL_6 - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_ZANGOOSE,
@@ -192,7 +192,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("HANA"),
.contestRank = CONTEST_RANK_HYPER
},
- {
+ [CONTEST_WINNER_HALL_UNUSED - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_LOUDRED,
@@ -201,7 +201,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("BRYANT"),
.contestRank = CONTEST_RANK_HYPER
},
- {
+ [CONTEST_WINNER_MUSEUM_UNUSED - 1] = {
.personality = 0,
.trainerId = 0xFFFF,
.species = SPECIES_DELCATTY,
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 7dc02b6a8..0ee20d1c6 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1466,15 +1466,15 @@ bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
return TRUE;
}
-bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
+bool8 ScrCmd_showcontestpainting(struct ScriptContext *ctx)
{
u8 contestWinnerId = ScriptReadByte(ctx);
- // Don't save artist's painting yet
+ // Artist's painting is temporary and already has its data loaded
if (contestWinnerId != CONTEST_WINNER_ARTIST)
SetContestWinnerForPainting(contestWinnerId);
- ShowContestWinnerPainting();
+ ShowContestPainting();
ScriptContext1_Stop();
return TRUE;
}