main.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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::Network);
  42. cpp3ds::Service::enable(cpp3ds::SSL);
  43. cpp3ds::Service::enable(cpp3ds::Httpc);
  44. cpp3ds::Service::enable(cpp3ds::AM);
  45. #ifndef EMULATION
  46. aptHook(&cookie, aptHookFunc, nullptr);
  47. AM_InitializeExternalTitleDatabase(false);
  48. #endif
  49. auto game = new FreeShop::FreeShop();
  50. game->run();
  51. FreeShop::DownloadQueue::getInstance().suspend();
  52. FreeShop::DownloadQueue::getInstance().save();
  53. delete game;
  54. return 0;
  55. }