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-02-02 12:44:00 +01:00
|
|
|
// IWRAM common
|
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
|
|
|
|
|
|
|
// IWRAM bss
|
2019-06-26 14:13:38 +02:00
|
|
|
static u8 gContestPaintingState;
|
|
|
|
static u16 gContestPaintingMosaicVal;
|
|
|
|
static u16 gContestPaintingFadeCounter;
|
|
|
|
static bool8 gUnknown_030011F6;
|
|
|
|
static u8 gContestPaintingWindowId;
|
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-03-04 22:34:09 +01:00
|
|
|
extern const u8 gContestPaintingCaption[];
|
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[];
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const u8 *const sContestCategoryNames_Unused[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
gContestCoolness,
|
|
|
|
gContestBeauty,
|
|
|
|
gContestCuteness,
|
|
|
|
gContestSmartness,
|
|
|
|
gContestToughness,
|
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const u8 *const sContestRankNames[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
gContestRankNormal,
|
|
|
|
gContestRankSuper,
|
|
|
|
gContestRankHyper,
|
|
|
|
gContestRankMaster,
|
|
|
|
gContestLink,
|
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const struct BgTemplate sContestPaintingBgTemplates[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 1,
|
|
|
|
.mapBaseIndex = 10,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const struct WindowTemplate sContestPaintingWindowTemplate =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 14,
|
|
|
|
.width = 26,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 1,
|
|
|
|
};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static const u8 *const sContestPaintingDescriptionPointers[] =
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
gContestPaintingCool1,
|
|
|
|
gContestPaintingCool2,
|
|
|
|
gContestPaintingCool3,
|
|
|
|
gContestPaintingBeauty1,
|
|
|
|
gContestPaintingBeauty2,
|
|
|
|
gContestPaintingBeauty3,
|
|
|
|
gContestPaintingCute1,
|
|
|
|
gContestPaintingCute2,
|
|
|
|
gContestPaintingCute3,
|
|
|
|
gContestPaintingSmart1,
|
|
|
|
gContestPaintingSmart2,
|
|
|
|
gContestPaintingSmart3,
|
|
|
|
gContestPaintingTough1,
|
|
|
|
gContestPaintingTough2,
|
|
|
|
gContestPaintingTough3,
|
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
const u16 gUnknown_085B0838[] = {RGB(0, 0, 0), RGB(0, 0, 0)};
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
void SetContestWinnerForPainting(int contestWinnerId)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
u8 *ptr1 = &gUnknown_02039F5D;
|
|
|
|
u8 *ptr2 = &gUnknown_02039F5C;
|
2021-02-14 10:01:20 +01:00
|
|
|
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
|
|
|
|
*ptr1 = contestWinnerId - 1;
|
|
|
|
*ptr2 = 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);
|
2018-12-15 20:07:07 +01:00
|
|
|
RemoveWindow(gContestPaintingWindowId);
|
|
|
|
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;
|
2018-12-15 20:07:07 +01:00
|
|
|
InitContestPaintingVars(1);
|
|
|
|
InitContestPaintingBg();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ResetPaletteFade();
|
|
|
|
DmaFillLarge32(3, 0, (void *)BG_VRAM, 0x18000, 0x1000);
|
|
|
|
ResetSpriteData();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SeedRng(gMain.vblankCounter1);
|
|
|
|
InitKeys();
|
|
|
|
InitContestPaintingWindow();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-11-10 19:46:39 +01:00
|
|
|
CreateContestPaintingPicture(gUnknown_02039F5D, gUnknown_02039F5C);
|
2018-12-15 20:07:07 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
PrintContestPaintingCaption(gUnknown_02039F5D, gUnknown_02039F5C);
|
|
|
|
LoadPalette(gUnknown_085B0838, 0, 1 * 2);
|
|
|
|
DmaClear32(3, PLTT, PLTT_SIZE);
|
|
|
|
BeginFastPaletteFade(2);
|
|
|
|
SetVBlankCallback(VBlankCB_ContestPainting);
|
|
|
|
gContestPaintingState = 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HoldContestPainting(void)
|
|
|
|
{
|
|
|
|
switch (gContestPaintingState)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
gContestPaintingState = 1;
|
|
|
|
if (gUnknown_030011F6 && gContestPaintingFadeCounter)
|
|
|
|
gContestPaintingFadeCounter--;
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-07-01 17:47:47 +02:00
|
|
|
gContestPaintingState++;
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0));
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gUnknown_030011F6)
|
|
|
|
gContestPaintingFadeCounter = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
SetMainCallback2(CB2_QuitContestPainting);
|
|
|
|
if (gUnknown_030011F6 && gContestPaintingFadeCounter < 30)
|
|
|
|
gContestPaintingFadeCounter++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitContestPaintingWindow(void)
|
|
|
|
{
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2019-11-10 19:46:39 +01:00
|
|
|
InitBgsFromTemplates(0, sContestPaintingBgTemplates, ARRAY_COUNT(sContestPaintingBgTemplates));
|
2018-12-15 20:07:07 +01:00
|
|
|
ChangeBgX(1, 0, 0);
|
|
|
|
ChangeBgY(1, 0, 0);
|
|
|
|
SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE));
|
2019-11-10 19:46:39 +01:00
|
|
|
gContestPaintingWindowId = AddWindow(&sContestPaintingWindowTemplate);
|
2018-12-15 20:07:07 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(gContestPaintingWindowId, PIXEL_FILL(0));
|
2018-12-15 20:07:07 +01:00
|
|
|
PutWindowTilemap(gContestPaintingWindowId);
|
|
|
|
CopyWindowToVram(gContestPaintingWindowId, 3);
|
|
|
|
ShowBg(1);
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
static void PrintContestPaintingCaption(u8 contestType, bool8 arg1)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
u8 category;
|
|
|
|
|
|
|
|
if (arg1 == TRUE)
|
|
|
|
return;
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
category = gContestPaintingWinner->contestCategory;
|
2018-12-15 20:07:07 +01:00
|
|
|
if (contestType < 8)
|
|
|
|
{
|
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);
|
2018-12-15 20:07:07 +01:00
|
|
|
sub_81DB5AC(gStringVar2);
|
2019-11-10 19:46:39 +01:00
|
|
|
StringCopy(gStringVar3, gContestPaintingWinner->monName);
|
2021-03-04 22:34:09 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gContestPaintingCaption);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
StringCopy(gStringVar1, gContestPaintingWinner->monName);
|
|
|
|
StringExpandPlaceholders(gStringVar4, sContestPaintingDescriptionPointers[category]);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
|
|
|
|
AddTextPrinterParameterized(gContestPaintingWindowId, 1, gStringVar4, x, 1, 0, 0);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitContestPaintingVars(bool8 arg0)
|
|
|
|
{
|
|
|
|
if (arg0 == FALSE)
|
|
|
|
{
|
|
|
|
gUnknown_030011F6 = FALSE;
|
|
|
|
gContestPaintingMosaicVal = 0;
|
|
|
|
gContestPaintingFadeCounter = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gUnknown_030011F6 = TRUE;
|
|
|
|
gContestPaintingMosaicVal = 15;
|
|
|
|
gContestPaintingFadeCounter = 30;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 15:28:09 +01:00
|
|
|
static void UpdateContestPaintingMosaicEffect(void)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
if (!gUnknown_030011F6)
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
static void InitContestMonPixels(u16 species, u8 whichSprite)
|
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);
|
2019-11-10 19:46:39 +01:00
|
|
|
if (whichSprite == 0)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
HandleLoadSpecialPokePic_DontHandleDeoxys(
|
|
|
|
&gMonFrontPicTable[species],
|
2020-09-19 19:37:24 +02:00
|
|
|
gMonSpritesGfxPtr->sprites.ptr[1],
|
2018-12-15 20:07:07 +01:00
|
|
|
species,
|
2019-11-10 19:46:39 +01:00
|
|
|
gContestPaintingWinner->personality);
|
2020-09-19 19:37:24 +02:00
|
|
|
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[1], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HandleLoadSpecialPokePic_DontHandleDeoxys(
|
|
|
|
&gMonBackPicTable[species],
|
2020-09-19 19:37:24 +02:00
|
|
|
gMonSpritesGfxPtr->sprites.ptr[0],
|
2018-12-15 20:07:07 +01:00
|
|
|
species,
|
2019-11-10 19:46:39 +01:00
|
|
|
gContestPaintingWinner->personality);
|
2020-09-19 19:37:24 +02:00
|
|
|
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[0], 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)])
|
|
|
|
|
|
|
|
static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
u8 x, y;
|
|
|
|
|
|
|
|
LoadPalette(gPictureFramePalettes, 0, 0x100);
|
2020-06-17 23:48:20 +02:00
|
|
|
if (arg1 == TRUE)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
switch (gContestPaintingWinner->contestCategory / 3)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM);
|
2019-11-10 19:46:39 +01:00
|
|
|
RLUnCompWram(gPictureFrameTilemap_0, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM);
|
2019-11-10 19:46:39 +01:00
|
|
|
RLUnCompWram(gPictureFrameTilemap_1, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM);
|
2019-11-10 19:46:39 +01:00
|
|
|
RLUnCompWram(gPictureFrameTilemap_2, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM);
|
2019-11-10 19:46:39 +01:00
|
|
|
RLUnCompWram(gPictureFrameTilemap_3, gContestMonPixels);
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM);
|
2019-11-10 19:46:39 +01:00
|
|
|
RLUnCompWram(gPictureFrameTilemap_4, 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
|
|
|
}
|
2019-11-10 19:46:39 +01:00
|
|
|
else if (contestWinnerId < 8)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
RLUnCompVram(gPictureFrameTiles_5, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_5, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
switch (gContestPaintingWinner->contestCategory / 3)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_0, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_1, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_2, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_3, (void *)(BG_SCREEN_ADDR(12)));
|
2018-12-15 20:07:07 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
|
|
|
RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
RLUnCompVram(gPictureFrameTilemap_4, (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-09-10 15:14:53 +02:00
|
|
|
if (contestWinnerId > 1)
|
|
|
|
{
|
|
|
|
gMain.oamBuffer[0].x = 88;
|
|
|
|
gMain.oamBuffer[0].y = 24;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-26 05:26:15 +01:00
|
|
|
gMain.oamBuffer[0].x = 88; // Duplicated code
|
2020-09-10 15:14:53 +02:00
|
|
|
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;
|
|
|
|
|
2019-11-10 19:46:39 +01:00
|
|
|
if (contestWinnerId < 8)
|
|
|
|
contestCategory = gContestPaintingWinner->contestCategory;
|
2018-12-15 20:07:07 +01:00
|
|
|
else
|
2019-11-10 19:46:39 +01:00
|
|
|
contestCategory = gContestPaintingWinner->contestCategory / 3;
|
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);
|
2018-12-15 20:07:07 +01:00
|
|
|
LoadPalette(gContestPaintingMonPalette, 0x100, 0x200);
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 arg1)
|
2018-12-15 20:07:07 +01:00
|
|
|
{
|
2019-11-10 19:46:39 +01:00
|
|
|
AllocPaintingResources();
|
|
|
|
InitContestMonPixels(gContestPaintingWinner->species, 0);
|
|
|
|
DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId));
|
|
|
|
InitPaintingMonOamData(contestWinnerId);
|
|
|
|
LoadContestPaintingFrame(contestWinnerId, arg1);
|
2018-12-15 20:07:07 +01:00
|
|
|
}
|
2019-04-02 00:31:10 +02:00
|
|
|
|