summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp14
-rw-r--r--src/citra_qt/bootmanager.cpp6
-rw-r--r--src/core/3ds.h21
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/frontend/emu_window.cpp8
-rw-r--r--src/core/frontend/framebuffer_layout.cpp18
-rw-r--r--src/core/frontend/framebuffer_layout.h11
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp20
-rw-r--r--src/video_core/video_core.h15
9 files changed, 63 insertions, 51 deletions
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp
index 6bc0b0d00..47aadd60c 100644
--- a/src/citra/emu_window/emu_window_sdl2.cpp
+++ b/src/citra/emu_window/emu_window_sdl2.cpp
@@ -12,10 +12,10 @@
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "common/scm_rev.h" 13#include "common/scm_rev.h"
14#include "common/string_util.h" 14#include "common/string_util.h"
15#include "core/3ds.h"
15#include "core/settings.h" 16#include "core/settings.h"
16#include "input_common/keyboard.h" 17#include "input_common/keyboard.h"
17#include "input_common/main.h" 18#include "input_common/main.h"
18#include "video_core/video_core.h"
19 19
20void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { 20void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
21 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); 21 TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
@@ -80,12 +80,12 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
80 80
81 std::string window_title = Common::StringFromFormat("Citra %s| %s-%s ", Common::g_build_name, 81 std::string window_title = Common::StringFromFormat("Citra %s| %s-%s ", Common::g_build_name,
82 Common::g_scm_branch, Common::g_scm_desc); 82 Common::g_scm_branch, Common::g_scm_desc);
83 render_window = SDL_CreateWindow( 83 render_window =
84 window_title.c_str(), 84 SDL_CreateWindow(window_title.c_str(),
85 SDL_WINDOWPOS_UNDEFINED, // x position 85 SDL_WINDOWPOS_UNDEFINED, // x position
86 SDL_WINDOWPOS_UNDEFINED, // y position 86 SDL_WINDOWPOS_UNDEFINED, // y position
87 VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight, 87 Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight,
88 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); 88 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
89 89
90 if (render_window == nullptr) { 90 if (render_window == nullptr) {
91 LOG_CRITICAL(Frontend, "Failed to create SDL2 window! Exiting..."); 91 LOG_CRITICAL(Frontend, "Failed to create SDL2 window! Exiting...");
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index bae576d6a..06b62f44c 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -12,12 +12,11 @@
12#include "common/microprofile.h" 12#include "common/microprofile.h"
13#include "common/scm_rev.h" 13#include "common/scm_rev.h"
14#include "common/string_util.h" 14#include "common/string_util.h"
15#include "core/3ds.h"
15#include "core/core.h" 16#include "core/core.h"
16#include "core/settings.h" 17#include "core/settings.h"
17#include "input_common/keyboard.h" 18#include "input_common/keyboard.h"
18#include "input_common/main.h" 19#include "input_common/main.h"
19#include "video_core/debug_utils/debug_utils.h"
20#include "video_core/video_core.h"
21 20
22EmuThread::EmuThread(GRenderWindow* render_window) 21EmuThread::EmuThread(GRenderWindow* render_window)
23 : exec_step(false), running(false), stop_run(false), render_window(render_window) {} 22 : exec_step(false), running(false), stop_run(false), render_window(render_window) {}
@@ -266,8 +265,7 @@ void GRenderWindow::InitRenderTarget() {
266 child = new GGLWidgetInternal(fmt, this); 265 child = new GGLWidgetInternal(fmt, this);
267 QBoxLayout* layout = new QHBoxLayout(this); 266 QBoxLayout* layout = new QHBoxLayout(this);
268 267
269 resize(VideoCore::kScreenTopWidth, 268 resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
270 VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
271 layout->addWidget(child); 269 layout->addWidget(child);
272 layout->setMargin(0); 270 layout->setMargin(0);
273 setLayout(layout); 271 setLayout(layout);
diff --git a/src/core/3ds.h b/src/core/3ds.h
new file mode 100644
index 000000000..8715e27db
--- /dev/null
+++ b/src/core/3ds.h
@@ -0,0 +1,21 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace Core {
8
9// 3DS Video Constants
10// -------------------
11
12// NOTE: The LCDs actually rotate the image 90 degrees when displaying. Because of that the
13// framebuffers in video memory are stored in column-major order and rendered sideways, causing
14// the widths and heights of the framebuffers read by the LCD to be switched compared to the
15// heights and widths of the screens listed here.
16constexpr int kScreenTopWidth = 400; ///< 3DS top screen width
17constexpr int kScreenTopHeight = 240; ///< 3DS top screen height
18constexpr int kScreenBottomWidth = 320; ///< 3DS bottom screen width
19constexpr int kScreenBottomHeight = 240; ///< 3DS bottom screen height
20
21} // namespace Core
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index d9618c40c..cbfd1299c 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -179,6 +179,7 @@ set(SRCS
179 ) 179 )
180 180
181set(HEADERS 181set(HEADERS
182 3ds.h
182 arm/arm_interface.h 183 arm/arm_interface.h
183 arm/dynarmic/arm_dynarmic.h 184 arm/dynarmic/arm_dynarmic.h
184 arm/dynarmic/arm_dynarmic_cp15.h 185 arm/dynarmic/arm_dynarmic_cp15.h
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index 5fdb3a7e8..4f7d54a33 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -5,10 +5,10 @@
5#include <algorithm> 5#include <algorithm>
6#include <cmath> 6#include <cmath>
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/3ds.h"
8#include "core/core.h" 9#include "core/core.h"
9#include "core/frontend/emu_window.h" 10#include "core/frontend/emu_window.h"
10#include "core/settings.h" 11#include "core/settings.h"
11#include "video_core/video_core.h"
12 12
13/** 13/**
14 * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout 14 * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
@@ -38,11 +38,9 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
38 if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) 38 if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
39 return; 39 return;
40 40
41 touch_x = VideoCore::kScreenBottomWidth * 41 touch_x = Core::kScreenBottomWidth * (framebuffer_x - framebuffer_layout.bottom_screen.left) /
42 (framebuffer_x - framebuffer_layout.bottom_screen.left) /
43 (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); 42 (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left);
44 touch_y = VideoCore::kScreenBottomHeight * 43 touch_y = Core::kScreenBottomHeight * (framebuffer_y - framebuffer_layout.bottom_screen.top) /
45 (framebuffer_y - framebuffer_layout.bottom_screen.top) /
46 (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); 44 (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);
47 45
48 touch_pressed = true; 46 touch_pressed = true;
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index f3815170d..d2d02f9ff 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -5,16 +5,20 @@
5#include <cmath> 5#include <cmath>
6 6
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/3ds.h"
8#include "core/frontend/framebuffer_layout.h" 9#include "core/frontend/framebuffer_layout.h"
9#include "core/settings.h" 10#include "core/settings.h"
10#include "video_core/video_core.h"
11 11
12namespace Layout { 12namespace Layout {
13 13
14static const float TOP_SCREEN_ASPECT_RATIO = 14static const float TOP_SCREEN_ASPECT_RATIO =
15 static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth; 15 static_cast<float>(Core::kScreenTopHeight) / Core::kScreenTopWidth;
16static const float BOT_SCREEN_ASPECT_RATIO = 16static const float BOT_SCREEN_ASPECT_RATIO =
17 static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth; 17 static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
18
19float FramebufferLayout::GetScalingRatio() const {
20 return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
21}
18 22
19// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio 23// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
20template <class T> 24template <class T>
@@ -106,10 +110,10 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped
106 float window_aspect_ratio = static_cast<float>(height) / width; 110 float window_aspect_ratio = static_cast<float>(height) / width;
107 float emulation_aspect_ratio = 111 float emulation_aspect_ratio =
108 swapped 112 swapped
109 ? VideoCore::kScreenBottomHeight * 4 / 113 ? Core::kScreenBottomHeight * 4 /
110 (VideoCore::kScreenBottomWidth * 4.0f + VideoCore::kScreenTopWidth) 114 (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth)
111 : VideoCore::kScreenTopHeight * 4 / 115 : Core::kScreenTopHeight * 4 /
112 (VideoCore::kScreenTopWidth * 4.0f + VideoCore::kScreenBottomWidth); 116 (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth);
113 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO; 117 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
114 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO; 118 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
115 119
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
index f1df5c55a..9a7738969 100644
--- a/src/core/frontend/framebuffer_layout.h
+++ b/src/core/frontend/framebuffer_layout.h
@@ -5,7 +5,9 @@
5#pragma once 5#pragma once
6 6
7#include "common/math_util.h" 7#include "common/math_util.h"
8
8namespace Layout { 9namespace Layout {
10
9/// Describes the layout of the window framebuffer (size and top/bottom screen positions) 11/// Describes the layout of the window framebuffer (size and top/bottom screen positions)
10struct FramebufferLayout { 12struct FramebufferLayout {
11 unsigned width; 13 unsigned width;
@@ -14,6 +16,12 @@ struct FramebufferLayout {
14 bool bottom_screen_enabled; 16 bool bottom_screen_enabled;
15 MathUtil::Rectangle<unsigned> top_screen; 17 MathUtil::Rectangle<unsigned> top_screen;
16 MathUtil::Rectangle<unsigned> bottom_screen; 18 MathUtil::Rectangle<unsigned> bottom_screen;
19
20 /**
21 * Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
22 * screen.
23 */
24 float GetScalingRatio() const;
17}; 25};
18 26
19/** 27/**
@@ -52,4 +60,5 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swap
52 * @return Newly created FramebufferLayout object with default screen regions initialized 60 * @return Newly created FramebufferLayout object with default screen regions initialized
53 */ 61 */
54FramebufferLayout CustomFrameLayout(unsigned width, unsigned height); 62FramebufferLayout CustomFrameLayout(unsigned width, unsigned height);
55} 63
64} // namespace Layout
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 456443e86..8b717e43d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -561,20 +561,16 @@ RasterizerCacheOpenGL::GetFramebufferSurfaces(
561 color_params.is_tiled = depth_params.is_tiled = true; 561 color_params.is_tiled = depth_params.is_tiled = true;
562 562
563 // Set the internal resolution, assume the same scaling factor for top and bottom screens 563 // Set the internal resolution, assume the same scaling factor for top and bottom screens
564 const Layout::FramebufferLayout& layout = VideoCore::g_emu_window->GetFramebufferLayout(); 564 float resolution_scale_factor = Settings::values.resolution_factor;
565 if (Settings::values.resolution_factor == 0.0f) { 565 if (resolution_scale_factor == 0.0f) {
566 // Auto - scale resolution to the window size 566 // Auto - scale resolution to the window size
567 color_params.res_scale_width = depth_params.res_scale_width = 567 resolution_scale_factor = VideoCore::g_emu_window->GetFramebufferLayout().GetScalingRatio();
568 (float)layout.top_screen.GetWidth() / VideoCore::kScreenTopWidth;
569 color_params.res_scale_height = depth_params.res_scale_height =
570 (float)layout.top_screen.GetHeight() / VideoCore::kScreenTopHeight;
571 } else {
572 // Otherwise, scale the resolution by the specified factor
573 color_params.res_scale_width = Settings::values.resolution_factor;
574 depth_params.res_scale_width = Settings::values.resolution_factor;
575 color_params.res_scale_height = Settings::values.resolution_factor;
576 depth_params.res_scale_height = Settings::values.resolution_factor;
577 } 568 }
569 // Scale the resolution by the specified factor
570 color_params.res_scale_width = resolution_scale_factor;
571 depth_params.res_scale_width = resolution_scale_factor;
572 color_params.res_scale_height = resolution_scale_factor;
573 depth_params.res_scale_height = resolution_scale_factor;
578 574
579 color_params.addr = config.GetColorBufferPhysicalAddress(); 575 color_params.addr = config.GetColorBufferPhysicalAddress();
580 color_params.pixel_format = CachedSurface::PixelFormatFromColorFormat(config.color_format); 576 color_params.pixel_format = CachedSurface::PixelFormatFromColorFormat(config.color_format);
diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h
index 4aba19ca0..94e0867f0 100644
--- a/src/video_core/video_core.h
+++ b/src/video_core/video_core.h
@@ -15,21 +15,6 @@ class RendererBase;
15 15
16namespace VideoCore { 16namespace VideoCore {
17 17
18// 3DS Video Constants
19// -------------------
20
21// NOTE: The LCDs actually rotate the image 90 degrees when displaying. Because of that the
22// framebuffers in video memory are stored in column-major order and rendered sideways, causing
23// the widths and heights of the framebuffers read by the LCD to be switched compared to the
24// heights and widths of the screens listed here.
25static const int kScreenTopWidth = 400; ///< 3DS top screen width
26static const int kScreenTopHeight = 240; ///< 3DS top screen height
27static const int kScreenBottomWidth = 320; ///< 3DS bottom screen width
28static const int kScreenBottomHeight = 240; ///< 3DS bottom screen height
29
30// Video core renderer
31// ---------------------
32
33extern std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin 18extern std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin
34extern EmuWindow* g_emu_window; ///< Emu window 19extern EmuWindow* g_emu_window; ///< Emu window
35 20