#ifndef POKEMON_DATA_H #define POKEMON_DATA_H #pragma once /* The struct is laid out exactly as the data trasfer that gets sent for trade * information. It has to be packed in order to not have padding in the Flipper. * Packing is always potentially filled with pitfalls, however this has worked * in testing without issue and this code isn't meant to be portable. */ /* NOTE: These are all opposite endianness on the flipper than they are in the * GB/Z80. e.g. a uint16_t value of 0x2c01 translates to 0x012c. * Need to use __builtin_bswap16(val) to switch between Flipper and Pokemon. */ struct __attribute__((__packed__)) pokemon_structure { uint8_t index; uint16_t hp; // Calculated from level /* Level is normally calculated from exp, however, level is more human * readable/digestable compared to exp. Therefore, we set legel and then * from that calculate, (Max)HP, ATK, DEF, SPD, SPC. */ uint8_t level; uint8_t status_condition; // Do you really want to trade a Poisoned pokemon? uint8_t type[2]; // Pokemon with a single type just repeat the type twice uint8_t catch_held; // Unsure if this has any effect in Gen 1 uint8_t move[4]; uint16_t ot_id; uint8_t exp[3]; // Calculated from level uint16_t hp_ev; uint16_t atk_ev; uint16_t def_ev; uint16_t spd_ev; uint16_t special_ev; uint16_t iv; uint8_t move_pp[4]; uint8_t level_again; // Copy of level uint16_t max_hp; // Calculated from level uint16_t atk; // Calculated from level uint16_t def; // Calculated from level uint16_t spd; // Calculated from level uint16_t special; // Calculated from level }; struct __attribute__((__packed__)) name { /* Reused a few times, but in Gen I, all name strings are 11 bytes in memory. * At most, 10 symbols and a TERM_ byte. * Note that some strings must be shorter than 11. */ unsigned char str[11]; }; struct __attribute__((__packed__)) trade_data_block { unsigned char trainer_name[11]; uint8_t party_cnt; /* Only the first pokemon is ever used even though there are 7 bytes here. * If the remaining 6 bytes are _not_ 0xff, then the trade window renders * garbage for the Flipper's party. */ uint8_t party_members[7]; /* Only the first pokemon is set up, even though there are 6 total party members */ struct pokemon_structure party[6]; /* Only the first pokemon has an OT name and nickname even though there are 6 members */ /* OT name should not exceed 7 chars! */ struct name ot_name[6]; struct name nickname[6]; }; typedef struct trade_data_block TradeBlock; #endif /* POKEMON_DATA_H */