From 60e1ad20e4a9c27c53a1e6e2416b995b50d52744 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 10 Oct 2022 22:07:34 -0400 Subject: [PATCH 01/19] Add NUM_MON_PIC_FRAMES, and trainer pic size constants --- include/battle.h | 2 +- include/constants/pokemon.h | 8 + include/data.h | 6 + src/battle_anim_effects_2.c | 2 +- src/battle_anim_mons.c | 2 +- src/battle_anim_utility_funcs.c | 2 +- src/data.c | 70 +++---- src/data/trainer_graphics/back_pic_tables.h | 50 ++++- src/data/trainer_graphics/front_pic_tables.h | 186 +++++++++---------- src/pokemon.c | 10 +- src/pokemon_jump.c | 2 +- src/pokemon_storage_system.c | 2 +- src/pokenav_conditions.c | 2 +- src/pokenav_match_call_gfx.c | 2 +- src/trainer_pokemon_sprites.c | 28 +-- src/use_pokeblock.c | 2 +- 16 files changed, 211 insertions(+), 165 deletions(-) diff --git a/include/battle.h b/include/battle.h index e779dee3df..aa9acac3cb 100644 --- a/include/battle.h +++ b/include/battle.h @@ -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; diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index d0e6094483..716d5adf9d 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -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 diff --git a/include/data.h b/include/data.h index 0cd87fc99a..732fda992c 100644 --- a/include/data.h +++ b/include/data.h @@ -7,6 +7,12 @@ #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) + +#define MAX_TRAINER_PIC_FRAMES 4 // ? Red and Leaf's back pics have 5 frames + enum { BATTLER_AFFINE_NORMAL, BATTLER_AFFINE_EMERGE, diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 6b60440528..7efa2e9edd 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -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)((paletteNums[i] << 4) + 0x100), 32); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index a5d4659a9d..ba493ed189 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -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), (palette * 0x10) + 0x100, 0x20); diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index 403939f883..cae9eb7d5f 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -905,7 +905,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); } diff --git a/src/data.c b/src/data.c index 5856d17b85..d3674c2886 100644 --- a/src/data.c +++ b/src/data.c @@ -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, diff --git a/src/data/trainer_graphics/back_pic_tables.h b/src/data/trainer_graphics/back_pic_tables.h index 1dbffba428..524d48d480 100644 --- a/src/data/trainer_graphics/back_pic_tables.h +++ b/src/data/trainer_graphics/back_pic_tables.h @@ -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} diff --git a/src/data/trainer_graphics/front_pic_tables.h b/src/data/trainer_graphics/front_pic_tables.h index e751f3c1d2..dd4aa26de0 100644 --- a/src/data/trainer_graphics/front_pic_tables.h +++ b/src/data/trainer_graphics/front_pic_tables.h @@ -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} diff --git a/src/pokemon.c b/src/pokemon.c index b65f97bd85..0b4e6465bb 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -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 diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4f2a14fdf0..e9397a08e8 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -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; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 9a9e551a2a..a879cd4c89 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -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]; diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index e0645bac0b..e7269ae835 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -19,7 +19,7 @@ struct Pokenav_ConditionMenu { u32 monPal[CONDITION_MONS_LOADED][0x20]; u8 fill[0x180]; - u32 monPicGfx[CONDITION_MONS_LOADED][MON_PIC_SIZE]; + u32 monPicGfx[CONDITION_MONS_LOADED][MON_PIC_SIZE]; // TODO: Is this too small? bool8 inSearchMode; s16 toLoadListIndex; u32 (*callback)(struct Pokenav_ConditionMenu *); diff --git a/src/pokenav_match_call_gfx.c b/src/pokenav_match_call_gfx.c index fd5b36fae0..c207e3826c 100755 --- a/src/pokenav_match_call_gfx.c +++ b/src/pokenav_match_call_gfx.c @@ -49,7 +49,7 @@ struct Pokenav_MatchCallGfx u8 unusedTilemapBuffer[BG_SCREEN_SIZE]; u8 bgTilemapBuffer2[BG_SCREEN_SIZE]; u8 *trainerPicGfxPtr; - u8 trainerPicGfx[0x800]; + u8 trainerPicGfx[0x800]; // TODO u8 trainerPicPal[0x20]; }; diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c index a7289677e6..2ef8a7cff1 100644 --- a/src/trainer_pokemon_sprites.c +++ b/src/trainer_pokemon_sprites.c @@ -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; diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 2f16f220aa..37e75bc4e9 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -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]; From 5793a1a5e7865cd2a70706501c6ed801705b7fe3 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 2 Feb 2023 00:09:53 -0500 Subject: [PATCH 02/19] Correct some union room chat documentation --- ..._palette2.pal => chat_messages_window.pal} | 0 .../{window_1.pal => input_text.pal} | 0 .../{border.bin => keyboard.bin} | Bin .../{border.png => keyboard.png} | Bin graphics/union_room_chat/r_button.png | Bin 188 -> 177 bytes .../{unk_palette1.pal => unused.pal} | 0 graphics/union_room_chat/window_2.pal | 19 --- include/graphics.h | 8 +- src/graphics.c | 8 +- src/union_room_chat.c | 158 ++++++++++-------- 10 files changed, 94 insertions(+), 99 deletions(-) rename graphics/union_room_chat/{unk_palette2.pal => chat_messages_window.pal} (100%) rename graphics/union_room_chat/{window_1.pal => input_text.pal} (100%) rename graphics/union_room_chat/{border.bin => keyboard.bin} (100%) rename graphics/union_room_chat/{border.png => keyboard.png} (100%) rename graphics/union_room_chat/{unk_palette1.pal => unused.pal} (100%) delete mode 100644 graphics/union_room_chat/window_2.pal diff --git a/graphics/union_room_chat/unk_palette2.pal b/graphics/union_room_chat/chat_messages_window.pal similarity index 100% rename from graphics/union_room_chat/unk_palette2.pal rename to graphics/union_room_chat/chat_messages_window.pal diff --git a/graphics/union_room_chat/window_1.pal b/graphics/union_room_chat/input_text.pal similarity index 100% rename from graphics/union_room_chat/window_1.pal rename to graphics/union_room_chat/input_text.pal diff --git a/graphics/union_room_chat/border.bin b/graphics/union_room_chat/keyboard.bin similarity index 100% rename from graphics/union_room_chat/border.bin rename to graphics/union_room_chat/keyboard.bin diff --git a/graphics/union_room_chat/border.png b/graphics/union_room_chat/keyboard.png similarity index 100% rename from graphics/union_room_chat/border.png rename to graphics/union_room_chat/keyboard.png diff --git a/graphics/union_room_chat/r_button.png b/graphics/union_room_chat/r_button.png index 168a293f35474ee97ea6a9ed3754d59a6b5c978f..06079ca2113a79e665b763c48c086075818cf5ad 100644 GIT binary patch delta 123 zcmdnPxRFt@Gr-TCmrII^fq{Y7)59eQNDF{43p0>>d-qY$L`C~R8&4O<5RRF(y$3lN z3^HM^k*qXReihuNE+> WXz3gaE13i`mBG{1&t;ucLK6TA3MyOx delta 134 zcmdnUxQ9`(Gr-TCmrII^fq{Y7)59eQNOJ(O0t+*cyn9dO@kB-Y7#}JO0sl69D z84Nj`?=JYwFK+GVEj}S8=vOIQ4NIrtqD+a@$+LvGe)50hm~p60=bFvN>Eh;p7(^%h kZJiPzv9Ce4QhK)Cgm*f}KJN&=3pAR+)78&qol`;+056*@5dZ)H diff --git a/graphics/union_room_chat/unk_palette1.pal b/graphics/union_room_chat/unused.pal similarity index 100% rename from graphics/union_room_chat/unk_palette1.pal rename to graphics/union_room_chat/unused.pal diff --git a/graphics/union_room_chat/window_2.pal b/graphics/union_room_chat/window_2.pal deleted file mode 100644 index a8c95a3c04..0000000000 --- a/graphics/union_room_chat/window_2.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -156 197 98 -41 131 222 -0 82 172 -197 255 106 -172 230 49 -246 246 213 -255 49 49 -255 148 148 -131 164 213 -238 238 90 -65 65 65 -115 115 115 -172 172 172 -230 230 255 -0 0 0 -255 255 255 diff --git a/include/graphics.h b/include/graphics.h index 45dd9175de..135eaa95e3 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4992,10 +4992,10 @@ extern const u32 gUsePokeblockCondition_Gfx[]; extern const u16 gUnionRoomChat_Background_Pal[]; extern const u32 gUnionRoomChat_Background_Gfx[]; extern const u32 gUnionRoomChat_Background_Tilemap[]; -extern const u16 gUnionRoomChat_Window_Pal1[]; -extern const u16 gUnionRoomChat_Window_Pal2[]; -extern const u32 gUnionRoomChat_Border_Gfx[]; -extern const u32 gUnionRoomChat_Border_Tilemap[]; +extern const u16 gUnionRoomChat_InputText_Pal[]; +extern const u16 gUnionRoomChat_Keyboard_Pal[]; +extern const u32 gUnionRoomChat_Keyboard_Gfx[]; +extern const u32 gUnionRoomChat_Keyboard_Tilemap[]; extern const u32 gUnionRoomChat_RButtonLabels[]; // Use Pokeblock diff --git a/src/graphics.c b/src/graphics.c index e0045ba6b3..f288b98bf1 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1427,10 +1427,10 @@ const u32 gNamingScreenKeyboardSymbols_Tilemap[] = INCBIN_U32("graphics/naming_s const u16 gUnionRoomChat_Background_Pal[] = INCBIN_U16("graphics/union_room_chat/background.gbapal"); const u32 gUnionRoomChat_Background_Gfx[] = INCBIN_U32("graphics/union_room_chat/background.4bpp.lz"); const u32 gUnionRoomChat_Background_Tilemap[] = INCBIN_U32("graphics/union_room_chat/background.bin.lz"); -const u16 gUnionRoomChat_Window_Pal1[] = INCBIN_U16("graphics/union_room_chat/window_1.gbapal"); -const u16 gUnionRoomChat_Window_Pal2[] = INCBIN_U16("graphics/union_room_chat/window_2.gbapal"); -const u32 gUnionRoomChat_Border_Gfx[] = INCBIN_U32("graphics/union_room_chat/border.4bpp.lz"); -const u32 gUnionRoomChat_Border_Tilemap[] = INCBIN_U32("graphics/union_room_chat/border.bin.lz"); +const u16 gUnionRoomChat_InputText_Pal[] = INCBIN_U16("graphics/union_room_chat/input_text.gbapal"); +const u16 gUnionRoomChat_Keyboard_Pal[] = INCBIN_U16("graphics/union_room_chat/keyboard.gbapal"); +const u32 gUnionRoomChat_Keyboard_Gfx[] = INCBIN_U32("graphics/union_room_chat/keyboard.4bpp.lz"); +const u32 gUnionRoomChat_Keyboard_Tilemap[] = INCBIN_U32("graphics/union_room_chat/keyboard.bin.lz"); const u32 gUnionRoomChat_RButtonLabels[] = INCBIN_U32("graphics/union_room_chat/r_button_labels.4bpp.lz"); const u16 gTilesetPalettes_General[][16] = diff --git a/src/union_room_chat.c b/src/union_room_chat.c index af4ec2721f..253e025689 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -116,6 +116,13 @@ enum { // Shared by all above #define PALTAG_INTERFACE 0 +enum { + WIN_CHAT_HISTORY, + WIN_TEXT_ENTRY, + WIN_KEYBOARD, + WIN_SWAP_MENU, +}; + struct UnionRoomChat { u32 filler1; @@ -166,8 +173,7 @@ struct UnionRoomChatDisplay u8 bg1Buffer[BG_SCREEN_SIZE]; u8 bg3Buffer[BG_SCREEN_SIZE]; u8 bg2Buffer[BG_SCREEN_SIZE]; - u8 unk2128[0x20]; - u8 unk2148[0x20]; + u8 textEntryTiles[TILE_SIZE_4BPP * 2]; }; struct UnionRoomChatSprites @@ -247,11 +253,11 @@ static void FreeSprites(void); static void ResetGpuBgState(void); static void SetBgTilemapBuffers(void); static void ClearBg0(void); -static void LoadChatWindowBorderGfx(void); +static void LoadKeyboardWindowGfx(void); static void LoadChatWindowGfx(void); static void LoadChatUnkPalette(void); static void LoadChatMessagesWindow(void); -static void LoadKeyboardWindow(void); +static void DrawKeyboardWindow(void); static void LoadKeyboardSwapWindow(void); static void LoadTextEntryWindow(void); static void CreateKeyboardCursorSprite(void); @@ -520,8 +526,8 @@ static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT - 1][UNIO } }; -static const u16 sUnk_Palette1[] = INCBIN_U16("graphics/union_room_chat/unk_palette1.gbapal"); -static const u16 sUnk_Palette2[] = INCBIN_U16("graphics/union_room_chat/unk_palette2.gbapal"); +static const u16 sUnusedPalette[] = INCBIN_U16("graphics/union_room_chat/unused.gbapal"); // Loaded but never apparently used +static const u16 sChatMessagesWindow_Pal[] = INCBIN_U16("graphics/union_room_chat/chat_messages_window.gbapal"); static const struct BgTemplate sBgTemplates[] = { { @@ -560,7 +566,7 @@ static const struct BgTemplate sBgTemplates[] = { }; static const struct WindowTemplate sWinTemplates[] = { - { + [WIN_CHAT_HISTORY] = { .bg = 3, .tilemapLeft = 8, .tilemapTop = 1, @@ -568,7 +574,8 @@ static const struct WindowTemplate sWinTemplates[] = { .height = 19, .paletteNum = 15, .baseBlock = 0x0001, - }, { + }, + [WIN_TEXT_ENTRY] = { .bg = 1, .tilemapLeft = 9, .tilemapTop = 18, @@ -576,7 +583,8 @@ static const struct WindowTemplate sWinTemplates[] = { .height = 2, .paletteNum = 12, .baseBlock = 0x007a, - }, { + }, + [WIN_KEYBOARD] = { .bg = 1, .tilemapLeft = 0, .tilemapTop = 2, @@ -584,7 +592,8 @@ static const struct WindowTemplate sWinTemplates[] = { .height = 15, .paletteNum = 7, .baseBlock = 0x0020, - }, { + }, + [WIN_SWAP_MENU] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 2, @@ -749,15 +758,15 @@ static const u32 sTextEntryArrowTiles[] = INCBIN_U32("graphics/union_room_chat/t static const u32 sRButtonGfxTiles[] = INCBIN_U32("graphics/union_room_chat/r_button.4bpp.lz"); static const struct CompressedSpriteSheet sSpriteSheets[] = { - {sKeyboardCursorTiles, 0x1000, 0}, - {sTextEntryArrowTiles, 0x0040, 1}, - {sTextEntryCursorTiles, 0x0040, 2}, - {sRButtonGfxTiles, 0x0080, 3}, - {gUnionRoomChat_RButtonLabels, 0x0400, 4} + {.data = sKeyboardCursorTiles, .size = 0x1000, .tag = GFXTAG_KEYBOARD_CURSOR}, + {.data = sTextEntryArrowTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_ARROW}, + {.data = sTextEntryCursorTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_CURSOR}, + {.data = sRButtonGfxTiles, .size = 0x0080, .tag = GFXTAG_RBUTTON_ICON}, + {.data = gUnionRoomChat_RButtonLabels, .size = 0x0400, .tag = GFXTAG_RBUTTON_LABELS} }; static const struct SpritePalette sSpritePalette = { - sUnionRoomChatInterfacePal, 0 + .data = sUnionRoomChatInterfacePal, .tag = PALTAG_INTERFACE }; static const struct OamData sOam_KeyboardCursor = { @@ -960,7 +969,7 @@ static void CB2_LoadInterface(void) sChat->handleInputTask = CreateTask(Task_HandlePlayerInput, 8); sChat->receiveMessagesTask = CreateTask(Task_ReceiveChatMessage, 7); LoadWirelessStatusIndicatorSpriteGfx(); - CreateWirelessStatusIndicatorSprite(232, 150); + CreateWirelessStatusIndicatorSprite(DISPLAY_WIDTH - 8, DISPLAY_HEIGHT - 10); } break; } @@ -1749,7 +1758,7 @@ static void RegisterTextAtRow(void) static void ResetMessageEntryBuffer(void) { sChat->messageEntryBuffer[0] = EOS; - sChat->lastBufferCursorPos = 15; + sChat->lastBufferCursorPos = MAX_MESSAGE_LENGTH; sChat->bufferCursorPos = 0; } @@ -2053,10 +2062,10 @@ static void Task_ReceiveChatMessage(u8 taskId) tState = 3; // fall through case 3: - for (; tI < 5 && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++) + for (; tI < MAX_RFU_PLAYERS && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++) ; - if (tI == 5) + if (tI == MAX_RFU_PLAYERS) { tState = 1; return; @@ -2244,7 +2253,7 @@ static bool32 Display_LoadGfx(u8 *state) ClearBg0(); break; case 2: - LoadChatWindowBorderGfx(); + LoadKeyboardWindowGfx(); break; case 3: LoadChatWindowGfx(); @@ -2254,7 +2263,7 @@ static bool32 Display_LoadGfx(u8 *state) break; case 5: LoadChatMessagesWindow(); - LoadKeyboardWindow(); + DrawKeyboardWindow(); LoadKeyboardSwapWindow(); LoadTextEntryWindow(); break; @@ -2280,7 +2289,7 @@ static bool32 Display_ShowKeyboardSwapMenu(u8 *state) { case 0: ShowKeyboardSwapMenu(); - CopyWindowToVram(3, COPYWIN_FULL); + CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL); break; case 1: return IsDma3ManagerBusyWithBgCopy(); @@ -2296,7 +2305,7 @@ static bool32 Display_HideKeyboardSwapMenu(u8 *state) { case 0: HideKeyboardSwapMenu(); - CopyWindowToVram(3, COPYWIN_FULL); + CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL); break; case 1: return IsDma3ManagerBusyWithBgCopy(); @@ -2316,7 +2325,7 @@ static bool32 Display_SwitchPages(u8 *state) return TRUE; PrintCurrentKeyboardPage(); - CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX); break; case 1: if (IsDma3ManagerBusyWithBgCopy()) @@ -2393,7 +2402,7 @@ static bool32 Display_UpdateMessageBuffer(u8 *state) FillTextEntryWindow(x, width, 0); str = GetMessageEntryBuffer(); DrawTextEntryMessage(0, str, 3, 1, 2); - CopyWindowToVram(1, COPYWIN_GFX); + CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -2422,7 +2431,7 @@ static bool32 Display_AskRegisterText(u8 *state) length = StringLength_Multibyte(str); FillTextEntryWindow(x, length, PIXEL_FILL(6)); DrawTextEntryMessage(x, str, 0, 4, 5); - CopyWindowToVram(1, COPYWIN_GFX); + CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -2463,7 +2472,7 @@ static bool32 Display_CancelRegister(u8 *state) length = StringLength_Multibyte(str); FillTextEntryWindow(x, length, PIXEL_FILL(0)); DrawTextEntryMessage(x, str, 3, 1, 2); - CopyWindowToVram(1, COPYWIN_GFX); + CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -2501,7 +2510,7 @@ static bool32 Display_ReturnToKeyboard(u8 *state) { case 0: PrintCurrentKeyboardPage(); - CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX); (*state)++; break; case 1: @@ -2527,7 +2536,7 @@ static bool32 Display_ScrollChat(u8 *state) str = GetLastReceivedMessage(); colorIdx = GetReceivedPlayerIndex(); PrintChatMessage(row, str, colorIdx); - CopyWindowToVram(0, COPYWIN_GFX); + CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX); break; case 1: if (IsDma3ManagerBusyWithBgCopy()) @@ -2546,8 +2555,8 @@ static bool32 Display_ScrollChat(u8 *state) } // fall through case 2: - ScrollWindow(0, 0, 5, PIXEL_FILL(1)); - CopyWindowToVram(0, COPYWIN_GFX); + ScrollWindow(WIN_CHAT_HISTORY, 0, 5, PIXEL_FILL(1)); + CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX); sDisplay->scrollCount++; (*state)++; // fall through @@ -2864,7 +2873,7 @@ static void DestroyStdMessageWindow(void) static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue) { - FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14); + FillWindowPixelRect(WIN_TEXT_ENTRY, fillValue, x * 8, 1, width * 8, 14); } static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor) @@ -2881,7 +2890,7 @@ static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shad strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING; strBuffer[2] = 8; StringCopy(&strBuffer[3], str); - AddTextPrinterParameterized3(1, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer); + AddTextPrinterParameterized3(WIN_TEXT_ENTRY, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer); } static void PrintCurrentKeyboardPage(void) @@ -2894,7 +2903,7 @@ static void PrintCurrentKeyboardPage(void) u8 str[45]; u8 *str2; - FillWindowPixelBuffer(2, PIXEL_FILL(15)); + FillWindowPixelBuffer(WIN_KEYBOARD, PIXEL_FILL(15)); page = GetCurrentKeyboardPage(); color[0] = TEXT_COLOR_TRANSPARENT; color[1] = TEXT_DYNAMIC_COLOR_5; @@ -2916,7 +2925,7 @@ static void PrintCurrentKeyboardPage(void) return; StringCopy(&str[3], sUnionRoomKeyboardText[page][i]); - AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); + AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); } } else @@ -2927,7 +2936,7 @@ static void PrintCurrentKeyboardPage(void) str2 = GetRegisteredTextByRow(i); if (GetStringWidth(FONT_SMALL, str2, 0) <= 40) { - AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2); + AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2); } else { @@ -2938,8 +2947,8 @@ static void PrintCurrentKeyboardPage(void) StringCopyN_Multibyte(str, str2, length); } while (GetStringWidth(FONT_SMALL, str, 0) > 35); - AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); - AddTextPrinterParameterized3(2, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis); + AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); + AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis); } } } @@ -2989,17 +2998,17 @@ static bool32 SlideKeyboardPageIn(void) static void ShowKeyboardSwapMenu(void) { - FillWindowPixelBuffer(3, PIXEL_FILL(1)); - DrawTextBorderOuter(3, 1, 13); - PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts); - InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage()); - PutWindowTilemap(3); + FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1)); + DrawTextBorderOuter(WIN_SWAP_MENU, 1, 13); + PrintMenuActionTextsAtPos(WIN_SWAP_MENU, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts); + InitMenuNormal(WIN_SWAP_MENU, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage()); + PutWindowTilemap(WIN_SWAP_MENU); } static void HideKeyboardSwapMenu(void) { - ClearStdWindowAndFrameToTransparent(3, FALSE); - ClearWindowTilemap(3); + ClearStdWindowAndFrameToTransparent(WIN_SWAP_MENU, FALSE); + ClearWindowTilemap(WIN_SWAP_MENU); } static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx) @@ -3009,8 +3018,8 @@ static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx) color[0] = TEXT_COLOR_WHITE; color[1] = colorIdx * 2 + 2; color[2] = colorIdx * 2 + 3; - FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15); - AddTextPrinterParameterized3(0, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str); + FillWindowPixelRect(WIN_CHAT_HISTORY, PIXEL_FILL(1), 0, row * 15, 168, 15); + AddTextPrinterParameterized3(WIN_CHAT_HISTORY, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str); } static void ResetGpuBgState(void) @@ -3053,12 +3062,12 @@ static void ClearBg0(void) CopyBgTilemapBufferToVram(0); } -static void LoadChatWindowBorderGfx(void) +static void LoadKeyboardWindowGfx(void) { - LoadPalette(gUnionRoomChat_Window_Pal2, BG_PLTT_ID(7), PLTT_SIZE_4BPP); - LoadPalette(gUnionRoomChat_Window_Pal1, BG_PLTT_ID(12), PLTT_SIZE_4BPP); - DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Border_Gfx, 0, 0, 0); - CopyToBgTilemapBuffer(1, gUnionRoomChat_Border_Tilemap, 0, 0); + LoadPalette(gUnionRoomChat_Keyboard_Pal, BG_PLTT_ID(7), PLTT_SIZE_4BPP); + LoadPalette(gUnionRoomChat_InputText_Pal, BG_PLTT_ID(12), PLTT_SIZE_4BPP); + DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Keyboard_Gfx, 0, 0, 0); + CopyToBgTilemapBuffer(1, gUnionRoomChat_Keyboard_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); } @@ -3070,8 +3079,12 @@ static void LoadChatWindowGfx(void) ptr = DecompressAndCopyTileDataToVram(2, gUnionRoomChat_Background_Gfx, 0, 0, 0); if (ptr) { - CpuFastCopy(&ptr[0x220], sDisplay->unk2128, sizeof(sDisplay->unk2128)); - CpuFastCopy(&ptr[0x420], sDisplay->unk2148, sizeof(sDisplay->unk2148)); + // The below is nonsense. Tiles 0x11 and 0x21 of the background tileset are + // the second half of "OK" and the "T" in "START" in the instructions header. + // They're later blitted onto the text entry window, then immediately cleared. + // The window has a different palette as well, so the tiles would appear mostly black anyway. + CpuFastCopy(&ptr[0x11 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 0], TILE_SIZE_4BPP); + CpuFastCopy(&ptr[0x21 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 1], TILE_SIZE_4BPP); } CopyToBgTilemapBuffer(2, gUnionRoomChat_Background_Tilemap, 0, 0); @@ -3080,23 +3093,23 @@ static void LoadChatWindowGfx(void) static void LoadChatUnkPalette(void) { - LoadPalette(sUnk_Palette1, BG_PLTT_ID(8), sizeof(sUnk_Palette1)); - RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + 0x20, 0x20, 1); + LoadPalette(sUnusedPalette, BG_PLTT_ID(8), sizeof(sUnusedPalette)); + RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + TILE_SIZE_4BPP, TILE_SIZE_4BPP, 1); } static void LoadChatMessagesWindow(void) { - LoadPalette(sUnk_Palette2, BG_PLTT_ID(15), sizeof(sUnk_Palette2)); - PutWindowTilemap(0); - FillWindowPixelBuffer(0, PIXEL_FILL(1)); - CopyWindowToVram(0, COPYWIN_FULL); + LoadPalette(sChatMessagesWindow_Pal, BG_PLTT_ID(15), sizeof(sChatMessagesWindow_Pal)); + PutWindowTilemap(WIN_CHAT_HISTORY); + FillWindowPixelBuffer(WIN_CHAT_HISTORY, PIXEL_FILL(1)); + CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_FULL); } -static void LoadKeyboardWindow(void) +static void DrawKeyboardWindow(void) { - PutWindowTilemap(2); + PutWindowTilemap(WIN_KEYBOARD); PrintCurrentKeyboardPage(); - CopyWindowToVram(2, COPYWIN_FULL); + CopyWindowToVram(WIN_KEYBOARD, COPYWIN_FULL); } static void LoadTextEntryWindow(void) @@ -3106,20 +3119,21 @@ static void LoadTextEntryWindow(void) unused[0] = 0; unused[1] = 0xFF; + // Pointless, cleared below. The tiles are nonsense anyway, see LoadChatWindowGfx. for (i = 0; i < MAX_MESSAGE_LENGTH; i++) - BlitBitmapToWindow(1, sDisplay->unk2128, i * 8, 0, 8, 16); + BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->textEntryTiles, i * 8, 0, 8, 16); - FillWindowPixelBuffer(1, PIXEL_FILL(0)); - PutWindowTilemap(1); - CopyWindowToVram(1, COPYWIN_FULL); + FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0)); + PutWindowTilemap(WIN_TEXT_ENTRY); + CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_FULL); } static void LoadKeyboardSwapWindow(void) { - FillWindowPixelBuffer(3, PIXEL_FILL(1)); - LoadUserWindowBorderGfx(3, 1, BG_PLTT_ID(13)); - LoadUserWindowBorderGfx_(3, 0xA, BG_PLTT_ID(2)); - LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP); + FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1)); + LoadUserWindowBorderGfx(WIN_SWAP_MENU, 1, BG_PLTT_ID(13)); + LoadUserWindowBorderGfx_(WIN_SWAP_MENU, 0xA, BG_PLTT_ID(2)); + LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP); } static void InitScanlineEffect(void) From db5edc49d76eaf0e67c0d80e34feb8f6f1f7e37c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 8 Feb 2023 12:10:17 -0500 Subject: [PATCH 03/19] Sync mapjson --- tools/mapjson/mapjson.cpp | 140 +++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 48 deletions(-) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 1a3058f3da..0f2f4f5bb6 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -29,6 +29,7 @@ using json11::Json; #include "mapjson.h" +string version; string read_text_file(string filepath) { ifstream in_file(filepath); @@ -61,7 +62,7 @@ void write_text_file(string filepath, string text) { } -string json_to_string(const Json &data, const string &field = "") { +string json_to_string(const Json &data, const string &field = "", bool silent = false) { const Json value = !field.empty() ? data[field] : data; string output = ""; switch (value.type()) { @@ -75,12 +76,14 @@ string json_to_string(const Json &data, const string &field = "") { output = value.bool_value() ? "TRUE" : "FALSE"; break; default:{ - string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; - FATAL_ERROR("%s is unexpected type; expected string, number, or bool.\n", s.c_str()); + if (!silent) { + string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; + FATAL_ERROR("%s is unexpected type; expected string, number, or bool.\n", s.c_str()); + } } } - if (output.empty()){ + if (!silent && output.empty()) { string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; FATAL_ERROR("%s cannot be empty.\n", s.c_str()); } @@ -88,14 +91,14 @@ string json_to_string(const Json &data, const string &field = "") { return output; } -string generate_map_header_text(Json map_data, Json layouts_data, string version) { +string generate_map_header_text(Json map_data, Json layouts_data) { string map_layout_id = json_to_string(map_data, "layout"); vector matched; - for (auto &field : layouts_data["layouts"].array_items()) { - if (map_layout_id == json_to_string(field, "id")) - matched.push_back(field); + for (auto &layout : layouts_data["layouts"].array_items()) { + if (map_layout_id == json_to_string(layout, "id", true)) + matched.push_back(layout); } if (matched.size() != 1) @@ -123,28 +126,33 @@ string generate_map_header_text(Json map_data, Json layouts_data, string version text << "\t.4byte " << mapName << "_MapScripts\n"; if (map_data.object_items().find("connections") != map_data.object_items().end() - && map_data["connections"].array_items().size() > 0) + && map_data["connections"].array_items().size() > 0 && json_to_string(map_data, "connections_no_include", true) != "TRUE") text << "\t.4byte " << mapName << "_MapConnections\n"; else - text << "\t.4byte 0x0\n"; + text << "\t.4byte NULL\n"; text << "\t.2byte " << json_to_string(map_data, "music") << "\n" << "\t.2byte " << json_to_string(layout, "id") << "\n" << "\t.byte " << json_to_string(map_data, "region_map_section") << "\n" << "\t.byte " << json_to_string(map_data, "requires_flash") << "\n" << "\t.byte " << json_to_string(map_data, "weather") << "\n" - << "\t.byte " << json_to_string(map_data, "map_type") << "\n" - << "\t.2byte 0\n"; + << "\t.byte " << json_to_string(map_data, "map_type") << "\n"; + + if (version != "firered") + text << "\t.2byte 0\n"; if (version == "ruby") text << "\t.byte " << json_to_string(map_data, "show_map_name") << "\n"; - else if (version == "emerald") + else if (version == "emerald" || version == "firered") text << "\tmap_header_flags " << "allow_cycling=" << json_to_string(map_data, "allow_cycling") << ", " << "allow_escaping=" << json_to_string(map_data, "allow_escaping") << ", " << "allow_running=" << json_to_string(map_data, "allow_running") << ", " << "show_map_name=" << json_to_string(map_data, "show_map_name") << "\n"; + if (version == "firered") + text << "\t.byte " << json_to_string(map_data, "floor_number") << "\n"; + text << "\t.byte " << json_to_string(map_data, "battle_scene") << "\n\n"; return text.str(); @@ -193,22 +201,34 @@ string generate_map_events_text(Json map_data) { text << objects_label << ":\n"; for (unsigned int i = 0; i < map_data["object_events"].array_items().size(); i++) { auto obj_event = map_data["object_events"].array_items()[i]; - text << "\tobject_event " << i + 1 << ", " - << json_to_string(obj_event, "graphics_id") << ", 0, " - << json_to_string(obj_event, "x") << ", " - << json_to_string(obj_event, "y") << ", " - << json_to_string(obj_event, "elevation") << ", " - << json_to_string(obj_event, "movement_type") << ", " - << json_to_string(obj_event, "movement_range_x") << ", " - << json_to_string(obj_event, "movement_range_y") << ", " - << json_to_string(obj_event, "trainer_type") << ", " - << json_to_string(obj_event, "trainer_sight_or_berry_tree_id") << ", " - << json_to_string(obj_event, "script") << ", " - << json_to_string(obj_event, "flag") << "\n"; + string type = json_to_string(obj_event, "type", true); + + // If no type field is present, assume it's a regular object event. + if (type == "" || type == "object") { + text << "\tobject_event " << i + 1 << ", " + << json_to_string(obj_event, "graphics_id") << ", 0, " + << json_to_string(obj_event, "x") << ", " + << json_to_string(obj_event, "y") << ", " + << json_to_string(obj_event, "elevation") << ", " + << json_to_string(obj_event, "movement_type") << ", " + << json_to_string(obj_event, "movement_range_x") << ", " + << json_to_string(obj_event, "movement_range_y") << ", " + << json_to_string(obj_event, "trainer_type") << ", " + << json_to_string(obj_event, "trainer_sight_or_berry_tree_id") << ", " + << json_to_string(obj_event, "script") << ", " + << json_to_string(obj_event, "flag") << "\n"; + } else if (type == "clone") { + text << "\tclone_event " << i + 1 << ", " + << json_to_string(obj_event, "graphics_id") << ", " + << json_to_string(obj_event, "x") << ", " + << json_to_string(obj_event, "y") << ", " + << json_to_string(obj_event, "target_local_id") << ", " + << json_to_string(obj_event, "target_map") << "\n"; + } } text << "\n"; } else { - objects_label = "0x0"; + objects_label = "NULL"; } if (map_data["warp_events"].array_items().size() > 0) { @@ -224,14 +244,15 @@ string generate_map_events_text(Json map_data) { } text << "\n"; } else { - warps_label = "0x0"; + warps_label = "NULL"; } if (map_data["coord_events"].array_items().size() > 0) { coords_label = mapName + "_MapCoordEvents"; text << coords_label << ":\n"; for (auto &coord_event : map_data["coord_events"].array_items()) { - if (json_to_string(coord_event, "type") == "trigger") { + string type = json_to_string(coord_event, "type"); + if (type == "trigger") { text << "\tcoord_event " << json_to_string(coord_event, "x") << ", " << json_to_string(coord_event, "y") << ", " @@ -240,7 +261,7 @@ string generate_map_events_text(Json map_data) { << json_to_string(coord_event, "var_value") << ", " << json_to_string(coord_event, "script") << "\n"; } - else if (coord_event["type"] == "weather") { + else if (type == "weather") { text << "\tcoord_weather_event " << json_to_string(coord_event, "x") << ", " << json_to_string(coord_event, "y") << ", " @@ -250,14 +271,15 @@ string generate_map_events_text(Json map_data) { } text << "\n"; } else { - coords_label = "0x0"; + coords_label = "NULL"; } if (map_data["bg_events"].array_items().size() > 0) { bgs_label = mapName + "_MapBGEvents"; text << bgs_label << ":\n"; for (auto &bg_event : map_data["bg_events"].array_items()) { - if (bg_event["type"] == "sign") { + string type = json_to_string(bg_event, "type"); + if (type == "sign") { text << "\tbg_sign_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " @@ -265,15 +287,21 @@ string generate_map_events_text(Json map_data) { << json_to_string(bg_event, "player_facing_dir") << ", " << json_to_string(bg_event, "script") << "\n"; } - else if (bg_event["type"] == "hidden_item") { + else if (type == "hidden_item") { text << "\tbg_hidden_item_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " << json_to_string(bg_event, "elevation") << ", " << json_to_string(bg_event, "item") << ", " - << json_to_string(bg_event, "flag") << "\n"; + << json_to_string(bg_event, "flag"); + if (version == "firered") { + text << ", " + << json_to_string(bg_event, "quantity") << ", " + << json_to_string(bg_event, "underfoot"); + } + text << "\n"; } - else if (bg_event["type"] == "secret_base") { + else if (type == "secret_base") { text << "\tbg_secret_base_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " @@ -283,7 +311,7 @@ string generate_map_events_text(Json map_data) { } text << "\n"; } else { - bgs_label = "0x0"; + bgs_label = "NULL"; } text << mapName << "_MapEvents::\n" @@ -299,7 +327,7 @@ string get_directory_name(string filename) { return filename.substr(0, dir_pos + 1); } -void process_map(string map_filepath, string layouts_filepath, string version) { +void process_map(string map_filepath, string layouts_filepath) { string mapdata_err, layouts_err; string mapdata_json_text = read_text_file(map_filepath); @@ -313,7 +341,7 @@ void process_map(string map_filepath, string layouts_filepath, string version) { if (layouts_data == Json()) FATAL_ERROR("%s\n", layouts_err.c_str()); - string header_text = generate_map_header_text(map_data, layouts_data, version); + string header_text = generate_map_header_text(map_data, layouts_data); string events_text = generate_map_events_text(map_data); string connections_text = generate_map_connections_text(map_data); @@ -337,7 +365,10 @@ string generate_groups_text(Json groups_data) { text << "\n"; } - text << "\t.align 2\n" << "gMapGroups::\n"; + if (version != "firered") + text << "\t.align 2\n"; + + text << "gMapGroups::\n"; for (auto &group : groups_data["group_order"].array_items()) text << "\t.4byte " << json_to_string(group) << "\n"; text << "\n"; @@ -484,6 +515,7 @@ string generate_layout_headers_text(Json layouts_data) { text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/layouts/layouts.json\n@\n\n"; for (auto &layout : layouts_data["layouts"].array_items()) { + if (layout == Json::object()) continue; string layoutName = json_to_string(layout, "name"); string border_label = layoutName + "_Border"; string blockdata_label = layoutName + "_Blockdata"; @@ -498,7 +530,13 @@ string generate_layout_headers_text(Json layouts_data) { << "\t.4byte " << border_label << "\n" << "\t.4byte " << blockdata_label << "\n" << "\t.4byte " << json_to_string(layout, "primary_tileset") << "\n" - << "\t.4byte " << json_to_string(layout, "secondary_tileset") << "\n\n"; + << "\t.4byte " << json_to_string(layout, "secondary_tileset") << "\n"; + if (version == "firered") { + text << "\t.byte " << json_to_string(layout, "border_width") << "\n" + << "\t.byte " << json_to_string(layout, "border_height") << "\n" + << "\t.2byte 0\n"; + } + text << "\n"; } return text.str(); @@ -512,8 +550,11 @@ string generate_layouts_table_text(Json layouts_data) { text << "\t.align 2\n" << json_to_string(layouts_data, "layouts_table_label") << "::\n"; - for (auto &layout : layouts_data["layouts"].array_items()) - text << "\t.4byte " << json_to_string(layout, "name") << "\n"; + for (auto &layout : layouts_data["layouts"].array_items()) { + string layout_name = json_to_string(layout, "name", true); + if (layout_name.empty()) layout_name = "NULL"; + text << "\t.4byte " << layout_name << "\n"; + } return text.str(); } @@ -526,9 +567,12 @@ string generate_layouts_constants_text(Json layouts_data) { text << "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from data/layouts/layouts.json\n//\n\n"; - int i = 0; - for (auto &layout : layouts_data["layouts"].array_items()) - text << "#define " << json_to_string(layout, "id") << " " << ++i << "\n"; + int i = 1; + for (auto &layout : layouts_data["layouts"].array_items()) { + if (layout != Json::object()) + text << "#define " << json_to_string(layout, "id") << " " << i << "\n"; + i++; + } text << "\n#endif // GUARD_CONSTANTS_LAYOUTS_H\n"; @@ -559,9 +603,9 @@ int main(int argc, char *argv[]) { FATAL_ERROR("USAGE: mapjson [options]\n"); char *version_arg = argv[2]; - string version(version_arg); - if (version != "emerald" && version != "ruby") - FATAL_ERROR("ERROR: must be 'emerald' or 'ruby'.\n"); + version = string(version_arg); + if (version != "emerald" && version != "ruby" && version != "firered") + FATAL_ERROR("ERROR: must be 'emerald', 'firered', or 'ruby'.\n"); char *mode_arg = argv[1]; string mode(mode_arg); @@ -575,7 +619,7 @@ int main(int argc, char *argv[]) { string filepath(argv[3]); string layouts_filepath(argv[4]); - process_map(filepath, layouts_filepath, version); + process_map(filepath, layouts_filepath); } else if (mode == "groups") { if (argc != 4) From 118a9701c94730a563afe271a3502800464cc771 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 8 Feb 2023 12:52:28 -0500 Subject: [PATCH 04/19] Add event type errors --- tools/mapjson/mapjson.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 0f2f4f5bb6..10283eb08b 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -224,6 +224,8 @@ string generate_map_events_text(Json map_data) { << json_to_string(obj_event, "y") << ", " << json_to_string(obj_event, "target_local_id") << ", " << json_to_string(obj_event, "target_map") << "\n"; + } else { + FATAL_ERROR("Unknown object event type '%s'. Expected 'object' or 'clone'.\n", type.c_str()); } } text << "\n"; @@ -267,6 +269,8 @@ string generate_map_events_text(Json map_data) { << json_to_string(coord_event, "y") << ", " << json_to_string(coord_event, "elevation") << ", " << json_to_string(coord_event, "weather") << "\n"; + } else { + FATAL_ERROR("Unknown coord event type '%s'. Expected 'trigger' or 'weather'.\n", type.c_str()); } } text << "\n"; @@ -307,6 +311,8 @@ string generate_map_events_text(Json map_data) { << json_to_string(bg_event, "y") << ", " << json_to_string(bg_event, "elevation") << ", " << json_to_string(bg_event, "secret_base_id") << "\n"; + } else { + FATAL_ERROR("Unknown bg event type '%s'. Expected 'sign', 'hidden_item', or 'secret_base'.\n", type.c_str()); } } text << "\n"; From de56e400ffd5791fd6975323295a7bce642bed80 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 8 Feb 2023 13:11:10 -0500 Subject: [PATCH 05/19] Sync clone object macro --- asm/macros/map.inc | 28 ++++++++++++++++++++++------ include/constants/event_objects.h | 3 +++ include/global.fieldmap.h | 2 +- src/event_object_movement.c | 2 +- tools/mapjson/mapjson.cpp | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/asm/macros/map.inc b/asm/macros/map.inc index 662257e416..21445138de 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -19,11 +19,11 @@ .4byte \script .endm - @ Defines an object event template for map data. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h - .macro object_event index:req, gfx:req, inConnection:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req + @ Defines an object event template for map data, to be used by a normal object. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h + .macro object_event index:req, gfx:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req .byte \index .byte \gfx - .byte \inConnection + .byte OBJ_KIND_NORMAL .space 1 @ Padding .2byte \x, \y .byte \elevation @@ -38,6 +38,22 @@ inc _num_npcs .endm + @ Defines an object event template for map data, to be used by a clone object. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h + @ NOTE: The handling for this type of event does not exist in Emerald by default; it is exclusive to FRLG. + .macro clone_event index:req, gfx:req, x:req, y:req, target_local_id:req, target_map_id:req + .byte \index + .byte \gfx + .byte OBJ_KIND_CLONE + .space 1 @ Padding + .2byte \x, \y + .byte \target_local_id + .space 3 @ Padding + .2byte \target_map_id & 0xFF @ map num + .2byte \target_map_id >> 8 @ map group + .space 8 @ Padding + inc _num_npcs + .endm + @ Defines a warp event for map data. Mirrors the struct layout of WarpEvent in include/global.fieldmap.h .macro warp_def x:req, y:req, elevation:req, warpId:req, map_id:req .2byte \x, \y @@ -49,12 +65,12 @@ .endm @ Defines a coord event for map data. Mirrors the struct layout of CoordEvent in include/global.fieldmap.h - .macro coord_event x:req, y:req, elevation:req, trigger:req, index:req, script:req + .macro coord_event x:req, y:req, elevation:req, var:req, varValue:req, script:req .2byte \x, \y .byte \elevation .space 1 @ Padding - .2byte \trigger - .2byte \index + .2byte \var + .2byte \varValue .space 2 @ Padding .4byte \script inc _num_traps diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 8278c6a66b..c8fa942655 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -288,6 +288,9 @@ #define FIRST_DECORATION_SPRITE_GFX OBJ_EVENT_GFX_PICHU_DOLL +#define OBJ_KIND_NORMAL 0 +#define OBJ_KIND_CLONE 255 // Exclusive to FRLG + // Special object event local ids #define OBJ_EVENT_ID_PLAYER 0xFF #define OBJ_EVENT_ID_CAMERA 0x7F diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 26e5c44bf1..d8fea5b23c 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -67,7 +67,7 @@ struct ObjectEventTemplate { /*0x00*/ u8 localId; /*0x01*/ u8 graphicsId; - /*0x02*/ u8 inConnection; // Leftover from FRLG + /*0x02*/ u8 kind; // Always OBJ_KIND_NORMAL in Emerald. /*0x03*/ //u8 padding1; /*0x04*/ s16 x; /*0x06*/ s16 y; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 870f55081f..be0c4ce26d 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1498,7 +1498,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l y -= MAP_OFFSET; objectEventTemplate.localId = localId; objectEventTemplate.graphicsId = graphicsId; - objectEventTemplate.inConnection = 0; + objectEventTemplate.kind = OBJ_KIND_NORMAL; objectEventTemplate.x = x; objectEventTemplate.y = y; objectEventTemplate.elevation = elevation; diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 10283eb08b..460e5e8aff 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -206,7 +206,7 @@ string generate_map_events_text(Json map_data) { // If no type field is present, assume it's a regular object event. if (type == "" || type == "object") { text << "\tobject_event " << i + 1 << ", " - << json_to_string(obj_event, "graphics_id") << ", 0, " + << json_to_string(obj_event, "graphics_id") << ", " << json_to_string(obj_event, "x") << ", " << json_to_string(obj_event, "y") << ", " << json_to_string(obj_event, "elevation") << ", " From c29cf5a5e5a017c9b5f479c46965cc6da2bf6eef Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 8 Feb 2023 13:34:38 -0500 Subject: [PATCH 06/19] Remove unnecessary version check --- tools/mapjson/mapjson.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 460e5e8aff..cfe95c485a 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -371,10 +371,7 @@ string generate_groups_text(Json groups_data) { text << "\n"; } - if (version != "firered") - text << "\t.align 2\n"; - - text << "gMapGroups::\n"; + text << "\t.align 2\n" << "gMapGroups::\n"; for (auto &group : groups_data["group_order"].array_items()) text << "\t.4byte " << json_to_string(group) << "\n"; text << "\n"; From 6da5e0a280d481d3eab0ca292dd53277f75d120a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 11 Feb 2023 17:13:53 -0300 Subject: [PATCH 07/19] Rename eventLegal to fatefulEncounter --- asm/macros/event.inc | 14 +++++++------- data/maps/BirthIsland_Exterior/scripts.inc | 2 +- data/maps/FarawayIsland_Interior/scripts.inc | 2 +- data/maps/NavelRock_Bottom/scripts.inc | 2 +- data/maps/NavelRock_Top/scripts.inc | 2 +- data/maps/SouthernIsland_Interior/scripts.inc | 4 ++-- data/script_cmd_table.inc | 4 ++-- data/scripts/gift_pichu.inc | 2 +- data/specials.inc | 2 +- include/pokemon.h | 8 ++++---- include/trade.h | 4 ++-- src/battle_util.c | 6 +++--- src/egg_hatch.c | 6 +++--- src/party_menu.c | 8 ++++---- src/pokemon.c | 18 +++++++++--------- src/scrcmd.c | 12 ++++++------ src/trade.c | 16 ++++++++-------- 17 files changed, 56 insertions(+), 56 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 6c0c3856b9..ed2e95c6c7 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1576,15 +1576,15 @@ .4byte \value .endm - @ Sets the eventLegal bit for the Pokemon in the specified slot of the player's party. - .macro setmoneventlegal slot:req + @ Sets the fatefulEncounter bit for the Pokemon in the specified slot of the player's party. + .macro setfatefulencounter slot:req .byte 0xcd .2byte \slot .endm - @ Checks if the eventLegal bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, + @ Checks if the fatefulEncounter bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, @ VAR_RESULT is TRUE. If the bit is set (or if the specified slot is empty or invalid), VAR_RESULT is FALSE. - .macro checkmoneventlegal slot:req + .macro checkfatefulencounter slot:req .byte 0xce .2byte \slot .endm @@ -1932,10 +1932,10 @@ closebraillemessage .endm - @ Creates an "event legal" Pokémon for an encounter - .macro seteventmon species:req, level:req, item=ITEM_NONE + @ Creates a Pokémon with the fatefulEncounter bit set for an encounter + .macro setfatefulencountermon species:req, level:req, item=ITEM_NONE setvar VAR_0x8004, \species setvar VAR_0x8005, \level setvar VAR_0x8006, \item - special CreateEventLegalEnemyMon + special CreateFatefulEncounterEnemyMon .endm diff --git a/data/maps/BirthIsland_Exterior/scripts.inc b/data/maps/BirthIsland_Exterior/scripts.inc index d2174eee99..2b5d6ba1ad 100644 --- a/data/maps/BirthIsland_Exterior/scripts.inc +++ b/data/maps/BirthIsland_Exterior/scripts.inc @@ -85,7 +85,7 @@ BirthIsland_Exterior_EventScript_Deoxys:: delay 40 waitmoncry setvar VAR_LAST_TALKED, LOCALID_DEOXYS - seteventmon SPECIES_DEOXYS, 30 + setfatefulencountermon SPECIES_DEOXYS, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/FarawayIsland_Interior/scripts.inc b/data/maps/FarawayIsland_Interior/scripts.inc index d3d519ed15..1a7eb43c6b 100644 --- a/data/maps/FarawayIsland_Interior/scripts.inc +++ b/data/maps/FarawayIsland_Interior/scripts.inc @@ -129,7 +129,7 @@ FarawayIsland_Interior_EventScript_Mew:: special DestroyMewEmergingGrassSprite delay 40 waitmoncry - seteventmon SPECIES_MEW, 30 + setfatefulencountermon SPECIES_MEW, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Bottom/scripts.inc b/data/maps/NavelRock_Bottom/scripts.inc index 90cc229895..cee6242f66 100644 --- a/data/maps/NavelRock_Bottom/scripts.inc +++ b/data/maps/NavelRock_Bottom/scripts.inc @@ -53,7 +53,7 @@ NavelRock_Bottom_EventScript_Lugia:: playmoncry SPECIES_LUGIA, CRY_MODE_ENCOUNTER waitmoncry delay 20 - seteventmon SPECIES_LUGIA, 70 + setfatefulencountermon SPECIES_LUGIA, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Top/scripts.inc b/data/maps/NavelRock_Top/scripts.inc index 10969367a1..c25fbdb22b 100644 --- a/data/maps/NavelRock_Top/scripts.inc +++ b/data/maps/NavelRock_Top/scripts.inc @@ -57,7 +57,7 @@ NavelRock_Top_EventScript_HoOh:: applymovement LOCALID_HO_OH, NavelRock_Top_Movement_HoOhApproach waitmovement 0 special RemoveCameraObject - seteventmon SPECIES_HO_OH, 70 + setfatefulencountermon SPECIES_HO_OH, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/SouthernIsland_Interior/scripts.inc b/data/maps/SouthernIsland_Interior/scripts.inc index 8486739d93..a0eaabff3c 100644 --- a/data/maps/SouthernIsland_Interior/scripts.inc +++ b/data/maps/SouthernIsland_Interior/scripts.inc @@ -105,11 +105,11 @@ SouthernIsland_Interior_EventScript_Sign:: end SouthernIsland_Interior_EventScript_SetLatiosBattleVars:: - seteventmon SPECIES_LATIOS, 50, ITEM_SOUL_DEW + setfatefulencountermon SPECIES_LATIOS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_EventScript_SetLatiasBattleVars:: - seteventmon SPECIES_LATIAS, 50, ITEM_SOUL_DEW + setfatefulencountermon SPECIES_LATIAS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_Movement_CameraPanUp: diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 51b7f966e4..7957e34eb4 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -205,8 +205,8 @@ gScriptCmdTable:: .4byte ScrCmd_nop1 @ 0xca .4byte ScrCmd_nop1 @ 0xcb .4byte ScrCmd_nop1 @ 0xcc - .4byte ScrCmd_setmoneventlegal @ 0xcd - .4byte ScrCmd_checkmoneventlegal @ 0xce + .4byte ScrCmd_setmonfatefulencounter @ 0xcd + .4byte ScrCmd_checkmonfatefulencounter @ 0xce .4byte ScrCmd_trywondercardscript @ 0xcf .4byte ScrCmd_nop1 @ 0xd0 .4byte ScrCmd_warpspinenter @ 0xd1 diff --git a/data/scripts/gift_pichu.inc b/data/scripts/gift_pichu.inc index d2cd381b53..de2346a0a2 100644 --- a/data/scripts/gift_pichu.inc +++ b/data/scripts/gift_pichu.inc @@ -29,7 +29,7 @@ SurfPichu_FullParty: SurfPichu_GiveEgg: giveegg SPECIES_PICHU - setmoneventlegal VAR_GIFT_PICHU_SLOT + setfatefulencounter VAR_GIFT_PICHU_SLOT setmonmetlocation VAR_GIFT_PICHU_SLOT, METLOC_FATEFUL_ENCOUNTER vgoto_if_eq VAR_GIFT_PICHU_SLOT, 1, SurfPichu_Slot1 vgoto_if_eq VAR_GIFT_PICHU_SLOT, 2, SurfPichu_Slot2 diff --git a/data/specials.inc b/data/specials.inc index 26eb4e134b..9ea7df31a1 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -490,7 +490,7 @@ gSpecials:: def_special ScrollableMultichoice_ClosePersistentMenu def_special DoDeoxysRockInteraction def_special SetDeoxysRockPalette - def_special CreateEventLegalEnemyMon + def_special CreateFatefulEncounterEnemyMon def_special StartMirageTowerDisintegration def_special StartMirageTowerShake def_special StartMirageTowerFossilFallAndSink diff --git a/include/pokemon.h b/include/pokemon.h index ab102000a3..8087d7b318 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -85,7 +85,7 @@ enum { MON_DATA_EARTH_RIBBON, MON_DATA_WORLD_RIBBON, MON_DATA_UNUSED_RIBBONS, - MON_DATA_EVENT_LEGAL, + MON_DATA_FATEFUL_ENCOUNTER, MON_DATA_KNOWN_MOVES, MON_DATA_RIBBON_COUNT, MON_DATA_RIBBONS, @@ -165,7 +165,7 @@ struct PokemonSubstruct3 /* 0x0B */ u32 earthRibbon:1; /* 0x0B */ u32 worldRibbon:1; // distributed during Pokémon Festa '04 and '05 to tournament winners /* 0x0B */ u32 unusedRibbons:4; // discarded in Gen 4 - /* 0x0B */ u32 eventLegal:1; // controls Mew & Deoxys obedience; if set, Pokémon is a fateful encounter in Gen 4+; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness. + /* 0x0B */ u32 fatefulEncounter:1; // controls Mew & Deoxys obedience; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness. }; // Number of bytes in the largest Pokémon substruct. @@ -401,12 +401,12 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest); -void CreateEventLegalMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); +void CreateFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId); void SetDeoxysStats(void); u16 GetUnionRoomTrainerPic(void); u16 GetUnionRoomTrainerClass(void); -void CreateEventLegalEnemyMon(void); +void CreateFatefulEncounterEnemyMon(void); void CalculateMonStats(struct Pokemon *mon); void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest); u8 GetLevelFromMonExp(struct Pokemon *mon); diff --git a/include/trade.h b/include/trade.h index d63749653a..f89d203e9c 100644 --- a/include/trade.h +++ b/include/trade.h @@ -12,8 +12,8 @@ extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; s32 GetGameProgressForLinkTrade(void); void CB2_StartCreateTradeMenu(void); void CB2_LinkTrade(void); -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal); -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal); +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isFatefulEncounter); +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isFatefulEncounter); int CanSpinTradeMon(struct Pokemon *, u16); void InitTradeSequenceBgGpuRegs(void); void LinkTradeDrawWindow(void); diff --git a/src/battle_util.c b/src/battle_util.c index bbf34ab316..c3186671f5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3885,14 +3885,14 @@ u8 GetMoveTarget(u16 move, u8 setTarget) return targetBattler; } -static bool32 IsMonEventLegal(u8 battlerId) +static bool32 IsBattlerFatefulEncounter(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) return TRUE; if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_MEW) return TRUE; - return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_EVENT_LEGAL, NULL); + return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_FATEFUL_ENCOUNTER, NULL); } u8 IsMonDisobedient(void) @@ -3906,7 +3906,7 @@ u8 IsMonDisobedient(void) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; - if (IsMonEventLegal(gBattlerAttacker)) // only false if illegal Mew or Deoxys + if (IsBattlerFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys { if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 8c0bb5f79a..b741a9b15a 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -313,7 +313,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) { u16 species; u32 personality, pokerus; - u8 i, friendship, language, gameMet, markings, isEventLegal; + u8 i, friendship, language, gameMet, markings, isFatefulEncounter; u16 moves[MAX_MON_MOVES]; u32 ivs[NUM_STATS]; @@ -332,7 +332,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) gameMet = GetMonData(egg, MON_DATA_MET_GAME); markings = GetMonData(egg, MON_DATA_MARKINGS); pokerus = GetMonData(egg, MON_DATA_POKERUS); - isEventLegal = GetMonData(egg, MON_DATA_EVENT_LEGAL); + isFatefulEncounter = GetMonData(egg, MON_DATA_FATEFUL_ENCOUNTER); CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); @@ -350,7 +350,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) friendship = 120; SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship); SetMonData(temp, MON_DATA_POKERUS, &pokerus); - SetMonData(temp, MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(temp, MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); *egg = *temp; } diff --git a/src/party_menu.c b/src/party_menu.c index da2cb0fd19..571af54a41 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3591,9 +3591,9 @@ static void CursorCb_Register(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); + u8 isFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); - switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isEventLegal)) + switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isFatefulEncounter)) { case CANT_REGISTER_MON: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); @@ -3618,8 +3618,8 @@ static void CursorCb_Trade1(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); - u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isEventLegal); + u8 isFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); + u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isFatefulEncounter); if (stringId != UR_TRADE_MSG_NONE) { diff --git a/src/pokemon.c b/src/pokemon.c index e8d334a6ac..e08a08103b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2623,12 +2623,12 @@ void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerP GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); } -void CreateEventLegalMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +void CreateFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) { - bool32 isEventLegal = TRUE; + bool32 isFatefulEncounter = TRUE; CreateMon(mon, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); - SetMonData(mon, MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(mon, MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); } // If FALSE, should load this game's Deoxys form. If TRUE, should load normal Deoxys form @@ -2763,14 +2763,14 @@ u16 GetUnionRoomTrainerClass(void) return gFacilityClassToTrainerClass[gUnionRoomFacilityClasses[arrId]]; } -void CreateEventLegalEnemyMon(void) +void CreateFatefulEncounterEnemyMon(void) { s32 species = gSpecialVar_0x8004; s32 level = gSpecialVar_0x8005; s32 itemId = gSpecialVar_0x8006; ZeroEnemyPartyMons(); - CreateEventLegalMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateFatefulEncounterMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); if (itemId) { u8 heldItem[2]; @@ -3957,8 +3957,8 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_UNUSED_RIBBONS: retVal = substruct3->unusedRibbons; break; - case MON_DATA_EVENT_LEGAL: - retVal = substruct3->eventLegal; + case MON_DATA_FATEFUL_ENCOUNTER: + retVal = substruct3->fatefulEncounter; break; case MON_DATA_SPECIES2: retVal = substruct0->species; @@ -4341,8 +4341,8 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_UNUSED_RIBBONS: SET8(substruct3->unusedRibbons); break; - case MON_DATA_EVENT_LEGAL: - SET8(substruct3->eventLegal); + case MON_DATA_FATEFUL_ENCOUNTER: + SET8(substruct3->fatefulEncounter); break; case MON_DATA_IVS: { diff --git a/src/scrcmd.c b/src/scrcmd.c index 45cb65afb1..56bea0843e 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2206,21 +2206,21 @@ bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx) } } -// This command will set a Pokémon's eventLegal bit; there is no similar command to clear it. -bool8 ScrCmd_setmoneventlegal(struct ScriptContext *ctx) +// This command will set a Pokémon's fatefulEncounter bit; there is no similar command to clear it. +bool8 ScrCmd_setmonfatefulencounter(struct ScriptContext *ctx) { - bool8 isEventLegal = TRUE; + bool8 isFatefulEncounter = TRUE; u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - SetMonData(&gPlayerParty[partyIndex], MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); return FALSE; } -bool8 ScrCmd_checkmoneventlegal(struct ScriptContext *ctx) +bool8 ScrCmd_checkmonfatefulencounter(struct ScriptContext *ctx) { u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_EVENT_LEGAL, NULL); + gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, NULL); return FALSE; } diff --git a/src/trade.c b/src/trade.c index f8817421f2..a02cad9df1 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1577,7 +1577,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade illegitimate Deoxys or Mew if (partnerSpecies == SPECIES_DEOXYS || partnerSpecies == SPECIES_MEW) { - if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_EVENT_LEGAL)) + if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_FATEFUL_ENCOUNTER)) return PARTNER_MON_INVALID; } @@ -2426,7 +2426,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if (species[monIdx] == SPECIES_DEOXYS || species[monIdx] == SPECIES_MEW) { - if (!GetMonData(&playerParty[monIdx], MON_DATA_EVENT_LEGAL)) + if (!GetMonData(&playerParty[monIdx], MON_DATA_FATEFUL_ENCOUNTER)) return CANT_TRADE_INVALID_MON; } @@ -2491,17 +2491,17 @@ s32 GetGameProgressForLinkTrade(void) return TRADE_BOTH_PLAYERS_READY; } -static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isEventLegal) +static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isFatefulEncounter) { if (species == SPECIES_DEOXYS || species == SPECIES_MEW) { - if (!isEventLegal) + if (!isFatefulEncounter) return TRUE; } return FALSE; } -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal) +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isFatefulEncounter) { bool8 playerHasNationalDex = player.hasNationalDex; bool8 playerCanLinkNationally = player.canLinkNationally; @@ -2520,7 +2520,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf } // Cannot trade illegitimate Deoxys/Mew - if (IsDeoxysOrMewUntradable(playerSpecies, isEventLegal)) + if (IsDeoxysOrMewUntradable(playerSpecies, isFatefulEncounter)) return UR_TRADE_MSG_MON_CANT_BE_TRADED_2; if (partnerSpecies == SPECIES_EGG) @@ -2563,11 +2563,11 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf return UR_TRADE_MSG_NONE; } -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal) +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isFatefulEncounter) { bool8 hasNationalDex = player.hasNationalDex; - if (IsDeoxysOrMewUntradable(species, isEventLegal)) + if (IsDeoxysOrMewUntradable(species, isFatefulEncounter)) return CANT_REGISTER_MON; if (hasNationalDex) From 96865f66afc9872e142e6c26e597e4f5db32f42e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 11 Feb 2023 22:36:42 -0300 Subject: [PATCH 08/19] Updated term to modernFatefulEncounter --- asm/macros/event.inc | 14 +++++----- data/maps/BirthIsland_Exterior/scripts.inc | 2 +- data/maps/FarawayIsland_Interior/scripts.inc | 2 +- data/maps/NavelRock_Bottom/scripts.inc | 2 +- data/maps/NavelRock_Top/scripts.inc | 2 +- data/maps/SouthernIsland_Interior/scripts.inc | 4 +-- data/script_cmd_table.inc | 4 +-- data/scripts/gift_pichu.inc | 2 +- data/specials.inc | 2 +- include/pokemon.h | 27 ++++++++++++------- include/trade.h | 4 +-- src/battle_util.c | 4 +-- src/egg_hatch.c | 6 ++--- src/party_menu.c | 8 +++--- src/pokemon.c | 14 +++++----- src/scrcmd.c | 10 +++---- src/trade.c | 12 ++++----- 17 files changed, 63 insertions(+), 56 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index ed2e95c6c7..26a7e81579 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1576,15 +1576,15 @@ .4byte \value .endm - @ Sets the fatefulEncounter bit for the Pokemon in the specified slot of the player's party. - .macro setfatefulencounter slot:req + @ Sets the modernFatefulEncounter bit for the Pokemon in the specified slot of the player's party. + .macro setmodernfatefulencounter slot:req .byte 0xcd .2byte \slot .endm - @ Checks if the fatefulEncounter bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, + @ Checks if the modernFatefulEncounter bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, @ VAR_RESULT is TRUE. If the bit is set (or if the specified slot is empty or invalid), VAR_RESULT is FALSE. - .macro checkfatefulencounter slot:req + .macro checkmodernfatefulencounter slot:req .byte 0xce .2byte \slot .endm @@ -1932,10 +1932,10 @@ closebraillemessage .endm - @ Creates a Pokémon with the fatefulEncounter bit set for an encounter - .macro setfatefulencountermon species:req, level:req, item=ITEM_NONE + @ Creates a Pokémon with the modernFatefulEncounter bit set for an encounter + .macro setmodernfatefulencountermon species:req, level:req, item=ITEM_NONE setvar VAR_0x8004, \species setvar VAR_0x8005, \level setvar VAR_0x8006, \item - special CreateFatefulEncounterEnemyMon + special CreateModernFatefulEncounterEnemyMon .endm diff --git a/data/maps/BirthIsland_Exterior/scripts.inc b/data/maps/BirthIsland_Exterior/scripts.inc index 2b5d6ba1ad..4e38d8855e 100644 --- a/data/maps/BirthIsland_Exterior/scripts.inc +++ b/data/maps/BirthIsland_Exterior/scripts.inc @@ -85,7 +85,7 @@ BirthIsland_Exterior_EventScript_Deoxys:: delay 40 waitmoncry setvar VAR_LAST_TALKED, LOCALID_DEOXYS - setfatefulencountermon SPECIES_DEOXYS, 30 + setmodernfatefulencountermon SPECIES_DEOXYS, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/FarawayIsland_Interior/scripts.inc b/data/maps/FarawayIsland_Interior/scripts.inc index 1a7eb43c6b..91536c13bf 100644 --- a/data/maps/FarawayIsland_Interior/scripts.inc +++ b/data/maps/FarawayIsland_Interior/scripts.inc @@ -129,7 +129,7 @@ FarawayIsland_Interior_EventScript_Mew:: special DestroyMewEmergingGrassSprite delay 40 waitmoncry - setfatefulencountermon SPECIES_MEW, 30 + setmodernfatefulencountermon SPECIES_MEW, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Bottom/scripts.inc b/data/maps/NavelRock_Bottom/scripts.inc index cee6242f66..4230398d8b 100644 --- a/data/maps/NavelRock_Bottom/scripts.inc +++ b/data/maps/NavelRock_Bottom/scripts.inc @@ -53,7 +53,7 @@ NavelRock_Bottom_EventScript_Lugia:: playmoncry SPECIES_LUGIA, CRY_MODE_ENCOUNTER waitmoncry delay 20 - setfatefulencountermon SPECIES_LUGIA, 70 + setmodernfatefulencountermon SPECIES_LUGIA, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Top/scripts.inc b/data/maps/NavelRock_Top/scripts.inc index c25fbdb22b..4388c1d5c5 100644 --- a/data/maps/NavelRock_Top/scripts.inc +++ b/data/maps/NavelRock_Top/scripts.inc @@ -57,7 +57,7 @@ NavelRock_Top_EventScript_HoOh:: applymovement LOCALID_HO_OH, NavelRock_Top_Movement_HoOhApproach waitmovement 0 special RemoveCameraObject - setfatefulencountermon SPECIES_HO_OH, 70 + setmodernfatefulencountermon SPECIES_HO_OH, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/SouthernIsland_Interior/scripts.inc b/data/maps/SouthernIsland_Interior/scripts.inc index a0eaabff3c..77350c0768 100644 --- a/data/maps/SouthernIsland_Interior/scripts.inc +++ b/data/maps/SouthernIsland_Interior/scripts.inc @@ -105,11 +105,11 @@ SouthernIsland_Interior_EventScript_Sign:: end SouthernIsland_Interior_EventScript_SetLatiosBattleVars:: - setfatefulencountermon SPECIES_LATIOS, 50, ITEM_SOUL_DEW + setmodernfatefulencountermon SPECIES_LATIOS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_EventScript_SetLatiasBattleVars:: - setfatefulencountermon SPECIES_LATIAS, 50, ITEM_SOUL_DEW + setmodernfatefulencountermon SPECIES_LATIAS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_Movement_CameraPanUp: diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 7957e34eb4..d16e25e187 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -205,8 +205,8 @@ gScriptCmdTable:: .4byte ScrCmd_nop1 @ 0xca .4byte ScrCmd_nop1 @ 0xcb .4byte ScrCmd_nop1 @ 0xcc - .4byte ScrCmd_setmonfatefulencounter @ 0xcd - .4byte ScrCmd_checkmonfatefulencounter @ 0xce + .4byte ScrCmd_setmonmodernfatefulencounter @ 0xcd + .4byte ScrCmd_checkmonmodernfatefulencounter @ 0xce .4byte ScrCmd_trywondercardscript @ 0xcf .4byte ScrCmd_nop1 @ 0xd0 .4byte ScrCmd_warpspinenter @ 0xd1 diff --git a/data/scripts/gift_pichu.inc b/data/scripts/gift_pichu.inc index de2346a0a2..56c1e52349 100644 --- a/data/scripts/gift_pichu.inc +++ b/data/scripts/gift_pichu.inc @@ -29,7 +29,7 @@ SurfPichu_FullParty: SurfPichu_GiveEgg: giveegg SPECIES_PICHU - setfatefulencounter VAR_GIFT_PICHU_SLOT + setmodernfatefulencounter VAR_GIFT_PICHU_SLOT setmonmetlocation VAR_GIFT_PICHU_SLOT, METLOC_FATEFUL_ENCOUNTER vgoto_if_eq VAR_GIFT_PICHU_SLOT, 1, SurfPichu_Slot1 vgoto_if_eq VAR_GIFT_PICHU_SLOT, 2, SurfPichu_Slot2 diff --git a/data/specials.inc b/data/specials.inc index 9ea7df31a1..6d53864676 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -490,7 +490,7 @@ gSpecials:: def_special ScrollableMultichoice_ClosePersistentMenu def_special DoDeoxysRockInteraction def_special SetDeoxysRockPalette - def_special CreateFatefulEncounterEnemyMon + def_special CreateModernFatefulEncounterEnemyMon def_special StartMirageTowerDisintegration def_special StartMirageTowerShake def_special StartMirageTowerFossilFallAndSink diff --git a/include/pokemon.h b/include/pokemon.h index 8087d7b318..5836d2c34b 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -152,20 +152,27 @@ struct PokemonSubstruct3 /* 0x08 */ u32 cuteRibbon:3; /* 0x09 */ u32 smartRibbon:3; /* 0x09 */ u32 toughRibbon:3; - /* 0x09 */ u32 championRibbon:1; + /* 0x09 */ u32 championRibbon:1; // Shared by bo /* 0x0A */ u32 winningRibbon:1; /* 0x0A */ u32 victoryRibbon:1; /* 0x0A */ u32 artistRibbon:1; /* 0x0A */ u32 effortRibbon:1; - /* 0x0A */ u32 marineRibbon:1; // never distributed - /* 0x0A */ u32 landRibbon:1; // never distributed - /* 0x0A */ u32 skyRibbon:1; // never distributed - /* 0x0A */ u32 countryRibbon:1; // distributed during Pokémon Festa '04 and '05 to tournament winners + /* 0x0A */ u32 marineRibbon:1; // Never distributed. + /* 0x0A */ u32 landRibbon:1; // Never distributed. + /* 0x0A */ u32 skyRibbon:1; // Never distributed. + /* 0x0A */ u32 countryRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. /* 0x0B */ u32 nationalRibbon:1; /* 0x0B */ u32 earthRibbon:1; - /* 0x0B */ u32 worldRibbon:1; // distributed during Pokémon Festa '04 and '05 to tournament winners - /* 0x0B */ u32 unusedRibbons:4; // discarded in Gen 4 - /* 0x0B */ u32 fatefulEncounter:1; // controls Mew & Deoxys obedience; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness. + /* 0x0B */ u32 worldRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. + /* 0x0B */ u32 unusedRibbons:4; // Discarded in Gen 4. + + // The functionality of this bit changed in FRLG: + // In RS, this bit does nothing, is never set, & is accidentally unset when hatching Eggs. + // In FRLG & Emerald, this controls Mew & Deoxys obedience and whether they can be traded. + // If set, a Pokémon is a fateful encounter in FRLG's summary screen if hatched & for all Pokémon in Gen 4+ summary screens. + // Set for in-game event island legendaries, events distributed after a certain date, & Pokémon from XD: Gale of Darkness. + // Not to be confused with METLOC_FATEFUL_ENCOUNTER. + /* 0x0B */ u32 modernFatefulEncounter:1; }; // Number of bytes in the largest Pokémon substruct. @@ -401,12 +408,12 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest); -void CreateFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); +void CreateModernFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId); void SetDeoxysStats(void); u16 GetUnionRoomTrainerPic(void); u16 GetUnionRoomTrainerClass(void); -void CreateFatefulEncounterEnemyMon(void); +void CreateModernFatefulEncounterEnemyMon(void); void CalculateMonStats(struct Pokemon *mon); void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest); u8 GetLevelFromMonExp(struct Pokemon *mon); diff --git a/include/trade.h b/include/trade.h index f89d203e9c..6b621038fc 100644 --- a/include/trade.h +++ b/include/trade.h @@ -12,8 +12,8 @@ extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; s32 GetGameProgressForLinkTrade(void); void CB2_StartCreateTradeMenu(void); void CB2_LinkTrade(void); -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isFatefulEncounter); -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isFatefulEncounter); +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isModernFatefulEncounter); +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isModernFatefulEncounter); int CanSpinTradeMon(struct Pokemon *, u16); void InitTradeSequenceBgGpuRegs(void); void LinkTradeDrawWindow(void); diff --git a/src/battle_util.c b/src/battle_util.c index c3186671f5..007bf68831 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3885,7 +3885,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget) return targetBattler; } -static bool32 IsBattlerFatefulEncounter(u8 battlerId) +static bool32 IsBattlerModernFatefulEncounter(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) return TRUE; @@ -3906,7 +3906,7 @@ u8 IsMonDisobedient(void) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; - if (IsBattlerFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys + if (IsBattlerModernFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys { if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index b741a9b15a..bf615be061 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -313,7 +313,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) { u16 species; u32 personality, pokerus; - u8 i, friendship, language, gameMet, markings, isFatefulEncounter; + u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter; u16 moves[MAX_MON_MOVES]; u32 ivs[NUM_STATS]; @@ -332,7 +332,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) gameMet = GetMonData(egg, MON_DATA_MET_GAME); markings = GetMonData(egg, MON_DATA_MARKINGS); pokerus = GetMonData(egg, MON_DATA_POKERUS); - isFatefulEncounter = GetMonData(egg, MON_DATA_FATEFUL_ENCOUNTER); + isModernFatefulEncounter = GetMonData(egg, MON_DATA_FATEFUL_ENCOUNTER); CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); @@ -350,7 +350,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) friendship = 120; SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship); SetMonData(temp, MON_DATA_POKERUS, &pokerus); - SetMonData(temp, MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); + SetMonData(temp, MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); *egg = *temp; } diff --git a/src/party_menu.c b/src/party_menu.c index 571af54a41..8c84c5c030 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3591,9 +3591,9 @@ static void CursorCb_Register(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); - switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isFatefulEncounter)) + switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isModernFatefulEncounter)) { case CANT_REGISTER_MON: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); @@ -3618,8 +3618,8 @@ static void CursorCb_Trade1(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); - u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isFatefulEncounter); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); + u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isModernFatefulEncounter); if (stringId != UR_TRADE_MSG_NONE) { diff --git a/src/pokemon.c b/src/pokemon.c index e08a08103b..9b6ee977d6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2623,12 +2623,12 @@ void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerP GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); } -void CreateFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +void CreateModernFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) { - bool32 isFatefulEncounter = TRUE; + bool32 isModernFatefulEncounter = TRUE; CreateMon(mon, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); - SetMonData(mon, MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); + SetMonData(mon, MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); } // If FALSE, should load this game's Deoxys form. If TRUE, should load normal Deoxys form @@ -2763,14 +2763,14 @@ u16 GetUnionRoomTrainerClass(void) return gFacilityClassToTrainerClass[gUnionRoomFacilityClasses[arrId]]; } -void CreateFatefulEncounterEnemyMon(void) +void CreateModernFatefulEncounterEnemyMon(void) { s32 species = gSpecialVar_0x8004; s32 level = gSpecialVar_0x8005; s32 itemId = gSpecialVar_0x8006; ZeroEnemyPartyMons(); - CreateFatefulEncounterMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateModernFatefulEncounterMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); if (itemId) { u8 heldItem[2]; @@ -3958,7 +3958,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) retVal = substruct3->unusedRibbons; break; case MON_DATA_FATEFUL_ENCOUNTER: - retVal = substruct3->fatefulEncounter; + retVal = substruct3->modernFatefulEncounter; break; case MON_DATA_SPECIES2: retVal = substruct0->species; @@ -4342,7 +4342,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) SET8(substruct3->unusedRibbons); break; case MON_DATA_FATEFUL_ENCOUNTER: - SET8(substruct3->fatefulEncounter); + SET8(substruct3->modernFatefulEncounter); break; case MON_DATA_IVS: { diff --git a/src/scrcmd.c b/src/scrcmd.c index 56bea0843e..d055ff3a07 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2206,17 +2206,17 @@ bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx) } } -// This command will set a Pokémon's fatefulEncounter bit; there is no similar command to clear it. -bool8 ScrCmd_setmonfatefulencounter(struct ScriptContext *ctx) +// This command will set a Pokémon's modernFatefulEncounter bit; there is no similar command to clear it. +bool8 ScrCmd_setmonmodernfatefulencounter(struct ScriptContext *ctx) { - bool8 isFatefulEncounter = TRUE; + bool8 isModernFatefulEncounter = TRUE; u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - SetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, &isFatefulEncounter); + SetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); return FALSE; } -bool8 ScrCmd_checkmonfatefulencounter(struct ScriptContext *ctx) +bool8 ScrCmd_checkmonmodernfatefulencounter(struct ScriptContext *ctx) { u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); diff --git a/src/trade.c b/src/trade.c index a02cad9df1..508cde7cb5 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2491,17 +2491,17 @@ s32 GetGameProgressForLinkTrade(void) return TRADE_BOTH_PLAYERS_READY; } -static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isFatefulEncounter) +static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isModernFatefulEncounter) { if (species == SPECIES_DEOXYS || species == SPECIES_MEW) { - if (!isFatefulEncounter) + if (!isModernFatefulEncounter) return TRUE; } return FALSE; } -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isFatefulEncounter) +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isModernFatefulEncounter) { bool8 playerHasNationalDex = player.hasNationalDex; bool8 playerCanLinkNationally = player.canLinkNationally; @@ -2520,7 +2520,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf } // Cannot trade illegitimate Deoxys/Mew - if (IsDeoxysOrMewUntradable(playerSpecies, isFatefulEncounter)) + if (IsDeoxysOrMewUntradable(playerSpecies, isModernFatefulEncounter)) return UR_TRADE_MSG_MON_CANT_BE_TRADED_2; if (partnerSpecies == SPECIES_EGG) @@ -2563,11 +2563,11 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf return UR_TRADE_MSG_NONE; } -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isFatefulEncounter) +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isModernFatefulEncounter) { bool8 hasNationalDex = player.hasNationalDex; - if (IsDeoxysOrMewUntradable(species, isFatefulEncounter)) + if (IsDeoxysOrMewUntradable(species, isModernFatefulEncounter)) return CANT_REGISTER_MON; if (hasNationalDex) From a937b3221ac54fc48b9dde2294980d6585f7442c Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 11 Feb 2023 23:16:24 -0300 Subject: [PATCH 09/19] Documented Ribbons --- include/pokemon.h | 24 ++++++++++++------------ src/trade.c | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 5836d2c34b..273cb9175f 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -147,22 +147,22 @@ struct PokemonSubstruct3 /* 0x07 */ u32 isEgg:1; /* 0x07 */ u32 abilityNum:1; - /* 0x08 */ u32 coolRibbon:3; - /* 0x08 */ u32 beautyRibbon:3; - /* 0x08 */ u32 cuteRibbon:3; - /* 0x09 */ u32 smartRibbon:3; - /* 0x09 */ u32 toughRibbon:3; - /* 0x09 */ u32 championRibbon:1; // Shared by bo - /* 0x0A */ u32 winningRibbon:1; - /* 0x0A */ u32 victoryRibbon:1; - /* 0x0A */ u32 artistRibbon:1; - /* 0x0A */ u32 effortRibbon:1; + /* 0x08 */ u32 coolRibbon:3; // Stores the highest contest rank achieved in the Cool category. + /* 0x08 */ u32 beautyRibbon:3; // Stores the highest contest rank achieved in the Beauty category. + /* 0x08 */ u32 cuteRibbon:3; // Stores the highest contest rank achieved in the Cute category. + /* 0x09 */ u32 smartRibbon:3; // Stores the highest contest rank achieved in the Smart category. + /* 0x09 */ u32 toughRibbon:3; // Stores the highest contest rank achieved in the Tough category. + /* 0x09 */ u32 championRibbon:1; // Given when defeating the Champion in both RSE and FRLG. + /* 0x0A */ u32 winningRibbon:1; // Given at the Battle Tower's Level 50 challenge by winning a set of seven battles that extends the current streak to 56 or more. + /* 0x0A */ u32 victoryRibbon:1; // Given at the Battle Tower's Level 100 challenge by winning a set of seven battles that extends the current streak to 56 or more. + /* 0x0A */ u32 artistRibbon:1; // Given at the Contest Hall by winning a Master Rank contest with at least 800 points, and agreeing to have the Pokémon's portrait placed in the museum after being offered. + /* 0x0A */ u32 effortRibbon:1; // Given at Slateport's market to Pokémon with maximum EVs. /* 0x0A */ u32 marineRibbon:1; // Never distributed. /* 0x0A */ u32 landRibbon:1; // Never distributed. /* 0x0A */ u32 skyRibbon:1; // Never distributed. /* 0x0A */ u32 countryRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. - /* 0x0B */ u32 nationalRibbon:1; - /* 0x0B */ u32 earthRibbon:1; + /* 0x0B */ u32 nationalRibbon:1; // Given to purified Shadow Pokémon in Colosseum/XD. + /* 0x0B */ u32 earthRibbon:1; // Given to teams that have beaten Mt. Battle's 100-battle challenge in Colosseum/XD. /* 0x0B */ u32 worldRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. /* 0x0B */ u32 unusedRibbons:4; // Discarded in Gen 4. diff --git a/src/trade.c b/src/trade.c index 508cde7cb5..9e811888fd 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2380,7 +2380,7 @@ static void SaveTradeGiftRibbons(void) { if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenu->giftRibbons[i] != 0) { - if (sTradeMenu->giftRibbons[i] < 64) + if (sTradeMenu->giftRibbons[i] < MAX_GIFT_RIBBON) gSaveBlock1Ptr->giftRibbons[i] = sTradeMenu->giftRibbons[i]; } } From bd549903336848ac3b914eb36aeee832d446ff96 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 15 Feb 2023 13:56:11 -0300 Subject: [PATCH 10/19] Review changes --- asm/macros/event.inc | 4 +- data/maps/BirthIsland_Exterior/scripts.inc | 2 +- data/maps/FarawayIsland_Interior/scripts.inc | 2 +- data/maps/NavelRock_Bottom/scripts.inc | 2 +- data/maps/NavelRock_Top/scripts.inc | 2 +- data/maps/SouthernIsland_Interior/scripts.inc | 4 +- data/script_cmd_table.inc | 454 +++++++++--------- data/specials.inc | 2 +- include/pokemon.h | 5 +- src/battle_util.c | 2 +- src/egg_hatch.c | 4 +- src/party_menu.c | 4 +- src/pokemon.c | 12 +- src/scrcmd.c | 4 +- src/trade.c | 4 +- 15 files changed, 253 insertions(+), 254 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 26a7e81579..b91ac68210 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1933,9 +1933,9 @@ .endm @ Creates a Pokémon with the modernFatefulEncounter bit set for an encounter - .macro setmodernfatefulencountermon species:req, level:req, item=ITEM_NONE + .macro seteventmon species:req, level:req, item=ITEM_NONE setvar VAR_0x8004, \species setvar VAR_0x8005, \level setvar VAR_0x8006, \item - special CreateModernFatefulEncounterEnemyMon + special CreateEnemyEventMon .endm diff --git a/data/maps/BirthIsland_Exterior/scripts.inc b/data/maps/BirthIsland_Exterior/scripts.inc index 4e38d8855e..d2174eee99 100644 --- a/data/maps/BirthIsland_Exterior/scripts.inc +++ b/data/maps/BirthIsland_Exterior/scripts.inc @@ -85,7 +85,7 @@ BirthIsland_Exterior_EventScript_Deoxys:: delay 40 waitmoncry setvar VAR_LAST_TALKED, LOCALID_DEOXYS - setmodernfatefulencountermon SPECIES_DEOXYS, 30 + seteventmon SPECIES_DEOXYS, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/FarawayIsland_Interior/scripts.inc b/data/maps/FarawayIsland_Interior/scripts.inc index 91536c13bf..d3d519ed15 100644 --- a/data/maps/FarawayIsland_Interior/scripts.inc +++ b/data/maps/FarawayIsland_Interior/scripts.inc @@ -129,7 +129,7 @@ FarawayIsland_Interior_EventScript_Mew:: special DestroyMewEmergingGrassSprite delay 40 waitmoncry - setmodernfatefulencountermon SPECIES_MEW, 30 + seteventmon SPECIES_MEW, 30 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Bottom/scripts.inc b/data/maps/NavelRock_Bottom/scripts.inc index 4230398d8b..90cc229895 100644 --- a/data/maps/NavelRock_Bottom/scripts.inc +++ b/data/maps/NavelRock_Bottom/scripts.inc @@ -53,7 +53,7 @@ NavelRock_Bottom_EventScript_Lugia:: playmoncry SPECIES_LUGIA, CRY_MODE_ENCOUNTER waitmoncry delay 20 - setmodernfatefulencountermon SPECIES_LUGIA, 70 + seteventmon SPECIES_LUGIA, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/NavelRock_Top/scripts.inc b/data/maps/NavelRock_Top/scripts.inc index 4388c1d5c5..10969367a1 100644 --- a/data/maps/NavelRock_Top/scripts.inc +++ b/data/maps/NavelRock_Top/scripts.inc @@ -57,7 +57,7 @@ NavelRock_Top_EventScript_HoOh:: applymovement LOCALID_HO_OH, NavelRock_Top_Movement_HoOhApproach waitmovement 0 special RemoveCameraObject - setmodernfatefulencountermon SPECIES_HO_OH, 70 + seteventmon SPECIES_HO_OH, 70 setflag FLAG_SYS_CTRL_OBJ_DELETE special BattleSetup_StartLegendaryBattle waitstate diff --git a/data/maps/SouthernIsland_Interior/scripts.inc b/data/maps/SouthernIsland_Interior/scripts.inc index 77350c0768..8486739d93 100644 --- a/data/maps/SouthernIsland_Interior/scripts.inc +++ b/data/maps/SouthernIsland_Interior/scripts.inc @@ -105,11 +105,11 @@ SouthernIsland_Interior_EventScript_Sign:: end SouthernIsland_Interior_EventScript_SetLatiosBattleVars:: - setmodernfatefulencountermon SPECIES_LATIOS, 50, ITEM_SOUL_DEW + seteventmon SPECIES_LATIOS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_EventScript_SetLatiasBattleVars:: - setmodernfatefulencountermon SPECIES_LATIAS, 50, ITEM_SOUL_DEW + seteventmon SPECIES_LATIAS, 50, ITEM_SOUL_DEW return SouthernIsland_Interior_Movement_CameraPanUp: diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index d16e25e187..f50ce5322b 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -1,232 +1,232 @@ .align 2 gScriptCmdTable:: - .4byte ScrCmd_nop @ 0x00 - .4byte ScrCmd_nop1 @ 0x01 - .4byte ScrCmd_end @ 0x02 - .4byte ScrCmd_return @ 0x03 - .4byte ScrCmd_call @ 0x04 - .4byte ScrCmd_goto @ 0x05 - .4byte ScrCmd_goto_if @ 0x06 - .4byte ScrCmd_call_if @ 0x07 - .4byte ScrCmd_gotostd @ 0x08 - .4byte ScrCmd_callstd @ 0x09 - .4byte ScrCmd_gotostd_if @ 0x0a - .4byte ScrCmd_callstd_if @ 0x0b - .4byte ScrCmd_returnram @ 0x0c - .4byte ScrCmd_endram @ 0x0d - .4byte ScrCmd_setmysteryeventstatus @ 0x0e - .4byte ScrCmd_loadword @ 0x0f - .4byte ScrCmd_loadbyte @ 0x10 - .4byte ScrCmd_setptr @ 0x11 - .4byte ScrCmd_loadbytefromptr @ 0x12 - .4byte ScrCmd_setptrbyte @ 0x13 - .4byte ScrCmd_copylocal @ 0x14 - .4byte ScrCmd_copybyte @ 0x15 - .4byte ScrCmd_setvar @ 0x16 - .4byte ScrCmd_addvar @ 0x17 - .4byte ScrCmd_subvar @ 0x18 - .4byte ScrCmd_copyvar @ 0x19 - .4byte ScrCmd_setorcopyvar @ 0x1a - .4byte ScrCmd_compare_local_to_local @ 0x1b - .4byte ScrCmd_compare_local_to_value @ 0x1c - .4byte ScrCmd_compare_local_to_ptr @ 0x1d - .4byte ScrCmd_compare_ptr_to_local @ 0x1e - .4byte ScrCmd_compare_ptr_to_value @ 0x1f - .4byte ScrCmd_compare_ptr_to_ptr @ 0x20 - .4byte ScrCmd_compare_var_to_value @ 0x21 - .4byte ScrCmd_compare_var_to_var @ 0x22 - .4byte ScrCmd_callnative @ 0x23 - .4byte ScrCmd_gotonative @ 0x24 - .4byte ScrCmd_special @ 0x25 - .4byte ScrCmd_specialvar @ 0x26 - .4byte ScrCmd_waitstate @ 0x27 - .4byte ScrCmd_delay @ 0x28 - .4byte ScrCmd_setflag @ 0x29 - .4byte ScrCmd_clearflag @ 0x2a - .4byte ScrCmd_checkflag @ 0x2b - .4byte ScrCmd_initclock @ 0x2c - .4byte ScrCmd_dotimebasedevents @ 0x2d - .4byte ScrCmd_gettime @ 0x2e - .4byte ScrCmd_playse @ 0x2f - .4byte ScrCmd_waitse @ 0x30 - .4byte ScrCmd_playfanfare @ 0x31 - .4byte ScrCmd_waitfanfare @ 0x32 - .4byte ScrCmd_playbgm @ 0x33 - .4byte ScrCmd_savebgm @ 0x34 - .4byte ScrCmd_fadedefaultbgm @ 0x35 - .4byte ScrCmd_fadenewbgm @ 0x36 - .4byte ScrCmd_fadeoutbgm @ 0x37 - .4byte ScrCmd_fadeinbgm @ 0x38 - .4byte ScrCmd_warp @ 0x39 - .4byte ScrCmd_warpsilent @ 0x3a - .4byte ScrCmd_warpdoor @ 0x3b - .4byte ScrCmd_warphole @ 0x3c - .4byte ScrCmd_warpteleport @ 0x3d - .4byte ScrCmd_setwarp @ 0x3e - .4byte ScrCmd_setdynamicwarp @ 0x3f - .4byte ScrCmd_setdivewarp @ 0x40 - .4byte ScrCmd_setholewarp @ 0x41 - .4byte ScrCmd_getplayerxy @ 0x42 - .4byte ScrCmd_getpartysize @ 0x43 - .4byte ScrCmd_additem @ 0x44 - .4byte ScrCmd_removeitem @ 0x45 - .4byte ScrCmd_checkitemspace @ 0x46 - .4byte ScrCmd_checkitem @ 0x47 - .4byte ScrCmd_checkitemtype @ 0x48 - .4byte ScrCmd_addpcitem @ 0x49 - .4byte ScrCmd_checkpcitem @ 0x4a - .4byte ScrCmd_adddecoration @ 0x4b - .4byte ScrCmd_removedecoration @ 0x4c - .4byte ScrCmd_checkdecor @ 0x4d - .4byte ScrCmd_checkdecorspace @ 0x4e - .4byte ScrCmd_applymovement @ 0x4f - .4byte ScrCmd_applymovementat @ 0x50 - .4byte ScrCmd_waitmovement @ 0x51 - .4byte ScrCmd_waitmovementat @ 0x52 - .4byte ScrCmd_removeobject @ 0x53 - .4byte ScrCmd_removeobjectat @ 0x54 - .4byte ScrCmd_addobject @ 0x55 - .4byte ScrCmd_addobjectat @ 0x56 - .4byte ScrCmd_setobjectxy @ 0x57 - .4byte ScrCmd_showobjectat @ 0x58 - .4byte ScrCmd_hideobjectat @ 0x59 - .4byte ScrCmd_faceplayer @ 0x5a - .4byte ScrCmd_turnobject @ 0x5b - .4byte ScrCmd_trainerbattle @ 0x5c - .4byte ScrCmd_dotrainerbattle @ 0x5d - .4byte ScrCmd_gotopostbattlescript @ 0x5e - .4byte ScrCmd_gotobeatenscript @ 0x5f - .4byte ScrCmd_checktrainerflag @ 0x60 - .4byte ScrCmd_settrainerflag @ 0x61 - .4byte ScrCmd_cleartrainerflag @ 0x62 - .4byte ScrCmd_setobjectxyperm @ 0x63 - .4byte ScrCmd_copyobjectxytoperm @ 0x64 - .4byte ScrCmd_setobjectmovementtype @ 0x65 - .4byte ScrCmd_waitmessage @ 0x66 - .4byte ScrCmd_message @ 0x67 - .4byte ScrCmd_closemessage @ 0x68 - .4byte ScrCmd_lockall @ 0x69 - .4byte ScrCmd_lock @ 0x6a - .4byte ScrCmd_releaseall @ 0x6b - .4byte ScrCmd_release @ 0x6c - .4byte ScrCmd_waitbuttonpress @ 0x6d - .4byte ScrCmd_yesnobox @ 0x6e - .4byte ScrCmd_multichoice @ 0x6f - .4byte ScrCmd_multichoicedefault @ 0x70 - .4byte ScrCmd_multichoicegrid @ 0x71 - .4byte ScrCmd_drawbox @ 0x72 - .4byte ScrCmd_erasebox @ 0x73 - .4byte ScrCmd_drawboxtext @ 0x74 - .4byte ScrCmd_showmonpic @ 0x75 - .4byte ScrCmd_hidemonpic @ 0x76 - .4byte ScrCmd_showcontestpainting @ 0x77 - .4byte ScrCmd_braillemessage @ 0x78 - .4byte ScrCmd_givemon @ 0x79 - .4byte ScrCmd_giveegg @ 0x7a - .4byte ScrCmd_setmonmove @ 0x7b - .4byte ScrCmd_checkpartymove @ 0x7c - .4byte ScrCmd_bufferspeciesname @ 0x7d - .4byte ScrCmd_bufferleadmonspeciesname @ 0x7e - .4byte ScrCmd_bufferpartymonnick @ 0x7f - .4byte ScrCmd_bufferitemname @ 0x80 - .4byte ScrCmd_bufferdecorationname @ 0x81 - .4byte ScrCmd_buffermovename @ 0x82 - .4byte ScrCmd_buffernumberstring @ 0x83 - .4byte ScrCmd_bufferstdstring @ 0x84 - .4byte ScrCmd_bufferstring @ 0x85 - .4byte ScrCmd_pokemart @ 0x86 - .4byte ScrCmd_pokemartdecoration @ 0x87 - .4byte ScrCmd_pokemartdecoration2 @ 0x88 - .4byte ScrCmd_playslotmachine @ 0x89 - .4byte ScrCmd_setberrytree @ 0x8a - .4byte ScrCmd_choosecontestmon @ 0x8b - .4byte ScrCmd_startcontest @ 0x8c - .4byte ScrCmd_showcontestresults @ 0x8d - .4byte ScrCmd_contestlinktransfer @ 0x8e - .4byte ScrCmd_random @ 0x8f - .4byte ScrCmd_addmoney @ 0x90 - .4byte ScrCmd_removemoney @ 0x91 - .4byte ScrCmd_checkmoney @ 0x92 - .4byte ScrCmd_showmoneybox @ 0x93 - .4byte ScrCmd_hidemoneybox @ 0x94 - .4byte ScrCmd_updatemoneybox @ 0x95 - .4byte ScrCmd_getpokenewsactive @ 0x96 - .4byte ScrCmd_fadescreen @ 0x97 - .4byte ScrCmd_fadescreenspeed @ 0x98 - .4byte ScrCmd_setflashlevel @ 0x99 - .4byte ScrCmd_animateflash @ 0x9a - .4byte ScrCmd_messageautoscroll @ 0x9b - .4byte ScrCmd_dofieldeffect @ 0x9c - .4byte ScrCmd_setfieldeffectargument @ 0x9d - .4byte ScrCmd_waitfieldeffect @ 0x9e - .4byte ScrCmd_setrespawn @ 0x9f - .4byte ScrCmd_checkplayergender @ 0xa0 - .4byte ScrCmd_playmoncry @ 0xa1 - .4byte ScrCmd_setmetatile @ 0xa2 - .4byte ScrCmd_resetweather @ 0xa3 - .4byte ScrCmd_setweather @ 0xa4 - .4byte ScrCmd_doweather @ 0xa5 - .4byte ScrCmd_setstepcallback @ 0xa6 - .4byte ScrCmd_setmaplayoutindex @ 0xa7 - .4byte ScrCmd_setobjectsubpriority @ 0xa8 - .4byte ScrCmd_resetobjectsubpriority @ 0xa9 - .4byte ScrCmd_createvobject @ 0xaa - .4byte ScrCmd_turnvobject @ 0xab - .4byte ScrCmd_opendoor @ 0xac - .4byte ScrCmd_closedoor @ 0xad - .4byte ScrCmd_waitdooranim @ 0xae - .4byte ScrCmd_setdooropen @ 0xaf - .4byte ScrCmd_setdoorclosed @ 0xb0 - .4byte ScrCmd_addelevmenuitem @ 0xb1 - .4byte ScrCmd_showelevmenu @ 0xb2 - .4byte ScrCmd_checkcoins @ 0xb3 - .4byte ScrCmd_addcoins @ 0xb4 - .4byte ScrCmd_removecoins @ 0xb5 - .4byte ScrCmd_setwildbattle @ 0xb6 - .4byte ScrCmd_dowildbattle @ 0xb7 - .4byte ScrCmd_setvaddress @ 0xb8 - .4byte ScrCmd_vgoto @ 0xb9 - .4byte ScrCmd_vcall @ 0xba - .4byte ScrCmd_vgoto_if @ 0xbb - .4byte ScrCmd_vcall_if @ 0xbc - .4byte ScrCmd_vmessage @ 0xbd - .4byte ScrCmd_vbuffermessage @ 0xbe - .4byte ScrCmd_vbufferstring @ 0xbf - .4byte ScrCmd_showcoinsbox @ 0xc0 - .4byte ScrCmd_hidecoinsbox @ 0xc1 - .4byte ScrCmd_updatecoinsbox @ 0xc2 - .4byte ScrCmd_incrementgamestat @ 0xc3 - .4byte ScrCmd_setescapewarp @ 0xc4 - .4byte ScrCmd_waitmoncry @ 0xc5 - .4byte ScrCmd_bufferboxname @ 0xc6 - .4byte ScrCmd_nop1 @ 0xc7 - .4byte ScrCmd_nop1 @ 0xc8 - .4byte ScrCmd_nop1 @ 0xc9 - .4byte ScrCmd_nop1 @ 0xca - .4byte ScrCmd_nop1 @ 0xcb - .4byte ScrCmd_nop1 @ 0xcc - .4byte ScrCmd_setmonmodernfatefulencounter @ 0xcd - .4byte ScrCmd_checkmonmodernfatefulencounter @ 0xce - .4byte ScrCmd_trywondercardscript @ 0xcf - .4byte ScrCmd_nop1 @ 0xd0 - .4byte ScrCmd_warpspinenter @ 0xd1 - .4byte ScrCmd_setmonmetlocation @ 0xd2 - .4byte ScrCmd_moverotatingtileobjects @ 0xd3 - .4byte ScrCmd_turnrotatingtileobjects @ 0xd4 - .4byte ScrCmd_initrotatingtilepuzzle @ 0xd5 - .4byte ScrCmd_freerotatingtilepuzzle @ 0xd6 - .4byte ScrCmd_warpmossdeepgym @ 0xd7 - .4byte ScrCmd_selectapproachingtrainer @ 0xd8 - .4byte ScrCmd_lockfortrainer @ 0xd9 - .4byte ScrCmd_closebraillemessage @ 0xda - .4byte ScrCmd_messageinstant @ 0xdb - .4byte ScrCmd_fadescreenswapbuffers @ 0xdc - .4byte ScrCmd_buffertrainerclassname @ 0xdd - .4byte ScrCmd_buffertrainername @ 0xde - .4byte ScrCmd_pokenavcall @ 0xdf - .4byte ScrCmd_warpwhitefade @ 0xe0 - .4byte ScrCmd_buffercontestname @ 0xe1 - .4byte ScrCmd_bufferitemnameplural @ 0xe2 + .4byte ScrCmd_nop @ 0x00 + .4byte ScrCmd_nop1 @ 0x01 + .4byte ScrCmd_end @ 0x02 + .4byte ScrCmd_return @ 0x03 + .4byte ScrCmd_call @ 0x04 + .4byte ScrCmd_goto @ 0x05 + .4byte ScrCmd_goto_if @ 0x06 + .4byte ScrCmd_call_if @ 0x07 + .4byte ScrCmd_gotostd @ 0x08 + .4byte ScrCmd_callstd @ 0x09 + .4byte ScrCmd_gotostd_if @ 0x0a + .4byte ScrCmd_callstd_if @ 0x0b + .4byte ScrCmd_returnram @ 0x0c + .4byte ScrCmd_endram @ 0x0d + .4byte ScrCmd_setmysteryeventstatus @ 0x0e + .4byte ScrCmd_loadword @ 0x0f + .4byte ScrCmd_loadbyte @ 0x10 + .4byte ScrCmd_setptr @ 0x11 + .4byte ScrCmd_loadbytefromptr @ 0x12 + .4byte ScrCmd_setptrbyte @ 0x13 + .4byte ScrCmd_copylocal @ 0x14 + .4byte ScrCmd_copybyte @ 0x15 + .4byte ScrCmd_setvar @ 0x16 + .4byte ScrCmd_addvar @ 0x17 + .4byte ScrCmd_subvar @ 0x18 + .4byte ScrCmd_copyvar @ 0x19 + .4byte ScrCmd_setorcopyvar @ 0x1a + .4byte ScrCmd_compare_local_to_local @ 0x1b + .4byte ScrCmd_compare_local_to_value @ 0x1c + .4byte ScrCmd_compare_local_to_ptr @ 0x1d + .4byte ScrCmd_compare_ptr_to_local @ 0x1e + .4byte ScrCmd_compare_ptr_to_value @ 0x1f + .4byte ScrCmd_compare_ptr_to_ptr @ 0x20 + .4byte ScrCmd_compare_var_to_value @ 0x21 + .4byte ScrCmd_compare_var_to_var @ 0x22 + .4byte ScrCmd_callnative @ 0x23 + .4byte ScrCmd_gotonative @ 0x24 + .4byte ScrCmd_special @ 0x25 + .4byte ScrCmd_specialvar @ 0x26 + .4byte ScrCmd_waitstate @ 0x27 + .4byte ScrCmd_delay @ 0x28 + .4byte ScrCmd_setflag @ 0x29 + .4byte ScrCmd_clearflag @ 0x2a + .4byte ScrCmd_checkflag @ 0x2b + .4byte ScrCmd_initclock @ 0x2c + .4byte ScrCmd_dotimebasedevents @ 0x2d + .4byte ScrCmd_gettime @ 0x2e + .4byte ScrCmd_playse @ 0x2f + .4byte ScrCmd_waitse @ 0x30 + .4byte ScrCmd_playfanfare @ 0x31 + .4byte ScrCmd_waitfanfare @ 0x32 + .4byte ScrCmd_playbgm @ 0x33 + .4byte ScrCmd_savebgm @ 0x34 + .4byte ScrCmd_fadedefaultbgm @ 0x35 + .4byte ScrCmd_fadenewbgm @ 0x36 + .4byte ScrCmd_fadeoutbgm @ 0x37 + .4byte ScrCmd_fadeinbgm @ 0x38 + .4byte ScrCmd_warp @ 0x39 + .4byte ScrCmd_warpsilent @ 0x3a + .4byte ScrCmd_warpdoor @ 0x3b + .4byte ScrCmd_warphole @ 0x3c + .4byte ScrCmd_warpteleport @ 0x3d + .4byte ScrCmd_setwarp @ 0x3e + .4byte ScrCmd_setdynamicwarp @ 0x3f + .4byte ScrCmd_setdivewarp @ 0x40 + .4byte ScrCmd_setholewarp @ 0x41 + .4byte ScrCmd_getplayerxy @ 0x42 + .4byte ScrCmd_getpartysize @ 0x43 + .4byte ScrCmd_additem @ 0x44 + .4byte ScrCmd_removeitem @ 0x45 + .4byte ScrCmd_checkitemspace @ 0x46 + .4byte ScrCmd_checkitem @ 0x47 + .4byte ScrCmd_checkitemtype @ 0x48 + .4byte ScrCmd_addpcitem @ 0x49 + .4byte ScrCmd_checkpcitem @ 0x4a + .4byte ScrCmd_adddecoration @ 0x4b + .4byte ScrCmd_removedecoration @ 0x4c + .4byte ScrCmd_checkdecor @ 0x4d + .4byte ScrCmd_checkdecorspace @ 0x4e + .4byte ScrCmd_applymovement @ 0x4f + .4byte ScrCmd_applymovementat @ 0x50 + .4byte ScrCmd_waitmovement @ 0x51 + .4byte ScrCmd_waitmovementat @ 0x52 + .4byte ScrCmd_removeobject @ 0x53 + .4byte ScrCmd_removeobjectat @ 0x54 + .4byte ScrCmd_addobject @ 0x55 + .4byte ScrCmd_addobjectat @ 0x56 + .4byte ScrCmd_setobjectxy @ 0x57 + .4byte ScrCmd_showobjectat @ 0x58 + .4byte ScrCmd_hideobjectat @ 0x59 + .4byte ScrCmd_faceplayer @ 0x5a + .4byte ScrCmd_turnobject @ 0x5b + .4byte ScrCmd_trainerbattle @ 0x5c + .4byte ScrCmd_dotrainerbattle @ 0x5d + .4byte ScrCmd_gotopostbattlescript @ 0x5e + .4byte ScrCmd_gotobeatenscript @ 0x5f + .4byte ScrCmd_checktrainerflag @ 0x60 + .4byte ScrCmd_settrainerflag @ 0x61 + .4byte ScrCmd_cleartrainerflag @ 0x62 + .4byte ScrCmd_setobjectxyperm @ 0x63 + .4byte ScrCmd_copyobjectxytoperm @ 0x64 + .4byte ScrCmd_setobjectmovementtype @ 0x65 + .4byte ScrCmd_waitmessage @ 0x66 + .4byte ScrCmd_message @ 0x67 + .4byte ScrCmd_closemessage @ 0x68 + .4byte ScrCmd_lockall @ 0x69 + .4byte ScrCmd_lock @ 0x6a + .4byte ScrCmd_releaseall @ 0x6b + .4byte ScrCmd_release @ 0x6c + .4byte ScrCmd_waitbuttonpress @ 0x6d + .4byte ScrCmd_yesnobox @ 0x6e + .4byte ScrCmd_multichoice @ 0x6f + .4byte ScrCmd_multichoicedefault @ 0x70 + .4byte ScrCmd_multichoicegrid @ 0x71 + .4byte ScrCmd_drawbox @ 0x72 + .4byte ScrCmd_erasebox @ 0x73 + .4byte ScrCmd_drawboxtext @ 0x74 + .4byte ScrCmd_showmonpic @ 0x75 + .4byte ScrCmd_hidemonpic @ 0x76 + .4byte ScrCmd_showcontestpainting @ 0x77 + .4byte ScrCmd_braillemessage @ 0x78 + .4byte ScrCmd_givemon @ 0x79 + .4byte ScrCmd_giveegg @ 0x7a + .4byte ScrCmd_setmonmove @ 0x7b + .4byte ScrCmd_checkpartymove @ 0x7c + .4byte ScrCmd_bufferspeciesname @ 0x7d + .4byte ScrCmd_bufferleadmonspeciesname @ 0x7e + .4byte ScrCmd_bufferpartymonnick @ 0x7f + .4byte ScrCmd_bufferitemname @ 0x80 + .4byte ScrCmd_bufferdecorationname @ 0x81 + .4byte ScrCmd_buffermovename @ 0x82 + .4byte ScrCmd_buffernumberstring @ 0x83 + .4byte ScrCmd_bufferstdstring @ 0x84 + .4byte ScrCmd_bufferstring @ 0x85 + .4byte ScrCmd_pokemart @ 0x86 + .4byte ScrCmd_pokemartdecoration @ 0x87 + .4byte ScrCmd_pokemartdecoration2 @ 0x88 + .4byte ScrCmd_playslotmachine @ 0x89 + .4byte ScrCmd_setberrytree @ 0x8a + .4byte ScrCmd_choosecontestmon @ 0x8b + .4byte ScrCmd_startcontest @ 0x8c + .4byte ScrCmd_showcontestresults @ 0x8d + .4byte ScrCmd_contestlinktransfer @ 0x8e + .4byte ScrCmd_random @ 0x8f + .4byte ScrCmd_addmoney @ 0x90 + .4byte ScrCmd_removemoney @ 0x91 + .4byte ScrCmd_checkmoney @ 0x92 + .4byte ScrCmd_showmoneybox @ 0x93 + .4byte ScrCmd_hidemoneybox @ 0x94 + .4byte ScrCmd_updatemoneybox @ 0x95 + .4byte ScrCmd_getpokenewsactive @ 0x96 + .4byte ScrCmd_fadescreen @ 0x97 + .4byte ScrCmd_fadescreenspeed @ 0x98 + .4byte ScrCmd_setflashlevel @ 0x99 + .4byte ScrCmd_animateflash @ 0x9a + .4byte ScrCmd_messageautoscroll @ 0x9b + .4byte ScrCmd_dofieldeffect @ 0x9c + .4byte ScrCmd_setfieldeffectargument @ 0x9d + .4byte ScrCmd_waitfieldeffect @ 0x9e + .4byte ScrCmd_setrespawn @ 0x9f + .4byte ScrCmd_checkplayergender @ 0xa0 + .4byte ScrCmd_playmoncry @ 0xa1 + .4byte ScrCmd_setmetatile @ 0xa2 + .4byte ScrCmd_resetweather @ 0xa3 + .4byte ScrCmd_setweather @ 0xa4 + .4byte ScrCmd_doweather @ 0xa5 + .4byte ScrCmd_setstepcallback @ 0xa6 + .4byte ScrCmd_setmaplayoutindex @ 0xa7 + .4byte ScrCmd_setobjectsubpriority @ 0xa8 + .4byte ScrCmd_resetobjectsubpriority @ 0xa9 + .4byte ScrCmd_createvobject @ 0xaa + .4byte ScrCmd_turnvobject @ 0xab + .4byte ScrCmd_opendoor @ 0xac + .4byte ScrCmd_closedoor @ 0xad + .4byte ScrCmd_waitdooranim @ 0xae + .4byte ScrCmd_setdooropen @ 0xaf + .4byte ScrCmd_setdoorclosed @ 0xb0 + .4byte ScrCmd_addelevmenuitem @ 0xb1 + .4byte ScrCmd_showelevmenu @ 0xb2 + .4byte ScrCmd_checkcoins @ 0xb3 + .4byte ScrCmd_addcoins @ 0xb4 + .4byte ScrCmd_removecoins @ 0xb5 + .4byte ScrCmd_setwildbattle @ 0xb6 + .4byte ScrCmd_dowildbattle @ 0xb7 + .4byte ScrCmd_setvaddress @ 0xb8 + .4byte ScrCmd_vgoto @ 0xb9 + .4byte ScrCmd_vcall @ 0xba + .4byte ScrCmd_vgoto_if @ 0xbb + .4byte ScrCmd_vcall_if @ 0xbc + .4byte ScrCmd_vmessage @ 0xbd + .4byte ScrCmd_vbuffermessage @ 0xbe + .4byte ScrCmd_vbufferstring @ 0xbf + .4byte ScrCmd_showcoinsbox @ 0xc0 + .4byte ScrCmd_hidecoinsbox @ 0xc1 + .4byte ScrCmd_updatecoinsbox @ 0xc2 + .4byte ScrCmd_incrementgamestat @ 0xc3 + .4byte ScrCmd_setescapewarp @ 0xc4 + .4byte ScrCmd_waitmoncry @ 0xc5 + .4byte ScrCmd_bufferboxname @ 0xc6 + .4byte ScrCmd_nop1 @ 0xc7 + .4byte ScrCmd_nop1 @ 0xc8 + .4byte ScrCmd_nop1 @ 0xc9 + .4byte ScrCmd_nop1 @ 0xca + .4byte ScrCmd_nop1 @ 0xcb + .4byte ScrCmd_nop1 @ 0xcc + .4byte ScrCmd_setmonmodernfatefulencounter @ 0xcd + .4byte ScrCmd_checkmonmodernfatefulencounter @ 0xce + .4byte ScrCmd_trywondercardscript @ 0xcf + .4byte ScrCmd_nop1 @ 0xd0 + .4byte ScrCmd_warpspinenter @ 0xd1 + .4byte ScrCmd_setmonmetlocation @ 0xd2 + .4byte ScrCmd_moverotatingtileobjects @ 0xd3 + .4byte ScrCmd_turnrotatingtileobjects @ 0xd4 + .4byte ScrCmd_initrotatingtilepuzzle @ 0xd5 + .4byte ScrCmd_freerotatingtilepuzzle @ 0xd6 + .4byte ScrCmd_warpmossdeepgym @ 0xd7 + .4byte ScrCmd_selectapproachingtrainer @ 0xd8 + .4byte ScrCmd_lockfortrainer @ 0xd9 + .4byte ScrCmd_closebraillemessage @ 0xda + .4byte ScrCmd_messageinstant @ 0xdb + .4byte ScrCmd_fadescreenswapbuffers @ 0xdc + .4byte ScrCmd_buffertrainerclassname @ 0xdd + .4byte ScrCmd_buffertrainername @ 0xde + .4byte ScrCmd_pokenavcall @ 0xdf + .4byte ScrCmd_warpwhitefade @ 0xe0 + .4byte ScrCmd_buffercontestname @ 0xe1 + .4byte ScrCmd_bufferitemnameplural @ 0xe2 gScriptCmdTableEnd:: .4byte ScrCmd_nop diff --git a/data/specials.inc b/data/specials.inc index 6d53864676..a0dbde8683 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -490,7 +490,7 @@ gSpecials:: def_special ScrollableMultichoice_ClosePersistentMenu def_special DoDeoxysRockInteraction def_special SetDeoxysRockPalette - def_special CreateModernFatefulEncounterEnemyMon + def_special CreateEnemyEventMon def_special StartMirageTowerDisintegration def_special StartMirageTowerShake def_special StartMirageTowerFossilFallAndSink diff --git a/include/pokemon.h b/include/pokemon.h index 273cb9175f..0375b20dc0 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -85,7 +85,7 @@ enum { MON_DATA_EARTH_RIBBON, MON_DATA_WORLD_RIBBON, MON_DATA_UNUSED_RIBBONS, - MON_DATA_FATEFUL_ENCOUNTER, + MON_DATA_MODERN_FATEFUL_ENCOUNTER, MON_DATA_KNOWN_MOVES, MON_DATA_RIBBON_COUNT, MON_DATA_RIBBONS, @@ -408,12 +408,11 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest); -void CreateModernFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId); void SetDeoxysStats(void); u16 GetUnionRoomTrainerPic(void); u16 GetUnionRoomTrainerClass(void); -void CreateModernFatefulEncounterEnemyMon(void); +void CreateEnemyEventMon(void); void CalculateMonStats(struct Pokemon *mon); void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest); u8 GetLevelFromMonExp(struct Pokemon *mon); diff --git a/src/battle_util.c b/src/battle_util.c index 007bf68831..9f06bf36bf 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3892,7 +3892,7 @@ static bool32 IsBattlerModernFatefulEncounter(u8 battlerId) if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_MEW) return TRUE; - return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_FATEFUL_ENCOUNTER, NULL); + return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_MODERN_FATEFUL_ENCOUNTER, NULL); } u8 IsMonDisobedient(void) diff --git a/src/egg_hatch.c b/src/egg_hatch.c index bf615be061..96d431a226 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -332,7 +332,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) gameMet = GetMonData(egg, MON_DATA_MET_GAME); markings = GetMonData(egg, MON_DATA_MARKINGS); pokerus = GetMonData(egg, MON_DATA_POKERUS); - isModernFatefulEncounter = GetMonData(egg, MON_DATA_FATEFUL_ENCOUNTER); + isModernFatefulEncounter = GetMonData(egg, MON_DATA_MODERN_FATEFUL_ENCOUNTER); CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); @@ -350,7 +350,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) friendship = 120; SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship); SetMonData(temp, MON_DATA_POKERUS, &pokerus); - SetMonData(temp, MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); + SetMonData(temp, MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); *egg = *temp; } diff --git a/src/party_menu.c b/src/party_menu.c index 8c84c5c030..dcc3974c16 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3591,7 +3591,7 @@ static void CursorCb_Register(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MODERN_FATEFUL_ENCOUNTER); switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isModernFatefulEncounter)) { @@ -3618,7 +3618,7 @@ static void CursorCb_Trade1(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_FATEFUL_ENCOUNTER); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MODERN_FATEFUL_ENCOUNTER); u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isModernFatefulEncounter); if (stringId != UR_TRADE_MSG_NONE) diff --git a/src/pokemon.c b/src/pokemon.c index 9b6ee977d6..1c55091e0d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2623,12 +2623,12 @@ void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerP GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); } -void CreateModernFatefulEncounterMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +static void CreateEventMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) { bool32 isModernFatefulEncounter = TRUE; CreateMon(mon, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); - SetMonData(mon, MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); + SetMonData(mon, MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); } // If FALSE, should load this game's Deoxys form. If TRUE, should load normal Deoxys form @@ -2763,14 +2763,14 @@ u16 GetUnionRoomTrainerClass(void) return gFacilityClassToTrainerClass[gUnionRoomFacilityClasses[arrId]]; } -void CreateModernFatefulEncounterEnemyMon(void) +void CreateEnemyEventMon(void) { s32 species = gSpecialVar_0x8004; s32 level = gSpecialVar_0x8005; s32 itemId = gSpecialVar_0x8006; ZeroEnemyPartyMons(); - CreateModernFatefulEncounterMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateEventMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); if (itemId) { u8 heldItem[2]; @@ -3957,7 +3957,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_UNUSED_RIBBONS: retVal = substruct3->unusedRibbons; break; - case MON_DATA_FATEFUL_ENCOUNTER: + case MON_DATA_MODERN_FATEFUL_ENCOUNTER: retVal = substruct3->modernFatefulEncounter; break; case MON_DATA_SPECIES2: @@ -4341,7 +4341,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_UNUSED_RIBBONS: SET8(substruct3->unusedRibbons); break; - case MON_DATA_FATEFUL_ENCOUNTER: + case MON_DATA_MODERN_FATEFUL_ENCOUNTER: SET8(substruct3->modernFatefulEncounter); break; case MON_DATA_IVS: diff --git a/src/scrcmd.c b/src/scrcmd.c index d055ff3a07..18a56631d3 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2212,7 +2212,7 @@ bool8 ScrCmd_setmonmodernfatefulencounter(struct ScriptContext *ctx) bool8 isModernFatefulEncounter = TRUE; u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - SetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); + SetMonData(&gPlayerParty[partyIndex], MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); return FALSE; } @@ -2220,7 +2220,7 @@ bool8 ScrCmd_checkmonmodernfatefulencounter(struct ScriptContext *ctx) { u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_FATEFUL_ENCOUNTER, NULL); + gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MODERN_FATEFUL_ENCOUNTER, NULL); return FALSE; } diff --git a/src/trade.c b/src/trade.c index 9e811888fd..04f9efce9f 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1577,7 +1577,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade illegitimate Deoxys or Mew if (partnerSpecies == SPECIES_DEOXYS || partnerSpecies == SPECIES_MEW) { - if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_FATEFUL_ENCOUNTER)) + if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_MODERN_FATEFUL_ENCOUNTER)) return PARTNER_MON_INVALID; } @@ -2426,7 +2426,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if (species[monIdx] == SPECIES_DEOXYS || species[monIdx] == SPECIES_MEW) { - if (!GetMonData(&playerParty[monIdx], MON_DATA_FATEFUL_ENCOUNTER)) + if (!GetMonData(&playerParty[monIdx], MON_DATA_MODERN_FATEFUL_ENCOUNTER)) return CANT_TRADE_INVALID_MON; } From dbd02d3a56f83f2f85d3b8c0b0c5c97f6579bc39 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 15 Feb 2023 14:06:42 -0300 Subject: [PATCH 11/19] Clarified Champion Ribbon's description to avoid being interpreted as needing to beat the champion in both RSE and FRLG. --- include/pokemon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pokemon.h b/include/pokemon.h index 0375b20dc0..897f54762c 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -152,7 +152,7 @@ struct PokemonSubstruct3 /* 0x08 */ u32 cuteRibbon:3; // Stores the highest contest rank achieved in the Cute category. /* 0x09 */ u32 smartRibbon:3; // Stores the highest contest rank achieved in the Smart category. /* 0x09 */ u32 toughRibbon:3; // Stores the highest contest rank achieved in the Tough category. - /* 0x09 */ u32 championRibbon:1; // Given when defeating the Champion in both RSE and FRLG. + /* 0x09 */ u32 championRibbon:1; // Given when defeating the Champion. Because both RSE and FRLG use it, later generations don't specify from which region it comes from. /* 0x0A */ u32 winningRibbon:1; // Given at the Battle Tower's Level 50 challenge by winning a set of seven battles that extends the current streak to 56 or more. /* 0x0A */ u32 victoryRibbon:1; // Given at the Battle Tower's Level 100 challenge by winning a set of seven battles that extends the current streak to 56 or more. /* 0x0A */ u32 artistRibbon:1; // Given at the Contest Hall by winning a Master Rank contest with at least 800 points, and agreeing to have the Pokémon's portrait placed in the museum after being offered. From bc3805f9d32d532088214fe38492d8d92c6c6666 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 17 Feb 2023 13:27:39 -0500 Subject: [PATCH 12/19] Fix two binary palettes --- graphics/battle_anims/sprites/black_ball.bin | Bin 36 -> 0 bytes graphics/battle_anims/sprites/black_ball.pal | 19 ++++++++++++++++++ .../battle_anims/unused/line_sketch_2.pal | 19 ++++++++++++++++++ .../battle_anims/unused/line_sketch_2_pal.bin | Bin 32 -> 0 bytes src/graphics.c | 4 ++-- 5 files changed, 40 insertions(+), 2 deletions(-) delete mode 100644 graphics/battle_anims/sprites/black_ball.bin create mode 100644 graphics/battle_anims/sprites/black_ball.pal create mode 100644 graphics/battle_anims/unused/line_sketch_2.pal delete mode 100644 graphics/battle_anims/unused/line_sketch_2_pal.bin diff --git a/graphics/battle_anims/sprites/black_ball.bin b/graphics/battle_anims/sprites/black_ball.bin deleted file mode 100644 index 4a6592a8edc36cade78caec09192fd5174eb5e6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36 pcmWeoU|>)%HWpwsa5iRUW;Zc5aByZ|V_;`s=5Tg4HU=^o7yw7&1D^l@ diff --git a/graphics/battle_anims/sprites/black_ball.pal b/graphics/battle_anims/sprites/black_ball.pal new file mode 100644 index 0000000000..57e320140e --- /dev/null +++ b/graphics/battle_anims/sprites/black_ball.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +156 205 98 +156 205 98 +156 205 98 +131 205 131 +156 205 0 +24 0 106 +156 8 98 +0 213 131 +24 197 0 +164 8 106 +156 8 98 +164 8 106 +156 205 131 +24 213 98 +156 8 106 +164 205 98 diff --git a/graphics/battle_anims/unused/line_sketch_2.pal b/graphics/battle_anims/unused/line_sketch_2.pal new file mode 100644 index 0000000000..17cce5c65e --- /dev/null +++ b/graphics/battle_anims/unused/line_sketch_2.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +0 0 255 +0 255 255 +148 255 255 +148 205 255 +148 156 255 +0 0 0 +0 0 0 +0 0 0 +255 0 8 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +255 255 255 diff --git a/graphics/battle_anims/unused/line_sketch_2_pal.bin b/graphics/battle_anims/unused/line_sketch_2_pal.bin deleted file mode 100644 index 15379a9ceae794c6755d5198ba223866efd6138a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32 kcmWeoU;u-f2lb!od5r3d>KM2g80A?G7_bX4{;y{M0C$E5-v9sr diff --git a/src/graphics.c b/src/graphics.c index f6b3ce0af2..40ed78ae69 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -69,7 +69,7 @@ const u32 gBattleAnimSpriteGfx_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/ const u32 gBattleAnimSpritePal_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/sprites/black_smoke.gbapal.lz"); const u32 gBattleAnimSpriteGfx_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.4bpp.lz"); -const u32 gBattleAnimSpritePal_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.bin"); +const u32 gBattleAnimSpritePal_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.gbapal.lz"); const u32 gBattleAnimSpritePal_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.4bpp.lz"); @@ -257,7 +257,7 @@ const u16 gBattleAnimUnused_Unknown2[] = INCBIN_U16("graphics/battle_anims/unuse const u16 gBattleAnimUnused_Unknown3[] = INCBIN_U16("graphics/battle_anims/unused/unknown_3.bin"); const u32 gBattleAnimUnusedGfx_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.8bpp.lz"); -const u16 gBattleAnimUnusedPal_LineSketch2[] = INCBIN_U16("graphics/battle_anims/unused/line_sketch_2_pal.bin"); +const u16 gBattleAnimUnusedPal_LineSketch2[] = INCBIN_U16("graphics/battle_anims/unused/line_sketch_2.gbapal.lz"); const u32 gBattleAnimUnusedTilemap_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.bin.lz"); const u32 gBattleAnimSpriteGfx_BlueLines[] = INCBIN_U32("graphics/battle_anims/sprites/blue_lines.4bpp.lz"); From 4be4ec30815e21c342c7f769b94e10491f17cdf5 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 17 Feb 2023 16:43:22 -0300 Subject: [PATCH 13/19] metatitleBehavior -> metatileBehavior --- src/bike.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bike.c b/src/bike.c index ae30ce288b..ae9dfd3e91 100644 --- a/src/bike.c +++ b/src/bike.c @@ -863,23 +863,23 @@ static u8 Bike_DPadToDirection(u16 heldKeys) static u8 GetBikeCollision(u8 direction) { - u8 metatitleBehavior; + u8 metatileBehavior; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; s16 x = playerObjEvent->currentCoords.x; s16 y = playerObjEvent->currentCoords.y; MoveCoords(direction, &x, &y); - metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y); - return GetBikeCollisionAt(playerObjEvent, x, y, direction, metatitleBehavior); + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + return GetBikeCollisionAt(playerObjEvent, x, y, direction, metatileBehavior); } -static u8 GetBikeCollisionAt(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatitleBehavior) +static u8 GetBikeCollisionAt(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) { - u8 collision = CheckForObjectEventCollision(objectEvent, x, y, direction, metatitleBehavior); + u8 collision = CheckForObjectEventCollision(objectEvent, x, y, direction, metatileBehavior); if (collision > COLLISION_OBJECT_EVENT) return collision; - if (collision == COLLISION_NONE && IsRunningDisallowedByMetatile(metatitleBehavior)) + if (collision == COLLISION_NONE && IsRunningDisallowedByMetatile(metatileBehavior)) collision = COLLISION_IMPASSABLE; if (collision) From 8f74a6777afc43eb0093b326ae6c69b4ca6ac38d Mon Sep 17 00:00:00 2001 From: Zunawe Date: Mon, 20 Feb 2023 18:17:30 -0800 Subject: [PATCH 14/19] Fix spelling mistake for item flag --- data/maps/PetalburgWoods/map.json | 2 +- include/constants/flags.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/maps/PetalburgWoods/map.json b/data/maps/PetalburgWoods/map.json index 4179d81957..2979e7e469 100644 --- a/data/maps/PetalburgWoods/map.json +++ b/data/maps/PetalburgWoods/map.json @@ -168,7 +168,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "PetalburgWoods_EventScript_ItemParalyzeHeal", - "flag": "FLAG_ITEM_PETALBURD_WOODS_PARALYZE_HEAL" + "flag": "FLAG_ITEM_PETALBURG_WOODS_PARALYZE_HEAL" }, { "graphics_id": "OBJ_EVENT_GFX_GIRL_2", diff --git a/include/constants/flags.h b/include/constants/flags.h index 4e108e1fe9..f39a7219c0 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1162,7 +1162,7 @@ #define FLAG_ITEM_ROUTE_103_GUARD_SPEC 0x45A #define FLAG_ITEM_ROUTE_104_X_ACCURACY 0x45B #define FLAG_ITEM_MAUVILLE_CITY_X_SPEED 0x45C -#define FLAG_ITEM_PETALBURD_WOODS_PARALYZE_HEAL 0x45D +#define FLAG_ITEM_PETALBURG_WOODS_PARALYZE_HEAL 0x45D #define FLAG_ITEM_ROUTE_115_GREAT_BALL 0x45E #define FLAG_ITEM_SAFARI_ZONE_NORTH_CALCIUM 0x45F #define FLAG_ITEM_MT_PYRE_3F_SUPER_REPEL 0x460 From 60be59d18b04ef0dec2ee0948dfcfaeda59ad059 Mon Sep 17 00:00:00 2001 From: Zunawe Date: Wed, 22 Feb 2023 13:13:57 -0800 Subject: [PATCH 15/19] Fix wrong route in hidden item flag name --- data/maps/Route114/map.json | 2 +- include/constants/flags.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/maps/Route114/map.json b/data/maps/Route114/map.json index 10f15233c9..17c483c0fa 100644 --- a/data/maps/Route114/map.json +++ b/data/maps/Route114/map.json @@ -503,7 +503,7 @@ "y": 30, "elevation": 3, "item": "ITEM_REVIVE", - "flag": "FLAG_HIDDEN_ITEM_ROUTE_113_REVIVE" + "flag": "FLAG_HIDDEN_ITEM_ROUTE_114_REVIVE" } ] } diff --git a/include/constants/flags.h b/include/constants/flags.h index f39a7219c0..4bef779385 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -580,7 +580,7 @@ #define FLAG_HIDDEN_ITEM_ROUTE_121_HP_UP (FLAG_HIDDEN_ITEMS_START + 0x27) #define FLAG_HIDDEN_ITEM_ROUTE_121_NUGGET (FLAG_HIDDEN_ITEMS_START + 0x28) #define FLAG_HIDDEN_ITEM_ROUTE_123_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x29) -#define FLAG_HIDDEN_ITEM_ROUTE_113_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x2A) +#define FLAG_HIDDEN_ITEM_ROUTE_114_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x2A) #define FLAG_HIDDEN_ITEM_LILYCOVE_CITY_PP_UP (FLAG_HIDDEN_ITEMS_START + 0x2B) #define FLAG_HIDDEN_ITEM_ROUTE_104_SUPER_POTION (FLAG_HIDDEN_ITEMS_START + 0x2C) #define FLAG_HIDDEN_ITEM_ROUTE_116_SUPER_POTION (FLAG_HIDDEN_ITEMS_START + 0x2D) From 079ca8ab2925c572c96a7042f2ce6d275bb844ba Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 24 Feb 2023 07:53:02 -0300 Subject: [PATCH 16/19] Renamed MON_DATA_SPECIES2 to MON_DATA_SPECIES_OR_EGG for clarification --- include/pokemon.h | 2 +- src/battle_ai_script_commands.c | 4 +- src/battle_ai_switch_items.c | 20 +++++----- src/battle_controllers.c | 14 +++---- src/battle_main.c | 66 ++++++++++++++++----------------- src/battle_script_commands.c | 18 ++++----- src/battle_setup.c | 2 +- src/battle_tower.c | 2 +- src/battle_util.c | 16 ++++---- src/braille_puzzles.c | 4 +- src/dodrio_berry_picking.c | 2 +- src/field_poison.c | 2 +- src/field_specials.c | 8 ++-- src/frontier_util.c | 2 +- src/hall_of_fame.c | 2 +- src/menu_specialized.c | 2 +- src/mystery_event_script.c | 2 +- src/party_menu.c | 6 +-- src/pokeblock_feed.c | 6 +-- src/pokemon.c | 20 +++++----- src/pokemon_jump.c | 2 +- src/pokemon_storage_system.c | 20 +++++----- src/pokemon_summary_screen.c | 2 +- src/pokenav_conditions.c | 2 +- src/roulette.c | 2 +- src/script_pokemon_util.c | 2 +- src/trade.c | 14 +++---- src/union_room.c | 12 +++--- 28 files changed, 128 insertions(+), 128 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index ab102000a3..c845227461 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -70,7 +70,7 @@ enum { MON_DATA_SPATK, MON_DATA_SPDEF, MON_DATA_MAIL, - MON_DATA_SPECIES2, + MON_DATA_SPECIES_OR_EGG, MON_DATA_IVS, MON_DATA_CHAMPION_RIBBON, MON_DATA_WINNING_RIBBON, diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index aacbe20ac4..2152be374a 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1329,8 +1329,8 @@ static void Cmd_count_usable_party_mons(void) { if (i != battlerOnField1 && i != battlerOnField2 && GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { AI_THINKING_STRUCT->funcResult++; } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 13cfb9bfdc..5789a3ff6f 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -86,9 +86,9 @@ static bool8 ShouldSwitchIfWonderGuard(void) { if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[gActiveBattler]) continue; @@ -184,9 +184,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -382,9 +382,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -488,9 +488,9 @@ static bool8 ShouldSwitch(void) { if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -823,8 +823,8 @@ static bool8 ShouldUseItem(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { validMons++; } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index e5cfb3be68..b93e65fdc0 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -592,8 +592,8 @@ static void SetBattlePartyIds(void) if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) { if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 - && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG)) { gBattlerPartyIndexes[i] = j; @@ -603,8 +603,8 @@ static void SetBattlePartyIds(void) else { if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 - && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG)) { gBattlerPartyIndexes[i] = j; @@ -618,7 +618,7 @@ static void SetBattlePartyIds(void) { if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES) != SPECIES_NONE // Probably a typo by Game Freak. The rest use SPECIES2. - && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) && gBattlerPartyIndexes[i - 2] != j) { @@ -629,8 +629,8 @@ static void SetBattlePartyIds(void) else { if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 - && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) && gBattlerPartyIndexes[i - 2] != j) { diff --git a/src/battle_main.c b/src/battle_main.c index 508cc400fd..b8fea024ee 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -712,33 +712,33 @@ static void CB2_InitBattleInternal(void) gBattleCommunication[MULTIUSE_STATE] = 0; } -#define BUFFER_PARTY_VS_SCREEN_STATUS(party, flags, i) \ - for ((i) = 0; (i) < PARTY_SIZE; (i)++) \ - { \ - u16 species = GetMonData(&(party)[(i)], MON_DATA_SPECIES2); \ - u16 hp = GetMonData(&(party)[(i)], MON_DATA_HP); \ - u32 status = GetMonData(&(party)[(i)], MON_DATA_STATUS); \ - \ - if (species == SPECIES_NONE) \ - continue; \ - \ - /* Is healthy mon? */ \ - if (species != SPECIES_EGG && hp != 0 && status == 0) \ - (flags) |= 1 << (i) * 2; \ - \ - if (species == SPECIES_NONE) /* Redundant */ \ - continue; \ - \ - /* Is Egg or statused? */ \ - if (hp != 0 && (species == SPECIES_EGG || status != 0)) \ - (flags) |= 2 << (i) * 2; \ - \ - if (species == SPECIES_NONE) /* Redundant */ \ - continue; \ - \ - /* Is fainted? */ \ - if (species != SPECIES_EGG && hp == 0) \ - (flags) |= 3 << (i) * 2; \ +#define BUFFER_PARTY_VS_SCREEN_STATUS(party, flags, i) \ + for ((i) = 0; (i) < PARTY_SIZE; (i)++) \ + { \ + u16 species = GetMonData(&(party)[(i)], MON_DATA_SPECIES_OR_EGG); \ + u16 hp = GetMonData(&(party)[(i)], MON_DATA_HP); \ + u32 status = GetMonData(&(party)[(i)], MON_DATA_STATUS); \ + \ + if (species == SPECIES_NONE) \ + continue; \ + \ + /* Is healthy mon? */ \ + if (species != SPECIES_EGG && hp != 0 && status == 0) \ + (flags) |= 1 << (i) * 2; \ + \ + if (species == SPECIES_NONE) /* Redundant */ \ + continue; \ + \ + /* Is Egg or statused? */ \ + if (hp != 0 && (species == SPECIES_EGG || status != 0)) \ + (flags) |= 2 << (i) * 2; \ + \ + if (species == SPECIES_NONE) /* Redundant */ \ + continue; \ + \ + /* Is fainted? */ \ + if (species != SPECIES_EGG && hp == 0) \ + (flags) |= 3 << (i) * 2; \ } // For Vs Screen at link battle start @@ -3502,8 +3502,8 @@ static void BattleIntroDrawPartySummaryScreens(void) { for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; @@ -3520,8 +3520,8 @@ static void BattleIntroDrawPartySummaryScreens(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; @@ -3546,8 +3546,8 @@ static void BattleIntroDrawPartySummaryScreens(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2fcd195953..d12477bea8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5682,8 +5682,8 @@ static void Cmd_drawpartystatussummary(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatuses[i].hp = 0xFFFF; hpStatuses[i].status = 0; @@ -8331,7 +8331,7 @@ static void Cmd_healpartystatus(void) for (i = 0; i < PARTY_SIZE; i++) { - u16 species = GetMonData(&party[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); u8 abilityNum = GetMonData(&party[i], MON_DATA_ABILITY_NUM); if (species != SPECIES_NONE && species != SPECIES_EGG) @@ -8877,8 +8877,8 @@ static void Cmd_trydobeatup(void) for (;gBattleCommunication[0] < PARTY_SIZE; gBattleCommunication[0]++) { if (GetMonData(&party[gBattleCommunication[0]], MON_DATA_HP) - && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) - && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&party[gBattleCommunication[0]], MON_DATA_STATUS)) break; } @@ -9396,9 +9396,9 @@ static void Cmd_assistattackselect(void) { if (monId == gBattlerPartyIndexes[gBattlerAttacker]) continue; - if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; for (moveId = 0; moveId < MAX_MON_MOVES; moveId++) @@ -9564,7 +9564,7 @@ static void Cmd_pickup(void) { for (i = 0; i < PARTY_SIZE; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM)) @@ -9587,7 +9587,7 @@ static void Cmd_pickup(void) { for (i = 0; i < PARTY_SIZE; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM)) diff --git a/src/battle_setup.c b/src/battle_setup.c index 2ba9429d32..cc1ad70fed 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -724,7 +724,7 @@ static u16 GetSumOfPlayerPartyLevel(u8 numMons) for (i = 0; i < PARTY_SIZE; i++) { - u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) { diff --git a/src/battle_tower.c b/src/battle_tower.c index 1e134b8fa1..8838b5f2d2 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -3271,7 +3271,7 @@ s32 GetHighestLevelInPlayerParty(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG) { s32 level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL, NULL); if (level > highestLevel) diff --git a/src/battle_util.c b/src/battle_util.c index bbf34ab316..4bc1a4156f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2278,8 +2278,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId * MULTI_PARTY_SIZE; i < playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE); @@ -2318,8 +2318,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId * MULTI_PARTY_SIZE; i < playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE); @@ -2336,8 +2336,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId; i < playerId + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId + 3); @@ -2365,8 +2365,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) break; diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 6b5d66d315..3487428495 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -93,11 +93,11 @@ bool8 CheckRelicanthWailord(void) { // Emerald change: why did they flip it? // First comes Wailord - if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2, 0) == SPECIES_WAILORD) + if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES_OR_EGG, 0) == SPECIES_WAILORD) { CalculatePlayerPartyCount(); // Last comes Relicanth - if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES2, 0) == SPECIES_RELICANTH) + if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES_OR_EGG, 0) == SPECIES_RELICANTH) return TRUE; } return FALSE; diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index e23c04c1ad..8d47595c8b 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -2906,7 +2906,7 @@ void IsDodrioInParty(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES) - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_DODRIO) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_DODRIO) { gSpecialVar_Result = TRUE; return; diff --git a/src/field_poison.c b/src/field_poison.c index fcb47acdb8..f254a6d142 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -19,7 +19,7 @@ static bool32 IsMonValidSpecies(struct Pokemon *pokemon) { - u16 species = GetMonData(pokemon, MON_DATA_SPECIES2); + u16 species = GetMonData(pokemon, MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_NONE || species == SPECIES_EGG) return FALSE; diff --git a/src/field_specials.c b/src/field_specials.c index 6251a4db7e..38746c97a4 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1442,7 +1442,7 @@ bool8 IsStarterInParty(void) u8 partyCount = CalculatePlayerPartyCount(); for (i = 0; i < partyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) == starter) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) == starter) return TRUE; } return FALSE; @@ -1535,8 +1535,8 @@ u8 GetLeadMonIndex(void) u8 partyCount = CalculatePlayerPartyCount(); for (i = 0; i < partyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_NONE) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_NONE) return i; } return 0; @@ -1544,7 +1544,7 @@ u8 GetLeadMonIndex(void) u16 ScriptGetPartyMonSpecies(void) { - return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL); + return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES_OR_EGG, NULL); } // Removed for Emerald diff --git a/src/frontier_util.c b/src/frontier_util.c index 4830f92117..8cd385e653 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -2044,7 +2044,7 @@ static void CheckPartyIneligibility(void) numEligibleMons = 0; do { - u16 species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); u16 heldItem = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM); u8 level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); u16 hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 18aa19cce2..f4a4c96d71 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -445,7 +445,7 @@ static void Task_Hof_InitMonData(u8 taskId) u8 nick[POKEMON_NAME_LENGTH + 2]; if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) { - sHofMonPtr->mon[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + sHofMonPtr->mon[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); sHofMonPtr->mon[i].tid = GetMonData(&gPlayerParty[i], MON_DATA_OT_ID); sHofMonPtr->mon[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); sHofMonPtr->mon[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index e9317a8ebc..8f25c3188f 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1072,7 +1072,7 @@ void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, if (partyId != numMons) { - u16 species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); + u16 species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES_OR_EGG, NULL); u32 trainerId = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); u32 personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index d1b514a173..124ababa45 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -319,7 +319,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx) void *mailPtr = (void *)(data + sizeof(struct Pokemon)); pokemon = *(struct Pokemon *)pokemonPtr; - species = GetMonData(&pokemon, MON_DATA_SPECIES2); + species = GetMonData(&pokemon, MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_EGG) StringCopyN(gStringVar1, gText_EggNickname, POKEMON_NAME_LENGTH + 1); diff --git a/src/party_menu.c b/src/party_menu.c index 7fbefb5b52..dce0a38e10 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3593,7 +3593,7 @@ static void CursorCb_Store(u8 taskId) // Register mon for the Trading Board in Union Room static void CursorCb_Register(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES_OR_EGG); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); @@ -3620,7 +3620,7 @@ static void CursorCb_Register(u8 taskId) static void CursorCb_Trade1(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES_OR_EGG); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isEventLegal); @@ -3934,7 +3934,7 @@ static void CreatePartyMonIconSprite(struct Pokemon *mon, struct PartyMenuBox *m if (IsMultiBattle() == TRUE && gMain.inBattle) handleDeoxys = (sMultiBattlePartnersPartyMask[slot] ^ handleDeoxys) ? TRUE : FALSE; - species2 = GetMonData(mon, MON_DATA_SPECIES2); + species2 = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); CreatePartyMonIconSpriteParameterized(species2, GetMonData(mon, MON_DATA_PERSONALITY), menuBox, 1, handleDeoxys); UpdatePartyMonHPBar(menuBox->monSpriteId, mon); } diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 7117be8856..a334038d8d 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -725,14 +725,14 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) { case 0: // Load mon gfx - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); sPokeblockFeed->loadGfxState++; break; case 1: // Load mon palette - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); trainerId = GetMonData(mon, MON_DATA_OT_ID); palette = GetMonSpritePalStructFromOtIdPersonality(species, trainerId, personality); @@ -907,7 +907,7 @@ static void Task_FadeOutPokeblockFeed(u8 taskId) static u8 CreateMonSprite(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); u8 spriteId = CreateSprite(&gMultiuseSpriteTemplate, MON_X, MON_Y, 2); sPokeblockFeed->species = species; diff --git a/src/pokemon.c b/src/pokemon.c index e8d334a6ac..94ca688d79 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3960,7 +3960,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_EVENT_LEGAL: retVal = substruct3->eventLegal; break; - case MON_DATA_SPECIES2: + case MON_DATA_SPECIES_OR_EGG: retVal = substruct0->species; if (substruct0->species && (substruct3->isEgg || boxMon->isBadEgg)) retVal = SPECIES_EGG; @@ -4087,7 +4087,7 @@ void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg) case MON_DATA_MAIL: SET8(mon->mail); break; - case MON_DATA_SPECIES2: + case MON_DATA_SPECIES_OR_EGG: break; default: SetBoxMonData(&mon->box, field, data); @@ -4464,9 +4464,9 @@ u8 GetMonsStateToDoubles(void) for (i = 0; i < gPlayerPartyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0 - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_NONE) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_NONE) aliveCount++; } @@ -4480,7 +4480,7 @@ u8 GetMonsStateToDoubles_2(void) for (i = 0; i < PARTY_SIZE; i++) { - u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL); + u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL); if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0) aliveCount++; @@ -5872,7 +5872,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) if (ShouldSkipFriendshipChange()) return; - species = GetMonData(mon, MON_DATA_SPECIES2, 0); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0); if (heldItem == ITEM_ENIGMA_BERRY) @@ -6183,7 +6183,7 @@ bool8 TryIncrementMonLevel(struct Pokemon *mon) u32 CanMonLearnTMHM(struct Pokemon *mon, u8 tm) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); if (species == SPECIES_EGG) { return 0; @@ -6273,7 +6273,7 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) u16 learnedMoves[MAX_MON_MOVES]; u16 moves[MAX_LEVEL_UP_MOVES]; u8 numMoves = 0; - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); int i, j, k; @@ -6442,7 +6442,7 @@ static void Task_PlayMapChosenOrBattleBGM(u8 taskId) const u32 *GetMonFrontSpritePal(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); return GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality); @@ -6464,7 +6464,7 @@ const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 p const struct CompressedSpritePalette *GetMonSpritePalStruct(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); return GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 963552d7df..3a985a6d59 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2354,7 +2354,7 @@ void IsPokemonJumpSpeciesInParty(void) { if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES)) { - u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (IsSpeciesAllowedInPokemonJump(species)) { gSpecialVar_Result = TRUE; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index c9855f9d5d..80d0605a0a 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -4430,7 +4430,7 @@ static u8 GetMonIconPriorityByCursorPos(void) static void CreateMovingMonIcon(void) { u32 personality = GetMonData(&sStorage->movingMon, MON_DATA_PERSONALITY); - u16 species = GetMonData(&sStorage->movingMon, MON_DATA_SPECIES2); + u16 species = GetMonData(&sStorage->movingMon, MON_DATA_SPECIES_OR_EGG); u8 priority = GetMonIconPriorityByCursorPos(); sStorage->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); @@ -4452,7 +4452,7 @@ static void InitBoxMonSprites(u8 boxId) { for (j = 0; j < IN_BOX_COLUMNS; j++) { - species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); @@ -4480,7 +4480,7 @@ static void InitBoxMonSprites(u8 boxId) static void CreateBoxMonIconAtPos(u8 boxPosition) { - u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { @@ -4714,7 +4714,7 @@ static void GetIncomingBoxMonData(u8 boxId) { for (j = 0; j < IN_BOX_COLUMNS; j++) { - sStorage->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + sStorage->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES_OR_EGG); if (sStorage->boxSpecies[boxPosition] != SPECIES_NONE) sStorage->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); boxPosition++; @@ -4742,14 +4742,14 @@ static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) static void CreatePartyMonsSprites(bool8 visible) { u16 i, count; - u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES_OR_EGG); u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); sStorage->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); count = 1; for (i = 1; i < PARTY_SIZE; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); @@ -6867,7 +6867,7 @@ static void SetDisplayMonData(void *pokemon, u8 mode) { struct Pokemon *mon = (struct Pokemon *)pokemon; - sStorage->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + sStorage->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); if (sStorage->displayMonSpecies != SPECIES_NONE) { sanityIsBadEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); @@ -6890,7 +6890,7 @@ static void SetDisplayMonData(void *pokemon, u8 mode) { struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; - sStorage->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + sStorage->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES_OR_EGG); if (sStorage->displayMonSpecies != SPECIES_NONE) { u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); @@ -8438,7 +8438,7 @@ static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn) static void MultiMove_SetIconToBg(u8 x, u8 y) { u8 position = x + (IN_BOX_COLUMNS * y); - u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES_OR_EGG); u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY); if (species != SPECIES_NONE) @@ -8463,7 +8463,7 @@ static void MultiMove_SetIconToBg(u8 x, u8 y) static void MultiMove_ClearIconFromBg(u8 x, u8 y) { u8 position = x + (IN_BOX_COLUMNS * y); - u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 1f6ccd2737..7b306016ce 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1384,7 +1384,7 @@ static bool8 ExtractMonDataToSummaryStruct(struct Pokemon *mon) { case 0: sum->species = GetMonData(mon, MON_DATA_SPECIES); - sum->species2 = GetMonData(mon, MON_DATA_SPECIES2); + sum->species2 = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); sum->exp = GetMonData(mon, MON_DATA_EXP); sum->level = GetMonData(mon, MON_DATA_LEVEL); sum->abilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM); diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index e0645bac0b..05f86cab2f 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -531,7 +531,7 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) boxId = monListPtr->monData[listId].boxId; monId = monListPtr->monData[listId].monId; - species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); + species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES_OR_EGG, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE); diff --git a/src/roulette.c b/src/roulette.c index 283cceebfe..06561f7988 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -1144,7 +1144,7 @@ static void InitRouletteTableData(void) for (i = 0; i < PARTY_SIZE; i++) { - switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2)) + switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG)) { case SPECIES_SHROOMISH: sRoulette->partySpeciesFlags |= HAS_SHROOMISH; diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index ae7aa92dc8..6e5653884b 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -118,7 +118,7 @@ static bool8 CheckPartyMonHasHeldItem(u16 item) for(i = 0; i < PARTY_SIZE; i++) { - u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == item) return TRUE; } diff --git a/src/trade.c b/src/trade.c index f8817421f2..ab19f5fee6 100644 --- a/src/trade.c +++ b/src/trade.c @@ -564,7 +564,7 @@ static void CB2_CreateTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, @@ -576,7 +576,7 @@ static void CB2_CreateTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -755,7 +755,7 @@ static void CB2_ReturnToTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, @@ -767,7 +767,7 @@ static void CB2_ReturnToTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -2395,7 +2395,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int for (i = 0; i < partyCount; i++) { - species2[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES2); + species2[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES_OR_EGG); species[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES); } @@ -2593,7 +2593,7 @@ int CanSpinTradeMon(struct Pokemon *mon, u16 monIdx) // Make Eggs not count for numMonsLeft for (i = 0; i < gPlayerPartyCount; i++) { - speciesArray[i] = GetMonData(&mon[i], MON_DATA_SPECIES2); + speciesArray[i] = GetMonData(&mon[i], MON_DATA_SPECIES_OR_EGG); if (speciesArray[i] == SPECIES_EGG) speciesArray[i] = SPECIES_NONE; } @@ -2803,7 +2803,7 @@ static void LoadTradeMonPic(u8 whichParty, u8 state) switch (state) { case 0: - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); if (whichParty == TRADE_PLAYER) diff --git a/src/union_room.c b/src/union_room.c index 082b7dec54..9160fc16ae 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4176,7 +4176,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) { for (i = 0; i < gPlayerPartyCount; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_EGG) return UR_TRADE_MATCH; } @@ -4186,7 +4186,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) { for (i = 0; i < gPlayerPartyCount; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (gSpeciesInfo[species].types[0] == type || gSpeciesInfo[species].types[1] == type) return UR_TRADE_MATCH; } @@ -4319,7 +4319,7 @@ static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void) for (i = 0; i < gPlayerPartyCount; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= UNION_ROOM_MAX_LEVEL - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) count++; } @@ -4348,7 +4348,7 @@ void Script_ResetUnionRoomTrade(void) static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trade) { - trade->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); trade->playerLevel = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); trade->playerPersonality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); if (trade->playerSpecies == SPECIES_EGG) @@ -4359,7 +4359,7 @@ static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trad static void RegisterTradeMon(u32 monId, struct UnionRoomTrade *trade) { - trade->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); trade->level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); trade->personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); } @@ -4390,7 +4390,7 @@ static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *trade, u8 mult cur_personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); if (cur_personality != personality) continue; - cur_species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + cur_species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (cur_species != species) continue; response = i; From d00c8902f9bc1a6a2dc16fc9005b04818ebcfe60 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 25 Feb 2023 16:48:16 -0300 Subject: [PATCH 17/19] Whitelist instead of Blacklist for TOOLDIRS in Makefiles --- Makefile | 3 ++- make_tools.mk | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 88303e7f39..50a7e0d255 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,8 @@ JSONPROC := tools/jsonproc/jsonproc$(EXE) PERL := perl -TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) +# Inclusive list. If you don't want a tool to be built, don't add it here. +TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc TOOLBASE = $(TOOLDIRS:tools/%=%) TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) diff --git a/make_tools.mk b/make_tools.mk index 697897a693..7e0baf8900 100644 --- a/make_tools.mk +++ b/make_tools.mk @@ -1,7 +1,8 @@ MAKEFLAGS += --no-print-directory -TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) +# Inclusive list. If you don't want a tool to be built, don't add it here. +TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc .PHONY: all $(TOOLDIRS) From f376b71f7c9c256858f350abf0a079d4b79afbda Mon Sep 17 00:00:00 2001 From: Zunawe Date: Sat, 25 Feb 2023 13:48:39 -0800 Subject: [PATCH 18/19] Fix wrong route in item flag name --- data/maps/Route110/map.json | 2 +- include/constants/flags.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/maps/Route110/map.json b/data/maps/Route110/map.json index 630b20bd37..2b52164113 100644 --- a/data/maps/Route110/map.json +++ b/data/maps/Route110/map.json @@ -288,7 +288,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "Route110_EventScript_ItemRareCandy", - "flag": "FLAG_ITEM_ROUTE_109_RARE_CANDY" + "flag": "FLAG_ITEM_ROUTE_110_RARE_CANDY" }, { "graphics_id": "OBJ_EVENT_GFX_CYCLING_TRIATHLETE_M", diff --git a/include/constants/flags.h b/include/constants/flags.h index 4bef779385..99a8377a75 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1051,7 +1051,7 @@ #define FLAG_ITEM_ROUTE_105_IRON 0x3EB #define FLAG_ITEM_ROUTE_106_PROTEIN 0x3EC #define FLAG_ITEM_ROUTE_109_PP_UP 0x3ED -#define FLAG_ITEM_ROUTE_109_RARE_CANDY 0x3EE +#define FLAG_ITEM_ROUTE_110_RARE_CANDY 0x3EE #define FLAG_ITEM_ROUTE_110_DIRE_HIT 0x3EF #define FLAG_ITEM_ROUTE_111_TM37 0x3F0 #define FLAG_ITEM_ROUTE_111_STARDUST 0x3F1 From be8479371343528d67d203ab117ef9cc86a2c061 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 27 Feb 2023 12:47:35 -0500 Subject: [PATCH 19/19] Let scaninc/preproc ignore empty asm files --- tools/preproc/asm_file.cpp | 4 +++- tools/scaninc/asm_file.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp index af16e232d3..04a7410e00 100644 --- a/tools/preproc/asm_file.cpp +++ b/tools/preproc/asm_file.cpp @@ -41,6 +41,8 @@ AsmFile::AsmFile(std::string filename) : m_filename(filename) if (m_size < 0) FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str()); + else if (m_size == 0) + return; // Empty file m_buffer = new char[m_size + 1]; @@ -73,7 +75,7 @@ AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename)) AsmFile::~AsmFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } // Removes comments to simplify further processing. diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp index 109e604a22..d2cc624ee5 100644 --- a/tools/scaninc/asm_file.cpp +++ b/tools/scaninc/asm_file.cpp @@ -36,6 +36,11 @@ AsmFile::AsmFile(std::string path) m_size = std::ftell(fp); + if (m_size < 0) + FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str()); + else if (m_size == 0) + return; // Empty file + m_buffer = new char[m_size]; std::rewind(fp); @@ -51,7 +56,7 @@ AsmFile::AsmFile(std::string path) AsmFile::~AsmFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)