2018-11-19 17:16:01 +01:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2018-12-15 20:07:07 +01:00
|
|
|
#include "battle.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "battle_gfx_sfx_util.h"
|
2018-12-15 20:07:07 +01:00
|
|
|
#include "bg.h"
|
|
|
|
#include "contest.h"
|
|
|
|
#include "contest_painting.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-12-15 20:07:07 +01:00
|
|
|
#include "decompress.h"
|
|
|
|
#include "gpu_regs.h"
|
2019-11-10 23:29:52 +01:00
|
|
|
#include "image_processing_effects.h"
|
2018-12-15 20:07:07 +01:00
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "lilycove_lady.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "random.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "constants/rgb.h"
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
u16 (*gContestMonPixels)[][32];
|
2019-11-10 23:29:52 +01:00
|
|
|
struct ImageProcessingContext gImageProcessingContext;
|
2019-11-10 19:46:39 +01:00
|
|
|
struct ContestWinner *gContestPaintingWinner;
|
2019-02-02 12:44:00 +01:00
|
|
|
u16 *gContestPaintingMonPalette;
|
2018-11-19 17:16:01 +01:00
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static u8 sHoldState;
|
|
|
|
static u16 sMosaicVal;
|
|
|
|
static u16 sFadeCounter;
|
|
|
|
static bool8 sVarsInitialized;
|
|
|
|
static u8 sWindowId;
|
2018-12-15 20:07:07 +01:00
|
|
|
|
|
|
|
static void ShowContestPainting(void);
|
|
|
|
static void HoldContestPainting(void);
|
|
|
|
static void InitContestPaintingWindow(void);
|
|
|
|
static void InitContestPaintingBg(void);
|
|
|
|
static void InitContestPaintingVars(bool8);
|
2019-11-10 19:46:39 +01:00
|
|
|
static void CreateContestPaintingPicture(u8, u8);
|
2018-12-15 20:07:07 +01:00
|
|
|
static void PrintContestPaintingCaption(u8, u8);
|
|
|
|
static void VBlankCB_ContestPainting(void);
|
2019-11-10 19:46:39 +01:00
|
|
|
static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]);
|
2018-12-15 20:07:07 +01:00
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
extern const u8 gContestHallPaintingCaption[];
|
2018-12-15 20:07:07 +01:00
|
|
|
extern const u8 gContestCoolness[];
|
|
|
|
extern const u8 gContestBeauty[];
|
|
|
|
extern const u8 gContestCuteness[];
|
|
|
|
extern const u8 gContestSmartness[];
|
|
|
|
extern const u8 gContestToughness[];
|
|
|
|
extern const u8 gContestRankNormal[];
|
|
|
|
extern const u8 gContestRankSuper[];
|
|
|
|
extern const u8 gContestRankHyper[];
|
|
|
|
extern const u8 gContestRankMaster[];
|
|
|
|
extern const u8 gContestLink[];
|
|
|
|
extern const u8 gContestPaintingCool1[];
|
|
|
|
extern const u8 gContestPaintingCool2[];
|
|
|
|
extern const u8 gContestPaintingCool3[];
|
|
|
|
extern const u8 gContestPaintingBeauty1[];
|
|
|
|
extern const u8 gContestPaintingBeauty2[];
|
|
|
|
extern const u8 gContestPaintingBeauty3[];
|
|
|
|
extern const u8 gContestPaintingCute1[];
|
|
|
|
extern const u8 gContestPaintingCute2[];
|
|
|
|
extern const u8 gContestPaintingCute3[];
|
|
|
|
extern const u8 gContestPaintingSmart1[];
|
|
|
|
extern const u8 gContestPaintingSmart2[];
|
|
|
|
extern const u8 gContestPaintingSmart3[];
|
|
|
|
extern const u8 gContestPaintingTough1[];
|
|
|
|
extern const u8 gContestPaintingTough2[];
|
|
|
|
extern const u8 gContestPaintingTough3[];
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
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");
|
2018-12-15 20:07:07 +01:00
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const u8 *const sContestCategoryNames_Unused[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
[CONTEST_CATEGORY_COOL] = gContestCoolness,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = gContestBeauty,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = gContestCuteness,
|
|
|
|
[CONTEST_CATEGORY_SMART] = gContestSmartness,
|
|
|
|
[CONTEST_CATEGORY_TOUGH] = gContestToughness,
|
2018-12-15 20:07:07 +01:00
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const u8 *const sContestRankNames[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
[CONTEST_RANK_NORMAL] = gContestRankNormal,
|
|
|
|
[CONTEST_RANK_SUPER] = gContestRankSuper,
|
|
|
|
[CONTEST_RANK_HYPER] = gContestRankHyper,
|
|
|
|
[CONTEST_RANK_MASTER] = gContestRankMaster,
|
|
|
|
[CONTEST_RANK_LINK] = gContestLink,
|
2018-12-15 20:07:07 +01:00
|
|
|
};
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static const struct BgTemplate sBgTemplates[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 1,
|
|
|
|
.mapBaseIndex = 10,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static const struct WindowTemplate sWindowTemplate =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 14,
|
|
|
|
.width = 26,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 1,
|
|
|
|
};
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static const u8 *const sMuseumCaptions[NUM_PAINTING_CAPTIONS * CONTEST_CATEGORIES_COUNT] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
[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,
|
2018-12-15 20:07:07 +01:00
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const struct OamData sContestPaintingMonOamData =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2019-04-02 00:31:10 +02:00
|
|
|
.mosaic = TRUE,
|
2018-12-15 20:07:07 +01:00
|
|
|
.bpp = ST_OAM_8BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2018-12-15 20:07:07 +01:00
|
|
|
.x = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2018-12-15 20:07:07 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2021-04-22 20:30:45 +02:00
|
|
|
static const u16 sBgPalette[] = {RGB_BLACK, RGB_BLACK};
|
2018-12-15 20:07:07 +01:00
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
void SetContestWinnerForPainting(int contestWinnerId)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
u8 *saveIdx = &gCurContestWinnerSaveIdx;
|
|
|
|
u8 *isForArtist = &gCurContestWinnerIsForArtist;
|
2021-02-14 10:01:20 +01:00
|
|
|
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
|
2021-04-22 02:04:12 +02:00
|
|
|
*saveIdx = contestWinnerId - 1;
|
|
|
|
*isForArtist = FALSE;
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CB2_ContestPainting(void)
|
|
|
|
{
|
|
|
|
ShowContestPainting();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CB2_HoldContestPainting(void)
|
|
|
|
{
|
|
|
|
HoldContestPainting();
|
|
|
|
RunTextPrinters();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CB2_QuitContestPainting(void)
|
|
|
|
{
|
|
|
|
SetMainCallback2(gMain.savedCallback);
|
|
|
|
FREE_AND_SET_NULL(gContestPaintingMonPalette);
|
2019-11-10 19:46:39 +01:00
|
|
|
FREE_AND_SET_NULL(gContestMonPixels);
|
2021-04-22 02:04:12 +02:00
|
|
|
RemoveWindow(sWindowId);
|
2018-12-15 20:07:07 +01:00
|
|
|
Free(GetBgTilemapBuffer(1));
|
|
|
|
FreeMonSpritesGfx();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ShowContestPainting(void)
|
|
|
|
{
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
AllocateMonSpritesGfx();
|
2019-11-10 19:46:39 +01:00
|
|
|
gContestPaintingWinner = &gCurContestWinner;
|
2021-04-22 02:04:12 +02:00
|
|
|
InitContestPaintingVars(TRUE);
|
2018-12-15 20:07:07 +01:00
|
|
|
InitContestPaintingBg();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ResetPaletteFade();
|
2021-04-22 02:04:12 +02:00
|
|
|
DmaFillLarge32(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
|
2018-12-15 20:07:07 +01:00
|
|
|
ResetSpriteData();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SeedRng(gMain.vblankCounter1);
|
|
|
|
InitKeys();
|
|
|
|
InitContestPaintingWindow();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-04-22 02:04:12 +02:00
|
|
|
CreateContestPaintingPicture(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
|
2018-12-15 20:07:07 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-22 02:04:12 +02:00
|
|
|
PrintContestPaintingCaption(gCurContestWinnerSaveIdx, gCurContestWinnerIsForArtist);
|
2022-08-19 16:29:35 +02:00
|
|
|
SetBackdropFromPalette(sBgPalette);
|
2018-12-15 20:07:07 +01:00
|
|
|
DmaClear32(3, PLTT, PLTT_SIZE);
|
|
|
|
BeginFastPaletteFade(2);
|
|
|
|
SetVBlankCallback(VBlankCB_ContestPainting);
|
2021-04-22 02:04:12 +02:00
|
|
|
sHoldState = 0;
|
2018-12-15 20:07:07 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON);
|
|
|
|
SetMainCallback2(CB2_HoldContestPainting);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HoldContestPainting(void)
|
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
switch (sHoldState)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
2021-04-22 02:04:12 +02:00
|
|
|
sHoldState = 1;
|
|
|
|
if (sVarsInitialized && sFadeCounter)
|
|
|
|
sFadeCounter--;
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-11-03 02:02:39 +01:00
|
|
|
if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
sHoldState++;
|
2023-07-31 21:33:14 +02:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
if (sVarsInitialized)
|
|
|
|
sFadeCounter = 0;
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
SetMainCallback2(CB2_QuitContestPainting);
|
2021-04-22 02:04:12 +02:00
|
|
|
if (sVarsInitialized && sFadeCounter < 30)
|
|
|
|
sFadeCounter++;
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitContestPaintingWindow(void)
|
|
|
|
{
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2021-04-22 02:04:12 +02:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgX(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(1, 0, BG_COORD_SET);
|
2018-12-15 20:07:07 +01:00
|
|
|
SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE));
|
2021-04-22 02:04:12 +02:00
|
|
|
sWindowId = AddWindow(&sWindowTemplate);
|
2018-12-15 20:07:07 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2021-04-22 02:04:12 +02:00
|
|
|
FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0));
|
|
|
|
PutWindowTilemap(sWindowId);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(sWindowId, COPYWIN_FULL);
|
2018-12-15 20:07:07 +01:00
|
|
|
ShowBg(1);
|
|
|
|
}
|
|
|
|
|
2021-04-22 20:30:45 +02:00
|
|
|
static void PrintContestPaintingCaption(u8 contestType, bool8 isForArtist)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
u8 category;
|
|
|
|
|
2021-04-22 20:30:45 +02:00
|
|
|
// Artist's painting has no caption
|
|
|
|
if (isForArtist == TRUE)
|
2018-12-15 20:07:07 +01:00
|
|
|
return;
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
category = gContestPaintingWinner->contestCategory;
|
2021-04-22 02:04:12 +02:00
|
|
|
if (contestType < MUSEUM_CONTEST_WINNERS_START)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Contest Hall caption
|
2019-08-04 10:22:19 +02:00
|
|
|
BufferContestName(gStringVar1, category);
|
2018-12-15 20:07:07 +01:00
|
|
|
StringAppend(gStringVar1, gText_Space);
|
2019-11-10 19:46:39 +01:00
|
|
|
StringAppend(gStringVar1, sContestRankNames[gContestPaintingWinner->contestRank]);
|
|
|
|
StringCopy(gStringVar2, gContestPaintingWinner->trainerName);
|
2021-04-22 20:30:45 +02:00
|
|
|
ConvertInternationalContestantName(gStringVar2);
|
2019-11-10 19:46:39 +01:00
|
|
|
StringCopy(gStringVar3, gContestPaintingWinner->monName);
|
2021-04-22 02:04:12 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gContestHallPaintingCaption);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Museum caption
|
2019-11-10 19:46:39 +01:00
|
|
|
StringCopy(gStringVar1, gContestPaintingWinner->monName);
|
2021-04-22 02:04:12 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, sMuseumCaptions[category]);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 208);
|
|
|
|
AddTextPrinterParameterized(sWindowId, FONT_NORMAL, gStringVar4, x, 1, 0, 0);
|
2018-12-15 20:07:07 +01:00
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitContestPaintingBg(void)
|
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
REG_IE |= INTR_FLAG_VBLANK;
|
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | 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);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDY, 0);
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static void InitContestPaintingVars(bool8 reset)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
if (reset == FALSE)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Never reached
|
|
|
|
sVarsInitialized = FALSE;
|
|
|
|
sMosaicVal = 0;
|
|
|
|
sFadeCounter = 0;
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
sVarsInitialized = TRUE;
|
|
|
|
sMosaicVal = 15;
|
|
|
|
sFadeCounter = 30;
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 15:28:09 +01:00
|
|
|
static void UpdateContestPaintingMosaicEffect(void)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
if (!sVarsInitialized)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
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);
|
2021-04-22 02:04:12 +02:00
|
|
|
sMosaicVal = sFadeCounter / 2;
|
|
|
|
SetGpuReg(REG_OFFSET_MOSAIC, (sMosaicVal << 12) | (sMosaicVal << 8) | (sMosaicVal << 4) | (sMosaicVal << 0));
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VBlankCB_ContestPainting(void)
|
|
|
|
{
|
2018-12-16 15:28:09 +01:00
|
|
|
UpdateContestPaintingMosaicEffect();
|
2018-12-15 20:07:07 +01:00
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2021-10-03 05:47:59 +02:00
|
|
|
static void InitContestMonPixels(u16 species, bool8 backPic)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
const void *pal = GetMonSpritePalFromSpeciesAndPersonality(species, gContestPaintingWinner->trainerId, gContestPaintingWinner->personality);
|
2018-12-15 20:07:07 +01:00
|
|
|
LZDecompressVram(pal, gContestPaintingMonPalette);
|
2021-10-03 05:47:59 +02:00
|
|
|
if (!backPic)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2022-08-25 09:42:41 +02:00
|
|
|
HandleLoadSpecialPokePic(TRUE,
|
|
|
|
gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT],
|
|
|
|
species,
|
|
|
|
gContestPaintingWinner->personality);
|
2021-10-03 05:47:59 +02:00
|
|
|
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-25 09:42:41 +02:00
|
|
|
HandleLoadSpecialPokePic(FALSE,
|
|
|
|
gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT],
|
|
|
|
species,
|
|
|
|
gContestPaintingWinner->personality);
|
2021-10-03 05:47:59 +02:00
|
|
|
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64])
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2020-08-25 22:03:04 +02:00
|
|
|
u16 tileY, tileX, pixelY, pixelX;
|
2018-12-15 20:07:07 +01:00
|
|
|
u8 colorIndex;
|
|
|
|
|
|
|
|
for (tileY = 0; tileY < 8; tileY++)
|
|
|
|
{
|
|
|
|
for (tileX = 0; tileX < 8; tileX++)
|
|
|
|
{
|
|
|
|
for (pixelY = 0; pixelY < 8; pixelY++)
|
|
|
|
{
|
|
|
|
for (pixelX = 0; pixelX < 8; pixelX++)
|
|
|
|
{
|
2020-10-22 11:37:51 +02:00
|
|
|
colorIndex = spriteGfx[32 * (tileY * 8 + tileX) + (pixelY << 2) + (pixelX >> 1)];
|
2018-12-15 20:07:07 +01:00
|
|
|
if (pixelX & 1)
|
|
|
|
colorIndex >>= 4;
|
|
|
|
else
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
colorIndex &= 0xF;
|
2020-08-25 22:03:04 +02:00
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
if (colorIndex == 0) // transparent pixel
|
|
|
|
(*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = 0x8000;
|
2018-12-15 20:07:07 +01:00
|
|
|
else
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
(*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = palette[colorIndex];
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 isForArtist)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
u8 x, y;
|
|
|
|
|
2022-08-19 17:32:00 +02:00
|
|
|
LoadPalette(sPictureFramePalettes, BG_PLTT_ID(0), 8 * PLTT_SIZE_4BPP);
|
2021-04-22 02:04:12 +02:00
|
|
|
if (isForArtist == TRUE)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Load Artist's frame
|
|
|
|
switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
|
|
|
|
RLUnCompWram(sPictureFrameTilemap_Cool, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
|
|
|
|
RLUnCompWram(sPictureFrameTilemap_Beauty, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
|
|
|
|
RLUnCompWram(sPictureFrameTilemap_Cute, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
|
|
|
|
RLUnCompWram(sPictureFrameTilemap_Smart, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
|
|
|
|
RLUnCompWram(sPictureFrameTilemap_Tough, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the background
|
|
|
|
for (y = 0; y < 20; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 32; x++)
|
|
|
|
VRAM_PICTURE_DATA(x, y) = 0x1015;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the image frame
|
|
|
|
for (y = 0; y < 10; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 18; x++)
|
2019-11-10 19:46:39 +01:00
|
|
|
VRAM_PICTURE_DATA(x + 6, y + 2) = (*gContestMonPixels)[y + 2][x + 6];
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Re-set the entire top row to the first top frame part
|
|
|
|
for (x = 0; x < 16; x++)
|
2019-11-10 19:46:39 +01:00
|
|
|
VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7];
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
2021-04-22 02:04:12 +02:00
|
|
|
else if (contestWinnerId < MUSEUM_CONTEST_WINNERS_START)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Load Contest Hall lobby frame
|
|
|
|
RLUnCompVram(sPictureFrameTiles_HallLobby, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_HallLobby, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Load Museum frame
|
|
|
|
switch (gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Cool, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_Cool, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Beauty, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_Beauty, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Cute, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_Cute, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Smart, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_Smart, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
2021-04-22 02:04:12 +02:00
|
|
|
RLUnCompVram(sPictureFrameTiles_Tough, (void *)VRAM);
|
|
|
|
RLUnCompVram(sPictureFrameTilemap_Tough, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
#undef VRAM_PICTURE_DATA
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static void InitPaintingMonOamData(u8 contestWinnerId)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
gMain.oamBuffer[0] = sContestPaintingMonOamData;
|
2018-12-15 20:07:07 +01:00
|
|
|
gMain.oamBuffer[0].tileNum = 0;
|
|
|
|
|
2020-10-26 05:26:15 +01:00
|
|
|
if (contestWinnerId > 1)
|
|
|
|
{
|
|
|
|
gMain.oamBuffer[0].x = 88;
|
|
|
|
gMain.oamBuffer[0].y = 24;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gMain.oamBuffer[0].x = 88; // Duplicated code
|
|
|
|
gMain.oamBuffer[0].y = 24;
|
|
|
|
}
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static u8 GetImageEffectForContestWinner(u8 contestWinnerId)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
u8 contestCategory;
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
if (contestWinnerId < MUSEUM_CONTEST_WINNERS_START)
|
2019-11-10 19:46:39 +01:00
|
|
|
contestCategory = gContestPaintingWinner->contestCategory;
|
2018-12-15 20:07:07 +01:00
|
|
|
else
|
2021-04-22 02:04:12 +02:00
|
|
|
contestCategory = gContestPaintingWinner->contestCategory / NUM_PAINTING_CAPTIONS;
|
2018-12-15 20:07:07 +01:00
|
|
|
|
|
|
|
switch (contestCategory)
|
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
2019-11-10 19:46:39 +01:00
|
|
|
return IMAGE_EFFECT_OUTLINE_COLORED;
|
2018-12-15 20:07:07 +01:00
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
2019-11-10 19:46:39 +01:00
|
|
|
return IMAGE_EFFECT_SHIMMER;
|
2018-12-15 20:07:07 +01:00
|
|
|
case CONTEST_CATEGORY_CUTE:
|
2019-11-10 19:46:39 +01:00
|
|
|
return IMAGE_EFFECT_POINTILLISM;
|
2018-12-15 20:07:07 +01:00
|
|
|
case CONTEST_CATEGORY_SMART:
|
2019-11-10 19:46:39 +01:00
|
|
|
return IMAGE_EFFECT_CHARCOAL;
|
2018-12-15 20:07:07 +01:00
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
2019-11-10 19:46:39 +01:00
|
|
|
return IMAGE_EFFECT_GRAYSCALE_LIGHT;
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return contestCategory;
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static void AllocPaintingResources(void)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
gContestPaintingMonPalette = AllocZeroed(OBJ_PLTT_SIZE);
|
|
|
|
gContestMonPixels = AllocZeroed(0x2000);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static void DoContestPaintingImageProcessing(u8 imageEffect)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 23:29:52 +01:00
|
|
|
gImageProcessingContext.canvasPixels = gContestMonPixels;
|
|
|
|
gImageProcessingContext.canvasPalette = gContestPaintingMonPalette;
|
|
|
|
gImageProcessingContext.paletteStart = 0;
|
|
|
|
gImageProcessingContext.personality = gContestPaintingWinner->personality % 256;
|
|
|
|
gImageProcessingContext.columnStart = 0;
|
|
|
|
gImageProcessingContext.rowStart = 0;
|
|
|
|
gImageProcessingContext.columnEnd = 64;
|
|
|
|
gImageProcessingContext.rowEnd = 64;
|
|
|
|
gImageProcessingContext.canvasWidth = 64;
|
|
|
|
gImageProcessingContext.canvasHeight = 64;
|
2019-11-10 19:46:39 +01:00
|
|
|
|
|
|
|
switch (imageEffect)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
case IMAGE_EFFECT_CHARCOAL:
|
|
|
|
case IMAGE_EFFECT_GRAYSCALE_LIGHT:
|
2019-11-10 23:29:52 +01:00
|
|
|
gImageProcessingContext.quantizeEffect = QUANTIZE_EFFECT_GRAYSCALE;
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
2019-11-10 19:46:39 +01:00
|
|
|
case IMAGE_EFFECT_OUTLINE_COLORED:
|
|
|
|
case IMAGE_EFFECT_SHIMMER:
|
|
|
|
case IMAGE_EFFECT_POINTILLISM:
|
2018-12-15 20:07:07 +01:00
|
|
|
default:
|
2019-11-10 23:29:52 +01:00
|
|
|
gImageProcessingContext.quantizeEffect = QUANTIZE_EFFECT_STANDARD_LIMITED_COLORS;
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-11-10 23:29:52 +01:00
|
|
|
gImageProcessingContext.var_16 = 2;
|
|
|
|
gImageProcessingContext.effect = imageEffect;
|
2019-11-12 17:25:02 +01:00
|
|
|
gImageProcessingContext.dest = (void *)OBJ_VRAM0;
|
2018-12-15 20:07:07 +01:00
|
|
|
|
2019-11-10 23:29:52 +01:00
|
|
|
ApplyImageProcessingEffects(&gImageProcessingContext);
|
|
|
|
ApplyImageProcessingQuantization(&gImageProcessingContext);
|
|
|
|
ConvertImageProcessingToGBA(&gImageProcessingContext);
|
2022-08-19 17:32:00 +02:00
|
|
|
LoadPalette(gContestPaintingMonPalette, OBJ_PLTT_ID(0), 16 * PLTT_SIZE_4BPP);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 isForArtist)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
AllocPaintingResources();
|
2021-10-03 05:47:59 +02:00
|
|
|
InitContestMonPixels(gContestPaintingWinner->species, FALSE);
|
2019-11-10 19:46:39 +01:00
|
|
|
DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId));
|
|
|
|
InitPaintingMonOamData(contestWinnerId);
|
2021-04-22 02:04:12 +02:00
|
|
|
LoadContestPaintingFrame(contestWinnerId, isForArtist);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
2019-04-02 00:31:10 +02:00
|
|
|
|