From 0e455634975b12504e643d2620889935a03df83b Mon Sep 17 00:00:00 2001 From: i0brendan0 Date: Mon, 19 Feb 2018 02:54:13 -0600 Subject: [PATCH 1/9] Add Fix for Lock On Status Moves These changes should fix the status move and secondary effects not working if the opponent is flying or digging but has been locked on. --- docs/bugs_and_glitches.md | 7 ++++++- engine/battle/effect_commands.asm | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 5abf9d08a..7a4242ece 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -292,13 +292,18 @@ This is a bug with `CheckHiddenOpponent` in [engine/battle/effect_commands.asm]( ```asm CheckHiddenOpponent: ; 37daa ; BUG: This routine should account for Lock-On and Mind Reader. +; Uncomment the lines below to fix. + ; ld a, BATTLE_VARS_SUBSTATUS5_OPP + ; call GetBattleVar + ; bit SUBSTATUS_LOCK_ON, a + ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret ``` -*To do:* Fix this bug. +**Fix:** Uncomment those 4 lines to fix. ## Beat Up can desynchronize link battles diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 48efba8fa..2cf4ac97d 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -9708,6 +9708,11 @@ BattleCommand_ThunderAccuracy: ; 37d94 CheckHiddenOpponent: ; 37daa ; BUG: This routine should account for Lock-On and Mind Reader. +; Uncomment the lines below to fix. + ; ld a, BATTLE_VARS_SUBSTATUS5_OPP + ; call GetBattleVar + ; bit SUBSTATUS_LOCK_ON, a + ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND From a99adb0e5affbb8ef5aa8ded07043801665efd9e Mon Sep 17 00:00:00 2001 From: i0brendan0 Date: Tue, 20 Feb 2018 01:48:22 -0600 Subject: [PATCH 2/9] Fix I did a dumb and used the wrong check instruction. Should actually work. --- docs/bugs_and_glitches.md | 2 +- engine/battle/effect_commands.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 7a4242ece..a1693a00d 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -295,7 +295,7 @@ CheckHiddenOpponent: ; 37daa ; Uncomment the lines below to fix. ; ld a, BATTLE_VARS_SUBSTATUS5_OPP ; call GetBattleVar - ; bit SUBSTATUS_LOCK_ON, a + ; and 1 << SUBSTATUS_LOCK_ON ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 2cf4ac97d..12915038c 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -9711,7 +9711,7 @@ CheckHiddenOpponent: ; 37daa ; Uncomment the lines below to fix. ; ld a, BATTLE_VARS_SUBSTATUS5_OPP ; call GetBattleVar - ; bit SUBSTATUS_LOCK_ON, a + ; and 1 << SUBSTATUS_LOCK_ON ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar From b57bafd3b7ca771a51596207105a54784175cb7b Mon Sep 17 00:00:00 2001 From: i0brendan0 Date: Mon, 26 Feb 2018 02:34:25 -0600 Subject: [PATCH 3/9] revert --- engine/battle/effect_commands.asm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 12915038c..48efba8fa 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -9708,11 +9708,6 @@ BattleCommand_ThunderAccuracy: ; 37d94 CheckHiddenOpponent: ; 37daa ; BUG: This routine should account for Lock-On and Mind Reader. -; Uncomment the lines below to fix. - ; ld a, BATTLE_VARS_SUBSTATUS5_OPP - ; call GetBattleVar - ; and 1 << SUBSTATUS_LOCK_ON - ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND From 82ffb584c8fefc04e1bad4895cdc2d9222100b4c Mon Sep 17 00:00:00 2001 From: i0brendan0 Date: Thu, 1 Mar 2018 04:08:54 -0600 Subject: [PATCH 4/9] Add Protect Bug and Fix Moves 'miss' when opponent uses Protect. --- docs/bugs_and_glitches.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index a1693a00d..34b04de9b 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -53,6 +53,7 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th - [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution) - [`Special_CheckBugContestContestantFlag` can read beyond its data table](#special_checkbugcontestcontestantflag-can-read-beyond-its-data-table) - [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1) +- [Moves erroneously say they have missed when the opponent uses Protect or Detect](#moves-erroneously-say-they-have-missed-when-the-opponent-uses-protect-or-detect) ## Thick Club and Light Ball can decrease damage done with boosted (Special) Attack @@ -1486,3 +1487,29 @@ ClearWRAM:: ; 25a ``` **Fix:** Change `jr nc, .bank_loop` to `jr c, .bank_loop`. + +## Moves erroneously say they have missed when the opponent uses Protect or Detect + +In [battle/effect_commands.asm](battle/effect_commands.asm): + +```asm +BattleCommand_CheckHit: ; 34d32 +; checkhit + + call .DreamEater + jp z, .Miss + + call .Protect + jp nz, .Miss +``` + +**Fix:** Change `jp nz, .Miss` to `jp nz, .Failed` and add + +```asm +.Failed: + ld a, 1 + ld [wEffectFailed], a + ret +``` + +at [line 1781](battle/effect_commands.asm#L1718). From 51bbfee89192cd93c49e3c400ca8745cc3e77e30 Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Thu, 1 Mar 2018 04:06:46 -0600 Subject: [PATCH 5/9] Reflect Rangi's suggestion --- docs/bugs_and_glitches.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 34b04de9b..ce2715d92 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -293,19 +293,25 @@ This is a bug with `CheckHiddenOpponent` in [engine/battle/effect_commands.asm]( ```asm CheckHiddenOpponent: ; 37daa ; BUG: This routine should account for Lock-On and Mind Reader. -; Uncomment the lines below to fix. - ; ld a, BATTLE_VARS_SUBSTATUS5_OPP - ; call GetBattleVar - ; and 1 << SUBSTATUS_LOCK_ON - ; ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret ``` -**Fix:** Uncomment those 4 lines to fix. +Fix: +```asm +CheckHiddenOpponent: ; 37daa + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVar + and 1 << SUBSTATUS_LOCK_ON + ret z + ld a, BATTLE_VARS_SUBSTATUS3_OPP + call GetBattleVar + and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND + ret +``` ## Beat Up can desynchronize link battles From 158144f9cbebdb076262dc45c05253cb8fbc1acf Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Sat, 2 Jun 2018 01:12:52 -0500 Subject: [PATCH 6/9] undo protect message bug --- docs/bugs_and_glitches.md | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index ce2715d92..efe951263 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -53,7 +53,6 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th - [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution) - [`Special_CheckBugContestContestantFlag` can read beyond its data table](#special_checkbugcontestcontestantflag-can-read-beyond-its-data-table) - [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1) -- [Moves erroneously say they have missed when the opponent uses Protect or Detect](#moves-erroneously-say-they-have-missed-when-the-opponent-uses-protect-or-detect) ## Thick Club and Light Ball can decrease damage done with boosted (Special) Attack @@ -1493,29 +1492,3 @@ ClearWRAM:: ; 25a ``` **Fix:** Change `jr nc, .bank_loop` to `jr c, .bank_loop`. - -## Moves erroneously say they have missed when the opponent uses Protect or Detect - -In [battle/effect_commands.asm](battle/effect_commands.asm): - -```asm -BattleCommand_CheckHit: ; 34d32 -; checkhit - - call .DreamEater - jp z, .Miss - - call .Protect - jp nz, .Miss -``` - -**Fix:** Change `jp nz, .Miss` to `jp nz, .Failed` and add - -```asm -.Failed: - ld a, 1 - ld [wEffectFailed], a - ret -``` - -at [line 1781](battle/effect_commands.asm#L1718). From 57efc4b392598d773e8bfc35cb742cf9d8632c57 Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Mon, 18 Jun 2018 00:32:36 -0500 Subject: [PATCH 7/9] final fix --- docs/bugs_and_glitches.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index efe951263..cd69a08fd 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -305,6 +305,7 @@ CheckHiddenOpponent: ; 37daa ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVar and 1 << SUBSTATUS_LOCK_ON + cp 1 << SUBSTATUS_LOCK_ON ret z ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar From 6e62eabb42cb8c933e77d84768353c5fec47cf3a Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Sat, 21 Jul 2018 03:36:03 -0500 Subject: [PATCH 8/9] final change --- docs/bugs_and_glitches.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index cd69a08fd..4aeb088ef 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -304,6 +304,7 @@ Fix: CheckHiddenOpponent: ; 37daa ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVar + ld a, [hl] and 1 << SUBSTATUS_LOCK_ON cp 1 << SUBSTATUS_LOCK_ON ret z From 8755a88458b912975c537e489e182ca956dcac9b Mon Sep 17 00:00:00 2001 From: i0brendan0 <19826742+i0brendan0@users.noreply.github.com> Date: Sat, 21 Jul 2018 05:05:40 -0500 Subject: [PATCH 9/9] turns out none of the code is needed --- docs/bugs_and_glitches.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 4aeb088ef..7dfd8f421 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -302,18 +302,11 @@ Fix: ```asm CheckHiddenOpponent: ; 37daa - ld a, BATTLE_VARS_SUBSTATUS5_OPP - call GetBattleVar - ld a, [hl] - and 1 << SUBSTATUS_LOCK_ON - cp 1 << SUBSTATUS_LOCK_ON - ret z - ld a, BATTLE_VARS_SUBSTATUS3_OPP - call GetBattleVar - and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret ``` +The code in `CheckHiddenOpponent` is completely redundant as `CheckHit` already does what this code is doing. Another option is to remove `CheckHiddenOpponent` completely, the calls to `CheckHiddenOpponent`, and the jump afterwards. + ## Beat Up can desynchronize link battles *Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*