From 67b4a0df210ce80f7fe3e7ac372221b4f7ce852d Mon Sep 17 00:00:00 2001 From: weihuoya Date: Sun, 9 Oct 2022 18:33:29 +0800 Subject: [PATCH] fx --- src/android/app/build.gradle | 8 +- src/android/app/src/main/AndroidManifest.xml | 2 +- .../app/src/main/assets/3dstdb-zh_CN.txt | 7 ++ .../src/main/assets/config/config-games.ini | 14 ++++ .../org/citra/emu/ui/EmulationFragment.java | 1 + .../main/res/layout-land/activity_memory.xml | 20 ++--- .../src/main/res/layout/activity_editor.xml | 1 + .../app/src/main/res/layout/activity_main.xml | 2 + .../src/main/res/layout/activity_memory.xml | 20 ++--- src/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- src/android/jni/main_android.cpp | 2 + src/core/file_sys/disk_archive.cpp | 12 +-- src/core/frontend/emu_window.cpp | 3 - src/core/frontend/framebuffer_layout.cpp | 80 +++++++------------ src/core/settings.h | 2 + 16 files changed, 86 insertions(+), 92 deletions(-) diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index b999ecb917e..50cc9e7a6ff 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -78,13 +78,13 @@ android { dependencies { implementation 'androidx.appcompat:appcompat:1.4.0' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.+' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.2.1' - implementation "androidx.preference:preference:1.1.+" - implementation "androidx.core:core-google-shortcuts:1.0.+" + implementation "androidx.preference:preference:1.1.1" + implementation "androidx.core:core-google-shortcuts:1.0.1" implementation 'androidx.viewpager2:viewpager2:1.0.0' implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.documentfile:documentfile:1.0.+' + implementation 'androidx.documentfile:documentfile:1.0.1' } def getVersion() { diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index 1fc78ef9e13..f73740145f6 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml @@ -114,7 +114,7 @@ android:resource="@xml/nnf_provider_paths" /> { stopConfiguringControls(); stopConfiguringLayout(); + mInputOverlay.onPressedFeedback(); }); mChatLayout = contents.findViewById(R.id.chat_input); diff --git a/src/android/app/src/main/res/layout-land/activity_memory.xml b/src/android/app/src/main/res/layout-land/activity_memory.xml index 37534fd3a24..b6550f58b61 100644 --- a/src/android/app/src/main/res/layout-land/activity_memory.xml +++ b/src/android/app/src/main/res/layout-land/activity_memory.xml @@ -31,8 +31,7 @@ @@ -60,28 +59,26 @@ @@ -89,8 +86,6 @@ @@ -113,7 +108,6 @@ @@ -157,7 +151,6 @@ @@ -187,7 +180,6 @@ diff --git a/src/android/app/src/main/res/layout/activity_editor.xml b/src/android/app/src/main/res/layout/activity_editor.xml index 3246fff4797..2675618c3e6 100644 --- a/src/android/app/src/main/res/layout/activity_editor.xml +++ b/src/android/app/src/main/res/layout/activity_editor.xml @@ -18,6 +18,7 @@ android:textColor="@android:color/darker_gray" android:text="ID:00040000000AFD00" android:textSize="14sp" + android:textIsSelectable="true" android:paddingTop="10dp" android:paddingBottom="4dp" android:layout_below="@id/toolbar" diff --git a/src/android/app/src/main/res/layout/activity_main.xml b/src/android/app/src/main/res/layout/activity_main.xml index f95d50b9318..b2a680574d2 100644 --- a/src/android/app/src/main/res/layout/activity_main.xml +++ b/src/android/app/src/main/res/layout/activity_main.xml @@ -22,6 +22,8 @@ android:id="@+id/tabs_main" android:background="?attr/colorPrimary" app:tabBackground="?attr/colorPrimary" + app:tabMaxWidth="0dp" + app:tabGravity="fill" android:layout_width="match_parent" android:layout_height="wrap_content" /> diff --git a/src/android/app/src/main/res/layout/activity_memory.xml b/src/android/app/src/main/res/layout/activity_memory.xml index d5b3f4d4671..ee9f115c574 100644 --- a/src/android/app/src/main/res/layout/activity_memory.xml +++ b/src/android/app/src/main/res/layout/activity_memory.xml @@ -29,8 +29,7 @@ @@ -58,28 +57,26 @@ @@ -87,8 +84,6 @@ @@ -111,7 +106,6 @@ @@ -155,7 +149,6 @@ @@ -185,7 +178,6 @@ diff --git a/src/android/build.gradle b/src/android/build.gradle index 3b98696bfbe..5b5049f9f4c 100644 --- a/src/android/build.gradle +++ b/src/android/build.gradle @@ -7,7 +7,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:7.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/src/android/gradle/wrapper/gradle-wrapper.properties b/src/android/gradle/wrapper/gradle-wrapper.properties index b0de95e99c2..3060578a003 100644 --- a/src/android/gradle/wrapper/gradle-wrapper.properties +++ b/src/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip diff --git a/src/android/jni/main_android.cpp b/src/android/jni/main_android.cpp index 3c40fb9a955..f6da133e70f 100644 --- a/src/android/jni/main_android.cpp +++ b/src/android/jni/main_android.cpp @@ -444,6 +444,8 @@ JNIEXPORT void JNICALL Java_org_citra_emu_NativeLibrary_Run(JNIEnv* env, jclass Settings::values.use_direct_display = true; Settings::values.accurate_max_min = false; Settings::values.accurate_rcp_rsq = false; + Settings::values.skip_load_buffer = false; + Settings::values.merge_framebuffer = false; Settings::values.use_hw_gs = Config::Get(Config::USE_HW_GS); Settings::values.use_gles = Config::Get(Config::USE_GLES); Settings::values.show_fps = Config::Get(Config::SHOW_FPS); diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 2e3d03ac6f7..1335427f0b8 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp @@ -7,6 +7,7 @@ #include #include "common/common_types.h" #include "common/file_util.h" +#include "common/string_util.h" #include "common/logging/log.h" #include "core/file_sys/disk_archive.h" #include "core/file_sys/errors.h" @@ -64,16 +65,17 @@ u32 DiskDirectory::Read(const u32 count, Entry* entries) { u32 entries_read = 0; while (entries_read < count && children_iterator != directory.children.cend()) { - const FileUtil::FSTEntry& file = *children_iterator; - const std::string& filename = file.virtualName; - Entry& entry = entries[entries_read]; + const auto& file = *children_iterator; + const auto& filename = file.virtualName; + const auto& filename16 = Common::UTF8ToUTF16(filename); + auto& entry = entries[entries_read]; LOG_TRACE(Service_FS, "File {}: size={} dir={}", filename, file.size, file.isDirectory); // TODO(Link Mauve): use a proper conversion to UTF-16. for (std::size_t j = 0; j < FILENAME_LENGTH; ++j) { - entry.filename[j] = filename[j]; - if (!filename[j]) + entry.filename[j] = filename16[j]; + if (!filename16[j]) break; } diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 0d6fff530e1..6d99d32ab19 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -104,9 +104,6 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { } void EmuWindow::UpdateFramebufferLayout(u32 width, u32 height) { - ASSERT(width > 0); - ASSERT(height > 0); - Layout::FramebufferLayout layout; if (Settings::values.custom_layout) { layout = Layout::CustomFrameLayout(width, height); diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index f9fe4c9dd8a..82e9efbf8ff 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -10,10 +10,8 @@ namespace Layout { -static const float TOP_SCREEN_ASPECT_RATIO = - static_cast(Core::kScreenTopHeight) / Core::kScreenTopWidth; -static const float BOT_SCREEN_ASPECT_RATIO = - static_cast(Core::kScreenBottomHeight) / Core::kScreenBottomWidth; +static const float TOP_SCREEN_ASPECT_RATIO = static_cast(Core::kScreenTopHeight) / Core::kScreenTopWidth; +static const float BOT_SCREEN_ASPECT_RATIO = static_cast(Core::kScreenBottomHeight) / Core::kScreenBottomWidth; u32 FramebufferLayout::GetScalingRatio() const { return static_cast(((top_screen.GetWidth() - 1) / Core::kScreenTopWidth) + 1); @@ -21,20 +19,17 @@ u32 FramebufferLayout::GetScalingRatio() const { // Finds the largest size subrectangle contained in window area that is confined to the aspect ratio template -static Common::Rectangle maxRectangle(Common::Rectangle window_area, - float screen_aspect_ratio) { - float scale = std::min(static_cast(window_area.GetWidth()), - window_area.GetHeight() / screen_aspect_ratio); - return Common::Rectangle{0, 0, static_cast(std::round(scale)), - static_cast(std::round(scale * screen_aspect_ratio))}; +static Common::Rectangle maxRectangle(Common::Rectangle window_area, float aspect_ratio) { + float scale = std::min(static_cast(window_area.GetWidth()), window_area.GetHeight() / aspect_ratio); + return Common::Rectangle{0, 0, static_cast(std::round(scale)), static_cast(std::round(scale * aspect_ratio))}; } FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool swapped) { FramebufferLayout res{width, height, true, true, {}, {}}; // Default layout gives equal screen sizes to the top and bottom screen - Common::Rectangle screen_window_area{0, 0, width, height / 2}; - Common::Rectangle top_screen = maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO); - Common::Rectangle bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO); + Common::Rectangle screen_area{0, 0, width, height / 2}; + Common::Rectangle top_screen = maxRectangle(screen_area, TOP_SCREEN_ASPECT_RATIO); + Common::Rectangle bot_screen = maxRectangle(screen_area, BOT_SCREEN_ASPECT_RATIO); float window_aspect_ratio = static_cast(height) / width; // both screens height are taken into account by multiplying by 2 @@ -42,18 +37,16 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool swapped) { if (window_aspect_ratio < emulation_aspect_ratio) { // Apply borders to the left and right sides of the window. - top_screen = - top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2); - bot_screen = - bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2); + top_screen = top_screen.TranslateX((screen_area.GetWidth() - top_screen.GetWidth()) / 2); + bot_screen = bot_screen.TranslateX((screen_area.GetWidth() - bot_screen.GetWidth()) / 2); // Move the top screen to the bottom if we are swapped. res.top_screen = swapped ? top_screen.TranslateY(height / 2) : top_screen; res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateY(height / 2); } else { // Window is narrower than the emulation content => apply borders to the top and bottom // Recalculate the bottom screen to account for the width difference between top and bottom - screen_window_area = {0, 0, width, top_screen.GetHeight()}; - bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO); + screen_area = {0, 0, width, top_screen.GetHeight()}; + bot_screen = maxRectangle(screen_area, BOT_SCREEN_ASPECT_RATIO); bot_screen = bot_screen.TranslateX((top_screen.GetWidth() - bot_screen.GetWidth()) / 2); if (swapped) { res.top_screen = top_screen.TranslateY(bot_screen.GetHeight()); @@ -71,18 +64,16 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped) { // so just calculate them both even if the other isn't showing. FramebufferLayout res{width, height, !swapped, swapped, {}, {}}; - Common::Rectangle screen_window_area{0, 0, width, height}; - Common::Rectangle top_screen = maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO); - Common::Rectangle bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO); + Common::Rectangle screen_area{0, 0, width, height}; + Common::Rectangle top_screen = maxRectangle(screen_area, TOP_SCREEN_ASPECT_RATIO); + Common::Rectangle bot_screen = maxRectangle(screen_area, BOT_SCREEN_ASPECT_RATIO); float window_aspect_ratio = static_cast(height) / width; float emulation_aspect_ratio = (swapped) ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO; if (window_aspect_ratio < emulation_aspect_ratio) { - top_screen = - top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2); - bot_screen = - bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2); + top_screen = top_screen.TranslateX((screen_area.GetWidth() - top_screen.GetWidth()) / 2); + bot_screen = bot_screen.TranslateX((screen_area.GetWidth() - bot_screen.GetWidth()) / 2); } else { top_screen = top_screen.TranslateY((height - top_screen.GetHeight()) / 2); bot_screen = bot_screen.TranslateY((height - bot_screen.GetHeight()) / 2); @@ -98,28 +89,24 @@ FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped) { // To do that, find the total emulation box and maximize that based on window size float window_aspect_ratio = static_cast(height) / width; float emulation_aspect_ratio = - swapped ? Core::kScreenBottomHeight * 4 / - (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth) - : Core::kScreenTopHeight * 4 / - (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth); + swapped ? Core::kScreenBottomHeight * 4 / (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth) + : Core::kScreenTopHeight * 4 / (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth); float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO; float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO; - Common::Rectangle screen_window_area{0, 0, width, height}; - Common::Rectangle total_rect = maxRectangle(screen_window_area, emulation_aspect_ratio); + Common::Rectangle screen_area{0, 0, width, height}; + Common::Rectangle total_rect = maxRectangle(screen_area, emulation_aspect_ratio); Common::Rectangle large_screen = maxRectangle(total_rect, large_screen_aspect_ratio); Common::Rectangle fourth_size_rect = total_rect.Scale(.25f); Common::Rectangle small_screen = maxRectangle(fourth_size_rect, small_screen_aspect_ratio); if (window_aspect_ratio < emulation_aspect_ratio) { - large_screen = - large_screen.TranslateX((screen_window_area.GetWidth() - total_rect.GetWidth()) / 2); + large_screen = large_screen.TranslateX((screen_area.GetWidth() - total_rect.GetWidth()) / 2); } else { large_screen = large_screen.TranslateY((height - total_rect.GetHeight()) / 2); } // Shift the small screen to the bottom right corner - small_screen = small_screen.TranslateX(large_screen.right) - .TranslateY(large_screen.top + small_screen.GetHeight() / 2); + small_screen = small_screen.TranslateX(large_screen.right).TranslateY(large_screen.top + small_screen.GetHeight() / 2); res.top_screen = swapped ? small_screen : large_screen; res.bottom_screen = swapped ? large_screen : small_screen; return res; @@ -130,34 +117,29 @@ FramebufferLayout SideFrameLayout(u32 width, u32 height, bool swapped) { const float window_aspect_ratio = static_cast(height) / width; if (height > width + width / 2) { - Common::Rectangle screen_window_area{0, 0, width, height}; - Common::Rectangle top_screen = - maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO); - Common::Rectangle bot_screen = Common::Rectangle{ - top_screen.left, top_screen.top, top_screen.right, - static_cast(top_screen.GetHeight() / BOT_SCREEN_ASPECT_RATIO)}; + Common::Rectangle screen_area{0, 0, width, height}; + Common::Rectangle top_screen = maxRectangle(screen_area, TOP_SCREEN_ASPECT_RATIO); + Common::Rectangle bot_screen{top_screen.left, top_screen.top, top_screen.right, static_cast(top_screen.GetWidth() * BOT_SCREEN_ASPECT_RATIO)}; res.top_screen = swapped ? top_screen.TranslateY(bot_screen.GetHeight()) : top_screen; res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateY(top_screen.GetHeight()); } else { // Aspect ratio of both screens side by side - const float emulation_aspect_ratio = static_cast(Core::kScreenTopHeight) / - (Core::kScreenTopWidth + Core::kScreenBottomWidth); - Common::Rectangle screen_window_area{0, 0, width, height}; + const float emulation_aspect_ratio = static_cast(Core::kScreenTopHeight) / (Core::kScreenTopWidth + Core::kScreenBottomWidth); + Common::Rectangle screen_area{0, 0, width, height}; // Find largest Rectangle that can fit in the window size with the given aspect ratio - Common::Rectangle screen_rect = - maxRectangle(screen_window_area, emulation_aspect_ratio); + Common::Rectangle screen_rect = maxRectangle(screen_area, emulation_aspect_ratio); // Find sizes of top and bottom screen Common::Rectangle top_screen = maxRectangle(screen_rect, TOP_SCREEN_ASPECT_RATIO); Common::Rectangle bot_screen = maxRectangle(screen_rect, BOT_SCREEN_ASPECT_RATIO); if (window_aspect_ratio < emulation_aspect_ratio) { // Apply borders to the left and right sides of the window. - u32 shift_horizontal = (screen_window_area.GetWidth() - screen_rect.GetWidth()) / 2; + u32 shift_horizontal = (screen_area.GetWidth() - screen_rect.GetWidth()) / 2; top_screen = top_screen.TranslateX(shift_horizontal); bot_screen = bot_screen.TranslateX(shift_horizontal); } else { // Window is narrower than the emulation content => apply borders to the top and bottom - u32 shift_vertical = (screen_window_area.GetHeight() - screen_rect.GetHeight()) / 2; + u32 shift_vertical = (screen_area.GetHeight() - screen_rect.GetHeight()) / 2; top_screen = top_screen.TranslateY(shift_vertical); bot_screen = bot_screen.TranslateY(shift_vertical); } diff --git a/src/core/settings.h b/src/core/settings.h index 2142bfd2997..a0952b11398 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -207,6 +207,8 @@ struct Values { bool skip_slow_draw; bool skip_cpu_write; bool skip_texture_copy; + bool skip_load_buffer; + bool merge_framebuffer; bool disable_clip_coef; bool display_transfer_hack; bool stream_buffer_hack;