Jump to content

Expanded party: Difference between revisions

→‎Memory addresses: Added some analysis of the swapping mechanics.
(→‎Memory addresses: Organized the addresses into a table and collapsed it. Also the main data is 44 bytes each, not 45.)
(→‎Memory addresses: Added some analysis of the swapping mechanics.)
Line 545:
*Expanded menu sprite animation entries (see [[Party scrolling memory corruption]])
*Expanded battle participation flags (see [[Participants glitch (Generation I)|Participants glitch]])
 
=== Swapping mechanics ===
Since each party Pokémon has four distinct pieces of data, for party Pokémon beyond number 6, those data regions often overlap, which causes the effect of swapping two Pokémon to be non-obvious. In addition, the data regions for Pokémon main data extrapolates to the stack region as well as the [[Echo RAM]] region, which may also cause complicated behaviors. Discounting possible stack corruption issues, the procedure for swapping two different party Pokémon works as follows<ref>[https://github.com/pret/pokered/blob/1dcaede8b5e41dbec9bf3f2b18c77d1b7d2de708/engine/menus/start_sub_menus.asm#L694 The function to swap two party Pokémon]</ref>:
* Swap their species bytes 1 using the HRAM byte <code>hSwapTemp</code> as the buffer.
* Swap their main data using the buffer <code>wSwitchPartyMonTempBuffer</code> ($CC97 for R/B).
* Swap their Trainer names using the buffer <code>wSwitchPartyMonTempBuffer</code>.
* Swap their nicknames using the buffer <code>wSwitchPartyMonTempBuffer</code>.
The details of each individual swap operation should only matter in rare cases, such as when the main data regions of the two Pokémon overlap or when one of them overlaps with the buffer (both thanks to the Echo RAM). Denoting the Pokémon selected first as Pokémon A and the one selected second as Pokémon B, each individual swap operation works as follows:
* Copy the data for Pokémon B to the buffer.
* Copy the data for Pokémon A to the data for Pokémon B.
* Copy the buffer to the data for Pokémon A.
 
==In {{GSC}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.