-
Notifications
You must be signed in to change notification settings - Fork 19
Pokemon index extension branch
This is the first feature branch of the repository, implementing an actual case of 16-bit extension. Pokémon species IDs are extended to 16 bits, updating the various subsystems that depend on the actual indexes to use the conversion table created by this branch.
(NOTE: this documentation page is a work in progress. Items below that don't link anywhere haven't been written yet.)
- Conversion table definition
- Affected subsystems
- Map scripting changes
- Evolutions and learnsets
- Trainer data
- Subsystems using full indexes
- Saving and reloading
- Indirection tables
An unused, suitably-aligned region of WRAM bank 2, starting at address $D200, was reserved for the Pokémon index conversion table, as well as any further conversion tables added by future branches.
The table itself is declared as wPokemonIndexTable
, with a corresponding set of parameter constants
prefixed by MON_TABLE
; the values of those parameters are the following:
Constant | Value |
---|---|
MON_TABLE_ENTRIES |
100 |
MON_TABLE_LOCKED_ENTRIES |
30 |
MON_TABLE_CACHE_SIZE |
16 |
MON_TABLE_SAVED_RECENT_INDEXES |
8 |
MON_TABLE_MINIMUM_RESERVED_INDEX |
$FD |
The parameters defined above make the table fit exactly in $100 bytes with no padding. The minimum reserved ID is set
to $FD so eggs can continue using that value: the EGG
constant is redefined as -3, which will expand as $FD when
used as an 8-bit value and $FFFD when used as a 16-bit value; since $FD is defined as a reserved ID, it will convert
to $FFFD (and vice-versa), making the EGG
constant valid both as an 8-bit ID and a 16-bit index.
The home bank functions needed to access this table are declared as GetPokemonIndexFromID
,
GetPokemonIDFromIndex
, LockPokemonID
and GetLockedPokemonID
. The garbage collector function is also exposed as
PokemonTableGarbageCollection
.
The garbage collector will look for valid IDs in the following locations to consider them as "in use":
- Party and currently-selected PC box
- Opponent trainer's party and linked player's party
- Roaming Pokémon
- Pokémon left in the Day-Care
- Bug-Catching Contest current Pokémon and results
- Various temporary buffers (
wBattleMon
,wEnemyMon
,wTempMon
,wBufferMon
, odd egg data, base stat data)