Jump to content

Expanded party: Difference between revisions

m
Consistent use of uppercase hex
m (Fixed formatting in table in Memory Corruption Pattern section)
m (Consistent use of uppercase hex)
 
Line 588:
The memory corruption caused by healing with an expanded party is sparse, but can affect a large diversity of memory locations, depending on how soon the 0xFF terminator byte is found.
 
For each non-0xFF byte found in the party Pokémon species list, the party healing routine traverses the party Pokémon records beginning at 0xD16B (for {{RB}}), 0xD16A (for {{Y}}), 0xD12B (for {{RG}}). Each record is 44 (0x2c0x2C) bytes long and the following offsets in each record are manipulated as such:
{| class="wikitable"
|+
Line 605:
|Overwritten with the value 0
|-
|'''0x1c0x1C, 0x1d0x1D, 0x1e0x1E, 0x1f0x1F'''
|PP for moves
(<code>wPartyMon#PP</code>)
|Lower 6 bits are overwritten with max PP value determined from move ID read from offsets '''0x08''', '''0x09''', '''0x0a0x0A''', '''0x0b0x0B''' respectively, plus bonus PP calculated from PP Up count determined from upper 2 bits of the preexisting value (which are kept the same)
'''NOTE:''' If one of the move IDs read is 0, nothing is overwritten for the current offset and the later offsets are skipped, since the game assumes the move list to be terminated.
|}
To calculate the addresses manipulated when healing a certain party slot, multiply the zero-based index of the slot by the size of the Pokémon record (0x2c0x2C bytes), add that to the party starting address depending on the game version as mentioned before, and add the offsets mentioned above to get the effective addresses accessed when that particular party index is healed.
 
Since the healing routine uses 16-bit pointers to traverse the memory and only looks for a 0xFF terminator byte to stop execution, it can potentially corrupt memory past the end of the expanded party region (that is, beyond the 256th party Pokémon record) and reach I/O registers and [[HRAM]]. This has been confirmed with an oversized expanded party obtained via memory hacking and using a debugger. <!-- I tested it myself. The game crashed at some point though, just barely touched the beginning of HRAM, but it did get there. Might have been the VBlank interrupt triggering and getting messed up, I was using breakpoints on every loop iteration of the HealParty routine. ~~~~Kagamiin~ -->
20

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.