diff options
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 2bf377b24..8c04685a5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include "core/hle/kernel/kernel.h" | 36 | #include "core/hle/kernel/kernel.h" |
| 37 | #include "core/hle/kernel/physical_core.h" | 37 | #include "core/hle/kernel/physical_core.h" |
| 38 | #include "core/hle/service/acc/profile_manager.h" | 38 | #include "core/hle/service/acc/profile_manager.h" |
| 39 | #include "core/hle/service/am/applet_manager.h" | ||
| 39 | #include "core/hle/service/am/frontend/applets.h" | 40 | #include "core/hle/service/am/frontend/applets.h" |
| 40 | #include "core/hle/service/apm/apm_controller.h" | 41 | #include "core/hle/service/apm/apm_controller.h" |
| 41 | #include "core/hle/service/filesystem/filesystem.h" | 42 | #include "core/hle/service/filesystem/filesystem.h" |
| @@ -136,7 +137,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 136 | struct System::Impl { | 137 | struct System::Impl { |
| 137 | explicit Impl(System& system) | 138 | explicit Impl(System& system) |
| 138 | : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, cpu_manager{system}, | 139 | : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, cpu_manager{system}, |
| 139 | reporter{system}, frontend_applets{system}, profile_manager{} {} | 140 | reporter{system}, applet_manager{system}, frontend_applets{system}, profile_manager{} {} |
| 140 | 141 | ||
| 141 | void Initialize(System& system) { | 142 | void Initialize(System& system) { |
| 142 | device_memory = std::make_unique<Core::DeviceMemory>(); | 143 | device_memory = std::make_unique<Core::DeviceMemory>(); |
| @@ -330,16 +331,27 @@ struct System::Impl { | |||
| 330 | } | 331 | } |
| 331 | 332 | ||
| 332 | SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, | 333 | SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, |
| 333 | const std::string& filepath, u64 program_id, | 334 | const std::string& filepath, |
| 334 | std::size_t program_index) { | 335 | Service::AM::FrontendAppletParameters& params) { |
| 335 | app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), | 336 | app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), |
| 336 | program_id, program_index); | 337 | params.program_id, params.program_index); |
| 337 | 338 | ||
| 338 | if (!app_loader) { | 339 | if (!app_loader) { |
| 339 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 340 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
| 340 | return SystemResultStatus::ErrorGetLoader; | 341 | return SystemResultStatus::ErrorGetLoader; |
| 341 | } | 342 | } |
| 342 | 343 | ||
| 344 | if (app_loader->ReadProgramId(params.program_id) != Loader::ResultStatus::Success) { | ||
| 345 | LOG_ERROR(Core, "Failed to find title id for ROM!"); | ||
| 346 | } | ||
| 347 | |||
| 348 | std::string name = "Unknown program"; | ||
| 349 | if (app_loader->ReadTitle(name) != Loader::ResultStatus::Success) { | ||
| 350 | LOG_ERROR(Core, "Failed to read title for ROM!"); | ||
| 351 | } | ||
| 352 | |||
| 353 | LOG_INFO(Core, "Loading {} ({})", name, params.program_id); | ||
| 354 | |||
| 343 | InitializeKernel(system); | 355 | InitializeKernel(system); |
| 344 | 356 | ||
| 345 | // Create the application process. | 357 | // Create the application process. |
| @@ -373,6 +385,10 @@ struct System::Impl { | |||
| 373 | cheat_engine->Initialize(); | 385 | cheat_engine->Initialize(); |
| 374 | } | 386 | } |
| 375 | 387 | ||
| 388 | // Register with applet manager. | ||
| 389 | applet_manager.CreateAndInsertByFrontendAppletParameters(main_process->GetProcessId(), | ||
| 390 | params); | ||
| 391 | |||
| 376 | // All threads are started, begin main process execution, now that we're in the clear. | 392 | // All threads are started, begin main process execution, now that we're in the clear. |
| 377 | main_process->Run(load_parameters->main_thread_priority, | 393 | main_process->Run(load_parameters->main_thread_priority, |
| 378 | load_parameters->main_thread_stack_size); | 394 | load_parameters->main_thread_stack_size); |
| @@ -386,21 +402,13 @@ struct System::Impl { | |||
| 386 | } | 402 | } |
| 387 | } | 403 | } |
| 388 | 404 | ||
| 389 | if (app_loader->ReadProgramId(program_id) != Loader::ResultStatus::Success) { | 405 | perf_stats = std::make_unique<PerfStats>(params.program_id); |
| 390 | LOG_ERROR(Core, "Failed to find title id for ROM (Error {})", load_result); | ||
| 391 | } | ||
| 392 | perf_stats = std::make_unique<PerfStats>(program_id); | ||
| 393 | // Reset counters and set time origin to current frame | 406 | // Reset counters and set time origin to current frame |
| 394 | GetAndResetPerfStats(); | 407 | GetAndResetPerfStats(); |
| 395 | perf_stats->BeginSystemFrame(); | 408 | perf_stats->BeginSystemFrame(); |
| 396 | 409 | ||
| 397 | std::string name = "Unknown Game"; | ||
| 398 | if (app_loader->ReadTitle(name) != Loader::ResultStatus::Success) { | ||
| 399 | LOG_ERROR(Core, "Failed to read title for ROM (Error {})", load_result); | ||
| 400 | } | ||
| 401 | |||
| 402 | std::string title_version; | 410 | std::string title_version; |
| 403 | const FileSys::PatchManager pm(program_id, system.GetFileSystemController(), | 411 | const FileSys::PatchManager pm(params.program_id, system.GetFileSystemController(), |
| 404 | system.GetContentProvider()); | 412 | system.GetContentProvider()); |
| 405 | const auto metadata = pm.GetControlMetadata(); | 413 | const auto metadata = pm.GetControlMetadata(); |
| 406 | if (metadata.first != nullptr) { | 414 | if (metadata.first != nullptr) { |
| @@ -409,14 +417,15 @@ struct System::Impl { | |||
| 409 | if (auto room_member = room_network.GetRoomMember().lock()) { | 417 | if (auto room_member = room_network.GetRoomMember().lock()) { |
| 410 | Network::GameInfo game_info; | 418 | Network::GameInfo game_info; |
| 411 | game_info.name = name; | 419 | game_info.name = name; |
| 412 | game_info.id = program_id; | 420 | game_info.id = params.program_id; |
| 413 | game_info.version = title_version; | 421 | game_info.version = title_version; |
| 414 | room_member->SendGameInfo(game_info); | 422 | room_member->SendGameInfo(game_info); |
| 415 | } | 423 | } |
| 416 | 424 | ||
| 417 | // Workarounds: | 425 | // Workarounds: |
| 418 | // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK | 426 | // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK |
| 419 | Settings::values.renderer_amdvlk_depth_bias_workaround = program_id == 0x1006A800016E000ULL; | 427 | Settings::values.renderer_amdvlk_depth_bias_workaround = |
| 428 | params.program_id == 0x1006A800016E000ULL; | ||
| 420 | 429 | ||
| 421 | status = SystemResultStatus::Success; | 430 | status = SystemResultStatus::Success; |
| 422 | return status; | 431 | return status; |
| @@ -455,6 +464,7 @@ struct System::Impl { | |||
| 455 | } | 464 | } |
| 456 | kernel.CloseServices(); | 465 | kernel.CloseServices(); |
| 457 | kernel.ShutdownCores(); | 466 | kernel.ShutdownCores(); |
| 467 | applet_manager.Reset(); | ||
| 458 | services.reset(); | 468 | services.reset(); |
| 459 | service_manager.reset(); | 469 | service_manager.reset(); |
| 460 | fs_controller.Reset(); | 470 | fs_controller.Reset(); |
| @@ -566,7 +576,8 @@ struct System::Impl { | |||
| 566 | 576 | ||
| 567 | std::unique_ptr<Tools::RenderdocAPI> renderdoc_api; | 577 | std::unique_ptr<Tools::RenderdocAPI> renderdoc_api; |
| 568 | 578 | ||
| 569 | /// Frontend applets | 579 | /// Applets |
| 580 | Service::AM::AppletManager applet_manager; | ||
| 570 | Service::AM::Frontend::FrontendAppletHolder frontend_applets; | 581 | Service::AM::Frontend::FrontendAppletHolder frontend_applets; |
| 571 | 582 | ||
| 572 | /// APM (Performance) services | 583 | /// APM (Performance) services |
| @@ -680,8 +691,8 @@ void System::InitializeDebugger() { | |||
| 680 | } | 691 | } |
| 681 | 692 | ||
| 682 | SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, | 693 | SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, |
| 683 | u64 program_id, std::size_t program_index) { | 694 | Service::AM::FrontendAppletParameters& params) { |
| 684 | return impl->Load(*this, emu_window, filepath, program_id, program_index); | 695 | return impl->Load(*this, emu_window, filepath, params); |
| 685 | } | 696 | } |
| 686 | 697 | ||
| 687 | bool System::IsPoweredOn() const { | 698 | bool System::IsPoweredOn() const { |