diff options
Diffstat (limited to 'src')
25 files changed, 802 insertions, 165 deletions
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 | ||
| 8 | set(HEADERS | 9 | set(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 | |||
| 14 | namespace DSP { | ||
| 15 | namespace HLE { | ||
| 16 | |||
| 17 | /// The final output to the speakers is stereo. Preprocessing output in Source is also stereo. | ||
| 18 | using StereoFrame16 = std::array<std::array<s16, 2>, AudioCore::samples_per_frame>; | ||
| 19 | |||
| 20 | /// The DSP is quadraphonic internally. | ||
| 21 | using 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 | */ | ||
| 27 | template<typename FrameT, typename FilterT> | ||
| 28 | void 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 | |||
| 15 | namespace DSP { | ||
| 16 | namespace HLE { | ||
| 17 | |||
| 18 | void SourceFilters::Reset() { | ||
| 19 | Enable(false, false); | ||
| 20 | } | ||
| 21 | |||
| 22 | void 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 | |||
| 32 | void SourceFilters::Configure(SourceConfiguration::Configuration::SimpleFilter config) { | ||
| 33 | simple_filter.Configure(config); | ||
| 34 | } | ||
| 35 | |||
| 36 | void SourceFilters::Configure(SourceConfiguration::Configuration::BiquadFilter config) { | ||
| 37 | biquad_filter.Configure(config); | ||
| 38 | } | ||
| 39 | |||
| 40 | void 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 | |||
| 55 | void SourceFilters::SimpleFilter::Reset() { | ||
| 56 | y1.fill(0); | ||
| 57 | // Configure as passthrough. | ||
| 58 | a1 = 0; | ||
| 59 | b0 = 1 << 15; | ||
| 60 | } | ||
| 61 | |||
| 62 | void SourceFilters::SimpleFilter::Configure(SourceConfiguration::Configuration::SimpleFilter config) { | ||
| 63 | a1 = config.a1; | ||
| 64 | b0 = config.b0; | ||
| 65 | } | ||
| 66 | |||
| 67 | std::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 | |||
| 81 | void 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 | |||
| 91 | void 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 | |||
| 99 | std::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 | |||
| 14 | namespace DSP { | ||
| 15 | namespace HLE { | ||
| 16 | |||
| 17 | /// Preprocessing filters. There is an independent set of filters for each Source. | ||
| 18 | class 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 | |||
| 51 | private: | ||
| 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_qt/config.cpp b/src/citra_qt/config.cpp index 8e247ff5c..d1a19ade9 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp | |||
| @@ -16,7 +16,7 @@ Config::Config() { | |||
| 16 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 16 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| 17 | qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; | 17 | qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; |
| 18 | FileUtil::CreateFullPath(qt_config_loc); | 18 | FileUtil::CreateFullPath(qt_config_loc); |
| 19 | qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); | 19 | qt_config = new QSettings(QString::fromLocal8Bit(qt_config_loc.c_str()), QSettings::IniFormat); |
| 20 | 20 | ||
| 21 | Reload(); | 21 | Reload(); |
| 22 | } | 22 | } |
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 1f8d69a03..a0b216b0a 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.toLocal8Bit()); |
| 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); |
| @@ -148,7 +148,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d | |||
| 148 | 148 | ||
| 149 | emit EntryReady({ | 149 | emit EntryReady({ |
| 150 | new GameListItem(QString::fromStdString(Loader::GetFileTypeString(filetype))), | 150 | new GameListItem(QString::fromStdString(Loader::GetFileTypeString(filetype))), |
| 151 | new GameListItemPath(QString::fromStdString(physical_name)), | 151 | new GameListItemPath(QString::fromLocal8Bit(physical_name.c_str())), |
| 152 | new GameListItemSize(FileUtil::GetSize(physical_name)), | 152 | new GameListItemSize(FileUtil::GetSize(physical_name)), |
| 153 | }); | 153 | }); |
| 154 | } | 154 | } |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index a0ae4c9fa..7c3486dea 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -105,7 +105,7 @@ public: | |||
| 105 | * @todo Fix this function to be thread-safe. | 105 | * @todo Fix this function to be thread-safe. |
| 106 | * @return PadState object indicating the current pad state | 106 | * @return PadState object indicating the current pad state |
| 107 | */ | 107 | */ |
| 108 | const Service::HID::PadState GetPadState() const { | 108 | Service::HID::PadState GetPadState() const { |
| 109 | return pad_state; | 109 | return pad_state; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| @@ -116,11 +116,59 @@ public: | |||
| 116 | * @return std::tuple of (x, y, pressed) where `x` and `y` are the touch coordinates and | 116 | * @return std::tuple of (x, y, pressed) where `x` and `y` are the touch coordinates and |
| 117 | * `pressed` is true if the touch screen is currently being pressed | 117 | * `pressed` is true if the touch screen is currently being pressed |
| 118 | */ | 118 | */ |
| 119 | const std::tuple<u16, u16, bool> GetTouchState() const { | 119 | std::tuple<u16, u16, bool> GetTouchState() const { |
| 120 | return std::make_tuple(touch_x, touch_y, touch_pressed); | 120 | return std::make_tuple(touch_x, touch_y, touch_pressed); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | /** | 123 | /** |
| 124 | * Gets the current accelerometer state (acceleration along each three axis). | ||
| 125 | * Axis explained: | ||
| 126 | * +x is the same direction as LEFT on D-pad. | ||
| 127 | * +y is normal to the touch screen, pointing outward. | ||
| 128 | * +z is the same direction as UP on D-pad. | ||
| 129 | * Units: | ||
| 130 | * 1 unit of return value = 1/512 g (measured by hw test), | ||
| 131 | * where g is the gravitational acceleration (9.8 m/sec2). | ||
| 132 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 133 | * @todo Implement accelerometer input in front-end. | ||
| 134 | * @return std::tuple of (x, y, z) | ||
| 135 | */ | ||
| 136 | std::tuple<s16, s16, s16> GetAccelerometerState() const { | ||
| 137 | // stubbed | ||
| 138 | return std::make_tuple(0, -512, 0); | ||
| 139 | } | ||
| 140 | |||
| 141 | /** | ||
| 142 | * Gets the current gyroscope state (angular rates about each three axis). | ||
| 143 | * Axis explained: | ||
| 144 | * +x is the same direction as LEFT on D-pad. | ||
| 145 | * +y is normal to the touch screen, pointing outward. | ||
| 146 | * +z is the same direction as UP on D-pad. | ||
| 147 | * Orientation is determined by right-hand rule. | ||
| 148 | * Units: | ||
| 149 | * 1 unit of return value = (1/coef) deg/sec, | ||
| 150 | * where coef is the return value of GetGyroscopeRawToDpsCoefficient(). | ||
| 151 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 152 | * @todo Implement gyroscope input in front-end. | ||
| 153 | * @return std::tuple of (x, y, z) | ||
| 154 | */ | ||
| 155 | std::tuple<s16, s16, s16> GetGyroscopeState() const { | ||
| 156 | // stubbed | ||
| 157 | return std::make_tuple(0, 0, 0); | ||
| 158 | } | ||
| 159 | |||
| 160 | /** | ||
| 161 | * Gets the coefficient for units conversion of gyroscope state. | ||
| 162 | * The conversion formula is r = coefficient * v, | ||
| 163 | * where v is angular rate in deg/sec, | ||
| 164 | * and r is the gyroscope state. | ||
| 165 | * @return float-type coefficient | ||
| 166 | */ | ||
| 167 | f32 GetGyroscopeRawToDpsCoefficient() const { | ||
| 168 | return 14.375f; // taken from hw test, and gyroscope's document | ||
| 169 | } | ||
| 170 | |||
| 171 | /** | ||
| 124 | * Returns currently active configuration. | 172 | * Returns currently active configuration. |
| 125 | * @note Accesses to the returned object need not be consistent because it may be modified in another thread | 173 | * @note Accesses to the returned object need not be consistent because it may be modified in another thread |
| 126 | */ | 174 | */ |
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 97d2a2242..cfbfbc2a7 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -46,6 +46,7 @@ namespace Log { | |||
| 46 | SUB(Service, NIM) \ | 46 | SUB(Service, NIM) \ |
| 47 | SUB(Service, NWM) \ | 47 | SUB(Service, NWM) \ |
| 48 | SUB(Service, CAM) \ | 48 | SUB(Service, CAM) \ |
| 49 | SUB(Service, CECD) \ | ||
| 49 | SUB(Service, CFG) \ | 50 | SUB(Service, CFG) \ |
| 50 | SUB(Service, DSP) \ | 51 | SUB(Service, DSP) \ |
| 51 | SUB(Service, DLP) \ | 52 | SUB(Service, DLP) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index d0c6c5f43..4f6856f3d 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -61,6 +61,7 @@ enum class Class : ClassType { | |||
| 61 | Service_NIM, ///< The NIM (Network interface manager) service | 61 | Service_NIM, ///< The NIM (Network interface manager) service |
| 62 | Service_NWM, ///< The NWM (Network wlan manager) service | 62 | Service_NWM, ///< The NWM (Network wlan manager) service |
| 63 | Service_CAM, ///< The CAM (Camera) service | 63 | Service_CAM, ///< The CAM (Camera) service |
| 64 | Service_CECD, ///< The CECD service | ||
| 64 | Service_CFG, ///< The CFG (Configuration) service | 65 | Service_CFG, ///< The CFG (Configuration) service |
| 65 | Service_DSP, ///< The DSP (DSP control) service | 66 | Service_DSP, ///< The DSP (DSP control) service |
| 66 | Service_DLP, ///< The DLP (Download Play) service | 67 | Service_DLP, ///< The DLP (Download Play) service |
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 | ||
| 3467 | MICROPROFILE_DEFINE(DynCom_Decode, "DynCom", "Decode", MP_RGB(255, 64, 64)); | 3468 | MICROPROFILE_DEFINE(DynCom_Decode, "DynCom", "Decode", MP_RGB(255, 64, 64)); |
| 3468 | 3469 | ||
| 3469 | static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) { | 3470 | static 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 | |||
| 3498 | static 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 | ||
| 3511 | translated: | ||
| 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 | ||
| 3532 | static 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 | |||
| 3525 | static int clz(unsigned int x) { | 3553 | static 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/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 @@ | |||
| 12 | namespace Service { | 13 | namespace Service { |
| 13 | namespace CECD { | 14 | namespace CECD { |
| 14 | 15 | ||
| 15 | void Init() { | 16 | static Kernel::SharedPtr<Kernel::Event> cecinfo_event; |
| 16 | using namespace Kernel; | 17 | static Kernel::SharedPtr<Kernel::Event> change_state_event; |
| 18 | |||
| 19 | void 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 | |||
| 28 | void 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 | |||
| 37 | void 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 | ||
| 22 | void Shutdown() { | 45 | void 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 | ||
| 7 | namespace Service { | 7 | namespace Service { |
| 8 | |||
| 9 | class Interface; | ||
| 10 | |||
| 8 | namespace CECD { | 11 | namespace CECD { |
| 9 | 12 | ||
| 13 | /** | ||
| 14 | * GetCecInfoEventHandle service function | ||
| 15 | * Inputs: | ||
| 16 | * 0: 0x000F0000 | ||
| 17 | * Outputs: | ||
| 18 | * 1: ResultCode | ||
| 19 | * 3: Event Handle | ||
| 20 | */ | ||
| 21 | void 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 | */ | ||
| 31 | void GetChangeStateEventHandle(Service::Interface* self); | ||
| 32 | |||
| 10 | /// Initialize CECD service(s) | 33 | /// Initialize CECD service(s) |
| 11 | void Init(); | 34 | void 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 | ||
| 7 | namespace Service { | 8 | namespace Service { |
| 8 | namespace CECD { | 9 | namespace CECD { |
| 9 | 10 | ||
| 10 | static const Interface::FunctionInfo FunctionTable[] = { | 11 | static const Interface::FunctionInfo FunctionTable[] = { |
| 11 | { 0x00120104, nullptr, "ReadSavedData" }, | 12 | {0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"}, |
| 13 | {0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"}, | ||
| 14 | {0x00120104, nullptr, "ReadSavedData"}, | ||
| 12 | }; | 15 | }; |
| 13 | 16 | ||
| 14 | CECD_U_Interface::CECD_U_Interface() { | 17 | CECD_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 { | |||
| 9 | namespace CFG { | 9 | namespace CFG { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const 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 { | |||
| 9 | namespace CFG { | 9 | namespace CFG { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const 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 { | |||
| 9 | namespace CFG { | 9 | namespace CFG { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const 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/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 | ||
| 32 | namespace GSP_GPU { | 32 | namespace GSP_GPU { |
| 33 | 33 | ||
| 34 | const ResultCode ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(ErrorDescription::OutofRangeOrMisalignedAddress, ErrorModule::GX, | ||
| 35 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02A01 | ||
| 36 | const ResultCode ERR_GSP_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX, | ||
| 37 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BF2 | ||
| 38 | const 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 |
| 35 | Kernel::SharedPtr<Kernel::Event> g_interrupt_event; | 42 | Kernel::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 | */ |
| 68 | static bool CheckWriteParameters(u32 base_address, u32 size_in_bytes) { | 76 | static 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 | */ |
| 92 | static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { | 115 | static 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 | */ | ||
| 135 | static 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 | ||
| 209 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { | 224 | ResultCode 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 | */ | ||
| 311 | static 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 | */ | ||
| 359 | static 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 | */ |
| 195 | void SignalInterrupt(InterruptId interrupt_id); | 195 | void SignalInterrupt(InterruptId interrupt_id); |
| 196 | 196 | ||
| 197 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); | 197 | ResultCode 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/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index cb4fd38e2..1053d0f40 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -33,6 +33,11 @@ static Kernel::SharedPtr<Kernel::Event> event_debug_pad; | |||
| 33 | 33 | ||
| 34 | static u32 next_pad_index; | 34 | static u32 next_pad_index; |
| 35 | static u32 next_touch_index; | 35 | static u32 next_touch_index; |
| 36 | static u32 next_accelerometer_index; | ||
| 37 | static u32 next_gyroscope_index; | ||
| 38 | |||
| 39 | static int enable_accelerometer_count = 0; // positive means enabled | ||
| 40 | static int enable_gyroscope_count = 0; // positive means enabled | ||
| 36 | 41 | ||
| 37 | const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping = {{ | 42 | const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping = {{ |
| 38 | Service::HID::PAD_A, Service::HID::PAD_B, Service::HID::PAD_X, Service::HID::PAD_Y, | 43 | Service::HID::PAD_A, Service::HID::PAD_B, Service::HID::PAD_X, Service::HID::PAD_Y, |
| @@ -78,17 +83,17 @@ void Update() { | |||
| 78 | PadState changed = { { (state.hex ^ old_state.hex) } }; | 83 | PadState changed = { { (state.hex ^ old_state.hex) } }; |
| 79 | 84 | ||
| 80 | // Get the current Pad entry | 85 | // Get the current Pad entry |
| 81 | PadDataEntry* pad_entry = &mem->pad.entries[mem->pad.index]; | 86 | PadDataEntry& pad_entry = mem->pad.entries[mem->pad.index]; |
| 82 | 87 | ||
| 83 | // Update entry properties | 88 | // Update entry properties |
| 84 | pad_entry->current_state.hex = state.hex; | 89 | pad_entry.current_state.hex = state.hex; |
| 85 | pad_entry->delta_additions.hex = changed.hex & state.hex; | 90 | pad_entry.delta_additions.hex = changed.hex & state.hex; |
| 86 | pad_entry->delta_removals.hex = changed.hex & old_state.hex;; | 91 | pad_entry.delta_removals.hex = changed.hex & old_state.hex;; |
| 87 | 92 | ||
| 88 | // Set circle Pad | 93 | // Set circle Pad |
| 89 | pad_entry->circle_pad_x = state.circle_left ? -MAX_CIRCLEPAD_POS : | 94 | pad_entry.circle_pad_x = state.circle_left ? -MAX_CIRCLEPAD_POS : |
| 90 | state.circle_right ? MAX_CIRCLEPAD_POS : 0x0; | 95 | state.circle_right ? MAX_CIRCLEPAD_POS : 0x0; |
| 91 | pad_entry->circle_pad_y = state.circle_down ? -MAX_CIRCLEPAD_POS : | 96 | pad_entry.circle_pad_y = state.circle_down ? -MAX_CIRCLEPAD_POS : |
| 92 | state.circle_up ? MAX_CIRCLEPAD_POS : 0x0; | 97 | state.circle_up ? MAX_CIRCLEPAD_POS : 0x0; |
| 93 | 98 | ||
| 94 | // If we just updated index 0, provide a new timestamp | 99 | // If we just updated index 0, provide a new timestamp |
| @@ -101,11 +106,11 @@ void Update() { | |||
| 101 | next_touch_index = (next_touch_index + 1) % mem->touch.entries.size(); | 106 | next_touch_index = (next_touch_index + 1) % mem->touch.entries.size(); |
| 102 | 107 | ||
| 103 | // Get the current touch entry | 108 | // Get the current touch entry |
| 104 | TouchDataEntry* touch_entry = &mem->touch.entries[mem->touch.index]; | 109 | TouchDataEntry& touch_entry = mem->touch.entries[mem->touch.index]; |
| 105 | bool pressed = false; | 110 | bool pressed = false; |
| 106 | 111 | ||
| 107 | std::tie(touch_entry->x, touch_entry->y, pressed) = VideoCore::g_emu_window->GetTouchState(); | 112 | std::tie(touch_entry.x, touch_entry.y, pressed) = VideoCore::g_emu_window->GetTouchState(); |
| 108 | touch_entry->valid.Assign(pressed ? 1 : 0); | 113 | touch_entry.valid.Assign(pressed ? 1 : 0); |
| 109 | 114 | ||
| 110 | // TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which | 115 | // TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which |
| 111 | // supposedly is "Touch-screen entry, which contains the raw coordinate data prior to being | 116 | // supposedly is "Touch-screen entry, which contains the raw coordinate data prior to being |
| @@ -120,6 +125,58 @@ void Update() { | |||
| 120 | // Signal both handles when there's an update to Pad or touch | 125 | // Signal both handles when there's an update to Pad or touch |
| 121 | event_pad_or_touch_1->Signal(); | 126 | event_pad_or_touch_1->Signal(); |
| 122 | event_pad_or_touch_2->Signal(); | 127 | event_pad_or_touch_2->Signal(); |
| 128 | |||
| 129 | // Update accelerometer | ||
| 130 | if (enable_accelerometer_count > 0) { | ||
| 131 | mem->accelerometer.index = next_accelerometer_index; | ||
| 132 | next_accelerometer_index = (next_accelerometer_index + 1) % mem->accelerometer.entries.size(); | ||
| 133 | |||
| 134 | AccelerometerDataEntry& accelerometer_entry = mem->accelerometer.entries[mem->accelerometer.index]; | ||
| 135 | std::tie(accelerometer_entry.x, accelerometer_entry.y, accelerometer_entry.z) | ||
| 136 | = VideoCore::g_emu_window->GetAccelerometerState(); | ||
| 137 | |||
| 138 | // Make up "raw" entry | ||
| 139 | // TODO(wwylele): | ||
| 140 | // From hardware testing, the raw_entry values are approximately, | ||
| 141 | // but not exactly, as twice as corresponding entries (or with a minus sign). | ||
| 142 | // It may caused by system calibration to the accelerometer. | ||
| 143 | // Figure out how it works, or, if no game reads raw_entry, | ||
| 144 | // the following three lines can be removed and leave raw_entry unimplemented. | ||
| 145 | mem->accelerometer.raw_entry.x = -2 * accelerometer_entry.x; | ||
| 146 | mem->accelerometer.raw_entry.z = 2 * accelerometer_entry.y; | ||
| 147 | mem->accelerometer.raw_entry.y = -2 * accelerometer_entry.z; | ||
| 148 | |||
| 149 | // If we just updated index 0, provide a new timestamp | ||
| 150 | if (mem->accelerometer.index == 0) { | ||
| 151 | mem->accelerometer.index_reset_ticks_previous = mem->accelerometer.index_reset_ticks; | ||
| 152 | mem->accelerometer.index_reset_ticks = (s64)CoreTiming::GetTicks(); | ||
| 153 | } | ||
| 154 | |||
| 155 | event_accelerometer->Signal(); | ||
| 156 | } | ||
| 157 | |||
| 158 | // Update gyroscope | ||
| 159 | if (enable_gyroscope_count > 0) { | ||
| 160 | mem->gyroscope.index = next_gyroscope_index; | ||
| 161 | next_gyroscope_index = (next_gyroscope_index + 1) % mem->gyroscope.entries.size(); | ||
| 162 | |||
| 163 | GyroscopeDataEntry& gyroscope_entry = mem->gyroscope.entries[mem->gyroscope.index]; | ||
| 164 | std::tie(gyroscope_entry.x, gyroscope_entry.y, gyroscope_entry.z) | ||
| 165 | = VideoCore::g_emu_window->GetGyroscopeState(); | ||
| 166 | |||
| 167 | // Make up "raw" entry | ||
| 168 | mem->gyroscope.raw_entry.x = gyroscope_entry.x; | ||
| 169 | mem->gyroscope.raw_entry.z = -gyroscope_entry.y; | ||
| 170 | mem->gyroscope.raw_entry.y = gyroscope_entry.z; | ||
| 171 | |||
| 172 | // If we just updated index 0, provide a new timestamp | ||
| 173 | if (mem->gyroscope.index == 0) { | ||
| 174 | mem->gyroscope.index_reset_ticks_previous = mem->gyroscope.index_reset_ticks; | ||
| 175 | mem->gyroscope.index_reset_ticks = (s64)CoreTiming::GetTicks(); | ||
| 176 | } | ||
| 177 | |||
| 178 | event_gyroscope->Signal(); | ||
| 179 | } | ||
| 123 | } | 180 | } |
| 124 | 181 | ||
| 125 | void GetIPCHandles(Service::Interface* self) { | 182 | void GetIPCHandles(Service::Interface* self) { |
| @@ -139,40 +196,69 @@ void GetIPCHandles(Service::Interface* self) { | |||
| 139 | void EnableAccelerometer(Service::Interface* self) { | 196 | void EnableAccelerometer(Service::Interface* self) { |
| 140 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 197 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 141 | 198 | ||
| 199 | ++enable_accelerometer_count; | ||
| 142 | event_accelerometer->Signal(); | 200 | event_accelerometer->Signal(); |
| 143 | 201 | ||
| 144 | cmd_buff[1] = RESULT_SUCCESS.raw; | 202 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 145 | 203 | ||
| 146 | LOG_WARNING(Service_HID, "(STUBBED) called"); | 204 | LOG_DEBUG(Service_HID, "called"); |
| 147 | } | 205 | } |
| 148 | 206 | ||
| 149 | void DisableAccelerometer(Service::Interface* self) { | 207 | void DisableAccelerometer(Service::Interface* self) { |
| 150 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 208 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 151 | 209 | ||
| 210 | --enable_accelerometer_count; | ||
| 152 | event_accelerometer->Signal(); | 211 | event_accelerometer->Signal(); |
| 153 | 212 | ||
| 154 | cmd_buff[1] = RESULT_SUCCESS.raw; | 213 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 155 | 214 | ||
| 156 | LOG_WARNING(Service_HID, "(STUBBED) called"); | 215 | LOG_DEBUG(Service_HID, "called"); |
| 157 | } | 216 | } |
| 158 | 217 | ||
| 159 | void EnableGyroscopeLow(Service::Interface* self) { | 218 | void EnableGyroscopeLow(Service::Interface* self) { |
| 160 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 219 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 161 | 220 | ||
| 221 | ++enable_gyroscope_count; | ||
| 162 | event_gyroscope->Signal(); | 222 | event_gyroscope->Signal(); |
| 163 | 223 | ||
| 164 | cmd_buff[1] = RESULT_SUCCESS.raw; | 224 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 165 | 225 | ||
| 166 | LOG_WARNING(Service_HID, "(STUBBED) called"); | 226 | LOG_DEBUG(Service_HID, "called"); |
| 167 | } | 227 | } |
| 168 | 228 | ||
| 169 | void DisableGyroscopeLow(Service::Interface* self) { | 229 | void DisableGyroscopeLow(Service::Interface* self) { |
| 170 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 230 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 171 | 231 | ||
| 232 | --enable_gyroscope_count; | ||
| 172 | event_gyroscope->Signal(); | 233 | event_gyroscope->Signal(); |
| 173 | 234 | ||
| 174 | cmd_buff[1] = RESULT_SUCCESS.raw; | 235 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 175 | 236 | ||
| 237 | LOG_DEBUG(Service_HID, "called"); | ||
| 238 | } | ||
| 239 | |||
| 240 | void GetGyroscopeLowRawToDpsCoefficient(Service::Interface* self) { | ||
| 241 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 242 | |||
| 243 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 244 | |||
| 245 | f32 coef = VideoCore::g_emu_window->GetGyroscopeRawToDpsCoefficient(); | ||
| 246 | memcpy(&cmd_buff[2], &coef, 4); | ||
| 247 | } | ||
| 248 | |||
| 249 | void GetGyroscopeLowCalibrateParam(Service::Interface* self) { | ||
| 250 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 251 | |||
| 252 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 253 | |||
| 254 | const s16 param_unit = 6700; // an approximate value taken from hw | ||
| 255 | GyroscopeCalibrateParam param = { | ||
| 256 | { 0, param_unit, -param_unit }, | ||
| 257 | { 0, param_unit, -param_unit }, | ||
| 258 | { 0, param_unit, -param_unit }, | ||
| 259 | }; | ||
| 260 | memcpy(&cmd_buff[2], ¶m, sizeof(param)); | ||
| 261 | |||
| 176 | LOG_WARNING(Service_HID, "(STUBBED) called"); | 262 | LOG_WARNING(Service_HID, "(STUBBED) called"); |
| 177 | } | 263 | } |
| 178 | 264 | ||
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 517f4f2ae..170d19ea8 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -78,6 +78,24 @@ struct TouchDataEntry { | |||
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * Structure of a single entry of accelerometer state history within HID shared memory | ||
| 82 | */ | ||
| 83 | struct AccelerometerDataEntry { | ||
| 84 | s16 x; | ||
| 85 | s16 y; | ||
| 86 | s16 z; | ||
| 87 | }; | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Structure of a single entry of gyroscope state history within HID shared memory | ||
| 91 | */ | ||
| 92 | struct GyroscopeDataEntry { | ||
| 93 | s16 x; | ||
| 94 | s16 y; | ||
| 95 | s16 z; | ||
| 96 | }; | ||
| 97 | |||
| 98 | /** | ||
| 81 | * Structure of data stored in HID shared memory | 99 | * Structure of data stored in HID shared memory |
| 82 | */ | 100 | */ |
| 83 | struct SharedMem { | 101 | struct SharedMem { |
| @@ -112,6 +130,46 @@ struct SharedMem { | |||
| 112 | 130 | ||
| 113 | std::array<TouchDataEntry, 8> entries; ///< Last 8 touch entries, in pixel coordinates | 131 | std::array<TouchDataEntry, 8> entries; ///< Last 8 touch entries, in pixel coordinates |
| 114 | } touch; | 132 | } touch; |
| 133 | |||
| 134 | /// Accelerometer data | ||
| 135 | struct { | ||
| 136 | s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0 | ||
| 137 | s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks` | ||
| 138 | u32 index; ///< Index of the last updated accelerometer entry | ||
| 139 | |||
| 140 | INSERT_PADDING_WORDS(0x1); | ||
| 141 | |||
| 142 | AccelerometerDataEntry raw_entry; | ||
| 143 | INSERT_PADDING_BYTES(2); | ||
| 144 | |||
| 145 | std::array<AccelerometerDataEntry, 8> entries; | ||
| 146 | } accelerometer; | ||
| 147 | |||
| 148 | /// Gyroscope data | ||
| 149 | struct { | ||
| 150 | s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0 | ||
| 151 | s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks` | ||
| 152 | u32 index; ///< Index of the last updated accelerometer entry | ||
| 153 | |||
| 154 | INSERT_PADDING_WORDS(0x1); | ||
| 155 | |||
| 156 | GyroscopeDataEntry raw_entry; | ||
| 157 | INSERT_PADDING_BYTES(2); | ||
| 158 | |||
| 159 | std::array<GyroscopeDataEntry, 32> entries; | ||
| 160 | } gyroscope; | ||
| 161 | }; | ||
| 162 | |||
| 163 | /** | ||
| 164 | * Structure of calibrate params that GetGyroscopeLowCalibrateParam returns | ||
| 165 | */ | ||
| 166 | struct GyroscopeCalibrateParam { | ||
| 167 | struct { | ||
| 168 | // TODO (wwylele): figure out the exact meaning of these params | ||
| 169 | s16 zero_point; | ||
| 170 | s16 positive_unit_point; | ||
| 171 | s16 negative_unit_point; | ||
| 172 | } x, y, z; | ||
| 115 | }; | 173 | }; |
| 116 | 174 | ||
| 117 | // TODO: MSVC does not support using offsetof() on non-static data members even though this | 175 | // TODO: MSVC does not support using offsetof() on non-static data members even though this |
| @@ -222,6 +280,26 @@ void DisableGyroscopeLow(Interface* self); | |||
| 222 | */ | 280 | */ |
| 223 | void GetSoundVolume(Interface* self); | 281 | void GetSoundVolume(Interface* self); |
| 224 | 282 | ||
| 283 | /** | ||
| 284 | * HID::GetGyroscopeLowRawToDpsCoefficient service function | ||
| 285 | * Inputs: | ||
| 286 | * None | ||
| 287 | * Outputs: | ||
| 288 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 289 | * 2 : float output value | ||
| 290 | */ | ||
| 291 | void GetGyroscopeLowRawToDpsCoefficient(Service::Interface* self); | ||
| 292 | |||
| 293 | /** | ||
| 294 | * HID::GetGyroscopeLowCalibrateParam service function | ||
| 295 | * Inputs: | ||
| 296 | * None | ||
| 297 | * Outputs: | ||
| 298 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 299 | * 2~6 (18 bytes) : struct GyroscopeCalibrateParam | ||
| 300 | */ | ||
| 301 | void GetGyroscopeLowCalibrateParam(Service::Interface* self); | ||
| 302 | |||
| 225 | /// Checks for user input updates | 303 | /// Checks for user input updates |
| 226 | void Update(); | 304 | void Update(); |
| 227 | 305 | ||
diff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cpp index c50f597eb..046e65b11 100644 --- a/src/core/hle/service/hid/hid_spvr.cpp +++ b/src/core/hle/service/hid/hid_spvr.cpp | |||
| @@ -9,16 +9,16 @@ namespace Service { | |||
| 9 | namespace HID { | 9 | namespace HID { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const Interface::FunctionInfo FunctionTable[] = { |
| 12 | {0x000A0000, GetIPCHandles, "GetIPCHandles"}, | 12 | {0x000A0000, GetIPCHandles, "GetIPCHandles"}, |
| 13 | {0x000B0000, nullptr, "StartAnalogStickCalibration"}, | 13 | {0x000B0000, nullptr, "StartAnalogStickCalibration"}, |
| 14 | {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"}, | 14 | {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"}, |
| 15 | {0x00110000, EnableAccelerometer, "EnableAccelerometer"}, | 15 | {0x00110000, EnableAccelerometer, "EnableAccelerometer"}, |
| 16 | {0x00120000, DisableAccelerometer, "DisableAccelerometer"}, | 16 | {0x00120000, DisableAccelerometer, "DisableAccelerometer"}, |
| 17 | {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"}, | 17 | {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"}, |
| 18 | {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"}, | 18 | {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"}, |
| 19 | {0x00150000, nullptr, "GetGyroscopeLowRawToDpsCoefficient"}, | 19 | {0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"}, |
| 20 | {0x00160000, nullptr, "GetGyroscopeLowCalibrateParam"}, | 20 | {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"}, |
| 21 | {0x00170000, GetSoundVolume, "GetSoundVolume"}, | 21 | {0x00170000, GetSoundVolume, "GetSoundVolume"}, |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | HID_SPVR_Interface::HID_SPVR_Interface() { | 24 | HID_SPVR_Interface::HID_SPVR_Interface() { |
diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp index bbdde2abb..bb157b83d 100644 --- a/src/core/hle/service/hid/hid_user.cpp +++ b/src/core/hle/service/hid/hid_user.cpp | |||
| @@ -9,16 +9,16 @@ namespace Service { | |||
| 9 | namespace HID { | 9 | namespace HID { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const Interface::FunctionInfo FunctionTable[] = { |
| 12 | {0x000A0000, GetIPCHandles, "GetIPCHandles"}, | 12 | {0x000A0000, GetIPCHandles, "GetIPCHandles"}, |
| 13 | {0x000B0000, nullptr, "StartAnalogStickCalibration"}, | 13 | {0x000B0000, nullptr, "StartAnalogStickCalibration"}, |
| 14 | {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"}, | 14 | {0x000E0000, nullptr, "GetAnalogStickCalibrateParam"}, |
| 15 | {0x00110000, EnableAccelerometer, "EnableAccelerometer"}, | 15 | {0x00110000, EnableAccelerometer, "EnableAccelerometer"}, |
| 16 | {0x00120000, DisableAccelerometer, "DisableAccelerometer"}, | 16 | {0x00120000, DisableAccelerometer, "DisableAccelerometer"}, |
| 17 | {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"}, | 17 | {0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"}, |
| 18 | {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"}, | 18 | {0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"}, |
| 19 | {0x00150000, nullptr, "GetGyroscopeLowRawToDpsCoefficient"}, | 19 | {0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"}, |
| 20 | {0x00160000, nullptr, "GetGyroscopeLowCalibrateParam"}, | 20 | {0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"}, |
| 21 | {0x00170000, GetSoundVolume, "GetSoundVolume"}, | 21 | {0x00170000, GetSoundVolume, "GetSoundVolume"}, |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | HID_U_Interface::HID_U_Interface() { | 24 | HID_U_Interface::HID_U_Interface() { |
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 | ||