diff options
32 files changed, 421 insertions, 178 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe9f76cd..05a560404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ if (NOT MSVC) else() # Silence deprecation warnings add_definitions(/D_CRT_SECURE_NO_WARNINGS) + # set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) endif() add_definitions(-DSINGLETHREADED) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index f45d09fc2..1f8f5922b 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -36,7 +36,8 @@ bool Config::LoadINI(INIReader* config, const char* location, const std::string& return true; } -void Config::ReadControls() { +void Config::ReadValues() { + // Controls Settings::values.pad_a_key = glfw_config->GetInteger("Controls", "pad_a", GLFW_KEY_A); Settings::values.pad_b_key = glfw_config->GetInteger("Controls", "pad_b", GLFW_KEY_S); Settings::values.pad_x_key = glfw_config->GetInteger("Controls", "pad_x", GLFW_KEY_Z); @@ -54,27 +55,21 @@ void Config::ReadControls() { Settings::values.pad_sdown_key = glfw_config->GetInteger("Controls", "pad_sdown", GLFW_KEY_DOWN); Settings::values.pad_sleft_key = glfw_config->GetInteger("Controls", "pad_sleft", GLFW_KEY_LEFT); Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT); -} -void Config::ReadCore() { + // Core Settings::values.cpu_core = glfw_config->GetInteger("Core", "cpu_core", Core::CPU_Interpreter); Settings::values.gpu_refresh_rate = glfw_config->GetInteger("Core", "gpu_refresh_rate", 60); -} -void Config::ReadData() { + // Data Storage Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true); -} -void Config::ReadMiscellaneous() { + // Miscellaneous Settings::values.enable_log = glfw_config->GetBoolean("Miscellaneous", "enable_log", true); } void Config::Reload() { LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file); - ReadControls(); - ReadCore(); - ReadData(); - ReadMiscellaneous(); + ReadValues(); } Config::~Config() { diff --git a/src/citra/config.h b/src/citra/config.h index 19bb83700..2b46fa8aa 100644 --- a/src/citra/config.h +++ b/src/citra/config.h @@ -15,10 +15,7 @@ class Config { std::string glfw_config_loc; bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true); - void ReadControls(); - void ReadCore(); - void ReadData(); - void ReadMiscellaneous(); + void ReadValues(); public: Config(); ~Config(); diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 8efb39e2e..697bf4693 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp @@ -58,9 +58,13 @@ EmuWindow_GLFW::EmuWindow_GLFW() { ReloadSetKeymaps(); + glfwSetErrorCallback([](int error, const char *desc){ + ERROR_LOG(GUI, "GLFW 0x%08x: %s", error, desc); + }); + // Initialize the window if(glfwInit() != GL_TRUE) { - printf("Failed to initialize GLFW! Exiting..."); + ERROR_LOG(GUI, "Failed to initialize GLFW! Exiting..."); exit(1); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); @@ -75,7 +79,7 @@ EmuWindow_GLFW::EmuWindow_GLFW() { window_title.c_str(), NULL, NULL); if (m_render_window == NULL) { - printf("Failed to create GLFW window! Exiting..."); + ERROR_LOG(GUI, "Failed to create GLFW window! Exiting..."); exit(1); } diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 09fce4d6f..3209e5900 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -21,7 +21,7 @@ Config::Config() { Reload(); } -void Config::ReadControls() { +void Config::ReadValues() { qt_config->beginGroup("Controls"); Settings::values.pad_a_key = qt_config->value("pad_a", Qt::Key_A).toInt(); Settings::values.pad_b_key = qt_config->value("pad_b", Qt::Key_S).toInt(); @@ -41,9 +41,22 @@ void Config::ReadControls() { Settings::values.pad_sleft_key = qt_config->value("pad_sleft", Qt::Key_Left).toInt(); Settings::values.pad_sright_key = qt_config->value("pad_sright", Qt::Key_Right).toInt(); qt_config->endGroup(); + + qt_config->beginGroup("Core"); + Settings::values.cpu_core = qt_config->value("cpu_core", Core::CPU_Interpreter).toInt(); + Settings::values.gpu_refresh_rate = qt_config->value("gpu_refresh_rate", 60).toInt(); + qt_config->endGroup(); + + qt_config->beginGroup("Data Storage"); + Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool(); + qt_config->endGroup(); + + qt_config->beginGroup("Miscellaneous"); + Settings::values.enable_log = qt_config->value("enable_log", true).toBool(); + qt_config->endGroup(); } -void Config::SaveControls() { +void Config::SaveValues() { qt_config->beginGroup("Controls"); qt_config->setValue("pad_a", Settings::values.pad_a_key); qt_config->setValue("pad_b", Settings::values.pad_b_key); @@ -63,58 +76,27 @@ void Config::SaveControls() { qt_config->setValue("pad_sleft", Settings::values.pad_sleft_key); qt_config->setValue("pad_sright", Settings::values.pad_sright_key); qt_config->endGroup(); -} - -void Config::ReadCore() { - qt_config->beginGroup("Core"); - Settings::values.cpu_core = qt_config->value("cpu_core", Core::CPU_Interpreter).toInt(); - Settings::values.gpu_refresh_rate = qt_config->value("gpu_refresh_rate", 60).toInt(); - qt_config->endGroup(); -} -void Config::SaveCore() { qt_config->beginGroup("Core"); qt_config->setValue("cpu_core", Settings::values.cpu_core); qt_config->setValue("gpu_refresh_rate", Settings::values.gpu_refresh_rate); qt_config->endGroup(); -} - -void Config::ReadData() { - qt_config->beginGroup("Data Storage"); - Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool(); - qt_config->endGroup(); -} -void Config::SaveData() { qt_config->beginGroup("Data Storage"); qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd); qt_config->endGroup(); -} - -void Config::ReadMiscellaneous() { - qt_config->beginGroup("Miscellaneous"); - Settings::values.enable_log = qt_config->value("enable_log", true).toBool(); - qt_config->endGroup(); -} -void Config::SaveMiscellaneous() { qt_config->beginGroup("Miscellaneous"); qt_config->setValue("enable_log", Settings::values.enable_log); qt_config->endGroup(); } void Config::Reload() { - ReadControls(); - ReadCore(); - ReadData(); - ReadMiscellaneous(); + ReadValues(); } void Config::Save() { - SaveControls(); - SaveCore(); - SaveData(); - SaveMiscellaneous(); + SaveValues(); } Config::~Config() { diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h index 8c6568cb2..4c95d0cb9 100644 --- a/src/citra_qt/config.h +++ b/src/citra_qt/config.h @@ -12,15 +12,8 @@ class Config { QSettings* qt_config; std::string qt_config_loc; - void ReadControls(); - void SaveControls(); - void ReadCore(); - void SaveCore(); - void ReadData(); - void SaveData(); - - void ReadMiscellaneous(); - void SaveMiscellaneous(); + void ReadValues(); + void SaveValues(); public: Config(); ~Config(); diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 38c681ee0..2ef7d98c0 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp @@ -7,7 +7,6 @@ #include "common/log_manager.h" #include "common/console_listener.h" #include "common/timer.h" -#include "common/thread.h" void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, const char* function, const char* fmt, ...) diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index f899e2e8a..233cd3e3a 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -26,7 +26,7 @@ #define CITRA_IGNORE_EXIT(x) #include <algorithm> -#include <map> +#include <unordered_map> #include <stdio.h> #include <assert.h> #include <cstdio> @@ -94,9 +94,8 @@ typedef unsigned int (*shtop_fp_t)(arm_processor *cpu, unsigned int sht_oper); /* exclusive memory access */ static int exclusive_detect(ARMul_State* state, ARMword addr){ - int i; #if 0 - for(i = 0; i < 128; i++){ + for(int i = 0; i < 128; i++){ if(state->exclusive_tag_array[i] == addr) return 0; } @@ -108,9 +107,8 @@ static int exclusive_detect(ARMul_State* state, ARMword addr){ } static void add_exclusive_addr(ARMul_State* state, ARMword addr){ - int i; #if 0 - for(i = 0; i < 128; i++){ + for(int i = 0; i < 128; i++){ if(state->exclusive_tag_array[i] == 0xffffffff){ state->exclusive_tag_array[i] = addr; //DEBUG_LOG(ARM11, "In %s, add addr 0x%x\n", __func__, addr); @@ -3309,9 +3307,8 @@ const transop_fp_t arm_instruction_trans[] = { INTERPRETER_TRANSLATE(blx_1_thumb) }; -typedef map<unsigned int, int> bb_map; -bb_map CreamCache[65536]; -bb_map ProfileCache[65536]; +typedef std::unordered_map<u32, int> bb_map; +bb_map CreamCache; //#define USE_DUMMY_CACHE @@ -3319,14 +3316,12 @@ bb_map ProfileCache[65536]; unsigned int DummyCache[0x100000]; #endif -#define HASH(x) ((x + (x << 3) + (x >> 6)) % 65536) void insert_bb(unsigned int addr, int start) { #ifdef USE_DUMMY_CACHE DummyCache[addr] = start; #else -// CreamCache[addr] = start; - CreamCache[HASH(addr)][addr] = start; + CreamCache[addr] = start; #endif } @@ -3341,8 +3336,8 @@ int find_bb(unsigned int addr, int &start) } else ret = -1; #else - bb_map::const_iterator it = CreamCache[HASH(addr)].find(addr); - if (it != CreamCache[HASH(addr)].end()) { + bb_map::const_iterator it = CreamCache.find(addr); + if (it != CreamCache.end()) { start = static_cast<int>(it->second); ret = 0; #if HYBRID_MODE @@ -3473,30 +3468,15 @@ void flush_bb(uint32_t addr) uint32_t start; addr &= 0xfffff000; - for (int i = 0; i < 65536; i ++) { - for (it = CreamCache[i].begin(); it != CreamCache[i].end(); ) { - start = static_cast<uint32_t>(it->first); - //start = (start >> 12) << 12; - start &= 0xfffff000; - if (start == addr) { - //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); - CreamCache[i].erase(it ++); - } else - ++it; - } - } - - for (int i = 0; i < 65536; i ++) { - for (it = ProfileCache[i].begin(); it != ProfileCache[i].end(); ) { - start = static_cast<uint32_t>(it->first); - //start = (start >> 12) << 12; - start &= 0xfffff000; - if (start == addr) { - //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); - ProfileCache[i].erase(it ++); - } else - ++it; - } + for (it = CreamCache.begin(); it != CreamCache.end(); ) { + start = static_cast<uint32_t>(it->first); + //start = (start >> 12) << 12; + start &= 0xfffff000; + if (start == addr) { + //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); + CreamCache.erase(it++); + } else + ++it; } //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr); diff --git a/src/core/arm/skyeye_common/armcpu.h b/src/core/arm/skyeye_common/armcpu.h index 3a029f0e7..2b756c5bc 100644 --- a/src/core/arm/skyeye_common/armcpu.h +++ b/src/core/arm/skyeye_common/armcpu.h @@ -24,8 +24,6 @@ #include <stddef.h> #include <stdio.h> -#include "common/thread.h" - #include "core/arm/skyeye_common/armdefs.h" typedef struct ARM_CPU_State_s { diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 5ea75361e..f3cb11133 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h @@ -67,6 +67,8 @@ public: u16str = std::u16string(data, size/2 - 1); // Data is always null-terminated. break; } + default: + break; } } diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index a740a3d59..169ab0f1c 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -50,7 +50,7 @@ bool Archive_SDMC::Initialize() { * @return Opened file, or nullptr */ std::unique_ptr<File> Archive_SDMC::OpenFile(const Path& path, const Mode mode) const { - DEBUG_LOG(FILESYS, "called path=%s mode=%d", path.DebugStr().c_str(), mode); + DEBUG_LOG(FILESYS, "called path=%s mode=%u", path.DebugStr().c_str(), mode.hex); File_SDMC* file = new File_SDMC(this, path, mode); if (!file->Open()) return nullptr; diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 018000abd..80a34c2d5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include <algorithm> + #include "common/common.h" #include "core/core.h" @@ -37,7 +39,7 @@ Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) { return 0; } -bool ObjectPool::IsValid(Handle handle) { +bool ObjectPool::IsValid(Handle handle) const { int index = handle - HANDLE_OFFSET; if (index < 0) return false; @@ -75,13 +77,8 @@ void ObjectPool::List() { } } -int ObjectPool::GetCount() { - int count = 0; - for (int i = 0; i < MAX_COUNT; i++) { - if (occupied[i]) - count++; - } - return count; +int ObjectPool::GetCount() const { + return std::count(occupied.begin(), occupied.end(), true); } Object* ObjectPool::CreateByIDType(int type) { diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 8d3937ce8..00a2228bf 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -86,7 +86,7 @@ public: } } - bool IsValid(Handle handle); + bool IsValid(Handle handle) const; template <class T> T* Get(Handle handle) { @@ -142,7 +142,7 @@ public: Object* &operator [](Handle handle); void List(); void Clear(); - int GetCount(); + int GetCount() const; private: diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index b303ba128..d07e9761b 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -88,20 +88,19 @@ bool ReleaseMutexForThread(Mutex* mutex, Handle thread) { bool ReleaseMutex(Mutex* mutex) { MutexEraseLock(mutex); - bool woke_threads = false; // Find the next waiting thread for the mutex... - while (!woke_threads && !mutex->waiting_threads.empty()) { + while (!mutex->waiting_threads.empty()) { std::vector<Handle>::iterator iter = mutex->waiting_threads.begin(); - woke_threads |= ReleaseMutexForThread(mutex, *iter); + ReleaseMutexForThread(mutex, *iter); mutex->waiting_threads.erase(iter); } + // Reset mutex lock thread handle, nothing is waiting - if (!woke_threads) { - mutex->locked = false; - mutex->lock_thread = -1; - } - return woke_threads; + mutex->locked = false; + mutex->lock_thread = -1; + + return true; } /** diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f3f54a4e9..f59795901 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -143,7 +143,7 @@ void ChangeReadyState(Thread* t, bool ready) { /// Verify that a thread has not been released from waiting inline bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle) { _dbg_assert_(KERNEL, thread != nullptr); - return type == thread->wait_type && wait_handle == thread->wait_handle; + return (type == thread->wait_type) && (wait_handle == thread->wait_handle) && (thread->IsWaiting()); } /// Stops the current thread diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp index 9af96f6b8..46aee40d6 100644 --- a/src/core/hle/service/ac_u.cpp +++ b/src/core/hle/service/ac_u.cpp @@ -11,6 +11,24 @@ namespace AC_U { +/** + * AC_U::GetWifiStatus service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Output connection type, 0 = none, 1 = Old3DS Internet, 2 = New3DS Internet. + */ +void GetWifiStatus(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + // TODO(purpasmart96): This function is only a stub, + // it returns a valid result without implementing full functionality. + + cmd_buff[1] = 0; // No error + cmd_buff[2] = 0; // Connection type set to none + + WARN_LOG(KERNEL, "(STUBBED) called"); +} + const Interface::FunctionInfo FunctionTable[] = { {0x00010000, nullptr, "CreateDefaultConfig"}, {0x00040006, nullptr, "ConnectAsync"}, @@ -18,7 +36,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00080004, nullptr, "CloseAsync"}, {0x00090002, nullptr, "GetCloseResult"}, {0x000A0000, nullptr, "GetLastErrorCode"}, - {0x000D0000, nullptr, "GetWifiStatus"}, + {0x000D0000, GetWifiStatus, "GetWifiStatus"}, {0x000E0042, nullptr, "GetCurrentAPInfo"}, {0x00100042, nullptr, "GetCurrentNZoneInfo"}, {0x00110042, nullptr, "GetNZoneApNumService"}, diff --git a/src/core/hle/service/cfg_u.cpp b/src/core/hle/service/cfg_u.cpp index 822b0e2b8..d6b586ea0 100644 --- a/src/core/hle/service/cfg_u.cpp +++ b/src/core/hle/service/cfg_u.cpp @@ -11,6 +11,90 @@ namespace CFG_U { +static const std::array<const char*, 187> country_codes = { + nullptr, "JP", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 0-7 + "AI", "AG", "AR", "AW", "BS", "BB", "BZ", "BO", // 8-15 + "BR", "VG", "CA", "KY", "CL", "CO", "CR", "DM", // 16-23 + "DO", "EC", "SV", "GF", "GD", "GP", "GT", "GY", // 24-31 + "HT", "HN", "JM", "MQ", "MX", "MS", "AN", "NI", // 32-39 + "PA", "PY", "PE", "KN", "LC", "VC", "SR", "TT", // 40-47 + "TC", "US", "UY", "VI", "VE", nullptr, nullptr, nullptr, // 48-55 + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 56-63 + "AL", "AU", "AT", "BE", "BA", "BW", "BG", "HR", // 64-71 + "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", // 72-79 + "HU", "IS", "IE", "IT", "LV", "LS", "LI", "LT", // 80-87 + "LU", "MK", "MT", "ME", "MZ", "NA", "NL", "NZ", // 88-95 + "NO", "PL", "PT", "RO", "RU", "RS", "SK", "SI", // 96-103 + "ZA", "ES", "SZ", "SE", "CH", "TR", "GB", "ZM", // 104-111 + "ZW", "AZ", "MR", "ML", "NE", "TD", "SD", "ER", // 112-119 + "DJ", "SO", "AD", "GI", "GG", "IM", "JE", "MC", // 120-127 + "TW", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 128-135 + "KR", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 136-143 + "HK", "MO", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 144-151 + "ID", "SG", "TH", "PH", "MY", nullptr, nullptr, nullptr, // 152-159 + "CN", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 160-167 + "AE", "IN", "EG", "OM", "QA", "KW", "SA", "SY", // 168-175 + "BH", "JO", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // 176-183 + "SM", "VA", "BM", // 184-186 +}; + +/** + * CFG_User::GetCountryCodeString service function + * Inputs: + * 1 : Country Code ID + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Country's 2-char string + */ +static void GetCountryCodeString(Service::Interface* self) { + u32* cmd_buffer = Service::GetCommandBuffer(); + u32 country_code_id = cmd_buffer[1]; + + if (country_code_id >= country_codes.size()) { + ERROR_LOG(KERNEL, "requested country code id=%d is invalid", country_code_id); + cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; + return; + } + + const char* code = country_codes[country_code_id]; + if (code != nullptr) { + cmd_buffer[1] = 0; + cmd_buffer[2] = code[0] | (code[1] << 8); + } else { + cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; + DEBUG_LOG(KERNEL, "requested country code id=%d is not set", country_code_id); + } +} + +/** + * CFG_User::GetCountryCodeID service function + * Inputs: + * 1 : Country Code 2-char string + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Country Code ID + */ +static void GetCountryCodeID(Service::Interface* self) { + u32* cmd_buffer = Service::GetCommandBuffer(); + u16 country_code = cmd_buffer[1]; + u16 country_code_id = -1; + + for (u32 i = 0; i < country_codes.size(); ++i) { + const char* code_string = country_codes[i]; + + if (code_string != nullptr) { + u16 code = code_string[0] | (code_string[1] << 8); + if (code == country_code) { + country_code_id = i; + break; + } + } + } + + cmd_buffer[1] = 0; + cmd_buffer[2] = country_code_id; +} + const Interface::FunctionInfo FunctionTable[] = { {0x00010082, nullptr, "GetConfigInfoBlk2"}, {0x00020000, nullptr, "SecureInfoGetRegion"}, @@ -20,8 +104,8 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00060000, nullptr, "GetModelNintendo2DS"}, {0x00070040, nullptr, "unknown"}, {0x00080080, nullptr, "unknown"}, - {0x00090080, nullptr, "GetCountryCodeString"}, - {0x000A0040, nullptr, "GetCountryCodeID"}, + {0x00090040, GetCountryCodeString, "GetCountryCodeString"}, + {0x000A0040, GetCountryCodeID, "GetCountryCodeID"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// // Interface class diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp index bbcf26f61..72be4c817 100644 --- a/src/core/hle/service/dsp_dsp.cpp +++ b/src/core/hle/service/dsp_dsp.cpp @@ -4,6 +4,7 @@ #include "common/log.h" #include "core/hle/hle.h" +#include "core/hle/kernel/event.h" #include "core/hle/service/dsp_dsp.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -11,38 +12,137 @@ namespace DSP_DSP { +static Handle semaphore_event; +static Handle interrupt_event; + +/** + * DSP_DSP::ConvertProcessAddressFromDspDram service function + * Inputs: + * 1 : Address + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : (inaddr << 1) + 0x1FF40000 (where 0x1FF00000 is the DSP RAM address) + */ +void ConvertProcessAddressFromDspDram(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + u32 addr = cmd_buff[1]; + + cmd_buff[1] = 0; // No error + cmd_buff[2] = (addr << 1) + (Memory::DSP_MEMORY_VADDR + 0x40000); + + DEBUG_LOG(KERNEL, "(STUBBED) called with address %u", addr); +} + +/** + * DSP_DSP::LoadComponent service function + * Inputs: + * 1 : Size + * 2 : Unknown (observed only half word used) + * 3 : Unknown (observed only half word used) + * 4 : (size << 4) | 0xA + * 5 : Buffer address + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Component loaded, 0 on not loaded, 1 on loaded + */ +void LoadComponent(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + cmd_buff[1] = 0; // No error + cmd_buff[2] = 1; // Pretend that we actually loaded the DSP firmware + + // TODO(bunnei): Implement real DSP firmware loading + + DEBUG_LOG(KERNEL, "(STUBBED) called"); +} + +/** + * DSP_DSP::GetSemaphoreEventHandle service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 3 : Semaphore event handle + */ +void GetSemaphoreEventHandle(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + cmd_buff[1] = 0; // No error + cmd_buff[3] = semaphore_event; // Event handle + + DEBUG_LOG(KERNEL, "(STUBBED) called"); +} + +/** + * DSP_DSP::RegisterInterruptEvents service function + * Inputs: + * 1 : Parameter 0 (purpose unknown) + * 2 : Parameter 1 (purpose unknown) + * 4 : Interrupt event handle + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +void RegisterInterruptEvents(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + interrupt_event = static_cast<Handle>(cmd_buff[4]); + + cmd_buff[1] = 0; // No error + + DEBUG_LOG(KERNEL, "(STUBBED) called"); +} + +/** + * DSP_DSP::WriteReg0x10 service function + * Inputs: + * 1 : Unknown (observed only half word used) + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +void WriteReg0x10(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + Kernel::SignalEvent(interrupt_event); + + cmd_buff[1] = 0; // No error + + DEBUG_LOG(KERNEL, "(STUBBED) called"); +} + const Interface::FunctionInfo FunctionTable[] = { - {0x00010040, nullptr, "RecvData"}, - {0x00020040, nullptr, "RecvDataIsReady"}, - {0x00030080, nullptr, "SendData"}, - {0x00040040, nullptr, "SendDataIsEmpty"}, - {0x00070040, nullptr, "WriteReg0x10"}, - {0x00080000, nullptr, "GetSemaphore"}, - {0x00090040, nullptr, "ClearSemaphore"}, - {0x000B0000, nullptr, "CheckSemaphoreRequest"}, - {0x000C0040, nullptr, "ConvertProcessAddressFromDspDram"}, - {0x000D0082, nullptr, "WriteProcessPipe"}, - {0x001000C0, nullptr, "ReadPipeIfPossible"}, - {0x001100C2, nullptr, "LoadComponent"}, - {0x00120000, nullptr, "UnloadComponent"}, - {0x00130082, nullptr, "FlushDataCache"}, - {0x00140082, nullptr, "InvalidateDCache"}, - {0x00150082, nullptr, "RegisterInterruptEvents"}, - {0x00160000, nullptr, "GetSemaphoreEventHandle"}, - {0x00170040, nullptr, "SetSemaphoreMask"}, - {0x00180040, nullptr, "GetPhysicalAddress"}, - {0x00190040, nullptr, "GetVirtualAddress"}, - {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"}, - {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"}, - {0x001C0082, nullptr, "SetIirFilterEQ"}, - {0x001F0000, nullptr, "GetHeadphoneStatus"}, - {0x00210000, nullptr, "GetIsDspOccupied"}, + {0x00010040, nullptr, "RecvData"}, + {0x00020040, nullptr, "RecvDataIsReady"}, + {0x00030080, nullptr, "SendData"}, + {0x00040040, nullptr, "SendDataIsEmpty"}, + {0x00070040, WriteReg0x10, "WriteReg0x10"}, + {0x00080000, nullptr, "GetSemaphore"}, + {0x00090040, nullptr, "ClearSemaphore"}, + {0x000B0000, nullptr, "CheckSemaphoreRequest"}, + {0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"}, + {0x000D0082, nullptr, "WriteProcessPipe"}, + {0x001000C0, nullptr, "ReadPipeIfPossible"}, + {0x001100C2, LoadComponent, "LoadComponent"}, + {0x00120000, nullptr, "UnloadComponent"}, + {0x00130082, nullptr, "FlushDataCache"}, + {0x00140082, nullptr, "InvalidateDCache"}, + {0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"}, + {0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"}, + {0x00170040, nullptr, "SetSemaphoreMask"}, + {0x00180040, nullptr, "GetPhysicalAddress"}, + {0x00190040, nullptr, "GetVirtualAddress"}, + {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"}, + {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"}, + {0x001C0082, nullptr, "SetIirFilterEQ"}, + {0x001F0000, nullptr, "GetHeadphoneStatus"}, + {0x00210000, nullptr, "GetIsDspOccupied"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// // Interface class Interface::Interface() { + semaphore_event = Kernel::CreateEvent(RESETTYPE_ONESHOT, "DSP_DSP::semaphore_event"); + interrupt_event = 0; + Register(FunctionTable, ARRAY_SIZE(FunctionTable)); } diff --git a/src/core/hle/service/dsp_dsp.h b/src/core/hle/service/dsp_dsp.h index c4ce44245..9431b62f6 100644 --- a/src/core/hle/service/dsp_dsp.h +++ b/src/core/hle/service/dsp_dsp.h @@ -20,7 +20,7 @@ public: * @return Port name of service */ std::string GetPortName() const override { - return "dsp:DSP"; + return "dsp::DSP"; } }; diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 95663b905..51e8b579e 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp @@ -55,7 +55,7 @@ static void OpenFile(Service::Interface* self) { u32 filename_ptr = cmd_buff[9]; FileSys::Path file_path(filename_type, filename_size, filename_ptr); - DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%d", file_path.DebugStr().c_str(), mode, attributes); + DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); ResultVal<Handle> handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); cmd_buff[1] = handle.Code().raw; @@ -102,8 +102,8 @@ static void OpenFileDirectly(Service::Interface* self) { FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); FileSys::Path file_path(filename_type, filename_size, filename_ptr); - DEBUG_LOG(KERNEL, "archive_path=%s file_path=%s, mode=%d attributes=%d", - archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode, attributes); + DEBUG_LOG(KERNEL, "archive_path=%s file_path=%s, mode=%u attributes=%d", + archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes); if (archive_path.GetType() != FileSys::Empty) { ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); diff --git a/src/core/hle/service/hid_user.cpp b/src/core/hle/service/hid_user.cpp index d29de1a52..2abaf0f2f 100644 --- a/src/core/hle/service/hid_user.cpp +++ b/src/core/hle/service/hid_user.cpp @@ -55,7 +55,7 @@ static void UpdateNextCirclePadState() { /** * Sets a Pad state (button or button combo) as pressed */ -void PadButtonPress(PadState pad_state) { +void PadButtonPress(const PadState& pad_state) { next_state.hex |= pad_state.hex; UpdateNextCirclePadState(); } @@ -63,7 +63,7 @@ void PadButtonPress(PadState pad_state) { /** * Sets a Pad state (button or button combo) as released */ -void PadButtonRelease(PadState pad_state) { +void PadButtonRelease(const PadState& pad_state) { next_state.hex &= ~pad_state.hex; UpdateNextCirclePadState(); } diff --git a/src/core/hle/service/hid_user.h b/src/core/hle/service/hid_user.h index 5ed97085d..8f53befdb 100644 --- a/src/core/hle/service/hid_user.h +++ b/src/core/hle/service/hid_user.h @@ -93,8 +93,8 @@ const PadState PAD_CIRCLE_UP = {{1u << 30}}; const PadState PAD_CIRCLE_DOWN = {{1u << 31}}; // Methods for updating the HID module's state -void PadButtonPress(PadState pad_state); -void PadButtonRelease(PadState pad_state); +void PadButtonPress(const PadState& pad_state); +void PadButtonRelease(const PadState& pad_state); void PadUpdateComplete(); /** diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp index d9122dbbc..941df467b 100644 --- a/src/core/hle/service/ptm_u.cpp +++ b/src/core/hle/service/ptm_u.cpp @@ -11,15 +11,101 @@ namespace PTM_U { +/// Charge levels used by PTM functions +enum class ChargeLevels : u32 { + CriticalBattery = 1, + LowBattery = 2, + HalfFull = 3, + MostlyFull = 4, + CompletelyFull = 5, +}; + +static bool shell_open = true; + +static bool battery_is_charging = true; + +/** + * It is unknown if GetAdapterState is the same as GetBatteryChargeState, + * it is likely to just be a duplicate function of GetBatteryChargeState + * that controls another part of the HW. + * PTM_U::GetAdapterState service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Output of function, 0 = not charging, 1 = charging. + */ +static void GetAdapterState(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + // TODO(purpasmart96): This function is only a stub, + // it returns a valid result without implementing full functionality. + + cmd_buff[1] = 0; // No error + cmd_buff[2] = battery_is_charging ? 1 : 0; + + WARN_LOG(KERNEL, "(STUBBED) called"); +} + +/* + * PTM_User::GetShellState service function. + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Whether the 3DS's physical shell casing is open (1) or closed (0) + */ +static void GetShellState(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + cmd_buff[1] = 0; + cmd_buff[2] = shell_open ? 1 : 0; + + DEBUG_LOG(KERNEL, "PTM_U::GetShellState called"); +} + +/** + * PTM_U::GetBatteryLevel service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Battery level, 5 = completely full battery, 4 = mostly full battery, + * 3 = half full battery, 2 = low battery, 1 = critical battery. + */ +static void GetBatteryLevel(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + // TODO(purpasmart96): This function is only a stub, + // it returns a valid result without implementing full functionality. + + cmd_buff[1] = 0; // No error + cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery + + WARN_LOG(KERNEL, "(STUBBED) called"); +} + +/** + * PTM_U::GetBatteryChargeState service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Output of function, 0 = not charging, 1 = charging. + */ +static void GetBatteryChargeState(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + // TODO(purpasmart96): This function is only a stub, + // it returns a valid result without implementing full functionality. + + cmd_buff[1] = 0; // No error + cmd_buff[2] = battery_is_charging ? 1 : 0; + + WARN_LOG(KERNEL, "(STUBBED) called"); +} + const Interface::FunctionInfo FunctionTable[] = { {0x00010002, nullptr, "RegisterAlarmClient"}, {0x00020080, nullptr, "SetRtcAlarm"}, {0x00030000, nullptr, "GetRtcAlarm"}, {0x00040000, nullptr, "CancelRtcAlarm"}, - {0x00050000, nullptr, "GetAdapterState"}, - {0x00060000, nullptr, "GetShellState"}, - {0x00070000, nullptr, "GetBatteryLevel"}, - {0x00080000, nullptr, "GetBatteryChargeState"}, + {0x00050000, GetAdapterState, "GetAdapterState"}, + {0x00060000, GetShellState, "GetShellState"}, + {0x00070000, GetBatteryLevel, "GetBatteryLevel"}, + {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, {0x000B00C2, nullptr, "GetStepHistory"}, diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 87d768856..43a3cbe03 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -189,6 +189,8 @@ static Result CreateAddressArbiter(u32* arbiter) { /// Arbitrate address static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) { + DEBUG_LOG(SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", arbiter, + address, type, value); return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), address, value).raw; } @@ -331,6 +333,9 @@ static Result ClearEvent(Handle evt) { /// Sleep the current thread static void SleepThread(s64 nanoseconds) { DEBUG_LOG(SVC, "called nanoseconds=%lld", nanoseconds); + + // Check for next thread to schedule + HLE::Reschedule(__func__); } /// This returns the total CPU ticks elapsed since the CPU was powered-on diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 3ad801c63..af5e1b39b 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -49,7 +49,7 @@ inline void Write(u32 addr, const T data) { // Writes other than u32 are untested, so I'd rather have them abort than silently fail if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) { - ERROR_LOG(GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); return; } @@ -140,8 +140,8 @@ inline void Write(u32 addr, const T data) { DEBUG_LOG(GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), dst format %x", config.output_height * config.output_width * 4, - config.GetPhysicalInputAddress(), config.input_width, config.input_height, - config.GetPhysicalOutputAddress(), config.output_width, config.output_height, + config.GetPhysicalInputAddress(), (u32)config.input_width, (u32)config.input_height, + config.GetPhysicalOutputAddress(), (u32)config.output_width, (u32)config.output_height, config.output_format.Value()); } break; diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index 4d0719263..ea001673a 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp @@ -68,7 +68,7 @@ inline void Write(u32 addr, const T data) { break; default: - ERROR_LOG(HW, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(HW, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); } } diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp index e29a773f1..593e5de30 100644 --- a/src/core/hw/ndma.cpp +++ b/src/core/hw/ndma.cpp @@ -15,7 +15,7 @@ inline void Read(T &var, const u32 addr) { template <typename T> inline void Write(u32 addr, const T data) { - ERROR_LOG(NDMA, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(NDMA, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); } // Explicitly instantiate template functions because we aren't defining this in the header: diff --git a/src/core/mem_map.h b/src/core/mem_map.h index a58c59244..c9529f84c 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h @@ -16,10 +16,9 @@ typedef u32 PAddr; ///< Represents a pointer in the physical address space. //////////////////////////////////////////////////////////////////////////////////////////////////// -enum { +enum : u32 { BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size - DSP_SIZE = 0x00080000, ///< DSP memory size AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size FCRAM_SIZE = 0x08000000, ///< FCRAM size @@ -34,6 +33,9 @@ enum { SHARED_MEMORY_VADDR_END = (SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE), SHARED_MEMORY_MASK = (SHARED_MEMORY_SIZE - 1), + DSP_MEMORY_SIZE = 0x00080000, ///< DSP memory size + DSP_MEMORY_VADDR = 0x1FF00000, ///< DSP memory virtual address + CONFIG_MEMORY_SIZE = 0x00001000, ///< Configuration memory size CONFIG_MEMORY_VADDR = 0x1FF80000, ///< Configuration memory virtual address CONFIG_MEMORY_VADDR_END = (CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE), diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 443d5ad7e..e8747840c 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -92,7 +92,7 @@ inline void Read(T &var, const VAddr vaddr) { var = *((const T*)&g_vram[vaddr & VRAM_MASK]); } else { - ERROR_LOG(MEMMAP, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr); + ERROR_LOG(MEMMAP, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, vaddr); } } @@ -141,7 +141,7 @@ inline void Write(const VAddr vaddr, const T data) { // Error out... } else { - ERROR_LOG(MEMMAP, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, vaddr); + ERROR_LOG(MEMMAP, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, vaddr); } } diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 1ec727698..8a6ba2560 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -60,7 +60,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { const u8* load_address = base_address + loader_config.data_offset; // TODO: What happens if a loader overwrites a previous one's data? - for (int component = 0; component < loader_config.component_count; ++component) { + for (unsigned component = 0; component < loader_config.component_count; ++component) { u32 attribute_index = loader_config.GetComponent(component); vertex_attribute_sources[attribute_index] = load_address; vertex_attribute_strides[attribute_index] = static_cast<u32>(loader_config.byte_count); diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 275b06b7c..8a5f11424 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -155,7 +155,7 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data // This is put into a try-catch block to make sure we notice unknown configurations. std::vector<OutputRegisterInfo> output_info_table; - for (int i = 0; i < 7; ++i) { + for (unsigned i = 0; i < 7; ++i) { using OutputAttributes = Pica::Regs::VSOutputAttributes; // TODO: It's still unclear how the attribute components map to the register! @@ -375,8 +375,8 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { png_write_info(png_ptr, info_ptr); buf = new u8[row_stride * texture_config.height]; - for (int y = 0; y < texture_config.height; ++y) { - for (int x = 0; x < texture_config.width; ++x) { + for (unsigned y = 0; y < texture_config.height; ++y) { + for (unsigned x = 0; x < texture_config.width; ++x) { // Cf. rasterizer code for an explanation of this algorithm. int texel_index_within_tile = 0; for (int block_size_index = 0; block_size_index < 3; ++block_size_index) { @@ -402,7 +402,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { } // Write image data - for (auto y = 0; y < texture_config.height; ++y) + for (unsigned y = 0; y < texture_config.height; ++y) { u8* row_ptr = (u8*)buf + y * row_stride; u8* ptr = row_ptr; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index abbb4c2cb..06de6afbd 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -61,7 +61,7 @@ void RendererOpenGL::SwapBuffers() { for(int i : {0, 1}) { const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; - if (textures[i].width != framebuffer.width || textures[i].height != framebuffer.height) { + if (textures[i].width != (GLsizei)framebuffer.width || textures[i].height != (GLsizei)framebuffer.height) { // Reallocate texture if the framebuffer size has changed. // This is expected to not happen very often and hence should not be a // performance problem. @@ -240,14 +240,14 @@ MathUtil::Rectangle<unsigned> RendererOpenGL::GetViewportExtent() { MathUtil::Rectangle<unsigned> viewport_extent; if (window_aspect_ratio > emulation_aspect_ratio) { // Window is narrower than the emulation content => apply borders to the top and bottom - unsigned viewport_height = emulation_aspect_ratio * framebuffer_width; + unsigned viewport_height = std::round(emulation_aspect_ratio * framebuffer_width); viewport_extent.left = 0; viewport_extent.top = (framebuffer_height - viewport_height) / 2; viewport_extent.right = viewport_extent.left + framebuffer_width; viewport_extent.bottom = viewport_extent.top + viewport_height; } else { // Otherwise, apply borders to the left and right sides of the window. - unsigned viewport_width = framebuffer_height / emulation_aspect_ratio; + unsigned viewport_width = std::round(framebuffer_height / emulation_aspect_ratio); viewport_extent.left = (framebuffer_width - viewport_width) / 2; viewport_extent.top = 0; viewport_extent.right = viewport_extent.left + viewport_width; |