Advertisement
luckytyphlosion

YNSC TAS Party Swaps writeup.

Oct 25th, 2018
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. The party swaps have a bit of a wacky story to them. Party swaps are one of the best tools in terms of the amount of bytes manipulated, but the way party swaps work are not understandable intuitively. Here is a description of the memory swapped, from MrWint's Save Corruption TAS:
  2.  
  3. The species is swapped (1 byte): $d164 + A <-> $d164 + B
  4. The Pokémon data is swapped (44 bytes): $d16b + 44*A <-> $d16b + 44*B
  5. The Pokémon OT name is swapped (11 bytes): $d273 + 11* A <-> $d273 + 11*B
  6. The Pokémon nickname is swapped (11 bytes): $d2b5 + 11*A <-> $d2b5 + 11*B
  7.  
  8. Back when I routed the party swaps, I did so through trial and error, observing memory, and with a bit of intuition. Only now when I tried to understand how these party swaps worked, I realized numerous improvements. Unfortuately, due to the timing of the GDQx event not allowing time to redo the TAS, my lack of motivation to understand party swaps which made me not realize how these swaps were inoptimal, and a recent 30 second strat improvement anyway which defeats the purpose of redoing the TAS with the improved swaps, the swaps will stay inoptimal. The following is merely an explanation of the swaps, and do not imply any sort of optimal behaviour. Note that slots are zero-indexed here, but references to Party Pokemon (e.g. Party Mon 1 nickname) are one-indexed.
  9.  
  10. - Swap slot 0 and 1, then slot 1 and slot 9. These swaps are necessary to place Party Mon 1 nickname into memory which will be swapped later. This might be able to be merged into a single swap (slot 0 with slot 9)
  11. - Swap slot 9 and 10, then slot 15 and 16. These swaps do the following:
  12. - Slot 9 & 10's Data: Swaps Rival Name with the beginning of Item Memory. This also has an effect of swapping the memory where Party Mon 1 nickname was placed in the previous swaps into Rival Name, which provides a save memory location for Party Mon 1 nickname to reside for a later swap where it is swapped into Caught Flags.
  13. - Slot 9 & 10's Nickname: Swaps the beginning of Item Memory into a later portion of Item Memory. This is undesirable because it requires scrolling later into memory to the items that represent the Rival Name, but may actually be necessary because the next swap does the reverse of this, and also does another crucial aspect of the setup to execute the Hall of Fame script, and may be the best way to achieve the behaviour wanted.
  14. - Slot 15 & 16's OT: Swaps the beginning of Item Memory into a later portion of Item Memory, therefore reverting the above swap.
  15. - Slot 15 & 16's Nickname: Swaps some map data with other map data. The important behaviour here is that it swaps a map ID which corresponds to the same map bank as the Hall of Fame, which is necessary to have the Hall of Fame script run.
  16. - Close the Party Menu and open the Item Menu.
  17. - Merge the first TM41 with the second TM41 to create TM41 x99. The newly created TM41 x99 stack corresponds to the pointer $63f1, which points to safe memory before the Hall of Fame script.
  18. - Swap the 2nd TM41 (TM41 x99) with the item below CANCEL (todo list position), to align it correctly with the memory location of the script pointer.
  19. - Swap slot 16 and 23, then slot 23 and 22. This places the TM41 x99 above into the map script pointer. Swapping 16 and 22 would not work as illustrated by the following diagram:
  20. If we swap slot 16 with slot 22.
  21. TM41 x99 <-> Script Pointer (OT)
  22. Script Pointer <-> Other Map Data B ($d3b2-$d3bc) (nickname)
  23.  
  24. But if we swap slot 16 with 23, then 23 with 22.
  25. TM41 x99 <-> Other Map Data A ($d370-$d37a) (OT)
  26. Script Pointer <-> Other Map Data B ($d3b2-$d3bc) (nickname)
  27.  
  28. Other Map Data A ($d370-$d37a) <-> Script Pointer (OT)
  29. Other Map Data B ($d3b2-$d3bc) <-> Other Map Data C ($d3a7-$d3b1) (nickname)
  30.  
  31. Note that slot 21 as the intermediate swap would not work since it overlaps with other crucial map data, but slot 20 might.
  32. - Swap slot 19 and 12. This swaps Party Mon 1 nickname stored in rival name from the above swaps into Pokedex Flags. The nickname is specifically crafted to give a caught amount of Pokemon of 60-69, which gives a Pokedex rating that does not require an input to advance through, allowing input to be ended earlier.
  33. - Exit the Party Menu and Start Menu. The opening walk in the Hall of Fame script is executed, however OAK's Hall of Fame text prints an error (Error 1) because the Party Swaps had also loaded an invalid Map Text pointer which prints an error message that is faster than the normal Hall of Fame text.
  34. - The Hall of Fame script executes. Input has already ended after clearing the Error 1 text, and the earlier Pokedex Caught Flag manipulation prints an inputless Pokedex rating.
  35.  
  36. == Some Extra Stuff ==
  37. Why can't we swap slot 6 with slot 0 (or slot 12 with slot 6) to place the nickname into Dex Flags? Why do the weird swap trickery?
  38.  
  39. Slot 6 with 0 has the following issue:
  40. OT1-OT4 (inclusive) <-> PartyMon1 (data)
  41. Nick1 <-> OT1 (OT)
  42. CaughtFlags ($d2f7-$d301) <-> Nick1 (nickname)
  43.  
  44. So what actually happens is we swap the first 11 bytes of PartyMon1 into CaughtFlags.
  45.  
  46. But Nicknames and OT overlap, so we can just swap slot 12 and slot 6, right? Unfortunately no.
  47. CaughtFlags ($d2f7-$d301) <-> Nick1 (OT)
  48. ItemData ($d339-$d343) <-> CaughtFlags ($d2f7-$d301) (nickname)
  49.  
  50. So what actually happens is we swap a portion of ItemData into CaughtFlags.
  51.  
  52. This is the big reason why party swaps are hard to deal with, due to the overlap of swaps.
  53.  
  54. Optimal swaps would consist of naming the player with the preset YELLOW (or some other manipulated name) and the following (note that these have not been tested):
  55. 9 <-> 10
  56. 15 <-> 16
  57. Item swaps.
  58. 16 <-> 20
  59. 20 <-> 22
  60. 12 <-> 6 (this might be able to be moved earlier)
  61.  
  62. Note that these improvements are all irrelevant anyway due to a recent 30 second strat improvement which does an entirely different set of swaps, as well as some other modifications to the route.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement