PKM File Fields
PKM files have been ripped from saved and traded online for roughly the last 5 years or so by players. Pulling them out of games is very easy and makes trading or giving out pokemon to friends a simple task. When GameFreak needs to get or set specific data for a pokemon, they do it using a switch statement and a series of fields. They do it like so:
typedef enum{
PID,
field2,
field3,
field4,
checksum,
species,
item,
tidsid,
exp,
happiness,
-and so forth-
} PKMField;
When they need to write data to the pkm file, they use this function:
void setPKMStat(void* pPKM, PKMField field, int data)
and when they need to retrieve data from a PKM file, they use this:
PKMField getPKMStat(void* pPKM, PKMField field, int data) (data is basically always 0 in the "get" function)
The switch statements for these functions are large. In gen 3 they used 2 switches, one for party data and one for box data. In gens 4 and 5 they switched to a single massive switch that can retrieve anything. In B2W2 a PKM file has 179 fields. In BW PKM files had 175 fields.
The following is a partial list of field values for these functions: (all are in hexadecimal)
0- pid 1- unused short 2- unused short 3- unused short 4- checksum 5- species 6- item 7- tidsid 8- exp 9- happiness a- abil b- markings c- region d- hp ev e- atk ev f- def ev 10- spa ev 11- spd ev 12- spe ev 13- cool contest 14- beauty contest 15- cute contest 16- smart contest 17- tough contest 18- sheen contest 19- Sinnoh Champ Ribbon 1A- Ability Ribbon 1B- Great Ability Ribbon 1C- Double Ability Ribbon 1D- Multi Ability Ribbon 1E- Pair Ability Ribbon 1F- World Ability Ribbon 20- Alert Ribbon 21- Shock Ribbon 22- Downcast Ribbon 23- Careless Ribbon 24- Relax Ribbon 25- Snooze Ribbon 26- Smile Ribbon 27- Gorgeous Ribbon 28- Royal Ribbon 29- Gorgeous Royal Ribbon 2a- Footprint Ribbon 2b- Record Ribbon 2c- History Ribbon 2d- Legend Ribbon 2e- Red Ribbon 2f- Green Ribbon 30- Blue Ribbon 31- Festival Ribbon 32- Carnival Ribbon 33- Classic Ribbon 34- Premier Ribbon 35- 36- move1 37- move2 38- move3 39- move4 3a- move1 pp 3b- move2 pp 3c- move3 pp 3d- move4 pp 3e- move1 pp up 3f- move2 pp up 40- move3 pp up 41- move4 pp up 46- hp iv 47- atk iv 48- def iv 49- spa iv 4a- spd iv 4b- spe iv 4c- is_egg 4d- hoenn ribbon set 1 4e- hoenn ribbon set 2 4f- fateful encounter 6e- gender(0 male, 1 female) 6f- form 70- nature 71- has dw abil 97- pokerus 98- poke ball