gc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <switch.h>
  5. #include "ui/menu.h" // for GameInfo_t. Changing this soon.
  6. #include "nx/cnmt.h"
  7. #include "nx/nca.h"
  8. #include "gfx/image.h"
  9. #include "gfx/text.h"
  10. typedef struct
  11. {
  12. uint16_t file_count;
  13. uint16_t cnmt_count;
  14. uint16_t nca_count; // num of ncas found.
  15. uint16_t tik_count; // num tickets on gamecard.
  16. uint16_t cert_count; // num cert on gamecard.
  17. uint16_t game_count; // num of games found. this is the total cnmt found with a unique ID.
  18. uint64_t total_size; // total size of all files on the gamecard.
  19. } GameCardFileTable_t;
  20. // maybe change this so that each entry gets a file entry
  21. // so cert/nca/tik/cnmt etc...
  22. typedef struct
  23. {
  24. char name[0x30];
  25. } GameCardStringTable_t;
  26. typedef struct
  27. {
  28. uint8_t key_gen; // keygen of this entry (only cnmt is checked).
  29. uint64_t size; // size of all ncas in this entry.
  30. Cnmt_t cnmt; // ncm data, such as cnmt header, cnmt extended header, ncm key, content infos.
  31. } GameCardEntry_t;
  32. typedef struct
  33. {
  34. uint64_t total_size; // total install size.
  35. uint64_t base_size; // total base size.
  36. uint64_t upp_size; // total upp size.
  37. uint64_t dlc_size; // total dlc size.
  38. uint32_t total_count;
  39. uint16_t base_count; // should always be 1.
  40. uint16_t upp_count; // i'm not sure if games can come with multiple updates for the same game, wouldn't make sense. This is here for compatibilty should that happen (cxi).
  41. uint16_t dlc_count; // games can come bundled with multiple dlc.
  42. GameCardEntry_t *base; // array for base entry.
  43. GameCardEntry_t *upp; // array for upp entry.
  44. GameCardEntry_t *dlc; // array for dlc entry.
  45. } GameCardGameEntries_t;
  46. typedef struct
  47. {
  48. GameCardGameEntries_t *entries;
  49. GameCardFileTable_t file_table;
  50. GameCardStringTable_t *string_table;
  51. } GameCard_t;
  52. //
  53. bool init_gc(void);
  54. void exit_gc(void);
  55. //
  56. bool gc_poll(void);
  57. bool gc_mount(void);
  58. bool gc_unmount(void);
  59. //
  60. uint16_t gc_get_game_count(void);
  61. uint16_t gc_get_base_count(uint16_t game_pos);
  62. uint16_t gc_get_upp_count(uint16_t game_pos);
  63. uint16_t gc_get_dlc_count(uint16_t game_pos);
  64. uint16_t gc_get_current_base_count(void);
  65. uint16_t gc_get_current_upp_count(void);
  66. uint16_t gc_get_current_dlc_count(void);
  67. //
  68. bool gc_setup_game_info(GameInfo_t *out_info, uint16_t game_pos);
  69. bool gc_setup_detailed_game_info(GameInfoDetailed_t *info_out, uint16_t entry);
  70. bool gc_next_game(GameInfo_t *info_out);
  71. bool gc_prev_game(GameInfo_t *info_out);
  72. bool gc_change_game(GameInfo_t *info_out, uint16_t game_pos);
  73. //
  74. bool gc_install_ex(uint16_t game_pos, NcmStorageId storage_id);
  75. bool gc_install(NcmStorageId storage_id);