I messed around with the turn count glitches a bit because it's a lot easier when you can set the turn count to whatever you want.
DaWoblefet had already identified the methods for fetching turn count in BDSP and I found the analogous methods in SV, so we spent a couple of evenings working this out. That said, I'll explain how each of these mechanics is broken.
Turn Counter
The turn counter is actually capped at 9999. This isn't an issue of the turn counter being capped at 255.
View attachment 691213
Wish
When you use Wish, it stores the turn that it was used, cast to an unsigned byte. Then on subsequent turns, it checks if that turn count cast to an unsigned byte is greater than the stored Wish turn value. If so, then Wish goes off.
- Example #1: You use Wish on turn 7. On turn 8, it checks if 7 < 8 and if so, Wish will activate. This is how you get Wish activating next turn.
- Example #2: You use Wish on turn 9999. Since turn count will never advance past this, Wish will never activate. It will repeatedly check if 15 < 15.
- Example #3: You use Wish on turn 255. However, 256 cast to an unsigned byte will be 0. On turn 256, the game checks if 255 < 0 which isn't satisfied. In fact, turn count can only ever be 0-255, so Wish will never go off again, nor can you use it again once you break it this way.
Future Sight
When you use Future Sight, the game stores the expected turn that it should activate. This value is an integer, which is fine. However, when it fetches the current turn count, this is again an unsigned byte. Future Sight activates if the expected turn is less than or equal to the current turn count, cast to an unsigned byte.
- Example #1: You use Future Sight on turn 7. This stores turn 9 as the turn to activate. On turn 8, it checks if 9 <= 8, and doesn't activate. On turn 9, it checks if 9 <= 9, and does activate.
- Example #2: You use Future Sight on turn 255. This stores turn 257 as the turn to activate. On turn 256, it checks if 257 <= 0 and doesn't activate. On turn 257, it checks if 257 <= 1 and doesn't activate. Since turn count will always return a number from 0-255, Future Sight will break if used on turn 254 or higher, since the expected activation turn is 256 or higher, which can't be reached.
Echoed Voice
This one is pretty complicated so bear with me.
The game stores a list of 400 move records in a battle. Here's an example of the start of the records block. The first row is a header with an address, then the number of entries (0x37).
Each row after that is a record storing: turn count (at 0x00), the Pokemon that used the move (at 0x04), the move used (at 0x08), and whether it was successful (at 0x0A).
View attachment 691215
Using a move adds an entry. Missing a turn or using an item doesn't add any entry. When all 400 entries are filled, the game starts overwriting the first entries starting at 0xC and starts counting number of entries from 1. It looks like it only checks the first entries counted by this value in the header.
Echoed Voice works by checking backwards for consecutive Echoed Voice uses by the same Pokemon until it no longer finds one. So for example, if you use Echoed Voice on turns 2, 3, 4, 5, then use it again on turn 6, it will check the records block for this Pokemon using it on turn 5, then turn 4, then turn 3, then turn 2, then fail to find one on turn 1, and calculate for 5 consecutive Echoed Voice uses.
The problem with Echoed Voice is that again, when it fetches turn count, this is cast to an unsigned byte. Turn 256 = turn 0, turn 257 = turn 1, turn 258 = turn 2, etc. On turn 258, the game thinks that you are actually on turn 2 and checks the record block for Echoed Voice used on turn 1 instead!
There are some implications of this:
- If you haven't overwritten any turn counts under 256, then the base power of Echoed Voice depends on what you did within the first 0-255 turns. The corresponding turn is the current turn cast to an unsigned byte. For this reason, I can't explain what the Japanese user observed, because I don't know what happened for the first 255 turns, what moves were recorded, and how much was overwritten.
- If you overwrite any moves and you are past turn 255, then Echoed Voice won't be able to find another turn to consider consecutive, and BP will be 40.
- If you get to 400 total moves used but less than turn 255, this will also start overwriting and resets the total entry count to 1. Since everything at the end of the block will then be ignored, Echoed Voice won't see the previous consecutive uses.
Fusion Flare/Fusion Bolt
These moves check the above record block to see if the last move used on the same turn was the other fusion move. Again, turn count is cast to an unsigned byte. For this reason, you can do a cool party trick where you chain Fusion Flare with Fusion Bolt in a singles battle.
- Make sure you are the last Pokémon to use either Fusion Bolt or Fusion Flare on the first turn (turn 0).
- Make sure you do not use more than 400 moves to overwrite the first turn's moves.
- On turn 256, make sure you are the first Pokemon to use the Fusion move that was not used on turn 0. This will chain with the move you used at the start of the battle for 200 BP instead of 100 BP.
No, these work fine. They don't check the turn count the same way as the other moves.
----
I did not test Round, which also uses this mechanic. I'll try to answer any questions if my explanation is unclear.
I did not check how far back these glitches exist, but I would guess they affect at least gen 8, possibly even more before that.
Here is a gist showing the pseudocode and disassembly for the above functions.
If there are more questions, we can gather up a bunch and answer them as pertinent.