pokemon_app.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef POKEMON_APP_H
  2. #define POKEMON_APP_H
  3. #pragma once
  4. #include <gui/scene_manager.h>
  5. #include <gui/view.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/icon.h>
  8. #include <gui/modules/submenu.h>
  9. #include <gui/modules/text_input.h>
  10. #include <gui/modules/variable_item_list.h>
  11. #include <gblink.h>
  12. #include "pokemon_data.h"
  13. #define TAG "Pokemon"
  14. /* #defines for the data table entries */
  15. #define GROWTH_FAST 4
  16. #define GROWTH_MEDIUM_FAST 0
  17. #define GROWTH_MEDIUM_SLOW 3
  18. #define GROWTH_SLOW 5
  19. struct pokemon_data_table {
  20. const char* name;
  21. const Icon* icon;
  22. const uint8_t index;
  23. const uint8_t base_hp;
  24. const uint8_t base_atk;
  25. const uint8_t base_def;
  26. const uint8_t base_spd;
  27. const uint8_t base_special;
  28. const uint8_t type[2];
  29. const uint8_t move[4];
  30. const uint8_t growth;
  31. };
  32. typedef struct pokemon_data_table PokemonTable;
  33. struct named_list {
  34. const char* name;
  35. const uint8_t index;
  36. };
  37. typedef struct named_list NamedList;
  38. struct pokemon_fap {
  39. ViewDispatcher* view_dispatcher;
  40. /* View ports for each of the application's steps */
  41. View* select_view;
  42. void* trade;
  43. /* Scene manager */
  44. SceneManager* scene_manager;
  45. /* gui modules used in the application lifetime */
  46. Submenu* submenu;
  47. TextInput* text_input;
  48. VariableItemList* variable_item_list;
  49. /* Table of pokemon data for Gen I */
  50. const PokemonTable* pokemon_table;
  51. /* List of moves, alphabetically ordered */
  52. const NamedList* move_list;
  53. /* List of types, alphabetically ordered */
  54. const NamedList* type_list;
  55. /* Struct for holding trade data */
  56. /* NOTE: There may be some runtime memory savings by adding more intelligence
  57. * to views/trade and slimming down this struct to only contain the single
  58. * pokemon data rather than the full 6 member party data.
  59. */
  60. TradeBlock* trade_block;
  61. /* Pin definition to actual Game Link Cable interface */
  62. struct gblink_pins pins;
  63. int malveke_detected;
  64. /* The currently selected pokemon */
  65. int curr_pokemon;
  66. /* TODO: Other variables will end up here, like selected level, EV/IV,
  67. * moveset, etc. Likely will want to be another sub struct similar to
  68. * the actual pokemon data structure.
  69. */
  70. int curr_stats;
  71. };
  72. typedef struct pokemon_fap PokemonFap;
  73. typedef enum {
  74. AppViewMainMenu,
  75. AppViewOpts, // Generic view ID meant for module re-use
  76. AppViewSelectPokemon,
  77. AppViewTrade,
  78. AppViewExitConfirm,
  79. } AppView;
  80. int pokemon_table_get_num_from_index(const PokemonTable* table, uint8_t index);
  81. int pokemon_named_list_get_num_elements(const NamedList* list);
  82. int pokemon_named_list_get_list_pos_from_index(const NamedList* list, uint8_t index);
  83. const char* pokemon_named_list_get_name_from_index(const NamedList* list, uint8_t index);
  84. void pokemon_trade_block_set_default_name(char* dest, PokemonFap* pokemon_fap, size_t n);
  85. void pokemon_trade_block_recalculate(PokemonFap* pokemon_fap);
  86. void pokemon_trade_block_recalculate_stats_from_level(PokemonFap* pokemon_fap);
  87. #endif /* POKEMON_APP_H */