summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-05-28 03:06:59 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-05-28 03:41:24 +0200
commiteb10f250254a0153abd789e49a36945d996631a7 (patch)
tree5f7a0e290892f1137ccd28420991ef7981377cf6 /src/core
parentOpenGL: Remove unused RendererOpenGL fields (diff)
downloadyuzu-eb10f250254a0153abd789e49a36945d996631a7.tar
yuzu-eb10f250254a0153abd789e49a36945d996631a7.tar.gz
yuzu-eb10f250254a0153abd789e49a36945d996631a7.tar.bz2
yuzu-eb10f250254a0153abd789e49a36945d996631a7.tar.lz
yuzu-eb10f250254a0153abd789e49a36945d996631a7.tar.xz
yuzu-eb10f250254a0153abd789e49a36945d996631a7.tar.zst
yuzu-eb10f250254a0153abd789e49a36945d996631a7.zip
Diffstat (limited to 'src/core')
-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
5 files changed, 46 insertions, 13 deletions
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 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+namespace Core {
+
+// 3DS Video Constants
+// -------------------
+
+// NOTE: The LCDs actually rotate the image 90 degrees when displaying. Because of that the
+// framebuffers in video memory are stored in column-major order and rendered sideways, causing
+// the widths and heights of the framebuffers read by the LCD to be switched compared to the
+// heights and widths of the screens listed here.
+constexpr int kScreenTopWidth = 400; ///< 3DS top screen width
+constexpr int kScreenTopHeight = 240; ///< 3DS top screen height
+constexpr int kScreenBottomWidth = 320; ///< 3DS bottom screen width
+constexpr int kScreenBottomHeight = 240; ///< 3DS bottom screen height
+
+} // 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
)
set(HEADERS
+ 3ds.h
arm/arm_interface.h
arm/dynarmic/arm_dynarmic.h
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 @@
#include <algorithm>
#include <cmath>
#include "common/assert.h"
+#include "core/3ds.h"
#include "core/core.h"
#include "core/frontend/emu_window.h"
#include "core/settings.h"
-#include "video_core/video_core.h"
/**
* 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) {
if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
return;
- touch_x = VideoCore::kScreenBottomWidth *
- (framebuffer_x - framebuffer_layout.bottom_screen.left) /
+ touch_x = Core::kScreenBottomWidth * (framebuffer_x - framebuffer_layout.bottom_screen.left) /
(framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left);
- touch_y = VideoCore::kScreenBottomHeight *
- (framebuffer_y - framebuffer_layout.bottom_screen.top) /
+ touch_y = Core::kScreenBottomHeight * (framebuffer_y - framebuffer_layout.bottom_screen.top) /
(framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);
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 @@
#include <cmath>
#include "common/assert.h"
+#include "core/3ds.h"
#include "core/frontend/framebuffer_layout.h"
#include "core/settings.h"
-#include "video_core/video_core.h"
namespace Layout {
static const float TOP_SCREEN_ASPECT_RATIO =
- static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth;
+ static_cast<float>(Core::kScreenTopHeight) / Core::kScreenTopWidth;
static const float BOT_SCREEN_ASPECT_RATIO =
- static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth;
+ static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
+
+float FramebufferLayout::GetScalingRatio() const {
+ return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
+}
// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
template <class T>
@@ -106,10 +110,10 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped
float window_aspect_ratio = static_cast<float>(height) / width;
float emulation_aspect_ratio =
swapped
- ? VideoCore::kScreenBottomHeight * 4 /
- (VideoCore::kScreenBottomWidth * 4.0f + VideoCore::kScreenTopWidth)
- : VideoCore::kScreenTopHeight * 4 /
- (VideoCore::kScreenTopWidth * 4.0f + VideoCore::kScreenBottomWidth);
+ ? 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;
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 @@
#pragma once
#include "common/math_util.h"
+
namespace Layout {
+
/// Describes the layout of the window framebuffer (size and top/bottom screen positions)
struct FramebufferLayout {
unsigned width;
@@ -14,6 +16,12 @@ struct FramebufferLayout {
bool bottom_screen_enabled;
MathUtil::Rectangle<unsigned> top_screen;
MathUtil::Rectangle<unsigned> bottom_screen;
+
+ /**
+ * Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
+ * screen.
+ */
+ float GetScalingRatio() const;
};
/**
@@ -52,4 +60,5 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swap
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout CustomFrameLayout(unsigned width, unsigned height);
-}
+
+} // namespace Layout