From b49f2d2958640c4a1707546fb637ef0d2ffa654c Mon Sep 17 00:00:00 2001
From: Weiyi Wang <wwylele@gmail.com>
Date: Mon, 10 Dec 2018 22:25:02 -0500
Subject: [PATCH] APT: enable LLE applet

---
 src/core/hle/service/apt/applet_manager.cpp | 22 +++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp
index 076f5f6cf..8d7d671da 100644
--- a/src/core/hle/service/apt/applet_manager.cpp
+++ b/src/core/hle/service/apt/applet_manager.cpp
@@ -327,10 +327,13 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
     // There are some problems with LLE applets. The rasterizer cache gets out of sync
     // when the applet is closed. To avoid breaking applications because of the issue,
     // we are going to disable loading LLE applets before further fixes are done.
-    //    auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id,
-    //    region_value)); if (process) {
-    //        return RESULT_SUCCESS;
-    //    }
+    auto cfg = Service::CFG::GetModule(system);
+    u32 region_value = cfg->GetRegionValue();
+    auto process =
+        NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, region_value));
+    if (process) {
+        return RESULT_SUCCESS;
+    }
 
     // If we weren't able to load the native applet title, try to fallback to an HLE implementation.
     auto applet = HLE::Applets::Applet::Get(applet_id);
@@ -354,10 +357,13 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
     // There are some problems with LLE applets. The rasterizer cache gets out of sync
     // when the applet is closed. To avoid breaking applications because of the issue,
     // we are going to disable loading LLE applets before further fixes are done.
-    //    auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id,
-    //    region_value)); if (process) {
-    //        return RESULT_SUCCESS;
-    //    }
+    auto cfg = Service::CFG::GetModule(system);
+    u32 region_value = cfg->GetRegionValue();
+    auto process =
+        NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, region_value));
+    if (process) {
+        return RESULT_SUCCESS;
+    }
 
     // If we weren't able to load the native applet title, try to fallback to an HLE implementation.
     auto applet = HLE::Applets::Applet::Get(applet_id);