From 35cffea9874a8b135eddade958b62ee2ecf441c1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 30 Mar 2019 12:37:18 +0100 Subject: [PATCH] Helpful macros for atk49 --- asm/macros/battle_script.inc | 32 ++++++++++ data/battle_scripts_1.s | 72 ++++++++-------------- include/constants/battle_script_commands.h | 22 ++++++- src/battle_script_commands.c | 25 +------- 4 files changed, 79 insertions(+), 72 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index ed32e4643..7a1af4c17 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -403,6 +403,38 @@ .byte \param0 .byte \param1 .endm + + @ Help macros for 5 uses of moveend command + + @ All cases + .macro moveendall + setbyte sMOVEEND_STATE, 0 + moveend 0, 0 + .endm + + @ Chosen case + .macro moveendcase case:req + setbyte sMOVEEND_STATE, \case + moveend 1, 0 + .endm + + @ All cases from (inclusive) + .macro moveendfrom from:req + setbyte sMOVEEND_STATE, \from + moveend 0, 0 + .endm + + @ All cases from 0 to (not inclusive) + .macro moveendto to:req + setbyte sMOVEEND_STATE, 0 + moveend 2, \to + .endm + + @ Cases from (inclusive) to (not inclusive) + .macro moveendfromto from:req, to:req + setbyte sMOVEEND_STATE, \from + moveend 2, \to + .endm .macro typecalc2 .byte 0x4a diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ae0e36be1..a3ba7eb08 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -284,8 +284,7 @@ BattleScript_HitFromAtkAnimation:: seteffectwithchance tryfaintmon BS_TARGET, FALSE, NULL BattleScript_MoveEnd:: - setbyte sMOVEEND_STATE, 0x0 - moveend 0x0, 0x0 + moveendall end BattleScript_MakeMoveMissed:: @@ -423,8 +422,7 @@ BattleScript_ExplosionLoop: resultmessage waitmessage 0x40 tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifnexttargetvalid BattleScript_ExplosionLoop tryfaintmon BS_ATTACKER, FALSE, NULL end @@ -432,8 +430,7 @@ BattleScript_ExplosionMissed: effectivenesssound resultmessage waitmessage 0x40 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifnexttargetvalid BattleScript_ExplosionLoop tryfaintmon BS_ATTACKER, FALSE, NULL end @@ -657,8 +654,7 @@ BattleScript_DoMultiHit:: printstring STRINGID_EMPTYSTRING3 waitmessage 0x1 addbyte sMULTIHIT_STRING + 4, 0x1 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_MultiHitPrintStrings decrementmultihit BattleScript_MultiHitLoop goto BattleScript_MultiHitPrintStrings @@ -674,10 +670,8 @@ BattleScript_MultiHitPrintStrings:: BattleScript_MultiHitEnd:: seteffectwithchance tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0x2 - moveend 0x1, 0x0 - setbyte sMOVEEND_STATE, 0x4 - moveend 0x0, 0x0 + moveendcase ATK49_SYNCHRONIZE_TARGET + moveendfrom ATK49_STATUS_IMMUNITY_ABILITIES end BattleScript_EffectConversion:: @@ -1441,8 +1435,7 @@ BattleScript_DoTripleKickAttack:: waitmessage 0x40 printstring STRINGID_EMPTYSTRING3 waitmessage 0x1 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_TripleKickPrintStrings decrementmultihit BattleScript_TripleKickLoop goto BattleScript_TripleKickPrintStrings @@ -1461,8 +1454,7 @@ BattleScript_TripleKickPrintStrings:: BattleScript_TripleKickEnd:: seteffectwithchance tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0xE - moveend 0x0, 0x0 + moveendfrom ATK49_UPDATE_LAST_MOVES end BattleScript_EffectThief:: @@ -1893,8 +1885,7 @@ BattleScript_DoHitAllWithUndergroundBonus:: printstring STRINGID_EMPTYSTRING3 waitmessage 0x1 tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifnexttargetvalid BattleScript_HitsAllWithUndergroundBonusLoop end BattleScript_HitAllWithUndergroundBonusMissed:: @@ -1903,8 +1894,7 @@ BattleScript_HitAllWithUndergroundBonusMissed:: effectivenesssound resultmessage waitmessage 0x40 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET jumpifnexttargetvalid BattleScript_HitsAllWithUndergroundBonusLoop end @@ -1995,8 +1985,7 @@ BattleScript_BeatUpAttack:: resultmessage waitmessage 0x40 tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET goto BattleScript_BeatUpLoop BattleScript_BeatUpEnd:: end @@ -2617,8 +2606,7 @@ BattleScript_TeeterDanceLoop:: resultmessage waitmessage 0x40 BattleScript_TeeterDanceDoMoveEndIncrement:: - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET BattleScript_TeeterDanceLoopIncrement:: addbyte gBattlerTarget, 0x1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TeeterDanceLoop @@ -3140,10 +3128,8 @@ BattleScript_DoSwitchOut:: switchinanim BS_ATTACKER, FALSE waitstate switchineffects BS_ATTACKER - setbyte sMOVEEND_STATE, 0x4 - moveend 0x1, 0x0 - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase ATK49_STATUS_IMMUNITY_ABILITIES + moveendcase ATK49_MIRROR_MOVE end2 BattleScript_PursuitDmgOnSwitchOut:: @@ -3166,8 +3152,7 @@ BattleScript_PursuitDmgOnSwitchOut:: resultmessage waitmessage 0x40 tryfaintmon BS_TARGET, FALSE, NULL - setbyte sMOVEEND_STATE, 0x3 - moveend 0x2, 0x6 + moveendfromto ATK49_MOVE_END_ABILITIES, ATK49_CHOICE_MOVE various4 BS_TARGET jumpifbyte CMP_EQUAL, gBattleCommunication, 0x0, BattleScript_PursuitDmgOnSwitchOutRet setbyte sGIVEEXP_STATE, 0x0 @@ -3395,8 +3380,7 @@ BattleScript_DisabledNoMore:: BattleScript_SelectingDisabledMoveInPalace:: printstring STRINGID_PKMNMOVEISDISABLED BattleScript_SelectingUnusableMoveInPalace:: - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET end BattleScript_EncoredNoMore:: @@ -3425,8 +3409,7 @@ BattleScript_SpikesOnAttacker:: BattleScript_SpikesOnAttackerFainted:: setbyte sGIVEEXP_STATE, 0x0 getexp BS_ATTACKER - setbyte sMOVEEND_STATE, 0x0 - moveend 0x0, 0x0 + moveendall goto BattleScript_HandleFaintedMon BattleScript_SpikesOnTarget:: @@ -3441,8 +3424,7 @@ BattleScript_SpikesOnTarget:: BattleScript_SpikesOnTargetFainted:: setbyte sGIVEEXP_STATE, 0x0 getexp BS_TARGET - setbyte sMOVEEND_STATE, 0x0 - moveend 0x0, 0x0 + moveendall goto BattleScript_HandleFaintedMon BattleScript_SpikesOnFaintedBattler:: @@ -3457,8 +3439,7 @@ BattleScript_SpikesOnFaintedBattler:: BattleScript_SpikesOnFaintedBattlerFainted:: setbyte sGIVEEXP_STATE, 0x0 getexp BS_FAINTED - setbyte sMOVEEND_STATE, 0x0 - moveend 0x0, 0x0 + moveendall goto BattleScript_HandleFaintedMon BattleScript_PrintHurtBySpikes:: @@ -3562,10 +3543,8 @@ BattleScript_DoFutureAttackHit:: tryfaintmon BS_TARGET, FALSE, NULL atk24 BattleScript_FutureAttackEnd BattleScript_FutureAttackEnd:: - setbyte sMOVEEND_STATE, 0x0 - moveend 0x1, 0x0 - setbyte sMOVEEND_STATE, 0xB - moveend 0x2, 0xE + moveendcase ATK49_RAGE + moveendfromto ATK49_ITEM_EFFECTS_ALL, ATK49_UPDATE_LAST_MOVES setbyte gMoveResultFlags, 0 end2 @@ -4254,8 +4233,7 @@ BattleScript_AbilityCuredStatus:: BattleScript_IgnoresWhileAsleep:: printstring STRINGID_PKMNIGNORESASLEEP waitmessage 0x40 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET end BattleScript_IgnoresAndUsesRandomMove:: @@ -4271,8 +4249,7 @@ BattleScript_MoveUsedLoafingAround:: BattleScript_82DB6C7:: printfromtable gInobedientStringIds waitmessage 0x40 - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET end BattleScript_IgnoresAndFallsAsleep:: @@ -4280,8 +4257,7 @@ BattleScript_IgnoresAndFallsAsleep:: waitmessage 0x40 setmoveeffect MOVE_EFFECT_SLEEP | MOVE_EFFECT_AFFECTS_USER seteffectprimary - setbyte sMOVEEND_STATE, 0x0 - moveend 0x2, 0x10 + moveendto ATK49_NEXT_TARGET end BattleScript_IgnoresAndHitsItself:: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index e8a2980a5..894bd13b6 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -95,8 +95,6 @@ // statchange defines #define STAT_CHANGE_BS_PTR 0x1 #define STAT_CHANGE_NOT_PROTECT_AFFECTED 0x20 -#define STAT_CHANGE_WORKED 0 -#define STAT_CHANGE_DIDNT_WORK 1 // atk48 #define ATK48_STAT_NEGATIVE 0x1 @@ -104,6 +102,26 @@ #define ATK48_ONLY_MULTIPLE 0x4 #define ATK48_DONT_CHECK_LOWER 0x8 +// atk49, moveend cases +#define ATK49_RAGE 0 +#define ATK49_DEFROST 1 +#define ATK49_SYNCHRONIZE_TARGET 2 +#define ATK49_MOVE_END_ABILITIES 3 +#define ATK49_STATUS_IMMUNITY_ABILITIES 4 +#define ATK49_SYNCHRONIZE_ATTACKER 5 +#define ATK49_CHOICE_MOVE 6 +#define ATK49_CHANGED_ITEMS 7 +#define ATK49_ATTACKER_INVISIBLE 8 +#define ATK49_ATTACKER_VISIBLE 9 +#define ATK49_TARGET_VISIBLE 10 +#define ATK49_ITEM_EFFECTS_ALL 11 +#define ATK49_KINGSROCK_SHELLBELL 12 +#define ATK49_SUBSTITUTE 13 +#define ATK49_UPDATE_LAST_MOVES 14 +#define ATK49_MIRROR_MOVE 15 +#define ATK49_NEXT_TARGET 16 +#define ATK49_COUNT 17 + #define BIT_HP 0x1 #define BIT_ATK 0x2 #define BIT_DEF 0x4 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0eb6dfec0..0a0c34ad2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4480,28 +4480,6 @@ static void atk48_playstatchangeanimation(void) } } -enum -{ - ATK49_RAGE, - ATK49_DEFROST, - ATK49_SYNCHRONIZE_TARGET, - ATK49_MOVE_END_ABILITIES, - ATK49_STATUS_IMMUNITY_ABILITIES, - ATK49_SYNCHRONIZE_ATTACKER, - ATK49_CHOICE_MOVE, - ATK49_CHANGED_ITEMS, - ATK49_ATTACKER_INVISIBLE, - ATK49_ATTACKER_VISIBLE, - ATK49_TARGET_VISIBLE, - ATK49_ITEM_EFFECTS_ALL, - ATK49_KINGSROCK_SHELLBELL, - ATK49_SUBSTITUTE, - ATK49_UPDATE_LAST_MOVES, - ATK49_MIRROR_MOVE, - ATK49_NEXT_TARGET, - ATK49_COUNT, -}; - static void atk49_moveend(void) { s32 i; @@ -7210,6 +7188,9 @@ static void atk88_negativedamage(void) gBattlescriptCurrInstr++; } +#define STAT_CHANGE_WORKED 0 +#define STAT_CHANGE_DIDNT_WORK 1 + static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) { bool8 certain = FALSE;