pokemon_app.h 3.0 KB

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