#include #include #include #include "scenes/pokemon_menu.h" #include "views/trade.h" #include "views/select_pokemon.h" #include "pokemon_app.h" #include "pokemon_char_encode.h" const PokemonTable pokemon_table[] = { /* Values for base_*, moves, etc., pulled directly from a copy of Pokemon Blue */ {"Bulbasaur", &I_bulbasaur, 0x99, 0x2D, 0x31, 0x31, 0x2D, 0x41, {0x16, 0x03}, {0x21, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Ivysaur", &I_ivysaur, 0x09, 0x3C, 0x3E, 0x3F, 0x3C, 0x50, {0x16, 0x03}, {0x21, 0x2D, 0x49, 0x00}, GROWTH_MEDIUM_SLOW}, {"Venusaur", &I_venusaur, 0x9A, 0x50, 0x52, 0x53, 0x50, 0x64, {0x16, 0x03}, {0x21, 0x2D, 0x49, 0x16}, GROWTH_MEDIUM_SLOW}, {"Charmander", &I_charmander, 0xB0, 0x27, 0x34, 0x2B, 0x41, 0x32, {0x14, 0x14}, {0x0A, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Charmeleon", &I_charmeleon, 0xB2, 0x3A, 0x40, 0x3A, 0x50, 0x41, {0x14, 0x14}, {0x0A, 0x2D, 0x34, 0x00}, GROWTH_MEDIUM_SLOW}, {"Charizard", &I_charizard, 0xB4, 0x4E, 0x54, 0x4E, 0x64, 0x55, {0x14, 0x02}, {0x0A, 0x2D, 0x34, 0x2B}, GROWTH_MEDIUM_SLOW}, {"Squirtle", &I_squirtle, 0xB1, 0x2C, 0x30, 0x41, 0x2B, 0x32, {0x15, 0x15}, {0x21, 0x27, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Wartortle", &I_wartortle, 0xB3, 0x3B, 0x3F, 0x50, 0x3A, 0x41, {0x15, 0x15}, {0x21, 0x27, 0x91, 0x00}, GROWTH_MEDIUM_SLOW}, {"Blastoise", &I_blastoise, 0x1C, 0x4F, 0x53, 0x64, 0x4E, 0x55, {0x15, 0x15}, {0x21, 0x27, 0x91, 0x37}, GROWTH_MEDIUM_SLOW}, {"Caterpie", &I_caterpie, 0x7B, 0x2D, 0x1E, 0x23, 0x2D, 0x14, {0x07, 0x07}, {0x21, 0x51, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Metapod", &I_metapod, 0x7C, 0x32, 0x14, 0x37, 0x1E, 0x19, {0x07, 0x07}, {0x6A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Butterfree", &I_butterfree, 0x7D, 0x3C, 0x2D, 0x32, 0x46, 0x50, {0x07, 0x02}, {0x5D, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Weedle", &I_weedle, 0x70, 0x28, 0x23, 0x1E, 0x32, 0x14, {0x07, 0x03}, {0x28, 0x51, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Kakuna", &I_kakuna, 0x71, 0x2D, 0x19, 0x32, 0x23, 0x19, {0x07, 0x03}, {0x6A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Beedrill", &I_beedrill, 0x72, 0x41, 0x50, 0x28, 0x4B, 0x2D, {0x07, 0x03}, {0x1F, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Pidgey", &I_pidgey, 0x24, 0x28, 0x2D, 0x28, 0x38, 0x23, {0x00, 0x02}, {0x10, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Pidgeotto", &I_pidgeotto, 0x96, 0x3F, 0x3C, 0x37, 0x47, 0x32, {0x00, 0x02}, {0x10, 0x1C, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Pidgeot", &I_pidgeot, 0x97, 0x53, 0x50, 0x4B, 0x5B, 0x46, {0x00, 0x02}, {0x10, 0x1C, 0x62, 0x00}, GROWTH_MEDIUM_SLOW}, {"Rattata", &I_rattata, 0xA5, 0x1E, 0x38, 0x23, 0x48, 0x19, {0x00, 0x00}, {0x21, 0x27, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Raticate", &I_raticate, 0xA6, 0x37, 0x51, 0x3C, 0x61, 0x32, {0x00, 0x00}, {0x21, 0x27, 0x62, 0x00}, GROWTH_MEDIUM_FAST}, {"Spearow", &I_spearow, 0x05, 0x28, 0x3C, 0x1E, 0x46, 0x1F, {0x00, 0x02}, {0x40, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Fearow", &I_fearow, 0x23, 0x41, 0x5A, 0x41, 0x64, 0x3D, {0x00, 0x02}, {0x40, 0x2D, 0x2B, 0x00}, GROWTH_MEDIUM_FAST}, {"Ekans", &I_ekans, 0x6C, 0x23, 0x3C, 0x2C, 0x37, 0x28, {0x03, 0x03}, {0x23, 0x2B, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Arbok", &I_arbok, 0x2D, 0x3C, 0x55, 0x45, 0x50, 0x41, {0x03, 0x03}, {0x23, 0x2B, 0x28, 0x00}, GROWTH_MEDIUM_FAST}, {"Pikachu", &I_pikachu, 0x54, 0x23, 0x37, 0x1E, 0x5A, 0x32, {0x17, 0x17}, {0x54, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Raichu", &I_raichu, 0x55, 0x3C, 0x5A, 0x37, 0x64, 0x5A, {0x17, 0x17}, {0x54, 0x2D, 0x56, 0x00}, GROWTH_MEDIUM_FAST}, {"Sandshrew", &I_sandshrew, 0x60, 0x32, 0x4B, 0x55, 0x28, 0x1E, {0x04, 0x04}, {0x0A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Sandslash", &I_sandslash, 0x61, 0x4B, 0x64, 0x6E, 0x41, 0x37, {0x04, 0x04}, {0x0A, 0x1C, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Nidoran\200", &I_nidoranf, 0x0F, 0x37, 0x2F, 0x34, 0x29, 0x28, {0x03, 0x03}, {0x2D, 0x21, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Nidorina", &I_nidorina, 0xA8, 0x46, 0x3E, 0x43, 0x38, 0x37, {0x03, 0x03}, {0x2D, 0x21, 0x0A, 0x00}, GROWTH_MEDIUM_SLOW}, {"Nidoqueen", &I_nidoqueen, 0x10, 0x5A, 0x52, 0x57, 0x4C, 0x4B, {0x03, 0x04}, {0x21, 0x0A, 0x27, 0x22}, GROWTH_MEDIUM_SLOW}, {"Nidoran\201", &I_nidoranm, 0x03, 0x2E, 0x39, 0x28, 0x32, 0x28, {0x03, 0x03}, {0x2B, 0x21, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Nidorino", &I_nidorino, 0xA7, 0x3D, 0x48, 0x39, 0x41, 0x37, {0x03, 0x03}, {0x2B, 0x21, 0x1E, 0x00}, GROWTH_MEDIUM_SLOW}, {"Nidoking", &I_nidoking, 0x07, 0x51, 0x5C, 0x4D, 0x55, 0x4B, {0x03, 0x04}, {0x21, 0x1E, 0x28, 0x25}, GROWTH_MEDIUM_SLOW}, {"Clefairy", &I_clefairy, 0x04, 0x46, 0x2D, 0x30, 0x23, 0x3C, {0x00, 0x00}, {0x01, 0x2D, 0x00, 0x00}, GROWTH_FAST}, {"Clefable", &I_clefable, 0x8E, 0x5F, 0x46, 0x49, 0x3C, 0x55, {0x00, 0x00}, {0x2F, 0x03, 0x6B, 0x76}, GROWTH_FAST}, {"Vulpix", &I_vulpix, 0x52, 0x26, 0x29, 0x28, 0x41, 0x41, {0x14, 0x14}, {0x34, 0x27, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Ninetales", &I_ninetales, 0x53, 0x49, 0x4C, 0x4B, 0x64, 0x64, {0x14, 0x14}, {0x34, 0x27, 0x62, 0x2E}, GROWTH_MEDIUM_FAST}, {"Jigglypuff", &I_jigglypuff, 0x64, 0x73, 0x2D, 0x14, 0x14, 0x19, {0x00, 0x00}, {0x2F, 0x00, 0x00, 0x00}, GROWTH_FAST}, {"Wigglytuff", &I_wigglytuff, 0x65, 0x8C, 0x46, 0x2D, 0x2D, 0x32, {0x00, 0x00}, {0x2F, 0x32, 0x6F, 0x03}, GROWTH_FAST}, {"Zubat", &I_zubat, 0x6B, 0x28, 0x2D, 0x23, 0x37, 0x28, {0x03, 0x02}, {0x8D, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Golbat", &I_golbat, 0x82, 0x4B, 0x50, 0x46, 0x5A, 0x4B, {0x03, 0x02}, {0x8D, 0x67, 0x2C, 0x00}, GROWTH_MEDIUM_FAST}, {"Oddish", &I_oddish, 0xB9, 0x2D, 0x32, 0x37, 0x1E, 0x4B, {0x16, 0x03}, {0x47, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Gloom", &I_gloom, 0xBA, 0x3C, 0x41, 0x46, 0x28, 0x55, {0x16, 0x03}, {0x47, 0x4D, 0x4E, 0x00}, GROWTH_MEDIUM_SLOW}, {"Vileplume", &I_vileplume, 0xBB, 0x4B, 0x50, 0x55, 0x32, 0x64, {0x16, 0x03}, {0x4E, 0x4F, 0x33, 0x50}, GROWTH_MEDIUM_SLOW}, {"Paras", &I_paras, 0x6D, 0x23, 0x46, 0x37, 0x19, 0x37, {0x07, 0x16}, {0x0A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Parasect", &I_parasect, 0x2E, 0x3C, 0x5F, 0x50, 0x1E, 0x50, {0x07, 0x16}, {0x0A, 0x4E, 0x8D, 0x00}, GROWTH_MEDIUM_FAST}, {"Venonat", &I_venonat, 0x41, 0x3C, 0x37, 0x32, 0x2D, 0x28, {0x07, 0x03}, {0x21, 0x32, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Venomoth", &I_venomoth, 0x77, 0x46, 0x41, 0x3C, 0x5A, 0x5A, {0x07, 0x03}, {0x21, 0x32, 0x4D, 0x8D}, GROWTH_MEDIUM_FAST}, {"Diglett", &I_diglett, 0x3B, 0x0A, 0x37, 0x19, 0x5F, 0x2D, {0x04, 0x04}, {0x0A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Dugtrio", &I_dugtrio, 0x76, 0x23, 0x50, 0x32, 0x78, 0x46, {0x04, 0x04}, {0x0A, 0x2D, 0x5B, 0x00}, GROWTH_MEDIUM_FAST}, {"Meowth", &I_meowth, 0x4D, 0x28, 0x2D, 0x23, 0x5A, 0x28, {0x00, 0x00}, {0x0A, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Persian", &I_persian, 0x90, 0x41, 0x46, 0x3C, 0x73, 0x41, {0x00, 0x00}, {0x0A, 0x2D, 0x2C, 0x67}, GROWTH_MEDIUM_FAST}, {"Psyduck", &I_psyduck, 0x2F, 0x32, 0x34, 0x30, 0x37, 0x32, {0x15, 0x15}, {0x0A, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Golduck", &I_golduck, 0x80, 0x50, 0x52, 0x4E, 0x55, 0x50, {0x15, 0x15}, {0x0A, 0x27, 0x32, 0x00}, GROWTH_MEDIUM_FAST}, {"Mankey", &I_mankey, 0x39, 0x28, 0x50, 0x23, 0x46, 0x23, {0x01, 0x01}, {0x0A, 0x2B, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Primeape", &I_primeape, 0x75, 0x41, 0x69, 0x3C, 0x5F, 0x3C, {0x01, 0x01}, {0x0A, 0x2B, 0x02, 0x9A}, GROWTH_MEDIUM_FAST}, {"Growlithe", &I_growlithe, 0x21, 0x37, 0x46, 0x2D, 0x3C, 0x32, {0x14, 0x14}, {0x2C, 0x2E, 0x00, 0x00}, GROWTH_SLOW}, {"Arcanine", &I_arcanine, 0x14, 0x5A, 0x6E, 0x50, 0x5F, 0x50, {0x14, 0x14}, {0x2E, 0x34, 0x2B, 0x24}, GROWTH_SLOW}, {"Poliwag", &I_poliwag, 0x47, 0x28, 0x32, 0x28, 0x5A, 0x28, {0x15, 0x15}, {0x91, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Poliwhirl", &I_poliwhirl, 0x6E, 0x41, 0x41, 0x41, 0x5A, 0x32, {0x15, 0x15}, {0x91, 0x5F, 0x37, 0x00}, GROWTH_MEDIUM_SLOW}, {"Poliwrath", &I_poliwrath, 0x6F, 0x5A, 0x55, 0x5F, 0x46, 0x46, {0x15, 0x01}, {0x5F, 0x37, 0x03, 0x22}, GROWTH_MEDIUM_SLOW}, {"Abra", &I_abra, 0x94, 0x19, 0x14, 0x0F, 0x5A, 0x69, {0x18, 0x18}, {0x64, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Kadabra", &I_kadabra, 0x26, 0x28, 0x23, 0x1E, 0x69, 0x78, {0x18, 0x18}, {0x64, 0x5D, 0x32, 0x00}, GROWTH_MEDIUM_SLOW}, {"Alakazam", &I_alakazam, 0x95, 0x37, 0x32, 0x2D, 0x78, 0x87, {0x18, 0x18}, {0x64, 0x5D, 0x32, 0x00}, GROWTH_MEDIUM_SLOW}, {"Machop", &I_machop, 0x6A, 0x46, 0x50, 0x32, 0x23, 0x23, {0x01, 0x01}, {0x02, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Machoke", &I_machoke, 0x29, 0x50, 0x64, 0x46, 0x2D, 0x32, {0x01, 0x01}, {0x02, 0x43, 0x2B, 0x00}, GROWTH_MEDIUM_SLOW}, {"Machamp", &I_machamp, 0x7E, 0x5A, 0x82, 0x50, 0x37, 0x41, {0x01, 0x01}, {0x02, 0x43, 0x2B, 0x00}, GROWTH_MEDIUM_SLOW}, {"Bellsprout", &I_bellsprout, 0xBC, 0x32, 0x4B, 0x23, 0x28, 0x46, {0x16, 0x03}, {0x16, 0x4A, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Weepinbell", &I_weepinbell, 0xBD, 0x41, 0x5A, 0x32, 0x37, 0x55, {0x16, 0x03}, {0x16, 0x4A, 0x23, 0x00}, GROWTH_MEDIUM_SLOW}, {"Victreebel", &I_victreebel, 0xBE, 0x50, 0x69, 0x41, 0x46, 0x64, {0x16, 0x03}, {0x4F, 0x4E, 0x33, 0x4B}, GROWTH_MEDIUM_SLOW}, {"Tentacool", &I_tentacool, 0x18, 0x28, 0x28, 0x23, 0x46, 0x64, {0x15, 0x03}, {0x33, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Tentacruel", &I_tentacruel, 0x9B, 0x50, 0x46, 0x41, 0x64, 0x78, {0x15, 0x03}, {0x33, 0x30, 0x23, 0x00}, GROWTH_SLOW}, {"Geodude", &I_geodude, 0xA9, 0x28, 0x50, 0x64, 0x14, 0x1E, {0x05, 0x04}, {0x21, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Graveler", &I_graveler, 0x27, 0x37, 0x5F, 0x73, 0x23, 0x2D, {0x05, 0x04}, {0x21, 0x6F, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Golem", &I_golem, 0x31, 0x50, 0x6E, 0x82, 0x2D, 0x37, {0x05, 0x04}, {0x21, 0x6F, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {"Ponyta", &I_ponyta, 0xA3, 0x32, 0x55, 0x37, 0x5A, 0x41, {0x14, 0x14}, {0x34, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Rapidash", &I_rapidash, 0xA4, 0x41, 0x64, 0x46, 0x69, 0x50, {0x14, 0x14}, {0x34, 0x27, 0x17, 0x2D}, GROWTH_MEDIUM_FAST}, {"Slowpoke", &I_slowpoke, 0x25, 0x5A, 0x41, 0x41, 0x0F, 0x28, {0x15, 0x18}, {0x5D, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Slowbro", &I_slowbro, 0x08, 0x5F, 0x4B, 0x6E, 0x1E, 0x50, {0x15, 0x18}, {0x5D, 0x32, 0x1D, 0x00}, GROWTH_MEDIUM_FAST}, {"Magnemite", &I_magnemite, 0xAD, 0x19, 0x23, 0x46, 0x2D, 0x5F, {0x17, 0x17}, {0x21, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Magneton", &I_magneton, 0x36, 0x32, 0x3C, 0x5F, 0x46, 0x78, {0x17, 0x17}, {0x21, 0x31, 0x54, 0x00}, GROWTH_MEDIUM_FAST}, {"Farfetch'd", &I_farfetchd, 0x40, 0x34, 0x41, 0x37, 0x3C, 0x3A, {0x00, 0x02}, {0x40, 0x1C, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Doduo", &I_doduo, 0x46, 0x23, 0x55, 0x2D, 0x4B, 0x23, {0x00, 0x02}, {0x40, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Dodrio", &I_dodrio, 0x74, 0x3C, 0x6E, 0x46, 0x64, 0x3C, {0x00, 0x02}, {0x40, 0x2D, 0x1F, 0x00}, GROWTH_MEDIUM_FAST}, {"Seel", &I_seel, 0x3A, 0x41, 0x2D, 0x37, 0x2D, 0x46, {0x15, 0x15}, {0x1D, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Dewgong", &I_dewgong, 0x78, 0x5A, 0x46, 0x50, 0x46, 0x5F, {0x15, 0x19}, {0x1D, 0x2D, 0x3E, 0x00}, GROWTH_MEDIUM_FAST}, {"Grimer", &I_grimer, 0x0D, 0x50, 0x50, 0x32, 0x19, 0x28, {0x03, 0x03}, {0x01, 0x32, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Muk", &I_muk, 0x88, 0x69, 0x69, 0x4B, 0x32, 0x41, {0x03, 0x03}, {0x01, 0x32, 0x8B, 0x00}, GROWTH_MEDIUM_FAST}, {"Shellder", &I_shellder, 0x17, 0x1E, 0x41, 0x64, 0x28, 0x2D, {0x15, 0x15}, {0x21, 0x6E, 0x00, 0x00}, GROWTH_SLOW}, {"Cloyster", &I_cloyster, 0x8B, 0x32, 0x5F, 0xB4, 0x46, 0x55, {0x15, 0x19}, {0x6E, 0x30, 0x80, 0x3E}, GROWTH_SLOW}, {"Gastly", &I_gastly, 0x19, 0x1E, 0x23, 0x1E, 0x50, 0x64, {0x08, 0x03}, {0x7A, 0x6D, 0x65, 0x00}, GROWTH_MEDIUM_SLOW}, {"Haunter", &I_haunter, 0x93, 0x2D, 0x32, 0x2D, 0x5F, 0x73, {0x08, 0x03}, {0x7A, 0x6D, 0x65, 0x00}, GROWTH_MEDIUM_SLOW}, {"Gengar", &I_gengar, 0x0E, 0x3C, 0x41, 0x3C, 0x6E, 0x82, {0x08, 0x03}, {0x7A, 0x6D, 0x65, 0x00}, GROWTH_MEDIUM_SLOW}, {"Onix", &I_onix, 0x22, 0x23, 0x2D, 0xA0, 0x46, 0x1E, {0x05, 0x04}, {0x21, 0x67, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Drowzee", &I_drowzee, 0x30, 0x3C, 0x30, 0x2D, 0x2A, 0x5A, {0x18, 0x18}, {0x01, 0x5F, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Hypno", &I_hypno, 0x81, 0x55, 0x49, 0x46, 0x43, 0x73, {0x18, 0x18}, {0x01, 0x5F, 0x32, 0x5D}, GROWTH_MEDIUM_FAST}, {"Krabby", &I_krabby, 0x4E, 0x1E, 0x69, 0x5A, 0x32, 0x19, {0x15, 0x15}, {0x91, 0x2B, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Kingler", &I_kingler, 0x8A, 0x37, 0x82, 0x73, 0x4B, 0x32, {0x15, 0x15}, {0x91, 0x2B, 0x0B, 0x00}, GROWTH_MEDIUM_FAST}, {"Voltorb", &I_voltorb, 0x06, 0x28, 0x1E, 0x32, 0x64, 0x37, {0x17, 0x17}, {0x21, 0x67, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Electrode", &I_electrode, 0x8D, 0x3C, 0x32, 0x46, 0x8C, 0x50, {0x17, 0x17}, {0x21, 0x67, 0x31, 0x00}, GROWTH_MEDIUM_FAST}, {"Exeggcute", &I_exeggcute, 0x0C, 0x3C, 0x28, 0x50, 0x28, 0x3C, {0x16, 0x18}, {0x8C, 0x5F, 0x00, 0x00}, GROWTH_SLOW}, {"Exeggutor", &I_exeggutor, 0x0A, 0x5F, 0x5F, 0x55, 0x37, 0x7D, {0x16, 0x18}, {0x8C, 0x5F, 0x00, 0x00}, GROWTH_SLOW}, {"Cubone", &I_cubone, 0x11, 0x32, 0x32, 0x5F, 0x23, 0x28, {0x04, 0x04}, {0x7D, 0x2D, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Marowak", &I_marowak, 0x91, 0x3C, 0x50, 0x6E, 0x2D, 0x32, {0x04, 0x04}, {0x7D, 0x2D, 0x2B, 0x74}, GROWTH_MEDIUM_FAST}, {"Hitmonlee", &I_hitmonlee, 0x2B, 0x32, 0x78, 0x35, 0x57, 0x23, {0x01, 0x01}, {0x18, 0x60, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Hitmonchan", &I_hitmonchan, 0x2C, 0x32, 0x69, 0x4F, 0x4C, 0x23, {0x01, 0x01}, {0x04, 0x61, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Lickitung", &I_lickitung, 0x0B, 0x5A, 0x37, 0x4B, 0x1E, 0x3C, {0x00, 0x00}, {0x23, 0x30, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Koffing", &I_koffing, 0x37, 0x28, 0x41, 0x5F, 0x23, 0x3C, {0x03, 0x03}, {0x21, 0x7B, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Weezing", &I_weezing, 0x8F, 0x41, 0x5A, 0x78, 0x3C, 0x55, {0x03, 0x03}, {0x21, 0x7B, 0x7C, 0x00}, GROWTH_MEDIUM_FAST}, {"Rhyhorn", &I_rhyhorn, 0x12, 0x50, 0x55, 0x5F, 0x19, 0x1E, {0x04, 0x05}, {0x1E, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Rhydon", &I_rhydon, 0x01, 0x69, 0x82, 0x78, 0x28, 0x2D, {0x04, 0x05}, {0x1E, 0x17, 0x27, 0x1F}, GROWTH_SLOW}, {"Chansey", &I_chansey, 0x28, 0xFA, 0x05, 0x05, 0x32, 0x69, {0x00, 0x00}, {0x01, 0x03, 0x00, 0x00}, GROWTH_FAST}, {"Tangela", &I_tangela, 0x1E, 0x41, 0x37, 0x73, 0x3C, 0x64, {0x16, 0x16}, {0x84, 0x14, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Kangaskhan", &I_kangaskhan, 0x02, 0x69, 0x5F, 0x50, 0x5A, 0x28, {0x00, 0x00}, {0x04, 0x63, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Horsea", &I_horsea, 0x5C, 0x1E, 0x28, 0x46, 0x3C, 0x46, {0x15, 0x15}, {0x91, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Seadra", &I_seadra, 0x5D, 0x37, 0x41, 0x5F, 0x55, 0x5F, {0x15, 0x15}, {0x91, 0x6C, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Goldeen", &I_goldeen, 0x9D, 0x2D, 0x43, 0x3C, 0x3F, 0x32, {0x15, 0x15}, {0x40, 0x27, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Seaking", &I_seaking, 0x9E, 0x50, 0x5C, 0x41, 0x44, 0x50, {0x15, 0x15}, {0x40, 0x27, 0x30, 0x00}, GROWTH_MEDIUM_FAST}, {"Staryu", &I_staryu, 0x1B, 0x1E, 0x2D, 0x37, 0x55, 0x46, {0x15, 0x15}, {0x21, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Starmie", &I_starmie, 0x98, 0x3C, 0x4B, 0x55, 0x73, 0x64, {0x15, 0x18}, {0x21, 0x37, 0x6A, 0x00}, GROWTH_SLOW}, {"Mr.Mime", &I_mr_mime, 0x2A, 0x28, 0x2D, 0x41, 0x5A, 0x64, {0x18, 0x18}, {0x5D, 0x70, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Scyther", &I_scyther, 0x1A, 0x46, 0x6E, 0x50, 0x69, 0x37, {0x07, 0x02}, {0x62, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Jynx", &I_jynx, 0x48, 0x41, 0x32, 0x23, 0x5F, 0x5F, {0x19, 0x18}, {0x01, 0x8E, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Electabuzz", &I_electabuzz, 0x35, 0x41, 0x53, 0x39, 0x69, 0x55, {0x17, 0x17}, {0x62, 0x2B, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Magmar", &I_magmar, 0x33, 0x41, 0x5F, 0x39, 0x5D, 0x55, {0x14, 0x14}, {0x34, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Pinsir", &I_pinsir, 0x1D, 0x41, 0x7D, 0x64, 0x55, 0x37, {0x07, 0x07}, {0x0B, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Tauros", &I_tauros, 0x3C, 0x4B, 0x64, 0x5F, 0x6E, 0x46, {0x00, 0x00}, {0x21, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Magikarp", &I_magikarp, 0x85, 0x14, 0x0A, 0x37, 0x50, 0x14, {0x15, 0x15}, {0x96, 0x00, 0x00, 0x00}, GROWTH_SLOW}, {"Gyarados", &I_gyarados, 0x16, 0x5F, 0x7D, 0x4F, 0x51, 0x64, {0x15, 0x02}, {0x2C, 0x52, 0x2B, 0x38}, GROWTH_SLOW}, {"Lapras", &I_lapras, 0x13, 0x82, 0x55, 0x50, 0x3C, 0x5F, {0x15, 0x19}, {0x37, 0x2D, 0x00, 0x00}, GROWTH_SLOW}, {"Ditto", &I_ditto, 0x4C, 0x30, 0x30, 0x30, 0x30, 0x30, {0x00, 0x00}, {0x90, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Eevee", &I_eevee, 0x66, 0x37, 0x37, 0x32, 0x37, 0x41, {0x00, 0x00}, {0x21, 0x1C, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Vaporeon", &I_vaporeon, 0x69, 0x82, 0x41, 0x3C, 0x41, 0x6E, {0x15, 0x15}, {0x21, 0x1C, 0x62, 0x37}, GROWTH_MEDIUM_FAST}, {"Jolteon", &I_jolteon, 0x68, 0x41, 0x41, 0x3C, 0x82, 0x6E, {0x17, 0x17}, {0x21, 0x1C, 0x62, 0x54}, GROWTH_MEDIUM_FAST}, {"Flareon", &I_flareon, 0x67, 0x41, 0x82, 0x3C, 0x41, 0x6E, {0x14, 0x14}, {0x21, 0x1C, 0x62, 0x34}, GROWTH_MEDIUM_FAST}, {"Porygon", &I_porygon, 0xAA, 0x41, 0x3C, 0x46, 0x28, 0x4B, {0x00, 0x00}, {0x21, 0x9F, 0xA0, 0x00}, GROWTH_MEDIUM_FAST}, {"Omanyte", &I_omanyte, 0x62, 0x23, 0x28, 0x64, 0x23, 0x5A, {0x05, 0x15}, {0x37, 0x6E, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Omastar", &I_omastar, 0x63, 0x46, 0x3C, 0x7D, 0x37, 0x73, {0x05, 0x15}, {0x37, 0x6E, 0x1E, 0x00}, GROWTH_MEDIUM_FAST}, {"Kabuto", &I_kabuto, 0x5A, 0x1E, 0x50, 0x5A, 0x37, 0x2D, {0x05, 0x15}, {0x0A, 0x6A, 0x00, 0x00}, GROWTH_MEDIUM_FAST}, {"Kabutops", &I_kabutops, 0x5B, 0x3C, 0x73, 0x69, 0x50, 0x46, {0x05, 0x15}, {0x0A, 0x6A, 0x47, 0x00}, GROWTH_MEDIUM_FAST}, {"Aerodactyl", &I_aerodactyl, 0xAB, 0x50, 0x69, 0x41, 0x82, 0x3C, {0x05, 0x02}, {0x11, 0x61, 0x00, 0x00}, GROWTH_SLOW}, {"Snorlax", &I_snorlax, 0x84, 0xA0, 0x6E, 0x41, 0x1E, 0x41, {0x00, 0x00}, {0x1D, 0x85, 0x9C, 0x00}, GROWTH_SLOW}, {"Articuno", &I_articuno, 0x4A, 0x5A, 0x55, 0x64, 0x55, 0x7D, {0x19, 0x02}, {0x40, 0x3A, 0x00, 0x00}, GROWTH_SLOW}, {"Zapdos", &I_zapdos, 0x4B, 0x5A, 0x5A, 0x55, 0x64, 0x7D, {0x17, 0x02}, {0x54, 0x41, 0x00, 0x00}, GROWTH_SLOW}, {"Moltres", &I_moltres, 0x49, 0x5A, 0x64, 0x5A, 0x5A, 0x7D, {0x14, 0x02}, {0x40, 0x53, 0x00, 0x00}, GROWTH_SLOW}, {"Dratini", &I_dratini, 0x58, 0x29, 0x40, 0x2D, 0x32, 0x32, {0x1A, 0x1A}, {0x23, 0x2B, 0x00, 0x00}, GROWTH_SLOW}, {"Dragonair", &I_dragonair, 0x59, 0x3D, 0x54, 0x41, 0x46, 0x46, {0x1A, 0x1A}, {0x23, 0x2B, 0x56, 0x00}, GROWTH_SLOW}, {"Dragonite", &I_dragonite, 0x42, 0x5B, 0x86, 0x5F, 0x50, 0x64, {0x1A, 0x02}, {0x23, 0x2B, 0x56, 0x61}, GROWTH_SLOW}, {"Mewtwo", &I_mewtwo, 0x83, 0x6A, 0x6E, 0x5A, 0x82, 0x9A, {0x18, 0x18}, {0x5D, 0x32, 0x81, 0x5E}, GROWTH_SLOW}, {"Mew", &I_mew, 0x15, 0x64, 0x64, 0x64, 0x64, 0x64, {0x18, 0x18}, {0x01, 0x00, 0x00, 0x00}, GROWTH_MEDIUM_SLOW}, {}, }; const NamedList move_list[] = { {"No Move", 0x00}, {"Absorb", 0x47}, {"Acid Armor", 0x97}, {"Acid", 0x33}, {"Agility", 0x61}, {"Amnesia", 0x85}, {"Aurora Beam", 0x3E}, {"Barrage", 0x8C}, {"Barrier", 0x70}, {"Bide", 0x75}, {"Bind", 0x14}, {"Bite", 0x2C}, {"Blizzard", 0x3B}, {"Body Slam", 0x22}, {"Bone Club", 0x7D}, {"Boomerang", 0x9B}, {"Bubblebeam", 0x3D}, {"Bubble", 0x91}, {"Clamp", 0x80}, {"Comet Punch", 0x04}, {"Confuse Ray", 0x6D}, {"Confusion", 0x5D}, {"Constrict", 0x84}, {"Conversion", 0xA0}, {"Counter", 0x44}, {"Crabhammer", 0x98}, {"Cut", 0x0F}, {"Defense Curl", 0x6F}, {"Dig", 0x5B}, {"Disable", 0x32}, {"Dizzy Punch", 0x92}, {"Doubleslap", 0x03}, {"Double Kick", 0x18}, {"Double Team", 0x68}, {"Double-Edge", 0x26}, {"Dragon Rage", 0x52}, {"Dream Eater", 0x8A}, {"Drill Peck", 0x41}, {"Earthquake", 0x59}, {"Egg Bomb", 0x79}, {"Ember", 0x34}, {"Explosion", 0x99}, {"Fire Blast", 0x7E}, {"Fire Punch", 0x07}, {"Fire Spin", 0x53}, {"Fissure", 0x5A}, {"Flamethrower", 0x35}, {"Flash", 0x94}, {"Fly", 0x13}, {"Focus Energy", 0x74}, {"Fury Attack", 0x1F}, {"Fury Swipes", 0x9A}, {"Glare", 0x89}, {"Growl", 0x2D}, {"Growth", 0x4A}, {"Guillotine", 0x0C}, {"Gust", 0x10}, {"Harden", 0x6A}, {"Haze", 0x72}, {"Headbutt", 0x1D}, {"Hi Jump Kick", 0x88}, {"Horn Attack", 0x1E}, {"Horn Drill", 0x20}, {"Hydro Pump", 0x38}, {"Hyper Beam", 0x3F}, {"Hyper Fang", 0x9E}, {"Hypnosis", 0x5F}, {"Ice Beam", 0x3A}, {"Ice Punch", 0x08}, {"Jump Kick", 0x1A}, {"Karate Chop", 0x02}, {"Kinesis", 0x86}, {"Leech Life", 0x8D}, {"Leech Seed", 0x49}, {"Leer", 0x2B}, {"Lick", 0x7A}, {"Light Screen", 0x71}, {"Lovely Kiss", 0x8E}, {"Low Kick", 0x43}, {"Meditate", 0x60}, {"Mega Drain", 0x48}, {"Mega Kick", 0x19}, {"Mega Punch", 0x05}, {"Metronome", 0x76}, {"Mimic", 0x66}, {"Minimize", 0x6B}, {"Mirror Move", 0x77}, {"Mist", 0x36}, {"Night Shade", 0x65}, {"Pay Day", 0x06}, {"Peck", 0x40}, {"Petal Dance", 0x50}, {"Pin Missile", 0x2A}, {"Poisonpowder", 0x4D}, {"Poison Gas", 0x8B}, {"Poison Sting", 0x28}, {"Pound", 0x01}, {"Psybeam", 0x3C}, {"Psychic", 0x5E}, {"Psywave", 0x95}, {"Quick Attack", 0x62}, {"Rage", 0x63}, {"Razor Leaf", 0x4B}, {"Razor Wind", 0x0D}, {"Recover", 0x69}, {"Reflect", 0x73}, {"Rest", 0x9C}, {"Roar", 0x2E}, {"Rock Slide", 0x9D}, {"Rock Throw", 0x58}, {"Rolling Kick", 0x1B}, {"Sand Attack", 0x1C}, {"Scratch", 0x0A}, {"Screech", 0x67}, {"Seismic Toss", 0x45}, {"Selfdestruct", 0x78}, {"Sharpen", 0x9F}, {"Sing", 0x2F}, {"Skull Bash", 0x82}, {"Sky Attack", 0x8F}, {"Slam", 0x15}, {"Slash", 0xA3}, {"Sleep Powder", 0x4F}, {"Sludge", 0x7C}, {"Smog", 0x7B}, {"Smokescreen", 0x6C}, {"Softboiled", 0x87}, {"Solar Beam", 0x4C}, {"Sonicboom", 0x31}, {"Spike Cannon", 0x83}, {"Splash", 0x96}, {"Spore", 0x93}, {"Stomp", 0x17}, {"Strength", 0x46}, {"String Shot", 0x51}, {"Struggle", 0xA5}, {"Stun Spore", 0x4E}, {"Submission", 0x42}, {"Substitute", 0xA4}, {"Supersonic", 0x30}, {"Super Fang", 0xA2}, {"Surf", 0x39}, {"Swift", 0x81}, {"Swords Dance", 0x0E}, {"Tackle", 0x21}, {"Tail Whip", 0x27}, {"Take Down", 0x24}, {"Teleport", 0x64}, {"Thrash", 0x25}, {"Thunderbolt", 0x55}, {"Thunderpunch", 0x09}, {"Thundershock", 0x54}, {"Thunder Wave", 0x56}, {"Thunder", 0x57}, {"Toxic", 0x5C}, {"Transform", 0x90}, {"Tri Attack", 0xA1}, {"Twineedle", 0x29}, {"Vicegrip", 0x0B}, {"Vine Whip", 0x16}, {"Waterfall", 0x7F}, {"Water Gun", 0x37}, {"Whirlwind", 0x12}, {"Wing Attack", 0x11}, {"Withdraw", 0x6E}, {"Wrap", 0x23}, {}, }; const NamedList type_list[] = { {"Bug", 0x07}, {"Dragon", 0x1A}, {"Electric", 0x17}, {"Fighting", 0x01}, {"Fire", 0x14}, {"Flying", 0x02}, {"Ghost", 0x08}, {"Grass", 0x16}, {"Ground", 0x04}, {"Ice", 0x19}, {"Normal", 0x00}, {"Poison", 0x03}, {"Psychic", 0x18}, {"Rock", 0x05}, {"Water", 0x15}, {}, }; int pokemon_named_list_get_num_elements(const NamedList* list) { int i; for(i = 0;; i++) { if(list[i].name == NULL) return i; } /* XXX: Would be faster to do something like this, but, can't easily do * that using the current pointers. Might be able to clean this up later? */ //return sizeof(type_list)/sizeof(type_list[0]); } int pokemon_named_list_get_list_pos_from_index(const NamedList* list, uint8_t index) { int i; for(i = 0;; i++) { if(list[i].name == NULL) break; if(index == list[i].index) return i; } /* XXX: This will return the first entry in case index is not matched. * Could be surprising at runtime. */ return 0; } const char* pokemon_named_list_get_name_from_index(const NamedList* list, uint8_t index) { int i; for(i = 0;; i++) { if(list[i].name == NULL) break; if(index == list[i].index) return list[i].name; } /* XXX: This will return the first entry in the case index is not matched, * this could be confusing/problematic at runtime. */ return list[0].name; } /* If dest is not NULL, a copy of the default name is written to it as well */ void pokemon_trade_block_set_default_name(char* dest, PokemonFap* pokemon_fap, size_t n) { int i; char buf[11]; /* Walk through the default name, toupper() each character, encode it, and * then write that to the same position in the trade_block. */ /* XXX: The limit of this is hard-coded to a length of 11 at most. This may * be a problem down the road! */ for(i = 0; i < 11; i++) { pokemon_fap->trade_block->nickname[0].str[i] = pokemon_char_to_encoded( toupper(pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon].name[i])); buf[i] = toupper(pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon].name[i]); } if(dest != NULL) { strncpy(dest, buf, n); } } #define UINT32_TO_EXP(input, output_array) \ do { \ (output_array)[2] = (uint8_t)((input)&0xFF); \ (output_array)[1] = (uint8_t)(((input) >> 8) & 0xFF); \ (output_array)[0] = (uint8_t)(((input) >> 16) & 0xFF); \ } while(0) void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap) { struct pokemon_structure* pkmn = &pokemon_fap->trade_block->party[0]; const PokemonTable* table = &pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon]; int curr_stats = pokemon_fap->curr_stats; uint32_t experience; int level = pkmn->level; uint16_t stat; uint8_t hp_iv = 0xf; uint8_t atk_iv = 0xf; uint8_t def_iv = 0xf; uint8_t spd_iv = 0xf; uint8_t special_iv = 0xf; /* Calculate exp */ switch(table->growth) { case GROWTH_FAST: // https://bulbapedia.bulbagarden.net/wiki/Experience#Fast experience = (4 * level * level * level) / 5; break; case GROWTH_MEDIUM_FAST: // https://bulbapedia.bulbagarden.net/wiki/Experience#Medium_Fast experience = (level * level * level); break; case GROWTH_MEDIUM_SLOW: // https://bulbapedia.bulbagarden.net/wiki/Experience#Medium_Slow experience = (((level * level * level) * 6 / 5) - (15 * level * level) + (100 * level) - 140); break; case GROWTH_SLOW: // https://bulbapedia.bulbagarden.net/wiki/Experience#Slow experience = (5 * level * level * level) / 4; break; default: furi_crash("incorrect growth val"); break; } pkmn->level_again = level; UINT32_TO_EXP(experience, pkmn->exp); /* Generate STATEXP */ switch(curr_stats) { case 1: case 4: stat = (0xffff / 100) * level; break; case 2: case 5: stat = 0xffff; break; default: stat = 0; break; } stat = __builtin_bswap16(stat); pkmn->hp_ev = stat; pkmn->atk_ev = stat; pkmn->def_ev = stat; pkmn->spd_ev = stat; pkmn->special_ev = stat; /* Set up IVs */ if(curr_stats <= 2) { atk_iv = rand() % 15; def_iv = rand() % 15; spd_iv = rand() % 15; special_iv = rand() % 15; pkmn->iv = ((atk_iv & 0x0f) << 12) | ((def_iv & 0x0f) << 8) | ((spd_iv & 0x0f) << 4) | ((special_iv & 0x0f)); hp_iv = (pkmn->iv & 0xAA) >> 4; } /* Calculate HP */ // https://bulbapedia.bulbagarden.net/wiki/Stat#Generations_I_and_II stat = floor((((2 * (table->base_hp + hp_iv)) + floor(sqrt(pkmn->hp_ev) / 4)) * level) / 100) + (level + 10); pkmn->hp = __builtin_bswap16(stat); pkmn->max_hp = pkmn->hp; /* Calculate ATK, DEF, SPD, SP */ // https://bulbapedia.bulbagarden.net/wiki/Stat#Generations_I_and_II stat = floor((((2 * (table->base_atk + atk_iv)) + floor(sqrt(pkmn->atk_ev) / 4)) * level) / 100) + 5; pkmn->atk = __builtin_bswap16(stat); stat = floor((((2 * (table->base_def + def_iv)) + floor(sqrt(pkmn->def_ev) / 4)) * level) / 100) + 5; pkmn->def = __builtin_bswap16(stat); stat = floor((((2 * (table->base_spd + spd_iv)) + floor(sqrt(pkmn->spd_ev) / 4)) * level) / 100) + 5; pkmn->spd = __builtin_bswap16(stat); stat = floor( (((2 * (table->base_special + special_iv)) + floor(sqrt(pkmn->special_ev) / 4)) * level) / 100) + 5; pkmn->special = __builtin_bswap16(stat); } /* Rebuild the current trade block's variables based on curr_pokemon */ void pokemon_trade_block_recalculate(PokemonFap* pokemon_fap) { struct pokemon_structure* pkmn = &pokemon_fap->trade_block->party[0]; const PokemonTable* table = &pokemon_fap->pokemon_table[pokemon_fap->curr_pokemon]; int i; /* Set current pokemon to the trade structure */ pkmn->index = table->index; pokemon_fap->trade_block->party_members[0] = table->index; /* Set current pokemon's moves to the trade structure */ for(i = 0; i < 4; i++) { pkmn->move[i] = table->move[i]; } /* Set current pokemon's types to the trade structure */ for(i = 0; i < 2; i++) { pkmn->type[i] = table->type[i]; } pokemon_trade_block_recalculate_stats_from_level(pokemon_fap); pokemon_trade_block_set_default_name(NULL, pokemon_fap, 0); } /* Allocates a chunk of memory for the trade data block and sets up some * default values. */ static TradeBlock* trade_block_alloc(void) { TradeBlock* trade; trade = malloc(sizeof(TradeBlock)); /* Clear struct to be all TERM_ bytes as the various name strings need this */ memset(trade, TERM_, sizeof(TradeBlock)); /* The party_members element needs to be 0xff for unused */ memset(trade->party_members, 0xFF, sizeof(trade->party_members)); /* Zero the main party data, TERM_ in there can cause weirdness */ memset(trade->party, 0x00, sizeof(trade->party)); /* Set our Name, the pokemon's default OT name and ID */ trade->party_cnt = 1; /* Trainer/OT name, not to exceed 7 characters! */ pokemon_str_to_encoded_array(trade->trainer_name, "Flipper", sizeof(trade->trainer_name)); pokemon_str_to_encoded_array(trade->ot_name[0].str, "Flipper", sizeof(trade->ot_name[0].str)); /* OT trainer ID# */ trade->party[0].ot_id = __builtin_bswap16(42069); /* XXX: move pp isn't explicitly set up, should be fine */ /* XXX: catch/held isn't explicitly set up, should be okay for only Gen I support now */ /* XXX: Status condition isn't explicity let up, would you ever want to? */ /* Set up initial level */ trade->party[0].level = 2; return trade; } static void trade_block_free(TradeBlock* trade) { free(trade); } PokemonFap* pokemon_alloc() { PokemonFap* pokemon_fap = (PokemonFap*)malloc(sizeof(PokemonFap)); // View dispatcher pokemon_fap->view_dispatcher = view_dispatcher_alloc(); view_dispatcher_enable_queue(pokemon_fap->view_dispatcher); view_dispatcher_set_event_callback_context(pokemon_fap->view_dispatcher, pokemon_fap); view_dispatcher_attach_to_gui( pokemon_fap->view_dispatcher, (Gui*)furi_record_open(RECORD_GUI), ViewDispatcherTypeFullscreen); /* Set up pointers to const data tables for reference elsewhere */ pokemon_fap->pokemon_table = pokemon_table; pokemon_fap->move_list = move_list; pokemon_fap->type_list = type_list; // Set up defaults pokemon_fap->curr_pokemon = 0; pokemon_fap->curr_stats = 0; // Set up trade party struct pokemon_fap->trade_block = trade_block_alloc(); /* Update trade block struct with calculated details from initial values from trade_block_alloc() */ pokemon_trade_block_recalculate(pokemon_fap); /* Set up gui modules used. It would be nice if these could be allocated and * freed as needed, however, the scene manager still requires pointers that * get set up as a part of the scene. Therefore, individual scene's exit * callbacks cannot free the buffer. */ pokemon_fap->text_input = text_input_alloc(); pokemon_fap->submenu = submenu_alloc(); pokemon_fap->variable_item_list = variable_item_list_alloc(); // Set up menu scene pokemon_fap->scene_manager = scene_manager_alloc(&pokemon_scene_manager_handlers, pokemon_fap); view_dispatcher_add_view( pokemon_fap->view_dispatcher, AppViewMainMenu, submenu_get_view(pokemon_fap->submenu)); scene_manager_next_scene(pokemon_fap->scene_manager, MainMenuScene); // Select Pokemon View pokemon_fap->select_view = select_pokemon_alloc(pokemon_fap); view_dispatcher_add_view( pokemon_fap->view_dispatcher, AppViewSelectPokemon, pokemon_fap->select_view); // Trade View pokemon_fap->trade_view = trade_alloc(pokemon_fap); view_dispatcher_add_view(pokemon_fap->view_dispatcher, AppViewTrade, pokemon_fap->trade_view); return pokemon_fap; } void free_app(PokemonFap* pokemon_fap) { furi_assert(pokemon_fap); // Free views view_dispatcher_remove_view(pokemon_fap->view_dispatcher, AppViewSelectPokemon); select_pokemon_free(pokemon_fap); view_dispatcher_remove_view(pokemon_fap->view_dispatcher, AppViewTrade); trade_free(pokemon_fap); view_dispatcher_remove_view(pokemon_fap->view_dispatcher, AppViewMainMenu); view_dispatcher_free(pokemon_fap->view_dispatcher); // Free scenes scene_manager_free(pokemon_fap->scene_manager); // Free gui modules submenu_free(pokemon_fap->submenu); text_input_free(pokemon_fap->text_input); variable_item_list_free(pokemon_fap->variable_item_list); // Close records furi_record_close(RECORD_GUI); // Free trade block trade_block_free(pokemon_fap->trade_block); // Free rest free(pokemon_fap); pokemon_fap = NULL; } int32_t pokemon_app(void* p) { UNUSED(p); PokemonFap* pokemon_fap = pokemon_alloc(); furi_hal_light_set(LightRed, 0x00); furi_hal_light_set(LightGreen, 0x00); furi_hal_light_set(LightBlue, 0x00); //switch view and run dispatcher view_dispatcher_run(pokemon_fap->view_dispatcher); // Free resources free_app(pokemon_fap); return 0; }