main.cpp 1.5 KB

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