diff options
-rw-r--r-- | src/citra/config.cpp | 17 | ||||
-rw-r--r-- | src/citra/config.h | 5 | ||||
-rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 8 | ||||
-rw-r--r-- | src/citra_qt/config.cpp | 52 | ||||
-rw-r--r-- | src/citra_qt/config.h | 11 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 54 | ||||
-rw-r--r-- | src/core/hle/kernel/mutex.cpp | 15 | ||||
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/ac_u.cpp | 20 | ||||
-rw-r--r-- | src/core/hle/service/cfg_u.cpp | 88 | ||||
-rw-r--r-- | src/core/hle/service/dsp_dsp.cpp | 131 | ||||
-rw-r--r-- | src/core/hle/service/dsp_dsp.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/ptm_u.cpp | 19 | ||||
-rw-r--r-- | src/core/hle/svc.cpp | 5 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 4 |
15 files changed, 294 insertions, 139 deletions
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/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/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..a2b68cac8 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,118 @@ namespace DSP_DSP { +static Handle semaphore_event; +static Handle interrupt_event; + +/** + * 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, nullptr, "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/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp index d9122dbbc..1ce32ee4a 100644 --- a/src/core/hle/service/ptm_u.cpp +++ b/src/core/hle/service/ptm_u.cpp @@ -11,13 +11,30 @@ namespace PTM_U { +static bool shell_open = true; + +/* + * 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"); +} + const Interface::FunctionInfo FunctionTable[] = { {0x00010002, nullptr, "RegisterAlarmClient"}, {0x00020080, nullptr, "SetRtcAlarm"}, {0x00030000, nullptr, "GetRtcAlarm"}, {0x00040000, nullptr, "CancelRtcAlarm"}, {0x00050000, nullptr, "GetAdapterState"}, - {0x00060000, nullptr, "GetShellState"}, + {0x00060000, GetShellState, "GetShellState"}, {0x00070000, nullptr, "GetBatteryLevel"}, {0x00080000, nullptr, "GetBatteryChargeState"}, {0x00090000, nullptr, "GetPedometerState"}, 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/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 2469d0b01..06de6afbd 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -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; |