diff --git a/constants/gba_constants.inc b/constants/gba_constants.inc index 3ff857ee8..9f51b0f02 100644 --- a/constants/gba_constants.inc +++ b/constants/gba_constants.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_GBA_CONSTANTS_INC +#define GUARD_CONSTANTS_GBA_CONSTANTS_INC + .set PSR_USR_MODE, 0x00000010 .set PSR_FIQ_MODE, 0x00000011 .set PSR_IRQ_MODE, 0x00000012 @@ -511,3 +514,5 @@ .set BLDCNT_TGT2_OBJ, 1 << 12 .set BLDCNT_TGT2_BD, 1 << 13 .set BLDCNT_TGT2_ALL, BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD + +#endif @ GUARD_CONSTANTS_GBA_CONSTANTS_INC diff --git a/constants/global.inc b/constants/global.inc index 621ba2af8..b9462fa26 100644 --- a/constants/global.inc +++ b/constants/global.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_GLOBAL_INC +#define GUARD_CONSTANTS_GLOBAL_INC + .set TRUE, 1 .set FALSE, 0 @@ -20,3 +23,5 @@ .set OBJ_IMAGE_ANIM_H_FLIP, 1 << 6 .set OBJ_IMAGE_ANIM_V_FLIP, 1 << 7 + +#endif @ GUARD_CONSTANTS_GLOBAL_INC diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc index 1a744dc7f..2599b6c4a 100644 --- a/constants/m4a_constants.inc +++ b/constants/m4a_constants.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_M4A_CONSTANTS_INC +#define GUARD_CONSTANTS_M4A_CONSTANTS_INC + .equiv ID_NUMBER, 0x68736d53 .equiv PCM_DMA_BUF_SIZE, 1584 @@ -250,3 +253,5 @@ struct_field o_CgbChannel_nextChannelPointer, 4 struct_field o_CgbChannel_dummy4, 8 struct_field CgbChannel_size, 0 + +#endif @ GUARD_CONSTANTS_M4A_CONSTANTS_INC diff --git a/constants/tms_hms.inc b/constants/tms_hms.inc index 3450aa73b..4ce6d9032 100644 --- a/constants/tms_hms.inc +++ b/constants/tms_hms.inc @@ -1,3 +1,6 @@ +#ifndef GUARD_CONSTANTS_TMS_HMS_INC +#define GUARD_CONSTANTS_TMS_HMS_INC + #include "constants/tms_hms.h" /* Expands to: @@ -15,3 +18,5 @@ FOREACH_TM(EQUIV_TM) FOREACH_HM(EQUIV_HM) #undef EQUIV_TM #undef EQUIV_HM + +#endif @ GUARD_CONSTANTS_TMS_HMS_INC diff --git a/include/pokemon.h b/include/pokemon.h index 7f70d8a52..526103e58 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -210,7 +210,8 @@ struct BoxPokemon u8 isBadEgg:1; u8 hasSpecies:1; u8 isEgg:1; - u8 unused:5; + u8 blockBoxRS:1; // Unused, but Pokémon Box Ruby & Sapphire will refuse to deposit a Pokémon with this flag set + u8 unused:4; u8 otName[PLAYER_NAME_LENGTH]; u8 markings; u16 checksum; diff --git a/src/m4a_1.s b/src/m4a_1.s index 3f1578806..20f9197a8 100644 --- a/src/m4a_1.s +++ b/src/m4a_1.s @@ -1395,7 +1395,7 @@ _081DD9F6: cmp r6, 0 beq _081DDA14 ldrb r0, [r4, o_CgbChannel_modify] - movs r1, 0x1 + movs r1, CGB_CHANNEL_MO_VOL orrs r0, r1 strb r0, [r4, o_CgbChannel_modify] _081DDA14: diff --git a/src/wild_encounter.c b/src/wild_encounter.c index aa4ffe4ca..1b5e91d3a 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -56,7 +56,12 @@ static bool8 IsWildLevelAllowedByRepel(u8 level); static void ApplyFluteEncounterRateMod(u32 *encRate); static void ApplyCleanseTagEncounterRateMod(u32 *encRate); static u8 GetMaxLevelOfSpeciesInWildTable(const struct WildPokemon *wildMon, u16 species, u8 area); +#ifdef BUGFIX static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex); +//static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex, u32 size); //TodoFix +#else +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex); +#endif static bool8 IsAbilityAllowingEncounter(u8 level); EWRAM_DATA static u8 sWildEncountersDisabled = 0; @@ -463,6 +468,12 @@ static void CreateWildMon(u16 species, u8 level) CreateMonWithNature(&gEnemyParty[0], species, level, USE_RANDOM_IVS, PickWildMonNature()); } +#ifdef BUGFIX +#define TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildPokemon, type, ability, ptr, count) TryGetAbilityInfluencedWildMonIndex(wildPokemon, type, ability, ptr) +//#define TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildPokemon, type, ability, ptr, count) TryGetAbilityInfluencedWildMonIndex(wildPokemon, type, ability, ptr, count) //TodoFix +#else +#define TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildPokemon, type, ability, ptr, count) TryGetAbilityInfluencedWildMonIndex(wildPokemon, type, ability, ptr) +#endif static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags) { @@ -472,9 +483,9 @@ static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 ar switch (area) { case WILD_AREA_LAND: - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex, LAND_WILD_COUNT)) break; - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex, LAND_WILD_COUNT)) break; if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_LIGHTNING_ROD, &wildMonIndex)) break; @@ -490,7 +501,7 @@ static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 ar case WILD_AREA_WATER: if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex)) break; - if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex)) + if (TRY_GET_ABILITY_INFLUENCED_WILD_MON_INDEX(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex, WATER_WILD_COUNT)) break; if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_LIGHTNING_ROD, &wildMonIndex)) break; @@ -1069,7 +1080,12 @@ static u8 GetMaxLevelOfSpeciesInWildTable(const struct WildPokemon *wildMon, u16 return maxLevel; } +#ifdef BUGFIX static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex) +//static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex, u32 size) //TodoFix +#else +static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u16 ability, u8 *monIndex) +#endif { if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)) return FALSE; @@ -1078,7 +1094,12 @@ static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildM else if (Random() % 2 != 0) return FALSE; +#ifdef BUGFIX return TryGetRandomWildMonIndexByType(wildMon, type, LAND_WILD_COUNT, monIndex); + //return TryGetRandomWildMonIndexByType(wildMon, type, size, monIndex); //TodoFix +#else + return TryGetRandomWildMonIndexByType(wildMon, type, LAND_WILD_COUNT, monIndex); +#endif } static void ApplyFluteEncounterRateMod(u32 *encRate)