luna.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #include "luna.hpp"
  2. shared_pointer<ares::Interface> interface;
  3. vector<shared_pointer<ares::Interface>> interfaces;
  4. namespace nall::Path {
  5. string settings;
  6. string templates;
  7. string data;
  8. }
  9. Video videoInstance;
  10. Audio audioInstance;
  11. Input inputInstance;
  12. #include <cv/interface/interface.hpp>
  13. #include <fc/interface/interface.hpp>
  14. #include <gb/interface/interface.hpp>
  15. #include <gba/interface/interface.hpp>
  16. #include <md/interface/interface.hpp>
  17. #include <ms/interface/interface.hpp>
  18. #include <msx/interface/interface.hpp>
  19. #include <n64/interface/interface.hpp>
  20. #include <ngp/interface/interface.hpp>
  21. #include <pce/interface/interface.hpp>
  22. #include <ps1/interface/interface.hpp>
  23. #include <sfc/interface/interface.hpp>
  24. #include <sg/interface/interface.hpp>
  25. #include <ws/interface/interface.hpp>
  26. #include <nall/main.hpp>
  27. auto nall::main(Arguments arguments) -> void {
  28. Application::setName("luna");
  29. Application::setScreenSaver(false);
  30. settings.load();
  31. if(file::exists({Path::program(), "paths.bml"})) {
  32. Path::settings = Path::program();
  33. } else {
  34. Path::settings = {Path::userSettings(), "luna/"};
  35. directory::create(Path::settings);
  36. }
  37. if(auto document = BML::unserialize(file::read({Path::settings, "paths.bml"}))) {
  38. Path::templates = document["templates"].text();
  39. Path::data = document["data"].text();
  40. }
  41. if(!directory::exists(Path::templates)) {
  42. Path::templates = {Path::userData(), "luna/"};
  43. directory::create(Path::templates);
  44. }
  45. if(!directory::exists(Path::data)) {
  46. Path::data = {Path::user(), "luna/"};
  47. directory::create(Path::data);
  48. }
  49. file::write({Path::settings, "paths.bml"}, string{
  50. "data: ", Path::data, "\n",
  51. "templates: ", Path::templates, "\n"
  52. });
  53. //create interfaces list in alphabetical order of interface->name() values
  54. #ifdef CORE_CV
  55. interfaces.append(new ares::ColecoVision::ColecoVisionInterface);
  56. #endif
  57. #ifdef CORE_FC
  58. interfaces.append(new ares::Famicom::FamicomInterface);
  59. #endif
  60. #ifdef CORE_GB
  61. interfaces.append(new ares::GameBoy::GameBoyInterface);
  62. #endif
  63. #ifdef CORE_GB
  64. interfaces.append(new ares::GameBoy::GameBoyColorInterface);
  65. #endif
  66. #ifdef CORE_GBA
  67. interfaces.append(new ares::GameBoyAdvance::GameBoyAdvanceInterface);
  68. #endif
  69. #ifdef CORE_GBA
  70. interfaces.append(new ares::GameBoyAdvance::GameBoyPlayerInterface);
  71. #endif
  72. #ifdef CORE_MD
  73. interfaces.append(new ares::MegaDrive::MegaDriveInterface);
  74. #endif
  75. #ifdef CORE_MS
  76. interfaces.append(new ares::MasterSystem::GameGearInterface);
  77. #endif
  78. #ifdef CORE_MS
  79. interfaces.append(new ares::MasterSystem::MasterSystemInterface);
  80. #endif
  81. #ifdef CORE_MSX
  82. interfaces.append(new ares::MSX::MSXInterface);
  83. #endif
  84. #ifdef CORE_MSX
  85. interfaces.append(new ares::MSX::MSX2Interface);
  86. #endif
  87. #ifdef CORE_N64
  88. interfaces.append(new ares::Nintendo64::Nintendo64Interface);
  89. #endif
  90. #ifdef CORE_NGP
  91. interfaces.append(new ares::NeoGeoPocket::NeoGeoPocketInterface);
  92. #endif
  93. #ifdef CORE_NGP
  94. interfaces.append(new ares::NeoGeoPocket::NeoGeoPocketColorInterface);
  95. #endif
  96. #ifdef CORE_PCE
  97. interfaces.append(new ares::PCEngine::PCEngineInterface);
  98. #endif
  99. #ifdef CORE_PCE
  100. interfaces.append(new ares::PCEngine::PCEngineDuoInterface);
  101. #endif
  102. #ifdef CORE_PS1
  103. interfaces.append(new ares::PlayStation::PlayStationInterface);
  104. #endif
  105. #ifdef CORE_WS
  106. interfaces.append(new ares::WonderSwan::PocketChallengeV2Interface);
  107. #endif
  108. #ifdef CORE_SG
  109. interfaces.append(new ares::SG1000::SC3000Interface);
  110. #endif
  111. #ifdef CORE_SG
  112. interfaces.append(new ares::SG1000::SG1000Interface);
  113. #endif
  114. #ifdef CORE_SFC
  115. interfaces.append(new ares::SuperFamicom::SuperFamicomInterface);
  116. #endif
  117. #ifdef CORE_PCE
  118. interfaces.append(new ares::PCEngine::SuperGrafxInterface);
  119. #endif
  120. #ifdef CORE_WS
  121. interfaces.append(new ares::WonderSwan::SwanCrystalInterface);
  122. #endif
  123. #ifdef CORE_WS
  124. interfaces.append(new ares::WonderSwan::WonderSwanInterface);
  125. #endif
  126. #ifdef CORE_WS
  127. interfaces.append(new ares::WonderSwan::WonderSwanColorInterface);
  128. #endif
  129. ares::platform = &emulator;
  130. Instances::program.construct();
  131. emulator.inputUpdate();
  132. inputManager.poll();
  133. hotkeys.bind();
  134. Application::onMain({&Emulator::main, &emulator});
  135. Application::run();
  136. settings.save();
  137. Instances::program.destruct();
  138. }