-
Notifications
You must be signed in to change notification settings - Fork 20
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
- Battle Tower
- Pokédex
- 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)
The following subsystems in the game were updated to use 16-bit indexes correctly:
- Base data: adapted the helper function
GetBaseData
to do an ID-to-index conversion and fixed other references to that data, and removed the species ID from the base data (it is now computed through an index-to-ID conversion). - Battle functions:
-
BattleCommand_Critical
,DittoMetalPowder
,LightBallBoost
andThickClubBoost
use 16-bit indexes for their checks. -
LoadEnemyMon
checks for Unown's and Magikarp's 16-bit indexes now.
-
- Battle Tower trainer data and party validation
- Breeding: adapted to use 16-bit indexes all throughout, including when checking for a Ditto, a Togepi or a Nidoran.
- Bug-Catching Contest: all tables and functions were updated to load and use 16-bit indexes.
- Evolutions, learnsets and egg moves
- In-game trades: redesigned the data to contain a 16-bit index for the wanted and given Pokémon, and adapted the corresponding functions.
- Intro sequence: updated to use Wooper's 16-bit index.
- Leftover mobile code: fixed for completeness.
- Miscellaneous functions:
-
IsAPokemon
will now check whether the ID is a valid table ID (or an egg). -
MoonBallMultiplier
will properly parse 16-bit species indexes in evolution data. (Also, it now works as expected, instead of looking for a non-existent evolutionary item.) -
Unreferenced_CorrectPartyErrors
will correctly handle table IDs and correct invalid ones.
-
- Odd Egg generation: the species is now generated from a 16-bit species index table.
- Overworld:
- Berry Juice generation will properly check for Shuckle's 16-bit index.
- Pokémon sprites were adapted the data and functions to index into a 16-bit table.
- Surf icon now properly checks for Pikachu's 16-bit index.
- Player room's decorations: adapted the data table to contain 16-bit species indexes for decorations based on Pokémon sprites (by adding a lookup table) and updated the corresponding functions to read from that table.
- Pokémon cries, dex entries and footprints
- Pokémon move screen: updated to check for a valid table ID (instead of an ID no greater than
NUM_POKEMON
) when checking for a previous or a next Pokémon in order to display scroll arrows. - Pokémon names, pics and palettes: adapted the loader functions to do an ID-to-index conversion.
- Map scripts and events
- Time Capsule: adapted to use 16-bit species indexes in checks, including specific checks for Magnemite and Magneton (whose types changed between generations 1 and 2).
- Trainer data
- Unown's special handling: checks for Unown when displaying or printing a Pokémon's picture, when catching a Pokémon, when evolving a Pokémon and when a Pokémon is sent out to battle adapted to check for Unown's 16-bit index.
- Wild Pokémon: updated all wild Pokémon tables to contain 16-bit indexes and fixed the functions that load wild data to load those indexes correctly (including performing index-to-ID conversions).
TODO
TODO
TODO
TODO
TODO