diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 0f51061e8..c5bede3f5 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1275,8 +1275,8 @@ various \battler, VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP .endm - .macro various7 battler:req - various \battler, 7 + .macro resetplayerfainted + various BS_ATTACKER, VARIOUS_RESET_PLAYER_FAINTED .endm .macro palaceflavortext battler:req @@ -1303,12 +1303,12 @@ various \battler, VARIOUS_EMIT_YESNOBOX .endm - .macro various14 battler:req - various \battler, 14 + .macro arenadrawreftextbox + various BS_ATTACKER, VARIOUS_DRAW_ARENA_REF_TEXT_BOX .endm - .macro various15 battler:req - various \battler, 15 + .macro arenaerasereftextbox + various BS_ATTACKER, VARIOUS_ERASE_ARENA_REF_TEXT_BOX .endm .macro arenajudgmentstring id:req @@ -1340,11 +1340,11 @@ .endm .macro setalreadystatusedmoveattempt battler:req - various \battler, 23 + various \battler, VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT .endm - .macro various24 battler:req - various \battler, 24 + .macro palacetryescapestatus battler:req + various \battler, VARIOUS_PALACE_TRY_ESCAPE_STATUS .endm .macro setoutcomeonteleport battler:req diff --git a/common_syms/bg.txt b/common_syms/bg.txt index 2495d1646..0a3c3aecc 100644 --- a/common_syms/bg.txt +++ b/common_syms/bg.txt @@ -1 +1 @@ -gUnneededFireRedVariable +gWindowTileAutoAllocEnabled diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index e7aad6a93..83b1f3cea 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -3514,7 +3514,7 @@ Move_MEMENTO: delay 48 playsewithpan SE_M_PSYBEAM2, SOUND_PAN_ATTACKER waitforvisualfinish - createvisualtask sub_8114470, 2 + createvisualtask AnimTask_MementoHandleBg, 2 delay 12 setalpha 0, 16 delay 1 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 74efef7ac..30ca1b220 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2828,7 +2828,7 @@ BattleScript_HandleFaintedMon:: atk24 BattleScript_HandleFaintedMonMultiple jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_FaintedMonEnd jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonTryChooseAnother - jumpifword CMP_NO_COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_FaintedMonTryChooseAnother + jumpifword CMP_NO_COMMON_BITS, gHitMarker, HITMARKER_PLAYER_FAINTED, BattleScript_FaintedMonTryChooseAnother printstring STRINGID_USENEXTPKMN setbyte gBattleCommunication, 0 yesnobox @@ -2843,7 +2843,7 @@ BattleScript_FaintedMonTryChooseAnother:: jumpifbattletype BATTLE_TYPE_RECORDED_LINK, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_FRONTIER, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonChooseAnother - jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_FaintedMonChooseAnother + jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_PLAYER_FAINTED, BattleScript_FaintedMonChooseAnother jumpifbyte CMP_EQUAL, sBATTLE_STYLE, OPTIONS_BATTLE_STYLE_SET, BattleScript_FaintedMonChooseAnother jumpifcantswitch BS_PLAYER1, BattleScript_FaintedMonChooseAnother printstring STRINGID_ENEMYABOUTTOSWITCHPKMN @@ -2881,7 +2881,7 @@ BattleScript_FaintedMonChooseAnother:: hidepartystatussummary BS_FAINTED switchinanim BS_FAINTED, FALSE waitstate - various7 BS_ATTACKER + resetplayerfainted switchineffects BS_FAINTED jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonEnd cancelallactions @@ -3200,7 +3200,7 @@ BattleScript_DamagingWeatherLoop:: jumpifword CMP_EQUAL, gBattleMoveDamage, 0, BattleScript_DamagingWeatherLoopIncrement printfromtable gSandStormHailDmgStringIds waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE + orword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE effectivenesssound hitanimation BS_ATTACKER healthbarupdate BS_ATTACKER @@ -3212,7 +3212,7 @@ BattleScript_DamagingWeatherLoopIncrement:: addbyte gBattleCommunication, 1 jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop BattleScript_DamagingWeatherContinuesEnd:: - bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE + bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE end2 BattleScript_SandStormHailEnds:: @@ -3256,7 +3256,7 @@ BattleScript_SafeguardEnds:: BattleScript_LeechSeedTurnDrain:: playanimation BS_ATTACKER, B_ANIM_LEECH_SEED_DRAIN, sB_ANIM_ARG1 - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER copyword gBattleMoveDamage, gHpDealt @@ -3267,7 +3267,7 @@ BattleScript_LeechSeedTurnDrain:: BattleScript_LeechSeedTurnPrintLiquidOoze:: setbyte cMULTISTRING_CHOOSER, B_MSG_LEECH_SEED_OOZE BattleScript_LeechSeedTurnPrintAndUpdateHp:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_TARGET datahpupdate BS_TARGET printfromtable gLeechSeedStringIds @@ -3371,14 +3371,14 @@ BattleScript_EncoredNoMore:: BattleScript_DestinyBondTakesLife:: printstring STRINGID_PKMNTOOKFOE waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL return BattleScript_SpikesOnAttacker:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER call BattleScript_PrintHurtBySpikes @@ -3393,7 +3393,7 @@ BattleScript_SpikesOnAttackerFainted:: goto BattleScript_HandleFaintedMon BattleScript_SpikesOnTarget:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_TARGET datahpupdate BS_TARGET call BattleScript_PrintHurtBySpikes @@ -3408,7 +3408,7 @@ BattleScript_SpikesOnTargetFainted:: goto BattleScript_HandleFaintedMon BattleScript_SpikesOnFaintedBattler:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_FAINTED datahpupdate BS_FAINTED call BattleScript_PrintHurtBySpikes @@ -3430,7 +3430,7 @@ BattleScript_PrintHurtBySpikes:: BattleScript_PerishSongTakesLife:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL @@ -3662,7 +3662,7 @@ BattleScript_MagicCoatBounce:: pause B_WAIT_TIME_SHORT printstring STRINGID_PKMNMOVEBOUNCED waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_x800000 + orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_ALLOW_NO_PP setmagiccoattarget BS_ATTACKER return @@ -3673,7 +3673,7 @@ BattleScript_SnatchedMove:: playanimation BS_TARGET, B_ANIM_SNATCH_MOVE, NULL printstring STRINGID_PKMNSNATCHEDMOVE waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_x800000 + orword gHitMarker, HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_ALLOW_NO_PP swapattackerwithtarget return @@ -3713,7 +3713,7 @@ BattleScript_MoveUsedIsAsleep:: goto BattleScript_MoveEnd BattleScript_MoveUsedWokeUp:: - bicword gHitMarker, HITMARKER_x10 + bicword gHitMarker, HITMARKER_WAKE_UP_CLEAR printfromtable gWokeUpStringIds waitmessage B_WAIT_TIME_LONG updatestatusicon BS_ATTACKER @@ -3731,7 +3731,7 @@ BattleScript_PoisonTurnDmg:: BattleScript_DoStatusTurnDmg:: statusanimation BS_ATTACKER BattleScript_DoTurnDmg:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL @@ -3798,7 +3798,7 @@ BattleScript_DoSelfConfusionDmg:: effectivenesssound hitanimation BS_ATTACKER waitstate - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER resultmessage @@ -3931,7 +3931,7 @@ BattleScript_MoveEffectRecoil:: jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil jumpifability BS_ATTACKER, ABILITY_ROCK_HEAD, BattleScript_RecoilEnd BattleScript_DoRecoil:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_PKMNHITWITHRECOIL @@ -4174,7 +4174,7 @@ BattleScript_ColorChangeActivates:: return BattleScript_RoughSkinActivates:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_PKMNHURTSWITH @@ -4222,9 +4222,10 @@ BattleScript_IgnoresAndUsesRandomMove:: jumptocalledmove FALSE BattleScript_MoveUsedLoafingAround:: + @ Skip ahead if not the Battle Palace message jumpifbyte CMP_NOT_EQUAL, cMULTISTRING_CHOOSER, B_MSG_INCAPABLE_OF_POWER, BattleScript_MoveUsedLoafingAroundMsg setbyte gBattleCommunication, 0 - various24 BS_ATTACKER + palacetryescapestatus BS_ATTACKER setbyte cMULTISTRING_CHOOSER, B_MSG_INCAPABLE_OF_POWER BattleScript_MoveUsedLoafingAroundMsg:: printfromtable gInobedientStringIds @@ -4442,22 +4443,22 @@ BattleScript_ArenaTurnBeginning:: playse SE_ARENA_TIMEUP1 pause 8 playse SE_ARENA_TIMEUP1 - various14 BS_ATTACKER + arenadrawreftextbox arenajudgmentstring B_MSG_REF_COMMENCE_BATTLE arenawaitmessage B_MSG_REF_COMMENCE_BATTLE pause B_WAIT_TIME_LONG - various15 BS_ATTACKER + arenaerasereftextbox volumeup end2 @ Unused BattleScript_ArenaNothingDecided:: playse SE_DING_DONG - various14 BS_ATTACKER + arenadrawreftextbox arenajudgmentstring B_MSG_REF_NOTHING_IS_DECIDED arenawaitmessage B_MSG_REF_NOTHING_IS_DECIDED pause B_WAIT_TIME_LONG - various15 BS_ATTACKER + arenaerasereftextbox end2 BattleScript_ArenaDoJudgment:: @@ -4470,7 +4471,7 @@ BattleScript_ArenaDoJudgment:: pause 8 playse SE_ARENA_TIMEUP1 pause B_WAIT_TIME_LONG - various14 BS_ATTACKER + arenadrawreftextbox arenajudgmentstring B_MSG_REF_THATS_IT arenawaitmessage B_MSG_REF_THATS_IT pause B_WAIT_TIME_LONG @@ -4492,7 +4493,7 @@ BattleScript_ArenaDoJudgment:: arenajudgmentstring B_MSG_REF_PLAYER_WON arenawaitmessage B_MSG_REF_PLAYER_WON arenajudgmentwindow - various15 BS_ATTACKER + arenaerasereftextbox printstring STRINGID_DEFEATEDOPPONENTBYREFEREE waitmessage B_WAIT_TIME_LONG playfaintcry BS_OPPONENT1 @@ -4506,7 +4507,7 @@ BattleScript_ArenaJudgmentPlayerLoses: arenajudgmentstring B_MSG_REF_OPPONENT_WON arenawaitmessage B_MSG_REF_OPPONENT_WON arenajudgmentwindow - various15 BS_ATTACKER + arenaerasereftextbox printstring STRINGID_LOSTTOOPPONENTBYREFEREE waitmessage B_WAIT_TIME_LONG playfaintcry BS_PLAYER1 @@ -4520,7 +4521,7 @@ BattleScript_ArenaJudgmentDraw: arenajudgmentstring B_MSG_REF_DRAW arenawaitmessage B_MSG_REF_DRAW arenajudgmentwindow - various15 BS_ATTACKER + arenaerasereftextbox printstring STRINGID_TIEDOPPONENTBYREFEREE waitmessage B_WAIT_TIME_LONG playfaintcry BS_PLAYER1 diff --git a/gflib/bg.c b/gflib/bg.c index ec7c2113b..283a87ce0 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -42,10 +42,12 @@ static struct BgControl sGpuBgConfigs; static struct BgConfig2 sGpuBgConfigs2[NUM_BACKGROUNDS]; static u32 sDmaBusyBitfield[NUM_BACKGROUNDS]; -u32 gUnneededFireRedVariable; +u32 gWindowTileAutoAllocEnabled; static const struct BgConfig sZeroedBgControlStruct = { 0 }; +static u32 GetBgType(u8 bg); + void ResetBgs(void) { ResetBgControlStructs(); @@ -288,7 +290,8 @@ bool8 IsInvalidBg(u8 bg) return FALSE; } -int DummiedOutFireRedLeafGreenTileAllocFunc(int a1, int a2, int a3, int a4) +// From FRLG. Dummied out. +int BgTileAllocOp(int bg, int offset, int count, int mode) { return 0; } @@ -303,7 +306,7 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable) sDmaBusyBitfield[i] = 0; } - gUnneededFireRedVariable = leftoverFireRedLeafGreenVariable; + gWindowTileAutoAllocEnabled = leftoverFireRedLeafGreenVariable; } void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates) @@ -392,10 +395,8 @@ u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset) sDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20)); - if (gUnneededFireRedVariable == 1) - { - DummiedOutFireRedLeafGreenTileAllocFunc(bg, tileOffset / 0x20, size / 0x20, 1); - } + if (gWindowTileAutoAllocEnabled == TRUE) + BgTileAllocOp(bg, tileOffset / 0x20, size / 0x20, 1); return cursor; } @@ -523,9 +524,9 @@ u16 GetBgAttribute(u8 bg, u8 attributeId) case BG_ATTR_METRIC: switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: return GetBgMetricTextMode(bg, 0) * 0x800; - case 1: + case BG_TYPE_AFFINE: return GetBgMetricAffineMode(bg, 0) * 0x100; default: return 0; @@ -891,10 +892,10 @@ void CopyBgTilemapBufferToVram(u8 bg) { switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800; break; - case 1: + case BG_TYPE_AFFINE: sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100; break; default: @@ -915,7 +916,7 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi { switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: { const u16 * srcCopy = src; for (destY16 = destY; destY16 < (destY + height); destY16++) @@ -927,7 +928,7 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi } break; } - case 1: + case BG_TYPE_AFFINE: { const u8 * srcCopy = src; mode = GetBgMetricAffineMode(bg, 0x1); @@ -963,7 +964,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 screenHeight = GetBgMetricTextMode(bg, 0x2) * 0x20; switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: srcPtr = src + ((srcY * srcWidth) + srcX) * 2; for (i = destX; i < (destX + rectWidth); i++) { @@ -976,7 +977,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcPtr += (srcWidth - destY) * 2; } break; - case 1: + case BG_TYPE_AFFINE: srcPtr = src + ((srcY * srcWidth) + srcX); var = GetBgMetricAffineMode(bg, 0x1); for (i = destX; i < (destX + rectWidth); i++) @@ -1003,7 +1004,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, { switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: for (y16 = y; y16 < (y + height); y16++) { for (x16 = x; x16 < (x + width); x16++) @@ -1012,7 +1013,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, } } break; - case 1: + case BG_TYPE_AFFINE: mode = GetBgMetricAffineMode(bg, 0x1); for (y16 = y; y16 < (y + height); y16++) { @@ -1046,7 +1047,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt mode2 = GetBgMetricTextMode(bg, 0x2) * 0x20; switch (GetBgType(bg)) { - case 0: + case BG_TYPE_NORMAL: for (y16 = y; y16 < (y + height); y16++) { for (x16 = x; x16 < (x + width); x16++) @@ -1056,7 +1057,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt } } break; - case 1: + case BG_TYPE_AFFINE: mode3 = GetBgMetricAffineMode(bg, 0x1); for (y16 = y; y16 < (y + height); y16++) { @@ -1190,7 +1191,7 @@ void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s *dest = var; } -u32 GetBgType(u8 bg) +static u32 GetBgType(u8 bg) { u8 mode = GetBgMode(); @@ -1202,31 +1203,31 @@ u32 GetBgType(u8 bg) { case 0: case 1: - return 0; + return BG_TYPE_NORMAL; } break; case 2: switch (mode) { case 0: - return 0; + return BG_TYPE_NORMAL; case 1: case 2: - return 1; + return BG_TYPE_AFFINE; } break; case 3: switch (mode) { case 0: - return 0; + return BG_TYPE_NORMAL; case 2: - return 1; + return BG_TYPE_AFFINE; } break; } - return 0xFFFF; + return BG_TYPE_NONE; } bool32 IsInvalidBg32(u8 bg) diff --git a/gflib/bg.h b/gflib/bg.h index 58fd1282c..60327eab3 100644 --- a/gflib/bg.h +++ b/gflib/bg.h @@ -25,6 +25,12 @@ enum BG_ATTR_BASETILE, }; +enum { + BG_TYPE_NORMAL, + BG_TYPE_AFFINE, + BG_TYPE_NONE = 0xFFFF +}; + struct BgTemplate { u16 bg:2; // 0x1, 0x2 -> 0x3 @@ -43,7 +49,7 @@ void Unused_ResetBgControlStruct(u8 bg); u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode); void SetTextModeAndHideBgs(void); bool8 IsInvalidBg(u8 bg); -int DummiedOutFireRedLeafGreenTileAllocFunc(int a1, int a2, int a3, int a4); +int BgTileAllocOp(int bg, int offset, int count, int mode); void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable); void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates); void InitBgFromTemplate(const struct BgTemplate *template); @@ -78,7 +84,6 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric); u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric); u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight); void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2); -u32 GetBgType(u8 bg); bool32 IsInvalidBg32(u8 bg); bool32 IsTileMapOutsideWram(u8 bg); diff --git a/gflib/string_util.c b/gflib/string_util.c index addc7e4f2..b7485184a 100644 --- a/gflib/string_util.c +++ b/gflib/string_util.c @@ -630,7 +630,7 @@ bool32 IsStringJapanese(u8 *str) { while (*str != EOS) { - if (*str < CHAR_0) + if (*str <= JAPANESE_CHAR_END) if (*str != CHAR_SPACE) return TRUE; str++; @@ -639,13 +639,13 @@ bool32 IsStringJapanese(u8 *str) return FALSE; } -bool32 sub_800924C(u8 *str, s32 n) +bool32 IsStringNJapanese(u8 *str, s32 n) { s32 i; for (i = 0; *str != EOS && i < n; i++) { - if (*str < CHAR_0) + if (*str <= JAPANESE_CHAR_END) if (*str != CHAR_SPACE) return TRUE; str++; diff --git a/gflib/string_util.h b/gflib/string_util.h index 229193d52..7f3b64add 100644 --- a/gflib/string_util.h +++ b/gflib/string_util.h @@ -37,7 +37,7 @@ u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n); u32 StringLength_Multibyte(const u8 *str); u8 *WriteColorChangeControlCode(u8 *dest, u32 colorType, u8 color); bool32 IsStringJapanese(u8 *str); -bool32 sub_800924C(u8 *str, s32 n); +bool32 IsStringNJapanese(u8 *str, s32 n); u8 GetExtCtrlCodeLength(u8 code); s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2); void ConvertInternationalString(u8 *s, u8 language); diff --git a/gflib/text.h b/gflib/text.h index f660eb8d1..a08d0a0ff 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -263,6 +263,10 @@ #define PLACEHOLDER_ID_KYOGRE 0xC #define PLACEHOLDER_ID_GROUDON 0xD +// Hiragana from 0x1-0x50, Katakana from 0x51-0xA0. +// This excludes Japanese punctuation, which end at 0xB0 +#define JAPANESE_CHAR_END 0xA0 + // battle placeholders are located in battle_message.h #define NUM_TEXT_PRINTERS 32 diff --git a/gflib/window.c b/gflib/window.c index b03b513da..c7b8c8917 100644 --- a/gflib/window.c +++ b/gflib/window.c @@ -10,7 +10,7 @@ u32 gUnusedWindowVar2; u8 gTransparentTileNumber; u32 gUnusedWindowVar3; void *gWindowBgTilemapBuffers[NUM_BACKGROUNDS]; -extern u32 gUnneededFireRedVariable; +extern u32 gWindowTileAutoAllocEnabled; #define WINDOWS_MAX 32 @@ -55,9 +55,9 @@ bool16 InitWindows(const struct WindowTemplate *templates) for (i = 0, allocatedBaseBlock = 0, bgLayer = templates[i].bg; bgLayer != 0xFF && i < WINDOWS_MAX; ++i, bgLayer = templates[i].bg) { - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { - allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, templates[i].width * templates[i].height, 0); + allocatedBaseBlock = BgTileAllocOp(bgLayer, 0, templates[i].width * templates[i].height, 0); if (allocatedBaseBlock == -1) return FALSE; } @@ -100,10 +100,10 @@ bool16 InitWindows(const struct WindowTemplate *templates) gWindows[i].tileData = allocatedTilemapBuffer; gWindows[i].window = templates[i]; - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { gWindows[i].window.baseBlock = allocatedBaseBlock; - DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, allocatedBaseBlock, templates[i].width * templates[i].height, 1); + BgTileAllocOp(bgLayer, allocatedBaseBlock, templates[i].width * templates[i].height, 1); } } @@ -132,9 +132,9 @@ u16 AddWindow(const struct WindowTemplate *template) bgLayer = template->bg; allocatedBaseBlock = 0; - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { - allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, template->width * template->height, 0); + allocatedBaseBlock = BgTileAllocOp(bgLayer, 0, template->width * template->height, 0); if (allocatedBaseBlock == -1) return WINDOW_NONE; @@ -174,10 +174,10 @@ u16 AddWindow(const struct WindowTemplate *template) gWindows[win].tileData = allocatedTilemapBuffer; gWindows[win].window = *template; - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { gWindows[win].window.baseBlock = allocatedBaseBlock; - DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, allocatedBaseBlock, gWindows[win].window.width * gWindows[win].window.height, 1); + BgTileAllocOp(bgLayer, allocatedBaseBlock, gWindows[win].window.width * gWindows[win].window.height, 1); } return win; @@ -201,9 +201,9 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template) bgLayer = template->bg; allocatedBaseBlock = 0; - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { - allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, template->width * template->height, 0); + allocatedBaseBlock = BgTileAllocOp(bgLayer, 0, template->width * template->height, 0); if (allocatedBaseBlock == -1) return WINDOW_NONE; @@ -211,10 +211,10 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template) gWindows[win].window = *template; - if (gUnneededFireRedVariable == 1) + if (gWindowTileAutoAllocEnabled == TRUE) { gWindows[win].window.baseBlock = allocatedBaseBlock; - DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, allocatedBaseBlock, gWindows[win].window.width * gWindows[win].window.height, 1); + BgTileAllocOp(bgLayer, allocatedBaseBlock, gWindows[win].window.width * gWindows[win].window.height, 1); } return win; @@ -224,10 +224,8 @@ void RemoveWindow(u8 windowId) { u8 bgLayer = gWindows[windowId].window.bg; - if (gUnneededFireRedVariable == 1) - { - DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, gWindows[windowId].window.baseBlock, gWindows[windowId].window.width * gWindows[windowId].window.height, 2); - } + if (gWindowTileAutoAllocEnabled == TRUE) + BgTileAllocOp(bgLayer, gWindows[windowId].window.baseBlock, gWindows[windowId].window.width * gWindows[windowId].window.height, 2); gWindows[windowId].window = sDummyWindowTemplate; diff --git a/include/battle_arena.h b/include/battle_arena.h index c3bdd4ea7..b55fc39b0 100644 --- a/include/battle_arena.h +++ b/include/battle_arena.h @@ -9,6 +9,6 @@ void BattleArena_AddSkillPoints(u8 battler); void BattleArena_DeductMindPoints(u8 battler, u16 stringId); void sub_81A586C(u8 battler); void DrawArenaRefereeTextBox(void); -void RemoveArenaRefereeTextBox(void); +void EraseArenaRefereeTextBox(void); #endif //GUARD_BATTLE_ARENA_H diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index 3288204d1..a367bc043 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -39,7 +39,7 @@ void LoadAndCreateEnemyShadowSprites(void); void SpriteCB_SetInvisible(struct Sprite *sprite); void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species); void HideBattlerShadowSprite(u8 battlerId); -void sub_805EF14(void); +void FillAroundBattleWindows(void); void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute); void AllocateMonSpritesGfx(void); void FreeMonSpritesGfx(void); diff --git a/include/battle_util2.h b/include/battle_util2.h index fe767ea4b..51c9c0363 100644 --- a/include/battle_util2.h +++ b/include/battle_util2.h @@ -5,6 +5,6 @@ void AllocateBattleResources(void); void FreeBattleResources(void); void AdjustFriendshipOnBattleFaint(u8 battler); void SwitchPartyOrderInGameMulti(u8 battler, u8 arg1); -u32 sub_805725C(u8 battler); +u32 BattlePalace_TryEscapeStatus(u8 battler); #endif // GUARD_BATTLE_UTIL_H diff --git a/include/constants/battle.h b/include/constants/battle.h index 3dbd83255..a848146eb 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -161,8 +161,8 @@ #define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER) // Not really sure what a "hitmarker" is. -#define HITMARKER_x10 (1 << 4) -#define HITMARKER_x20 (1 << 5) +#define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked. +#define HITMARKER_SKIP_DMG_TRACK (1 << 5) #define HITMARKER_DESTINYBOND (1 << 6) #define HITMARKER_NO_ANIMATIONS (1 << 7) #define HITMARKER_IGNORE_SUBSTITUTE (1 << 8) @@ -177,13 +177,13 @@ #define HITMARKER_IGNORE_UNDERGROUND (1 << 17) #define HITMARKER_IGNORE_UNDERWATER (1 << 18) #define HITMARKER_UNABLE_TO_USE_MOVE (1 << 19) -#define HITMARKER_x100000 (1 << 20) -#define HITMARKER_x200000 (1 << 21) -#define HITMARKER_x400000 (1 << 22) -#define HITMARKER_x800000 (1 << 23) +#define HITMARKER_PASSIVE_DAMAGE (1 << 20) +#define HITMARKER_DISOBEDIENT_MOVE (1 << 21) +#define HITMARKER_PLAYER_FAINTED (1 << 22) +#define HITMARKER_ALLOW_NO_PP (1 << 23) #define HITMARKER_GRUDGE (1 << 24) #define HITMARKER_OBEYS (1 << 25) -#define HITMARKER_x4000000 (1 << 26) +#define HITMARKER_NEVER_SET (1 << 26) // Cleared as part of a large group. Never set or checked #define HITMARKER_CHARGING (1 << 27) #define HITMARKER_FAINTED(battler) (gBitTable[battler] << 28) #define HITMARKER_FAINTED2(battler) ((1 << 28) << battler) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 9794589af..d5e3eb7bb 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -72,12 +72,15 @@ #define VARIOUS_GET_BATTLER_FAINTED 4 #define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 #define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 +#define VARIOUS_RESET_PLAYER_FAINTED 7 #define VARIOUS_PALACE_FLAVOR_TEXT 8 #define VARIOUS_ARENA_JUDGMENT_WINDOW 9 #define VARIOUS_ARENA_OPPONENT_MON_LOST 10 #define VARIOUS_ARENA_PLAYER_MON_LOST 11 #define VARIOUS_ARENA_BOTH_MONS_LOST 12 #define VARIOUS_EMIT_YESNOBOX 13 +#define VARIOUS_DRAW_ARENA_REF_TEXT_BOX 14 +#define VARIOUS_ERASE_ARENA_REF_TEXT_BOX 15 #define VARIOUS_ARENA_JUDGMENT_STRING 16 #define VARIOUS_ARENA_WAIT_STRING 17 #define VARIOUS_WAIT_CRY 18 @@ -86,6 +89,7 @@ #define VARIOUS_VOLUME_DOWN 21 #define VARIOUS_VOLUME_UP 22 #define VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT 23 +#define VARIOUS_PALACE_TRY_ESCAPE_STATUS 24 #define VARIOUS_SET_TELEPORT_OUTCOME 25 #define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 diff --git a/include/pokedex_area_region_map.h b/include/pokedex_area_region_map.h index 175f60c74..6526d7b45 100755 --- a/include/pokedex_area_region_map.h +++ b/include/pokedex_area_region_map.h @@ -10,7 +10,7 @@ struct PokedexAreaMapTemplate }; void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *); -bool32 sub_81C4E90(void); +bool32 TryShowPokedexAreaMap(void); void PokedexAreaMapChangeBgY(u32); void FreePokedexAreaMapBgNum(void); diff --git a/src/battle_anim_dark.c b/src/battle_anim_dark.c index fdde34769..fe8b18105 100644 --- a/src/battle_anim_dark.c +++ b/src/battle_anim_dark.c @@ -784,7 +784,7 @@ void AnimTask_InitMementoShadow(u8 taskId) DestroyAnimVisualTask(taskId); } -void sub_8114470(u8 taskId) +void AnimTask_MementoHandleBg(u8 taskId) { u8 toBG2 = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) ^ 1 ? 1 : 0; ResetBattleAnimBg(toBG2); diff --git a/src/battle_anim_normal.c b/src/battle_anim_normal.c index 15a1452e4..d79f344ed 100644 --- a/src/battle_anim_normal.c +++ b/src/battle_anim_normal.c @@ -733,50 +733,67 @@ void AnimTask_InvertScreenColor(u8 taskId) DestroyAnimVisualTask(taskId); } -void UnusedAnimTask_8115F94(u8 taskId) +// Unused +#define tTimer data[0] +#define tLength data[1] +#define tFlagsScenery data[2] +#define tFlagsAttacker data[3] +#define tFlagsTarget data[4] +#define tColorR data[5] +#define tColorG data[6] +#define tColorB data[7] +void AnimTask_TintPalettes(u8 taskId) { u8 attackerBattler; u8 targetBattler; u8 paletteIndex; u32 selectedPalettes = 0; - if (gTasks[taskId].data[0] == 0) + if (gTasks[taskId].tTimer == 0) { - gTasks[taskId].data[2] = gBattleAnimArgs[0]; - gTasks[taskId].data[3] = gBattleAnimArgs[1]; - gTasks[taskId].data[4] = gBattleAnimArgs[2]; - gTasks[taskId].data[1] = gBattleAnimArgs[3]; - gTasks[taskId].data[5] = gBattleAnimArgs[4]; - gTasks[taskId].data[6] = gBattleAnimArgs[5]; - gTasks[taskId].data[7] = gBattleAnimArgs[6]; + gTasks[taskId].tFlagsScenery = gBattleAnimArgs[0]; + gTasks[taskId].tFlagsAttacker = gBattleAnimArgs[1]; + gTasks[taskId].tFlagsTarget = gBattleAnimArgs[2]; + gTasks[taskId].tLength = gBattleAnimArgs[3]; + gTasks[taskId].tColorR = gBattleAnimArgs[4]; + gTasks[taskId].tColorG = gBattleAnimArgs[5]; + gTasks[taskId].tColorB = gBattleAnimArgs[6]; } - gTasks[taskId].data[0]++; + gTasks[taskId].tTimer++; attackerBattler = gBattleAnimAttacker; targetBattler = gBattleAnimTarget; - if (gTasks[taskId].data[2] & 0x100) - selectedPalettes = 0x0000FFFF; + if (gTasks[taskId].tFlagsScenery & (1 << 8)) + selectedPalettes = PALETTES_BG; - if (gTasks[taskId].data[2] & 0x1) + if (gTasks[taskId].tFlagsScenery & 1) { paletteIndex = IndexOfSpritePaletteTag(gSprites[gHealthboxSpriteIds[attackerBattler]].template->paletteTag); selectedPalettes |= (1 << paletteIndex) << 16; } - if (gTasks[taskId].data[3] & 0x100) + if (gTasks[taskId].tFlagsAttacker & (1 << 8)) selectedPalettes |= (1 << attackerBattler) << 16; - if (gTasks[taskId].data[4] & 0x100) + if (gTasks[taskId].tFlagsTarget & (1 << 8)) selectedPalettes |= (1 << targetBattler) << 16; - TintPlttBuffer(selectedPalettes, gTasks[taskId].data[5], gTasks[taskId].data[6], gTasks[taskId].data[7]); - if (gTasks[taskId].data[0] == gTasks[taskId].data[1]) + TintPlttBuffer(selectedPalettes, gTasks[taskId].tColorR, gTasks[taskId].tColorG, gTasks[taskId].tColorB); + if (gTasks[taskId].tTimer == gTasks[taskId].tLength) { UnfadePlttBuffer(selectedPalettes); DestroyAnimVisualTask(taskId); } } +#undef tTimer +#undef tLength +#undef tFlagsScenery +#undef tFlagsAttacker +#undef tFlagsTarget +#undef tColorR +#undef tColorG +#undef tColorB static void AnimShakeMonOrBattleTerrain(struct Sprite *sprite) { diff --git a/src/battle_arena.c b/src/battle_arena.c index 11c918225..e216e72d3 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -917,7 +917,7 @@ void DrawArenaRefereeTextBox(void) FillBgTilemapBufferRect(0, 0x836, 29, 19, 1, 1, palNum); } -void RemoveArenaRefereeTextBox(void) +void EraseArenaRefereeTextBox(void) { u8 width; u8 height; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 184d630b5..77755775e 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -1213,7 +1213,8 @@ void HideBattlerShadowSprite(u8 battlerId) gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_SetInvisible; } -void sub_805EF14(void) +// Color the background tiles surrounding the action selection and move windows +void FillAroundBattleWindows(void) { u16 *vramPtr = (u16*)(VRAM + 0x240); s32 i; diff --git a/src/battle_main.c b/src/battle_main.c index 19505b385..f4e1c4d3d 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -961,7 +961,7 @@ static void CB2_HandleStartBattle(void) ShowBg(1); ShowBg(2); ShowBg(3); - sub_805EF14(); + FillAroundBattleWindows(); gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) @@ -1157,7 +1157,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) ShowBg(1); ShowBg(2); ShowBg(3); - sub_805EF14(); + FillAroundBattleWindows(); gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) @@ -1558,7 +1558,7 @@ static void CB2_HandleStartMultiBattle(void) ShowBg(1); ShowBg(2); ShowBg(3); - sub_805EF14(); + FillAroundBattleWindows(); gBattleCommunication[MULTIUSE_STATE] = 1; } if (gWirelessCommType) @@ -2150,7 +2150,7 @@ void CB2_InitEndLinkBattle(void) SetHBlankCallback(NULL); SetVBlankCallback(NULL); - gBattleTypeFlags &= ~(BATTLE_TYPE_LINK_IN_BATTLE); + gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { @@ -3116,7 +3116,7 @@ void SwitchInClearSetData(void) && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 && (gDisableStructs[i].battlerWithSureHit == gActiveBattler)) { - gStatuses3[i] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; gStatuses3[i] |= STATUS3_ALWAYS_HITS_TURN(2); } } @@ -3130,9 +3130,9 @@ void SwitchInClearSetData(void) for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler)) - gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBattler)); + gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(gActiveBattler); if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler) - gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); + gBattleMons[i].status2 &= ~STATUS2_WRAPPED; } gActionSelectionCursor[gActiveBattler] = 0; @@ -3212,9 +3212,9 @@ void FaintClearSetData(void) if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler)) - gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBattler)); + gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(gActiveBattler); if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler) - gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); + gBattleMons[i].status2 &= ~STATUS2_WRAPPED; } gActionSelectionCursor[gActiveBattler] = 0; @@ -3821,7 +3821,7 @@ static void TryDoEventsBeforeFirstTurn(void) gBattleCommunication[i] = 0; for (i = 0; i < gBattlersCount; i++) - gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); + gBattleMons[i].status2 &= ~STATUS2_FLINCHED; *(&gBattleStruct->turnEffectsTracker) = 0; *(&gBattleStruct->turnEffectsBattlerId) = 0; @@ -3852,7 +3852,7 @@ static void HandleEndTurn_ContinueBattle(void) gBattleCommunication[i] = 0; for (i = 0; i < gBattlersCount; i++) { - gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); + gBattleMons[i].status2 &= ~STATUS2_FLINCHED; if ((gBattleMons[i].status1 & STATUS1_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) CancelMultiTurnMoves(i); } @@ -3884,10 +3884,10 @@ void BattleTurnPassed(void) return; TurnValuesCleanUp(FALSE); - gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); - gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); - gHitMarker &= ~(HITMARKER_x400000); - gHitMarker &= ~(HITMARKER_x100000); + gHitMarker &= ~HITMARKER_NO_ATTACKSTRING; + gHitMarker &= ~HITMARKER_UNABLE_TO_USE_MOVE; + gHitMarker &= ~HITMARKER_PLAYER_FAINTED; + gHitMarker &= ~HITMARKER_PASSIVE_DAMAGE; gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; gBattleScripting.moveendState = 0; @@ -4795,12 +4795,12 @@ static void TurnValuesCleanUp(bool8 var0) { gDisableStructs[gActiveBattler].rechargeTimer--; if (gDisableStructs[gActiveBattler].rechargeTimer == 0) - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_RECHARGE); + gBattleMons[gActiveBattler].status2 &= ~STATUS2_RECHARGE; } } if (gDisableStructs[gActiveBattler].substituteHP == 0) - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_SUBSTITUTE); + gBattleMons[gActiveBattler].status2 &= ~STATUS2_SUBSTITUTE; } gSideTimers[0].followmeTimer = 0; @@ -4860,15 +4860,15 @@ static void RunTurnActionsFunctions(void) if (gCurrentTurnActionNumber >= gBattlersCount) // everyone did their actions, turn finished { - gHitMarker &= ~(HITMARKER_x100000); + gHitMarker &= ~HITMARKER_PASSIVE_DAMAGE; gBattleMainFunc = sEndTurnFuncsTable[gBattleOutcome & 0x7F]; } else { if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another battlerId { - gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING); - gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE); + gHitMarker &= ~HITMARKER_NO_ATTACKSTRING; + gHitMarker &= ~HITMARKER_UNABLE_TO_USE_MOVE; } } } @@ -4883,7 +4883,7 @@ static void HandleEndTurn_BattleWon(void) gBattleTextBuff1[0] = gBattleOutcome; gBattlerAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; - gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); + gBattleOutcome &= ~B_OUTCOME_LINK_BATTLE_RAN; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_EREADER_TRAINER)) @@ -4942,13 +4942,13 @@ static void HandleEndTurn_BattleLost(void) if (gBattleOutcome & B_OUTCOME_LINK_BATTLE_RAN) { gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeitedLinkBattle; - gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); + gBattleOutcome &= ~B_OUTCOME_LINK_BATTLE_RAN; gSaveBlock2Ptr->frontier.disableRecordBattle = TRUE; } else { gBattlescriptCurrInstr = BattleScript_FrontierLinkBattleLost; - gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); + gBattleOutcome &= ~B_OUTCOME_LINK_BATTLE_RAN; } } else @@ -4956,7 +4956,7 @@ static void HandleEndTurn_BattleLost(void) gBattleTextBuff1[0] = gBattleOutcome; gBattlerAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; - gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); + gBattleOutcome &= ~B_OUTCOME_LINK_BATTLE_RAN; } } else diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2a5b4c112..e33e31796 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -924,7 +924,7 @@ static void Cmd_attackcanceler(void) return; if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; - if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & (HITMARKER_x800000 | HITMARKER_NO_ATTACKSTRING)) + if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & (HITMARKER_ALLOW_NO_PP | HITMARKER_NO_ATTACKSTRING)) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) { gBattlescriptCurrInstr = BattleScript_NoPPForMove; @@ -932,7 +932,7 @@ static void Cmd_attackcanceler(void) return; } - gHitMarker &= ~(HITMARKER_x800000); + gHitMarker &= ~HITMARKER_ALLOW_NO_PP; if (!(gHitMarker & HITMARKER_OBEYS) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) { @@ -1237,7 +1237,7 @@ static void Cmd_ppreduce(void) } } - gHitMarker &= ~(HITMARKER_NO_PPDEDUCT); + gHitMarker &= ~HITMARKER_NO_PPDEDUCT; gBattlescriptCurrInstr++; } @@ -1869,7 +1869,7 @@ static void Cmd_datahpupdate(void) } else { - gHitMarker &= ~(HITMARKER_IGNORE_SUBSTITUTE); + gHitMarker &= ~HITMARKER_IGNORE_SUBSTITUTE; if (gBattleMoveDamage < 0) // hp goes up { gBattleMons[gActiveBattler].hp -= gBattleMoveDamage; @@ -1879,9 +1879,9 @@ static void Cmd_datahpupdate(void) } else // hp goes down { - if (gHitMarker & HITMARKER_x20) + if (gHitMarker & HITMARKER_SKIP_DMG_TRACK) { - gHitMarker &= ~(HITMARKER_x20); + gHitMarker &= ~HITMARKER_SKIP_DMG_TRACK; } else { @@ -1903,10 +1903,10 @@ static void Cmd_datahpupdate(void) gBattleMons[gActiveBattler].hp = 0; } - if (!gSpecialStatuses[gActiveBattler].dmg && !(gHitMarker & HITMARKER_x100000)) + if (!gSpecialStatuses[gActiveBattler].dmg && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE)) gSpecialStatuses[gActiveBattler].dmg = gHpDealt; - if (IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_x100000) && gCurrentMove != MOVE_PAIN_SPLIT) + if (IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && gCurrentMove != MOVE_PAIN_SPLIT) { gProtectStructs[gActiveBattler].physicalDmg = gHpDealt; gSpecialStatuses[gActiveBattler].physicalDmg = gHpDealt; @@ -1921,7 +1921,7 @@ static void Cmd_datahpupdate(void) gSpecialStatuses[gActiveBattler].physicalBattlerId = gBattlerTarget; } } - else if (!IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_x100000)) + else if (!IS_TYPE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE)) { gProtectStructs[gActiveBattler].specialDmg = gHpDealt; gSpecialStatuses[gActiveBattler].specialDmg = gHpDealt; @@ -1937,7 +1937,7 @@ static void Cmd_datahpupdate(void) } } } - gHitMarker &= ~(HITMARKER_x100000); + gHitMarker &= ~HITMARKER_PASSIVE_DAMAGE; BtlController_EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBattler].hp); MarkBattlerForControllerExec(gActiveBattler); } @@ -1972,7 +1972,7 @@ static void Cmd_effectivenesssound(void) gActiveBattler = gBattlerTarget; if (!(gMoveResultFlags & MOVE_RESULT_MISSED)) { - switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) + switch (gMoveResultFlags & (u8)(~MOVE_RESULT_MISSED)) { case MOVE_RESULT_SUPER_EFFECTIVE: BtlController_EmitPlaySE(0, SE_SUPER_EFFECTIVE); @@ -2026,7 +2026,7 @@ static void Cmd_resultmessage(void) else { gBattleCommunication[MSG_DISPLAY] = 1; - switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) + switch (gMoveResultFlags & (u8)(~MOVE_RESULT_MISSED)) { case MOVE_RESULT_SUPER_EFFECTIVE: stringId = STRINGID_SUPEREFFECTIVE; @@ -2060,9 +2060,9 @@ static void Cmd_resultmessage(void) } else if (gMoveResultFlags & MOVE_RESULT_ONE_HIT_KO) { - gMoveResultFlags &= ~(MOVE_RESULT_ONE_HIT_KO); - gMoveResultFlags &= ~(MOVE_RESULT_SUPER_EFFECTIVE); - gMoveResultFlags &= ~(MOVE_RESULT_NOT_VERY_EFFECTIVE); + gMoveResultFlags &= ~MOVE_RESULT_ONE_HIT_KO; + gMoveResultFlags &= ~MOVE_RESULT_SUPER_EFFECTIVE; + gMoveResultFlags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_OneHitKOMsg; return; @@ -2206,7 +2206,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_AFFECTS_USER) { gEffectBattler = gBattlerAttacker; // battlerId that effects get applied on - gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER); + gBattleCommunication[MOVE_EFFECT_BYTE] &= ~MOVE_EFFECT_AFFECTS_USER; affectsUser = MOVE_EFFECT_AFFECTS_USER; gBattleScripting.battler = gBattlerTarget; // theoretically the attacker } @@ -2273,7 +2273,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; } else { @@ -2314,7 +2314,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; } else { @@ -2370,7 +2370,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; } else { @@ -2398,7 +2398,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ABILITY_PREVENTS_ABILITY_STATUS; - gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; } else { @@ -2424,8 +2424,8 @@ void SetMoveEffect(bool8 primary, u8 certain) break; // It's redundant, because at this point we know the status1 value is 0. - gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON); - gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON); + gBattleMons[gEffectBattler].status1 &= ~STATUS1_TOXIC_POISON; + gBattleMons[gEffectBattler].status1 &= ~STATUS1_POISON; statusChanged = TRUE; break; } @@ -2453,7 +2453,7 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUSED_BY_ABILITY; - gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + gHitMarker &= ~HITMARKER_IGNORE_SAFEGUARD; } else { @@ -2790,7 +2790,7 @@ void SetMoveEffect(bool8 primary, u8 certain) } else { - gBattleMons[gBattlerTarget].status1 &= ~(STATUS1_PARALYSIS); + gBattleMons[gBattlerTarget].status1 &= ~STATUS1_PARALYSIS; gActiveBattler = gBattlerTarget; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); @@ -2881,7 +2881,7 @@ static void Cmd_seteffectwithchance(void) if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_CERTAIN && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_CERTAIN); + gBattleCommunication[MOVE_EFFECT_BYTE] &= ~MOVE_EFFECT_CERTAIN; SetMoveEffect(FALSE, MOVE_EFFECT_CERTAIN); } else if (Random() % 100 < percentChance @@ -2939,7 +2939,7 @@ static void Cmd_tryfaintmon(void) BattleScriptPop(); gBattlescriptCurrInstr = BS_ptr; - gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~SIDE_STATUS_SPIKES_DAMAGED; } else { @@ -2970,7 +2970,7 @@ static void Cmd_tryfaintmon(void) gBattlescriptCurrInstr = BS_ptr; if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - gHitMarker |= HITMARKER_x400000; + gHitMarker |= HITMARKER_PLAYER_FAINTED; if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); @@ -2983,7 +2983,7 @@ static void Cmd_tryfaintmon(void) } if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { - gHitMarker &= ~(HITMARKER_DESTINYBOND); + gHitMarker &= ~HITMARKER_DESTINYBOND; BattleScriptPush(gBattlescriptCurrInstr); gBattleMoveDamage = gBattleMons[battlerId].hp; gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife; @@ -3581,8 +3581,8 @@ static void MoveValuesCleanUp(void) gCritMultiplier = 1; gBattleCommunication[MOVE_EFFECT_BYTE] = 0; gBattleCommunication[MISS_TYPE] = 0; - gHitMarker &= ~(HITMARKER_DESTINYBOND); - gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); + gHitMarker &= ~HITMARKER_DESTINYBOND; + gHitMarker &= ~HITMARKER_SYNCHRONISE_EFFECT; } static void Cmd_movevaluescleanup(void) @@ -4217,7 +4217,7 @@ static void Cmd_moveend(void) && gSpecialStatuses[gBattlerTarget].specialDmg && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && moveType == TYPE_FIRE) { - gBattleMons[gBattlerTarget].status1 &= ~(STATUS1_FREEZE); + gBattleMons[gBattlerTarget].status1 &= ~STATUS1_FREEZE; gActiveBattler = gBattlerTarget; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBattlerTarget].status1); MarkBattlerForControllerExec(gActiveBattler); @@ -4313,7 +4313,7 @@ static void Cmd_moveend(void) gActiveBattler = gBattlerAttacker; BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); - gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); + gStatuses3[gBattlerAttacker] &= ~STATUS3_SEMI_INVULNERABLE; gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; gBattleScripting.moveendState++; return; @@ -4327,7 +4327,7 @@ static void Cmd_moveend(void) gActiveBattler = gBattlerTarget; BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); - gStatuses3[gBattlerTarget] &= ~(STATUS3_SEMI_INVULNERABLE); + gStatuses3[gBattlerTarget] &= ~STATUS3_SEMI_INVULNERABLE; gBattleScripting.moveendState++; return; } @@ -4337,7 +4337,7 @@ static void Cmd_moveend(void) for (i = 0; i < gBattlersCount; i++) { if (gDisableStructs[i].substituteHP == 0) - gBattleMons[i].status2 &= ~(STATUS2_SUBSTITUTE); + gBattleMons[i].status2 &= ~STATUS2_SUBSTITUTE; } gBattleScripting.moveendState++; break; @@ -4347,7 +4347,7 @@ static void Cmd_moveend(void) gActiveBattler = gBattlerAttacker; gBattlerAttacker = gBattlerTarget; gBattlerTarget = gActiveBattler; - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); + gHitMarker &= ~HITMARKER_SWAP_ATTACKER_TARGET; } if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED) { @@ -4657,7 +4657,7 @@ static void Cmd_jumpifcantswitch(void) s32 lastMonId; struct Pokemon *party; - gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(SWITCH_IGNORE_ESCAPE_PREVENTION)); + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~SWITCH_IGNORE_ESCAPE_PREVENTION); if (!(gBattlescriptCurrInstr[1] & SWITCH_IGNORE_ESCAPE_PREVENTION) && ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) @@ -4837,7 +4837,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(gActiveBattler, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitLinkStandbyMsg(0, 2, FALSE); MarkBattlerForControllerExec(gActiveBattler); } @@ -4866,7 +4866,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(0, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -4888,7 +4888,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(2, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -4909,7 +4909,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(1, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -4931,7 +4931,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(3, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -4994,7 +4994,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -5010,7 +5010,7 @@ static void Cmd_openpartyscreen(void) if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } @@ -5049,7 +5049,7 @@ static void Cmd_openpartyscreen(void) else hitmarkerFaintBits = PARTY_ACTION_SEND_OUT; - battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(PARTY_SCREEN_OPTIONAL)); + battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~PARTY_SCREEN_OPTIONAL); if (gSpecialStatuses[battlerId].flag40) { gBattlescriptCurrInstr += 6; @@ -5058,7 +5058,7 @@ static void Cmd_openpartyscreen(void) { gActiveBattler = battlerId; gAbsentBattlerFlags |= gBitTable[gActiveBattler]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); gBattlescriptCurrInstr = jumpPtr; } else @@ -5174,7 +5174,7 @@ static void Cmd_switchineffects(void) gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); UpdateSentPokesToOpponentValue(gActiveBattler); - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); gSpecialStatuses[gActiveBattler].flag40 = 0; if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) @@ -5186,8 +5186,8 @@ static void Cmd_switchineffects(void) gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_SPIKES_DAMAGED; - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_DESTINY_BOND); - gHitMarker &= ~(HITMARKER_DESTINYBOND); + gBattleMons[gActiveBattler].status2 &= ~STATUS2_DESTINY_BOND; + gHitMarker &= ~HITMARKER_DESTINYBOND; spikesDmg = (5 - gSideTimers[GetBattlerSide(gActiveBattler)].spikesAmount) * 2; gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / (spikesDmg); @@ -5216,7 +5216,7 @@ static void Cmd_switchineffects(void) if (!AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0) && !ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gActiveBattler, FALSE)) { - gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~SIDE_STATUS_SPIKES_DAMAGED; for (i = 0; i < gBattlersCount; i++) { @@ -5632,7 +5632,7 @@ static void Cmd_swapattackerwithtarget(void) gBattlerTarget = gActiveBattler; if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); + gHitMarker &= ~HITMARKER_SWAP_ATTACKER_TARGET; else gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET; @@ -6315,13 +6315,13 @@ static void Cmd_various(void) *choicedMove = 0; } break; - case 7: + case VARIOUS_RESET_PLAYER_FAINTED: if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLE)) && gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleMons[0].hp != 0 && gBattleMons[1].hp != 0) { - gHitMarker &= ~(HITMARKER_x400000); + gHitMarker &= ~HITMARKER_PLAYER_FAINTED; } break; case VARIOUS_PALACE_FLAVOR_TEXT: @@ -6355,7 +6355,7 @@ static void Cmd_various(void) case VARIOUS_ARENA_PLAYER_MON_LOST: gBattleMons[0].hp = 0; gHitMarker |= HITMARKER_FAINTED(0); - gHitMarker |= HITMARKER_x400000; + gHitMarker |= HITMARKER_PLAYER_FAINTED; gBattleStruct->arenaLostPlayerMons |= gBitTable[gBattlerPartyIndexes[0]]; gDisableStructs[0].truantSwitchInHack = 1; break; @@ -6364,7 +6364,7 @@ static void Cmd_various(void) gBattleMons[1].hp = 0; gHitMarker |= HITMARKER_FAINTED(0); gHitMarker |= HITMARKER_FAINTED(1); - gHitMarker |= HITMARKER_x400000; + gHitMarker |= HITMARKER_PLAYER_FAINTED; gBattleStruct->arenaLostPlayerMons |= gBitTable[gBattlerPartyIndexes[0]]; gBattleStruct->arenaLostOpponentMons |= gBitTable[gBattlerPartyIndexes[1]]; gDisableStructs[0].truantSwitchInHack = 1; @@ -6374,11 +6374,11 @@ static void Cmd_various(void) BtlController_EmitYesNoBox(0); MarkBattlerForControllerExec(gActiveBattler); break; - case 14: + case VARIOUS_DRAW_ARENA_REF_TEXT_BOX: DrawArenaRefereeTextBox(); break; - case 15: - RemoveArenaRefereeTextBox(); + case VARIOUS_ERASE_ARENA_REF_TEXT_BOX: + EraseArenaRefereeTextBox(); break; case VARIOUS_ARENA_JUDGMENT_STRING: BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]); @@ -6420,8 +6420,8 @@ static void Cmd_various(void) case VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT: gBattleStruct->alreadyStatusedMoveAttempt |= gBitTable[gActiveBattler]; break; - case 24: - if (sub_805725C(gActiveBattler)) + case VARIOUS_PALACE_TRY_ESCAPE_STATUS: + if (BattlePalace_TryEscapeStatus(gActiveBattler)) return; break; case VARIOUS_SET_TELEPORT_OUTCOME: @@ -6595,14 +6595,14 @@ static void Cmd_trymirrormove(void) if (move != 0 && move != 0xFFFF) { - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gCurrentMove = move; gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else if (validMovesCount) { - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; i = Random() % validMovesCount; gCurrentMove = movesArray[i]; gBattlerTarget = GetMoveTarget(gCurrentMove, 0); @@ -6882,15 +6882,15 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) else gActiveBattler = gBattlerTarget; - flags &= ~(MOVE_EFFECT_AFFECTS_USER); + flags &= ~MOVE_EFFECT_AFFECTS_USER; if (flags & MOVE_EFFECT_CERTAIN) certain++; - flags &= ~(MOVE_EFFECT_CERTAIN); + flags &= ~MOVE_EFFECT_CERTAIN; if (flags & STAT_BUFF_NOT_PROTECT_AFFECTED) notProtectAffected++; - flags &= ~(STAT_BUFF_NOT_PROTECT_AFFECTED); + flags &= ~STAT_BUFF_NOT_PROTECT_AFFECTED; PREPARE_STAT_BUFFER(gBattleTextBuff1, statId) @@ -7719,7 +7719,7 @@ static void Cmd_setsubstitute(void) gBattleMoveDamage = 1; gBattleMons[gBattlerAttacker].status2 |= STATUS2_SUBSTITUTE; - gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_WRAPPED); + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_WRAPPED; gDisableStructs[gBattlerAttacker].substituteHP = gBattleMoveDamage; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_SUBSTITUTE; gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE; @@ -7803,7 +7803,7 @@ static void Cmd_metronome(void) if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END) { - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; gBattlerTarget = GetMoveTarget(gCurrentMove, 0); return; @@ -8019,7 +8019,7 @@ static void Cmd_settypetorandomresistance(void) // conversion 2 static void Cmd_setalwayshitflag(void) { - gStatuses3[gBattlerTarget] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[gBattlerTarget] &= ~STATUS3_ALWAYS_HITS; gStatuses3[gBattlerTarget] |= STATUS3_ALWAYS_HITS_TURN(2); gDisableStructs[gBattlerTarget].battlerWithSureHit = gBattlerAttacker; gBattlescriptCurrInstr++; @@ -8137,7 +8137,7 @@ static void Cmd_trychoosesleeptalkmove(void) } - unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); + unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~MOVE_LIMITATION_PP); if (unusableMovesBits == 0xF) // all 4 moves cannot be chosen { gBattlescriptCurrInstr += 5; @@ -8153,7 +8153,7 @@ static void Cmd_trychoosesleeptalkmove(void) gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition]; gCurrMovePos = movePosition; - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gBattlerTarget = GetMoveTarget(gCalledMove, 0); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } @@ -8269,7 +8269,7 @@ static void Cmd_healpartystatus(void) if (gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF) { gBattleMons[gBattlerAttacker].status1 = 0; - gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; } else { @@ -8285,7 +8285,7 @@ static void Cmd_healpartystatus(void) if (gBattleMons[gActiveBattler].ability != ABILITY_SOUNDPROOF) { gBattleMons[gActiveBattler].status1 = 0; - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gActiveBattler].status2 &= ~STATUS2_NIGHTMARE; } else { @@ -8325,14 +8325,14 @@ static void Cmd_healpartystatus(void) toHeal = 0x3F; gBattleMons[gBattlerAttacker].status1 = 0; - gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { gBattleMons[gActiveBattler].status1 = 0; - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gActiveBattler].status2 &= ~STATUS2_NIGHTMARE; } } @@ -8435,7 +8435,7 @@ static void Cmd_rolloutdamagecalculation(void) } if (--gDisableStructs[gBattlerAttacker].rolloutTimer == 0) // last hit { - gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_MULTIPLETURNS; } gDynamicBasePower = gBattleMoves[gCurrentMove].power; @@ -8515,7 +8515,7 @@ static void Cmd_presentdamagecalculation(void) gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; else { - gMoveResultFlags &= ~(MOVE_RESULT_DOESNT_AFFECT_FOE); + gMoveResultFlags &= ~MOVE_RESULT_DOESNT_AFFECT_FOE; gBattlescriptCurrInstr = BattleScript_PresentHealTarget; } } @@ -8628,7 +8628,7 @@ static void Cmd_jumpifnopursuitswitchdmg(void) gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerTarget); gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; } else { @@ -8693,7 +8693,7 @@ static void Cmd_rapidspinfree(void) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_WRAPPED) { gBattleScripting.battler = gBattlerTarget; - gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_WRAPPED); + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_WRAPPED; gBattlerTarget = *(gBattleStruct->wrappedBy + gBattlerAttacker); gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; @@ -8707,14 +8707,14 @@ static void Cmd_rapidspinfree(void) } else if (gStatuses3[gBattlerAttacker] & STATUS3_LEECHSEED) { - gStatuses3[gBattlerAttacker] &= ~(STATUS3_LEECHSEED); - gStatuses3[gBattlerAttacker] &= ~(STATUS3_LEECHSEED_BATTLER); + gStatuses3[gBattlerAttacker] &= ~STATUS3_LEECHSEED; + gStatuses3[gBattlerAttacker] &= ~STATUS3_LEECHSEED_BATTLER; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_LeechSeedFree; } else if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_SPIKES) { - gSideStatuses[GetBattlerSide(gBattlerAttacker)] &= ~(SIDE_STATUS_SPIKES); + gSideStatuses[GetBattlerSide(gBattlerAttacker)] &= ~SIDE_STATUS_SPIKES; gSideTimers[GetBattlerSide(gBattlerAttacker)].spikesAmount = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SpikesFree; @@ -8970,7 +8970,7 @@ static void Cmd_setcharge(void) static void Cmd_callterrainattack(void) // nature power { - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gCurrentMove = sNaturePowerMoves[gBattleTerrain]; gBattlerTarget = GetMoveTarget(gCurrentMove, 0); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); @@ -9380,7 +9380,7 @@ static void Cmd_assistattackselect(void) } if (chooseableMovesNo) { - gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gCalledMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; gBattlerTarget = GetMoveTarget(gCalledMove, 0); gBattlescriptCurrInstr += 5; @@ -9736,8 +9736,8 @@ static void Cmd_removelightscreenreflect(void) // brick break if (gSideTimers[opposingSide].reflectTimer || gSideTimers[opposingSide].lightscreenTimer) { - gSideStatuses[opposingSide] &= ~(SIDE_STATUS_REFLECT); - gSideStatuses[opposingSide] &= ~(SIDE_STATUS_LIGHTSCREEN); + gSideStatuses[opposingSide] &= ~SIDE_STATUS_REFLECT; + gSideStatuses[opposingSide] &= ~SIDE_STATUS_LIGHTSCREEN; gSideTimers[opposingSide].reflectTimer = 0; gSideTimers[opposingSide].lightscreenTimer = 0; gBattleScripting.animTurn = 1; diff --git a/src/battle_util.c b/src/battle_util.c index 9af456449..62f7897c6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -646,9 +646,9 @@ void HandleAction_NothingIsFainted(void) gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR - | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 - | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT - | HITMARKER_CHARGING | HITMARKER_x4000000); + | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_PASSIVE_DAMAGE + | HITMARKER_OBEYS | HITMARKER_WAKE_UP_CLEAR | HITMARKER_SYNCHRONISE_EFFECT + | HITMARKER_CHARGING | HITMARKER_NEVER_SET); } void HandleAction_ActionFinished(void) @@ -659,9 +659,9 @@ void HandleAction_ActionFinished(void) SpecialStatusesClear(); gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_IGNORE_ON_AIR - | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_x100000 - | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT - | HITMARKER_CHARGING | HITMARKER_x4000000); + | HITMARKER_IGNORE_UNDERGROUND | HITMARKER_IGNORE_UNDERWATER | HITMARKER_PASSIVE_DAMAGE + | HITMARKER_OBEYS | HITMARKER_WAKE_UP_CLEAR | HITMARKER_SYNCHRONISE_EFFECT + | HITMARKER_CHARGING | HITMARKER_NEVER_SET); gCurrentMove = 0; gBattleMoveDamage = 0; @@ -1443,7 +1443,7 @@ u8 DoBattlerEndTurnEffects(void) { u8 effect = 0; - gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); while (gBattleStruct->turnEffectsBattlerId < gBattlersCount && gBattleStruct->turnEffectsTracker <= ENDTURN_BATTLER_COUNT) { gActiveBattler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->turnEffectsBattlerId]; @@ -1756,13 +1756,13 @@ u8 DoBattlerEndTurnEffects(void) return effect; } } - gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_x20); + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); return 0; } bool8 HandleWishPerishSongOnTurnEnd(void) { - gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); switch (gBattleStruct->wishPerishSongState) { @@ -1862,7 +1862,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) break; } - gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_x20); + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); return FALSE; } @@ -4067,7 +4067,7 @@ u8 IsMonDisobedient(void) gCalledMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove; gBattlerTarget = GetMoveTarget(gCalledMove, 0); - gHitMarker |= HITMARKER_x200000; + gHitMarker |= HITMARKER_DISOBEDIENT_MOVE; return 2; } } diff --git a/src/battle_util2.c b/src/battle_util2.c index def7302d3..3838f22bb 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -121,7 +121,9 @@ void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1) } } -u32 sub_805725C(u8 battlerId) +// Called when a Pokémon is unable to attack during a Battle Palace battle. +// Check if it was because they are frozen/asleep, and if so try to cure the status. +u32 BattlePalace_TryEscapeStatus(u8 battlerId) { u32 effect = 0; @@ -134,6 +136,7 @@ u32 sub_805725C(u8 battlerId) { if (UproarWakeUpCheck(battlerId)) { + // Wake up from Uproar gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP); gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); @@ -150,6 +153,7 @@ u32 sub_805725C(u8 battlerId) else toSub = 1; + // Reduce number of sleep turns if ((gBattleMons[battlerId].status1 & STATUS1_SLEEP) < toSub) gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP); else @@ -157,11 +161,13 @@ u32 sub_805725C(u8 battlerId) if (gBattleMons[battlerId].status1 & STATUS1_SLEEP) { + // Still asleep gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep; effect = 2; } else { + // Wake up gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WOKE_UP; @@ -177,10 +183,12 @@ u32 sub_805725C(u8 battlerId) { if (Random() % 5 != 0) { + // Still frozen gBattlescriptCurrInstr = BattleScript_MoveUsedIsFrozen; } else { + // Unfreeze gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; @@ -193,7 +201,7 @@ u32 sub_805725C(u8 battlerId) case 2: break; } - + // Loop until reaching the final state, or stop early if Pokémon was Asleep/Frozen } while (gBattleCommunication[MULTIUSE_STATE] != 2 && effect == 0); if (effect == 2) diff --git a/src/contest.c b/src/contest.c index 886f2b95d..68cad859d 100644 --- a/src/contest.c +++ b/src/contest.c @@ -75,7 +75,7 @@ static void Task_FinishRoundOfAppeals(u8); static void Task_ReadyUpdateHeartSliders(u8); static void Task_UpdateHeartSliders(u8); static void Task_WaitForHeartSliders(u8); -static void sub_80DA348(u8); +static void Task_RestorePlttBufferUnfaded(u8); static void Task_WaitPrintRoundResult(u8); static void Task_PrintRoundResultText(u8); static void Task_ReUpdateHeartSliders(u8); @@ -2553,10 +2553,10 @@ static void Task_UpdateHeartSliders(u8 taskId) static void Task_WaitForHeartSliders(u8 taskId) { if (SlidersDoneUpdating()) - gTasks[taskId].func = sub_80DA348; + gTasks[taskId].func = Task_RestorePlttBufferUnfaded; } -static void sub_80DA348(u8 taskId) +static void Task_RestorePlttBufferUnfaded(u8 taskId) { DmaCopy32Defvars(3, eContestTempSave.cachedPlttBufferUnfaded, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2); gTasks[taskId].data[0] = 0; diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index e9d6b6070..0e85e37f2 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -978,7 +978,7 @@ static void Task_HofPC_PrintMonInfo(u8 taskId) currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId); gSprites[currMonID].oam.priority = 0; - sHofFadePalettes = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000; + sHofFadePalettes = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ PALETTES_OBJECTS; BlendPalettesUnfaded(sHofFadePalettes, 0xC, RGB(16, 29, 24)); currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId]; diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index 8bcf506fb..1751fd59d 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -562,23 +562,31 @@ void UpdateItemMenuSwapLinePos(u8 y) UpdateSwapLineSpritesPos(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH | SWAP_LINE_HAS_MARGIN, 120, (y + 1) * 16); } -static void sub_80D5018(void *mem0, void *mem1) +static void ArrangeBerryGfx(void *src, void *dest) { u8 i, j; - memset(mem1, 0, 0x800); - mem1 += 0x100; + memset(dest, 0, 0x800); + + // Create top margin + dest += 0x100; + for (i = 0; i < 6; i++) { - mem1 += 0x20; + // Create left margin + dest += 0x20; + + // Copy one row of berry's icon for (j = 0; j < 6; j++) { - memcpy(mem1, mem0, 0x20); - mem1 += 0x20; - mem0 += 0x20; + memcpy(dest, src, 0x20); + dest += 0x20; + src += 0x20; } + + // Create right margin if (i != 5) - mem1 += 0x20; + dest += 0x20; } } @@ -595,7 +603,7 @@ static void LoadBerryGfx(u8 berryId) pal.tag = TAG_BERRY_PIC_PAL; LoadCompressedSpritePalette(&pal); LZDecompressWram(sBerryPicTable[berryId].tiles, &gDecompressionBuffer[0x1000]); - sub_80D5018(&gDecompressionBuffer[0x1000], &gDecompressionBuffer[0]); + ArrangeBerryGfx(&gDecompressionBuffer[0x1000], &gDecompressionBuffer[0]); } u8 CreateBerryTagSprite(u8 id, s16 x, s16 y) diff --git a/src/main.c b/src/main.c index 3125716e2..215f85c46 100644 --- a/src/main.c +++ b/src/main.c @@ -57,7 +57,7 @@ const IntrFunc gIntrTableTemplate[] = #define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc))) -static u16 gUnknown_03000000; +static u16 sUnusedVar; // Never read u16 gKeyRepeatStartDelay; bool8 gLinkTransferringData; @@ -117,7 +117,7 @@ void AgbMain() SetMainCallback2(NULL); gLinkTransferringData = FALSE; - gUnknown_03000000 = 0xFC0; + sUnusedVar = 0xFC0; for (;;) { diff --git a/src/main_menu.c b/src/main_menu.c index 3248c189f..a60cf1a28 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -170,7 +170,7 @@ // Static RAM declarations -static EWRAM_DATA u8 gUnknown_02022D04 = 0; +static EWRAM_DATA bool8 sStartedPokeBallTask = 0; static EWRAM_DATA u16 sCurrItemAndOptionMenuCheck = 0; static u8 sBirchSpeechMainTaskId; @@ -201,7 +201,7 @@ static void NewGameBirchSpeech_ShowDialogueWindow(u8, u8); static void NewGameBirchSpeech_ClearWindow(u8); static void Task_NewGameBirchSpeech_ThisIsAPokemon(u8); static void Task_NewGameBirchSpeech_MainSpeech(u8); -static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextPrinterTemplate *printer, u16 a); +static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 a); static void Task_NewGameBirchSpeech_AndYouAre(u8); static void Task_NewGameBirchSpeechSub_WaitForLotad(u8); static void Task_NewGameBirchSpeech_StartBirchLotadPlatformFade(u8); @@ -1348,7 +1348,7 @@ static void Task_NewGameBirchSpeech_ThisIsAPokemon(u8 taskId) { gTasks[taskId].func = Task_NewGameBirchSpeech_MainSpeech; StringExpandPlaceholders(gStringVar4, gText_ThisIsAPokemon); - AddTextPrinterWithCallbackForMessage(1, NewGameBirchSpeech_ShowPokeBallPrinterCallback); + AddTextPrinterWithCallbackForMessage(1, NewGameBirchSpeech_WaitForThisIsPokemonText); sBirchSpeechMainTaskId = taskId; } } @@ -1411,7 +1411,7 @@ static void Task_NewGameBirchSpeech_AndYouAre(u8 taskId) { if (!RunTextPrintersAndIsPrinter0Active()) { - gUnknown_02022D04 = 0; + sStartedPokeBallTask = FALSE; StringExpandPlaceholders(gStringVar4, gText_Birch_AndYouAre); AddTextPrinterForMessage(1); gTasks[taskId].func = Task_NewGameBirchSpeech_StartBirchLotadPlatformFade; @@ -2250,21 +2250,21 @@ static void NewGameBirchSpeech_ClearWindow(u8 windowId) CopyWindowToVram(windowId, 2); } -static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextPrinterTemplate *printer, u16 a) +static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 a) { - if (*(printer->currentChar - 2) == 8 && gUnknown_02022D04 == 0) + // Wait for Birch's "This is a Pokémon" text to reach the pause + // Then start the PokéBall release (if it hasn't been started already) + if (*(printer->currentChar - 2) == EXT_CTRL_CODE_PAUSE && !sStartedPokeBallTask) { - gUnknown_02022D04 = 1; + sStartedPokeBallTask = TRUE; CreateTask(Task_NewGameBirchSpeechSub_InitPokeBall, 0); } } -void CreateYesNoMenuParameterized(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f) +void CreateYesNoMenuParameterized(u8 x, u8 y, u16 baseTileNum, u16 baseBlock, u8 yesNoPalNum, u8 winPalNum) { - struct WindowTemplate sp; - - sp = CreateWindowTemplate(0, a + 1, b + 1, 5, 4, f, d); - CreateYesNoMenu(&sp, c, e, 0); + struct WindowTemplate template = CreateWindowTemplate(0, x + 1, y + 1, 5, 4, winPalNum, baseBlock); + CreateYesNoMenu(&template, baseTileNum, yesNoPalNum, 0); } static void NewGameBirchSpeech_ShowDialogueWindow(u8 windowId, u8 copyToVram) diff --git a/src/menu.c b/src/menu.c index de1468e3b..dcc32319e 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1769,9 +1769,7 @@ void ResetTempTileDataBuffers(void) { int i; for (i = 0; i < (int)ARRAY_COUNT(sTempTileDataBuffer); i++) - { sTempTileDataBuffer[i] = NULL; - } sTempTileDataBufferIdx = 0; } @@ -1784,9 +1782,7 @@ bool8 FreeTempTileDataBuffersIfPossible(void) if (sTempTileDataBufferIdx) { for (i = 0; i < sTempTileDataBufferIdx; i++) - { FREE_AND_SET_NULL(sTempTileDataBuffer[i]); - } sTempTileDataBufferIdx = 0; } return FALSE; diff --git a/src/pokedex_area_region_map.c b/src/pokedex_area_region_map.c index 82d5e50e5..1ee5ca988 100644 --- a/src/pokedex_area_region_map.c +++ b/src/pokedex_area_region_map.c @@ -17,7 +17,7 @@ static const u32 sPokedexAreaMapAffine_Tilemap[] = INCBIN_U32("graphics/interfac void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) { u8 mode; - sPokedexAreaMapBgNum = Alloc(4); + sPokedexAreaMapBgNum = Alloc(sizeof(sPokedexAreaMapBgNum)); mode = template->mode; if (mode == 0) @@ -28,8 +28,9 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) } else { + // This is never reached, only a mode of 0 is given SetBgAttribute(template->bg, BG_ATTR_METRIC, 2); - SetBgAttribute(template->bg, BG_ATTR_TYPE, 1); + SetBgAttribute(template->bg, BG_ATTR_TYPE, BG_TYPE_AFFINE); // This does nothing. BG_ATTR_TYPE can't be set with this function DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0); sub_8199D3C(DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1), template->offset, 64, 64, TRUE); } @@ -41,7 +42,7 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) *sPokedexAreaMapBgNum = template->bg; } -bool32 sub_81C4E90(void) +bool32 TryShowPokedexAreaMap(void) { if (!FreeTempTileDataBuffersIfPossible()) { @@ -56,8 +57,7 @@ bool32 sub_81C4E90(void) void FreePokedexAreaMapBgNum(void) { - if (sPokedexAreaMapBgNum != NULL) - FREE_AND_SET_NULL(sPokedexAreaMapBgNum); + TRY_FREE_AND_SET_NULL(sPokedexAreaMapBgNum); } void PokedexAreaMapChangeBgY(u32 a0) diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 12f0e0d9e..2f0d676cb 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -86,7 +86,7 @@ static void CreateAreaMarkerSprites(void); static void LoadAreaUnknownGraphics(void); static void CreateAreaUnknownSprites(void); static void Task_HandlePokedexAreaScreenInput(u8); -static void sub_813D6B4(void); +static void ResetPokedexAreaMapBg(void); static void DestroyAreaMarkerSprites(void); static const u32 sAreaGlow_Pal[] = INCBIN_U32("graphics/pokedex/area_glow.gbapal"); @@ -665,7 +665,7 @@ static void Task_ShowPokedexAreaScreen(u8 taskId) StringFill(sPokedexAreaScreen->charBuffer, CHAR_SPACE, 16); break; case 2: - if (sub_81C4E90() == TRUE) + if (TryShowPokedexAreaMap() == TRUE) return; PokedexAreaMapChangeBgY(-8); break; @@ -697,7 +697,7 @@ static void Task_ShowPokedexAreaScreen(u8 taskId) SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_ALL); StartAreaGlow(); ShowBg(2); - ShowBg(3); + ShowBg(3); // TryShowPokedexAreaMap will have done this already SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON); break; case 11: @@ -743,7 +743,7 @@ static void Task_HandlePokedexAreaScreenInput(u8 taskId) return; DestroyAreaMarkerSprites(); sPokedexAreaScreen->screenSwitchState[0] = gTasks[taskId].data[1]; - sub_813D6B4(); + ResetPokedexAreaMapBg(); DestroyTask(taskId); FreePokedexAreaMapBgNum(); FREE_AND_SET_NULL(sPokedexAreaScreen); @@ -753,7 +753,7 @@ static void Task_HandlePokedexAreaScreenInput(u8 taskId) gTasks[taskId].tState++; } -static void sub_813D6B4(void) +static void ResetPokedexAreaMapBg(void) { SetBgAttribute(3, BG_ATTR_CHARBASEINDEX, 0); SetBgAttribute(3, BG_ATTR_PALETTEMODE, 0); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a58187d8b..801041c53 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -9822,13 +9822,13 @@ struct u16 height; } static const sTilemapDimensions[][4] = { - { + [BG_TYPE_NORMAL] = { { 256, 256}, { 512, 256}, { 256, 512}, { 512, 512}, }, - { + [BG_TYPE_AFFINE] = { { 128, 128}, { 256, 256}, { 512, 512}, @@ -9853,7 +9853,7 @@ static void TilemapUtil_SetMap(u8 id, u8 bg, const void *tilemap, u16 width, u16 bgType = GetBgAttribute(bg, BG_ATTR_TYPE); sTilemapUtil[id].altWidth = sTilemapDimensions[bgType][bgScreenSize].width; sTilemapUtil[id].altHeight = sTilemapDimensions[bgType][bgScreenSize].height; - if (bgType != 0) + if (bgType != BG_TYPE_NORMAL) sTilemapUtil[id].tileSize = 1; else sTilemapUtil[id].tileSize = 2; diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 58de22f05..6bc0e175b 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -162,7 +162,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) BeginHardwarePaletteFade(0xFF, 0, 0x10, 0, 1); gPaletteFade.bufferTransferDisabled = 0; SetMainCallback2(BattleMainCB2); - sub_805EF14(); + FillAroundBattleWindows(); break; } diff --git a/sym_common.txt b/sym_common.txt index 1525d8aec..938b78fbe 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -2,7 +2,7 @@ .include "main.o" @ ../gflib/bg.o .align 2 -gUnneededFireRedVariable: +gWindowTileAutoAllocEnabled: .space 4 @ ../gflib/window.o .align 4