main.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "FreeShop.hpp"
  2. #include "DownloadQueue.hpp"
  3. #include "States/BrowseState.hpp"
  4. #include "States/SleepState.hpp"
  5. #include "States/SyncState.hpp"
  6. #ifndef EMULATION
  7. #include <3ds.h>
  8. #endif
  9. #ifndef EMULATION
  10. namespace {
  11. aptHookCookie cookie;
  12. void aptHookFunc(APT_HookType hookType, void *param)
  13. {
  14. switch (hookType) {
  15. case APTHOOK_ONSUSPEND:
  16. if (FreeShop::SleepState::isSleeping && R_SUCCEEDED(gspLcdInit()))
  17. {
  18. GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP);
  19. gspLcdExit();
  20. }
  21. // Fall through
  22. case APTHOOK_ONSLEEP:
  23. FreeShop::DownloadQueue::getInstance().suspend();
  24. break;
  25. case APTHOOK_ONRESTORE:
  26. case APTHOOK_ONWAKEUP:
  27. FreeShop::SleepState::isSleeping = false;
  28. FreeShop::SleepState::clock.restart();
  29. FreeShop::BrowseState::clockDownloadInactivity.restart();
  30. FreeShop::DownloadQueue::getInstance().resume();
  31. break;
  32. case APTHOOK_ONEXIT:
  33. FreeShop::SyncState::exitRequired = true;
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. }
  40. #endif
  41. int main(int argc, char** argv)
  42. {
  43. #ifndef NDEBUG
  44. // Console for reading stdout
  45. cpp3ds::Console::enable(cpp3ds::BottomScreen, cpp3ds::Color::Black);
  46. #endif
  47. cpp3ds::Service::enable(cpp3ds::Audio);
  48. cpp3ds::Service::enable(cpp3ds::Config);
  49. cpp3ds::Service::enable(cpp3ds::Network);
  50. cpp3ds::Service::enable(cpp3ds::SSL);
  51. cpp3ds::Service::enable(cpp3ds::Httpc);
  52. cpp3ds::Service::enable(cpp3ds::AM);
  53. #ifndef EMULATION
  54. aptHook(&cookie, aptHookFunc, nullptr);
  55. AM_InitializeExternalTitleDatabase(false);
  56. //aptSetSleepAllowed(false);
  57. #endif
  58. srand(time(NULL));
  59. auto game = new FreeShop::FreeShop();
  60. game->run();
  61. FreeShop::DownloadQueue::getInstance().suspend();
  62. FreeShop::DownloadQueue::getInstance().save();
  63. #ifndef EMULATION
  64. nimsExit();
  65. #endif
  66. delete game;
  67. return 0;
  68. }