Clean up contest_painting

This commit is contained in:
GriffinR 2021-04-21 20:04:12 -04:00
parent a2a9f22612
commit dbe24f0baa
27 changed files with 226 additions and 198 deletions

View File

@ -918,10 +918,10 @@
.byte 0x76 .byte 0x76
.endm .endm
@ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.) @ Draws an image of the winner of the contest. winnerId is any CONTEST_WINNER_* constant.
.macro showcontestwinner a:req .macro showcontestpainting winnerId:req
.byte 0x77 .byte 0x77
.byte \a .byte \winnerId
.endm .endm
@ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille @ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille

View File

@ -49,7 +49,7 @@ LilycoveCity_ContestLobby_EventScript_ContestArtist:: @ 821A264
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_ARTIST showcontestpainting CONTEST_WINNER_ARTIST
lockall lockall
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES compare VAR_RESULT, YES
@ -223,7 +223,7 @@ LilycoveCity_ContestLobby_EventScript_LinkContestArtist:: @ 821A436
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_ARTIST showcontestpainting CONTEST_WINNER_ARTIST
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES compare VAR_RESULT, YES
goto_if_eq LilycoveCity_ContestLobby_EventScript_TakePaintingToMuseumLink goto_if_eq LilycoveCity_ContestLobby_EventScript_TakePaintingToMuseumLink
@ -511,42 +511,42 @@ LilycoveCity_ContestLobby_EventScript_NinjaBoy:: @ 821A735
LilycoveCity_ContestLobby_EventScript_ContestWinner1:: @ 821A73E LilycoveCity_ContestLobby_EventScript_ContestWinner1:: @ 821A73E
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_1 showcontestpainting CONTEST_WINNER_HALL_1
releaseall releaseall
end end
LilycoveCity_ContestLobby_EventScript_ContestWinner2:: @ 821A745 LilycoveCity_ContestLobby_EventScript_ContestWinner2:: @ 821A745
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_2 showcontestpainting CONTEST_WINNER_HALL_2
releaseall releaseall
end end
LilycoveCity_ContestLobby_EventScript_ContestWinner3:: @ 821A74C LilycoveCity_ContestLobby_EventScript_ContestWinner3:: @ 821A74C
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_3 showcontestpainting CONTEST_WINNER_HALL_3
releaseall releaseall
end end
LilycoveCity_ContestLobby_EventScript_ContestWinner4:: @ 821A753 LilycoveCity_ContestLobby_EventScript_ContestWinner4:: @ 821A753
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_4 showcontestpainting CONTEST_WINNER_HALL_4
releaseall releaseall
end end
LilycoveCity_ContestLobby_EventScript_ContestWinner5:: @ 821A75A LilycoveCity_ContestLobby_EventScript_ContestWinner5:: @ 821A75A
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_5 showcontestpainting CONTEST_WINNER_HALL_5
releaseall releaseall
end end
LilycoveCity_ContestLobby_EventScript_ContestWinner6:: @ 821A761 LilycoveCity_ContestLobby_EventScript_ContestWinner6:: @ 821A761
lockall lockall
fadescreen FADE_TO_BLACK fadescreen FADE_TO_BLACK
showcontestwinner CONTEST_WINNER_HALL_6 showcontestpainting CONTEST_WINNER_HALL_6
releaseall releaseall
end end

View File

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

View File

@ -119,7 +119,7 @@ gScriptCmdTable:: @ 81DB67C
.4byte ScrCmd_drawboxtext @ 0x74 .4byte ScrCmd_drawboxtext @ 0x74
.4byte ScrCmd_showmonpic @ 0x75 .4byte ScrCmd_showmonpic @ 0x75
.4byte ScrCmd_hidemonpic @ 0x76 .4byte ScrCmd_hidemonpic @ 0x76
.4byte ScrCmd_showcontestwinner @ 0x77 .4byte ScrCmd_showcontestpainting @ 0x77
.4byte ScrCmd_braillemessage @ 0x78 .4byte ScrCmd_braillemessage @ 0x78
.4byte ScrCmd_givemon @ 0x79 .4byte ScrCmd_givemon @ 0x79
.4byte ScrCmd_giveegg @ 0x7a .4byte ScrCmd_giveegg @ 0x7a

View File

@ -149,7 +149,7 @@ gSpecials:: @ 81DBA64
def_special SaveMuseumContestPainting def_special SaveMuseumContestPainting
def_special DoesContestCategoryHaveWinner def_special DoesContestCategoryHaveWinner
def_special CountPlayerContestPaintings def_special CountPlayerContestPaintings
def_special ShowContestWinnerPainting def_special ShowContestPainting @ Unused, redundant with showcontestpainting command
def_special MauvilleGymSetDefaultBarriers def_special MauvilleGymSetDefaultBarriers
def_special MauvilleGymPressSwitch def_special MauvilleGymPressSwitch
def_special ShowFieldMessageStringVar4 def_special ShowFieldMessageStringVar4

View File

@ -1,4 +1,4 @@
gContestPaintingCaption:: @ 827EA0C gContestHallPaintingCaption:: @ 827EA0C
.string "{STR_VAR_1}\n" .string "{STR_VAR_1}\n"
.string "{STR_VAR_2}'s {STR_VAR_3}$" .string "{STR_VAR_2}'s {STR_VAR_3}$"

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 666 B

After

Width:  |  Height:  |  Size: 666 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -476,7 +476,7 @@ $(RAYQUAZAGFXDIR)/scene_4/streaks.4bpp: %.4bpp: %.png
$(RAYQUAZAGFXDIR)/scene_4/rayquaza.4bpp: %.4bpp: %.png $(RAYQUAZAGFXDIR)/scene_4/rayquaza.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 155 $(GFX) $< $@ -num_tiles 155
graphics/picture_frame/frame5.4bpp: %.4bpp: %.png graphics/picture_frame/lobby.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 86 $(GFX) $< $@ -num_tiles 86
$(ROULETTEGFXDIR)/roulette_tilt.4bpp: $(ROULETTEGFXDIR)/shroomish.4bpp \ $(ROULETTEGFXDIR)/roulette_tilt.4bpp: $(ROULETTEGFXDIR)/shroomish.4bpp \

View File

@ -22,7 +22,9 @@
#define CONTEST_TYPE_NPC_MASTER (CONTEST_RANK_MASTER + 1) #define CONTEST_TYPE_NPC_MASTER (CONTEST_RANK_MASTER + 1)
#define CONTEST_TYPE_LINK (CONTEST_RANK_LINK + 1) #define CONTEST_TYPE_LINK (CONTEST_RANK_LINK + 1)
#define CONTEST_WINNER_ARTIST 0 // Winner shown by the artist, painting not necessarily saved // IDs below - 1 are indexes into gSaveBlock1Ptr->contestWinners[]
// CONTEST_WINNER_ARTIST is for the winner of the most recent contest, and is not saved.
#define CONTEST_WINNER_ARTIST 0
#define CONTEST_WINNER_HALL_1 1 #define CONTEST_WINNER_HALL_1 1
#define CONTEST_WINNER_HALL_2 2 #define CONTEST_WINNER_HALL_2 2
#define CONTEST_WINNER_HALL_3 3 #define CONTEST_WINNER_HALL_3 3
@ -30,8 +32,8 @@
#define CONTEST_WINNER_HALL_5 5 #define CONTEST_WINNER_HALL_5 5
#define CONTEST_WINNER_HALL_6 6 #define CONTEST_WINNER_HALL_6 6
#define NUM_CONTEST_HALL_WINNERS 6 #define NUM_CONTEST_HALL_WINNERS 6
#define CONTEST_WINNER_7 7 #define CONTEST_WINNER_HALL_UNUSED 7
#define CONTEST_WINNER_8 8 #define CONTEST_WINNER_MUSEUM_UNUSED 8
#define CONTEST_WINNER_MUSEUM_COOL 9 #define CONTEST_WINNER_MUSEUM_COOL 9
#define CONTEST_WINNER_MUSEUM_BEAUTY 10 #define CONTEST_WINNER_MUSEUM_BEAUTY 10
#define CONTEST_WINNER_MUSEUM_CUTE 11 #define CONTEST_WINNER_MUSEUM_CUTE 11
@ -39,6 +41,14 @@
#define CONTEST_WINNER_MUSEUM_TOUGH 13 #define CONTEST_WINNER_MUSEUM_TOUGH 13
// NUM_CONTEST_WINNERS in constants/global.h // NUM_CONTEST_WINNERS in constants/global.h
#define MUSEUM_CONTEST_WINNERS_START CONTEST_WINNER_MUSEUM_UNUSED
// The number of possible captions for a Contest painting, per category
#define NUM_PAINTING_CAPTIONS 3
#define CONTEST_SAVE_FOR_MUSEUM ((u8)-1)
#define CONTEST_SAVE_FOR_ARTIST ((u8)-2)
#define CANT_ENTER_CONTEST 0 #define CANT_ENTER_CONTEST 0
#define CAN_ENTER_CONTEST_EQUAL_RANK 1 #define CAN_ENTER_CONTEST_EQUAL_RANK 1
#define CAN_ENTER_CONTEST_HIGH_RANK 2 #define CAN_ENTER_CONTEST_HIGH_RANK 2

View File

@ -326,8 +326,8 @@ extern u8 gHighestRibbonRank;
extern struct ContestResources *gContestResources; extern struct ContestResources *gContestResources;
extern u8 sContestBgCopyFlags; extern u8 sContestBgCopyFlags;
extern struct ContestWinner gCurContestWinner; extern struct ContestWinner gCurContestWinner;
extern u8 gUnknown_02039F5C; extern u8 gCurContestWinnerIsForArtist;
extern u8 gUnknown_02039F5D; extern u8 gCurContestWinnerSaveIdx;
extern u32 gContestRngValue; extern u32 gContestRngValue;
// contest.c // contest.c
@ -351,8 +351,8 @@ s8 Contest_GetMoveExcitement(u16 move);
bool8 IsContestantAllowedToCombo(u8 contestant); bool8 IsContestantAllowedToCombo(u8 contestant);
void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId); void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId);
void ResetContestLinkResults(void); void ResetContestLinkResults(void);
bool8 sub_80DEDA8(u8 a); bool8 SaveContestWinner(u8 rank);
u8 sub_80DEFA8(u8 a, u8 b); u8 GetContestWinnerSaveIdx(u8 rank, bool8 shift);
void ClearContestWinnerPicsInContestHall(void); void ClearContestWinnerPicsInContestHall(void);
void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language); void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language);

View File

@ -7,7 +7,7 @@ void StartContest(void);
void BufferContestantMonSpecies(void); void BufferContestantMonSpecies(void);
void ShowContestResults(void); void ShowContestResults(void);
void ContestLinkTransfer(u8); void ContestLinkTransfer(u8);
void ShowContestWinnerPainting(void); void ShowContestPainting(void);
u16 GetContestRand(void); u16 GetContestRand(void);
u8 CountPlayerContestPaintings(void); u8 CountPlayerContestPaintings(void);

View File

@ -350,8 +350,8 @@ EWRAM_DATA u8 gHighestRibbonRank = 0;
EWRAM_DATA struct ContestResources *gContestResources = NULL; EWRAM_DATA struct ContestResources *gContestResources = NULL;
EWRAM_DATA u8 sContestBgCopyFlags = 0; EWRAM_DATA u8 sContestBgCopyFlags = 0;
EWRAM_DATA struct ContestWinner gCurContestWinner = {0}; EWRAM_DATA struct ContestWinner gCurContestWinner = {0};
EWRAM_DATA bool8 gUnknown_02039F5C = 0; EWRAM_DATA bool8 gCurContestWinnerIsForArtist = 0;
EWRAM_DATA u8 gUnknown_02039F5D = 0; EWRAM_DATA u8 gCurContestWinnerSaveIdx = 0;
// IWRAM common vars. // IWRAM common vars.
u32 gContestRngValue; u32 gContestRngValue;
@ -5516,40 +5516,47 @@ void ResetContestLinkResults(void)
gSaveBlock2Ptr->contestLinkResults[i][j] = 0; gSaveBlock2Ptr->contestLinkResults[i][j] = 0;
} }
bool8 sub_80DEDA8(u8 rank) bool8 SaveContestWinner(u8 rank)
{ {
s32 i; 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++) for (i = 0; i < CONTESTANT_COUNT - 1; i++)
{
if (gContestFinalStandings[i] == 0) if (gContestFinalStandings[i] == 0)
break; 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; return FALSE;
// Adjust the random painting caption depending on the category
switch (gSpecialVar_ContestCategory) switch (gSpecialVar_ContestCategory)
{ {
case CONTEST_CATEGORY_COOL: case CONTEST_CATEGORY_COOL:
r7 += 0; captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL;
break; break;
case CONTEST_CATEGORY_BEAUTY: case CONTEST_CATEGORY_BEAUTY:
r7 += 3; captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY;
break; break;
case CONTEST_CATEGORY_CUTE: case CONTEST_CATEGORY_CUTE:
r7 += 6; captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE;
break; break;
case CONTEST_CATEGORY_SMART: case CONTEST_CATEGORY_SMART:
r7 += 9; captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART;
break; break;
case CONTEST_CATEGORY_TOUGH: case CONTEST_CATEGORY_TOUGH:
r7 += 12; captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH;
break; 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].personality = gContestMons[i].personality;
gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species; gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species;
gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId; gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId;
@ -5560,24 +5567,29 @@ bool8 sub_80DEDA8(u8 rank)
else else
gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank; gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank;
if (rank != 0xFF) if (rank != CONTEST_SAVE_FOR_MUSEUM)
gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory; gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory;
else else
gSaveBlock1Ptr->contestWinners[id].contestCategory = r7; gSaveBlock1Ptr->contestWinners[id].contestCategory = captionId;
} }
else else
{ {
// Set the most recent winner so the artist can show the player their painting
gCurContestWinner.personality = gContestMons[i].personality; gCurContestWinner.personality = gContestMons[i].personality;
gCurContestWinner.trainerId = gContestMons[i].otId; gCurContestWinner.trainerId = gContestMons[i].otId;
gCurContestWinner.species = gContestMons[i].species; gCurContestWinner.species = gContestMons[i].species;
StringCopy(gCurContestWinner.monName, gContestMons[i].nickname); StringCopy(gCurContestWinner.monName, gContestMons[i].nickname);
StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName); StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName);
gCurContestWinner.contestCategory = r7; gCurContestWinner.contestCategory = captionId;
} }
return TRUE; 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; s32 i;
@ -5587,13 +5599,15 @@ u8 sub_80DEFA8(u8 rank, u8 b)
case CONTEST_RANK_SUPER: case CONTEST_RANK_SUPER:
case CONTEST_RANK_HYPER: case CONTEST_RANK_HYPER:
case CONTEST_RANK_MASTER: 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)); memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner));
} }
return 0; return CONTEST_WINNER_HALL_1 - 1;
default: default:
// case CONTEST_SAVE_FOR_MUSEUM:
// case CONTEST_SAVE_FOR_ARTIST:
switch (gSpecialVar_ContestCategory) switch (gSpecialVar_ContestCategory)
{ {
case CONTEST_CATEGORY_COOL: case CONTEST_CATEGORY_COOL:
@ -5615,7 +5629,7 @@ void ClearContestWinnerPicsInContestHall(void)
{ {
s32 i; s32 i;
for (i = 0; i < 8; i++) for (i = 0; i < MUSEUM_CONTEST_WINNERS_START; i++)
gSaveBlock1Ptr->contestWinners[i] = gDefaultContestWinners[i]; gSaveBlock1Ptr->contestWinners[i] = gDefaultContestWinners[i];
} }

View File

@ -21,18 +21,16 @@
#include "window.h" #include "window.h"
#include "constants/rgb.h" #include "constants/rgb.h"
// IWRAM common
u16 (*gContestMonPixels)[][32]; u16 (*gContestMonPixels)[][32];
struct ImageProcessingContext gImageProcessingContext; struct ImageProcessingContext gImageProcessingContext;
struct ContestWinner *gContestPaintingWinner; struct ContestWinner *gContestPaintingWinner;
u16 *gContestPaintingMonPalette; u16 *gContestPaintingMonPalette;
// IWRAM bss static u8 sHoldState;
static u8 gContestPaintingState; static u16 sMosaicVal;
static u16 gContestPaintingMosaicVal; static u16 sFadeCounter;
static u16 gContestPaintingFadeCounter; static bool8 sVarsInitialized;
static bool8 gUnknown_030011F6; static u8 sWindowId;
static u8 gContestPaintingWindowId;
static void ShowContestPainting(void); static void ShowContestPainting(void);
static void HoldContestPainting(void); static void HoldContestPainting(void);
@ -44,7 +42,7 @@ static void PrintContestPaintingCaption(u8, u8);
static void VBlankCB_ContestPainting(void); static void VBlankCB_ContestPainting(void);
static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]); 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 gContestCoolness[];
extern const u8 gContestBeauty[]; extern const u8 gContestBeauty[];
extern const u8 gContestCuteness[]; extern const u8 gContestCuteness[];
@ -71,39 +69,39 @@ extern const u8 gContestPaintingTough1[];
extern const u8 gContestPaintingTough2[]; extern const u8 gContestPaintingTough2[];
extern const u8 gContestPaintingTough3[]; extern const u8 gContestPaintingTough3[];
const u16 gPictureFramePalettes[] = INCBIN_U16("graphics/picture_frame/bg.gbapal"); static const u16 sPictureFramePalettes[] = INCBIN_U16("graphics/picture_frame/bg.gbapal");
const u8 gPictureFrameTiles_0[] = INCBIN_U8("graphics/picture_frame/frame0.4bpp.rl"); static const u8 sPictureFrameTiles_Cool[] = INCBIN_U8("graphics/picture_frame/cool.4bpp.rl");
const u8 gPictureFrameTiles_1[] = INCBIN_U8("graphics/picture_frame/frame1.4bpp.rl"); static const u8 sPictureFrameTiles_Beauty[] = INCBIN_U8("graphics/picture_frame/beauty.4bpp.rl");
const u8 gPictureFrameTiles_2[] = INCBIN_U8("graphics/picture_frame/frame2.4bpp.rl"); static const u8 sPictureFrameTiles_Cute[] = INCBIN_U8("graphics/picture_frame/cute.4bpp.rl");
const u8 gPictureFrameTiles_3[] = INCBIN_U8("graphics/picture_frame/frame3.4bpp.rl"); static const u8 sPictureFrameTiles_Smart[] = INCBIN_U8("graphics/picture_frame/smart.4bpp.rl");
const u8 gPictureFrameTiles_4[] = INCBIN_U8("graphics/picture_frame/frame4.4bpp.rl"); static const u8 sPictureFrameTiles_Tough[] = INCBIN_U8("graphics/picture_frame/tough.4bpp.rl");
const u8 gPictureFrameTiles_5[] = INCBIN_U8("graphics/picture_frame/frame5.4bpp.rl"); static const u8 sPictureFrameTiles_HallLobby[] = INCBIN_U8("graphics/picture_frame/lobby.4bpp.rl");
const u8 gPictureFrameTilemap_0[] = INCBIN_U8("graphics/picture_frame/frame0_map.bin.rl"); static const u8 sPictureFrameTilemap_Cool[] = INCBIN_U8("graphics/picture_frame/cool_map.bin.rl");
const u8 gPictureFrameTilemap_1[] = INCBIN_U8("graphics/picture_frame/frame1_map.bin.rl"); static const u8 sPictureFrameTilemap_Beauty[] = INCBIN_U8("graphics/picture_frame/beauty_map.bin.rl");
const u8 gPictureFrameTilemap_2[] = INCBIN_U8("graphics/picture_frame/frame2_map.bin.rl"); static const u8 sPictureFrameTilemap_Cute[] = INCBIN_U8("graphics/picture_frame/cute_map.bin.rl");
const u8 gPictureFrameTilemap_3[] = INCBIN_U8("graphics/picture_frame/frame3_map.bin.rl"); static const u8 sPictureFrameTilemap_Smart[] = INCBIN_U8("graphics/picture_frame/smart_map.bin.rl");
const u8 gPictureFrameTilemap_4[] = INCBIN_U8("graphics/picture_frame/frame4_map.bin.rl"); static const u8 sPictureFrameTilemap_Tough[] = INCBIN_U8("graphics/picture_frame/tough_map.bin.rl");
const u8 gPictureFrameTilemap_5[] = INCBIN_U8("graphics/picture_frame/frame5_map.bin.rl"); static const u8 sPictureFrameTilemap_HallLobby[] = INCBIN_U8("graphics/picture_frame/lobby_map.bin.rl");
static const u8 *const sContestCategoryNames_Unused[] = static const u8 *const sContestCategoryNames_Unused[] =
{ {
gContestCoolness, [CONTEST_CATEGORY_COOL] = gContestCoolness,
gContestBeauty, [CONTEST_CATEGORY_BEAUTY] = gContestBeauty,
gContestCuteness, [CONTEST_CATEGORY_CUTE] = gContestCuteness,
gContestSmartness, [CONTEST_CATEGORY_SMART] = gContestSmartness,
gContestToughness, [CONTEST_CATEGORY_TOUGH] = gContestToughness,
}; };
static const u8 *const sContestRankNames[] = static const u8 *const sContestRankNames[] =
{ {
gContestRankNormal, [CONTEST_RANK_NORMAL] = gContestRankNormal,
gContestRankSuper, [CONTEST_RANK_SUPER] = gContestRankSuper,
gContestRankHyper, [CONTEST_RANK_HYPER] = gContestRankHyper,
gContestRankMaster, [CONTEST_RANK_MASTER] = gContestRankMaster,
gContestLink, [CONTEST_RANK_LINK] = gContestLink,
}; };
static const struct BgTemplate sContestPaintingBgTemplates[] = static const struct BgTemplate sBgTemplates[] =
{ {
{ {
.bg = 1, .bg = 1,
@ -116,7 +114,7 @@ static const struct BgTemplate sContestPaintingBgTemplates[] =
}, },
}; };
static const struct WindowTemplate sContestPaintingWindowTemplate = static const struct WindowTemplate sWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 2, .tilemapLeft = 2,
@ -127,23 +125,23 @@ static const struct WindowTemplate sContestPaintingWindowTemplate =
.baseBlock = 1, .baseBlock = 1,
}; };
static const u8 *const sContestPaintingDescriptionPointers[] = static const u8 *const sMuseumCaptions[NUM_PAINTING_CAPTIONS * CONTEST_CATEGORIES_COUNT] =
{ {
gContestPaintingCool1, [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool1,
gContestPaintingCool2, [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool2,
gContestPaintingCool3, [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL] = gContestPaintingCool3,
gContestPaintingBeauty1, [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty1,
gContestPaintingBeauty2, [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty2,
gContestPaintingBeauty3, [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY] = gContestPaintingBeauty3,
gContestPaintingCute1, [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute1,
gContestPaintingCute2, [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute2,
gContestPaintingCute3, [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE] = gContestPaintingCute3,
gContestPaintingSmart1, [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart1,
gContestPaintingSmart2, [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart2,
gContestPaintingSmart3, [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART] = gContestPaintingSmart3,
gContestPaintingTough1, [0 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough1,
gContestPaintingTough2, [1 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough2,
gContestPaintingTough3, [2 + NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH] = gContestPaintingTough3,
}; };
static const struct OamData sContestPaintingMonOamData = static const struct OamData sContestPaintingMonOamData =
@ -161,15 +159,15 @@ static const struct OamData sContestPaintingMonOamData =
.paletteNum = 0, .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) void SetContestWinnerForPainting(int contestWinnerId)
{ {
u8 *ptr1 = &gUnknown_02039F5D; u8 *saveIdx = &gCurContestWinnerSaveIdx;
u8 *ptr2 = &gUnknown_02039F5C; u8 *isForArtist = &gCurContestWinnerIsForArtist;
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1]; gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
*ptr1 = contestWinnerId - 1; *saveIdx = contestWinnerId - 1;
*ptr2 = FALSE; *isForArtist = FALSE;
} }
void CB2_ContestPainting(void) void CB2_ContestPainting(void)
@ -189,7 +187,7 @@ static void CB2_QuitContestPainting(void)
SetMainCallback2(gMain.savedCallback); SetMainCallback2(gMain.savedCallback);
FREE_AND_SET_NULL(gContestPaintingMonPalette); FREE_AND_SET_NULL(gContestPaintingMonPalette);
FREE_AND_SET_NULL(gContestMonPixels); FREE_AND_SET_NULL(gContestMonPixels);
RemoveWindow(gContestPaintingWindowId); RemoveWindow(sWindowId);
Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(1));
FreeMonSpritesGfx(); FreeMonSpritesGfx();
} }
@ -203,13 +201,13 @@ static void ShowContestPainting(void)
SetVBlankCallback(NULL); SetVBlankCallback(NULL);
AllocateMonSpritesGfx(); AllocateMonSpritesGfx();
gContestPaintingWinner = &gCurContestWinner; gContestPaintingWinner = &gCurContestWinner;
InitContestPaintingVars(1); InitContestPaintingVars(TRUE);
InitContestPaintingBg(); InitContestPaintingBg();
gMain.state++; gMain.state++;
break; break;
case 1: case 1:
ResetPaletteFade(); ResetPaletteFade();
DmaFillLarge32(3, 0, (void *)BG_VRAM, 0x18000, 0x1000); DmaFillLarge32(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
ResetSpriteData(); ResetSpriteData();
gMain.state++; gMain.state++;
break; break;
@ -220,16 +218,16 @@ static void ShowContestPainting(void)
gMain.state++; gMain.state++;
break; break;
case 3: case 3:
CreateContestPaintingPicture(gUnknown_02039F5D, gUnknown_02039F5C); CreateContestPaintingPicture(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
gMain.state++; gMain.state++;
break; break;
case 4: case 4:
PrintContestPaintingCaption(gUnknown_02039F5D, gUnknown_02039F5C); PrintContestPaintingCaption(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
LoadPalette(gUnknown_085B0838, 0, 1 * 2); LoadPalette(sBg_Palette, 0, 1 * 2);
DmaClear32(3, PLTT, PLTT_SIZE); DmaClear32(3, PLTT, PLTT_SIZE);
BeginFastPaletteFade(2); BeginFastPaletteFade(2);
SetVBlankCallback(VBlankCB_ContestPainting); 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); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON);
SetMainCallback2(CB2_HoldContestPainting); SetMainCallback2(CB2_HoldContestPainting);
break; break;
@ -238,29 +236,29 @@ static void ShowContestPainting(void)
static void HoldContestPainting(void) static void HoldContestPainting(void)
{ {
switch (gContestPaintingState) switch (sHoldState)
{ {
case 0: case 0:
if (!gPaletteFade.active) if (!gPaletteFade.active)
gContestPaintingState = 1; sHoldState = 1;
if (gUnknown_030011F6 && gContestPaintingFadeCounter) if (sVarsInitialized && sFadeCounter)
gContestPaintingFadeCounter--; sFadeCounter--;
break; break;
case 1: case 1:
if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
{ {
gContestPaintingState++; sHoldState++;
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0)); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0));
} }
if (gUnknown_030011F6) if (sVarsInitialized)
gContestPaintingFadeCounter = 0; sFadeCounter = 0;
break; break;
case 2: case 2:
if (!gPaletteFade.active) if (!gPaletteFade.active)
SetMainCallback2(CB2_QuitContestPainting); SetMainCallback2(CB2_QuitContestPainting);
if (gUnknown_030011F6 && gContestPaintingFadeCounter < 30) if (sVarsInitialized && sFadeCounter < 30)
gContestPaintingFadeCounter++; sFadeCounter++;
break; break;
} }
} }
@ -268,45 +266,47 @@ static void HoldContestPainting(void)
static void InitContestPaintingWindow(void) static void InitContestPaintingWindow(void)
{ {
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sContestPaintingBgTemplates, ARRAY_COUNT(sContestPaintingBgTemplates)); InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
ChangeBgX(1, 0, 0); ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0); ChangeBgY(1, 0, 0);
SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE));
gContestPaintingWindowId = AddWindow(&sContestPaintingWindowTemplate); sWindowId = AddWindow(&sWindowTemplate);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
FillWindowPixelBuffer(gContestPaintingWindowId, PIXEL_FILL(0)); FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0));
PutWindowTilemap(gContestPaintingWindowId); PutWindowTilemap(sWindowId);
CopyWindowToVram(gContestPaintingWindowId, 3); CopyWindowToVram(sWindowId, 3);
ShowBg(1); ShowBg(1);
} }
static void PrintContestPaintingCaption(u8 contestType, bool8 arg1) static void PrintContestPaintingCaption(u8 contestType, bool8 noCaption)
{ {
int x; int x;
u8 category; u8 category;
if (arg1 == TRUE) if (noCaption == TRUE)
return; return;
category = gContestPaintingWinner->contestCategory; category = gContestPaintingWinner->contestCategory;
if (contestType < 8) if (contestType < MUSEUM_CONTEST_WINNERS_START)
{ {
// Contest Hall caption
BufferContestName(gStringVar1, category); BufferContestName(gStringVar1, category);
StringAppend(gStringVar1, gText_Space); StringAppend(gStringVar1, gText_Space);
StringAppend(gStringVar1, sContestRankNames[gContestPaintingWinner->contestRank]); StringAppend(gStringVar1, sContestRankNames[gContestPaintingWinner->contestRank]);
StringCopy(gStringVar2, gContestPaintingWinner->trainerName); StringCopy(gStringVar2, gContestPaintingWinner->trainerName);
sub_81DB5AC(gStringVar2); sub_81DB5AC(gStringVar2);
StringCopy(gStringVar3, gContestPaintingWinner->monName); StringCopy(gStringVar3, gContestPaintingWinner->monName);
StringExpandPlaceholders(gStringVar4, gContestPaintingCaption); StringExpandPlaceholders(gStringVar4, gContestHallPaintingCaption);
} }
else else
{ {
// Museum caption
StringCopy(gStringVar1, gContestPaintingWinner->monName); StringCopy(gStringVar1, gContestPaintingWinner->monName);
StringExpandPlaceholders(gStringVar4, sContestPaintingDescriptionPointers[category]); StringExpandPlaceholders(gStringVar4, sMuseumCaptions[category]);
} }
x = GetStringCenterAlignXOffset(1, gStringVar4, 208); x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
AddTextPrinterParameterized(gContestPaintingWindowId, 1, gStringVar4, x, 1, 0, 0); AddTextPrinterParameterized(sWindowId, 1, gStringVar4, x, 1, 0, 0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
} }
@ -321,33 +321,34 @@ static void InitContestPaintingBg(void)
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
} }
static void InitContestPaintingVars(bool8 arg0) static void InitContestPaintingVars(bool8 reset)
{ {
if (arg0 == FALSE) if (reset == FALSE)
{ {
gUnknown_030011F6 = FALSE; // Never reached
gContestPaintingMosaicVal = 0; sVarsInitialized = FALSE;
gContestPaintingFadeCounter = 0; sMosaicVal = 0;
sFadeCounter = 0;
} }
else else
{ {
gUnknown_030011F6 = TRUE; sVarsInitialized = TRUE;
gContestPaintingMosaicVal = 15; sMosaicVal = 15;
gContestPaintingFadeCounter = 30; sFadeCounter = 30;
} }
} }
static void UpdateContestPaintingMosaicEffect(void) static void UpdateContestPaintingMosaicEffect(void)
{ {
if (!gUnknown_030011F6) if (!sVarsInitialized)
{ {
SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuReg(REG_OFFSET_MOSAIC, 0);
} }
else else
{ {
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256);
gContestPaintingMosaicVal = gContestPaintingFadeCounter / 2; sMosaicVal = sFadeCounter / 2;
SetGpuReg(REG_OFFSET_MOSAIC, (gContestPaintingMosaicVal << 12) | (gContestPaintingMosaicVal << 8) | (gContestPaintingMosaicVal << 4) | (gContestPaintingMosaicVal << 0)); 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)]) #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; u8 x, y;
LoadPalette(gPictureFramePalettes, 0, 0x100); LoadPalette(sPictureFramePalettes, 0, 0x100);
if (arg1 == TRUE) if (isForArtist == TRUE)
{ {
switch (gContestPaintingWinner->contestCategory / 3) // Load Artist's frame
switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
{ {
case CONTEST_CATEGORY_COOL: case CONTEST_CATEGORY_COOL:
RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
RLUnCompWram(gPictureFrameTilemap_0, gContestMonPixels); RLUnCompWram(sPictureFrameTilemap_Cool, gContestMonPixels);
break; break;
case CONTEST_CATEGORY_BEAUTY: case CONTEST_CATEGORY_BEAUTY:
RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
RLUnCompWram(gPictureFrameTilemap_1, gContestMonPixels); RLUnCompWram(sPictureFrameTilemap_Beauty, gContestMonPixels);
break; break;
case CONTEST_CATEGORY_CUTE: case CONTEST_CATEGORY_CUTE:
RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
RLUnCompWram(gPictureFrameTilemap_2, gContestMonPixels); RLUnCompWram(sPictureFrameTilemap_Cute, gContestMonPixels);
break; break;
case CONTEST_CATEGORY_SMART: case CONTEST_CATEGORY_SMART:
RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
RLUnCompWram(gPictureFrameTilemap_3, gContestMonPixels); RLUnCompWram(sPictureFrameTilemap_Smart, gContestMonPixels);
break; break;
case CONTEST_CATEGORY_TOUGH: case CONTEST_CATEGORY_TOUGH:
RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
RLUnCompWram(gPictureFrameTilemap_4, gContestMonPixels); RLUnCompWram(sPictureFrameTilemap_Tough, gContestMonPixels);
break; break;
} }
@ -463,34 +465,36 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
for (x = 0; x < 16; x++) for (x = 0; x < 16; x++)
VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7]; 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); // Load Contest Hall lobby frame
RLUnCompVram(gPictureFrameTilemap_5, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTiles_HallLobby, (void *)VRAM);
RLUnCompVram(sPictureFrameTilemap_HallLobby, (void *)(BG_SCREEN_ADDR(12)));
} }
else else
{ {
switch (gContestPaintingWinner->contestCategory / 3) // Load Museum frame
switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
{ {
case CONTEST_CATEGORY_COOL: case CONTEST_CATEGORY_COOL:
RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
RLUnCompVram(gPictureFrameTilemap_0, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTilemap_Cool, (void *)(BG_SCREEN_ADDR(12)));
break; break;
case CONTEST_CATEGORY_BEAUTY: case CONTEST_CATEGORY_BEAUTY:
RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
RLUnCompVram(gPictureFrameTilemap_1, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTilemap_Beauty, (void *)(BG_SCREEN_ADDR(12)));
break; break;
case CONTEST_CATEGORY_CUTE: case CONTEST_CATEGORY_CUTE:
RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
RLUnCompVram(gPictureFrameTilemap_2, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTilemap_Cute, (void *)(BG_SCREEN_ADDR(12)));
break; break;
case CONTEST_CATEGORY_SMART: case CONTEST_CATEGORY_SMART:
RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
RLUnCompVram(gPictureFrameTilemap_3, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTilemap_Smart, (void *)(BG_SCREEN_ADDR(12)));
break; break;
case CONTEST_CATEGORY_TOUGH: case CONTEST_CATEGORY_TOUGH:
RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
RLUnCompVram(gPictureFrameTilemap_4, (void *)(BG_SCREEN_ADDR(12))); RLUnCompVram(sPictureFrameTilemap_Tough, (void *)(BG_SCREEN_ADDR(12)));
break; break;
} }
} }
@ -519,10 +523,10 @@ static u8 GetImageEffectForContestWinner(u8 contestWinnerId)
{ {
u8 contestCategory; u8 contestCategory;
if (contestWinnerId < 8) if (contestWinnerId < MUSEUM_CONTEST_WINNERS_START)
contestCategory = gContestPaintingWinner->contestCategory; contestCategory = gContestPaintingWinner->contestCategory;
else else
contestCategory = gContestPaintingWinner->contestCategory / 3; contestCategory = gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS;
switch (contestCategory) switch (contestCategory)
{ {
@ -584,12 +588,12 @@ static void DoContestPaintingImageProcessing(u8 imageEffect)
LoadPalette(gContestPaintingMonPalette, 0x100, 0x200); LoadPalette(gContestPaintingMonPalette, 0x100, 0x200);
} }
static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 arg1) static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 isForArtist)
{ {
AllocPaintingResources(); AllocPaintingResources();
InitContestMonPixels(gContestPaintingWinner->species, 0); InitContestMonPixels(gContestPaintingWinner->species, 0);
DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId)); DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId));
InitPaintingMonOamData(contestWinnerId); InitPaintingMonOamData(contestWinnerId);
LoadContestPaintingFrame(contestWinnerId, arg1); LoadContestPaintingFrame(contestWinnerId, isForArtist);
} }

View File

@ -606,10 +606,10 @@ static void Task_ShowContestResults(u8 taskId)
} }
TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST); TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
sub_80DEDA8(gSpecialVar_ContestRank); SaveContestWinner(gSpecialVar_ContestRank); // Save for lobby painting
sub_80DEDA8(0xFE); SaveContestWinner(CONTEST_SAVE_FOR_ARTIST);
gUnknown_02039F5C = TRUE; gCurContestWinnerIsForArtist = TRUE;
gUnknown_02039F5D = sub_80DEFA8(0xFE, 0); gCurContestWinnerSaveIdx = GetContestWinnerSaveIdx(CONTEST_SAVE_FOR_ARTIST, FALSE);
var = VarGet(VAR_CONTEST_HALL_STATE); var = VarGet(VAR_CONTEST_HALL_STATE);
VarSet(VAR_CONTEST_HALL_STATE, 0); VarSet(VAR_CONTEST_HALL_STATE, 0);
SetContinueGameWarpStatusToDynamicWarp(); SetContinueGameWarpStatusToDynamicWarp();
@ -656,10 +656,10 @@ static void Task_ShowContestResults(u8 taskId)
if (gContestFinalStandings[gContestPlayerMonIndex] == 0) if (gContestFinalStandings[gContestPlayerMonIndex] == 0)
IncrementGameStat(GAME_STAT_WON_CONTEST); IncrementGameStat(GAME_STAT_WON_CONTEST);
sub_80DEDA8(gSpecialVar_ContestRank); SaveContestWinner(gSpecialVar_ContestRank); // Save for lobby painting
sub_80DEDA8(0xFE); SaveContestWinner(CONTEST_SAVE_FOR_ARTIST);
gUnknown_02039F5C = TRUE; gCurContestWinnerIsForArtist = TRUE;
gUnknown_02039F5D = sub_80DEFA8(0xFE, 0); gCurContestWinnerSaveIdx = GetContestWinnerSaveIdx(CONTEST_SAVE_FOR_ARTIST, FALSE);
TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST); TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
gTasks[taskId].func = Task_AnnouncePreliminaryResults; gTasks[taskId].func = Task_AnnouncePreliminaryResults;
} }
@ -2349,7 +2349,7 @@ void DoesContestCategoryHaveWinner(void)
void SaveMuseumContestPainting(void) void SaveMuseumContestPainting(void)
{ {
sub_80DEDA8(0xFF); SaveContestWinner(CONTEST_SAVE_FOR_MUSEUM);
} }
void ShouldReadyContestArtist(void) void ShouldReadyContestArtist(void)
@ -2449,15 +2449,15 @@ void sub_80F8970(void)
gSpecialVar_0x8006 = r7 + 4; gSpecialVar_0x8006 = r7 + 4;
} }
static void ExitContestWinnerPainting(void) static void ExitContestPainting(void)
{ {
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
} }
void ShowContestWinnerPainting(void) void ShowContestPainting(void)
{ {
SetMainCallback2(CB2_ContestPainting); SetMainCallback2(CB2_ContestPainting);
gMain.savedCallback = ExitContestWinnerPainting; gMain.savedCallback = ExitContestPainting;
} }
void SetLinkContestPlayerGfx(void) void SetLinkContestPlayerGfx(void)

View File

@ -138,7 +138,7 @@
const struct ContestWinner gDefaultContestWinners[] = const struct ContestWinner gDefaultContestWinners[] =
{ {
{ [CONTEST_WINNER_HALL_1 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_ELECTRIKE, .species = SPECIES_ELECTRIKE,
@ -147,7 +147,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("EZRA"), .trainerName = _("EZRA"),
.contestRank = CONTEST_RANK_NORMAL .contestRank = CONTEST_RANK_NORMAL
}, },
{ [CONTEST_WINNER_HALL_2 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_TROPIUS, .species = SPECIES_TROPIUS,
@ -156,7 +156,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("ALLAN"), .trainerName = _("ALLAN"),
.contestRank = CONTEST_RANK_HYPER .contestRank = CONTEST_RANK_HYPER
}, },
{ [CONTEST_WINNER_HALL_3 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_XATU, .species = SPECIES_XATU,
@ -165,7 +165,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("JULIET"), .trainerName = _("JULIET"),
.contestRank = CONTEST_RANK_NORMAL .contestRank = CONTEST_RANK_NORMAL
}, },
{ [CONTEST_WINNER_HALL_4 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_PLUSLE, .species = SPECIES_PLUSLE,
@ -174,7 +174,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("BAILY"), .trainerName = _("BAILY"),
.contestRank = CONTEST_RANK_MASTER .contestRank = CONTEST_RANK_MASTER
}, },
{ [CONTEST_WINNER_HALL_5 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_SHUPPET, .species = SPECIES_SHUPPET,
@ -183,7 +183,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("MELANY"), .trainerName = _("MELANY"),
.contestRank = CONTEST_RANK_SUPER .contestRank = CONTEST_RANK_SUPER
}, },
{ [CONTEST_WINNER_HALL_6 - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_ZANGOOSE, .species = SPECIES_ZANGOOSE,
@ -192,7 +192,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("HANA"), .trainerName = _("HANA"),
.contestRank = CONTEST_RANK_HYPER .contestRank = CONTEST_RANK_HYPER
}, },
{ [CONTEST_WINNER_HALL_UNUSED - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_LOUDRED, .species = SPECIES_LOUDRED,
@ -201,7 +201,7 @@ const struct ContestWinner gDefaultContestWinners[] =
.trainerName = _("BRYANT"), .trainerName = _("BRYANT"),
.contestRank = CONTEST_RANK_HYPER .contestRank = CONTEST_RANK_HYPER
}, },
{ [CONTEST_WINNER_MUSEUM_UNUSED - 1] = {
.personality = 0, .personality = 0,
.trainerId = 0xFFFF, .trainerId = 0xFFFF,
.species = SPECIES_DELCATTY, .species = SPECIES_DELCATTY,

View File

@ -1466,15 +1466,15 @@ bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
return TRUE; return TRUE;
} }
bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx) bool8 ScrCmd_showcontestpainting(struct ScriptContext *ctx)
{ {
u8 contestWinnerId = ScriptReadByte(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) if (contestWinnerId != CONTEST_WINNER_ARTIST)
SetContestWinnerForPainting(contestWinnerId); SetContestWinnerForPainting(contestWinnerId);
ShowContestWinnerPainting(); ShowContestPainting();
ScriptContext1_Stop(); ScriptContext1_Stop();
return TRUE; return TRUE;
} }