pokemon_app.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #include "pokemon_app.h"
  2. struct pokemon_lut pokemon_table[] = {
  3. { "Bulbasaur", &I_bulbasaur, 0x99 },
  4. { "Ivysaur", &I_ivysaur, 0x09 },
  5. { "Venusaur", &I_venusaur, 0x9A },
  6. { "Charmander", &I_charmander, 0xB0 },
  7. { "Charmeleon", &I_charmeleon, 0xB2 },
  8. { "Charizard", &I_charizard, 0xB4 },
  9. { "Squirtle", &I_squirtle, 0xB1 },
  10. { "Wartortle", &I_wartortle, 0xB3 },
  11. { "Blastoise", &I_blastoise, 0x1C },
  12. { "Caterpie", &I_caterpie, 0x7B },
  13. { "Metapod", &I_metapod, 0x7C },
  14. { "Butterfree", &I_butterfree, 0x7D },
  15. { "Weedle", &I_weedle, 0x70 },
  16. { "Kakuna", &I_kakuna, 0x71 },
  17. { "Beedrill", &I_beedrill, 0x72 },
  18. { "Pidgey", &I_pidgey, 0x24 },
  19. { "Pidgeotto", &I_pidgeotto, 0x96 },
  20. { "Pidgeot", &I_pidgeot, 0x97 },
  21. { "Rattata", &I_rattata, 0xA5 },
  22. { "Raticate", &I_raticate, 0xA6 },
  23. { "Spearow", &I_spearow, 0x05 },
  24. { "Fearow", &I_fearow, 0x23 },
  25. { "Ekans", &I_ekans, 0x6C },
  26. { "Arbok", &I_arbok, 0x2D },
  27. { "Pikachu", &I_pikachu, 0x54 },
  28. { "Raichu", &I_raichu, 0x55 },
  29. { "Sandshrew", &I_sandshrew, 0x60 },
  30. { "Sandslash", &I_sandslash, 0x61 },
  31. { "Nidoran ♀", &I_nidoranf, 0x0F },
  32. { "Nidorina", &I_nidorina, 0xA8 },
  33. { "Nidoqueen", &I_nidoqueen, 0x10 },
  34. { "Nidoran ♂", &I_nidoranm, 0x03 },
  35. { "Nidorino", &I_nidorino, 0xA7 },
  36. { "Nidoking", &I_nidoking, 0x07 },
  37. { "Clefairy", &I_clefairy, 0x04 },
  38. { "Clefable", &I_clefable, 0x8E },
  39. { "Vulpix", &I_vulpix, 0x52 },
  40. { "Ninetales", &I_ninetales, 0x53 },
  41. { "Jigglypuff", &I_jigglypuff, 0x64 },
  42. { "Wigglytuff", &I_wigglytuff, 0x65 },
  43. { "Zubat", &I_zubat, 0x6B },
  44. { "Golbat", &I_golbat, 0x82 },
  45. { "Oddish", &I_oddish, 0xB9 },
  46. { "Gloom", &I_gloom, 0xBA },
  47. { "Vileplume", &I_vileplume, 0xBB },
  48. { "Paras", &I_paras, 0x6D },
  49. { "Parasect", &I_parasect, 0x2E },
  50. { "Venonat", &I_venonat, 0x41 },
  51. { "Venomoth", &I_venomoth, 0x77 },
  52. { "Diglett", &I_diglett, 0x3B },
  53. { "Dugtrio", &I_dugtrio, 0x76 },
  54. { "Meowth", &I_meowth, 0x4D },
  55. { "Persian", &I_persian, 0x90 },
  56. { "Psyduck", &I_psyduck, 0x2F },
  57. { "Golduck", &I_golduck, 0x80 },
  58. { "Mankey", &I_mankey, 0x39 },
  59. { "Primeape", &I_primeape, 0x75 },
  60. { "Growlithe", &I_growlithe, 0x21 },
  61. { "Arcanine", &I_arcanine, 0x14 },
  62. { "Poliwag", &I_poliwag, 0x47 },
  63. { "Poliwhirl", &I_poliwhirl, 0x6E },
  64. { "Poliwrath", &I_poliwrath, 0x6F },
  65. { "Abra", &I_abra, 0x94 },
  66. { "Kadabra", &I_kadabra, 0x26 },
  67. { "Alakazam", &I_alakazam, 0x95 },
  68. { "Machop", &I_machop, 0x6A },
  69. { "Machoke", &I_machoke, 0x29 },
  70. { "Machamp", &I_machamp, 0x7E },
  71. { "Bellsprout", &I_bellsprout, 0xBC },
  72. { "Weepinbell", &I_weepinbell, 0xBD },
  73. { "Victreebel", &I_victreebel, 0xBE },
  74. { "Tentacool", &I_tentacool, 0x18 },
  75. { "Tentacruel", &I_tentacruel, 0x9B },
  76. { "Geodude", &I_geodude, 0xA9 },
  77. { "Graveler", &I_graveler, 0x27 },
  78. { "Golem", &I_golem, 0x31 },
  79. { "Ponyta", &I_ponyta, 0xA3 },
  80. { "Rapidash", &I_rapidash, 0xA4 },
  81. { "Slowpoke", &I_slowpoke, 0x25 },
  82. { "Slowbro", &I_slowbro, 0x08 },
  83. { "Magnemite", &I_magnemite, 0xAD },
  84. { "Magneton", &I_magneton, 0x36 },
  85. { "Farfetch'd", &I_farfetchd, 0x40 },
  86. { "Doduo", &I_doduo, 0x46 },
  87. { "Dodrio", &I_dodrio, 0x74 },
  88. { "Seel", &I_seel, 0x3A },
  89. { "Dewgong", &I_dewgong, 0x78 },
  90. { "Grimer", &I_grimer, 0x0D },
  91. { "Muk", &I_muk, 0x88 },
  92. { "Shellder", &I_shellder, 0x17 },
  93. { "Cloyster", &I_cloyster, 0x8B },
  94. { "Gastly", &I_gastly, 0x19 },
  95. { "Haunter", &I_haunter, 0x93 },
  96. { "Gengar", &I_gengar, 0x0E },
  97. { "Onix", &I_onix, 0x22 },
  98. { "Drowzee", &I_drowzee, 0x30 },
  99. { "Hypno", &I_hypno, 0x81 },
  100. { "Krabby", &I_krabby, 0x4E },
  101. { "Kingler", &I_kingler, 0x8A },
  102. { "Voltorb", &I_voltorb, 0x06 },
  103. { "Electrode", &I_electrode, 0x8D },
  104. { "Exeggcute", &I_exeggcute, 0x0C },
  105. { "Exeggutor", &I_exeggutor, 0x0A },
  106. { "Cubone", &I_cubone, 0x11 },
  107. { "Marowak", &I_marowak, 0x91 },
  108. { "Hitmonlee", &I_hitmonlee, 0x2B },
  109. { "Hitmonchan", &I_hitmonchan, 0x2C },
  110. { "Lickitung", &I_lickitung, 0x0B },
  111. { "Koffing", &I_koffing, 0x37 },
  112. { "Weezing", &I_weezing, 0x8F },
  113. { "Rhyhorn", &I_rhyhorn, 0x12 },
  114. { "Rhydon", &I_rhydon, 0x01 },
  115. { "Chansey", &I_chansey, 0x28 },
  116. { "Tangela", &I_tangela, 0x1E },
  117. { "Kangaskhan", &I_kangaskhan, 0x02 },
  118. { "Horsea", &I_horsea, 0x5C },
  119. { "Seadra", &I_seadra, 0x5D },
  120. { "Goldeen", &I_goldeen, 0x9D },
  121. { "Seaking", &I_seaking, 0x9E },
  122. { "Staryu", &I_staryu, 0x1B },
  123. { "Starmie", &I_starmie, 0x98 },
  124. { "Mr. Mime", &I_mr_mime, 0x2A },
  125. { "Scyther", &I_scyther, 0x1A },
  126. { "Jynx", &I_jynx, 0x48 },
  127. { "Electabuzz", &I_electabuzz, 0x35 },
  128. { "Magmar", &I_magmar, 0x33 },
  129. { "Pinsir", &I_pinsir, 0x1D },
  130. { "Tauros", &I_tauros, 0x3C },
  131. { "Magikarp", &I_magikarp, 0x85 },
  132. { "Gyarados", &I_gyarados, 0x16 },
  133. { "Lapras", &I_lapras, 0x13 },
  134. { "Ditto", &I_ditto, 0x4C },
  135. { "Eevee", &I_eevee, 0x66 },
  136. { "Vaporeon", &I_vaporeon, 0x69 },
  137. { "Jolteon", &I_jolteon, 0x68 },
  138. { "Flareon", &I_flareon, 0x67 },
  139. { "Porygon", &I_porygon, 0xAA },
  140. { "Omanyte", &I_omanyte, 0x62 },
  141. { "Omastar", &I_omastar, 0x63 },
  142. { "Kabuto", &I_kabuto, 0x5A },
  143. { "Kabutops", &I_kabutops, 0x5B },
  144. { "Aerodactyl", &I_aerodactyl, 0xAB },
  145. { "Snorlax", &I_snorlax, 0x84 },
  146. { "Articuno", &I_articuno, 0x4A },
  147. { "Zapdos", &I_zapdos, 0x4B },
  148. { "Moltres", &I_moltres, 0x49 },
  149. { "Dratini", &I_dratini, 0x58 },
  150. { "Dragonair", &I_dragonair, 0x59 },
  151. { "Dragonite", &I_dragonite, 0x42 },
  152. { "Mewtwo", &I_mewtwo, 0x83 },
  153. { "Mew", &I_mew, 0x15 },
  154. { },
  155. };
  156. uint32_t pokemon_exit_confirm_view(void* context) {
  157. UNUSED(context);
  158. return AppViewExitConfirm;
  159. }
  160. App* pokemon_alloc() {
  161. App* app = (App*)malloc(sizeof(App));
  162. // Gui
  163. app->gui = (Gui*)furi_record_open(RECORD_GUI);
  164. // View dispatcher
  165. app->view_dispatcher = view_dispatcher_alloc();
  166. view_dispatcher_enable_queue(app->view_dispatcher);
  167. view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
  168. view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
  169. // Start Index first pokemon
  170. app->current_pokemon = 0;
  171. // Select Pokemon View
  172. app->select_pokemon = select_pokemon_alloc(app);
  173. view_set_previous_callback(select_pokemon_get_view(app), pokemon_exit_confirm_view);
  174. view_dispatcher_add_view(
  175. app->view_dispatcher, AppViewSelectPokemon, select_pokemon_get_view(app));
  176. // Trade View
  177. app->trade = trade_alloc(app);
  178. view_set_previous_callback(trade_get_view(app), pokemon_exit_confirm_view);
  179. view_dispatcher_add_view(app->view_dispatcher, AppViewTrade, trade_get_view(app));
  180. view_dispatcher_switch_to_view(app->view_dispatcher, AppViewSelectPokemon);
  181. return app;
  182. }
  183. void free_app(App* app) {
  184. furi_assert(app);
  185. // Free views
  186. view_dispatcher_remove_view(app->view_dispatcher, AppViewSelectPokemon);
  187. select_pokemon_free(app);
  188. view_dispatcher_remove_view(app->view_dispatcher, AppViewTrade);
  189. trade_free(app);
  190. // Close records
  191. furi_record_close(RECORD_GUI);
  192. app->gui = NULL;
  193. // Free rest
  194. free(app);
  195. }
  196. extern "C" int32_t pokemon_app(void* p) {
  197. UNUSED(p);
  198. //FURI_LOG_D(TAG, "init scene");
  199. App* app = (App*)pokemon_alloc();
  200. furi_hal_light_set(LightRed, 0x00);
  201. furi_hal_light_set(LightGreen, 0x00);
  202. furi_hal_light_set(LightBlue, 0x00);
  203. //switch view and run dispatcher
  204. view_dispatcher_run(app->view_dispatcher);
  205. // Free resources
  206. free_app(app);
  207. furi_record_close(RECORD_GUI);
  208. return 0;
  209. }