summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-05-28 01:01:00 -0700
committerGravatar GitHub2017-05-28 01:01:00 -0700
commit4caa2bad9d57c97aa749d3a44f6be6f593bb798b (patch)
treeba001a9832ee8965963d17fd4e93e9222e1153de /src/core
parentMerge pull request #2732 from yuriks/add-fmt (diff)
parentCMake: Correct inter-module dependencies and library visibility (diff)
downloadyuzu-4caa2bad9d57c97aa749d3a44f6be6f593bb798b.tar.gz
yuzu-4caa2bad9d57c97aa749d3a44f6be6f593bb798b.tar.xz
yuzu-4caa2bad9d57c97aa749d3a44f6be6f593bb798b.zip
Merge pull request #2733 from yuriks/cmake-cleanup
Dependencies and build system cleanup
Diffstat (limited to 'src/core')
-rw-r--r--src/core/3ds.h21
-rw-r--r--src/core/CMakeLists.txt7
-rw-r--r--src/core/frontend/emu_window.cpp8
-rw-r--r--src/core/frontend/emu_window.h2
-rw-r--r--src/core/frontend/framebuffer_layout.cpp161
-rw-r--r--src/core/frontend/framebuffer_layout.h64
-rw-r--r--src/core/hle/applets/mii_selector.cpp1
-rw-r--r--src/core/hle/applets/swkbd.cpp1
-rw-r--r--src/core/hle/service/gsp_gpu.cpp2
-rw-r--r--src/core/settings.cpp2
-rw-r--r--src/core/tracer/recorder.cpp2
-rw-r--r--src/core/tracer/recorder.h2
12 files changed, 259 insertions, 14 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 @@
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 b19335fe1..7aa81e885 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -32,6 +32,7 @@ set(SRCS
32 frontend/camera/factory.cpp 32 frontend/camera/factory.cpp
33 frontend/camera/interface.cpp 33 frontend/camera/interface.cpp
34 frontend/emu_window.cpp 34 frontend/emu_window.cpp
35 frontend/framebuffer_layout.cpp
35 frontend/motion_emu.cpp 36 frontend/motion_emu.cpp
36 gdbstub/gdbstub.cpp 37 gdbstub/gdbstub.cpp
37 hle/config_mem.cpp 38 hle/config_mem.cpp
@@ -178,6 +179,7 @@ set(SRCS
178 ) 179 )
179 180
180set(HEADERS 181set(HEADERS
182 3ds.h
181 arm/arm_interface.h 183 arm/arm_interface.h
182 arm/dynarmic/arm_dynarmic.h 184 arm/dynarmic/arm_dynarmic.h
183 arm/dynarmic/arm_dynarmic_cp15.h 185 arm/dynarmic/arm_dynarmic_cp15.h
@@ -216,6 +218,7 @@ set(HEADERS
216 frontend/camera/factory.h 218 frontend/camera/factory.h
217 frontend/camera/interface.h 219 frontend/camera/interface.h
218 frontend/emu_window.h 220 frontend/emu_window.h
221 frontend/framebuffer_layout.h
219 frontend/input.h 222 frontend/input.h
220 frontend/motion_emu.h 223 frontend/motion_emu.h
221 gdbstub/gdbstub.h 224 gdbstub/gdbstub.h
@@ -377,5 +380,5 @@ include_directories(../../externals/cryptopp)
377create_directory_groups(${SRCS} ${HEADERS}) 380create_directory_groups(${SRCS} ${HEADERS})
378 381
379add_library(core STATIC ${SRCS} ${HEADERS}) 382add_library(core STATIC ${SRCS} ${HEADERS})
380 383target_link_libraries(core PUBLIC common PRIVATE audio_core video_core)
381target_link_libraries(core dynarmic cryptopp) 384target_link_libraries(core PRIVATE cryptopp dynarmic)
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/emu_window.h b/src/core/frontend/emu_window.h
index 36f2667fa..9414123a4 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -8,8 +8,8 @@
8#include <tuple> 8#include <tuple>
9#include <utility> 9#include <utility>
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/framebuffer_layout.h"
12#include "common/math_util.h" 11#include "common/math_util.h"
12#include "core/frontend/framebuffer_layout.h"
13 13
14/** 14/**
15 * Abstraction class used to provide an interface between emulation code and the frontend 15 * Abstraction class used to provide an interface between emulation code and the frontend
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
new file mode 100644
index 000000000..d2d02f9ff
--- /dev/null
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -0,0 +1,161 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <cmath>
6
7#include "common/assert.h"
8#include "core/3ds.h"
9#include "core/frontend/framebuffer_layout.h"
10#include "core/settings.h"
11
12namespace Layout {
13
14static const float TOP_SCREEN_ASPECT_RATIO =
15 static_cast<float>(Core::kScreenTopHeight) / Core::kScreenTopWidth;
16static const float BOT_SCREEN_ASPECT_RATIO =
17 static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
18
19float FramebufferLayout::GetScalingRatio() const {
20 return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
21}
22
23// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
24template <class T>
25static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area,
26 float screen_aspect_ratio) {
27 float scale = std::min(static_cast<float>(window_area.GetWidth()),
28 window_area.GetHeight() / screen_aspect_ratio);
29 return MathUtil::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)),
30 static_cast<T>(std::round(scale * screen_aspect_ratio))};
31}
32
33FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swapped) {
34 ASSERT(width > 0);
35 ASSERT(height > 0);
36
37 FramebufferLayout res{width, height, true, true, {}, {}};
38 // Default layout gives equal screen sizes to the top and bottom screen
39 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height / 2};
40 MathUtil::Rectangle<unsigned> top_screen =
41 maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
42 MathUtil::Rectangle<unsigned> bot_screen =
43 maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
44
45 float window_aspect_ratio = static_cast<float>(height) / width;
46 // both screens height are taken into account by multiplying by 2
47 float emulation_aspect_ratio = TOP_SCREEN_ASPECT_RATIO * 2;
48
49 if (window_aspect_ratio < emulation_aspect_ratio) {
50 // Apply borders to the left and right sides of the window.
51 top_screen =
52 top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
53 bot_screen =
54 bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
55 } else {
56 // Window is narrower than the emulation content => apply borders to the top and bottom
57 // Recalculate the bottom screen to account for the width difference between top and bottom
58 screen_window_area = {0, 0, width, top_screen.GetHeight()};
59 bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
60 bot_screen = bot_screen.TranslateX((top_screen.GetWidth() - bot_screen.GetWidth()) / 2);
61 if (swapped) {
62 bot_screen = bot_screen.TranslateY(height / 2 - bot_screen.GetHeight());
63 } else {
64 top_screen = top_screen.TranslateY(height / 2 - top_screen.GetHeight());
65 }
66 }
67 // Move the top screen to the bottom if we are swapped.
68 res.top_screen = swapped ? top_screen.TranslateY(height / 2) : top_screen;
69 res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateY(height / 2);
70 return res;
71}
72
73FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool swapped) {
74 ASSERT(width > 0);
75 ASSERT(height > 0);
76 // The drawing code needs at least somewhat valid values for both screens
77 // so just calculate them both even if the other isn't showing.
78 FramebufferLayout res{width, height, !swapped, swapped, {}, {}};
79
80 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
81 MathUtil::Rectangle<unsigned> top_screen =
82 maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
83 MathUtil::Rectangle<unsigned> bot_screen =
84 maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
85
86 float window_aspect_ratio = static_cast<float>(height) / width;
87 float emulation_aspect_ratio = (swapped) ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
88
89 if (window_aspect_ratio < emulation_aspect_ratio) {
90 top_screen =
91 top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
92 bot_screen =
93 bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
94 } else {
95 top_screen = top_screen.TranslateY((height - top_screen.GetHeight()) / 2);
96 bot_screen = bot_screen.TranslateY((height - bot_screen.GetHeight()) / 2);
97 }
98 res.top_screen = top_screen;
99 res.bottom_screen = bot_screen;
100 return res;
101}
102
103FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped) {
104 ASSERT(width > 0);
105 ASSERT(height > 0);
106
107 FramebufferLayout res{width, height, true, true, {}, {}};
108 // Split the window into two parts. Give 4x width to the main screen and 1x width to the small
109 // To do that, find the total emulation box and maximize that based on window size
110 float window_aspect_ratio = static_cast<float>(height) / width;
111 float emulation_aspect_ratio =
112 swapped
113 ? Core::kScreenBottomHeight * 4 /
114 (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth)
115 : Core::kScreenTopHeight * 4 /
116 (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth);
117 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
118 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
119
120 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
121 MathUtil::Rectangle<unsigned> total_rect =
122 maxRectangle(screen_window_area, emulation_aspect_ratio);
123 MathUtil::Rectangle<unsigned> large_screen =
124 maxRectangle(total_rect, large_screen_aspect_ratio);
125 MathUtil::Rectangle<unsigned> fourth_size_rect = total_rect.Scale(.25f);
126 MathUtil::Rectangle<unsigned> small_screen =
127 maxRectangle(fourth_size_rect, small_screen_aspect_ratio);
128
129 if (window_aspect_ratio < emulation_aspect_ratio) {
130 large_screen =
131 large_screen.TranslateX((screen_window_area.GetWidth() - total_rect.GetWidth()) / 2);
132 } else {
133 large_screen = large_screen.TranslateY((height - total_rect.GetHeight()) / 2);
134 }
135 // Shift the small screen to the bottom right corner
136 small_screen =
137 small_screen.TranslateX(large_screen.right)
138 .TranslateY(large_screen.GetHeight() + large_screen.top - small_screen.GetHeight());
139 res.top_screen = swapped ? small_screen : large_screen;
140 res.bottom_screen = swapped ? large_screen : small_screen;
141 return res;
142}
143
144FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) {
145 ASSERT(width > 0);
146 ASSERT(height > 0);
147
148 FramebufferLayout res{width, height, true, true, {}, {}};
149
150 MathUtil::Rectangle<unsigned> top_screen{
151 Settings::values.custom_top_left, Settings::values.custom_top_top,
152 Settings::values.custom_top_right, Settings::values.custom_top_bottom};
153 MathUtil::Rectangle<unsigned> bot_screen{
154 Settings::values.custom_bottom_left, Settings::values.custom_bottom_top,
155 Settings::values.custom_bottom_right, Settings::values.custom_bottom_bottom};
156
157 res.top_screen = top_screen;
158 res.bottom_screen = bot_screen;
159 return res;
160}
161}
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
new file mode 100644
index 000000000..9a7738969
--- /dev/null
+++ b/src/core/frontend/framebuffer_layout.h
@@ -0,0 +1,64 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/math_util.h"
8
9namespace Layout {
10
11/// Describes the layout of the window framebuffer (size and top/bottom screen positions)
12struct FramebufferLayout {
13 unsigned width;
14 unsigned height;
15 bool top_screen_enabled;
16 bool bottom_screen_enabled;
17 MathUtil::Rectangle<unsigned> top_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;
25};
26
27/**
28 * Factory method for constructing a default FramebufferLayout
29 * @param width Window framebuffer width in pixels
30 * @param height Window framebuffer height in pixels
31 * @param is_swapped if true, the bottom screen will be displayed above the top screen
32 * @return Newly created FramebufferLayout object with default screen regions initialized
33 */
34FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped);
35
36/**
37 * Factory method for constructing a FramebufferLayout with only the top or bottom screen
38 * @param width Window framebuffer width in pixels
39 * @param height Window framebuffer height in pixels
40 * @param is_swapped if true, the bottom screen will be displayed (and the top won't be displayed)
41 * @return Newly created FramebufferLayout object with default screen regions initialized
42 */
43FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped);
44
45/**
46 * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom
47 * screen on the right
48 * This is useful in particular because it matches well with a 1920x1080 resolution monitor
49 * @param width Window framebuffer width in pixels
50 * @param height Window framebuffer height in pixels
51 * @param is_swapped if true, the bottom screen will be the large display
52 * @return Newly created FramebufferLayout object with default screen regions initialized
53 */
54FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped);
55
56/**
57 * Factory method for constructing a custom FramebufferLayout
58 * @param width Window framebuffer width in pixels
59 * @param height Window framebuffer height in pixels
60 * @return Newly created FramebufferLayout object with default screen regions initialized
61 */
62FramebufferLayout CustomFrameLayout(unsigned width, unsigned height);
63
64} // namespace Layout
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
index 07c7f5b99..89f08daa2 100644
--- a/src/core/hle/applets/mii_selector.cpp
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -11,7 +11,6 @@
11#include "core/hle/kernel/kernel.h" 11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/shared_memory.h" 12#include "core/hle/kernel/shared_memory.h"
13#include "core/hle/result.h" 13#include "core/hle/result.h"
14#include "video_core/video_core.h"
15 14
16//////////////////////////////////////////////////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////////////////////////////////////////////////
17 16
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
index 059297fbc..fdf8807b0 100644
--- a/src/core/hle/applets/swkbd.cpp
+++ b/src/core/hle/applets/swkbd.cpp
@@ -14,7 +14,6 @@
14#include "core/hle/service/gsp_gpu.h" 14#include "core/hle/service/gsp_gpu.h"
15#include "core/hle/service/hid/hid.h" 15#include "core/hle/service/hid/hid.h"
16#include "core/memory.h" 16#include "core/memory.h"
17#include "video_core/video_core.h"
18 17
19//////////////////////////////////////////////////////////////////////////////////////////////////// 18////////////////////////////////////////////////////////////////////////////////////////////////////
20 19
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index 46c4ed01a..94f6b8a9c 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -8,11 +8,11 @@
8#include "core/hle/kernel/event.h" 8#include "core/hle/kernel/event.h"
9#include "core/hle/kernel/shared_memory.h" 9#include "core/hle/kernel/shared_memory.h"
10#include "core/hle/result.h" 10#include "core/hle/result.h"
11#include "core/hle/service/gsp_gpu.h"
11#include "core/hw/gpu.h" 12#include "core/hw/gpu.h"
12#include "core/hw/hw.h" 13#include "core/hw/hw.h"
13#include "core/hw/lcd.h" 14#include "core/hw/lcd.h"
14#include "core/memory.h" 15#include "core/memory.h"
15#include "gsp_gpu.h"
16#include "video_core/debug_utils/debug_utils.h" 16#include "video_core/debug_utils/debug_utils.h"
17#include "video_core/gpu_debugger.h" 17#include "video_core/gpu_debugger.h"
18 18
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index d2e7c6b97..d4f0429d1 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -6,7 +6,7 @@
6#include "core/gdbstub/gdbstub.h" 6#include "core/gdbstub/gdbstub.h"
7#include "core/hle/service/hid/hid.h" 7#include "core/hle/service/hid/hid.h"
8#include "core/hle/service/ir/ir.h" 8#include "core/hle/service/ir/ir.h"
9#include "settings.h" 9#include "core/settings.h"
10#include "video_core/video_core.h" 10#include "video_core/video_core.h"
11 11
12#include "core/frontend/emu_window.h" 12#include "core/frontend/emu_window.h"
diff --git a/src/core/tracer/recorder.cpp b/src/core/tracer/recorder.cpp
index 276a5b288..55b3b5efc 100644
--- a/src/core/tracer/recorder.cpp
+++ b/src/core/tracer/recorder.cpp
@@ -6,7 +6,7 @@
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/file_util.h" 7#include "common/file_util.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "recorder.h" 9#include "core/tracer/recorder.h"
10 10
11namespace CiTrace { 11namespace CiTrace {
12 12
diff --git a/src/core/tracer/recorder.h b/src/core/tracer/recorder.h
index aea363b95..39e6ec4fd 100644
--- a/src/core/tracer/recorder.h
+++ b/src/core/tracer/recorder.h
@@ -8,8 +8,8 @@
8#include <unordered_map> 8#include <unordered_map>
9#include <vector> 9#include <vector>
10#include <boost/crc.hpp> 10#include <boost/crc.hpp>
11#include "citrace.h"
12#include "common/common_types.h" 11#include "common/common_types.h"
12#include "core/tracer/citrace.h"
13 13
14namespace CiTrace { 14namespace CiTrace {
15 15