pokeemerald/src/mon_markings.c

623 lines
15 KiB
C
Raw Normal View History

2018-04-17 10:54:39 +02:00
#include "global.h"
#include "dma3.h"
#include "graphics.h"
#include "main.h"
2018-05-19 11:53:22 +02:00
#include "window.h"
#include "list_menu.h"
2018-04-17 10:54:39 +02:00
#include "mon_markings.h"
#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
#include "text_window.h"
2021-02-28 23:22:26 +01:00
#define ANIM_CURSOR (NUM_MON_MARKINGS * 2)
#define ANIM_TEXT (ANIM_CURSOR + 1)
#define SELECTION_OK NUM_MON_MARKINGS
#define SELECTION_CANCEL (SELECTION_OK + 1)
static void CreateMonMarkingsMenuSprites(s16, s16, u16, u16);
static void SpriteCB_Dummy(struct Sprite *);
static void SpriteCB_Marking(struct Sprite *);
static void SpriteCB_Cursor(struct Sprite *);
static struct Sprite *CreateMarkingComboSprite(u16, u16, const u16 *, u16);
2018-04-17 10:54:39 +02:00
2021-02-28 23:22:26 +01:00
static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/misc/mon_markings.gbapal");
static const u8 sMonMarkings_Gfx[] = INCBIN_U8("graphics/misc/mon_markings.4bpp");
2018-04-17 10:54:39 +02:00
2021-02-28 23:22:26 +01:00
static const struct OamData sOamData_MenuWindow =
2018-04-17 10:54:39 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-04-17 10:54:39 +02:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
2018-04-17 10:54:39 +02:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
2018-04-17 10:54:39 +02:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
2021-02-28 23:22:26 +01:00
// Used for the markings, OK/Cancel text, and cursor sprites
static const struct OamData sOamData_8x8 =
2018-04-17 10:54:39 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-04-17 10:54:39 +02:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(8x8),
2018-04-17 10:54:39 +02:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(8x8),
2018-04-17 10:54:39 +02:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_CircleOff[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_CircleOn[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(1, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_SquareOff[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(2, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_SquareOn[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(3, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_TriangleOff[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(4, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_TriangleOn[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(5, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_HeartOff[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(6, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Marking_HeartOn[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(7, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_Cursor[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(8, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_OKCancelText[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(9, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd *const sAnims_MenuSprite[] =
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sAnim_Marking_CircleOff,
sAnim_Marking_CircleOn,
sAnim_Marking_SquareOff,
sAnim_Marking_SquareOn,
sAnim_Marking_TriangleOff,
sAnim_Marking_TriangleOn,
sAnim_Marking_HeartOff,
sAnim_Marking_HeartOn,
[ANIM_CURSOR] = sAnim_Cursor,
[ANIM_TEXT] = sAnim_OKCancelText,
2018-04-17 10:54:39 +02:00
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MenuWindow_UpperHalf[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MenuWindow_LowerHalf[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(64, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd *const sAnims_MenuWindow[] =
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sAnim_MenuWindow_UpperHalf,
sAnim_MenuWindow_LowerHalf,
2018-04-17 10:54:39 +02:00
};
2021-02-28 23:22:26 +01:00
static const struct OamData sOamData_MarkingCombo =
2018-04-17 10:54:39 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-04-17 10:54:39 +02:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x8),
2018-04-17 10:54:39 +02:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x8),
2018-04-17 10:54:39 +02:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_AllOff[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_Circle[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(4, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_Square[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(8, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleSquare[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(12, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_Triangle[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(16, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleTriangle[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(20, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_SquareTriangle[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(24, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleSquareTriangle[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(28, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_Heart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(32, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(36, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_SquareHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(40, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleSquareHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(44, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_TriangleHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(48, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_CircleTriangleHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(52, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_SquareTriangleHeart[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(56, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd sAnim_MarkingCombo_AllOn[] =
2018-04-17 10:54:39 +02:00
{
ANIMCMD_FRAME(60, 5),
ANIMCMD_END,
};
2021-02-28 23:22:26 +01:00
static const union AnimCmd *const sAnims_MarkingCombo[] =
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sAnim_MarkingCombo_AllOff,
sAnim_MarkingCombo_Circle,
sAnim_MarkingCombo_Square,
sAnim_MarkingCombo_CircleSquare,
sAnim_MarkingCombo_Triangle,
sAnim_MarkingCombo_CircleTriangle,
sAnim_MarkingCombo_SquareTriangle,
sAnim_MarkingCombo_CircleSquareTriangle,
sAnim_MarkingCombo_Heart,
sAnim_MarkingCombo_CircleHeart,
sAnim_MarkingCombo_SquareHeart,
sAnim_MarkingCombo_CircleSquareHeart,
sAnim_MarkingCombo_TriangleHeart,
sAnim_MarkingCombo_CircleTriangleHeart,
sAnim_MarkingCombo_SquareTriangleHeart,
sAnim_MarkingCombo_AllOn,
2018-04-17 10:54:39 +02:00
};
2021-02-28 23:42:11 +01:00
static EWRAM_DATA struct MonMarkingsMenu *sMenu = NULL;
2018-04-17 10:54:39 +02:00
2021-02-28 23:42:11 +01:00
void InitMonMarkingsMenu(struct MonMarkingsMenu *ptr)
2018-04-17 10:54:39 +02:00
{
sMenu = ptr;
}
2021-02-28 23:22:26 +01:00
static void BufferMenuWindowTiles(void)
2018-04-17 10:54:39 +02:00
{
const struct TilesPal *frame = GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType);
sMenu->frameTiles = frame->tiles;
sMenu->framePalette = frame->pal;
sMenu->tileLoadState = 0;
2021-02-28 23:22:26 +01:00
CpuFill16(0, sMenu->windowSpriteTiles, sizeof(sMenu->windowSpriteTiles));
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
static bool8 BufferMenuFrameTiles(void)
2018-04-17 10:54:39 +02:00
{
u16 i;
2021-02-28 23:22:26 +01:00
u8 *dest = sMenu->windowSpriteTiles + sMenu->tileLoadState * 0x100;
2018-04-17 10:54:39 +02:00
switch (sMenu->tileLoadState)
{
case 0:
CpuFastCopy(sMenu->frameTiles, dest, TILE_SIZE_4BPP);
for (i = 0; i < 6; i++)
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP);
2021-02-28 23:22:26 +01:00
2018-04-17 10:54:39 +02:00
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 2, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP);
sMenu->tileLoadState++;
break;
default:
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 3, dest, TILE_SIZE_4BPP);
for (i = 0; i < 6; i++)
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 4, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP);
2021-02-28 23:22:26 +01:00
2018-04-17 10:54:39 +02:00
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 5, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP);
sMenu->tileLoadState++;
break;
case 13:
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 6, dest, TILE_SIZE_4BPP);
for (i = 0; i < 6; i++)
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 7, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP);
2021-02-28 23:22:26 +01:00
2018-04-17 10:54:39 +02:00
CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 8, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP);
sMenu->tileLoadState++;
return FALSE;
case 14:
return FALSE;
}
return TRUE;
}
2021-02-28 23:22:26 +01:00
void BufferMonMarkingsMenuTiles(void)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
BufferMenuWindowTiles();
while (BufferMenuFrameTiles());
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
void OpenMonMarkingsMenu(u8 markings, s16 x, s16 y)
2018-04-17 10:54:39 +02:00
{
u16 i;
sMenu->cursorPos = 0;
sMenu->markings = markings;
2019-09-08 18:21:24 +02:00
for (i = 0; i < NUM_MON_MARKINGS; i++)
2018-04-17 10:54:39 +02:00
sMenu->markingsArray[i] = (sMenu->markings >> i) & 1;
2021-02-28 23:22:26 +01:00
CreateMonMarkingsMenuSprites(x, y, sMenu->baseTileTag, sMenu->basePaletteTag);
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
void FreeMonMarkingsMenu(void)
2018-04-17 10:54:39 +02:00
{
u16 i;
for (i = 0; i < 2; i++)
{
FreeSpriteTilesByTag(sMenu->baseTileTag + i);
FreeSpritePaletteByTag(sMenu->basePaletteTag + i);
}
2021-02-28 23:22:26 +01:00
for (i = 0; i < ARRAY_COUNT(sMenu->windowSprites); i++)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
if (!sMenu->windowSprites[i])
2018-04-17 10:54:39 +02:00
return;
2021-02-28 23:22:26 +01:00
DestroySprite(sMenu->windowSprites[i]);
sMenu->windowSprites[i] = NULL;
2018-04-17 10:54:39 +02:00
}
2019-09-08 18:21:24 +02:00
for (i = 0; i < NUM_MON_MARKINGS; i++)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
if (!sMenu->markingSprites[i])
2018-04-17 10:54:39 +02:00
return;
2021-02-28 23:22:26 +01:00
DestroySprite(sMenu->markingSprites[i]);
sMenu->markingSprites[i] = NULL;
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
if (sMenu->cursorSprite)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
DestroySprite(sMenu->cursorSprite);
sMenu->cursorSprite = NULL;
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
if (sMenu->textSprite)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
DestroySprite(sMenu->textSprite);
sMenu->textSprite = NULL;
2018-04-17 10:54:39 +02:00
}
}
2021-02-28 23:22:26 +01:00
bool8 HandleMonMarkingsMenuInput(void)
2018-04-17 10:54:39 +02:00
{
u16 i;
2020-09-05 03:11:55 +02:00
if (JOY_NEW(DPAD_UP))
2018-04-17 10:54:39 +02:00
{
s8 pos;
PlaySE(SE_SELECT);
pos = --sMenu->cursorPos;
if (pos < 0)
2021-02-28 23:22:26 +01:00
sMenu->cursorPos = SELECTION_CANCEL;
2018-04-17 10:54:39 +02:00
return TRUE;
}
2020-09-05 03:11:55 +02:00
if (JOY_NEW(DPAD_DOWN))
2018-04-17 10:54:39 +02:00
{
s8 pos;
PlaySE(SE_SELECT);
pos = ++sMenu->cursorPos;
2021-02-28 23:22:26 +01:00
if (pos > SELECTION_CANCEL)
2018-04-17 10:54:39 +02:00
sMenu->cursorPos = 0;
return TRUE;
}
2020-09-05 03:11:55 +02:00
if (JOY_NEW(A_BUTTON))
2018-04-17 10:54:39 +02:00
{
PlaySE(SE_SELECT);
switch (sMenu->cursorPos)
{
2021-02-28 23:22:26 +01:00
case SELECTION_OK:
2018-04-17 10:54:39 +02:00
sMenu->markings = 0;
2019-09-08 18:21:24 +02:00
for (i = 0; i < NUM_MON_MARKINGS; i++)
2018-04-17 10:54:39 +02:00
sMenu->markings |= sMenu->markingsArray[i] << i;
return FALSE;
2021-02-28 23:22:26 +01:00
case SELECTION_CANCEL:
2018-04-17 10:54:39 +02:00
return FALSE;
}
sMenu->markingsArray[sMenu->cursorPos] = !sMenu->markingsArray[sMenu->cursorPos];
return TRUE;
}
2020-09-05 03:11:55 +02:00
if (JOY_NEW(B_BUTTON))
2018-04-17 10:54:39 +02:00
{
PlaySE(SE_SELECT);
return FALSE;
}
return TRUE;
}
2021-02-28 23:22:26 +01:00
#define sMarkingId data[0]
#define sCursorYOffset data[0]
static void CreateMonMarkingsMenuSprites(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag)
2018-04-17 10:54:39 +02:00
{
u16 i;
u8 spriteId;
struct SpriteSheet sheets[] =
{
2021-02-28 23:22:26 +01:00
{ sMenu->windowSpriteTiles, 0x1000, baseTileTag },
{ gMonMarkingsMenu_Gfx, 0x320, baseTileTag + 1 },
{}
2018-04-17 10:54:39 +02:00
};
struct SpritePalette palettes[] =
{
{ sMenu->framePalette, basePaletteTag },
2021-02-28 23:22:26 +01:00
{ gMonMarkingsMenu_Pal, basePaletteTag + 1},
{}
2018-04-17 10:54:39 +02:00
};
2021-02-28 23:22:26 +01:00
struct SpriteTemplate template =
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
.tileTag = baseTileTag,
.paletteTag = basePaletteTag,
.oam = &sOamData_MenuWindow,
.anims = sAnims_MenuWindow,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_Dummy,
2018-04-17 10:54:39 +02:00
};
LoadSpriteSheets(sheets);
LoadSpritePalettes(palettes);
2021-02-28 23:22:26 +01:00
// Create window sprites
for (i = 0; i < ARRAY_COUNT(sMenu->windowSprites); i++)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
spriteId = CreateSprite(&template, x + 32, y + 32, 1);
2018-11-28 21:08:22 +01:00
if (spriteId != MAX_SPRITES)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sMenu->windowSprites[i] = &gSprites[spriteId];
2018-04-17 10:54:39 +02:00
StartSpriteAnim(&gSprites[spriteId], i);
}
else
{
2021-02-28 23:22:26 +01:00
sMenu->windowSprites[i] = NULL;
2018-04-17 10:54:39 +02:00
return;
}
}
2021-02-28 23:22:26 +01:00
sMenu->windowSprites[1]->pos1.y = y + 96;
2018-04-17 10:54:39 +02:00
2021-02-28 23:22:26 +01:00
// Create marking sprites
template.tileTag++;
template.paletteTag++;
template.anims = sAnims_MenuSprite;
template.callback = SpriteCB_Marking;
template.oam = &sOamData_8x8;
2019-09-08 18:21:24 +02:00
for (i = 0; i < NUM_MON_MARKINGS; i++)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
spriteId = CreateSprite(&template, x + 32, y + 16 + 16 * i, 0);
2018-11-28 21:08:22 +01:00
if (spriteId != MAX_SPRITES)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sMenu->markingSprites[i] = &gSprites[spriteId];
gSprites[spriteId].sMarkingId = i;
2018-04-17 10:54:39 +02:00
}
else
{
2021-02-28 23:22:26 +01:00
sMenu->markingSprites[i] = NULL;
2018-04-17 10:54:39 +02:00
return;
}
}
2021-02-28 23:22:26 +01:00
// Create OK/Cancel text sprite
template.callback = SpriteCallbackDummy;
spriteId = CreateSprite(&template, 0, 0, 0);
2018-11-28 21:08:22 +01:00
if (spriteId != MAX_SPRITES)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sMenu->textSprite = &gSprites[spriteId];
sMenu->textSprite->oam.shape = SPRITE_SHAPE(32x32);
sMenu->textSprite->oam.size = SPRITE_SIZE(32x32);
StartSpriteAnim(sMenu->textSprite, ANIM_TEXT);
2021-02-28 23:39:21 +01:00
sMenu->textSprite->pos1.x = x + 32;
2021-02-28 23:22:26 +01:00
sMenu->textSprite->pos1.y = y + 80;
CalcCenterToCornerVec(sMenu->textSprite, SPRITE_SHAPE(32x16), SPRITE_SIZE(32x16), ST_OAM_AFFINE_OFF);
2018-04-17 10:54:39 +02:00
}
else
{
2021-02-28 23:22:26 +01:00
sMenu->textSprite = NULL;
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
// Create cursor sprite
template.callback = SpriteCB_Cursor;
spriteId = CreateSprite(&template, x + 12, 0, 0);
2018-11-28 21:08:22 +01:00
if (spriteId != MAX_SPRITES)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sMenu->cursorSprite = &gSprites[spriteId];
sMenu->cursorSprite->sCursorYOffset = y + 16;
StartSpriteAnim(sMenu->cursorSprite, ANIM_CURSOR);
2018-04-17 10:54:39 +02:00
}
else
{
2021-02-28 23:22:26 +01:00
sMenu->cursorSprite = NULL;
2018-04-17 10:54:39 +02:00
}
}
2021-02-28 23:22:26 +01:00
static void SpriteCB_Dummy(struct Sprite *sprite)
2018-04-17 10:54:39 +02:00
{
}
2021-02-28 23:22:26 +01:00
static void SpriteCB_Marking(struct Sprite *sprite)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
if (sMenu->markingsArray[sprite->sMarkingId])
StartSpriteAnim(sprite, 2 * sprite->sMarkingId + 1); // Set marking 'on'
2018-04-17 10:54:39 +02:00
else
2021-02-28 23:22:26 +01:00
StartSpriteAnim(sprite, 2 * sprite->sMarkingId); // Set marking 'off'
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
#undef sMarkingId
static void SpriteCB_Cursor(struct Sprite *sprite)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->sCursorYOffset;
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
#undef sCursorYOffset
// Creates a mon marking combination sprite with a spritesheet that holds every possible combination, used by the summary screen / Pokénav
struct Sprite *CreateMonMarkingAllCombosSprite(u16 tileTag, u16 paletteTag, const u16 *palette)
2018-04-17 10:54:39 +02:00
{
if (!palette)
2021-02-28 23:22:26 +01:00
palette = sMonMarkings_Pal;
return CreateMarkingComboSprite(tileTag, paletteTag, palette, 1 << NUM_MON_MARKINGS);
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
// Creates a mon marking combination sprite with a spritesheet that holds only one combination, used for the currently selected PC mon
struct Sprite *CreateMonMarkingComboSprite(u16 tileTag, u16 paletteTag, const u16 *palette)
2018-04-17 10:54:39 +02:00
{
if (!palette)
2021-02-28 23:22:26 +01:00
palette = sMonMarkings_Pal;
return CreateMarkingComboSprite(tileTag, paletteTag, palette, 1);
2018-04-17 10:54:39 +02:00
}
2021-02-28 23:22:26 +01:00
static struct Sprite *CreateMarkingComboSprite(u16 tileTag, u16 paletteTag, const u16 *palette, u16 size)
2018-04-17 10:54:39 +02:00
{
u8 spriteId;
2021-02-28 23:22:26 +01:00
struct SpriteTemplate template;
struct SpriteSheet sheet = { sMonMarkings_Gfx, 0x80, tileTag };
2018-04-17 10:54:39 +02:00
struct SpritePalette sprPalette = { palette, paletteTag };
2021-02-28 23:22:26 +01:00
template.tileTag = tileTag;
template.paletteTag = paletteTag;
template.oam = &sOamData_MarkingCombo;
template.anims = sAnims_MarkingCombo;
template.images = NULL;
template.affineAnims = gDummySpriteAffineAnimTable;
template.callback = SpriteCB_Dummy;
2018-04-17 10:54:39 +02:00
sheet.size = size * 0x80;
LoadSpriteSheet(&sheet);
LoadSpritePalette(&sprPalette);
2021-02-28 23:22:26 +01:00
spriteId = CreateSprite(&template, 0, 0, 0);
2018-11-28 21:08:22 +01:00
if (spriteId != MAX_SPRITES)
2018-04-17 10:54:39 +02:00
return &gSprites[spriteId];
else
return NULL;
}
2021-02-28 23:22:26 +01:00
// Update what combination is shown, used for sprites created with CreateMonMarkingComboSprite
void UpdateMonMarkingTiles(u8 markings, void *dest)
2018-04-17 10:54:39 +02:00
{
2021-02-28 23:22:26 +01:00
RequestDma3Copy(&sMonMarkings_Gfx[markings * 0x80], dest, 0x80, 0x10);
2018-04-17 10:54:39 +02:00
}