Merge pull request #1854 from GriffinRichards/constants-num-frames

Add MAX_MON_PIC_FRAMES, and trainer pic size constants
This commit is contained in:
GriffinR 2023-02-27 13:16:49 -05:00 committed by GitHub
commit 8d88a38561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 211 additions and 164 deletions

View File

@ -593,7 +593,7 @@ struct MonSpritesGfx
u8 *byte[MAX_BATTLERS_COUNT];
} sprites;
struct SpriteTemplate templates[MAX_BATTLERS_COUNT];
struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][4];
struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][MAX_MON_PIC_FRAMES];
u8 unusedArr[0x80];
u8 *barFontGfx;
void *unusedPtr;

View File

@ -260,6 +260,14 @@
#define MON_PIC_HEIGHT 64
#define MON_PIC_SIZE (MON_PIC_WIDTH * MON_PIC_HEIGHT / 2)
// Most pokemon have 2 frames (a default and an alternate for their animation).
// There are 4 exceptions:
// - Castform has 4 frames, 1 for each form
// - Deoxys has 2 frames, 1 for each form
// - Spinda has 1 frame, presumably to avoid the work of animating its spots
// - Unown has 1 frame, presumably to avoid the work of animating all 28 of its forms
#define MAX_MON_PIC_FRAMES 4
#define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2

View File

@ -7,6 +7,13 @@
#define MAX_TRAINER_ITEMS 4
#define TRAINER_PIC_WIDTH 64
#define TRAINER_PIC_HEIGHT 64
#define TRAINER_PIC_SIZE (TRAINER_PIC_WIDTH * TRAINER_PIC_HEIGHT / 2)
// Red and Leaf's back pics have 5 frames, but this is presumably irrelevant in the places this is used.
#define MAX_TRAINER_PIC_FRAMES 4
enum {
BATTLER_AFFINE_NORMAL,
BATTLER_AFFINE_EMERGE,

View File

@ -3023,7 +3023,7 @@ void AnimTask_LoadMusicNotesPals(u8 taskId)
for (i = 1; i < NUM_MUSIC_NOTE_PAL_TAGS; i++)
paletteNums[i] = AllocSpritePalette(ANIM_SPRITES_START - i);
gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000);
gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES);
LZDecompressWram(gBattleAnimSpritePal_MusicNotes2, gMonSpritesGfxPtr->buffer);
for (i = 0; i < NUM_MUSIC_NOTE_PAL_TAGS; i++)
LoadPalette(&gMonSpritesGfxPtr->buffer[i * 32], (u16)(OBJ_PLTT_ID(paletteNums[i])), PLTT_SIZE_4BPP);

View File

@ -2101,7 +2101,7 @@ u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16
u16 palette = AllocSpritePalette(sSpriteTemplates_MoveEffectMons[id].paletteTag);
if (gMonSpritesGfxPtr != NULL && gMonSpritesGfxPtr->buffer == NULL)
gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000);
gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES);
if (!isBackpic)
{
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), OBJ_PLTT_ID(palette), PLTT_SIZE_4BPP);

View File

@ -899,7 +899,7 @@ void AnimTask_GetBattleTerrain(u8 taskId)
void AnimTask_AllocBackupPalBuffer(u8 taskId)
{
gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000);
gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES);
DestroyAnimVisualTask(taskId);
}

View File

@ -48,68 +48,68 @@ const struct SpriteFrameImage gBattlerPicTable_OpponentRight[] =
const struct SpriteFrameImage gTrainerBackPicTable_Brendan[] =
{
gTrainerBackPic_Brendan, 0x0800,
gTrainerBackPic_Brendan + 0x0800, 0x0800,
gTrainerBackPic_Brendan + 0x1000, 0x0800,
gTrainerBackPic_Brendan + 0x1800, 0x0800,
gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_May[] =
{
gTrainerBackPic_May, 0x0800,
gTrainerBackPic_May + 0x0800, 0x0800,
gTrainerBackPic_May + 0x1000, 0x0800,
gTrainerBackPic_May + 0x1800, 0x0800,
gTrainerBackPic_May + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_May + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_May + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_May + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_Red[] =
{
gTrainerBackPic_Red, 0x0800,
gTrainerBackPic_Red + 0x0800, 0x0800,
gTrainerBackPic_Red + 0x1000, 0x0800,
gTrainerBackPic_Red + 0x1800, 0x0800,
gTrainerBackPic_Red + 0x2000, 0x0800,
gTrainerBackPic_Red + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_Red + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_Red + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_Red + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
gTrainerBackPic_Red + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_Leaf[] =
{
gTrainerBackPic_Leaf, 0x0800,
gTrainerBackPic_Leaf + 0x0800, 0x0800,
gTrainerBackPic_Leaf + 0x1000, 0x0800,
gTrainerBackPic_Leaf + 0x1800, 0x0800,
gTrainerBackPic_Leaf + 0x2000, 0x0800,
gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireBrendan[] =
{
gTrainerBackPic_RubySapphireBrendan, 0x0800,
gTrainerBackPic_RubySapphireBrendan + 0x0800, 0x0800,
gTrainerBackPic_RubySapphireBrendan + 0x1000, 0x0800,
gTrainerBackPic_RubySapphireBrendan + 0x1800, 0x0800,
gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireMay[] =
{
gTrainerBackPic_RubySapphireMay, 0x0800,
gTrainerBackPic_RubySapphireMay + 0x0800, 0x0800,
gTrainerBackPic_RubySapphireMay + 0x1000, 0x0800,
gTrainerBackPic_RubySapphireMay + 0x1800, 0x0800,
gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_Wally[] =
{
gTrainerBackPic_Wally, 0x0800,
gTrainerBackPic_Wally + 0x0800, 0x0800,
gTrainerBackPic_Wally + 0x1000, 0x0800,
gTrainerBackPic_Wally + 0x1800, 0x0800,
gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
const struct SpriteFrameImage gTrainerBackPicTable_Steven[] =
{
gTrainerBackPic_Steven, 0x0800,
gTrainerBackPic_Steven + 0x0800, 0x0800,
gTrainerBackPic_Steven + 0x1000, 0x0800,
gTrainerBackPic_Steven + 0x1800, 0x0800,
gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE,
gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE,
gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE,
gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE,
};
static const union AnimCmd sAnim_GeneralFrame0[] =
@ -290,7 +290,7 @@ static const union AnimCmd sAnim_MonPic_3[] =
ANIMCMD_END,
};
const union AnimCmd *const gAnims_MonPic[] =
const union AnimCmd *const gAnims_MonPic[MAX_MON_PIC_FRAMES] =
{
sAnim_MonPic_0,
sAnim_MonPic_1,

View File

@ -13,18 +13,48 @@ const struct MonCoords gTrainerBackPicCoords[] =
// this table goes functionally unused, since none of these pics are compressed
// and the place they would get extracted to gets overwritten later anyway
// the casts are so they'll play nice with the strict struct definition
#define TRAINER_BACK_SPRITE(trainerPic, sprite, size) [TRAINER_BACK_PIC_##trainerPic] = {(const u32 *)sprite, size, TRAINER_BACK_PIC_##trainerPic}
const struct CompressedSpriteSheet gTrainerBackPicTable[] =
{
TRAINER_BACK_SPRITE(BRENDAN, gTrainerBackPic_Brendan, 0x2000),
TRAINER_BACK_SPRITE(MAY, gTrainerBackPic_May, 0x2000),
TRAINER_BACK_SPRITE(RED, gTrainerBackPic_Red, 0x2800),
TRAINER_BACK_SPRITE(LEAF, gTrainerBackPic_Leaf, 0x2800),
TRAINER_BACK_SPRITE(RUBY_SAPPHIRE_BRENDAN, gTrainerBackPic_RubySapphireBrendan, 0x2000),
TRAINER_BACK_SPRITE(RUBY_SAPPHIRE_MAY, gTrainerBackPic_RubySapphireMay, 0x2000),
TRAINER_BACK_SPRITE(WALLY, gTrainerBackPic_Wally, 0x2000),
TRAINER_BACK_SPRITE(STEVEN, gTrainerBackPic_Steven, 0x2000),
[TRAINER_BACK_PIC_BRENDAN] = {
.data = (const u32 *)gTrainerBackPic_Brendan,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Brendan),
.tag = TRAINER_BACK_PIC_BRENDAN,
},
[TRAINER_BACK_PIC_MAY] = {
.data = (const u32 *)gTrainerBackPic_May,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_May),
.tag = TRAINER_BACK_PIC_MAY,
},
[TRAINER_BACK_PIC_RED] = {
.data = (const u32 *)gTrainerBackPic_Red,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Red),
.tag = TRAINER_BACK_PIC_RED,
},
[TRAINER_BACK_PIC_LEAF] = {
.data = (const u32 *)gTrainerBackPic_Leaf,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Leaf),
.tag = TRAINER_BACK_PIC_LEAF,
},
[TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN] = {
.data = (const u32 *)gTrainerBackPic_RubySapphireBrendan,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_RubySapphireBrendan),
.tag = TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN,
},
[TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY] = {
.data = (const u32 *)gTrainerBackPic_RubySapphireMay,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_RubySapphireMay),
.tag = TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY,
},
[TRAINER_BACK_PIC_WALLY] = {
.data = (const u32 *)gTrainerBackPic_Wally,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Wally),
.tag = TRAINER_BACK_PIC_WALLY,
},
[TRAINER_BACK_PIC_STEVEN] = {
.data = (const u32 *)gTrainerBackPic_Steven,
.size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Steven),
.tag = TRAINER_BACK_PIC_STEVEN,
},
};
#define TRAINER_BACK_PAL(trainerPic, pal) [TRAINER_BACK_PIC_##trainerPic] = {pal, TRAINER_BACK_PIC_##trainerPic}

View File

@ -99,99 +99,99 @@ const struct MonCoords gTrainerFrontPicCoords[] =
const struct CompressedSpriteSheet gTrainerFrontPicTable[] =
{
TRAINER_SPRITE(HIKER, gTrainerFrontPic_Hiker, 0x800),
TRAINER_SPRITE(AQUA_GRUNT_M, gTrainerFrontPic_AquaGruntM, 0x800),
TRAINER_SPRITE(POKEMON_BREEDER_F, gTrainerFrontPic_PokemonBreederF, 0x800),
TRAINER_SPRITE(COOLTRAINER_M, gTrainerFrontPic_CoolTrainerM, 0x800),
TRAINER_SPRITE(BIRD_KEEPER, gTrainerFrontPic_BirdKeeper, 0x800),
TRAINER_SPRITE(COLLECTOR, gTrainerFrontPic_Collector, 0x800),
TRAINER_SPRITE(AQUA_GRUNT_F, gTrainerFrontPic_AquaGruntF, 0x800),
TRAINER_SPRITE(SWIMMER_M, gTrainerFrontPic_SwimmerM, 0x800),
TRAINER_SPRITE(MAGMA_GRUNT_M, gTrainerFrontPic_MagmaGruntM, 0x800),
TRAINER_SPRITE(EXPERT_M, gTrainerFrontPic_ExpertM, 0x800),
TRAINER_SPRITE(AQUA_ADMIN_M, gTrainerFrontPic_AquaAdminM, 0x800),
TRAINER_SPRITE(BLACK_BELT, gTrainerFrontPic_BlackBelt, 0x800),
TRAINER_SPRITE(AQUA_ADMIN_F, gTrainerFrontPic_AquaAdminF, 0x800),
TRAINER_SPRITE(AQUA_LEADER_ARCHIE, gTrainerFrontPic_AquaLeaderArchie, 0x800),
TRAINER_SPRITE(HEX_MANIAC, gTrainerFrontPic_HexManiac, 0x800),
TRAINER_SPRITE(AROMA_LADY, gTrainerFrontPic_AromaLady, 0x800),
TRAINER_SPRITE(RUIN_MANIAC, gTrainerFrontPic_RuinManiac, 0x800),
TRAINER_SPRITE(INTERVIEWER, gTrainerFrontPic_Interviewer, 0x800),
TRAINER_SPRITE(TUBER_F, gTrainerFrontPic_TuberF, 0x800),
TRAINER_SPRITE(TUBER_M, gTrainerFrontPic_TuberM, 0x800),
TRAINER_SPRITE(COOLTRAINER_F, gTrainerFrontPic_CoolTrainerF, 0x800),
TRAINER_SPRITE(LADY, gTrainerFrontPic_Lady, 0x800),
TRAINER_SPRITE(BEAUTY, gTrainerFrontPic_Beauty, 0x800),
TRAINER_SPRITE(RICH_BOY, gTrainerFrontPic_RichBoy, 0x800),
TRAINER_SPRITE(EXPERT_F, gTrainerFrontPic_ExpertF, 0x800),
TRAINER_SPRITE(POKEMANIAC, gTrainerFrontPic_Pokemaniac, 0x800),
TRAINER_SPRITE(MAGMA_GRUNT_F, gTrainerFrontPic_MagmaGruntF, 0x800),
TRAINER_SPRITE(GUITARIST, gTrainerFrontPic_Guitarist, 0x800),
TRAINER_SPRITE(KINDLER, gTrainerFrontPic_Kindler, 0x800),
TRAINER_SPRITE(CAMPER, gTrainerFrontPic_Camper, 0x800),
TRAINER_SPRITE(PICNICKER, gTrainerFrontPic_Picnicker, 0x800),
TRAINER_SPRITE(BUG_MANIAC, gTrainerFrontPic_BugManiac, 0x800),
TRAINER_SPRITE(POKEMON_BREEDER_M, gTrainerFrontPic_PokemonBreederM, 0x800),
TRAINER_SPRITE(PSYCHIC_M, gTrainerFrontPic_PsychicM, 0x800),
TRAINER_SPRITE(PSYCHIC_F, gTrainerFrontPic_PsychicF, 0x800),
TRAINER_SPRITE(GENTLEMAN, gTrainerFrontPic_Gentleman, 0x800),
TRAINER_SPRITE(ELITE_FOUR_SIDNEY, gTrainerFrontPic_EliteFourSidney, 0x800),
TRAINER_SPRITE(ELITE_FOUR_PHOEBE, gTrainerFrontPic_EliteFourPhoebe, 0x800),
TRAINER_SPRITE(ELITE_FOUR_GLACIA, gTrainerFrontPic_EliteFourGlacia, 0x800),
TRAINER_SPRITE(ELITE_FOUR_DRAKE, gTrainerFrontPic_EliteFourDrake, 0x800),
TRAINER_SPRITE(LEADER_ROXANNE, gTrainerFrontPic_LeaderRoxanne, 0x800),
TRAINER_SPRITE(LEADER_BRAWLY, gTrainerFrontPic_LeaderBrawly, 0x800),
TRAINER_SPRITE(LEADER_WATTSON, gTrainerFrontPic_LeaderWattson, 0x800),
TRAINER_SPRITE(LEADER_FLANNERY, gTrainerFrontPic_LeaderFlannery, 0x800),
TRAINER_SPRITE(LEADER_NORMAN, gTrainerFrontPic_LeaderNorman, 0x800),
TRAINER_SPRITE(LEADER_WINONA, gTrainerFrontPic_LeaderWinona, 0x800),
TRAINER_SPRITE(LEADER_TATE_AND_LIZA, gTrainerFrontPic_LeaderTateAndLiza, 0x800),
TRAINER_SPRITE(LEADER_JUAN, gTrainerFrontPic_LeaderJuan, 0x800),
TRAINER_SPRITE(SCHOOL_KID_M, gTrainerFrontPic_SchoolKidM, 0x800),
TRAINER_SPRITE(SCHOOL_KID_F, gTrainerFrontPic_SchoolKidF, 0x800),
TRAINER_SPRITE(SR_AND_JR, gTrainerFrontPic_SrAndJr, 0x1000),
TRAINER_SPRITE(POKEFAN_M, gTrainerFrontPic_PokefanM, 0x1000),
TRAINER_SPRITE(POKEFAN_F, gTrainerFrontPic_PokefanF, 0x800),
TRAINER_SPRITE(YOUNGSTER, gTrainerFrontPic_Youngster, 0x800),
TRAINER_SPRITE(CHAMPION_WALLACE, gTrainerFrontPic_ChampionWallace, 0x1000),
TRAINER_SPRITE(FISHERMAN, gTrainerFrontPic_Fisherman, 0x800),
TRAINER_SPRITE(CYCLING_TRIATHLETE_M, gTrainerFrontPic_CyclingTriathleteM, 0x1000),
TRAINER_SPRITE(CYCLING_TRIATHLETE_F, gTrainerFrontPic_CyclingTriathleteF, 0x800),
TRAINER_SPRITE(RUNNING_TRIATHLETE_M, gTrainerFrontPic_RunningTriathleteM, 0x800),
TRAINER_SPRITE(RUNNING_TRIATHLETE_F, gTrainerFrontPic_RunningTriathleteF, 0x800),
TRAINER_SPRITE(SWIMMING_TRIATHLETE_M, gTrainerFrontPic_SwimmingTriathleteM, 0x800),
TRAINER_SPRITE(SWIMMING_TRIATHLETE_F, gTrainerFrontPic_SwimmingTriathleteF, 0x800),
TRAINER_SPRITE(DRAGON_TAMER, gTrainerFrontPic_DragonTamer, 0x800),
TRAINER_SPRITE(NINJA_BOY, gTrainerFrontPic_NinjaBoy, 0x800),
TRAINER_SPRITE(BATTLE_GIRL, gTrainerFrontPic_BattleGirl, 0x1000),
TRAINER_SPRITE(PARASOL_LADY, gTrainerFrontPic_ParasolLady, 0x800),
TRAINER_SPRITE(SWIMMER_F, gTrainerFrontPic_SwimmerF, 0x800),
TRAINER_SPRITE(TWINS, gTrainerFrontPic_Twins, 0x800),
TRAINER_SPRITE(SAILOR, gTrainerFrontPic_Sailor, 0x800),
TRAINER_SPRITE(MAGMA_ADMIN, gTrainerFrontPic_MagmaAdmin, 0x800),
TRAINER_SPRITE(WALLY, gTrainerFrontPic_Wally, 0x800),
TRAINER_SPRITE(BRENDAN, gTrainerFrontPic_Brendan, 0x800),
TRAINER_SPRITE(MAY, gTrainerFrontPic_May, 0x800),
TRAINER_SPRITE(BUG_CATCHER, gTrainerFrontPic_BugCatcher, 0x800),
TRAINER_SPRITE(POKEMON_RANGER_M, gTrainerFrontPic_PokemonRangerM, 0x800),
TRAINER_SPRITE(POKEMON_RANGER_F, gTrainerFrontPic_PokemonRangerF, 0x800),
TRAINER_SPRITE(MAGMA_LEADER_MAXIE, gTrainerFrontPic_MagmaLeaderMaxie, 0x800),
TRAINER_SPRITE(LASS, gTrainerFrontPic_Lass, 0x800),
TRAINER_SPRITE(YOUNG_COUPLE, gTrainerFrontPic_YoungCouple, 0x800),
TRAINER_SPRITE(OLD_COUPLE, gTrainerFrontPic_OldCouple, 0x800),
TRAINER_SPRITE(SIS_AND_BRO, gTrainerFrontPic_SisAndBro, 0x800),
TRAINER_SPRITE(STEVEN, gTrainerFrontPic_Steven, 0x800),
TRAINER_SPRITE(SALON_MAIDEN_ANABEL, gTrainerFrontPic_SalonMaidenAnabel, 0x800),
TRAINER_SPRITE(DOME_ACE_TUCKER, gTrainerFrontPic_DomeAceTucker, 0x800),
TRAINER_SPRITE(PALACE_MAVEN_SPENSER, gTrainerFrontPic_PalaceMavenSpenser, 0x800),
TRAINER_SPRITE(ARENA_TYCOON_GRETA, gTrainerFrontPic_ArenaTycoonGreta, 0x1000),
TRAINER_SPRITE(FACTORY_HEAD_NOLAND, gTrainerFrontPic_FactoryHeadNoland, 0x800),
TRAINER_SPRITE(PIKE_QUEEN_LUCY, gTrainerFrontPic_PikeQueenLucy, 0x800),
TRAINER_SPRITE(PYRAMID_KING_BRANDON, gTrainerFrontPic_PyramidKingBrandon, 0x800),
TRAINER_SPRITE(RED, gTrainerFrontPic_Red, 0x800),
TRAINER_SPRITE(LEAF, gTrainerFrontPic_Leaf, 0x800),
TRAINER_SPRITE(RS_BRENDAN, gTrainerFrontPic_RubySapphireBrendan, 0x800),
TRAINER_SPRITE(RS_MAY, gTrainerFrontPic_RubySapphireMay, 0x800),
TRAINER_SPRITE(HIKER, gTrainerFrontPic_Hiker, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AQUA_GRUNT_M, gTrainerFrontPic_AquaGruntM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(POKEMON_BREEDER_F, gTrainerFrontPic_PokemonBreederF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(COOLTRAINER_M, gTrainerFrontPic_CoolTrainerM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BIRD_KEEPER, gTrainerFrontPic_BirdKeeper, TRAINER_PIC_SIZE),
TRAINER_SPRITE(COLLECTOR, gTrainerFrontPic_Collector, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AQUA_GRUNT_F, gTrainerFrontPic_AquaGruntF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SWIMMER_M, gTrainerFrontPic_SwimmerM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(MAGMA_GRUNT_M, gTrainerFrontPic_MagmaGruntM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(EXPERT_M, gTrainerFrontPic_ExpertM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AQUA_ADMIN_M, gTrainerFrontPic_AquaAdminM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BLACK_BELT, gTrainerFrontPic_BlackBelt, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AQUA_ADMIN_F, gTrainerFrontPic_AquaAdminF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AQUA_LEADER_ARCHIE, gTrainerFrontPic_AquaLeaderArchie, TRAINER_PIC_SIZE),
TRAINER_SPRITE(HEX_MANIAC, gTrainerFrontPic_HexManiac, TRAINER_PIC_SIZE),
TRAINER_SPRITE(AROMA_LADY, gTrainerFrontPic_AromaLady, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RUIN_MANIAC, gTrainerFrontPic_RuinManiac, TRAINER_PIC_SIZE),
TRAINER_SPRITE(INTERVIEWER, gTrainerFrontPic_Interviewer, TRAINER_PIC_SIZE),
TRAINER_SPRITE(TUBER_F, gTrainerFrontPic_TuberF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(TUBER_M, gTrainerFrontPic_TuberM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(COOLTRAINER_F, gTrainerFrontPic_CoolTrainerF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LADY, gTrainerFrontPic_Lady, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BEAUTY, gTrainerFrontPic_Beauty, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RICH_BOY, gTrainerFrontPic_RichBoy, TRAINER_PIC_SIZE),
TRAINER_SPRITE(EXPERT_F, gTrainerFrontPic_ExpertF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(POKEMANIAC, gTrainerFrontPic_Pokemaniac, TRAINER_PIC_SIZE),
TRAINER_SPRITE(MAGMA_GRUNT_F, gTrainerFrontPic_MagmaGruntF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(GUITARIST, gTrainerFrontPic_Guitarist, TRAINER_PIC_SIZE),
TRAINER_SPRITE(KINDLER, gTrainerFrontPic_Kindler, TRAINER_PIC_SIZE),
TRAINER_SPRITE(CAMPER, gTrainerFrontPic_Camper, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PICNICKER, gTrainerFrontPic_Picnicker, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BUG_MANIAC, gTrainerFrontPic_BugManiac, TRAINER_PIC_SIZE),
TRAINER_SPRITE(POKEMON_BREEDER_M, gTrainerFrontPic_PokemonBreederM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PSYCHIC_M, gTrainerFrontPic_PsychicM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PSYCHIC_F, gTrainerFrontPic_PsychicF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(GENTLEMAN, gTrainerFrontPic_Gentleman, TRAINER_PIC_SIZE),
TRAINER_SPRITE(ELITE_FOUR_SIDNEY, gTrainerFrontPic_EliteFourSidney, TRAINER_PIC_SIZE),
TRAINER_SPRITE(ELITE_FOUR_PHOEBE, gTrainerFrontPic_EliteFourPhoebe, TRAINER_PIC_SIZE),
TRAINER_SPRITE(ELITE_FOUR_GLACIA, gTrainerFrontPic_EliteFourGlacia, TRAINER_PIC_SIZE),
TRAINER_SPRITE(ELITE_FOUR_DRAKE, gTrainerFrontPic_EliteFourDrake, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_ROXANNE, gTrainerFrontPic_LeaderRoxanne, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_BRAWLY, gTrainerFrontPic_LeaderBrawly, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_WATTSON, gTrainerFrontPic_LeaderWattson, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_FLANNERY, gTrainerFrontPic_LeaderFlannery, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_NORMAN, gTrainerFrontPic_LeaderNorman, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_WINONA, gTrainerFrontPic_LeaderWinona, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_TATE_AND_LIZA, gTrainerFrontPic_LeaderTateAndLiza, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEADER_JUAN, gTrainerFrontPic_LeaderJuan, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SCHOOL_KID_M, gTrainerFrontPic_SchoolKidM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SCHOOL_KID_F, gTrainerFrontPic_SchoolKidF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SR_AND_JR, gTrainerFrontPic_SrAndJr, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(POKEFAN_M, gTrainerFrontPic_PokefanM, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(POKEFAN_F, gTrainerFrontPic_PokefanF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(YOUNGSTER, gTrainerFrontPic_Youngster, TRAINER_PIC_SIZE),
TRAINER_SPRITE(CHAMPION_WALLACE, gTrainerFrontPic_ChampionWallace, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(FISHERMAN, gTrainerFrontPic_Fisherman, TRAINER_PIC_SIZE),
TRAINER_SPRITE(CYCLING_TRIATHLETE_M, gTrainerFrontPic_CyclingTriathleteM, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(CYCLING_TRIATHLETE_F, gTrainerFrontPic_CyclingTriathleteF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RUNNING_TRIATHLETE_M, gTrainerFrontPic_RunningTriathleteM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RUNNING_TRIATHLETE_F, gTrainerFrontPic_RunningTriathleteF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SWIMMING_TRIATHLETE_M, gTrainerFrontPic_SwimmingTriathleteM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SWIMMING_TRIATHLETE_F, gTrainerFrontPic_SwimmingTriathleteF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(DRAGON_TAMER, gTrainerFrontPic_DragonTamer, TRAINER_PIC_SIZE),
TRAINER_SPRITE(NINJA_BOY, gTrainerFrontPic_NinjaBoy, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BATTLE_GIRL, gTrainerFrontPic_BattleGirl, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(PARASOL_LADY, gTrainerFrontPic_ParasolLady, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SWIMMER_F, gTrainerFrontPic_SwimmerF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(TWINS, gTrainerFrontPic_Twins, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SAILOR, gTrainerFrontPic_Sailor, TRAINER_PIC_SIZE),
TRAINER_SPRITE(MAGMA_ADMIN, gTrainerFrontPic_MagmaAdmin, TRAINER_PIC_SIZE),
TRAINER_SPRITE(WALLY, gTrainerFrontPic_Wally, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BRENDAN, gTrainerFrontPic_Brendan, TRAINER_PIC_SIZE),
TRAINER_SPRITE(MAY, gTrainerFrontPic_May, TRAINER_PIC_SIZE),
TRAINER_SPRITE(BUG_CATCHER, gTrainerFrontPic_BugCatcher, TRAINER_PIC_SIZE),
TRAINER_SPRITE(POKEMON_RANGER_M, gTrainerFrontPic_PokemonRangerM, TRAINER_PIC_SIZE),
TRAINER_SPRITE(POKEMON_RANGER_F, gTrainerFrontPic_PokemonRangerF, TRAINER_PIC_SIZE),
TRAINER_SPRITE(MAGMA_LEADER_MAXIE, gTrainerFrontPic_MagmaLeaderMaxie, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LASS, gTrainerFrontPic_Lass, TRAINER_PIC_SIZE),
TRAINER_SPRITE(YOUNG_COUPLE, gTrainerFrontPic_YoungCouple, TRAINER_PIC_SIZE),
TRAINER_SPRITE(OLD_COUPLE, gTrainerFrontPic_OldCouple, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SIS_AND_BRO, gTrainerFrontPic_SisAndBro, TRAINER_PIC_SIZE),
TRAINER_SPRITE(STEVEN, gTrainerFrontPic_Steven, TRAINER_PIC_SIZE),
TRAINER_SPRITE(SALON_MAIDEN_ANABEL, gTrainerFrontPic_SalonMaidenAnabel, TRAINER_PIC_SIZE),
TRAINER_SPRITE(DOME_ACE_TUCKER, gTrainerFrontPic_DomeAceTucker, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PALACE_MAVEN_SPENSER, gTrainerFrontPic_PalaceMavenSpenser, TRAINER_PIC_SIZE),
TRAINER_SPRITE(ARENA_TYCOON_GRETA, gTrainerFrontPic_ArenaTycoonGreta, TRAINER_PIC_SIZE * 2),
TRAINER_SPRITE(FACTORY_HEAD_NOLAND, gTrainerFrontPic_FactoryHeadNoland, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PIKE_QUEEN_LUCY, gTrainerFrontPic_PikeQueenLucy, TRAINER_PIC_SIZE),
TRAINER_SPRITE(PYRAMID_KING_BRANDON, gTrainerFrontPic_PyramidKingBrandon, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RED, gTrainerFrontPic_Red, TRAINER_PIC_SIZE),
TRAINER_SPRITE(LEAF, gTrainerFrontPic_Leaf, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RS_BRENDAN, gTrainerFrontPic_RubySapphireBrendan, TRAINER_PIC_SIZE),
TRAINER_SPRITE(RS_MAY, gTrainerFrontPic_RubySapphireMay, TRAINER_PIC_SIZE),
};
#define TRAINER_PAL(trainerPic, pal) [TRAINER_PIC_##trainerPic] = {pal, TRAINER_PIC_##trainerPic}

View File

@ -6928,8 +6928,6 @@ static bool8 ShouldSkipFriendshipChange(void)
#define ALLOC_FAIL_BUFFER (1 << 0)
#define ALLOC_FAIL_STRUCT (1 << 1)
#define GFX_MANAGER_ACTIVE 0xA3 // Arbitrary value
#define GFX_MANAGER_SPR_SIZE (MON_PIC_SIZE * 4) // Only Castform uses more than MON_PIC_SIZE, despite not displaying its forms.
#define GFX_MANAGER_NUM_FRAMES 4 // Only 2 frames are needed
static void InitMonSpritesGfx_Battle(struct MonSpritesGfxManager* gfx)
{
@ -6976,7 +6974,7 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode)
case MON_SPR_GFX_MODE_FULL_PARTY:
gfx->numSprites = PARTY_SIZE + 1;
gfx->numSprites2 = PARTY_SIZE + 1;
gfx->numFrames = GFX_MANAGER_NUM_FRAMES;
gfx->numFrames = MAX_MON_PIC_FRAMES;
gfx->dataSize = 1;
gfx->mode = MON_SPR_GFX_MODE_FULL_PARTY;
break;
@ -6985,14 +6983,14 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode)
default:
gfx->numSprites = MAX_BATTLERS_COUNT;
gfx->numSprites2 = MAX_BATTLERS_COUNT;
gfx->numFrames = GFX_MANAGER_NUM_FRAMES;
gfx->numFrames = MAX_MON_PIC_FRAMES;
gfx->dataSize = 1;
gfx->mode = MON_SPR_GFX_MODE_NORMAL;
break;
}
// Set up sprite / sprite pointer buffers
gfx->spriteBuffer = AllocZeroed(gfx->dataSize * GFX_MANAGER_SPR_SIZE * gfx->numSprites);
gfx->spriteBuffer = AllocZeroed(gfx->dataSize * MON_PIC_SIZE * MAX_MON_PIC_FRAMES * gfx->numSprites);
gfx->spritePointers = AllocZeroed(gfx->numSprites * 32); // ? Only * 4 is necessary, perhaps they were thinking bits.
if (gfx->spriteBuffer == NULL || gfx->spritePointers == NULL)
{
@ -7001,7 +6999,7 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode)
else
{
for (i = 0; i < gfx->numSprites; i++)
gfx->spritePointers[i] = gfx->spriteBuffer + (gfx->dataSize * GFX_MANAGER_SPR_SIZE * i);
gfx->spritePointers[i] = gfx->spriteBuffer + (gfx->dataSize * MON_PIC_SIZE * MAX_MON_PIC_FRAMES * i);
}
// Set up sprite structs

View File

@ -2714,7 +2714,7 @@ static void CreateJumpMonSprite(struct PokemonJumpGfx *jumpGfx, struct PokemonJu
u8 spriteId;
spriteTemplate = sSpriteTemplate_JumpMon;
buffer = Alloc(0x2000);
buffer = Alloc(MON_PIC_SIZE * MAX_MON_PIC_FRAMES);
unusedBuffer = Alloc(MON_PIC_SIZE);
if (multiplayerId == GetPokeJumpMultiplayerId())
subpriority = 3;

View File

@ -550,7 +550,7 @@ struct PokemonStorageSystemData
u16 *displayMonTilePtr;
struct Sprite *displayMonSprite;
u16 displayMonPalBuffer[0x40];
u8 tileBuffer[MON_PIC_SIZE * 4]; // 4x the size of a 'Mon sprite to account for Castform
u8 tileBuffer[MON_PIC_SIZE * MAX_MON_PIC_FRAMES];
u8 itemIconBuffer[0x800];
u8 wallpaperBgTilemapBuffer[0x1000];
u8 displayMenuTilemapBuffer[0x800];

View File

@ -49,7 +49,7 @@ struct Pokenav_MatchCallGfx
u8 unusedTilemapBuffer[BG_SCREEN_SIZE];
u8 bgTilemapBuffer2[BG_SCREEN_SIZE];
u8 *trainerPicGfxPtr;
u8 trainerPicGfx[0x800];
u8 trainerPicGfx[TRAINER_PIC_SIZE];
u8 trainerPicPal[0x20];
};

View File

@ -9,6 +9,12 @@
#include "pokemon.h"
#include "constants/trainers.h"
#define PICS_COUNT 8
// Needs to be large enough to store either a decompressed pokemon pic or trainer pic
#define PIC_SPRITE_SIZE max(MON_PIC_SIZE, TRAINER_PIC_SIZE)
#define MAX_PIC_FRAMES max(MAX_MON_PIC_FRAMES, MAX_TRAINER_PIC_FRAMES)
struct PicData
{
u8 *frames;
@ -18,8 +24,6 @@ struct PicData
u8 active;
};
#define PICS_COUNT 8
static EWRAM_DATA struct SpriteTemplate sCreatingSpriteTemplate = {};
static EWRAM_DATA struct PicData sSpritePics[PICS_COUNT] = {};
@ -149,11 +153,11 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront
if (i == PICS_COUNT)
return 0xFFFF;
framePics = Alloc(4 * 0x800);
framePics = Alloc(PIC_SPRITE_SIZE * MAX_PIC_FRAMES);
if (!framePics)
return 0xFFFF;
images = Alloc(4 * sizeof(struct SpriteFrameImage));
images = Alloc(sizeof(struct SpriteFrameImage) * MAX_PIC_FRAMES);
if (!images)
{
Free(framePics);
@ -164,10 +168,10 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront
// debug trap?
return 0xFFFF;
}
for (j = 0; j < 4; j ++)
for (j = 0; j < MAX_PIC_FRAMES; j ++)
{
images[j].data = framePics + 0x800 * j;
images[j].size = 0x800;
images[j].data = framePics + PIC_SPRITE_SIZE * j;
images[j].size = PIC_SPRITE_SIZE;
}
sCreatingSpriteTemplate.tileTag = TAG_NONE;
sCreatingSpriteTemplate.oam = &sOamData_Normal;
@ -209,7 +213,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags,
if (i == PICS_COUNT)
return 0xFFFF;
framePics = Alloc(4 * MON_PIC_SIZE);
framePics = Alloc(MON_PIC_SIZE * MAX_MON_PIC_FRAMES);
if (!framePics)
return 0xFFFF;
@ -222,7 +226,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags,
{
type = flags;
}
images = Alloc(4 * sizeof(struct SpriteFrameImage));
images = Alloc(sizeof(struct SpriteFrameImage) * MAX_MON_PIC_FRAMES);
if (!images)
{
Free(framePics);
@ -233,7 +237,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags,
// debug trap?
return 0xFFFF;
}
for (j = 0; j < 4; j ++)
for (j = 0; j < MAX_MON_PIC_FRAMES; j ++)
{
images[j].data = framePics + MON_PIC_SIZE * j;
images[j].size = MON_PIC_SIZE;
@ -307,10 +311,10 @@ static u16 CreateTrainerCardSprite(u16 species, u32 otId, u32 personality, bool8
{
u8 *framePics;
framePics = Alloc(4 * 0x800);
framePics = Alloc(TRAINER_PIC_SIZE * MAX_TRAINER_PIC_FRAMES);
if (framePics && !DecompressPic_HandleDeoxys(species, personality, isFrontPic, framePics, isTrainer))
{
BlitBitmapRectToWindow(windowId, framePics, 0, 0, 0x40, 0x40, destX, destY, 0x40, 0x40);
BlitBitmapRectToWindow(windowId, framePics, 0, 0, TRAINER_PIC_WIDTH, TRAINER_PIC_HEIGHT, destX, destY, TRAINER_PIC_WIDTH, TRAINER_PIC_HEIGHT);
LoadPicPaletteBySlot(species, otId, personality, paletteSlot, isTrainer);
Free(framePics);
return 0;

View File

@ -88,7 +88,7 @@ struct UsePokeblockMenu
{
u32 unused;
u16 partyPalettes[PARTY_SIZE][0x40];
u8 partySheets[NUM_SELECTIONS_LOADED][0x2000];
u8 partySheets[NUM_SELECTIONS_LOADED][MON_PIC_SIZE * MAX_MON_PIC_FRAMES];
u8 unusedBuffer[0x1000];
u8 tilemapBuffer[BG_SCREEN_SIZE + 2];
u8 selectionIconSpriteIds[PARTY_SIZE + 1];