summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.travis-build.sh4
-rwxr-xr-x.travis-deps.sh4
-rw-r--r--.travis.yml4
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/audio_core/CMakeLists.txt3
-rw-r--r--src/audio_core/hle/common.h35
-rw-r--r--src/audio_core/hle/dsp.h17
-rw-r--r--src/audio_core/hle/filter.cpp115
-rw-r--r--src/audio_core/hle/filter.h112
-rw-r--r--src/citra/citra.cpp4
-rw-r--r--src/citra/config.cpp7
-rw-r--r--src/citra_qt/game_list.cpp2
-rw-r--r--src/citra_qt/main.cpp12
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/file_util.cpp51
-rw-r--r--src/common/logging/backend.cpp2
-rw-r--r--src/common/logging/log.h2
-rw-r--r--src/common/make_unique.h17
-rw-r--r--src/common/string_util.cpp16
-rw-r--r--src/common/string_util.h2
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp5
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.cpp83
-rw-r--r--src/core/core.cpp5
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp4
-rw-r--r--src/core/file_sys/archive_romfs.cpp3
-rw-r--r--src/core/file_sys/archive_savedata.cpp4
-rw-r--r--src/core/file_sys/archive_savedatacheck.cpp4
-rw-r--r--src/core/file_sys/archive_sdmc.cpp4
-rw-r--r--src/core/file_sys/archive_systemsavedata.cpp4
-rw-r--r--src/core/file_sys/disk_archive.cpp8
-rw-r--r--src/core/file_sys/ivfc_archive.cpp5
-rw-r--r--src/core/hle/kernel/process.cpp3
-rw-r--r--src/core/hle/result.h1
-rw-r--r--src/core/hle/service/cecd/cecd.cpp29
-rw-r--r--src/core/hle/service/cecd/cecd.h23
-rw-r--r--src/core/hle/service/cecd/cecd_u.cpp5
-rw-r--r--src/core/hle/service/cfg/cfg_i.cpp12
-rw-r--r--src/core/hle/service/cfg/cfg_s.cpp8
-rw-r--r--src/core/hle/service/cfg/cfg_u.cpp1
-rw-r--r--src/core/hle/service/dlp_srvr.cpp36
-rw-r--r--src/core/hle/service/dlp_srvr.h23
-rw-r--r--src/core/hle/service/fs/archive.cpp13
-rw-r--r--src/core/hle/service/gsp_gpu.cpp221
-rw-r--r--src/core/hle/service/gsp_gpu.h2
-rw-r--r--src/core/hle/service/service.cpp2
-rw-r--r--src/core/loader/loader.cpp5
-rw-r--r--src/core/loader/ncch.cpp1
-rw-r--r--src/video_core/renderer_base.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp5
-rw-r--r--src/video_core/renderer_opengl/pica_to_gl.h12
-rw-r--r--src/video_core/shader/shader.cpp1
-rw-r--r--src/video_core/video_core.cpp3
54 files changed, 722 insertions, 239 deletions
diff --git a/.travis-build.sh b/.travis-build.sh
index 22a3a9fd6..e06a4299b 100755
--- a/.travis-build.sh
+++ b/.travis-build.sh
@@ -11,8 +11,8 @@ fi
11 11
12#if OS is linux or is not set 12#if OS is linux or is not set
13if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then 13if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
14 export CC=gcc-4.9 14 export CC=gcc-5
15 export CXX=g++-4.9 15 export CXX=g++-5
16 export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH 16 export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH
17 17
18 mkdir build && cd build 18 mkdir build && cd build
diff --git a/.travis-deps.sh b/.travis-deps.sh
index eb99ead4f..c7bb7e785 100755
--- a/.travis-deps.sh
+++ b/.travis-deps.sh
@@ -5,8 +5,8 @@ set -x
5 5
6#if OS is linux or is not set 6#if OS is linux or is not set
7if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then 7if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
8 export CC=gcc-4.9 8 export CC=gcc-5
9 export CXX=g++-4.9 9 export CXX=g++-5
10 mkdir -p $HOME/.local 10 mkdir -p $HOME/.local
11 11
12 curl -L http://www.cmake.org/files/v2.8/cmake-2.8.11-Linux-i386.tar.gz \ 12 curl -L http://www.cmake.org/files/v2.8/cmake-2.8.11-Linux-i386.tar.gz \
diff --git a/.travis.yml b/.travis.yml
index 2e875cccf..8d86baece 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,8 +15,8 @@ addons:
15 sources: 15 sources:
16 - ubuntu-toolchain-r-test 16 - ubuntu-toolchain-r-test
17 packages: 17 packages:
18 - gcc-4.9 18 - gcc-5
19 - g++-4.9 19 - g++-5
20 - xorg-dev 20 - xorg-dev
21 - lib32stdc++6 # For CMake 21 - lib32stdc++6 # For CMake
22 - lftp # To upload builds 22 - lftp # To upload builds
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6a4a915a..3a0a161e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,7 @@ endif()
65message(STATUS "Target architecture: ${ARCHITECTURE}") 65message(STATUS "Target architecture: ${ARCHITECTURE}")
66 66
67if (NOT MSVC) 67if (NOT MSVC)
68 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") 68 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wno-attributes -pthread")
69 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") 69 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
70 70
71 if (ARCHITECTURE_x86_64) 71 if (ARCHITECTURE_x86_64)
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt
index c4bad8cb0..869da5e83 100644
--- a/src/audio_core/CMakeLists.txt
+++ b/src/audio_core/CMakeLists.txt
@@ -2,13 +2,16 @@ set(SRCS
2 audio_core.cpp 2 audio_core.cpp
3 codec.cpp 3 codec.cpp
4 hle/dsp.cpp 4 hle/dsp.cpp
5 hle/filter.cpp
5 hle/pipe.cpp 6 hle/pipe.cpp
6 ) 7 )
7 8
8set(HEADERS 9set(HEADERS
9 audio_core.h 10 audio_core.h
10 codec.h 11 codec.h
12 hle/common.h
11 hle/dsp.h 13 hle/dsp.h
14 hle/filter.h
12 hle/pipe.h 15 hle/pipe.h
13 sink.h 16 sink.h
14 ) 17 )
diff --git a/src/audio_core/hle/common.h b/src/audio_core/hle/common.h
new file mode 100644
index 000000000..37d441eb2
--- /dev/null
+++ b/src/audio_core/hle/common.h
@@ -0,0 +1,35 @@
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 <algorithm>
8#include <array>
9
10#include "audio_core/audio_core.h"
11
12#include "common/common_types.h"
13
14namespace DSP {
15namespace HLE {
16
17/// The final output to the speakers is stereo. Preprocessing output in Source is also stereo.
18using StereoFrame16 = std::array<std::array<s16, 2>, AudioCore::samples_per_frame>;
19
20/// The DSP is quadraphonic internally.
21using QuadFrame32 = std::array<std::array<s32, 4>, AudioCore::samples_per_frame>;
22
23/**
24 * This performs the filter operation defined by FilterT::ProcessSample on the frame in-place.
25 * FilterT::ProcessSample is called sequentially on the samples.
26 */
27template<typename FrameT, typename FilterT>
28void FilterFrame(FrameT& frame, FilterT& filter) {
29 std::transform(frame.begin(), frame.end(), frame.begin(), [&filter](const typename FrameT::value_type& sample) {
30 return filter.ProcessSample(sample);
31 });
32}
33
34} // namespace HLE
35} // namespace DSP
diff --git a/src/audio_core/hle/dsp.h b/src/audio_core/hle/dsp.h
index 376436c29..c15ef0b7a 100644
--- a/src/audio_core/hle/dsp.h
+++ b/src/audio_core/hle/dsp.h
@@ -126,8 +126,11 @@ struct SourceConfiguration {
126 union { 126 union {
127 u32_le dirty_raw; 127 u32_le dirty_raw;
128 128
129 BitField<0, 1, u32_le> format_dirty;
130 BitField<1, 1, u32_le> mono_or_stereo_dirty;
129 BitField<2, 1, u32_le> adpcm_coefficients_dirty; 131 BitField<2, 1, u32_le> adpcm_coefficients_dirty;
130 BitField<3, 1, u32_le> partial_embedded_buffer_dirty; ///< Tends to be set when a looped buffer is queued. 132 BitField<3, 1, u32_le> partial_embedded_buffer_dirty; ///< Tends to be set when a looped buffer is queued.
133 BitField<4, 1, u32_le> partial_reset_flag;
131 134
132 BitField<16, 1, u32_le> enable_dirty; 135 BitField<16, 1, u32_le> enable_dirty;
133 BitField<17, 1, u32_le> interpolation_dirty; 136 BitField<17, 1, u32_le> interpolation_dirty;
@@ -143,8 +146,7 @@ struct SourceConfiguration {
143 BitField<27, 1, u32_le> gain_2_dirty; 146 BitField<27, 1, u32_le> gain_2_dirty;
144 BitField<28, 1, u32_le> sync_dirty; 147 BitField<28, 1, u32_le> sync_dirty;
145 BitField<29, 1, u32_le> reset_flag; 148 BitField<29, 1, u32_le> reset_flag;
146 149 BitField<30, 1, u32_le> embedded_buffer_dirty;
147 BitField<31, 1, u32_le> embedded_buffer_dirty;
148 }; 150 };
149 151
150 // Gain control 152 // Gain control
@@ -175,7 +177,8 @@ struct SourceConfiguration {
175 /** 177 /**
176 * This is the simplest normalized first-order digital recursive filter. 178 * This is the simplest normalized first-order digital recursive filter.
177 * The transfer function of this filter is: 179 * The transfer function of this filter is:
178 * H(z) = b0 / (1 + a1 z^-1) 180 * H(z) = b0 / (1 - a1 z^-1)
181 * Note the feedbackward coefficient is negated.
179 * Values are signed fixed point with 15 fractional bits. 182 * Values are signed fixed point with 15 fractional bits.
180 */ 183 */
181 struct SimpleFilter { 184 struct SimpleFilter {
@@ -192,11 +195,11 @@ struct SourceConfiguration {
192 * Values are signed fixed point with 14 fractional bits. 195 * Values are signed fixed point with 14 fractional bits.
193 */ 196 */
194 struct BiquadFilter { 197 struct BiquadFilter {
195 s16_le b0;
196 s16_le b1;
197 s16_le b2;
198 s16_le a1;
199 s16_le a2; 198 s16_le a2;
199 s16_le a1;
200 s16_le b2;
201 s16_le b1;
202 s16_le b0;
200 }; 203 };
201 204
202 union { 205 union {
diff --git a/src/audio_core/hle/filter.cpp b/src/audio_core/hle/filter.cpp
new file mode 100644
index 000000000..2c65ef026
--- /dev/null
+++ b/src/audio_core/hle/filter.cpp
@@ -0,0 +1,115 @@
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 <array>
6#include <cstddef>
7
8#include "audio_core/hle/common.h"
9#include "audio_core/hle/dsp.h"
10#include "audio_core/hle/filter.h"
11
12#include "common/common_types.h"
13#include "common/math_util.h"
14
15namespace DSP {
16namespace HLE {
17
18void SourceFilters::Reset() {
19 Enable(false, false);
20}
21
22void SourceFilters::Enable(bool simple, bool biquad) {
23 simple_filter_enabled = simple;
24 biquad_filter_enabled = biquad;
25
26 if (!simple)
27 simple_filter.Reset();
28 if (!biquad)
29 biquad_filter.Reset();
30}
31
32void SourceFilters::Configure(SourceConfiguration::Configuration::SimpleFilter config) {
33 simple_filter.Configure(config);
34}
35
36void SourceFilters::Configure(SourceConfiguration::Configuration::BiquadFilter config) {
37 biquad_filter.Configure(config);
38}
39
40void SourceFilters::ProcessFrame(StereoFrame16& frame) {
41 if (!simple_filter_enabled && !biquad_filter_enabled)
42 return;
43
44 if (simple_filter_enabled) {
45 FilterFrame(frame, simple_filter);
46 }
47
48 if (biquad_filter_enabled) {
49 FilterFrame(frame, biquad_filter);
50 }
51}
52
53// SimpleFilter
54
55void SourceFilters::SimpleFilter::Reset() {
56 y1.fill(0);
57 // Configure as passthrough.
58 a1 = 0;
59 b0 = 1 << 15;
60}
61
62void SourceFilters::SimpleFilter::Configure(SourceConfiguration::Configuration::SimpleFilter config) {
63 a1 = config.a1;
64 b0 = config.b0;
65}
66
67std::array<s16, 2> SourceFilters::SimpleFilter::ProcessSample(const std::array<s16, 2>& x0) {
68 std::array<s16, 2> y0;
69 for (size_t i = 0; i < 2; i++) {
70 const s32 tmp = (b0 * x0[i] + a1 * y1[i]) >> 15;
71 y0[i] = MathUtil::Clamp(tmp, -32768, 32767);
72 }
73
74 y1 = y0;
75
76 return y0;
77}
78
79// BiquadFilter
80
81void SourceFilters::BiquadFilter::Reset() {
82 x1.fill(0);
83 x2.fill(0);
84 y1.fill(0);
85 y2.fill(0);
86 // Configure as passthrough.
87 a1 = a2 = b1 = b2 = 0;
88 b0 = 1 << 14;
89}
90
91void SourceFilters::BiquadFilter::Configure(SourceConfiguration::Configuration::BiquadFilter config) {
92 a1 = config.a1;
93 a2 = config.a2;
94 b0 = config.b0;
95 b1 = config.b1;
96 b2 = config.b2;
97}
98
99std::array<s16, 2> SourceFilters::BiquadFilter::ProcessSample(const std::array<s16, 2>& x0) {
100 std::array<s16, 2> y0;
101 for (size_t i = 0; i < 2; i++) {
102 const s32 tmp = (b0 * x0[i] + b1 * x1[i] + b2 * x2[i] + a1 * y1[i] + a2 * y2[i]) >> 14;
103 y0[i] = MathUtil::Clamp(tmp, -32768, 32767);
104 }
105
106 x2 = x1;
107 x1 = x0;
108 y2 = y1;
109 y1 = y0;
110
111 return y0;
112}
113
114} // namespace HLE
115} // namespace DSP
diff --git a/src/audio_core/hle/filter.h b/src/audio_core/hle/filter.h
new file mode 100644
index 000000000..75738f600
--- /dev/null
+++ b/src/audio_core/hle/filter.h
@@ -0,0 +1,112 @@
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 <array>
8
9#include "audio_core/hle/common.h"
10#include "audio_core/hle/dsp.h"
11
12#include "common/common_types.h"
13
14namespace DSP {
15namespace HLE {
16
17/// Preprocessing filters. There is an independent set of filters for each Source.
18class SourceFilters final {
19 SourceFilters() { Reset(); }
20
21 /// Reset internal state.
22 void Reset();
23
24 /**
25 * Enable/Disable filters
26 * See also: SourceConfiguration::Configuration::simple_filter_enabled,
27 * SourceConfiguration::Configuration::biquad_filter_enabled.
28 * @param simple If true, enables the simple filter. If false, disables it.
29 * @param simple If true, enables the biquad filter. If false, disables it.
30 */
31 void Enable(bool simple, bool biquad);
32
33 /**
34 * Configure simple filter.
35 * @param config Configuration from DSP shared memory.
36 */
37 void Configure(SourceConfiguration::Configuration::SimpleFilter config);
38
39 /**
40 * Configure biquad filter.
41 * @param config Configuration from DSP shared memory.
42 */
43 void Configure(SourceConfiguration::Configuration::BiquadFilter config);
44
45 /**
46 * Processes a frame in-place.
47 * @param frame Audio samples to process. Modified in-place.
48 */
49 void ProcessFrame(StereoFrame16& frame);
50
51private:
52 bool simple_filter_enabled;
53 bool biquad_filter_enabled;
54
55 struct SimpleFilter {
56 SimpleFilter() { Reset(); }
57
58 /// Resets internal state.
59 void Reset();
60
61 /**
62 * Configures this filter with application settings.
63 * @param config Configuration from DSP shared memory.
64 */
65 void Configure(SourceConfiguration::Configuration::SimpleFilter config);
66
67 /**
68 * Processes a single stereo PCM16 sample.
69 * @param x0 Input sample
70 * @return Output sample
71 */
72 std::array<s16, 2> ProcessSample(const std::array<s16, 2>& x0);
73
74 private:
75 // Configuration
76 s32 a1, b0;
77 // Internal state
78 std::array<s16, 2> y1;
79 } simple_filter;
80
81 struct BiquadFilter {
82 BiquadFilter() { Reset(); }
83
84 /// Resets internal state.
85 void Reset();
86
87 /**
88 * Configures this filter with application settings.
89 * @param config Configuration from DSP shared memory.
90 */
91 void Configure(SourceConfiguration::Configuration::BiquadFilter config);
92
93 /**
94 * Processes a single stereo PCM16 sample.
95 * @param x0 Input sample
96 * @return Output sample
97 */
98 std::array<s16, 2> ProcessSample(const std::array<s16, 2>& x0);
99
100 private:
101 // Configuration
102 s32 a1, a2, b0, b1, b2;
103 // Internal state
104 std::array<s16, 2> x1;
105 std::array<s16, 2> x2;
106 std::array<s16, 2> y1;
107 std::array<s16, 2> y2;
108 } biquad_filter;
109};
110
111} // namespace HLE
112} // namespace DSP
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 40e40f192..b12369136 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -5,6 +5,7 @@
5#include <string> 5#include <string>
6#include <thread> 6#include <thread>
7#include <iostream> 7#include <iostream>
8#include <memory>
8 9
9// This needs to be included before getopt.h because the latter #defines symbols used by it 10// This needs to be included before getopt.h because the latter #defines symbols used by it
10#include "common/microprofile.h" 11#include "common/microprofile.h"
@@ -19,7 +20,6 @@
19#include "common/logging/log.h" 20#include "common/logging/log.h"
20#include "common/logging/backend.h" 21#include "common/logging/backend.h"
21#include "common/logging/filter.h" 22#include "common/logging/filter.h"
22#include "common/make_unique.h"
23#include "common/scope_exit.h" 23#include "common/scope_exit.h"
24 24
25#include "core/settings.h" 25#include "core/settings.h"
@@ -79,7 +79,7 @@ int main(int argc, char **argv) {
79 GDBStub::ToggleServer(Settings::values.use_gdbstub); 79 GDBStub::ToggleServer(Settings::values.use_gdbstub);
80 GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port)); 80 GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port));
81 81
82 std::unique_ptr<EmuWindow_SDL2> emu_window = Common::make_unique<EmuWindow_SDL2>(); 82 std::unique_ptr<EmuWindow_SDL2> emu_window = std::make_unique<EmuWindow_SDL2>();
83 83
84 VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer; 84 VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer;
85 VideoCore::g_shader_jit_enabled = Settings::values.use_shader_jit; 85 VideoCore::g_shader_jit_enabled = Settings::values.use_shader_jit;
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 9034b188e..6b6617352 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory>
6
5#include <inih/cpp/INIReader.h> 7#include <inih/cpp/INIReader.h>
6 8
7#include <SDL.h> 9#include <SDL.h>
@@ -10,7 +12,6 @@
10 12
11#include "common/file_util.h" 13#include "common/file_util.h"
12#include "common/logging/log.h" 14#include "common/logging/log.h"
13#include "common/make_unique.h"
14 15
15#include "core/settings.h" 16#include "core/settings.h"
16 17
@@ -19,7 +20,7 @@
19Config::Config() { 20Config::Config() {
20 // TODO: Don't hardcode the path; let the frontend decide where to put the config files. 21 // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
21 sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini"; 22 sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini";
22 sdl2_config = Common::make_unique<INIReader>(sdl2_config_loc); 23 sdl2_config = std::make_unique<INIReader>(sdl2_config_loc);
23 24
24 Reload(); 25 Reload();
25} 26}
@@ -31,7 +32,7 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) {
31 LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); 32 LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location);
32 FileUtil::CreateFullPath(location); 33 FileUtil::CreateFullPath(location);
33 FileUtil::WriteStringToFile(true, default_contents, location); 34 FileUtil::WriteStringToFile(true, default_contents, location);
34 sdl2_config = Common::make_unique<INIReader>(location); // Reopen file 35 sdl2_config = std::make_unique<INIReader>(location); // Reopen file
35 36
36 return LoadINI(default_contents, false); 37 return LoadINI(default_contents, false);
37 } 38 }
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp
index 1f8d69a03..ffcab1f03 100644
--- a/src/citra_qt/game_list.cpp
+++ b/src/citra_qt/game_list.cpp
@@ -66,7 +66,7 @@ void GameList::ValidateEntry(const QModelIndex& item)
66 66
67 if (file_path.isEmpty()) 67 if (file_path.isEmpty())
68 return; 68 return;
69 std::string std_file_path = file_path.toStdString(); 69 std::string std_file_path(file_path.toStdString());
70 if (!FileUtil::Exists(std_file_path) || FileUtil::IsDirectory(std_file_path)) 70 if (!FileUtil::Exists(std_file_path) || FileUtil::IsDirectory(std_file_path))
71 return; 71 return;
72 emit GameChosen(file_path); 72 emit GameChosen(file_path);
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 32cceaf7e..ca0ae6f7b 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <clocale> 5#include <clocale>
6#include <memory>
6#include <thread> 7#include <thread>
7 8
8#include <QDesktopWidget> 9#include <QDesktopWidget>
@@ -30,7 +31,6 @@
30#include "citra_qt/debugger/ramview.h" 31#include "citra_qt/debugger/ramview.h"
31#include "citra_qt/debugger/registers.h" 32#include "citra_qt/debugger/registers.h"
32 33
33#include "common/make_unique.h"
34#include "common/microprofile.h" 34#include "common/microprofile.h"
35#include "common/platform.h" 35#include "common/platform.h"
36#include "common/scm_rev.h" 36#include "common/scm_rev.h"
@@ -319,7 +319,7 @@ void GMainWindow::BootGame(const std::string& filename) {
319 return; 319 return;
320 320
321 // Create and start the emulation thread 321 // Create and start the emulation thread
322 emu_thread = Common::make_unique<EmuThread>(render_window); 322 emu_thread = std::make_unique<EmuThread>(render_window);
323 emit EmulationStarting(emu_thread.get()); 323 emit EmulationStarting(emu_thread.get());
324 render_window->moveContext(); 324 render_window->moveContext();
325 emu_thread->start(); 325 emu_thread->start();
@@ -417,7 +417,7 @@ void GMainWindow::UpdateRecentFiles() {
417} 417}
418 418
419void GMainWindow::OnGameListLoadFile(QString game_path) { 419void GMainWindow::OnGameListLoadFile(QString game_path) {
420 BootGame(game_path.toLocal8Bit().data()); 420 BootGame(game_path.toStdString());
421} 421}
422 422
423void GMainWindow::OnMenuLoadFile() { 423void GMainWindow::OnMenuLoadFile() {
@@ -428,7 +428,7 @@ void GMainWindow::OnMenuLoadFile() {
428 if (!filename.isEmpty()) { 428 if (!filename.isEmpty()) {
429 settings.setValue("romsPath", QFileInfo(filename).path()); 429 settings.setValue("romsPath", QFileInfo(filename).path());
430 430
431 BootGame(filename.toLocal8Bit().data()); 431 BootGame(filename.toStdString());
432 } 432 }
433} 433}
434 434
@@ -440,7 +440,7 @@ void GMainWindow::OnMenuLoadSymbolMap() {
440 if (!filename.isEmpty()) { 440 if (!filename.isEmpty()) {
441 settings.setValue("symbolsPath", QFileInfo(filename).path()); 441 settings.setValue("symbolsPath", QFileInfo(filename).path());
442 442
443 LoadSymbolMap(filename.toLocal8Bit().data()); 443 LoadSymbolMap(filename.toStdString());
444 } 444 }
445} 445}
446 446
@@ -461,7 +461,7 @@ void GMainWindow::OnMenuRecentFile() {
461 QString filename = action->data().toString(); 461 QString filename = action->data().toString();
462 QFileInfo file_info(filename); 462 QFileInfo file_info(filename);
463 if (file_info.exists()) { 463 if (file_info.exists()) {
464 BootGame(filename.toLocal8Bit().data()); 464 BootGame(filename.toStdString());
465 } else { 465 } else {
466 // Display an error message and remove the file from the list. 466 // Display an error message and remove the file from the list.
467 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); 467 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename));
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 1c9be718f..c839ce173 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -42,7 +42,6 @@ set(HEADERS
42 logging/filter.h 42 logging/filter.h
43 logging/log.h 43 logging/log.h
44 logging/backend.h 44 logging/backend.h
45 make_unique.h
46 math_util.h 45 math_util.h
47 memory_util.h 46 memory_util.h
48 microprofile.h 47 microprofile.h
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index c3061479a..9ada09f8a 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -85,7 +85,7 @@ bool Exists(const std::string &filename)
85 StripTailDirSlashes(copy); 85 StripTailDirSlashes(copy);
86 86
87#ifdef _WIN32 87#ifdef _WIN32
88 int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); 88 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
89#else 89#else
90 int result = stat64(copy.c_str(), &file_info); 90 int result = stat64(copy.c_str(), &file_info);
91#endif 91#endif
@@ -102,7 +102,7 @@ bool IsDirectory(const std::string &filename)
102 StripTailDirSlashes(copy); 102 StripTailDirSlashes(copy);
103 103
104#ifdef _WIN32 104#ifdef _WIN32
105 int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); 105 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
106#else 106#else
107 int result = stat64(copy.c_str(), &file_info); 107 int result = stat64(copy.c_str(), &file_info);
108#endif 108#endif
@@ -138,7 +138,7 @@ bool Delete(const std::string &filename)
138 } 138 }
139 139
140#ifdef _WIN32 140#ifdef _WIN32
141 if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) 141 if (!DeleteFileW(Common::UTF8ToUTF16W(filename).c_str()))
142 { 142 {
143 LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s", 143 LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s",
144 filename.c_str(), GetLastErrorMsg()); 144 filename.c_str(), GetLastErrorMsg());
@@ -160,7 +160,7 @@ bool CreateDir(const std::string &path)
160{ 160{
161 LOG_TRACE(Common_Filesystem, "directory %s", path.c_str()); 161 LOG_TRACE(Common_Filesystem, "directory %s", path.c_str());
162#ifdef _WIN32 162#ifdef _WIN32
163 if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), nullptr)) 163 if (::CreateDirectoryW(Common::UTF8ToUTF16W(path).c_str(), nullptr))
164 return true; 164 return true;
165 DWORD error = GetLastError(); 165 DWORD error = GetLastError();
166 if (error == ERROR_ALREADY_EXISTS) 166 if (error == ERROR_ALREADY_EXISTS)
@@ -241,7 +241,7 @@ bool DeleteDir(const std::string &filename)
241 } 241 }
242 242
243#ifdef _WIN32 243#ifdef _WIN32
244 if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) 244 if (::RemoveDirectoryW(Common::UTF8ToUTF16W(filename).c_str()))
245 return true; 245 return true;
246#else 246#else
247 if (rmdir(filename.c_str()) == 0) 247 if (rmdir(filename.c_str()) == 0)
@@ -257,8 +257,13 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
257{ 257{
258 LOG_TRACE(Common_Filesystem, "%s --> %s", 258 LOG_TRACE(Common_Filesystem, "%s --> %s",
259 srcFilename.c_str(), destFilename.c_str()); 259 srcFilename.c_str(), destFilename.c_str());
260#ifdef _WIN32
261 if (_wrename(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str()) == 0)
262 return true;
263#else
260 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) 264 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
261 return true; 265 return true;
266#endif
262 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", 267 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
263 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 268 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
264 return false; 269 return false;
@@ -270,7 +275,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
270 LOG_TRACE(Common_Filesystem, "%s --> %s", 275 LOG_TRACE(Common_Filesystem, "%s --> %s",
271 srcFilename.c_str(), destFilename.c_str()); 276 srcFilename.c_str(), destFilename.c_str());
272#ifdef _WIN32 277#ifdef _WIN32
273 if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) 278 if (CopyFileW(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str(), FALSE))
274 return true; 279 return true;
275 280
276 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", 281 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
@@ -358,7 +363,7 @@ u64 GetSize(const std::string &filename)
358 363
359 struct stat64 buf; 364 struct stat64 buf;
360#ifdef _WIN32 365#ifdef _WIN32
361 if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) 366 if (_wstat64(Common::UTF8ToUTF16W(filename).c_str(), &buf) == 0)
362#else 367#else
363 if (stat64(filename.c_str(), &buf) == 0) 368 if (stat64(filename.c_str(), &buf) == 0)
364#endif 369#endif
@@ -432,16 +437,16 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
432 437
433#ifdef _WIN32 438#ifdef _WIN32
434 // Find the first file in the directory. 439 // Find the first file in the directory.
435 WIN32_FIND_DATA ffd; 440 WIN32_FIND_DATAW ffd;
436 441
437 HANDLE handle_find = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); 442 HANDLE handle_find = FindFirstFileW(Common::UTF8ToUTF16W(directory + "\\*").c_str(), &ffd);
438 if (handle_find == INVALID_HANDLE_VALUE) { 443 if (handle_find == INVALID_HANDLE_VALUE) {
439 FindClose(handle_find); 444 FindClose(handle_find);
440 return false; 445 return false;
441 } 446 }
442 // windows loop 447 // windows loop
443 do { 448 do {
444 const std::string virtual_name(Common::TStrToUTF8(ffd.cFileName)); 449 const std::string virtual_name(Common::UTF16ToUTF8(ffd.cFileName));
445#else 450#else
446 struct dirent dirent, *result = nullptr; 451 struct dirent dirent, *result = nullptr;
447 452
@@ -465,7 +470,7 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo
465 found_entries += ret_entries; 470 found_entries += ret_entries;
466 471
467#ifdef _WIN32 472#ifdef _WIN32
468 } while (FindNextFile(handle_find, &ffd) != 0); 473 } while (FindNextFileW(handle_find, &ffd) != 0);
469 FindClose(handle_find); 474 FindClose(handle_find);
470#else 475#else
471 } 476 }
@@ -572,15 +577,23 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
572// Returns the current directory 577// Returns the current directory
573std::string GetCurrentDir() 578std::string GetCurrentDir()
574{ 579{
575 char *dir;
576 // Get the current working directory (getcwd uses malloc) 580 // Get the current working directory (getcwd uses malloc)
581#ifdef _WIN32
582 wchar_t *dir;
583 if (!(dir = _wgetcwd(nullptr, 0))) {
584#else
585 char *dir;
577 if (!(dir = getcwd(nullptr, 0))) { 586 if (!(dir = getcwd(nullptr, 0))) {
578 587#endif
579 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s", 588 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",
580 GetLastErrorMsg()); 589 GetLastErrorMsg());
581 return nullptr; 590 return nullptr;
582 } 591 }
592#ifdef _WIN32
593 std::string strDir = Common::UTF16ToUTF8(dir);
594#else
583 std::string strDir = dir; 595 std::string strDir = dir;
596#endif
584 free(dir); 597 free(dir);
585 return strDir; 598 return strDir;
586} 599}
@@ -588,7 +601,11 @@ std::string GetCurrentDir()
588// Sets the current directory to the given directory 601// Sets the current directory to the given directory
589bool SetCurrentDir(const std::string &directory) 602bool SetCurrentDir(const std::string &directory)
590{ 603{
604#ifdef _WIN32
605 return _wchdir(Common::UTF8ToUTF16W(directory).c_str()) == 0;
606#else
591 return chdir(directory.c_str()) == 0; 607 return chdir(directory.c_str()) == 0;
608#endif
592} 609}
593 610
594#if defined(__APPLE__) 611#if defined(__APPLE__)
@@ -613,9 +630,9 @@ std::string& GetExeDirectory()
613 static std::string exe_path; 630 static std::string exe_path;
614 if (exe_path.empty()) 631 if (exe_path.empty())
615 { 632 {
616 TCHAR tchar_exe_path[2048]; 633 wchar_t wchar_exe_path[2048];
617 GetModuleFileName(nullptr, tchar_exe_path, 2048); 634 GetModuleFileNameW(nullptr, wchar_exe_path, 2048);
618 exe_path = Common::TStrToUTF8(tchar_exe_path); 635 exe_path = Common::UTF16ToUTF8(wchar_exe_path);
619 exe_path = exe_path.substr(0, exe_path.find_last_of('\\')); 636 exe_path = exe_path.substr(0, exe_path.find_last_of('\\'));
620 } 637 }
621 return exe_path; 638 return exe_path;
@@ -900,7 +917,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[])
900{ 917{
901 Close(); 918 Close();
902#ifdef _WIN32 919#ifdef _WIN32
903 _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); 920 _wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str());
904#else 921#else
905 m_file = fopen(filename.c_str(), openmode); 922 m_file = fopen(filename.c_str(), openmode);
906#endif 923#endif
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 757e0cf47..3d39f94d5 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -47,8 +47,10 @@ namespace Log {
47 SUB(Service, NIM) \ 47 SUB(Service, NIM) \
48 SUB(Service, NWM) \ 48 SUB(Service, NWM) \
49 SUB(Service, CAM) \ 49 SUB(Service, CAM) \
50 SUB(Service, CECD) \
50 SUB(Service, CFG) \ 51 SUB(Service, CFG) \
51 SUB(Service, DSP) \ 52 SUB(Service, DSP) \
53 SUB(Service, DLP) \
52 SUB(Service, HID) \ 54 SUB(Service, HID) \
53 SUB(Service, SOC) \ 55 SUB(Service, SOC) \
54 SUB(Service, IR) \ 56 SUB(Service, IR) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 4da4831c3..b8eede3b8 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -62,8 +62,10 @@ enum class Class : ClassType {
62 Service_NIM, ///< The NIM (Network interface manager) service 62 Service_NIM, ///< The NIM (Network interface manager) service
63 Service_NWM, ///< The NWM (Network wlan manager) service 63 Service_NWM, ///< The NWM (Network wlan manager) service
64 Service_CAM, ///< The CAM (Camera) service 64 Service_CAM, ///< The CAM (Camera) service
65 Service_CECD, ///< The CECD service
65 Service_CFG, ///< The CFG (Configuration) service 66 Service_CFG, ///< The CFG (Configuration) service
66 Service_DSP, ///< The DSP (DSP control) service 67 Service_DSP, ///< The DSP (DSP control) service
68 Service_DLP, ///< The DLP (Download Play) service
67 Service_HID, ///< The HID (Human interface device) service 69 Service_HID, ///< The HID (Human interface device) service
68 Service_SOC, ///< The SOC (Socket) service 70 Service_SOC, ///< The SOC (Socket) service
69 Service_IR, ///< The IR service 71 Service_IR, ///< The IR service
diff --git a/src/common/make_unique.h b/src/common/make_unique.h
deleted file mode 100644
index f6e7f017c..000000000
--- a/src/common/make_unique.h
+++ /dev/null
@@ -1,17 +0,0 @@
1// Copyright 2014 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 <algorithm>
8#include <memory>
9
10namespace Common {
11
12template <typename T, typename... Args>
13std::unique_ptr<T> make_unique(Args&&... args) {
14 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
15}
16
17} // namespace
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 6d6fc591f..f0aa072db 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -320,27 +320,27 @@ std::u16string UTF8ToUTF16(const std::string& input)
320#endif 320#endif
321} 321}
322 322
323static std::string UTF16ToUTF8(const std::wstring& input) 323static std::wstring CPToUTF16(u32 code_page, const std::string& input)
324{ 324{
325 auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); 325 auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
326 326
327 std::string output; 327 std::wstring output;
328 output.resize(size); 328 output.resize(size);
329 329
330 if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()), nullptr, nullptr)) 330 if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size())))
331 output.clear(); 331 output.clear();
332 332
333 return output; 333 return output;
334} 334}
335 335
336static std::wstring CPToUTF16(u32 code_page, const std::string& input) 336std::string UTF16ToUTF8(const std::wstring& input)
337{ 337{
338 auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); 338 auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr);
339 339
340 std::wstring output; 340 std::string output;
341 output.resize(size); 341 output.resize(size);
342 342
343 if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()))) 343 if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()), nullptr, nullptr))
344 output.clear(); 344 output.clear();
345 345
346 return output; 346 return output;
diff --git a/src/common/string_util.h b/src/common/string_util.h
index c5c474c6f..89d9f133e 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -95,7 +95,7 @@ std::string CP1252ToUTF8(const std::string& str);
95std::string SHIFTJISToUTF8(const std::string& str); 95std::string SHIFTJISToUTF8(const std::string& str);
96 96
97#ifdef _WIN32 97#ifdef _WIN32
98 98std::string UTF16ToUTF8(const std::wstring& input);
99std::wstring UTF8ToUTF16W(const std::string& str); 99std::wstring UTF8ToUTF16W(const std::string& str);
100 100
101#ifdef _UNICODE 101#ifdef _UNICODE
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 3473e2f5b..a8d891689 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -68,6 +68,7 @@ set(SRCS
68 hle/service/cfg/cfg_s.cpp 68 hle/service/cfg/cfg_s.cpp
69 hle/service/cfg/cfg_u.cpp 69 hle/service/cfg/cfg_u.cpp
70 hle/service/csnd_snd.cpp 70 hle/service/csnd_snd.cpp
71 hle/service/dlp_srvr.cpp
71 hle/service/dsp_dsp.cpp 72 hle/service/dsp_dsp.cpp
72 hle/service/err_f.cpp 73 hle/service/err_f.cpp
73 hle/service/frd/frd.cpp 74 hle/service/frd/frd.cpp
@@ -200,6 +201,7 @@ set(HEADERS
200 hle/service/cfg/cfg_s.h 201 hle/service/cfg/cfg_s.h
201 hle/service/cfg/cfg_u.h 202 hle/service/cfg/cfg_u.h
202 hle/service/csnd_snd.h 203 hle/service/csnd_snd.h
204 hle/service/dlp_srvr.h
203 hle/service/dsp_dsp.h 205 hle/service/dsp_dsp.h
204 hle/service/err_f.h 206 hle/service/err_f.h
205 hle/service/frd/frd.h 207 hle/service/frd/frd.h
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index f3be2c857..947f5094b 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -3,8 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring> 5#include <cstring>
6 6#include <memory>
7#include "common/make_unique.h"
8 7
9#include "core/arm/skyeye_common/armstate.h" 8#include "core/arm/skyeye_common/armstate.h"
10#include "core/arm/skyeye_common/armsupp.h" 9#include "core/arm/skyeye_common/armsupp.h"
@@ -18,7 +17,7 @@
18#include "core/core_timing.h" 17#include "core/core_timing.h"
19 18
20ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) { 19ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) {
21 state = Common::make_unique<ARMul_State>(initial_mode); 20 state = std::make_unique<ARMul_State>(initial_mode);
22} 21}
23 22
24ARM_DynCom::~ARM_DynCom() { 23ARM_DynCom::~ARM_DynCom() {
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
index 5f8826034..9ed61947e 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
@@ -36,7 +36,8 @@ enum {
36 CALL = (1 << 4), 36 CALL = (1 << 4),
37 RET = (1 << 5), 37 RET = (1 << 5),
38 END_OF_PAGE = (1 << 6), 38 END_OF_PAGE = (1 << 6),
39 THUMB = (1 << 7) 39 THUMB = (1 << 7),
40 SINGLE_STEP = (1 << 8)
40}; 41};
41 42
42#define RM BITS(sht_oper, 0, 3) 43#define RM BITS(sht_oper, 0, 3)
@@ -3466,7 +3467,35 @@ enum {
3466 3467
3467MICROPROFILE_DEFINE(DynCom_Decode, "DynCom", "Decode", MP_RGB(255, 64, 64)); 3468MICROPROFILE_DEFINE(DynCom_Decode, "DynCom", "Decode", MP_RGB(255, 64, 64));
3468 3469
3469static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) { 3470static unsigned int InterpreterTranslateInstruction(const ARMul_State* cpu, const u32 phys_addr, ARM_INST_PTR& inst_base) {
3471 unsigned int inst_size = 4;
3472 unsigned int inst = Memory::Read32(phys_addr & 0xFFFFFFFC);
3473
3474 // If we are in Thumb mode, we'll translate one Thumb instruction to the corresponding ARM instruction
3475 if (cpu->TFlag) {
3476 u32 arm_inst;
3477 ThumbDecodeStatus state = DecodeThumbInstruction(inst, phys_addr, &arm_inst, &inst_size, &inst_base);
3478
3479 // We have translated the Thumb branch instruction in the Thumb decoder
3480 if (state == ThumbDecodeStatus::BRANCH) {
3481 return inst_size;
3482 }
3483 inst = arm_inst;
3484 }
3485
3486 int idx;
3487 if (DecodeARMInstruction(inst, &idx) == ARMDecodeStatus::FAILURE) {
3488 std::string disasm = ARM_Disasm::Disassemble(phys_addr, inst);
3489 LOG_ERROR(Core_ARM11, "Decode failure.\tPC : [0x%x]\tInstruction : %s [%x]", phys_addr, disasm.c_str(), inst);
3490 LOG_ERROR(Core_ARM11, "cpsr=0x%x, cpu->TFlag=%d, r15=0x%x", cpu->Cpsr, cpu->TFlag, cpu->Reg[15]);
3491 CITRA_IGNORE_EXIT(-1);
3492 }
3493 inst_base = arm_instruction_trans[idx](inst, idx);
3494
3495 return inst_size;
3496}
3497
3498static int InterpreterTranslateBlock(ARMul_State* cpu, int& bb_start, u32 addr) {
3470 Common::Profiling::ScopeTimer timer_decode(profile_decode); 3499 Common::Profiling::ScopeTimer timer_decode(profile_decode);
3471 MICROPROFILE_SCOPE(DynCom_Decode); 3500 MICROPROFILE_SCOPE(DynCom_Decode);
3472 3501
@@ -3475,8 +3504,6 @@ static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) {
3475 // Go on next, until terminal instruction 3504 // Go on next, until terminal instruction
3476 // Save start addr of basicblock in CreamCache 3505 // Save start addr of basicblock in CreamCache
3477 ARM_INST_PTR inst_base = nullptr; 3506 ARM_INST_PTR inst_base = nullptr;
3478 unsigned int inst, inst_size = 4;
3479 int idx;
3480 int ret = NON_BRANCH; 3507 int ret = NON_BRANCH;
3481 int size = 0; // instruction size of basic block 3508 int size = 0; // instruction size of basic block
3482 bb_start = top; 3509 bb_start = top;
@@ -3485,30 +3512,10 @@ static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) {
3485 u32 pc_start = cpu->Reg[15]; 3512 u32 pc_start = cpu->Reg[15];
3486 3513
3487 while (ret == NON_BRANCH) { 3514 while (ret == NON_BRANCH) {
3488 inst = Memory::Read32(phys_addr & 0xFFFFFFFC); 3515 unsigned int inst_size = InterpreterTranslateInstruction(cpu, phys_addr, inst_base);
3489 3516
3490 size++; 3517 size++;
3491 // If we are in Thumb mode, we'll translate one Thumb instruction to the corresponding ARM instruction
3492 if (cpu->TFlag) {
3493 u32 arm_inst;
3494 ThumbDecodeStatus state = DecodeThumbInstruction(inst, phys_addr, &arm_inst, &inst_size, &inst_base);
3495
3496 // We have translated the Thumb branch instruction in the Thumb decoder
3497 if (state == ThumbDecodeStatus::BRANCH) {
3498 goto translated;
3499 }
3500 inst = arm_inst;
3501 }
3502
3503 if (DecodeARMInstruction(inst, &idx) == ARMDecodeStatus::FAILURE) {
3504 std::string disasm = ARM_Disasm::Disassemble(phys_addr, inst);
3505 LOG_ERROR(Core_ARM11, "Decode failure.\tPC : [0x%x]\tInstruction : %s [%x]", phys_addr, disasm.c_str(), inst);
3506 LOG_ERROR(Core_ARM11, "cpsr=0x%x, cpu->TFlag=%d, r15=0x%x", cpu->Cpsr, cpu->TFlag, cpu->Reg[15]);
3507 CITRA_IGNORE_EXIT(-1);
3508 }
3509 inst_base = arm_instruction_trans[idx](inst, idx);
3510 3518
3511translated:
3512 phys_addr += inst_size; 3519 phys_addr += inst_size;
3513 3520
3514 if ((phys_addr & 0xfff) == 0) { 3521 if ((phys_addr & 0xfff) == 0) {
@@ -3522,6 +3529,27 @@ translated:
3522 return KEEP_GOING; 3529 return KEEP_GOING;
3523} 3530}
3524 3531
3532static int InterpreterTranslateSingle(ARMul_State* cpu, int& bb_start, u32 addr) {
3533 Common::Profiling::ScopeTimer timer_decode(profile_decode);
3534 MICROPROFILE_SCOPE(DynCom_Decode);
3535
3536 ARM_INST_PTR inst_base = nullptr;
3537 bb_start = top;
3538
3539 u32 phys_addr = addr;
3540 u32 pc_start = cpu->Reg[15];
3541
3542 InterpreterTranslateInstruction(cpu, phys_addr, inst_base);
3543
3544 if (inst_base->br == NON_BRANCH) {
3545 inst_base->br = SINGLE_STEP;
3546 }
3547
3548 cpu->instruction_cache[pc_start] = bb_start;
3549
3550 return KEEP_GOING;
3551}
3552
3525static int clz(unsigned int x) { 3553static int clz(unsigned int x) {
3526 int n; 3554 int n;
3527 if (x == 0) return (32); 3555 if (x == 0) return (32);
@@ -3871,8 +3899,11 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3871 auto itr = cpu->instruction_cache.find(cpu->Reg[15]); 3899 auto itr = cpu->instruction_cache.find(cpu->Reg[15]);
3872 if (itr != cpu->instruction_cache.end()) { 3900 if (itr != cpu->instruction_cache.end()) {
3873 ptr = itr->second; 3901 ptr = itr->second;
3902 } else if (cpu->NumInstrsToExecute != 1) {
3903 if (InterpreterTranslateBlock(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION)
3904 goto END;
3874 } else { 3905 } else {
3875 if (InterpreterTranslate(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION) 3906 if (InterpreterTranslateSingle(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION)
3876 goto END; 3907 goto END;
3877 } 3908 }
3878 3909
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 84d6c392e..3bb843aab 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -4,7 +4,6 @@
4 4
5#include <memory> 5#include <memory>
6 6
7#include "common/make_unique.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
9 8
10#include "core/core.h" 9#include "core/core.h"
@@ -74,8 +73,8 @@ void Stop() {
74 73
75/// Initialize the core 74/// Initialize the core
76void Init() { 75void Init() {
77 g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE); 76 g_sys_core = std::make_unique<ARM_DynCom>(USER32MODE);
78 g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE); 77 g_app_core = std::make_unique<ARM_DynCom>(USER32MODE);
79 78
80 LOG_DEBUG(Core, "Initialized OK"); 79 LOG_DEBUG(Core, "Initialized OK");
81} 80}
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp
index 961264fe5..1d9eaefcb 100644
--- a/src/core/file_sys/archive_extsavedata.cpp
+++ b/src/core/file_sys/archive_extsavedata.cpp
@@ -3,12 +3,12 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory>
6#include <vector> 7#include <vector>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "common/file_util.h" 10#include "common/file_util.h"
10#include "common/logging/log.h" 11#include "common/logging/log.h"
11#include "common/make_unique.h"
12#include "common/string_util.h" 12#include "common/string_util.h"
13 13
14#include "core/file_sys/archive_extsavedata.h" 14#include "core/file_sys/archive_extsavedata.h"
@@ -84,7 +84,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
84 ErrorSummary::InvalidState, ErrorLevel::Status); 84 ErrorSummary::InvalidState, ErrorLevel::Status);
85 } 85 }
86 } 86 }
87 auto archive = Common::make_unique<DiskArchive>(fullpath); 87 auto archive = std::make_unique<DiskArchive>(fullpath);
88 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 88 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
89} 89}
90 90
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index a9a29ebde..38828b546 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -7,7 +7,6 @@
7 7
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10#include "common/make_unique.h"
11 10
12#include "core/file_sys/archive_romfs.h" 11#include "core/file_sys/archive_romfs.h"
13#include "core/file_sys/ivfc_archive.h" 12#include "core/file_sys/ivfc_archive.h"
@@ -25,7 +24,7 @@ ArchiveFactory_RomFS::ArchiveFactory_RomFS(Loader::AppLoader& app_loader) {
25} 24}
26 25
27ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) { 26ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) {
28 auto archive = Common::make_unique<IVFCArchive>(romfs_file, data_offset, data_size); 27 auto archive = std::make_unique<IVFCArchive>(romfs_file, data_offset, data_size);
29 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 28 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
30} 29}
31 30
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp
index fe020d21c..fd5711e14 100644
--- a/src/core/file_sys/archive_savedata.cpp
+++ b/src/core/file_sys/archive_savedata.cpp
@@ -3,11 +3,11 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory>
6 7
7#include "common/common_types.h" 8#include "common/common_types.h"
8#include "common/file_util.h" 9#include "common/file_util.h"
9#include "common/logging/log.h" 10#include "common/logging/log.h"
10#include "common/make_unique.h"
11#include "common/string_util.h" 11#include "common/string_util.h"
12 12
13#include "core/file_sys/archive_savedata.h" 13#include "core/file_sys/archive_savedata.h"
@@ -53,7 +53,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const P
53 ErrorSummary::InvalidState, ErrorLevel::Status); 53 ErrorSummary::InvalidState, ErrorLevel::Status);
54 } 54 }
55 55
56 auto archive = Common::make_unique<DiskArchive>(std::move(concrete_mount_point)); 56 auto archive = std::make_unique<DiskArchive>(std::move(concrete_mount_point));
57 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 57 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
58} 58}
59 59
diff --git a/src/core/file_sys/archive_savedatacheck.cpp b/src/core/file_sys/archive_savedatacheck.cpp
index 3db11c500..9f65e5455 100644
--- a/src/core/file_sys/archive_savedatacheck.cpp
+++ b/src/core/file_sys/archive_savedatacheck.cpp
@@ -3,12 +3,12 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory>
6#include <vector> 7#include <vector>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "common/file_util.h" 10#include "common/file_util.h"
10#include "common/logging/log.h" 11#include "common/logging/log.h"
11#include "common/make_unique.h"
12#include "common/string_util.h" 12#include "common/string_util.h"
13 13
14#include "core/file_sys/archive_savedatacheck.h" 14#include "core/file_sys/archive_savedatacheck.h"
@@ -44,7 +44,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveDataCheck::Open(co
44 } 44 }
45 auto size = file->GetSize(); 45 auto size = file->GetSize();
46 46
47 auto archive = Common::make_unique<IVFCArchive>(file, 0, size); 47 auto archive = std::make_unique<IVFCArchive>(file, 0, size);
48 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 48 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
49} 49}
50 50
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index 657221cbf..9b218af58 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -3,10 +3,10 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory>
6 7
7#include "common/file_util.h" 8#include "common/file_util.h"
8#include "common/logging/log.h" 9#include "common/logging/log.h"
9#include "common/make_unique.h"
10 10
11#include "core/file_sys/archive_sdmc.h" 11#include "core/file_sys/archive_sdmc.h"
12#include "core/file_sys/disk_archive.h" 12#include "core/file_sys/disk_archive.h"
@@ -36,7 +36,7 @@ bool ArchiveFactory_SDMC::Initialize() {
36} 36}
37 37
38ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) { 38ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) {
39 auto archive = Common::make_unique<DiskArchive>(sdmc_directory); 39 auto archive = std::make_unique<DiskArchive>(sdmc_directory);
40 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 40 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
41} 41}
42 42
diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp
index e1780de2f..1bcc228a1 100644
--- a/src/core/file_sys/archive_systemsavedata.cpp
+++ b/src/core/file_sys/archive_systemsavedata.cpp
@@ -3,11 +3,11 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <memory>
6#include <vector> 7#include <vector>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "common/file_util.h" 10#include "common/file_util.h"
10#include "common/make_unique.h"
11#include "common/string_util.h" 11#include "common/string_util.h"
12 12
13#include "core/file_sys/archive_systemsavedata.h" 13#include "core/file_sys/archive_systemsavedata.h"
@@ -59,7 +59,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c
59 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, 59 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
60 ErrorSummary::InvalidState, ErrorLevel::Status); 60 ErrorSummary::InvalidState, ErrorLevel::Status);
61 } 61 }
62 auto archive = Common::make_unique<DiskArchive>(fullpath); 62 auto archive = std::make_unique<DiskArchive>(fullpath);
63 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 63 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
64} 64}
65 65
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index 8e4ea01c5..489cc96fb 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -4,11 +4,11 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstdio> 6#include <cstdio>
7#include <memory>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "common/file_util.h" 10#include "common/file_util.h"
10#include "common/logging/log.h" 11#include "common/logging/log.h"
11#include "common/make_unique.h"
12 12
13#include "core/file_sys/disk_archive.h" 13#include "core/file_sys/disk_archive.h"
14 14
@@ -19,7 +19,7 @@ namespace FileSys {
19 19
20ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path, const Mode mode) const { 20ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path, const Mode mode) const {
21 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); 21 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
22 auto file = Common::make_unique<DiskFile>(*this, path, mode); 22 auto file = std::make_unique<DiskFile>(*this, path, mode);
23 ResultCode result = file->Open(); 23 ResultCode result = file->Open();
24 if (result.IsError()) 24 if (result.IsError())
25 return result; 25 return result;
@@ -83,7 +83,7 @@ bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) c
83 83
84std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const { 84std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const {
85 LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str()); 85 LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
86 auto directory = Common::make_unique<DiskDirectory>(*this, path); 86 auto directory = std::make_unique<DiskDirectory>(*this, path);
87 if (!directory->Open()) 87 if (!directory->Open())
88 return nullptr; 88 return nullptr;
89 return std::move(directory); 89 return std::move(directory);
@@ -132,7 +132,7 @@ ResultCode DiskFile::Open() {
132 // Open the file in binary mode, to avoid problems with CR/LF on Windows systems 132 // Open the file in binary mode, to avoid problems with CR/LF on Windows systems
133 mode_string += "b"; 133 mode_string += "b";
134 134
135 file = Common::make_unique<FileUtil::IOFile>(path, mode_string.c_str()); 135 file = std::make_unique<FileUtil::IOFile>(path, mode_string.c_str());
136 if (file->IsOpen()) 136 if (file->IsOpen())
137 return RESULT_SUCCESS; 137 return RESULT_SUCCESS;
138 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, ErrorLevel::Status); 138 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, ErrorLevel::Status);
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp
index a8e9a72ef..c61791ef7 100644
--- a/src/core/file_sys/ivfc_archive.cpp
+++ b/src/core/file_sys/ivfc_archive.cpp
@@ -7,7 +7,6 @@
7 7
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10#include "common/make_unique.h"
11 10
12#include "core/file_sys/ivfc_archive.h" 11#include "core/file_sys/ivfc_archive.h"
13 12
@@ -21,7 +20,7 @@ std::string IVFCArchive::GetName() const {
21} 20}
22 21
23ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, const Mode mode) const { 22ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
24 return MakeResult<std::unique_ptr<FileBackend>>(Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size)); 23 return MakeResult<std::unique_ptr<FileBackend>>(std::make_unique<IVFCFile>(romfs_file, data_offset, data_size));
25} 24}
26 25
27ResultCode IVFCArchive::DeleteFile(const Path& path) const { 26ResultCode IVFCArchive::DeleteFile(const Path& path) const {
@@ -58,7 +57,7 @@ bool IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) c
58} 57}
59 58
60std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const { 59std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const {
61 return Common::make_unique<IVFCDirectory>(); 60 return std::make_unique<IVFCDirectory>();
62} 61}
63 62
64u64 IVFCArchive::GetFreeBytes() const { 63u64 IVFCArchive::GetFreeBytes() const {
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 24b266eae..0546f6e16 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -2,10 +2,11 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory>
6
5#include "common/assert.h" 7#include "common/assert.h"
6#include "common/common_funcs.h" 8#include "common/common_funcs.h"
7#include "common/logging/log.h" 9#include "common/logging/log.h"
8#include "common/make_unique.h"
9 10
10#include "core/hle/kernel/memory.h" 11#include "core/hle/kernel/memory.h"
11#include "core/hle/kernel/process.h" 12#include "core/hle/kernel/process.h"
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 0cb76ba1c..2d22652d9 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -24,6 +24,7 @@ enum class ErrorDescription : u32 {
24 FS_InvalidOpenFlags = 230, 24 FS_InvalidOpenFlags = 230,
25 FS_NotAFile = 250, 25 FS_NotAFile = 250,
26 FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive 26 FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
27 OutofRangeOrMisalignedAddress = 513, // TODO(purpasmart): Check if this name fits its actual usage
27 FS_InvalidPath = 702, 28 FS_InvalidPath = 702,
28 InvalidSection = 1000, 29 InvalidSection = 1000,
29 TooLarge = 1001, 30 TooLarge = 1001,
diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp
index 6d79ce9b4..e6e36e7ec 100644
--- a/src/core/hle/service/cecd/cecd.cpp
+++ b/src/core/hle/service/cecd/cecd.cpp
@@ -4,6 +4,7 @@
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6 6
7#include "core/hle/kernel/event.h"
7#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
8#include "core/hle/service/cecd/cecd.h" 9#include "core/hle/service/cecd/cecd.h"
9#include "core/hle/service/cecd/cecd_s.h" 10#include "core/hle/service/cecd/cecd_s.h"
@@ -12,14 +13,38 @@
12namespace Service { 13namespace Service {
13namespace CECD { 14namespace CECD {
14 15
15void Init() { 16static Kernel::SharedPtr<Kernel::Event> cecinfo_event;
16 using namespace Kernel; 17static Kernel::SharedPtr<Kernel::Event> change_state_event;
18
19void GetCecInfoEventHandle(Service::Interface* self) {
20 u32* cmd_buff = Kernel::GetCommandBuffer();
21
22 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
23 cmd_buff[3] = Kernel::g_handle_table.Create(cecinfo_event).MoveFrom(); // Event handle
24
25 LOG_WARNING(Service_CECD, "(STUBBED) called");
26}
27
28void GetChangeStateEventHandle(Service::Interface* self) {
29 u32* cmd_buff = Kernel::GetCommandBuffer();
17 30
31 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
32 cmd_buff[3] = Kernel::g_handle_table.Create(change_state_event).MoveFrom(); // Event handle
33
34 LOG_WARNING(Service_CECD, "(STUBBED) called");
35}
36
37void Init() {
18 AddService(new CECD_S_Interface); 38 AddService(new CECD_S_Interface);
19 AddService(new CECD_U_Interface); 39 AddService(new CECD_U_Interface);
40
41 cecinfo_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::cecinfo_event");
42 change_state_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::change_state_event");
20} 43}
21 44
22void Shutdown() { 45void Shutdown() {
46 cecinfo_event = nullptr;
47 change_state_event = nullptr;
23} 48}
24 49
25} // namespace CECD 50} // namespace CECD
diff --git a/src/core/hle/service/cecd/cecd.h b/src/core/hle/service/cecd/cecd.h
index 9e158521b..89a8d67bb 100644
--- a/src/core/hle/service/cecd/cecd.h
+++ b/src/core/hle/service/cecd/cecd.h
@@ -5,8 +5,31 @@
5#pragma once 5#pragma once
6 6
7namespace Service { 7namespace Service {
8
9class Interface;
10
8namespace CECD { 11namespace CECD {
9 12
13/**
14 * GetCecInfoEventHandle service function
15 * Inputs:
16 * 0: 0x000F0000
17 * Outputs:
18 * 1: ResultCode
19 * 3: Event Handle
20 */
21void GetCecInfoEventHandle(Service::Interface* self);
22
23/**
24 * GetChangeStateEventHandle service function
25 * Inputs:
26 * 0: 0x00100000
27 * Outputs:
28 * 1: ResultCode
29 * 3: Event Handle
30 */
31void GetChangeStateEventHandle(Service::Interface* self);
32
10/// Initialize CECD service(s) 33/// Initialize CECD service(s)
11void Init(); 34void Init();
12 35
diff --git a/src/core/hle/service/cecd/cecd_u.cpp b/src/core/hle/service/cecd/cecd_u.cpp
index 9b720a738..ace1c73c0 100644
--- a/src/core/hle/service/cecd/cecd_u.cpp
+++ b/src/core/hle/service/cecd/cecd_u.cpp
@@ -2,13 +2,16 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/hle/service/cecd/cecd.h"
5#include "core/hle/service/cecd/cecd_u.h" 6#include "core/hle/service/cecd/cecd_u.h"
6 7
7namespace Service { 8namespace Service {
8namespace CECD { 9namespace CECD {
9 10
10static const Interface::FunctionInfo FunctionTable[] = { 11static const Interface::FunctionInfo FunctionTable[] = {
11 { 0x00120104, nullptr, "ReadSavedData" }, 12 {0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
13 {0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
14 {0x00120104, nullptr, "ReadSavedData"},
12}; 15};
13 16
14CECD_U_Interface::CECD_U_Interface() { 17CECD_U_Interface::CECD_U_Interface() {
diff --git a/src/core/hle/service/cfg/cfg_i.cpp b/src/core/hle/service/cfg/cfg_i.cpp
index 0559a07b2..b18060f6d 100644
--- a/src/core/hle/service/cfg/cfg_i.cpp
+++ b/src/core/hle/service/cfg/cfg_i.cpp
@@ -9,6 +9,18 @@ namespace Service {
9namespace CFG { 9namespace CFG {
10 10
11const Interface::FunctionInfo FunctionTable[] = { 11const Interface::FunctionInfo FunctionTable[] = {
12 // cfg common
13 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
14 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
15 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
16 {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
17 {0x00050000, GetSystemModel, "GetSystemModel"},
18 {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
19 {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
20 {0x00080080, nullptr, "GoThroughTable"},
21 {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
22 {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
23 // cfg:i
12 {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"}, 24 {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
13 {0x04020082, nullptr, "SetConfigInfoBlk4"}, 25 {0x04020082, nullptr, "SetConfigInfoBlk4"},
14 {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"}, 26 {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
diff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cpp
index b03d290e5..e001f7687 100644
--- a/src/core/hle/service/cfg/cfg_s.cpp
+++ b/src/core/hle/service/cfg/cfg_s.cpp
@@ -9,10 +9,18 @@ namespace Service {
9namespace CFG { 9namespace CFG {
10 10
11const Interface::FunctionInfo FunctionTable[] = { 11const Interface::FunctionInfo FunctionTable[] = {
12 // cfg common
12 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"}, 13 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
13 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"}, 14 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
14 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"}, 15 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
16 {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
15 {0x00050000, GetSystemModel, "GetSystemModel"}, 17 {0x00050000, GetSystemModel, "GetSystemModel"},
18 {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
19 {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
20 {0x00080080, nullptr, "GoThroughTable"},
21 {0x00090040, GetCountryCodeString, "GetCountryCodeString"},
22 {0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
23 // cfg:s
16 {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"}, 24 {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
17 {0x04020082, nullptr, "SetConfigInfoBlk4"}, 25 {0x04020082, nullptr, "SetConfigInfoBlk4"},
18 {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"}, 26 {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
diff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cpp
index 89ae96c9e..606f7b2eb 100644
--- a/src/core/hle/service/cfg/cfg_u.cpp
+++ b/src/core/hle/service/cfg/cfg_u.cpp
@@ -9,6 +9,7 @@ namespace Service {
9namespace CFG { 9namespace CFG {
10 10
11const Interface::FunctionInfo FunctionTable[] = { 11const Interface::FunctionInfo FunctionTable[] = {
12 // cfg common
12 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"}, 13 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
13 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"}, 14 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
14 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"}, 15 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
diff --git a/src/core/hle/service/dlp_srvr.cpp b/src/core/hle/service/dlp_srvr.cpp
new file mode 100644
index 000000000..1f30188da
--- /dev/null
+++ b/src/core/hle/service/dlp_srvr.cpp
@@ -0,0 +1,36 @@
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 "common/logging/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/dlp_srvr.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace DLP_SRVR
11
12namespace DLP_SRVR {
13
14static void unk_0x000E0040(Service::Interface* self) {
15 u32* cmd_buff = Kernel::GetCommandBuffer();
16
17 cmd_buff[1] = RESULT_SUCCESS.raw;
18 cmd_buff[2] = 0;
19
20 LOG_WARNING(Service_DLP, "(STUBBED) called");
21}
22
23const Interface::FunctionInfo FunctionTable[] = {
24 {0x00010183, nullptr, "Initialize"},
25 {0x00020000, nullptr, "Finalize"},
26 {0x000E0040, unk_0x000E0040, "unk_0x000E0040"},
27};
28
29////////////////////////////////////////////////////////////////////////////////////////////////////
30// Interface class
31
32Interface::Interface() {
33 Register(FunctionTable);
34}
35
36} // namespace
diff --git a/src/core/hle/service/dlp_srvr.h b/src/core/hle/service/dlp_srvr.h
new file mode 100644
index 000000000..d65d00814
--- /dev/null
+++ b/src/core/hle/service/dlp_srvr.h
@@ -0,0 +1,23 @@
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 "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace DLP_SRVR
11
12namespace DLP_SRVR {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17
18 std::string GetPortName() const override {
19 return "dlp:SRVR";
20 }
21};
22
23} // namespace
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 590697e76..e9588cb72 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -15,7 +15,6 @@
15#include "common/common_types.h" 15#include "common/common_types.h"
16#include "common/file_util.h" 16#include "common/file_util.h"
17#include "common/logging/log.h" 17#include "common/logging/log.h"
18#include "common/make_unique.h"
19 18
20#include "core/file_sys/archive_backend.h" 19#include "core/file_sys/archive_backend.h"
21#include "core/file_sys/archive_extsavedata.h" 20#include "core/file_sys/archive_extsavedata.h"
@@ -521,23 +520,23 @@ void ArchiveInit() {
521 520
522 std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); 521 std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX);
523 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); 522 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
524 auto sdmc_factory = Common::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory); 523 auto sdmc_factory = std::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory);
525 if (sdmc_factory->Initialize()) 524 if (sdmc_factory->Initialize())
526 RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC); 525 RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
527 else 526 else
528 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); 527 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
529 528
530 // Create the SaveData archive 529 // Create the SaveData archive
531 auto savedata_factory = Common::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory); 530 auto savedata_factory = std::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
532 RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData); 531 RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
533 532
534 auto extsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false); 533 auto extsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
535 if (extsavedata_factory->Initialize()) 534 if (extsavedata_factory->Initialize())
536 RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData); 535 RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData);
537 else 536 else
538 LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str()); 537 LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str());
539 538
540 auto sharedextsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true); 539 auto sharedextsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
541 if (sharedextsavedata_factory->Initialize()) 540 if (sharedextsavedata_factory->Initialize())
542 RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData); 541 RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
543 else 542 else
@@ -545,10 +544,10 @@ void ArchiveInit() {
545 sharedextsavedata_factory->GetMountPoint().c_str()); 544 sharedextsavedata_factory->GetMountPoint().c_str());
546 545
547 // Create the SaveDataCheck archive, basically a small variation of the RomFS archive 546 // Create the SaveDataCheck archive, basically a small variation of the RomFS archive
548 auto savedatacheck_factory = Common::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory); 547 auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
549 RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck); 548 RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck);
550 549
551 auto systemsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory); 550 auto systemsavedata_factory = std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
552 RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData); 551 RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
553} 552}
554 553
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index 2ace2cade..0c655395e 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -31,6 +31,13 @@ const static u32 REGS_BEGIN = 0x1EB00000;
31 31
32namespace GSP_GPU { 32namespace GSP_GPU {
33 33
34const ResultCode ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(ErrorDescription::OutofRangeOrMisalignedAddress, ErrorModule::GX,
35 ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02A01
36const ResultCode ERR_GSP_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX,
37 ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BF2
38const ResultCode ERR_GSP_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX,
39 ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BEC
40
34/// Event triggered when GSP interrupt has been signalled 41/// Event triggered when GSP interrupt has been signalled
35Kernel::SharedPtr<Kernel::Event> g_interrupt_event; 42Kernel::SharedPtr<Kernel::Event> g_interrupt_event;
36/// GSP shared memoryings 43/// GSP shared memoryings
@@ -59,47 +66,87 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) {
59} 66}
60 67
61/** 68/**
62 * Checks if the parameters in a register write call are valid and logs in the case that 69 * Writes sequential GSP GPU hardware registers using an array of source data
63 * they are not 70 *
64 * @param base_address The first address in the sequence of registers that will be written 71 * @param base_address The address of the first register in the sequence
65 * @param size_in_bytes The number of registers that will be written 72 * @param size_in_bytes The number of registers to update (size of data)
66 * @return true if the parameters are valid, false otherwise 73 * @param data A pointer to the source data
74 * @return RESULT_SUCCESS if the parameters are valid, error code otherwise
67 */ 75 */
68static bool CheckWriteParameters(u32 base_address, u32 size_in_bytes) { 76static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) {
69 // TODO: Return proper error codes 77 // This magic number is verified to be done by the gsp module
70 if (base_address + size_in_bytes >= 0x420000) { 78 const u32 max_size_in_bytes = 0x80;
71 LOG_ERROR(Service_GSP, "Write address out of range! (address=0x%08x, size=0x%08x)", 79
80 if (base_address & 3 || base_address >= 0x420000) {
81 LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
72 base_address, size_in_bytes); 82 base_address, size_in_bytes);
73 return false; 83 return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
74 } 84 } else if (size_in_bytes <= max_size_in_bytes) {
85 if (size_in_bytes & 3) {
86 LOG_ERROR(Service_GSP, "Misaligned size 0x%08x", size_in_bytes);
87 return ERR_GSP_REGS_MISALIGNED;
88 } else {
89 while (size_in_bytes > 0) {
90 HW::Write<u32>(base_address + REGS_BEGIN, *data);
91
92 size_in_bytes -= 4;
93 ++data;
94 base_address += 4;
95 }
96 return RESULT_SUCCESS;
97 }
75 98
76 // size should be word-aligned 99 } else {
77 if ((size_in_bytes % 4) != 0) { 100 LOG_ERROR(Service_GSP, "Out of range size 0x%08x", size_in_bytes);
78 LOG_ERROR(Service_GSP, "Invalid size 0x%08x", size_in_bytes); 101 return ERR_GSP_REGS_INVALID_SIZE;
79 return false;
80 } 102 }
81
82 return true;
83} 103}
84 104
85/** 105/**
86 * Writes sequential GSP GPU hardware registers using an array of source data 106 * Updates sequential GSP GPU hardware registers using parallel arrays of source data and masks.
107 * For each register, the value is updated only where the mask is high
87 * 108 *
88 * @param base_address The address of the first register in the sequence 109 * @param base_address The address of the first register in the sequence
89 * @param size_in_bytes The number of registers to update (size of data) 110 * @param size_in_bytes The number of registers to update (size of data)
90 * @param data A pointer to the source data 111 * @param data A pointer to the source data to use for updates
112 * @param masks A pointer to the masks
113 * @return RESULT_SUCCESS if the parameters are valid, error code otherwise
91 */ 114 */
92static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { 115static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, const u32* data, const u32* masks) {
93 // TODO: Return proper error codes 116 // This magic number is verified to be done by the gsp module
94 if (!CheckWriteParameters(base_address, size_in_bytes)) 117 const u32 max_size_in_bytes = 0x80;
95 return;
96 118
97 while (size_in_bytes > 0) { 119 if (base_address & 3 || base_address >= 0x420000) {
98 HW::Write<u32>(base_address + REGS_BEGIN, *data); 120 LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
121 base_address, size_in_bytes);
122 return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
123 } else if (size_in_bytes <= max_size_in_bytes) {
124 if (size_in_bytes & 3) {
125 LOG_ERROR(Service_GSP, "Misaligned size 0x%08x", size_in_bytes);
126 return ERR_GSP_REGS_MISALIGNED;
127 } else {
128 while (size_in_bytes > 0) {
129 const u32 reg_address = base_address + REGS_BEGIN;
130
131 u32 reg_value;
132 HW::Read<u32>(reg_value, reg_address);
133
134 // Update the current value of the register only for set mask bits
135 reg_value = (reg_value & ~*masks) | (*data | *masks);
136
137 HW::Write<u32>(reg_address, reg_value);
138
139 size_in_bytes -= 4;
140 ++data;
141 ++masks;
142 base_address += 4;
143 }
144 return RESULT_SUCCESS;
145 }
99 146
100 size_in_bytes -= 4; 147 } else {
101 ++data; 148 LOG_ERROR(Service_GSP, "Out of range size 0x%08x", size_in_bytes);
102 base_address += 4; 149 return ERR_GSP_REGS_INVALID_SIZE;
103 } 150 }
104} 151}
105 152
@@ -120,39 +167,7 @@ static void WriteHWRegs(Service::Interface* self) {
120 167
121 u32* src = (u32*)Memory::GetPointer(cmd_buff[4]); 168 u32* src = (u32*)Memory::GetPointer(cmd_buff[4]);
122 169
123 WriteHWRegs(reg_addr, size, src); 170 cmd_buff[1] = WriteHWRegs(reg_addr, size, src).raw;
124}
125
126/**
127 * Updates sequential GSP GPU hardware registers using parallel arrays of source data and masks.
128 * For each register, the value is updated only where the mask is high
129 *
130 * @param base_address The address of the first register in the sequence
131 * @param size_in_bytes The number of registers to update (size of data)
132 * @param data A pointer to the source data to use for updates
133 * @param masks A pointer to the masks
134 */
135static void WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, const u32* data, const u32* masks) {
136 // TODO: Return proper error codes
137 if (!CheckWriteParameters(base_address, size_in_bytes))
138 return;
139
140 while (size_in_bytes > 0) {
141 const u32 reg_address = base_address + REGS_BEGIN;
142
143 u32 reg_value;
144 HW::Read<u32>(reg_value, reg_address);
145
146 // Update the current value of the register only for set mask bits
147 reg_value = (reg_value & ~*masks) | (*data | *masks);
148
149 HW::Write<u32>(reg_address, reg_value);
150
151 size_in_bytes -= 4;
152 ++data;
153 ++masks;
154 base_address += 4;
155 }
156} 171}
157 172
158/** 173/**
@@ -174,7 +189,7 @@ static void WriteHWRegsWithMask(Service::Interface* self) {
174 u32* src_data = (u32*)Memory::GetPointer(cmd_buff[4]); 189 u32* src_data = (u32*)Memory::GetPointer(cmd_buff[4]);
175 u32* mask_data = (u32*)Memory::GetPointer(cmd_buff[6]); 190 u32* mask_data = (u32*)Memory::GetPointer(cmd_buff[6]);
176 191
177 WriteHWRegsWithMask(reg_addr, size, src_data, mask_data); 192 cmd_buff[1] = WriteHWRegsWithMask(reg_addr, size, src_data, mask_data).raw;
178} 193}
179 194
180/// Read a GSP GPU hardware register 195/// Read a GSP GPU hardware register
@@ -206,27 +221,27 @@ static void ReadHWRegs(Service::Interface* self) {
206 } 221 }
207} 222}
208 223
209void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { 224ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
210 u32 base_address = 0x400000; 225 u32 base_address = 0x400000;
211 PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); 226 PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left);
212 PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); 227 PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right);
213 if (info.active_fb == 0) { 228 if (info.active_fb == 0) {
214 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)), 4, 229 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)),
215 &phys_address_left); 230 4, &phys_address_left);
216 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)), 4, 231 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)),
217 &phys_address_right); 232 4, &phys_address_right);
218 } else { 233 } else {
219 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)), 4, 234 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)),
220 &phys_address_left); 235 4, &phys_address_left);
221 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)), 4, 236 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)),
222 &phys_address_right); 237 4, &phys_address_right);
223 } 238 }
224 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)), 4, 239 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)),
225 &info.stride); 240 4, &info.stride);
226 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)), 4, 241 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)),
227 &info.format); 242 4, &info.format);
228 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)), 4, 243 WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)),
229 &info.shown_fb); 244 4, &info.shown_fb);
230 245
231 if (Pica::g_debug_context) 246 if (Pica::g_debug_context)
232 Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr); 247 Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
@@ -234,6 +249,8 @@ void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
234 if (screen_id == 0) { 249 if (screen_id == 0) {
235 MicroProfileFlip(); 250 MicroProfileFlip();
236 } 251 }
252
253 return RESULT_SUCCESS;
237} 254}
238 255
239/** 256/**
@@ -251,9 +268,8 @@ static void SetBufferSwap(Service::Interface* self) {
251 u32* cmd_buff = Kernel::GetCommandBuffer(); 268 u32* cmd_buff = Kernel::GetCommandBuffer();
252 u32 screen_id = cmd_buff[1]; 269 u32 screen_id = cmd_buff[1];
253 FrameBufferInfo* fb_info = (FrameBufferInfo*)&cmd_buff[2]; 270 FrameBufferInfo* fb_info = (FrameBufferInfo*)&cmd_buff[2];
254 SetBufferSwap(screen_id, *fb_info);
255 271
256 cmd_buff[1] = 0; // No error 272 cmd_buff[1] = SetBufferSwap(screen_id, *fb_info).raw;
257} 273}
258 274
259/** 275/**
@@ -286,6 +302,22 @@ static void FlushDataCache(Service::Interface* self) {
286} 302}
287 303
288/** 304/**
305 * GSP_GPU::SetAxiConfigQoSMode service function
306 * Inputs:
307 * 1 : Mode, unused in emulator
308 * Outputs:
309 * 1 : Result of function, 0 on success, otherwise error code
310 */
311static void SetAxiConfigQoSMode(Service::Interface* self) {
312 u32* cmd_buff = Kernel::GetCommandBuffer();
313 u32 mode = cmd_buff[1];
314
315 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
316
317 LOG_WARNING(Service_GSP, "(STUBBED) called mode=0x%08X", mode);
318}
319
320/**
289 * GSP_GPU::RegisterInterruptRelayQueue service function 321 * GSP_GPU::RegisterInterruptRelayQueue service function
290 * Inputs: 322 * Inputs:
291 * 1 : "Flags" field, purpose is unknown 323 * 1 : "Flags" field, purpose is unknown
@@ -302,6 +334,12 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
302 g_interrupt_event = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[3]); 334 g_interrupt_event = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[3]);
303 ASSERT_MSG((g_interrupt_event != nullptr), "handle is not valid!"); 335 ASSERT_MSG((g_interrupt_event != nullptr), "handle is not valid!");
304 336
337 g_interrupt_event->name = "GSP_GPU::interrupt_event";
338
339 using Kernel::MemoryPermission;
340 g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite,
341 MemoryPermission::ReadWrite, "GSPSharedMem");
342
305 Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); 343 Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom();
306 344
307 // This specific code is required for a successful initialization, rather than 0 345 // This specific code is required for a successful initialization, rather than 0
@@ -314,6 +352,22 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
314} 352}
315 353
316/** 354/**
355 * GSP_GPU::UnregisterInterruptRelayQueue service function
356 * Outputs:
357 * 1 : Result of function, 0 on success, otherwise error code
358 */
359static void UnregisterInterruptRelayQueue(Service::Interface* self) {
360 u32* cmd_buff = Kernel::GetCommandBuffer();
361
362 g_shared_memory = nullptr;
363 g_interrupt_event = nullptr;
364
365 cmd_buff[1] = RESULT_SUCCESS.raw;
366
367 LOG_WARNING(Service_GSP, "called");
368}
369
370/**
317 * Signals that the specified interrupt type has occurred to userland code 371 * Signals that the specified interrupt type has occurred to userland code
318 * @param interrupt_id ID of interrupt that is being signalled 372 * @param interrupt_id ID of interrupt that is being signalled
319 * @todo This should probably take a thread_id parameter and only signal this thread? 373 * @todo This should probably take a thread_id parameter and only signal this thread?
@@ -591,11 +645,11 @@ const Interface::FunctionInfo FunctionTable[] = {
591 {0x000D0140, nullptr, "SetDisplayTransfer"}, 645 {0x000D0140, nullptr, "SetDisplayTransfer"},
592 {0x000E0180, nullptr, "SetTextureCopy"}, 646 {0x000E0180, nullptr, "SetTextureCopy"},
593 {0x000F0200, nullptr, "SetMemoryFill"}, 647 {0x000F0200, nullptr, "SetMemoryFill"},
594 {0x00100040, nullptr, "SetAxiConfigQoSMode"}, 648 {0x00100040, SetAxiConfigQoSMode, "SetAxiConfigQoSMode"},
595 {0x00110040, nullptr, "SetPerfLogMode"}, 649 {0x00110040, nullptr, "SetPerfLogMode"},
596 {0x00120000, nullptr, "GetPerfLog"}, 650 {0x00120000, nullptr, "GetPerfLog"},
597 {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"}, 651 {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"},
598 {0x00140000, nullptr, "UnregisterInterruptRelayQueue"}, 652 {0x00140000, UnregisterInterruptRelayQueue, "UnregisterInterruptRelayQueue"},
599 {0x00150002, nullptr, "TryAcquireRight"}, 653 {0x00150002, nullptr, "TryAcquireRight"},
600 {0x00160042, nullptr, "AcquireRight"}, 654 {0x00160042, nullptr, "AcquireRight"},
601 {0x00170000, nullptr, "ReleaseRight"}, 655 {0x00170000, nullptr, "ReleaseRight"},
@@ -616,10 +670,7 @@ Interface::Interface() {
616 Register(FunctionTable); 670 Register(FunctionTable);
617 671
618 g_interrupt_event = nullptr; 672 g_interrupt_event = nullptr;
619 673 g_shared_memory = nullptr;
620 using Kernel::MemoryPermission;
621 g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite,
622 MemoryPermission::ReadWrite, "GSPSharedMem");
623 674
624 g_thread_id = 0; 675 g_thread_id = 0;
625} 676}
diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h
index 0e2f7a21e..55a993bb8 100644
--- a/src/core/hle/service/gsp_gpu.h
+++ b/src/core/hle/service/gsp_gpu.h
@@ -194,7 +194,7 @@ public:
194 */ 194 */
195void SignalInterrupt(InterruptId interrupt_id); 195void SignalInterrupt(InterruptId interrupt_id);
196 196
197void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); 197ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info);
198 198
199/** 199/**
200 * Retrieves the framebuffer info stored in the GSP shared memory for the 200 * Retrieves the framebuffer info stored in the GSP shared memory for the
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 833a68f05..0fe3a4d7a 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -9,6 +9,7 @@
9#include "core/hle/service/ac_u.h" 9#include "core/hle/service/ac_u.h"
10#include "core/hle/service/act_u.h" 10#include "core/hle/service/act_u.h"
11#include "core/hle/service/csnd_snd.h" 11#include "core/hle/service/csnd_snd.h"
12#include "core/hle/service/dlp_srvr.h"
12#include "core/hle/service/dsp_dsp.h" 13#include "core/hle/service/dsp_dsp.h"
13#include "core/hle/service/err_f.h" 14#include "core/hle/service/err_f.h"
14#include "core/hle/service/gsp_gpu.h" 15#include "core/hle/service/gsp_gpu.h"
@@ -120,6 +121,7 @@ void Init() {
120 AddService(new AC_U::Interface); 121 AddService(new AC_U::Interface);
121 AddService(new ACT_U::Interface); 122 AddService(new ACT_U::Interface);
122 AddService(new CSND_SND::Interface); 123 AddService(new CSND_SND::Interface);
124 AddService(new DLP_SRVR::Interface);
123 AddService(new DSP_DSP::Interface); 125 AddService(new DSP_DSP::Interface);
124 AddService(new GSP_GPU::Interface); 126 AddService(new GSP_GPU::Interface);
125 AddService(new GSP_LCD::Interface); 127 AddService(new GSP_LCD::Interface);
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index b1907cd55..886501c41 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -6,7 +6,6 @@
6#include <string> 6#include <string>
7 7
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "common/make_unique.h"
10#include "common/string_util.h" 9#include "common/string_util.h"
11 10
12#include "core/file_sys/archive_romfs.h" 11#include "core/file_sys/archive_romfs.h"
@@ -120,7 +119,7 @@ ResultStatus LoadFile(const std::string& filename) {
120 AppLoader_THREEDSX app_loader(std::move(file), filename_filename, filename); 119 AppLoader_THREEDSX app_loader(std::move(file), filename_filename, filename);
121 // Load application and RomFS 120 // Load application and RomFS
122 if (ResultStatus::Success == app_loader.Load()) { 121 if (ResultStatus::Success == app_loader.Load()) {
123 Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); 122 Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
124 return ResultStatus::Success; 123 return ResultStatus::Success;
125 } 124 }
126 break; 125 break;
@@ -139,7 +138,7 @@ ResultStatus LoadFile(const std::string& filename) {
139 // Load application and RomFS 138 // Load application and RomFS
140 ResultStatus result = app_loader.Load(); 139 ResultStatus result = app_loader.Load();
141 if (ResultStatus::Success == result) { 140 if (ResultStatus::Success == result) {
142 Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); 141 Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
143 } 142 }
144 return result; 143 return result;
145 } 144 }
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 93f21bec2..e63cab33f 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -7,7 +7,6 @@
7#include <memory> 7#include <memory>
8 8
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10#include "common/make_unique.h"
11#include "common/string_util.h" 10#include "common/string_util.h"
12#include "common/swap.h" 11#include "common/swap.h"
13 12
diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp
index 6467ff723..101f84eb9 100644
--- a/src/video_core/renderer_base.cpp
+++ b/src/video_core/renderer_base.cpp
@@ -4,8 +4,6 @@
4 4
5#include <memory> 5#include <memory>
6 6
7#include "common/make_unique.h"
8
9#include "core/settings.h" 7#include "core/settings.h"
10 8
11#include "video_core/renderer_base.h" 9#include "video_core/renderer_base.h"
@@ -19,9 +17,9 @@ void RendererBase::RefreshRasterizerSetting() {
19 opengl_rasterizer_active = hw_renderer_enabled; 17 opengl_rasterizer_active = hw_renderer_enabled;
20 18
21 if (hw_renderer_enabled) { 19 if (hw_renderer_enabled) {
22 rasterizer = Common::make_unique<RasterizerOpenGL>(); 20 rasterizer = std::make_unique<RasterizerOpenGL>();
23 } else { 21 } else {
24 rasterizer = Common::make_unique<VideoCore::SWRasterizer>(); 22 rasterizer = std::make_unique<VideoCore::SWRasterizer>();
25 } 23 }
26 rasterizer->InitObjects(); 24 rasterizer->InitObjects();
27 rasterizer->Reset(); 25 rasterizer->Reset();
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 1fadcf5ae..cc6b3aeab 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -9,7 +9,6 @@
9 9
10#include "common/color.h" 10#include "common/color.h"
11#include "common/file_util.h" 11#include "common/file_util.h"
12#include "common/make_unique.h"
13#include "common/math_util.h" 12#include "common/math_util.h"
14#include "common/microprofile.h" 13#include "common/microprofile.h"
15#include "common/profiler.h" 14#include "common/profiler.h"
@@ -677,7 +676,7 @@ void RasterizerOpenGL::ReconfigureDepthTexture(DepthTextureInfo& texture, Pica::
677 676
678void RasterizerOpenGL::SetShader() { 677void RasterizerOpenGL::SetShader() {
679 PicaShaderConfig config = PicaShaderConfig::CurrentConfig(); 678 PicaShaderConfig config = PicaShaderConfig::CurrentConfig();
680 std::unique_ptr<PicaShader> shader = Common::make_unique<PicaShader>(); 679 std::unique_ptr<PicaShader> shader = std::make_unique<PicaShader>();
681 680
682 // Find (or generate) the GLSL shader for the current TEV state 681 // Find (or generate) the GLSL shader for the current TEV state
683 auto cached_shader = shader_cache.find(config); 682 auto cached_shader = shader_cache.find(config);
@@ -808,6 +807,9 @@ void RasterizerOpenGL::SyncFramebuffer() {
808 807
809 ReloadDepthBuffer(); 808 ReloadDepthBuffer();
810 } 809 }
810
811 ASSERT_MSG(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE,
812 "OpenGL rasterizer framebuffer setup failed, status %X", glCheckFramebufferStatus(GL_FRAMEBUFFER));
811} 813}
812 814
813void RasterizerOpenGL::SyncCullMode() { 815void RasterizerOpenGL::SyncCullMode() {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index a9ad46fe0..1323c12e4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -2,8 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory>
6
5#include "common/hash.h" 7#include "common/hash.h"
6#include "common/make_unique.h"
7#include "common/math_util.h" 8#include "common/math_util.h"
8#include "common/microprofile.h" 9#include "common/microprofile.h"
9#include "common/vector_math.h" 10#include "common/vector_math.h"
@@ -29,7 +30,7 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
29 } else { 30 } else {
30 MICROPROFILE_SCOPE(OpenGL_TextureUpload); 31 MICROPROFILE_SCOPE(OpenGL_TextureUpload);
31 32
32 std::unique_ptr<CachedTexture> new_texture = Common::make_unique<CachedTexture>(); 33 std::unique_ptr<CachedTexture> new_texture = std::make_unique<CachedTexture>();
33 34
34 new_texture->texture.Create(); 35 new_texture->texture.Create();
35 state.texture_units[texture_unit].texture_2d = new_texture->texture.handle; 36 state.texture_units[texture_unit].texture_2d = new_texture->texture.handle;
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h
index 3d6c4e9e5..fd3617d77 100644
--- a/src/video_core/renderer_opengl/pica_to_gl.h
+++ b/src/video_core/renderer_opengl/pica_to_gl.h
@@ -22,7 +22,7 @@ inline GLenum TextureFilterMode(Pica::Regs::TextureConfig::TextureFilter mode) {
22 }; 22 };
23 23
24 // Range check table for input 24 // Range check table for input
25 if (mode >= ARRAY_SIZE(filter_mode_table)) { 25 if (static_cast<size_t>(mode) >= ARRAY_SIZE(filter_mode_table)) {
26 LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode %d", mode); 26 LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode %d", mode);
27 UNREACHABLE(); 27 UNREACHABLE();
28 28
@@ -51,7 +51,7 @@ inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
51 }; 51 };
52 52
53 // Range check table for input 53 // Range check table for input
54 if (mode >= ARRAY_SIZE(wrap_mode_table)) { 54 if (static_cast<size_t>(mode) >= ARRAY_SIZE(wrap_mode_table)) {
55 LOG_CRITICAL(Render_OpenGL, "Unknown texture wrap mode %d", mode); 55 LOG_CRITICAL(Render_OpenGL, "Unknown texture wrap mode %d", mode);
56 UNREACHABLE(); 56 UNREACHABLE();
57 57
@@ -91,7 +91,7 @@ inline GLenum BlendFunc(Pica::Regs::BlendFactor factor) {
91 }; 91 };
92 92
93 // Range check table for input 93 // Range check table for input
94 if ((unsigned)factor >= ARRAY_SIZE(blend_func_table)) { 94 if (static_cast<size_t>(factor) >= ARRAY_SIZE(blend_func_table)) {
95 LOG_CRITICAL(Render_OpenGL, "Unknown blend factor %d", factor); 95 LOG_CRITICAL(Render_OpenGL, "Unknown blend factor %d", factor);
96 UNREACHABLE(); 96 UNREACHABLE();
97 97
@@ -122,7 +122,7 @@ inline GLenum LogicOp(Pica::Regs::LogicOp op) {
122 }; 122 };
123 123
124 // Range check table for input 124 // Range check table for input
125 if ((unsigned)op >= ARRAY_SIZE(logic_op_table)) { 125 if (static_cast<size_t>(op) >= ARRAY_SIZE(logic_op_table)) {
126 LOG_CRITICAL(Render_OpenGL, "Unknown logic op %d", op); 126 LOG_CRITICAL(Render_OpenGL, "Unknown logic op %d", op);
127 UNREACHABLE(); 127 UNREACHABLE();
128 128
@@ -145,7 +145,7 @@ inline GLenum CompareFunc(Pica::Regs::CompareFunc func) {
145 }; 145 };
146 146
147 // Range check table for input 147 // Range check table for input
148 if ((unsigned)func >= ARRAY_SIZE(compare_func_table)) { 148 if (static_cast<size_t>(func) >= ARRAY_SIZE(compare_func_table)) {
149 LOG_CRITICAL(Render_OpenGL, "Unknown compare function %d", func); 149 LOG_CRITICAL(Render_OpenGL, "Unknown compare function %d", func);
150 UNREACHABLE(); 150 UNREACHABLE();
151 151
@@ -168,7 +168,7 @@ inline GLenum StencilOp(Pica::Regs::StencilAction action) {
168 }; 168 };
169 169
170 // Range check table for input 170 // Range check table for input
171 if ((unsigned)action >= ARRAY_SIZE(stencil_op_table)) { 171 if (static_cast<size_t>(action) >= ARRAY_SIZE(stencil_op_table)) {
172 LOG_CRITICAL(Render_OpenGL, "Unknown stencil op %d", action); 172 LOG_CRITICAL(Render_OpenGL, "Unknown stencil op %d", action);
173 UNREACHABLE(); 173 UNREACHABLE();
174 174
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index eb1db0778..78d295c76 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -8,7 +8,6 @@
8#include <boost/range/algorithm/fill.hpp> 8#include <boost/range/algorithm/fill.hpp>
9 9
10#include "common/hash.h" 10#include "common/hash.h"
11#include "common/make_unique.h"
12#include "common/microprofile.h" 11#include "common/microprofile.h"
13#include "common/profiler.h" 12#include "common/profiler.h"
14 13
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index ee5e50df1..256899c89 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -5,7 +5,6 @@
5#include <memory> 5#include <memory>
6 6
7#include "common/emu_window.h" 7#include "common/emu_window.h"
8#include "common/make_unique.h"
9#include "common/logging/log.h" 8#include "common/logging/log.h"
10 9
11#include "core/core.h" 10#include "core/core.h"
@@ -32,7 +31,7 @@ bool Init(EmuWindow* emu_window) {
32 Pica::Init(); 31 Pica::Init();
33 32
34 g_emu_window = emu_window; 33 g_emu_window = emu_window;
35 g_renderer = Common::make_unique<RendererOpenGL>(); 34 g_renderer = std::make_unique<RendererOpenGL>();
36 g_renderer->SetWindow(g_emu_window); 35 g_renderer->SetWindow(g_emu_window);
37 if (g_renderer->Init()) { 36 if (g_renderer->Init()) {
38 LOG_DEBUG(Render, "initialized OK"); 37 LOG_DEBUG(Render, "initialized OK");