diff --git a/.editorconfig b/.editorconfig index a2ef9da067..a42588d1a6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,6 @@ root = true [*] -end_of_line = lf indent_size = 2 trim_trailing_whitespace = true diff --git a/Externals/enet/enet.vcxproj b/Externals/enet/enet.vcxproj index 71e0086faf..ac6fe790b1 100644 --- a/Externals/enet/enet.vcxproj +++ b/Externals/enet/enet.vcxproj @@ -61,6 +61,7 @@ + diff --git a/Languages/Languages.vcxproj b/Languages/Languages.vcxproj index 1bc6a6381a..c7d380a783 100644 --- a/Languages/Languages.vcxproj +++ b/Languages/Languages.vcxproj @@ -45,15 +45,15 @@ 10.0.15063.0 - + Utility - true v141 - - Utility + + true + + false - v141 diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 9d3dff94c4..350b78b361 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -25,6 +25,7 @@ #include "Common/Logging/LogManager.h" #include "Common/MsgHandler.h" +#include "Core/Boot/Boot.h" #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -794,7 +795,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv* // No use running the loop when booting fails s_have_wm_user_stop = false; - if (BootManager::BootCore(s_filename.c_str(), SConfig::BOOT_DEFAULT)) + if (BootManager::BootCore(BootParameters::GenerateFromFile(s_filename))) { static constexpr int TIMEOUT = 10000; static constexpr int WAIT_STEP = 25; diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index ca343be005..25dd14e7b2 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -155,17 +155,23 @@ static ALenum CheckALError(const char* desc) return err; } +static bool IsCreativeXFi() +{ + return strstr(alGetString(AL_RENDERER), "X-Fi") != nullptr; +} + void OpenALStream::SoundLoop() { Common::SetCurrentThreadName("Audio thread - openal"); - bool surround_capable = SConfig::GetInstance().bDPL2Decoder; - bool float32_capable = false; - bool fixed32_capable = false; + bool float32_capable = alIsExtensionPresent("AL_EXT_float32") != 0; + bool surround_capable = alIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi(); + bool use_surround = SConfig::GetInstance().bDPL2Decoder && surround_capable; -#if defined(__APPLE__) - surround_capable = false; -#endif + // As there is no extension to check for 32-bit fixed point support + // and we know that only a X-Fi with hardware OpenAL supports it, + // we just check if one is being used. + bool fixed32_capable = IsCreativeXFi(); u32 ulFrequency = m_mixer->GetSampleRate(); numBuffers = SConfig::GetInstance().iLatency + 2; // OpenAL requires a minimum of two buffers @@ -173,15 +179,6 @@ void OpenALStream::SoundLoop() memset(uiBuffers, 0, numBuffers * sizeof(ALuint)); uiSource = 0; - if (alIsExtensionPresent("AL_EXT_float32")) - float32_capable = true; - - // As there is no extension to check for 32-bit fixed point support - // and we know that only a X-Fi with hardware OpenAL supports it, - // we just check if one is being used. - if (strstr(alGetString(AL_RENDERER), "X-Fi")) - fixed32_capable = true; - // Clear error state before querying or else we get false positives. ALenum err = alGetError(); @@ -226,7 +223,7 @@ void OpenALStream::SoundLoop() unsigned int numSamples = OAL_MAX_SAMPLES; - if (surround_capable) + if (use_surround) { // DPL2 accepts 240 samples minimum (FWRDURATION) unsigned int minSamples = 240; @@ -297,7 +294,7 @@ void OpenALStream::SoundLoop() // 5.1 is not supported by the host, fallback to stereo WARN_LOG(AUDIO, "Unable to set 5.1 surround mode. Updating OpenAL Soft might fix this issue."); - surround_capable = false; + use_surround = false; } } else diff --git a/Source/Core/AudioCommon/OpenALStream.h b/Source/Core/AudioCommon/OpenALStream.h index 6d32a37adb..5e4b49c027 100644 --- a/Source/Core/AudioCommon/OpenALStream.h +++ b/Source/Core/AudioCommon/OpenALStream.h @@ -42,19 +42,23 @@ #define FRAME_SURROUND_INT32 SURROUND_CHANNELS* SIZE_INT32 #endif -#if defined(__APPLE__) -// OS X does not have the alext AL_FORMAT_STEREO_FLOAT32, AL_FORMAT_STEREO32, -// AL_FORMAT_51CHN32 and AL_FORMAT_51CHN16 yet. -#define AL_FORMAT_STEREO_FLOAT32 0 -#define AL_FORMAT_STEREO32 0 -#define AL_FORMAT_51CHN32 0 -#define AL_FORMAT_51CHN16 0 -#elif defined(_WIN32) +// From AL_EXT_float32 +#ifndef AL_FORMAT_STEREO_FLOAT32 +#define AL_FORMAT_STEREO_FLOAT32 0x10011 +#endif + +// From AL_EXT_MCFORMATS +#ifndef AL_FORMAT_51CHN16 +#define AL_FORMAT_51CHN16 0x120B +#endif +#ifndef AL_FORMAT_51CHN32 +#define AL_FORMAT_51CHN32 0x120C +#endif + // Only X-Fi on Windows supports the alext AL_FORMAT_STEREO32 alext for now, // but it is not documented or in "OpenAL/include/al.h". +#ifndef AL_FORMAT_STEREO32 #define AL_FORMAT_STEREO32 0x1203 -#else -#define AL_FORMAT_STEREO32 0 #endif class OpenALStream final : public SoundStream diff --git a/Source/Core/AudioCommon/XAudio2Stream.cpp b/Source/Core/AudioCommon/XAudio2Stream.cpp index 12954fc5bf..69c503f310 100644 --- a/Source/Core/AudioCommon/XAudio2Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2Stream.cpp @@ -25,8 +25,7 @@ private: public: StreamingVoiceContext(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent); - - ~StreamingVoiceContext(); + virtual ~StreamingVoiceContext(); void Stop(); void Play(); diff --git a/Source/Core/AudioCommon/XAudio2_7Stream.cpp b/Source/Core/AudioCommon/XAudio2_7Stream.cpp index 06fb645c95..1abf6d2096 100644 --- a/Source/Core/AudioCommon/XAudio2_7Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2_7Stream.cpp @@ -25,8 +25,7 @@ private: public: StreamingVoiceContext2_7(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent); - - ~StreamingVoiceContext2_7(); + virtual ~StreamingVoiceContext2_7(); void Stop(); void Play(); diff --git a/Source/Core/Common/Config/Section.h b/Source/Core/Common/Config/Section.h index 8b36ce157e..0a4662d156 100644 --- a/Source/Core/Common/Config/Section.h +++ b/Source/Core/Common/Config/Section.h @@ -27,6 +27,7 @@ class Section public: Section(LayerType layer, System system, const std::string& name); + virtual ~Section() = default; virtual bool Exists(const std::string& key) const; bool Delete(const std::string& key); diff --git a/Source/Core/Common/Crypto/ec.cpp b/Source/Core/Common/Crypto/ec.cpp index 9dca32878b..5fe7e9bb2b 100644 --- a/Source/Core/Common/Crypto/ec.cpp +++ b/Source/Core/Common/Crypto/ec.cpp @@ -15,6 +15,11 @@ #include "Common/Crypto/bn.h" #include "Common/Crypto/ec.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4505) +#endif + // y**2 + x*y = x**3 + x + b UNUSED static const u8 ec_b[30] = {0x00, 0x66, 0x64, 0x7e, 0xde, 0x6c, 0x33, 0x2c, 0x7f, 0x8c, 0x09, 0x23, 0xbb, 0x58, 0x21, 0x3b, 0x33, 0x3b, 0x20, 0xe9, @@ -404,3 +409,7 @@ void ec_priv_to_pub(const u8* k, u8* Q) { point_mul(Q, k, ec_G); } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index ebab9e9c48..203ddbac4b 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -631,9 +631,9 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) // Returns the current directory std::string GetCurrentDir() { - char* dir; // Get the current working directory (getcwd uses malloc) - if (!(dir = __getcwd(nullptr, 0))) + char* dir = __getcwd(nullptr, 0); + if (!dir) { ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", GetLastErrorMsg().c_str()); return nullptr; @@ -986,7 +986,7 @@ u64 IOFile::Tell() const if (IsOpen()) return ftello(m_file); else - return -1; + return UINT64_MAX; } bool IOFile::Flush() diff --git a/Source/Core/Common/GL/GLInterface/WGL.cpp b/Source/Core/Common/GL/GLInterface/WGL.cpp index 57c46cb42b..3e500f5866 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.cpp +++ b/Source/Core/Common/GL/GLInterface/WGL.cpp @@ -248,8 +248,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core) return false; } - int pixel_format; - if (!(pixel_format = ChoosePixelFormat(m_dc, &pfd))) + int pixel_format = ChoosePixelFormat(m_dc, &pfd); + if (!pixel_format) { PanicAlert("(2) Can't find a suitable PixelFormat."); return false; @@ -261,7 +261,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core) return false; } - if (!(m_rc = wglCreateContext(m_dc))) + m_rc = wglCreateContext(m_dc); + if (!m_rc) { PanicAlert("(4) Can't create an OpenGL rendering context."); return false; diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index 7e48e38d80..becaf09792 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -198,7 +198,7 @@ inline int IntLog2(u64 val) return 63 - __builtin_clzll(val); #elif defined(_MSC_VER) - unsigned long result = -1; + unsigned long result = ULONG_MAX; _BitScanReverse64(&result, val); return result; diff --git a/Source/Core/Common/Profiler.cpp b/Source/Core/Common/Profiler.cpp index fdc356a164..0be14073bd 100644 --- a/Source/Core/Common/Profiler.cpp +++ b/Source/Core/Common/Profiler.cpp @@ -29,8 +29,8 @@ std::string Profiler::s_lazy_result = ""; int Profiler::s_lazy_delay = 0; Profiler::Profiler(const std::string& name) - : m_name(name), m_usecs(0), m_usecs_min(-1), m_usecs_max(0), m_usecs_quad(0), m_calls(0), - m_depth(0) + : m_name(name), m_usecs(0), m_usecs_min(UINT64_MAX), m_usecs_max(0), m_usecs_quad(0), + m_calls(0), m_depth(0) { m_time = Common::Timer::GetTimeUs(); s_max_length = std::max(s_max_length, u32(m_name.length())); @@ -154,7 +154,7 @@ std::string Profiler::Read() buffer << std::setw(PROFILER_FIELD_LENGTH) << std::right << m_usecs_max; m_usecs = 0; - m_usecs_min = -1; + m_usecs_min = UINT64_MAX; m_usecs_max = 0; m_usecs_quad = 0; m_calls = 0; diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp index 1bb09878b6..9e72990747 100644 --- a/Source/Core/Common/SDCardUtil.cpp +++ b/Source/Core/Common/SDCardUtil.cpp @@ -49,6 +49,11 @@ #include // for unlink() #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4310) +#endif + /* Believe me, you *don't* want to change these constants !! */ #define BYTES_PER_SECTOR 512 #define RESERVED_SECTORS 32 @@ -289,3 +294,7 @@ FailWrite: ERROR_LOG(COMMON, "unlink(%s) failed: %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp index 190653ee31..fa81314795 100644 --- a/Source/Core/Common/Thread.cpp +++ b/Source/Core/Common/Thread.cpp @@ -62,11 +62,8 @@ void SwitchCurrentThread() } // Sets the debugger-visible name of the current thread. -// Uses undocumented (actually, it is now documented) trick. -// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp - -// This is implemented much nicer in upcoming msvc++, see: -// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx +// Uses trick documented in: +// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code void SetCurrentThreadName(const char* szThreadName) { static const DWORD MS_VC_EXCEPTION = 0x406D1388; @@ -83,7 +80,7 @@ void SetCurrentThreadName(const char* szThreadName) info.dwType = 0x1000; info.szName = szThreadName; - info.dwThreadID = -1; // dwThreadID; + info.dwThreadID = static_cast(-1); info.dwFlags = 0; __try diff --git a/Source/Core/Core/ARDecrypt.cpp b/Source/Core/Core/ARDecrypt.cpp index c4bd4f203d..77bfc175d3 100644 --- a/Source/Core/Core/ARDecrypt.cpp +++ b/Source/Core/Core/ARDecrypt.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include #ifdef _WIN32 #include @@ -469,7 +471,8 @@ void DecryptARCode(std::vector vCodes, std::vector* ops) std::transform(s.begin(), s.end(), s.begin(), toupper); } - if ((ret = alphatobin(uCodes, vCodes, (int)vCodes.size()))) + ret = alphatobin(uCodes, vCodes, (int)vCodes.size()); + if (ret) { // Return value is index + 1, 0 being the success flag value. PanicAlertT("Action Replay Code Decryption Error:\nParity Check Failed\n\nCulprit Code:\n%s", diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index f8ec23175f..58146d7506 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 9ca576721b..a703716abb 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -4,13 +4,17 @@ #include "Core/Boot/Boot.h" +#include +#include #include #include +#include #include #include #include "Common/Align.h" +#include "Common/CDUtils.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -18,10 +22,12 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" -#include "Core/Boot/Boot_DOL.h" +#include "Core/Boot/DolReader.h" +#include "Core/Boot/ElfReader.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Debugger/Debugger_SymbolMap.h" +#include "Core/FifoPlayer/FifoPlayer.h" #include "Core/HLE/HLE.h" #include "Core/HW/DVD/DVDInterface.h" #include "Core/HW/EXI/EXI_DeviceIPL.h" @@ -39,6 +45,76 @@ #include "DiscIO/NANDContentLoader.h" #include "DiscIO/Volume.h" +BootParameters::BootParameters(Parameters&& parameters_) : parameters(std::move(parameters_)) +{ +} + +std::unique_ptr BootParameters::GenerateFromFile(const std::string& path) +{ + const bool is_drive = cdio_is_cdrom(path); + // Check if the file exist, we may have gotten it from a --elf command line + // that gave an incorrect file name + if (!is_drive && !File::Exists(path)) + { + PanicAlertT("The specified file \"%s\" does not exist", path.c_str()); + return {}; + } + + std::string extension; + SplitPath(path, nullptr, nullptr, &extension); + std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); + + static const std::unordered_set disc_image_extensions = { + {".gcm", ".iso", ".tgc", ".wbfs", ".ciso", ".gcz"}}; + if (disc_image_extensions.find(extension) != disc_image_extensions.end() || is_drive) + { + auto volume = DiscIO::CreateVolumeFromFilename(path); + if (!volume) + { + if (is_drive) + { + PanicAlertT("Could not read \"%s\". " + "There is no disc in the drive or it is not a GameCube/Wii backup. " + "Please note that Dolphin cannot play games directly from the original " + "GameCube and Wii discs.", + path.c_str()); + } + else + { + PanicAlertT("\"%s\" is an invalid GCM/ISO file, or is not a GC/Wii ISO.", path.c_str()); + } + return {}; + } + return std::make_unique(Disc{path, std::move(volume)}); + } + + if (extension == ".elf") + return std::make_unique(Executable{path, std::make_unique(path)}); + + if (extension == ".dol") + return std::make_unique(Executable{path, std::make_unique(path)}); + + if (extension == ".dff") + return std::make_unique(DFF{path}); + + if (DiscIO::NANDContentManager::Access().GetNANDLoader(path).IsValid()) + return std::make_unique(NAND{path}); + + PanicAlertT("Could not recognize file %s", path.c_str()); + return {}; +} + +BootParameters::IPL::IPL(DiscIO::Region region_) : region(region_) +{ + const std::string directory = SConfig::GetInstance().GetDirectoryForRegion(region); + path = SConfig::GetInstance().GetBootROMPath(directory); +} + +BootParameters::IPL::IPL(DiscIO::Region region_, Disc&& disc_) : IPL(region_) +{ + disc = std::move(disc_); +} + // Inserts a disc into the emulated disc drive and returns a pointer to it. // The returned pointer must only be used while we are still booting, // because DVDThread can do whatever it wants to the disc after that. @@ -102,57 +178,20 @@ void CBoot::UpdateDebugger_MapLoaded() Host_NotifyMapLoaded(); } -bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_map_file, - std::string* title_id) +// Get map file paths for the active title. +bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_map_file) { - std::string title_id_str; - size_t name_begin_index; - - SConfig& _StartupPara = SConfig::GetInstance(); - switch (_StartupPara.m_BootType) - { - case SConfig::BOOT_WII_NAND: - { - const DiscIO::NANDContentLoader& Loader = - DiscIO::NANDContentManager::Access().GetNANDLoader(_StartupPara.m_strFilename); - if (Loader.IsValid()) - { - u64 TitleID = Loader.GetTMD().GetTitleId(); - title_id_str = StringFromFormat("%08X_%08X", (u32)(TitleID >> 32) & 0xFFFFFFFF, - (u32)TitleID & 0xFFFFFFFF); - } - break; - } - - case SConfig::BOOT_ELF: - case SConfig::BOOT_DOL: - // Strip the .elf/.dol file extension and directories before the name - name_begin_index = _StartupPara.m_strFilename.find_last_of("/") + 1; - if ((_StartupPara.m_strFilename.find_last_of("\\") + 1) > name_begin_index) - { - name_begin_index = _StartupPara.m_strFilename.find_last_of("\\") + 1; - } - title_id_str = _StartupPara.m_strFilename.substr( - name_begin_index, _StartupPara.m_strFilename.size() - 4 - name_begin_index); - break; - - default: - title_id_str = _StartupPara.GetGameID(); - break; - } + const std::string& game_id = SConfig::GetInstance().m_debugger_game_id; if (writable_map_file) - *writable_map_file = File::GetUserPath(D_MAPS_IDX) + title_id_str + ".map"; - - if (title_id) - *title_id = title_id_str; + *writable_map_file = File::GetUserPath(D_MAPS_IDX) + game_id + ".map"; bool found = false; static const std::string maps_directories[] = {File::GetUserPath(D_MAPS_IDX), File::GetSysDirectory() + MAPS_DIR DIR_SEP}; for (size_t i = 0; !found && i < ArraySize(maps_directories); ++i) { - std::string path = maps_directories[i] + title_id_str + ".map"; + std::string path = maps_directories[i] + game_id + ".map"; if (File::Exists(path)) { found = true; @@ -270,199 +309,170 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename) return true; } -// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp -bool CBoot::BootUp() +static const DiscIO::Volume* SetDefaultDisc() { - SConfig& _StartupPara = SConfig::GetInstance(); + const SConfig& config = SConfig::GetInstance(); + // load default image or create virtual drive from directory + if (!config.m_strDVDRoot.empty()) + return SetDisc(DiscIO::CreateVolumeFromDirectory(config.m_strDVDRoot, config.bWii)); + if (!config.m_strDefaultISO.empty()) + return SetDisc(DiscIO::CreateVolumeFromFilename(config.m_strDefaultISO)); + return nullptr; +} - if (_StartupPara.m_BootType == SConfig::BOOT_BS2) - NOTICE_LOG(BOOT, "Booting %s", _StartupPara.m_strBootROM.c_str()); - else - NOTICE_LOG(BOOT, "Booting %s", _StartupPara.m_strFilename.c_str()); +// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp +bool CBoot::BootUp(std::unique_ptr boot) +{ + SConfig& config = SConfig::GetInstance(); g_symbolDB.Clear(); // PAL Wii uses NTSC framerate and linecount in 60Hz modes - VideoInterface::Preset(DiscIO::IsNTSC(_StartupPara.m_region) || - (_StartupPara.bWii && _StartupPara.bPAL60)); + VideoInterface::Preset(DiscIO::IsNTSC(config.m_region) || (config.bWii && config.bPAL60)); - switch (_StartupPara.m_BootType) + struct BootTitle { - case SConfig::BOOT_ISO: - { - const DiscIO::Volume* volume = - SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename)); - - if (!volume) - return false; - - if ((volume->GetVolumeType() == DiscIO::Platform::WII_DISC) != _StartupPara.bWii) + BootTitle() : config(SConfig::GetInstance()) {} + bool operator()(BootParameters::Disc& disc) const { - PanicAlertT("Warning - starting ISO in wrong console mode!"); - } + NOTICE_LOG(BOOT, "Booting from disc: %s", disc.path.c_str()); + const DiscIO::Volume* volume = SetDisc(std::move(disc.volume)); - _StartupPara.bWii = volume->GetVolumeType() == DiscIO::Platform::WII_DISC; + if (!volume) + return false; - // We HLE the bootrom if requested or if LLEing it fails - if (_StartupPara.bHLE_BS2 || !Load_BS2(_StartupPara.m_strBootROM)) - EmulatedBS2(_StartupPara.bWii, volume); + if (!EmulatedBS2(config.bWii, volume)) + return false; - PatchEngine::LoadPatches(); - - // Scan for common HLE functions - if (_StartupPara.bHLE_BS2 && !_StartupPara.bEnableDebugging) - { - PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB); - SignatureDB db(SignatureDB::HandlerType::DSY); - if (db.Load(File::GetSysDirectory() + TOTALDB)) - { - db.Apply(&g_symbolDB); + // Try to load the symbol map if there is one, and then scan it for + // and eventually replace code + if (LoadMapFromFilename()) HLE::PatchFunctions(); - db.Clear(); + + return true; + } + + bool operator()(const BootParameters::Executable& executable) const + { + NOTICE_LOG(BOOT, "Booting from executable: %s", executable.path.c_str()); + + if (!executable.reader->IsValid()) + return false; + + const DiscIO::Volume* volume = nullptr; + // VolumeDirectory only works with DOLs. + if (StringEndsWith(executable.path, ".dol")) + { + if (!config.m_strDVDRoot.empty()) + { + NOTICE_LOG(BOOT, "Setting DVDRoot %s", config.m_strDVDRoot.c_str()); + volume = SetDisc(DiscIO::CreateVolumeFromDirectory( + config.m_strDVDRoot, config.bWii, config.m_strApploader, executable.path)); + } + else if (!config.m_strDefaultISO.empty()) + { + NOTICE_LOG(BOOT, "Loading default ISO %s", config.m_strDefaultISO.c_str()); + volume = SetDisc(DiscIO::CreateVolumeFromFilename(config.m_strDefaultISO)); + } } + else + { + volume = SetDefaultDisc(); + } + + if (!executable.reader->LoadIntoMemory()) + { + PanicAlertT("Failed to load the executable to memory."); + return false; + } + + // Poor man's bootup + if (config.bWii) + { + HID4.SBE = 1; + SetupMSR(); + SetupBAT(config.bWii); + // Because there is no TMD to get the requested system (IOS) version from, + // we default to IOS58, which is the version used by the Homebrew Channel. + SetupWiiMemory(volume, 0x000000010000003a); + } + else + { + EmulatedBS2_GC(volume, true); + } + + Load_FST(config.bWii, volume); + PC = executable.reader->GetEntryPoint(); + + if (executable.reader->LoadSymbols() || LoadMapFromFilename()) + { + UpdateDebugger_MapLoaded(); + HLE::PatchFunctions(); + } + return true; } - // Try to load the symbol map if there is one, and then scan it for - // and eventually replace code - if (LoadMapFromFilename()) - HLE::PatchFunctions(); - - break; - } - - case SConfig::BOOT_DOL: - { - CDolLoader dolLoader(_StartupPara.m_strFilename); - if (!dolLoader.IsValid()) - return false; - - // Check if we have gotten a Wii file or not - bool dolWii = dolLoader.IsWii(); - if (dolWii != _StartupPara.bWii) + bool operator()(const BootParameters::NAND& nand) const { - PanicAlertT("Warning - starting DOL in wrong console mode!"); + NOTICE_LOG(BOOT, "Booting from NAND: %s", nand.content_path.c_str()); + SetDefaultDisc(); + return Boot_WiiWAD(nand.content_path); } - const DiscIO::Volume* volume = nullptr; - if (!_StartupPara.m_strDVDRoot.empty()) + bool operator()(const BootParameters::IPL& ipl) const { - NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - volume = SetDisc(DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, dolWii, - _StartupPara.m_strApploader, - _StartupPara.m_strFilename)); + NOTICE_LOG(BOOT, "Booting GC IPL: %s", ipl.path.c_str()); + if (!File::Exists(ipl.path)) + { + if (ipl.disc) + PanicAlertT("Cannot start the game, because the GC IPL could not be found."); + else + PanicAlertT("Cannot find the GC IPL."); + return false; + } + + if (!Load_BS2(ipl.path)) + return false; + + if (ipl.disc) + { + NOTICE_LOG(BOOT, "Inserting disc: %s", ipl.disc->path.c_str()); + SetDisc(DiscIO::CreateVolumeFromFilename(ipl.disc->path)); + } + + if (LoadMapFromFilename()) + HLE::PatchFunctions(); + + return true; } - else if (!_StartupPara.m_strDefaultISO.empty()) + + bool operator()(const BootParameters::DFF& dff) const { - NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str()); - volume = SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); + NOTICE_LOG(BOOT, "Booting DFF: %s", dff.dff_path.c_str()); + return FifoPlayer::GetInstance().Open(dff.dff_path); } - // Poor man's bootup - if (dolWii) - { - HID4.SBE = 1; - SetupMSR(); - SetupBAT(dolWii); + private: + const SConfig& config; + }; - // Because there is no TMD to get the requested system (IOS) version from, - // we default to IOS58, which is the version used by the Homebrew Channel. - SetupWiiMemory(volume, 0x000000010000003a); - } - else - { - EmulatedBS2_GC(volume, true); - } - - Load_FST(dolWii, volume); - dolLoader.Load(); - PC = dolLoader.GetEntryPoint(); - - if (LoadMapFromFilename()) - HLE::PatchFunctions(); - - break; - } - - case SConfig::BOOT_ELF: - { - const DiscIO::Volume* volume = nullptr; - - // load image or create virtual drive from directory - if (!_StartupPara.m_strDVDRoot.empty()) - { - NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - volume = - SetDisc(DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii)); - } - else if (!_StartupPara.m_strDefaultISO.empty()) - { - NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str()); - volume = SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); - } - - // Poor man's bootup - if (_StartupPara.bWii) - { - // Because there is no TMD to get the requested system (IOS) version from, - // we default to IOS58, which is the version used by the Homebrew Channel. - SetupWiiMemory(volume, 0x000000010000003a); - } - else - { - EmulatedBS2_GC(volume, true); - } - - Load_FST(_StartupPara.bWii, volume); - if (!Boot_ELF(_StartupPara.m_strFilename)) - return false; - - // Note: Boot_ELF calls HLE::PatchFunctions() - - UpdateDebugger_MapLoaded(); - Dolphin_Debugger::AddAutoBreakpoints(); - break; - } - - case SConfig::BOOT_WII_NAND: - Boot_WiiWAD(_StartupPara.m_strFilename); - - PatchEngine::LoadPatches(); - - // Not bootstrapped yet, can't translate memory addresses. Thus, prevents Symbol Map usage. - // if (LoadMapFromFilename()) - // HLE::PatchFunctions(); - - // load default image or create virtual drive from directory - if (!_StartupPara.m_strDVDRoot.empty()) - SetDisc(DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, true)); - else if (!_StartupPara.m_strDefaultISO.empty()) - SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); - - break; - - // Bootstrap 2 (AKA: Initial Program Loader, "BIOS") - case SConfig::BOOT_BS2: - { - if (!Load_BS2(_StartupPara.m_strBootROM)) - return false; - - if (LoadMapFromFilename()) - HLE::PatchFunctions(); - - break; - } - - case SConfig::BOOT_DFF: - // do nothing - break; - - default: - { - PanicAlertT("Tried to load an unknown file type."); + if (!std::visit(BootTitle(), boot->parameters)) return false; - } - } + PatchEngine::LoadPatches(); HLE::PatchFixedFunctions(); return true; } + +BootExecutableReader::BootExecutableReader(const std::string& file_name) +{ + m_bytes.resize(File::GetSize(file_name)); + File::IOFile file{file_name, "rb"}; + file.ReadBytes(m_bytes.data(), m_bytes.size()); +} + +BootExecutableReader::BootExecutableReader(const std::vector& bytes) : m_bytes(bytes) +{ +} + +BootExecutableReader::~BootExecutableReader() = default; diff --git a/Source/Core/Core/Boot/Boot.h b/Source/Core/Core/Boot/Boot.h index 42c71b199f..1f52daa1c5 100644 --- a/Source/Core/Core/Boot/Boot.h +++ b/Source/Core/Core/Boot/Boot.h @@ -5,15 +5,15 @@ #pragma once #include +#include +#include #include +#include +#include #include "Common/CommonTypes.h" - -namespace DiscIO -{ -class Volume; -struct Partition; -} +#include "DiscIO/Enums.h" +#include "DiscIO/Volume.h" struct RegionSetting { @@ -23,11 +23,54 @@ struct RegionSetting const std::string code; }; +class BootExecutableReader; + +struct BootParameters +{ + struct Disc + { + std::string path; + std::unique_ptr volume; + }; + + struct Executable + { + std::string path; + std::unique_ptr reader; + }; + + struct NAND + { + std::string content_path; + }; + + struct IPL + { + explicit IPL(DiscIO::Region region_); + IPL(DiscIO::Region region_, Disc&& disc_); + std::string path; + DiscIO::Region region; + // It is possible to boot the IPL with a disc inserted (with "skip IPL" disabled). + std::optional disc; + }; + + struct DFF + { + std::string dff_path; + }; + + static std::unique_ptr GenerateFromFile(const std::string& path); + + using Parameters = std::variant; + BootParameters(Parameters&& parameters_); + + Parameters parameters; +}; + class CBoot { public: - static bool BootUp(); - static bool IsElfWii(const std::string& filename); + static bool BootUp(std::unique_ptr boot); // Tries to find a map file for the current game by looking first in the // local user directory, then in the shared user directory. @@ -38,11 +81,8 @@ public: // If writable_map_file is not nullptr, it is set to the path to where a map // file should be saved. // - // If title_id is not nullptr, it is set to the title id - // // Returns true if a map file exists, false if none could be found. - static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file, - std::string* title_id = nullptr); + static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file); static bool LoadMapFromFilename(); private: @@ -52,7 +92,6 @@ private: static void UpdateDebugger_MapLoaded(); - static bool Boot_ELF(const std::string& filename); static bool Boot_WiiWAD(const std::string& filename); static void SetupMSR(); @@ -66,3 +105,20 @@ private: static bool SetupWiiMemory(const DiscIO::Volume* volume, u64 ios_title_id); }; + +class BootExecutableReader +{ +public: + explicit BootExecutableReader(const std::string& file_name); + explicit BootExecutableReader(const std::vector& buffer); + virtual ~BootExecutableReader(); + + virtual u32 GetEntryPoint() const = 0; + virtual bool IsValid() const = 0; + virtual bool IsWii() const = 0; + virtual bool LoadIntoMemory(bool only_in_mem1 = false) const = 0; + virtual bool LoadSymbols() const = 0; + +protected: + std::vector m_bytes; +}; diff --git a/Source/Core/Core/Boot/Boot_ELF.cpp b/Source/Core/Core/Boot/Boot_ELF.cpp deleted file mode 100644 index 1cef0937ba..0000000000 --- a/Source/Core/Core/Boot/Boot_ELF.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include - -#include "Common/FileUtil.h" -#include "Common/Swap.h" -#include "Core/Boot/Boot.h" -#include "Core/Boot/ElfReader.h" -#include "Core/HLE/HLE.h" -#include "Core/PowerPC/PowerPC.h" - -bool CBoot::IsElfWii(const std::string& filename) -{ - /* We already check if filename existed before we called this function, so - there is no need for another check, just read the file right away */ - - size_t filesize = File::GetSize(filename); - auto elf = std::make_unique(filesize); - - { - File::IOFile f(filename, "rb"); - f.ReadBytes(elf.get(), filesize); - } - - // Use the same method as the DOL loader uses: search for mfspr from HID4, - // which should only be used in Wii ELFs. - // - // Likely to have some false positives/negatives, patches implementing a - // better heuristic are welcome. - - // Swap these once, instead of swapping every word in the file. - u32 HID4_pattern = Common::swap32(0x7c13fba6); - u32 HID4_mask = Common::swap32(0xfc1fffff); - ElfReader reader(elf.get()); - - for (int i = 0; i < reader.GetNumSegments(); ++i) - { - if (reader.IsCodeSegment(i)) - { - u32* code = (u32*)reader.GetSegmentPtr(i); - for (u32 j = 0; j < reader.GetSegmentSize(i) / sizeof(u32); ++j) - { - if ((code[j] & HID4_mask) == HID4_pattern) - return true; - } - } - } - - return false; -} - -bool CBoot::Boot_ELF(const std::string& filename) -{ - // Read ELF from file - size_t filesize = File::GetSize(filename); - auto elf = std::make_unique(filesize); - - { - File::IOFile f(filename, "rb"); - f.ReadBytes(elf.get(), filesize); - } - - // Load ELF into GameCube Memory - ElfReader reader(elf.get()); - if (!reader.LoadIntoMemory()) - return false; - - const bool is_wii = IsElfWii(filename); - if (is_wii) - HID4.SBE = 1; - SetupMSR(); - SetupBAT(is_wii); - - if (!reader.LoadSymbols()) - { - if (LoadMapFromFilename()) - HLE::PatchFunctions(); - } - else - { - HLE::PatchFunctions(); - } - - PC = reader.GetEntryPoint(); - - return true; -} diff --git a/Source/Core/Core/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Boot/Boot_WiiWAD.cpp index 54501a1638..889496ccb2 100644 --- a/Source/Core/Core/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Boot/Boot_WiiWAD.cpp @@ -11,6 +11,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/FileUtil.h" +#include "Common/MsgHandler.h" #include "Common/NandPaths.h" #include "Core/Boot/Boot.h" @@ -78,6 +79,13 @@ bool CBoot::Boot_WiiWAD(const std::string& _pFilename) return false; u64 titleID = ContentLoader.GetTMD().GetTitleId(); + + if (!IOS::ES::IsChannel(titleID)) + { + PanicAlertT("This WAD is not bootable."); + return false; + } + // create data directory File::CreateFullPath(Common::GetTitleDataPath(titleID, Common::FROM_SESSION_ROOT)); diff --git a/Source/Core/Core/Boot/Boot_DOL.cpp b/Source/Core/Core/Boot/DolReader.cpp similarity index 75% rename from Source/Core/Core/Boot/Boot_DOL.cpp rename to Source/Core/Core/Boot/DolReader.cpp index b86169744d..7f17696240 100644 --- a/Source/Core/Core/Boot/Boot_DOL.cpp +++ b/Source/Core/Core/Boot/DolReader.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/Boot/Boot_DOL.h" +#include "Core/Boot/DolReader.h" #include #include @@ -12,29 +12,19 @@ #include "Common/Swap.h" #include "Core/HW/Memmap.h" -CDolLoader::CDolLoader(const std::vector& buffer) +DolReader::DolReader(const std::vector& buffer) : BootExecutableReader(buffer) { m_is_valid = Initialize(buffer); } -CDolLoader::CDolLoader(const std::string& filename) +DolReader::DolReader(const std::string& filename) : BootExecutableReader(filename) { - const u64 size = File::GetSize(filename); - std::vector temp_buffer(size); - - { - File::IOFile pStream(filename, "rb"); - pStream.ReadBytes(temp_buffer.data(), temp_buffer.size()); - } - - m_is_valid = Initialize(temp_buffer); + m_is_valid = Initialize(m_bytes); } -CDolLoader::~CDolLoader() -{ -} +DolReader::~DolReader() = default; -bool CDolLoader::Initialize(const std::vector& buffer) +bool DolReader::Initialize(const std::vector& buffer) { if (buffer.size() < sizeof(SDolHeader)) return false; @@ -97,17 +87,30 @@ bool CDolLoader::Initialize(const std::vector& buffer) return true; } -void CDolLoader::Load() const +bool DolReader::LoadIntoMemory(bool only_in_mem1) const { + if (!m_is_valid) + return false; + // load all text (code) sections for (size_t i = 0; i < m_text_sections.size(); ++i) - if (!m_text_sections[i].empty()) + if (!m_text_sections[i].empty() && + !(only_in_mem1 && + m_dolheader.textAddress[i] + m_text_sections[i].size() >= Memory::REALRAM_SIZE)) + { Memory::CopyToEmu(m_dolheader.textAddress[i], m_text_sections[i].data(), m_text_sections[i].size()); + } // load all data sections for (size_t i = 0; i < m_data_sections.size(); ++i) - if (!m_data_sections[i].empty()) + if (!m_data_sections[i].empty() && + !(only_in_mem1 && + m_dolheader.dataAddress[i] + m_data_sections[i].size() >= Memory::REALRAM_SIZE)) + { Memory::CopyToEmu(m_dolheader.dataAddress[i], m_data_sections[i].data(), m_data_sections[i].size()); + } + + return true; } diff --git a/Source/Core/Core/Boot/Boot_DOL.h b/Source/Core/Core/Boot/DolReader.h similarity index 62% rename from Source/Core/Core/Boot/Boot_DOL.h rename to Source/Core/Core/Boot/DolReader.h index f415e35705..e2daa04733 100644 --- a/Source/Core/Core/Boot/Boot_DOL.h +++ b/Source/Core/Core/Boot/DolReader.h @@ -8,20 +8,20 @@ #include #include "Common/CommonTypes.h" +#include "Core/Boot/Boot.h" -class CDolLoader +class DolReader final : public BootExecutableReader { public: - CDolLoader(const std::string& filename); - CDolLoader(const std::vector& buffer); - ~CDolLoader(); - - bool IsValid() const { return m_is_valid; } - bool IsWii() const { return m_is_wii; } - u32 GetEntryPoint() const { return m_dolheader.entryPoint; } - // Load into emulated memory - void Load() const; + explicit DolReader(const std::string& filename); + explicit DolReader(const std::vector& buffer); + ~DolReader(); + bool IsValid() const override { return m_is_valid; } + bool IsWii() const override { return m_is_wii; } + u32 GetEntryPoint() const override { return m_dolheader.entryPoint; } + bool LoadIntoMemory(bool only_in_mem1 = false) const override; + bool LoadSymbols() const override { return false; } private: enum { diff --git a/Source/Core/Core/Boot/ElfReader.cpp b/Source/Core/Core/Boot/ElfReader.cpp index 91eeba7487..78a77954ed 100644 --- a/Source/Core/Core/Boot/ElfReader.cpp +++ b/Source/Core/Core/Boot/ElfReader.cpp @@ -66,7 +66,19 @@ static void byteswapSection(Elf32_Shdr& sec) bswap(sec.sh_type); } -ElfReader::ElfReader(void* ptr) +ElfReader::ElfReader(const std::vector& buffer) : BootExecutableReader(buffer) +{ + Initialize(m_bytes.data()); +} + +ElfReader::ElfReader(const std::string& filename) : BootExecutableReader(filename) +{ + Initialize(m_bytes.data()); +} + +ElfReader::~ElfReader() = default; + +void ElfReader::Initialize(u8* ptr) { base = (char*)ptr; base32 = (u32*)ptr; @@ -86,6 +98,8 @@ ElfReader::ElfReader(void* ptr) byteswapSection(sections[i]); } entryPoint = header->e_entry; + + bRelocate = (header->e_type != ET_EXEC); } const char* ElfReader::GetSectionName(int section) const @@ -103,13 +117,10 @@ const char* ElfReader::GetSectionName(int section) const } // This is just a simple elf loader, good enough to load elfs generated by devkitPPC -bool ElfReader::LoadIntoMemory(bool only_in_mem1) +bool ElfReader::LoadIntoMemory(bool only_in_mem1) const { INFO_LOG(MASTER_LOG, "String section: %i", header->e_shstrndx); - // Should we relocate? - bRelocate = (header->e_type != ET_EXEC); - if (bRelocate) { PanicAlert("Error: Dolphin doesn't know how to load a relocatable elf."); @@ -160,7 +171,7 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const return -1; } -bool ElfReader::LoadSymbols() +bool ElfReader::LoadSymbols() const { bool hasSymbols = false; SectionID sec = GetSectionByName(".symtab"); @@ -205,3 +216,31 @@ bool ElfReader::LoadSymbols() g_symbolDB.Index(); return hasSymbols; } + +bool ElfReader::IsWii() const +{ + // Use the same method as the DOL loader uses: search for mfspr from HID4, + // which should only be used in Wii ELFs. + // + // Likely to have some false positives/negatives, patches implementing a + // better heuristic are welcome. + + // Swap these once, instead of swapping every word in the file. + u32 HID4_pattern = Common::swap32(0x7c13fba6); + u32 HID4_mask = Common::swap32(0xfc1fffff); + + for (int i = 0; i < GetNumSegments(); ++i) + { + if (IsCodeSegment(i)) + { + u32* code = (u32*)GetSegmentPtr(i); + for (u32 j = 0; j < GetSegmentSize(i) / sizeof(u32); ++j) + { + if ((code[j] & HID4_mask) == HID4_pattern) + return true; + } + } + } + + return false; +} diff --git a/Source/Core/Core/Boot/ElfReader.h b/Source/Core/Core/Boot/ElfReader.h index e3d7c257a8..951f5a7b57 100644 --- a/Source/Core/Core/Boot/ElfReader.h +++ b/Source/Core/Core/Boot/ElfReader.h @@ -5,6 +5,7 @@ #pragma once #include "Common/CommonTypes.h" +#include "Core/Boot/Boot.h" #include "Core/Boot/ElfTypes.h" enum KnownElfTypes @@ -17,31 +18,23 @@ enum KnownElfTypes typedef int SectionID; -class ElfReader +class ElfReader final : public BootExecutableReader { -private: - char* base; - u32* base32; - - Elf32_Ehdr* header; - Elf32_Phdr* segments; - Elf32_Shdr* sections; - - u32* sectionAddrs; - bool bRelocate; - u32 entryPoint; - public: - explicit ElfReader(void* ptr); - ~ElfReader() {} + explicit ElfReader(const std::string& filename); + explicit ElfReader(const std::vector& buffer); + ~ElfReader(); u32 Read32(int off) const { return base32[off >> 2]; } // Quick accessors ElfType GetType() const { return (ElfType)(header->e_type); } ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); } - u32 GetEntryPoint() const { return entryPoint; } + u32 GetEntryPoint() const override { return entryPoint; } u32 GetFlags() const { return (u32)(header->e_flags); } - bool LoadIntoMemory(bool only_in_mem1 = false); - bool LoadSymbols(); + bool LoadIntoMemory(bool only_in_mem1 = false) const override; + bool LoadSymbols() const override; + // TODO: actually check for validity. + bool IsValid() const override { return true; } + bool IsWii() const override; int GetNumSegments() const { return (int)(header->e_phnum); } int GetNumSections() const { return (int)(header->e_shnum); } @@ -57,11 +50,24 @@ public: return nullptr; } bool IsCodeSegment(int segment) const { return segments[segment].p_flags & PF_X; } - const u8* GetSegmentPtr(int segment) { return GetPtr(segments[segment].p_offset); } + const u8* GetSegmentPtr(int segment) const { return GetPtr(segments[segment].p_offset); } int GetSegmentSize(int segment) const { return segments[segment].p_filesz; } u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; } int GetSectionSize(SectionID section) const { return sections[section].sh_size; } SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found bool DidRelocate() const { return bRelocate; } +private: + void Initialize(u8* bytes); + + char* base; + u32* base32; + + Elf32_Ehdr* header; + Elf32_Phdr* segments; + Elf32_Shdr* sections; + + u32* sectionAddrs; + bool bRelocate; + u32 entryPoint; }; diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 6262fd94dd..7738e0897c 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -31,6 +31,7 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Core/Boot/Boot.h" #include "Core/Config/Config.h" #include "Core/ConfigLoaders/GameConfigLoader.h" #include "Core/ConfigLoaders/NetPlayConfigLoader.h" @@ -222,23 +223,23 @@ static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode) } // Boot the ISO or file -bool BootCore(const std::string& filename, SConfig::EBootBS2 type) +bool BootCore(std::unique_ptr boot) { + if (!boot) + return false; + SConfig& StartUp = SConfig::GetInstance(); - StartUp.m_BootType = SConfig::BOOT_ISO; - StartUp.m_strFilename = filename; StartUp.bRunCompareClient = false; StartUp.bRunCompareServer = false; config_cache.SaveConfig(StartUp); - // If for example the ISO file is bad we return here - if (!StartUp.AutoSetup(type)) + if (!StartUp.SetPathsAndGameMetadata(*boot)) return false; // Load game specific settings - if (type == SConfig::BOOT_DEFAULT) + if (!std::holds_alternative(boot->parameters)) { std::string game_id = SConfig::GetInstance().GetGameID(); u16 revision = SConfig::GetInstance().GetRevision(); @@ -400,15 +401,14 @@ bool BootCore(const std::string& filename, SConfig::EBootBS2 type) if (StartUp.bWii) StartUp.SaveSettingsToSysconf(); - // Run the game - // Init the core - if (!Core::Init()) + const bool load_ipl = !StartUp.bWii && !StartUp.bHLE_BS2 && + std::holds_alternative(boot->parameters); + if (load_ipl) { - PanicAlertT("Couldn't init the core.\nCheck your configuration."); - return false; + return Core::Init(std::make_unique(BootParameters::IPL{ + StartUp.m_region, std::move(std::get(boot->parameters))})); } - - return true; + return Core::Init(std::move(boot)); } void Stop() diff --git a/Source/Core/Core/BootManager.h b/Source/Core/Core/BootManager.h index bb7b7cae99..a068247e50 100644 --- a/Source/Core/Core/BootManager.h +++ b/Source/Core/Core/BootManager.h @@ -4,13 +4,16 @@ #pragma once +#include #include #include "Core/ConfigManager.h" +struct BootParameters; + namespace BootManager { -bool BootCore(const std::string& filename, SConfig::EBootBS2 type); +bool BootCore(std::unique_ptr parameters); // Stop the emulation core and restore the configuration. void Stop(); diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index e3684b891d..00de803378 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -21,9 +21,8 @@ set(SRCS WiiRoot.cpp Boot/Boot_BS2Emu.cpp Boot/Boot.cpp - Boot/Boot_DOL.cpp - Boot/Boot_ELF.cpp Boot/Boot_WiiWAD.cpp + Boot/DolReader.cpp Boot/ElfReader.cpp Config/Config.cpp Config/GraphicsSettings.cpp @@ -174,7 +173,7 @@ set(SRCS IOS/Network/KD/NetKDRequest.cpp IOS/Network/KD/NetKDTime.cpp IOS/Network/KD/NWC24Config.cpp - IOS/Network/NCD/Config.cpp + IOS/Network/NCD/WiiNetConfig.cpp IOS/Network/NCD/Manage.cpp IOS/Network/WD/Command.cpp IOS/SDIO/SDIOSlot0.cpp diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index dcde16a17d..870fb1971c 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -57,7 +57,7 @@ const ConfigInfo GFX_ENABLE_GPU_TEXTURE_DECODING{ const ConfigInfo GFX_ENABLE_PIXEL_LIGHTING{{System::GFX, "Settings", "EnablePixelLighting"}, false}; const ConfigInfo GFX_FAST_DEPTH_CALC{{System::GFX, "Settings", "FastDepthCalc"}, true}; -const ConfigInfo GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1}; +const ConfigInfo GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1}; const ConfigInfo GFX_SSAA{{System::GFX, "Settings", "SSAA"}, false}; const ConfigInfo GFX_EFB_SCALE{{System::GFX, "Settings", "EFBScale"}, static_cast(SCALE_1X)}; diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index 7ff7b2b667..0b3b98ee06 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -47,7 +47,7 @@ extern const ConfigInfo GFX_INTERNAL_RESOLUTION_FRAME_DUMPS; extern const ConfigInfo GFX_ENABLE_GPU_TEXTURE_DECODING; extern const ConfigInfo GFX_ENABLE_PIXEL_LIGHTING; extern const ConfigInfo GFX_FAST_DEPTH_CALC; -extern const ConfigInfo GFX_MSAA; +extern const ConfigInfo GFX_MSAA; extern const ConfigInfo GFX_SSAA; extern const ConfigInfo GFX_EFB_SCALE; extern const ConfigInfo GFX_TEXFMT_OVERLAY_ENABLE; diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index 25cb3f358b..189e69a28a 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "Common/CommonPaths.h" diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 1143da3111..39af481ae1 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -4,7 +4,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp index dc115e1bb4..53e4d83399 100644 --- a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "Common/CommonFuncs.h" diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index ffd84edfac..5f01159b60 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include + #include "Common/CommonPaths.h" #include "Common/Config/Config.h" #include "Common/FileUtil.h" diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 400bbfc581..fd637afd0b 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "AudioCommon/AudioCommon.h" @@ -22,7 +24,6 @@ #include "Core/Analytics.h" #include "Core/Boot/Boot.h" -#include "Core/Boot/Boot_DOL.h" #include "Core/Config/Config.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -753,6 +754,20 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, u64 title_id, u m_title_id = title_id; m_revision = revision; + if (game_id.length() == 6) + { + m_debugger_game_id = game_id; + } + else if (title_id != 0) + { + m_debugger_game_id = + StringFromFormat("%08X_%08X", static_cast(title_id >> 32), static_cast(title_id)); + } + else + { + m_debugger_game_id.clear(); + } + if (!was_changed) return; @@ -881,165 +896,98 @@ std::string SConfig::GetBootROMPath(const std::string& region_directory) const return path; } -// Sets m_region to the region parameter, or to PAL if the region parameter -// is invalid. Set directory_name to the value returned by GetDirectoryForRegion -// for m_region. Returns false if the region parameter is invalid. -bool SConfig::SetRegion(DiscIO::Region region, std::string* directory_name) +struct SetGameMetadata { + SetGameMetadata(SConfig* config_, DiscIO::Region* region_) : config(config_), region(region_) {} + bool operator()(const BootParameters::Disc& disc) const + { + config->SetRunningGameMetadata(*disc.volume, disc.volume->GetGamePartition()); + config->bWii = disc.volume->GetVolumeType() == DiscIO::Platform::WII_DISC; + config->m_disc_booted_from_game_list = true; + *region = disc.volume->GetRegion(); + return true; + } + + bool operator()(const BootParameters::Executable& executable) const + { + if (!executable.reader->IsValid()) + return false; + + config->bWii = executable.reader->IsWii(); + + // TODO: Right now GC homebrew boots in NTSC and Wii homebrew in PAL. + // This is intentional so that Wii homebrew can boot in both 50Hz and 60Hz, + // without forcing all GC homebrew to 50Hz. + // In the future, it probably makes sense to add a Region setting for homebrew somewhere in + // the emulator config. + *region = config->bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U; + + // Strip the .elf/.dol file extension and directories before the name + SplitPath(executable.path, nullptr, &config->m_debugger_game_id, nullptr); + return true; + } + + bool operator()(const BootParameters::NAND& nand) const + { + const auto& loader = DiscIO::NANDContentManager::Access().GetNANDLoader(nand.content_path); + if (!loader.IsValid()) + return false; + + const IOS::ES::TMDReader& tmd = loader.GetTMD(); + + config->SetRunningGameMetadata(tmd); + config->bWii = true; + *region = tmd.GetRegion(); + return true; + } + + bool operator()(const BootParameters::IPL& ipl) const + { + config->bWii = false; + *region = ipl.region; + return true; + } + + bool operator()(const BootParameters::DFF& dff) const + { + std::unique_ptr dff_file(FifoDataFile::Load(dff.dff_path, true)); + if (!dff_file) + return false; + + config->bWii = dff_file->GetIsWii(); + *region = DiscIO::Region::NTSC_U; + return true; + } + +private: + SConfig* config; + DiscIO::Region* region; +}; + +bool SConfig::SetPathsAndGameMetadata(const BootParameters& boot) +{ + m_is_mios = false; + m_disc_booted_from_game_list = false; + DiscIO::Region region; + if (!std::visit(SetGameMetadata(this, ®ion), boot.parameters)) + return false; + + // Set up region const char* retrieved_region_dir = GetDirectoryForRegion(region); m_region = retrieved_region_dir ? region : DiscIO::Region::PAL; - *directory_name = retrieved_region_dir ? retrieved_region_dir : EUR_DIR; - return !!retrieved_region_dir; -} - -bool SConfig::AutoSetup(EBootBS2 _BootBS2) -{ - std::string set_region_dir(EUR_DIR); - - switch (_BootBS2) + const std::string set_region_dir = retrieved_region_dir ? retrieved_region_dir : EUR_DIR; + if (!retrieved_region_dir && + !PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)." + "\nContinue with PAL region?")) { - case BOOT_DEFAULT: - { - bool bootDrive = cdio_is_cdrom(m_strFilename); - // Check if the file exist, we may have gotten it from a --elf command line - // that gave an incorrect file name - if (!bootDrive && !File::Exists(m_strFilename)) - { - PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str()); - return false; - } - - std::string Extension; - SplitPath(m_strFilename, nullptr, nullptr, &Extension); - if (!strcasecmp(Extension.c_str(), ".gcm") || !strcasecmp(Extension.c_str(), ".iso") || - !strcasecmp(Extension.c_str(), ".tgc") || !strcasecmp(Extension.c_str(), ".wbfs") || - !strcasecmp(Extension.c_str(), ".ciso") || !strcasecmp(Extension.c_str(), ".gcz") || - bootDrive) - { - m_BootType = BOOT_ISO; - std::unique_ptr pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename)); - if (pVolume == nullptr) - { - if (bootDrive) - PanicAlertT("Could not read \"%s\". " - "There is no disc in the drive or it is not a GameCube/Wii backup. " - "Please note that Dolphin cannot play games directly from the original " - "GameCube and Wii discs.", - m_strFilename.c_str()); - else - PanicAlertT("\"%s\" is an invalid GCM/ISO file, or is not a GC/Wii ISO.", - m_strFilename.c_str()); - return false; - } - SetRunningGameMetadata(*pVolume, pVolume->GetGamePartition()); - - // Check if we have a Wii disc - bWii = pVolume->GetVolumeType() == DiscIO::Platform::WII_DISC; - - if (!SetRegion(pVolume->GetRegion(), &set_region_dir)) - if (!PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)." - "\nContinue with PAL region?")) - return false; - } - else if (!strcasecmp(Extension.c_str(), ".elf")) - { - bWii = CBoot::IsElfWii(m_strFilename); - // TODO: Right now GC homebrew boots in NTSC and Wii homebrew in PAL. - // This is intentional so that Wii homebrew can boot in both 50Hz and 60Hz, without forcing - // all GC homebrew to 50Hz. - // In the future, it probably makes sense to add a Region setting for homebrew somewhere in - // the emulator config. - SetRegion(bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U, &set_region_dir); - m_BootType = BOOT_ELF; - } - else if (!strcasecmp(Extension.c_str(), ".dol")) - { - CDolLoader dolfile(m_strFilename); - bWii = dolfile.IsWii(); - // TODO: See the ELF code above. - SetRegion(bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U, &set_region_dir); - m_BootType = BOOT_DOL; - } - else if (!strcasecmp(Extension.c_str(), ".dff")) - { - bWii = true; - SetRegion(DiscIO::Region::NTSC_U, &set_region_dir); - m_BootType = BOOT_DFF; - - std::unique_ptr ddfFile(FifoDataFile::Load(m_strFilename, true)); - - if (ddfFile) - { - bWii = ddfFile->GetIsWii(); - } - } - else if (DiscIO::NANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid()) - { - const DiscIO::NANDContentLoader& content_loader = - DiscIO::NANDContentManager::Access().GetNANDLoader(m_strFilename); - const IOS::ES::TMDReader& tmd = content_loader.GetTMD(); - - if (!IOS::ES::IsChannel(tmd.GetTitleId())) - { - PanicAlertT("This WAD is not bootable."); - return false; - } - - SetRegion(tmd.GetRegion(), &set_region_dir); - SetRunningGameMetadata(tmd); - - bWii = true; - m_BootType = BOOT_WII_NAND; - } - else - { - PanicAlertT("Could not recognize ISO file %s", m_strFilename.c_str()); - return false; - } - } - break; - - case BOOT_BS2_USA: - SetRegion(DiscIO::Region::NTSC_U, &set_region_dir); - m_strFilename.clear(); - m_BootType = SConfig::BOOT_BS2; - break; - - case BOOT_BS2_JAP: - SetRegion(DiscIO::Region::NTSC_J, &set_region_dir); - m_strFilename.clear(); - m_BootType = SConfig::BOOT_BS2; - break; - - case BOOT_BS2_EUR: - SetRegion(DiscIO::Region::PAL, &set_region_dir); - m_strFilename.clear(); - m_BootType = SConfig::BOOT_BS2; - break; + return false; } - // Setup paths + // Set up paths CheckMemcardPath(SConfig::GetInstance().m_strMemoryCardA, set_region_dir, true); CheckMemcardPath(SConfig::GetInstance().m_strMemoryCardB, set_region_dir, false); m_strSRAM = File::GetUserPath(F_GCSRAM_IDX); - if (!bWii) - { - if (!bHLE_BS2) - { - m_strBootROM = GetBootROMPath(set_region_dir); - - if (!File::Exists(m_strBootROM)) - { - WARN_LOG(BOOT, "Bootrom file %s not found - using HLE.", m_strBootROM.c_str()); - bHLE_BS2 = true; - } - } - } - else if (bWii && !bHLE_BS2) - { - WARN_LOG(BOOT, "GC bootrom file will not be loaded for Wii mode."); - bHLE_BS2 = true; - } + m_strBootROM = GetBootROMPath(set_region_dir); return true; } diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 33e6009ec6..69947125fc 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -51,6 +51,8 @@ enum GPUDeterminismMode GPU_DETERMINISM_FAKE_COMPLETION, }; +struct BootParameters; + struct SConfig : NonCopyable { // Wii Devices @@ -129,6 +131,7 @@ struct SConfig : NonCopyable bool bOverrideGCLanguage = false; bool bWii = false; + bool m_is_mios = false; // Interface settings bool bConfirmStop = false; @@ -181,26 +184,6 @@ struct SConfig : NonCopyable bool bEnableCustomRTC; u32 m_customRTCValue; - enum EBootBS2 - { - BOOT_DEFAULT, - BOOT_BS2_JAP, - BOOT_BS2_USA, - BOOT_BS2_EUR, - }; - - enum EBootType - { - BOOT_ISO, - BOOT_ELF, - BOOT_DOL, - BOOT_WII_NAND, - BOOT_MIOS, - BOOT_BS2, - BOOT_DFF - }; - - EBootType m_BootType; DiscIO::Region m_region; std::string m_strVideoBackend; @@ -210,7 +193,6 @@ struct SConfig : NonCopyable GPUDeterminismMode m_GPUDeterminismMode; // files - std::string m_strFilename; std::string m_strBootROM; std::string m_strSRAM; std::string m_strDefaultISO; @@ -220,6 +202,10 @@ struct SConfig : NonCopyable std::string m_perfDir; + std::string m_debugger_game_id; + // TODO: remove this as soon as the ticket view hack in IOS/ES/Views is dropped. + bool m_disc_booted_from_game_list = false; + const std::string& GetGameID() const { return m_game_id; } const std::string& GetTitleDescription() const { return m_title_description; } u64 GetTitleID() const { return m_title_id; } @@ -231,7 +217,7 @@ struct SConfig : NonCopyable void LoadDefaults(); static const char* GetDirectoryForRegion(DiscIO::Region region); std::string GetBootROMPath(const std::string& region_directory) const; - bool AutoSetup(EBootBS2 _BootBS2); + bool SetPathsAndGameMetadata(const BootParameters& boot); void CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA); DiscIO::Language GetCurrentLanguage(bool wii) const; @@ -389,7 +375,6 @@ private: void SetRunningGameMetadata(const std::string& game_id, u64 title_id, u16 revision, Core::TitleDatabase::TitleType type); - bool SetRegion(DiscIO::Region region, std::string* directory_name); static SConfig* m_Instance; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 122289c5b0..5c2be41259 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -122,7 +123,7 @@ static void InitIsCPUKey() } #endif -static void EmuThread(); +static void EmuThread(std::unique_ptr boot); bool GetIsThrottlerTempDisabled() { @@ -221,7 +222,7 @@ bool WantsDeterminism() // This is called from the GUI thread. See the booting call schedule in // BootManager.cpp -bool Init() +bool Init(std::unique_ptr boot) { if (s_emu_thread.joinable()) { @@ -248,7 +249,7 @@ bool Init() s_window_handle = Host_GetRenderHandle(); // Start the emu thread - s_emu_thread = std::thread(EmuThread); + s_emu_thread = std::thread(EmuThread, std::move(boot)); return true; } @@ -412,21 +413,18 @@ static void FifoPlayerThread() } // Enter CPU run loop. When we leave it - we are done. - if (FifoPlayer::GetInstance().Open(_CoreParameter.m_strFilename)) + if (auto cpu_core = FifoPlayer::GetInstance().GetCPUCore()) { - if (auto cpu_core = FifoPlayer::GetInstance().GetCPUCore()) - { - PowerPC::InjectExternalCPUCore(cpu_core.get()); - s_is_started = true; + PowerPC::InjectExternalCPUCore(cpu_core.get()); + s_is_started = true; - CPUSetInitialExecutionState(); - CPU::Run(); + CPUSetInitialExecutionState(); + CPU::Run(); - s_is_started = false; - PowerPC::InjectExternalCPUCore(nullptr); - } - FifoPlayer::GetInstance().Close(); + s_is_started = false; + PowerPC::InjectExternalCPUCore(nullptr); } + FifoPlayer::GetInstance().Close(); // If we did not enter the CPU Run Loop above then run a fake one instead. // We need to be IsRunningAndStarted() for DolphinWX to stop us. @@ -450,7 +448,7 @@ static void FifoPlayerThread() // Initialize and create emulation thread // Call browser: Init():s_emu_thread(). // See the BootManager.cpp file description for a complete call schedule. -static void EmuThread() +static void EmuThread(std::unique_ptr boot) { const SConfig& core_parameter = SConfig::GetInstance(); s_is_booting.Set(); @@ -470,16 +468,10 @@ static void EmuThread() Common::SetCurrentThreadName("Emuthread - Starting"); - if (SConfig::GetInstance().m_OCEnable) - DisplayMessage("WARNING: running at non-native CPU clock! Game may not be stable.", 8000); - DisplayMessage(cpu_info.brand_string, 8000); - DisplayMessage(cpu_info.Summarize(), 8000); - DisplayMessage(core_parameter.m_strFilename, 3000); - // For a time this acts as the CPU thread... DeclareAsCPUThread(); - Movie::Init(); + Movie::Init(*boot); Common::ScopeGuard movie_guard{Movie::Shutdown}; HW::Init(); @@ -560,7 +552,15 @@ static void EmuThread() // Load GCM/DOL/ELF whatever ... we boot with the interpreter core PowerPC::SetMode(PowerPC::CoreMode::Interpreter); - CBoot::BootUp(); + // Determine the CPU thread function + void (*cpuThreadFunc)(); + if (std::holds_alternative(boot->parameters)) + cpuThreadFunc = FifoPlayerThread; + else + cpuThreadFunc = CpuThread; + + if (!CBoot::BootUp(std::move(boot))) + return; // This adds the SyncGPU handler to CoreTiming, so now CoreTiming::Advance might block. Fifo::Prepare(); @@ -583,13 +583,6 @@ static void EmuThread() Host_UpdateDisasmDialog(); Host_UpdateMainFrame(); - // Determine the CPU thread function - void (*cpuThreadFunc)(void); - if (core_parameter.m_BootType == SConfig::BOOT_DFF) - cpuThreadFunc = FifoPlayerThread; - else - cpuThreadFunc = CpuThread; - // ENTER THE VIDEO THREAD LOOP if (core_parameter.bCPUThread) { diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index 89bdedb25c..78b5f5d6c7 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -11,11 +11,14 @@ #pragma once #include +#include #include #include #include "Common/CommonTypes.h" +struct BootParameters; + namespace Core { bool GetIsThrottlerTempDisabled(); @@ -31,7 +34,7 @@ enum class State Stopping }; -bool Init(); +bool Init(std::unique_ptr boot); void Stop(); void Shutdown(); diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 6616031f96..8dd469620c 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -35,16 +35,6 @@ - - - $(IntDir)/%(RelativeDir)/ - - - - - $(IntDir)/%(RelativeDir)/ - - @@ -52,9 +42,8 @@ - - + @@ -215,7 +204,7 @@ - + @@ -308,7 +297,7 @@ - + @@ -461,7 +450,7 @@ - + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 27485da41f..8163603ae9 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -154,6 +154,12 @@ {1fa9df3e-6741-4045-b2f6-457b4a0540a9} + + {a3d4778e-1891-458e-9bd1-009c2f5e8ed9} + + + {f0b52c84-49f4-470a-b037-edeea5634b9e} + @@ -182,15 +188,12 @@ Boot - - Boot - - - Boot - Boot + + Boot + Boot @@ -293,7 +296,7 @@ HLE - + HLE @@ -690,10 +693,18 @@ PowerPC\Jit64Common - - - - + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + IOS\USB\Bluetooth @@ -781,9 +792,6 @@ IOS\Network\KD - - IOS\Network\NCD - IOS\Network\NCD @@ -859,8 +867,15 @@ ConfigLoader - - + + Config + + + Config + + + IOS\Network\NCD + @@ -888,7 +903,7 @@ Boot - + Boot @@ -1337,10 +1352,18 @@ PowerPC\Jit64Common - - - - + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + + + PowerPC\SignatureDB + IOS\USB\Bluetooth @@ -1407,9 +1430,6 @@ IOS\Network\KD - - IOS\Network\NCD - IOS\Network\NCD @@ -1497,13 +1517,20 @@ ConfigLoader - - ConfigLoader + + Config + + + Config + + + IOS\Network\NCD + - + \ No newline at end of file diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index bb00023941..50ed09337d 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -5,15 +5,17 @@ #include "Core/DSP/DSPAssembler.h" +#include #include #include #include #include #include -#include #include +#include #include #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" diff --git a/Source/Core/Core/DSP/DSPCaptureLogger.cpp b/Source/Core/Core/DSP/DSPCaptureLogger.cpp index 4050379ec9..4b36b2ff41 100644 --- a/Source/Core/Core/DSP/DSPCaptureLogger.cpp +++ b/Source/Core/Core/DSP/DSPCaptureLogger.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index 972db90ec4..c9627de3af 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" diff --git a/Source/Core/Core/DSP/DSPHWInterface.cpp b/Source/Core/Core/DSP/DSPHWInterface.cpp index 09b66f42e2..fa18c96968 100644 --- a/Source/Core/Core/DSP/DSPHWInterface.cpp +++ b/Source/Core/Core/DSP/DSPHWInterface.cpp @@ -5,6 +5,7 @@ #include "Core/DSP/DSPHWInterface.h" +#include #include #include diff --git a/Source/Core/Core/DSP/LabelMap.cpp b/Source/Core/Core/DSP/LabelMap.cpp index d0137d9c35..e2e157ba79 100644 --- a/Source/Core/Core/DSP/LabelMap.cpp +++ b/Source/Core/Core/DSP/LabelMap.cpp @@ -3,6 +3,10 @@ // Refer to the license.txt file included. #include "Core/DSP/LabelMap.h" + +#include +#include + #include "Core/DSP/DSPTables.h" namespace DSP diff --git a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp index f431390991..bd2a71a2bd 100644 --- a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp +++ b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include diff --git a/Source/Core/Core/Debugger/Dump.cpp b/Source/Core/Core/Debugger/Dump.cpp index 45f8fde926..a7ee736caf 100644 --- a/Source/Core/Core/Debugger/Dump.cpp +++ b/Source/Core/Core/Debugger/Dump.cpp @@ -42,7 +42,7 @@ u32 CDump::GetGPR(int _step, int _gpr) u32 offset = _step * STRUCTUR_SIZE; if (offset >= m_size) - return -1; + return UINT32_MAX; return Read32(offset + OFFSET_GPR + (_gpr * 4)); } @@ -52,7 +52,7 @@ u32 CDump::GetPC(int _step) u32 offset = _step * STRUCTUR_SIZE; if (offset >= m_size) - return -1; + return UINT32_MAX; return Read32(offset + OFFSET_PC); } diff --git a/Source/Core/Core/Debugger/RSO.cpp b/Source/Core/Core/Debugger/RSO.cpp index bfab731032..013a9209a6 100644 --- a/Source/Core/Core/Debugger/RSO.cpp +++ b/Source/Core/Core/Debugger/RSO.cpp @@ -4,7 +4,11 @@ #include "Core/Debugger/RSO.h" +#include +#include +#include #include +#include #include "Common/CommonFuncs.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index 3cb0d25493..6e7899a78c 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -4,7 +4,9 @@ #include #include +#include #include +#include #include "Common/FileUtil.h" diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 6e70078c10..0458fe2fde 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -4,6 +4,8 @@ #include "Core/FifoPlayer/FifoPlaybackAnalyzer.h" +#include + #include "Common/CommonTypes.h" #include "Core/FifoPlayer/FifoAnalyzer.h" #include "Core/FifoPlayer/FifoDataFile.h" diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index 378ad29290..3b6ac26446 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "Core/FifoPlayer/FifoRecorder.h" diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index b3139e4945..eac79d099f 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -5,6 +5,7 @@ #include "Core/GeckoCodeConfig.h" #include +#include #include #include #include diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index cc166768da..5fb7fac59c 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -247,8 +247,10 @@ u32 UnPatch(const std::string& patch_name) return addr; } - for (const auto& symbol : g_symbolDB.GetSymbolsFromName(patch_name)) + const auto& symbols = g_symbolDB.GetSymbolsFromName(patch_name); + if (symbols.size()) { + const auto& symbol = symbols[0]; for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) { s_original_instructions.erase(addr); diff --git a/Source/Core/Core/HW/DSPHLE/MailHandler.cpp b/Source/Core/Core/HW/DSPHLE/MailHandler.cpp index da1ccfd29b..6d8de40b54 100644 --- a/Source/Core/Core/HW/DSPHLE/MailHandler.cpp +++ b/Source/Core/Core/HW/DSPHLE/MailHandler.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include "Core/HW/DSPHLE/MailHandler.h" + +#include + #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp index 625e5969ed..dff0f541b8 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp @@ -5,6 +5,7 @@ #include "Core/HW/DSPHLE/UCodes/UCodes.h" #include +#include #include #ifdef _WIN32 diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h index 6cc8b45242..07dc0f3e1d 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h @@ -63,7 +63,7 @@ protected: CMailHandler& m_mail_handler; - enum EDSP_Codes + enum EDSP_Codes : u32 { DSP_INIT = 0xDCD10000, DSP_RESUME = 0xDCD10001, diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 9ca15f9d17..ae1cc5496a 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -5,6 +5,7 @@ #include "Core/HW/DSPHLE/UCodes/Zelda.h" #include +#include #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp index 892d0d245e..281db0698b 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include "Core/DSP/DSPHost.h" + +#include + #include "Common/CommonTypes.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index 9faed66142..ee02b90533 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "AudioCommon/AudioCommon.h" @@ -348,8 +349,8 @@ static void DTKStreamingCallback(const std::vector& audio_data, s64 cycles_l // Determine which audio data to read next. static const int MAXIMUM_SAMPLES = 48000 / 2000 * 7; // 3.5ms of 48kHz samples - u64 read_offset; - u32 read_length; + u64 read_offset = 0; + u32 read_length = 0; if (s_stream && AudioInterface::IsPlaying()) { read_offset = s_audio_position; @@ -1213,9 +1214,8 @@ void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& partition, u u32 buffered_blocks = 0; u32 unbuffered_blocks = 0; - const u32 bytes_per_chunk = partition == DiscIO::PARTITION_NONE ? - DVD_ECC_BLOCK_SIZE : - DiscIO::VolumeWii::BLOCK_DATA_SIZE; + const u32 bytes_per_chunk = + partition == DiscIO::PARTITION_NONE ? DVD_ECC_BLOCK_SIZE : DiscIO::VolumeWii::BLOCK_DATA_SIZE; while (length > 0) { diff --git a/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp index f825f5eef6..58e497a8fb 100644 --- a/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp @@ -157,7 +157,7 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string& device_guid) if (adapter == INVALID_HANDLE_VALUE) { - INFO_LOG(SP1, "Failed to open TAP at %s", device_path); + INFO_LOG(SP1, "Failed to open TAP at %s", device_path.c_str()); return false; } return true; diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp index f02b61ec30..722f131603 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp @@ -4,8 +4,10 @@ #include "Core/HW/EXI/EXI_DeviceAGP.h" +#include #include #include +#include #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceDummy.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceDummy.cpp index 6969ec31d0..ee89644b53 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceDummy.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceDummy.cpp @@ -4,6 +4,8 @@ #include "Core/HW/EXI/EXI_DeviceDummy.h" +#include + #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp index 1af3a6b039..cc99b7d925 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp @@ -4,6 +4,7 @@ #include "Core/HW/EXI/EXI_DeviceEthernet.h" +#include #include #include "Common/ChunkFile.h" diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp index a4c9c3ad1b..7df96147b4 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp @@ -5,6 +5,7 @@ #include "Core/HW/EXI/EXI_DeviceIPL.h" #include +#include #include "Common/Assert.h" #include "Common/ChunkFile.h" @@ -98,8 +99,18 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade // Create the IPL m_pIPL = static_cast(Common::AllocateMemoryPages(ROM_SIZE)); - if (SConfig::GetInstance().bHLE_BS2) + // Load whole ROM dump + // Note: The Wii doesn't have a copy of the IPL, only fonts. + if (!SConfig::GetInstance().bWii && LoadFileToIPL(SConfig::GetInstance().m_strBootROM, 0)) { + // Descramble the encrypted section (contains BS1 and BS2) + Descrambler(m_pIPL + 0x100, 0x1afe00); + INFO_LOG(BOOT, "Loaded bootrom: %s", m_pIPL); // yay for null-terminated strings ;p + } + else + { + // If we are in Wii mode or if loading the GC IPL fails, we should still try to load fonts. + // Copy header if (DiscIO::IsNTSC(SConfig::GetInstance().m_region)) memcpy(m_pIPL, iplverNTSC, sizeof(iplverNTSC)); @@ -110,14 +121,6 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SHIFT_JIS), 0x1aff00); LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_WINDOWS_1252), 0x1fcf00); } - else - { - // Load whole ROM dump - LoadFileToIPL(SConfig::GetInstance().m_strBootROM, 0); - // Descramble the encrypted section (contains BS1 and BS2) - Descrambler(m_pIPL + 0x100, 0x1afe00); - INFO_LOG(BOOT, "Loaded bootrom: %s", m_pIPL); // yay for null-terminated strings ;p - } // Clear RTC memset(m_RTC, 0, sizeof(m_RTC)); @@ -157,17 +160,19 @@ void CEXIIPL::DoState(PointerWrap& p) p.Do(m_FontsLoaded); } -void CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset) +bool CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset) { File::IOFile stream(filename, "rb"); if (!stream) - return; + return false; u64 filesize = stream.GetSize(); - stream.ReadBytes(m_pIPL + offset, filesize); + if (!stream.ReadBytes(m_pIPL + offset, filesize)) + return false; m_FontsLoaded = true; + return true; } std::string CEXIIPL::FindIPLDump(const std::string& path_prefix) @@ -236,9 +241,7 @@ void CEXIIPL::SetCS(int _iCS) void CEXIIPL::UpdateRTC() { u32 epoch = - (SConfig::GetInstance().bWii || SConfig::GetInstance().m_BootType == SConfig::BOOT_MIOS) ? - WII_EPOCH : - GC_EPOCH; + (SConfig::GetInstance().bWii || SConfig::GetInstance().m_is_mios) ? WII_EPOCH : GC_EPOCH; u32 rtc = Common::swap32(GetEmulatedTime(epoch)); std::memcpy(m_RTC, &rtc, sizeof(u32)); } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h index 031001e6f6..ea2d7093e2 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h @@ -74,7 +74,7 @@ private: void TransferByte(u8& _uByte) override; bool IsWriteCommand() const { return !!(m_uAddress & (1 << 31)); } u32 CommandRegion() const { return (m_uAddress & ~(1 << 31)) >> 8; } - void LoadFileToIPL(const std::string& filename, u32 offset); + bool LoadFileToIPL(const std::string& filename, u32 offset); void LoadFontFile(const std::string& filename, u32 offset); std::string FindIPLDump(const std::string& path_prefix); }; diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index 55299a9663..8da1bd2c4d 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp index 0ad3a263a3..eca7eb2637 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp @@ -2,9 +2,12 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include +#include + #include "AudioCommon/CubebUtils.h" #include "Common/Common.h" #include "Common/CommonTypes.h" @@ -17,8 +20,6 @@ #include "Core/HW/GCPad.h" #include "Core/HW/SystemTimers.h" -#include - namespace ExpansionInterface { void CEXIMic::StreamInit() diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp index 2cf7399e3d..0fc0a18b3d 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp @@ -4,12 +4,14 @@ #include "Core/HW/GCMemcard/GCMemcardDirectory.h" +#include #include #include #include #include #include #include +#include #include "Common/Assert.h" #include "Common/ChunkFile.h" diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp index 894a922db7..6895ff327c 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/HW/GPFifo.cpp b/Source/Core/Core/HW/GPFifo.cpp index 174a284f11..403321fe37 100644 --- a/Source/Core/Core/HW/GPFifo.cpp +++ b/Source/Core/Core/HW/GPFifo.cpp @@ -4,6 +4,7 @@ #include "Core/HW/GPFifo.h" +#include #include #include "Common/ChunkFile.h" diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index 8ee341554d..a6dcdeebd6 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -20,14 +20,14 @@ template class ReadHandlingMethod { public: - virtual ~ReadHandlingMethod() {} + virtual ~ReadHandlingMethod() = default; virtual void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const = 0; }; template class WriteHandlingMethod { public: - virtual ~WriteHandlingMethod() {} + virtual ~WriteHandlingMethod() = default; virtual void AcceptWriteVisitor(WriteHandlingMethodVisitor& v) const = 0; }; @@ -39,7 +39,7 @@ class ConstantHandlingMethod : public ReadHandlingMethod { public: explicit ConstantHandlingMethod(T value) : value_(value) {} - virtual ~ConstantHandlingMethod() {} + virtual ~ConstantHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitConstant(value_); @@ -62,7 +62,7 @@ class NopHandlingMethod : public WriteHandlingMethod { public: NopHandlingMethod() {} - virtual ~NopHandlingMethod() {} + virtual ~NopHandlingMethod() = default; void AcceptWriteVisitor(WriteHandlingMethodVisitor& v) const override { v.VisitNop(); } }; template @@ -79,7 +79,7 @@ class DirectHandlingMethod : public ReadHandlingMethod, public WriteHandlingM { public: DirectHandlingMethod(T* addr, u32 mask) : addr_(addr), mask_(mask) {} - virtual ~DirectHandlingMethod() {} + virtual ~DirectHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitDirect(addr_, mask_); @@ -132,7 +132,7 @@ public: { } - virtual ~ComplexHandlingMethod() {} + virtual ~ComplexHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitComplex(&read_lambda_); @@ -304,6 +304,8 @@ void ReadHandler::ResetMethod(ReadHandlingMethod* method) struct FuncCreatorVisitor : public ReadHandlingMethodVisitor { + virtual ~FuncCreatorVisitor() = default; + std::function ret; void VisitConstant(T value) override @@ -356,6 +358,8 @@ void WriteHandler::ResetMethod(WriteHandlingMethod* method) struct FuncCreatorVisitor : public WriteHandlingMethodVisitor { + virtual ~FuncCreatorVisitor() = default; + std::function ret; void VisitNop() override diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 452f198884..ac69e4cd6c 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -7,6 +7,7 @@ // However, if a JITed instruction (for example lwz) wants to access a bad memory area that call // may be redirected here (for example to Read_U32()). +#include #include #include @@ -98,7 +99,7 @@ struct PhysicalMemoryRegion u8** out_pointer; u32 physical_address; u32 size; - enum + enum : u32 { ALWAYS = 0, FAKE_VMEM = 1, diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index b88bf05a49..4f0d7e8c65 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/HW/WiiSaveCrypted.cpp b/Source/Core/Core/HW/WiiSaveCrypted.cpp index d646fae570..46ba3fd33a 100644 --- a/Source/Core/Core/HW/WiiSaveCrypted.cpp +++ b/Source/Core/Core/HW/WiiSaveCrypted.cpp @@ -88,10 +88,9 @@ void CWiiSaveCrypted::ExportAllSaves() u32 success = 0; for (const u64& title : titles) { - CWiiSaveCrypted* export_save = new CWiiSaveCrypted("", title); - if (export_save->m_valid) + CWiiSaveCrypted export_save{"", title}; + if (export_save.m_valid) success++; - delete export_save; } SuccessAlertT("Successfully exported %u saves to %s", success, (File::GetUserPath(D_USER_IDX) + "private/wii/title/").c_str()); diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h index cfcc11b102..64044046af 100644 --- a/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h +++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h @@ -260,7 +260,7 @@ struct wm_guitar_extension u8 sy : 6; u8 pad2 : 2; // 1 on gh3, 0 on ghwt - u8 tb : 5; // not used in gh3 + u8 sb : 5; // not used in gh3 u8 pad3 : 3; // always 0 u8 whammy : 5; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp index df06e23eac..73218cbed7 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include "Common/Common.h" #include "Common/CommonTypes.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" @@ -15,10 +17,22 @@ #include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h" #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" +#include "InputCommon/ControllerEmu/ControlGroup/Slider.h" #include "InputCommon/ControllerEmu/ControlGroup/Triggers.h" namespace WiimoteEmu { +static const std::map s_slider_bar_control_codes{ + // values determined using a PS3 Guitar Hero 5 controller, which maps the touchbar to Zr on + // Windows + {0.0, 0x0F}, // not touching + {-0.4375, 0x04}, // top fret + {-0.097656, 0x0A}, // second fret + {0.203125, 0x12}, // third fret + {0.578125, 0x17}, // fourth fret + {1.0, 0x1F} // bottom fret +}; + constexpr std::array guitar_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x03}}; constexpr std::array guitar_fret_bitmasks{{ @@ -63,6 +77,9 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg) groups.emplace_back(m_whammy = new ControllerEmu::Triggers(_trans("Whammy"))); m_whammy->controls.emplace_back(new ControllerEmu::Input(_trans("Bar"))); + // slider bar + groups.emplace_back(m_slider_bar = new ControllerEmu::Slider(_trans("Slider Bar"))); + // set up register m_id = guitar_id; } @@ -83,8 +100,18 @@ void Guitar::GetState(u8* const data) gdata->sy = static_cast((y * 0x1F) + 0x20); } - // TODO: touch bar, probably not - gdata->tb = 0x0F; // not touched + // slider bar + if (m_slider_bar->controls[0]->control_ref->BoundCount()) + { + ControlState slider_bar; + m_slider_bar->GetState(&slider_bar); + gdata->sb = s_slider_bar_control_codes.lower_bound(slider_bar)->second; + } + else + { + // if user has not mapped controls for slider bar, tell game it's untouched + gdata->sb = 0x0F; + } // whammy bar ControlState whammy; @@ -125,6 +152,8 @@ ControllerEmu::ControlGroup* Guitar::GetGroup(GuitarGroup group) return m_whammy; case GuitarGroup::Stick: return m_stick; + case GuitarGroup::SliderBar: + return m_slider_bar; default: assert(false); return nullptr; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h index 169818bff5..36fd809af8 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h @@ -12,6 +12,7 @@ class AnalogStick; class Buttons; class ControlGroup; class Triggers; +class Slider; } namespace WiimoteEmu @@ -48,5 +49,6 @@ private: ControllerEmu::Buttons* m_strum; ControllerEmu::Triggers* m_whammy; ControllerEmu::AnalogStick* m_stick; + ControllerEmu::Slider* m_slider_bar; }; } diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index c12a983aba..0e45f869b4 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -16,6 +16,7 @@ 0x30 - 0x3f Input This file: Update() */ #include +#include #include #include #include diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index ff05c5c81c..8fcdb19fc3 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -4,9 +4,11 @@ #include "Core/HW/WiimoteEmu/WiimoteEmu.h" +#include #include #include #include +#include #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h index c998aa7409..44ea750605 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h @@ -91,7 +91,8 @@ enum class GuitarGroup Frets, Strum, Whammy, - Stick + Stick, + SliderBar }; enum class DrumsGroup diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 392dfe9caf..60a0e28c6e 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 98d1b47cbe..5ea2b48619 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -4,6 +4,8 @@ #include "Core/HotkeyManager.h" +#include +#include #include #include diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 430045705a..6023325681 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -328,7 +328,7 @@ void ES::DoState(PointerWrap& p) } } -ES::ContextArray::iterator ES::FindActiveContext(u32 fd) +ES::ContextArray::iterator ES::FindActiveContext(s32 fd) { return std::find_if(m_contexts.begin(), m_contexts.end(), [fd](const auto& context) { return context.ipc_fd == fd && context.active; }); diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index 1deb3919d7..b56ac57b69 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -94,7 +94,7 @@ public: TitleExportContext title_export; bool active = false; // We use this to associate an IPC fd with an ES context. - u32 ipc_fd = -1; + s32 ipc_fd = -1; }; // Title management @@ -277,7 +277,7 @@ private: IPCCommandResult DIGetTMDSize(const IOCtlVRequest& request); IPCCommandResult DIGetTMD(const IOCtlVRequest& request); - ContextArray::iterator FindActiveContext(u32 fd); + ContextArray::iterator FindActiveContext(s32 fd); ContextArray::iterator FindInactiveContext(); bool LaunchIOS(u64 ios_title_id); diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 224776dcaf..ba99dc77a6 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -5,10 +5,12 @@ #include "Core/IOS/ES/Formats.h" #include +#include #include #include #include #include +#include #include #include #include diff --git a/Source/Core/Core/IOS/ES/Views.cpp b/Source/Core/Core/IOS/ES/Views.cpp index 6bdd730c20..9d1369ca79 100644 --- a/Source/Core/Core/IOS/ES/Views.cpp +++ b/Source/Core/Core/IOS/ES/Views.cpp @@ -38,7 +38,7 @@ static bool ShouldReturnFakeViewsForIOSes(u64 title_id, const TitleContext& cont const bool ios = IsTitleType(title_id, IOS::ES::TitleType::System) && title_id != TITLEID_SYSMENU; const bool disc_title = context.active && IOS::ES::IsDiscTitle(context.tmd.GetTitleId()); return Core::WantsDeterminism() || - (ios && SConfig::GetInstance().m_BootType == SConfig::BOOT_ISO && disc_title); + (ios && SConfig::GetInstance().m_disc_booted_from_game_list && disc_title); } IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request) diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index abbc7b2444..56cb56ae10 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -18,7 +18,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" -#include "Core/Boot/Boot_DOL.h" +#include "Core/Boot/DolReader.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -282,14 +282,15 @@ bool Kernel::BootstrapPPC(const DiscIO::NANDContentLoader& content_loader) if (!content) return false; - const auto dol_loader = std::make_unique(content->m_Data->Get()); + const auto dol_loader = std::make_unique(content->m_Data->Get()); if (!dol_loader->IsValid()) return false; if (!SetupMemory(m_title_id, MemorySetupType::Full)) return false; - dol_loader->Load(); + if (!dol_loader->LoadIntoMemory()) + return false; // NAND titles start with address translation off at 0x3400 (via the PPC bootstub) // The state of other CPU registers (like the BAT registers) doesn't matter much diff --git a/Source/Core/Core/IOS/IOS.h b/Source/Core/Core/IOS/IOS.h index 32bcdc1694..6c49a70ec4 100644 --- a/Source/Core/Core/IOS/IOS.h +++ b/Source/Core/Core/IOS/IOS.h @@ -14,6 +14,7 @@ #include "Common/CommonTypes.h" #include "Core/CoreTiming.h" +#include "Core/HW/Memmap.h" #include "Core/HW/SystemTimers.h" #include "Core/IOS/IOSC.h" @@ -82,6 +83,12 @@ enum ProcessId : u32 PID_UNKNOWN = 19, }; +template +void WriteReturnValue(T value, u32 address) +{ + Memory::Write_U32(static_cast(value), address); +} + // HLE for the IOS kernel: IPC, device management, syscalls, and Dolphin-specific, IOS-wide calls. class Kernel { diff --git a/Source/Core/Core/IOS/IOSC.cpp b/Source/Core/Core/IOS/IOSC.cpp index ce47785ba9..129d0c485c 100644 --- a/Source/Core/Core/IOS/IOSC.cpp +++ b/Source/Core/Core/IOS/IOSC.cpp @@ -3,7 +3,10 @@ // Refer to the license.txt file included. #include +#include +#include #include +#include #include diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index ceb51f6f75..47a4fd5f6d 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -134,8 +134,7 @@ bool Load() return false; } - std::vector elf_bytes = mios.GetElf(); - ElfReader elf{elf_bytes.data()}; + ElfReader elf{mios.GetElf()}; if (!elf.LoadIntoMemory(true)) { PanicAlertT("Failed to load MIOS ELF into memory."); @@ -168,7 +167,7 @@ bool Load() Memory::Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE); NOTICE_LOG(IOS, "IPL ready."); - SConfig::GetInstance().m_BootType = SConfig::BOOT_MIOS; + SConfig::GetInstance().m_is_mios = true; DVDInterface::UpdateRunningGameMetadata(); return true; } diff --git a/Source/Core/Core/IOS/MemoryValues.cpp b/Source/Core/Core/IOS/MemoryValues.cpp index 2d0bca4626..1fe60dfd29 100644 --- a/Source/Core/Core/IOS/MemoryValues.cpp +++ b/Source/Core/Core/IOS/MemoryValues.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include "Core/IOS/MemoryValues.h" + +#include + #include "Common/CommonTypes.h" namespace IOS diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index cd25283e1a..b11800e12d 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -76,6 +76,11 @@ NetIPTop::~NetIPTop() #endif } +static constexpr u32 inet_addr(u8 a, u8 b, u8 c, u8 d) +{ + return (static_cast(a) << 24) | (static_cast(b) << 16) | (static_cast(c) << 8) | d; +} + static int inet_pton(const char* src, unsigned char* dst) { int saw_digit, octets; @@ -431,7 +436,7 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request) #ifdef _WIN32 DWORD forwardTableSize, ipTableSize, result; - DWORD ifIndex = -1; + NET_IFINDEX ifIndex = NET_IFINDEX_UNSPECIFIED; std::unique_ptr forwardTable; std::unique_ptr ipTable; @@ -462,13 +467,14 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request) } } - if (result == NO_ERROR || ifIndex != -1) + if (result == NO_ERROR || ifIndex != NET_IFINDEX_UNSPECIFIED) break; result = GetIpForwardTable(forwardTable.get(), &forwardTableSize, FALSE); } - if (ifIndex != -1 && GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR) + if (ifIndex != NET_IFINDEX_UNSPECIFIED && + GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR) { for (DWORD i = 0; i < ipTable->dwNumEntries; ++i) { @@ -817,9 +823,9 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req case 0x4003: // ip addr table Memory::Write_U32(0xC, request.io_vectors[1].address); - Memory::Write_U32(10 << 24 | 1 << 8 | 30, request.io_vectors[0].address); - Memory::Write_U32(255 << 24 | 255 << 16 | 255 << 8 | 0, request.io_vectors[0].address + 4); - Memory::Write_U32(10 << 24 | 0 << 16 | 255 << 8 | 255, request.io_vectors[0].address + 8); + Memory::Write_U32(inet_addr(10, 0, 1, 30), request.io_vectors[0].address); + Memory::Write_U32(inet_addr(255, 255, 255, 0), request.io_vectors[0].address + 4); + Memory::Write_U32(inet_addr(10, 0, 255, 255), request.io_vectors[0].address + 8); break; case 0x4005: // hardcoded value diff --git a/Source/Core/Core/IOS/Network/KD/NWC24Config.h b/Source/Core/Core/IOS/Network/KD/NWC24Config.h index 8aa07fc979..f25fb7b5fb 100644 --- a/Source/Core/Core/IOS/Network/KD/NWC24Config.h +++ b/Source/Core/Core/IOS/Network/KD/NWC24Config.h @@ -13,7 +13,7 @@ namespace HLE { namespace NWC24 { -enum ErrorCode : int +enum ErrorCode : s32 { WC24_OK = 0, WC24_ERR_FATAL = -1, diff --git a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp index 48c9e27da0..cbcf245fe9 100644 --- a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp +++ b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp @@ -41,7 +41,7 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); - Memory::Write_U32(0, request.buffer_out); // no error + WriteReturnValue(0, request.buffer_out); // no error break; case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib @@ -50,11 +50,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI"); - Memory::Write_U32(0, request.buffer_out); // no error + WriteReturnValue(0, request.buffer_out); // no error break; case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket - Memory::Write_U32(0, request.buffer_out); + WriteReturnValue(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); return_value = 0; INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); @@ -74,7 +74,7 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_REQUEST_REGISTER_USER_ID: INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID"); - Memory::Write_U32(0, request.buffer_out); + WriteReturnValue(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); break; @@ -110,20 +110,20 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) config.SetCreationStage(NWC24::NWC24Config::NWC24_IDCS_GENERATED); config.WriteConfig(); - Memory::Write_U32(ret, request.buffer_out); + WriteReturnValue(ret, request.buffer_out); } else { - Memory::Write_U32(NWC24::WC24_ERR_FATAL, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_FATAL, request.buffer_out); } } else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_GENERATED) { - Memory::Write_U32(NWC24::WC24_ERR_ID_GENERATED, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_ID_GENERATED, request.buffer_out); } else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_REGISTERED) { - Memory::Write_U32(NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out); } Memory::Write_U64(config.Id(), request.buffer_out + 4); Memory::Write_U32(config.CreationStage(), request.buffer_out + 0xC); diff --git a/Source/Core/Core/IOS/Network/NCD/Manage.h b/Source/Core/Core/IOS/Network/NCD/Manage.h index c4ce453697..2724d75577 100644 --- a/Source/Core/Core/IOS/Network/NCD/Manage.h +++ b/Source/Core/Core/IOS/Network/NCD/Manage.h @@ -8,7 +8,7 @@ #include "Common/CommonTypes.h" #include "Core/IOS/Device.h" -#include "Core/IOS/Network/NCD/Config.h" +#include "Core/IOS/Network/NCD/WiiNetConfig.h" namespace IOS { diff --git a/Source/Core/Core/IOS/Network/NCD/Config.cpp b/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp similarity index 97% rename from Source/Core/Core/IOS/Network/NCD/Config.cpp rename to Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp index 489ba97ca9..e101f5be6c 100644 --- a/Source/Core/Core/IOS/Network/NCD/Config.cpp +++ b/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IOS/Network/NCD/Config.h" +#include "Core/IOS/Network/NCD/WiiNetConfig.h" #include diff --git a/Source/Core/Core/IOS/Network/NCD/Config.h b/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.h similarity index 100% rename from Source/Core/Core/IOS/Network/NCD/Config.h rename to Source/Core/Core/IOS/Network/NCD/WiiNetConfig.h diff --git a/Source/Core/Core/IOS/Network/SSL.cpp b/Source/Core/Core/IOS/Network/SSL.cpp index ef826a7a58..925ab34f56 100644 --- a/Source/Core/Core/IOS/Network/SSL.cpp +++ b/Source/Core/Core/IOS/Network/SSL.cpp @@ -221,12 +221,12 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) mbedtls_ssl_set_hostname(&ssl->ctx, ssl->hostname.c_str()); ssl->active = true; - Memory::Write_U32(freeSSL, BufferIn); + WriteReturnValue(freeSSL, BufferIn); } else { _SSL_NEW_ERROR: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) " @@ -260,11 +260,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) ssl->active = false; - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SHUTDOWN " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -298,19 +298,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) if (ret) { - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } @@ -339,19 +339,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) { mbedtls_x509_crt_free(&ssl->clicert); mbedtls_pk_free(&ssl->pk); - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_own_cert(&ssl->config, &ssl->clicert, &ssl->pk); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; @@ -373,11 +373,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) mbedtls_pk_free(&ssl->pk); mbedtls_ssl_conf_own_cert(&ssl->config, nullptr, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; @@ -395,18 +395,18 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) if (ret) { mbedtls_x509_crt_free(&ssl->clicert); - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -428,11 +428,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) ssl->hostfd = sm.GetHostSocket(ssl->sockfd); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd); mbedtls_ssl_set_bio(&ssl->ctx, &ssl->hostfd, mbedtls_net_send, mbedtls_net_recv, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -453,7 +453,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } @@ -468,7 +468,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_WRITE " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -491,7 +491,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_READ(%d)" @@ -507,11 +507,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) { - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -533,11 +533,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) { - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } diff --git a/Source/Core/Core/IOS/Network/SSL.h b/Source/Core/Core/IOS/Network/SSL.h index c1253e8189..a8a8d55bd2 100644 --- a/Source/Core/Core/IOS/Network/SSL.h +++ b/Source/Core/Core/IOS/Network/SSL.h @@ -32,7 +32,7 @@ namespace HLE #define SSLID_VALID(x) \ (x >= 0 && x < NET_SSL_MAXINSTANCES && ::IOS::HLE::Device::NetSSL::_SSL[x].active) -enum ssl_err_t +enum ssl_err_t : s32 { SSL_OK = 0, SSL_ERR_FAILED = -1, diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index b5968568a1..ce79f8dfcb 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -335,15 +335,15 @@ void WiiSocket::Update(bool read, bool write, bool except) switch (ret) { case 0: - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); break; case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; @@ -366,13 +366,13 @@ void WiiSocket::Update(bool read, bool write, bool except) else res = SSL_ERR_FAILED; - Memory::Write_U32(res, BufferIn); + WriteReturnValue(res, BufferIn); if (!nonBlock) ReturnValue = res; break; } default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } @@ -412,24 +412,24 @@ void WiiSocket::Update(bool read, bool write, bool except) if (ret >= 0) { // Return bytes written or SSL_ERR_ZERO if none - Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); + WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); } else { switch (ret) { case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } } @@ -450,24 +450,24 @@ void WiiSocket::Update(bool read, bool write, bool except) if (ret >= 0) { // Return bytes read or SSL_ERR_ZERO if none - Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); + WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); } else { switch (ret) { case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } } @@ -479,7 +479,7 @@ void WiiSocket::Update(bool read, bool write, bool except) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } } else diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index 3884baefdb..14a739e601 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -134,7 +134,7 @@ IPCCommandResult SDIOSlot0::IOCtlV(const IOCtlVRequest& request) return GetDefaultReply(IPC_SUCCESS); } -u32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _BufferInSize, +s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _BufferInSize, u32 _rwBuffer, u32 _rwBufferSize, u32 _BufferOut, u32 _BufferOutSize) { // The game will send us a SendCMD with this information. To be able to read and write @@ -164,7 +164,7 @@ u32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _Buffer // Note: req.addr is the virtual address of _rwBuffer - u32 ret = RET_OK; + s32 ret = RET_OK; switch (req.command) { diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h index 55bfabf8da..5e69389b30 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h @@ -128,7 +128,7 @@ private: IPCCommandResult SendCommand(const IOCtlVRequest& request); - u32 ExecuteCommand(const Request& request, u32 BufferIn, u32 BufferInSize, u32 BufferIn2, + s32 ExecuteCommand(const Request& request, u32 BufferIn, u32 BufferInSize, u32 BufferIn2, u32 BufferInSize2, u32 _BufferOut, u32 BufferOutSize); void OpenInternal(); diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp index c0c9379979..c0296abcdf 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "Common/Assert.h" #include "Common/CommonPaths.h" diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index a23c236ab8..d3aa66fc7c 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -7,7 +7,10 @@ #include #include #include +#include +#include #include +#include #include #include @@ -530,7 +533,7 @@ void BluetoothReal::LoadLinkKeys() std::reverse(address.begin(), address.end()); const std::string& key_string = pair.substr(index + 1); - linkkey_t key; + linkkey_t key{}; size_t pos = 0; for (size_t i = 0; i < key_string.length(); i = i + 2) { diff --git a/Source/Core/Core/IOS/USB/Host.cpp b/Source/Core/Core/IOS/USB/Host.cpp index e440494460..cba1cc4c95 100644 --- a/Source/Core/Core/IOS/USB/Host.cpp +++ b/Source/Core/Core/IOS/USB/Host.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include +#include #include #ifdef __LIBUSB__ diff --git a/Source/Core/Core/IOS/USB/LibusbDevice.cpp b/Source/Core/Core/IOS/USB/LibusbDevice.cpp index 9b57062336..3c8476174e 100644 --- a/Source/Core/Core/IOS/USB/LibusbDevice.cpp +++ b/Source/Core/Core/IOS/USB/LibusbDevice.cpp @@ -5,8 +5,12 @@ #include #include #include +#include #include +#include +#include #include +#include #include diff --git a/Source/Core/Core/IOS/USB/OH0/OH0Device.cpp b/Source/Core/Core/IOS/USB/OH0/OH0Device.cpp index e72de9cdfe..72e9908b38 100644 --- a/Source/Core/Core/IOS/USB/OH0/OH0Device.cpp +++ b/Source/Core/Core/IOS/USB/OH0/OH0Device.cpp @@ -2,7 +2,9 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include +#include #include #include diff --git a/Source/Core/Core/IOS/USB/USBV4.cpp b/Source/Core/Core/IOS/USB/USBV4.cpp index c2b9825cd6..3d963c9598 100644 --- a/Source/Core/Core/IOS/USB/USBV4.cpp +++ b/Source/Core/Core/IOS/USB/USBV4.cpp @@ -49,7 +49,7 @@ struct HIDRequest }; #pragma pack(pop) -V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessage(ios, ioctl, -1) +V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); @@ -65,7 +65,7 @@ V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessa // (US for the language and replacing non-ASCII characters with '?'), // we can simply submit it as a usual control request. V4GetUSStringMessage::V4GetUSStringMessage(Kernel& ios, const IOCtlRequest& ioctl) - : CtrlMessage(ios, ioctl, -1) + : CtrlMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); @@ -87,7 +87,7 @@ void V4GetUSStringMessage::OnTransferComplete(s32 return_value) const TransferCommand::OnTransferComplete(return_value); } -V4IntrMessage::V4IntrMessage(Kernel& ios, const IOCtlRequest& ioctl) : IntrMessage(ios, ioctl, -1) +V4IntrMessage::V4IntrMessage(Kernel& ios, const IOCtlRequest& ioctl) : IntrMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); diff --git a/Source/Core/Core/IOS/USB/USBV5.cpp b/Source/Core/Core/IOS/USB/USBV5.cpp index 357676fe08..aa6d9bf98b 100644 --- a/Source/Core/Core/IOS/USB/USBV5.cpp +++ b/Source/Core/Core/IOS/USB/USBV5.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include diff --git a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp index 897f588809..edcf8b18c3 100644 --- a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp +++ b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp @@ -5,7 +5,10 @@ #include "Core/IOS/USB/USB_HID/HIDv4.h" #include +#include +#include #include +#include #include "Common/Align.h" #include "Common/ChunkFile.h" diff --git a/Source/Core/Core/IOS/USB/USB_KBD.cpp b/Source/Core/Core/IOS/USB/USB_KBD.cpp index a9f361a1a7..185353a150 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.cpp +++ b/Source/Core/Core/IOS/USB/USB_KBD.cpp @@ -5,6 +5,7 @@ #include "Core/IOS/USB/USB_KBD.h" #include +#include #include "Common/FileUtil.h" #include "Common/IniFile.h" diff --git a/Source/Core/Core/IOS/USB/USB_VEN/VEN.cpp b/Source/Core/Core/IOS/USB/USB_VEN/VEN.cpp index f9bb7a1583..955710f176 100644 --- a/Source/Core/Core/IOS/USB/USB_VEN/VEN.cpp +++ b/Source/Core/Core/IOS/USB/USB_VEN/VEN.cpp @@ -4,7 +4,11 @@ #include "Core/IOS/USB/USB_VEN/VEN.h" +#include #include +#include +#include +#include #include "Common/ChunkFile.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index a5464151b6..34e4d4e8b7 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -86,7 +86,7 @@ WFSI::WFSI(Kernel& ios, const std::string& device_name) : Device(ios, device_nam IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) { - u32 return_error_code = IPC_SUCCESS; + s32 return_error_code = IPC_SUCCESS; switch (request.request) { diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 207a047079..8b31b029e7 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -7,12 +7,15 @@ #include #include #include +#include #include #include #include #include +#include #include #include +#include #include #include "Common/Assert.h" @@ -23,6 +26,7 @@ #include "Common/NandPaths.h" #include "Common/StringUtil.h" #include "Common/Timer.h" +#include "Core/Boot/Boot.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -97,6 +101,8 @@ static std::string s_InputDisplay[8]; static GCManipFunction s_gc_manip_func; static WiiManipFunction s_wii_manip_func; +static std::string s_current_file_name; + // NOTE: Host / CPU Thread static void EnsureTmpInputSize(size_t bound) { @@ -183,13 +189,13 @@ std::string GetInputDisplay() // NOTE: GPU Thread std::string GetRTCDisplay() { - time_t current_time = - ExpansionInterface::CEXIIPL::GetEmulatedTime(ExpansionInterface::CEXIIPL::UNIX_EPOCH); - tm* gm_time = gmtime(¤t_time); - char buffer[256]; - strftime(buffer, sizeof(buffer), "Date/Time: %c\n", gm_time); + using ExpansionInterface::CEXIIPL; + + const time_t current_time = CEXIIPL::GetEmulatedTime(CEXIIPL::UNIX_EPOCH); + const tm* const gm_time = gmtime(¤t_time); + std::stringstream format_time; - format_time << buffer; + format_time << std::put_time(gm_time, "Date/Time: %c\n"); return format_time.str(); } @@ -216,11 +222,19 @@ void FrameUpdate() s_bPolled = false; } +static void CheckMD5(); +static void GetMD5(); + // called when game is booting up, even if no movie is active, // but potentially after BeginRecordingInput or PlayInput has been called. // NOTE: EmuThread -void Init() +void Init(const BootParameters& boot) { + if (std::holds_alternative(boot.parameters)) + s_current_file_name = std::get(boot.parameters).path; + else + s_current_file_name.clear(); + s_bPolled = false; s_bFrameStep = false; s_bSaveConfig = false; @@ -1551,8 +1565,11 @@ void GetSettings() static const mbedtls_md_info_t* s_md5_info = mbedtls_md_info_from_type(MBEDTLS_MD_MD5); // NOTE: Entrypoint for own thread -void CheckMD5() +static void CheckMD5() { + if (s_current_file_name.empty()) + return; + for (int i = 0, n = 0; i < 16; ++i) { if (tmpHeader.md5[i] != 0) @@ -1564,7 +1581,7 @@ void CheckMD5() Core::DisplayMessage("Verifying checksum...", 2000); unsigned char gameMD5[16]; - mbedtls_md_file(s_md5_info, SConfig::GetInstance().m_strFilename.c_str(), gameMD5); + mbedtls_md_file(s_md5_info, s_current_file_name.c_str(), gameMD5); if (memcmp(gameMD5, s_MD5, 16) == 0) Core::DisplayMessage("Checksum of current game matches the recorded game.", 2000); @@ -1573,11 +1590,14 @@ void CheckMD5() } // NOTE: Entrypoint for own thread -void GetMD5() +static void GetMD5() { + if (s_current_file_name.empty()) + return; + Core::DisplayMessage("Calculating checksum of game file...", 2000); memset(s_MD5, 0, sizeof(s_MD5)); - mbedtls_md_file(s_md5_info, SConfig::GetInstance().m_strFilename.c_str(), s_MD5); + mbedtls_md_file(s_md5_info, s_current_file_name.c_str(), s_MD5); Core::DisplayMessage("Finished calculating checksum.", 2000); } diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index 84326dcdb6..d56e61eaad 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -9,6 +9,8 @@ #include "Common/CommonTypes.h" +struct BootParameters; + struct GCPadStatus; class PointerWrap; struct wiimote_key; @@ -110,7 +112,7 @@ static_assert(sizeof(DTMHeader) == 256, "DTMHeader should be 256 bytes"); void FrameUpdate(); void InputUpdate(); -void Init(); +void Init(const BootParameters& boot); void SetPolledDevice(); @@ -171,8 +173,6 @@ bool PlayWiimote(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& void EndPlayInput(bool cont); void SaveRecording(const std::string& filename); void DoState(PointerWrap& p); -void CheckMD5(); -void GetMD5(); void Shutdown(); void CheckPadStatus(GCPadStatus* PadStatus, int controllerID); void CheckWiimoteStatus(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index f6a335eac8..6774e323c6 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -3,11 +3,16 @@ // Refer to the license.txt file included. #include "Core/NetPlayClient.h" + #include #include -#include #include +#include +#include #include + +#include + #include "Common/Common.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index a77a6657bf..1e86cf0e2d 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -3,9 +3,15 @@ // Refer to the license.txt file included. #include "Core/NetPlayServer.h" + +#include #include +#include #include +#include +#include #include + #include "Common/Common.h" #include "Common/ENetUtil.h" #include "Common/FileUtil.h" @@ -361,7 +367,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player) sf::Packet spac; spac << (MessageId)NP_MSG_DISABLE_GAME; // this thread doesn't need players lock - SendToClients(spac, -1); + SendToClients(spac, static_cast(-1)); break; } } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 5cacf63a4f..f1e24b6113 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -2,7 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include +#include +#include #include #include diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index 480ee662da..65b8547b98 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -495,7 +495,7 @@ void Interpreter::divwx(UGeckoInstruction inst) } if (((u32)a & 0x80000000) && b == 0) - rGPR[inst.RD] = -1; + rGPR[inst.RD] = UINT32_MAX; else rGPR[inst.RD] = 0; } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 4fe96f5bfc..97ca0af716 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -87,7 +87,7 @@ public: // Use to extract bytes from a register using the regcache. offset is in bytes. Gen::OpArg ExtractFromReg(int reg, int offset); void AndWithMask(Gen::X64Reg reg, u32 mask); - bool CheckMergedBranch(int crf); + bool CheckMergedBranch(u32 crf); void DoMergedBranch(); void DoMergedBranchCondition(); void DoMergedBranchImmediate(s64 val); diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index 601bf42248..e9db74a0ad 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -30,7 +30,7 @@ void RegCache::Start() xreg.free = true; xreg.dirty = false; xreg.locked = false; - xreg.ppcReg = INVALID_REG; + xreg.ppcReg = static_cast(INVALID_REG); } for (size_t i = 0; i < m_regs.size(); i++) { @@ -63,7 +63,7 @@ void RegCache::DiscardRegContentsIfCached(size_t preg) X64Reg xr = m_regs[preg].location.GetSimpleReg(); m_xregs[xr].free = true; m_xregs[xr].dirty = false; - m_xregs[xr].ppcReg = INVALID_REG; + m_xregs[xr].ppcReg = static_cast(INVALID_REG); m_regs[preg].away = false; m_regs[preg].location = GetDefaultLocation(preg); } @@ -216,7 +216,7 @@ void RegCache::StoreFromRegister(size_t i, FlushMode mode) if (mode == FlushMode::All) { m_xregs[xr].free = true; - m_xregs[xr].ppcReg = INVALID_REG; + m_xregs[xr].ppcReg = static_cast(INVALID_REG); m_xregs[xr].dirty = false; } } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index 63ac8ff7d5..12da80f64a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -486,7 +486,7 @@ void Jit64::FloatCompare(UGeckoInstruction inst, bool upper) // bool ordered = !!(inst.SUBOP10 & 32); int a = inst.FA; int b = inst.FB; - int crf = inst.CRFD; + u32 crf = inst.CRFD; int output[4] = {CR_SO, CR_EQ, CR_GT, CR_LT}; // Merge neighboring fcmp and cror (the primary use of cror). diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 5f25fd5d22..2ff5e1bffe 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -339,7 +339,7 @@ void Jit64::reg_imm(UGeckoInstruction inst) } } -bool Jit64::CheckMergedBranch(int crf) +bool Jit64::CheckMergedBranch(u32 crf) { if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE)) return false; @@ -473,7 +473,7 @@ void Jit64::cmpXX(UGeckoInstruction inst) JITDISABLE(bJITIntegerOff); int a = inst.RA; int b = inst.RB; - int crf = inst.CRFD; + u32 crf = inst.CRFD; bool merge_branch = CheckMergedBranch(crf); OpArg comparand; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index 1d34bf4796..fc6e1f262a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -202,7 +202,7 @@ void Jit64::lXXx(UGeckoInstruction inst) // If we're using reg+reg mode and b is an immediate, pretend we're using constant offset mode bool use_constant_offset = inst.OPCD != 31 || gpr.R(b).IsImm(); - s32 offset; + s32 offset = 0; if (use_constant_offset) offset = inst.OPCD == 31 ? gpr.R(b).SImm32() : (s32)inst.SIMM_16; // Depending on whether we have an immediate and/or update, find the optimum way to calculate diff --git a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp index 2fe4ea9f65..a3054f7509 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp @@ -4,6 +4,9 @@ #include "Core/PowerPC/Jit64Common/EmuCodeBlock.h" +#include +#include + #include "Common/Assert.h" #include "Common/CPUDetect.h" #include "Common/Intrinsics.h" diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp index d2d8873e90..57901bdb0f 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h" + +#include + #include "Common/Assert.h" #include "Common/CPUDetect.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index 6c19a81c22..efad560110 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -10,8 +10,11 @@ // locating performance issues. #include +#include #include +#include #include +#include #include #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index e427671f6f..6f602ec3da 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef _WIN32 #include diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 7716ccf3fc..9df3483223 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "Common/Atomic.h" #include "Common/BitSet.h" diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 312cf96ddd..c34cfd72fc 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -3,8 +3,10 @@ // Refer to the license.txt file included. #include +#include #include #include +#include #include "Common/Assert.h" #include "Common/CommonTypes.h" @@ -728,8 +730,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32 code[i].opinfo = opinfo; code[i].address = address; code[i].inst = inst; - code[i].branchTo = -1; - code[i].branchToIndex = -1; + code[i].branchTo = UINT32_MAX; + code[i].branchToIndex = UINT32_MAX; code[i].skip = false; block->m_stats->numCycles += opinfo->numCycles; block->m_physical_addresses.insert(result.physical_address); diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index 1ca6e6aa61..9e53c239b9 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -296,7 +296,7 @@ constexpr int BAT_INDEX_SHIFT = 17; constexpr u32 BAT_PAGE_SIZE = 1 << BAT_INDEX_SHIFT; constexpr u32 BAT_MAPPED_BIT = 0x1; constexpr u32 BAT_PHYSICAL_BIT = 0x2; -constexpr u32 BAT_RESULT_MASK = ~0x3; +constexpr u32 BAT_RESULT_MASK = UINT32_C(~0x3); using BatTable = std::array; // 128 KB extern BatTable ibat_table; extern BatTable dbat_table; diff --git a/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp index 1aea672ab6..f8f1fa7153 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp index 91ff8eb0e1..9e1a924667 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "Common/FileUtil.h" diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 4dfd5f64a0..fc9ab89f87 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index a3fffacea6..01cbd1d2fe 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -156,8 +156,7 @@ static std::string DoState(PointerWrap& p) return version_created_by; } - bool is_wii = - SConfig::GetInstance().bWii || SConfig::GetInstance().m_BootType == SConfig::BOOT_MIOS; + bool is_wii = SConfig::GetInstance().bWii || SConfig::GetInstance().m_is_mios; const bool is_wii_currently = is_wii; p.Do(is_wii); if (is_wii != is_wii_currently) diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index 9225d6705d..286aba930e 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "Core/TitleDatabase.h" diff --git a/Source/Core/Core/ec_wii.cpp b/Source/Core/Core/ec_wii.cpp index 7237512b86..9049b0a493 100644 --- a/Source/Core/Core/ec_wii.cpp +++ b/Source/Core/Core/ec_wii.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index b674dedc18..a1c8c97b40 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -48,7 +48,7 @@ private: CISOFileReader(File::IOFile file); typedef u16 MapType; - static const MapType UNUSED_BLOCK_ID = -1; + static const MapType UNUSED_BLOCK_ID = UINT16_MAX; File::IOFile m_file; u64 m_size; diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index cf14144f50..b809047679 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -77,10 +77,10 @@ u64 FileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _ u64 read_length = std::min(_MaxBufferSize, pFileInfo->m_FileSize - _OffsetInFile); - DEBUG_LOG( - DISCIO, - "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64 " Size: %" PRIx64, - read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset, pFileInfo->m_FileSize); + DEBUG_LOG(DISCIO, "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64 + " Size: %" PRIx64, + read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset, + pFileInfo->m_FileSize); m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_partition); return read_length; @@ -155,7 +155,7 @@ bool FileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const std::optional FileSystemGCWii::GetBootDOLOffset() const { std::optional offset = m_rVolume->ReadSwapped(0x420, m_partition); - return offset ? static_cast(*offset) << 2 : std::optional(); + return offset ? static_cast(*offset) << m_offset_shift : std::optional(); } std::optional FileSystemGCWii::GetBootDOLSize(u64 dol_offset) const diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index ed965983e6..f6f603d8ff 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -35,7 +35,7 @@ const size_t VolumeDirectory::MAX_ID_LENGTH; VolumeDirectory::VolumeDirectory(const std::string& directory, bool is_wii, const std::string& apploader, const std::string& dol) - : m_data_start_address(-1), m_disk_header(DISKHEADERINFO_ADDRESS), + : m_data_start_address(UINT64_MAX), m_disk_header(DISKHEADERINFO_ADDRESS), m_disk_header_info(std::make_unique()), m_fst_address(0), m_dol_address(0) { m_root_directory = ExtractDirectoryName(directory); diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index f928bbcdf3..4b6ef56539 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -32,7 +32,8 @@ namespace DiscIO constexpr u64 PARTITION_DATA_OFFSET = 0x20000; VolumeWii::VolumeWii(std::unique_ptr reader) - : m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), m_last_decrypted_block(-1) + : m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), + m_last_decrypted_block(UINT64_MAX) { _assert_(m_pReader); diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index 528f2aa0e0..988518724a 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -18,6 +18,7 @@ #include "Common/MsgHandler.h" #include "Core/Analytics.h" +#include "Core/Boot/Boot.h" #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -422,7 +423,7 @@ int main(int argc, char* argv[]) DolphinAnalytics::Instance()->ReportDolphinStart("nogui"); - if (!BootManager::BootCore(boot_filename, SConfig::BOOT_DEFAULT)) + if (!BootManager::BootCore(BootParameters::GenerateFromFile(boot_filename))) { fprintf(stderr, "Could not boot %s\n", boot_filename.c_str()); return 1; diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt index 42a42bfaa8..e5ff552b6c 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_AUTOMOC ON) set(SRCS AboutDialog.cpp + HotkeyScheduler.cpp Host.cpp InDevelopmentWarning.cpp Main.cpp @@ -24,6 +25,12 @@ set(SRCS Config/Mapping/GCKeyboardEmu.cpp Config/Mapping/GCPadEmu.cpp Config/Mapping/GCPadWiiU.cpp + Config/Mapping/Hotkey3D.cpp + Config/Mapping/HotkeyGeneral.cpp + Config/Mapping/HotkeyGraphics.cpp + Config/Mapping/HotkeyStates.cpp + Config/Mapping/HotkeyTAS.cpp + Config/Mapping/HotkeyWii.cpp Config/Mapping/MappingBool.cpp Config/Mapping/MappingButton.cpp Config/Mapping/MappingNumeric.cpp @@ -41,6 +48,7 @@ set(SRCS GameList/ListProxyModel.cpp QtUtils/DoubleClickEventFilter.cpp QtUtils/ElidedButton.cpp + QtUtils/FocusEventFilter.cpp Settings/GeneralPane.cpp Settings/InterfacePane.cpp Settings/PathPane.cpp diff --git a/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.cpp b/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.cpp new file mode 100644 index 0000000000..c144d53f76 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.cpp @@ -0,0 +1,42 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/Hotkey3D.h" + +#include +#include + +#include "Core/HotkeyManager.h" + +Hotkey3D::Hotkey3D(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void Hotkey3D::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget( + CreateGroupBox(tr("3D"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_TOGGLE))); + m_main_layout->addWidget( + CreateGroupBox(tr("3D Depth"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_DEPTH))); + + setLayout(m_main_layout); +} + +InputConfig* Hotkey3D::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void Hotkey3D::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void Hotkey3D::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.h b/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.h new file mode 100644 index 0000000000..b7e78822f2 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/Hotkey3D.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class Hotkey3D final : public MappingWidget +{ +public: + explicit Hotkey3D(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.cpp b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.cpp new file mode 100644 index 0000000000..fc111f745c --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.cpp @@ -0,0 +1,47 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/HotkeyGeneral.h" + +#include +#include +#include + +#include "Core/HotkeyManager.h" + +HotkeyGeneral::HotkeyGeneral(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void HotkeyGeneral::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget( + CreateGroupBox(tr("General"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL))); + + auto* vbox = new QVBoxLayout(); + vbox->addWidget(CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME))); + vbox->addWidget( + CreateGroupBox(tr("Emulation Speed"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED))); + m_main_layout->addItem(vbox); + + setLayout(m_main_layout); +} + +InputConfig* HotkeyGeneral::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void HotkeyGeneral::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void HotkeyGeneral::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.h b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.h new file mode 100644 index 0000000000..15c6dd04b3 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGeneral.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class HotkeyGeneral final : public MappingWidget +{ +public: + explicit HotkeyGeneral(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.cpp b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.cpp new file mode 100644 index 0000000000..fe4cc8cdba --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.cpp @@ -0,0 +1,48 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/HotkeyGraphics.h" + +#include +#include +#include + +#include "Core/HotkeyManager.h" + +HotkeyGraphics::HotkeyGraphics(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void HotkeyGraphics::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget( + CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK))); + + auto* vbox = new QVBoxLayout(); + vbox->addWidget(CreateGroupBox(tr("Graphics Toggles"), + HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES))); + vbox->addWidget( + CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR))); + m_main_layout->addItem(vbox); + + setLayout(m_main_layout); +} + +InputConfig* HotkeyGraphics::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void HotkeyGraphics::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void HotkeyGraphics::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.h b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.h new file mode 100644 index 0000000000..63837202b3 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyGraphics.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class HotkeyGraphics final : public MappingWidget +{ +public: + explicit HotkeyGraphics(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.cpp b/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.cpp new file mode 100644 index 0000000000..20d85cd544 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.cpp @@ -0,0 +1,42 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/HotkeyStates.h" + +#include +#include + +#include "Core/HotkeyManager.h" + +HotkeyStates::HotkeyStates(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void HotkeyStates::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget( + CreateGroupBox(tr("Save"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SAVE_STATE))); + m_main_layout->addWidget( + CreateGroupBox(tr("Load"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_STATE))); + + setLayout(m_main_layout); +} + +InputConfig* HotkeyStates::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void HotkeyStates::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void HotkeyStates::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.h b/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.h new file mode 100644 index 0000000000..bf36ec96f3 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyStates.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class HotkeyStates final : public MappingWidget +{ +public: + explicit HotkeyStates(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.cpp b/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.cpp new file mode 100644 index 0000000000..2586ff2d2a --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.cpp @@ -0,0 +1,42 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/HotkeyTAS.h" + +#include +#include + +#include "Core/HotkeyManager.h" + +HotkeyTAS::HotkeyTAS(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void HotkeyTAS::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget( + CreateGroupBox(tr("Frame Advance"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FRAME_ADVANCE))); + m_main_layout->addWidget( + CreateGroupBox(tr("Movie"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_MOVIE))); + + setLayout(m_main_layout); +} + +InputConfig* HotkeyTAS::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void HotkeyTAS::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void HotkeyTAS::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.h b/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.h new file mode 100644 index 0000000000..d6fabc1294 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyTAS.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class HotkeyTAS final : public MappingWidget +{ +public: + explicit HotkeyTAS(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.cpp b/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.cpp new file mode 100644 index 0000000000..7cfebf5705 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.cpp @@ -0,0 +1,39 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/Config/Mapping/HotkeyWii.h" + +#include +#include + +#include "Core/HotkeyManager.h" + +HotkeyWii::HotkeyWii(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void HotkeyWii::CreateMainLayout() +{ + m_main_layout = new QHBoxLayout(); + + m_main_layout->addWidget(CreateGroupBox(tr("Wii"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_WII))); + + setLayout(m_main_layout); +} + +InputConfig* HotkeyWii::GetConfig() +{ + return HotkeyManagerEmu::GetConfig(); +} + +void HotkeyWii::LoadSettings() +{ + HotkeyManagerEmu::LoadConfig(); +} + +void HotkeyWii::SaveSettings() +{ + HotkeyManagerEmu::GetConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.h b/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.h new file mode 100644 index 0000000000..56906e8770 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/HotkeyWii.h @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt2/Config/Mapping/MappingWidget.h" + +class QHBoxLayout; + +class HotkeyWii final : public MappingWidget +{ +public: + explicit HotkeyWii(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QHBoxLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index 04e20485b2..33e30a9b93 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -20,6 +20,12 @@ #include "DolphinQt2/Config/Mapping/GCKeyboardEmu.h" #include "DolphinQt2/Config/Mapping/GCPadEmu.h" #include "DolphinQt2/Config/Mapping/GCPadWiiU.h" +#include "DolphinQt2/Config/Mapping/Hotkey3D.h" +#include "DolphinQt2/Config/Mapping/HotkeyGeneral.h" +#include "DolphinQt2/Config/Mapping/HotkeyGraphics.h" +#include "DolphinQt2/Config/Mapping/HotkeyStates.h" +#include "DolphinQt2/Config/Mapping/HotkeyTAS.h" +#include "DolphinQt2/Config/Mapping/HotkeyWii.h" #include "DolphinQt2/Config/Mapping/WiimoteEmuExtension.h" #include "DolphinQt2/Config/Mapping/WiimoteEmuGeneral.h" #include "DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.h" @@ -285,6 +291,18 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) AddWidget(tr("Extension"), extension); break; } + case Type::MAPPING_HOTKEYS: + { + widget = new HotkeyGeneral(this); + AddWidget(tr("General"), widget); + AddWidget(tr("TAS Tools"), new HotkeyTAS(this)); + AddWidget(tr("Wii (Remote)"), new HotkeyWii(this)); + AddWidget(tr("Graphics"), new HotkeyGraphics(this)); + AddWidget(tr("3D"), new Hotkey3D(this)); + AddWidget(tr("Save States"), new HotkeyStates(this)); + setWindowTitle(tr("Hotkey Settings")); + break; + } default: return; } diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h index c181f642b3..8e6fd82d7c 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h @@ -41,7 +41,9 @@ public: MAPPING_GC_STEERINGWHEEL, // Wii MAPPING_WIIMOTE_EMU, - MAPPING_WIIMOTE_HYBRID + MAPPING_WIIMOTE_HYBRID, + // Hotkeys + MAPPING_HOTKEYS }; explicit MappingWindow(QWidget* parent, int port_num); diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj index 3e5ba69f0e..55e74a42cd 100644 --- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj +++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj @@ -41,31 +41,18 @@ - - true - $(ExternalsDir)ffmpeg\lib;$(ExternalsDir)OpenAL\lib;%(AdditionalLibraryDirectories) avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;%(AdditionalDependencies) - - /NODEFAULTLIB:libcmt %(AdditionalOptions) - $(ProjectDir)\VideoInterface;$(ProjectDir)\GameList;$(ProjectDir)\Settings;$(ProjectDir)\Config;$(ProjectDir)\Config\Mapping;$(ProjectDir)\QtUtils;%(AdditionalIncludeDirectories) + $(ProjectDir)VideoInterface;$(ProjectDir)GameList;$(ProjectDir)Settings;$(ProjectDir)Config;$(ProjectDir)Config\Mapping;$(ProjectDir)QtUtils;%(AdditionalIncludeDirectories) DolphinQt2.manifest;%(AdditionalManifestFiles) - - - - - - - - @@ -83,11 +70,13 @@ + + @@ -98,12 +87,14 @@ + + @@ -125,6 +116,12 @@ + + + + + + @@ -140,6 +137,7 @@ + @@ -147,6 +145,7 @@ + @@ -156,11 +155,9 @@ - @@ -216,10 +213,10 @@ {604C8368-F34A-4D55-82C8-CC92A0C13254} - + {0e033be3-2e08-428e-9ae9-bc673efa12b5} - + {29f29a19-f141-45ad-9679-5a2923b49da3} @@ -235,10 +232,6 @@ - - - - @@ -248,4 +241,4 @@ - + \ No newline at end of file diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.cpp b/Source/Core/DolphinQt2/GameList/GameListModel.cpp index 07f23c1b94..78f13928fb 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt2/GameList/GameListModel.cpp @@ -3,6 +3,8 @@ // Refer to the license.txt file included. #include "DolphinQt2/GameList/GameListModel.h" + +#include "DiscIO/Enums.h" #include "DolphinQt2/Resources.h" #include "DolphinQt2/Settings.h" @@ -21,6 +23,8 @@ GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent) emit layoutAboutToBeChanged(); emit layoutChanged(); }); + + // TODO: Reload m_title_database when the language changes } QVariant GameListModel::data(const QModelIndex& index, int role) const @@ -63,7 +67,16 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const break; case COL_TITLE: if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole) - return game->GetLongName(); + { + QString display_name = QString::fromStdString(m_title_database.GetTitleName( + game->GetGameID().toStdString(), game->GetPlatformID() == DiscIO::Platform::WII_WAD ? + Core::TitleDatabase::TitleType::Channel : + Core::TitleDatabase::TitleType::Other)); + if (display_name.isEmpty()) + return game->GetLongName(); + + return display_name; + } break; case COL_ID: if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole) diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.h b/Source/Core/DolphinQt2/GameList/GameListModel.h index ab6a149cde..bd49c348d3 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.h +++ b/Source/Core/DolphinQt2/GameList/GameListModel.h @@ -7,6 +7,7 @@ #include #include +#include "Core/TitleDatabase.h" #include "DolphinQt2/GameList/GameFile.h" #include "DolphinQt2/GameList/GameTracker.h" @@ -54,4 +55,5 @@ private: GameTracker m_tracker; QList> m_games; + Core::TitleDatabase m_title_database; }; diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp new file mode 100644 index 0000000000..3be862f8e1 --- /dev/null +++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp @@ -0,0 +1,363 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt2/HotkeyScheduler.h" + +#include +#include + +#include + +#include "AudioCommon/AudioCommon.h" +#include "Common/Thread.h" +#include "Core/Core.h" +#include "Core/HotkeyManager.h" +#include "Core/IOS/IOS.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" +#include "Core/State.h" +#include "DolphinQt2/MainWindow.h" +#include "DolphinQt2/Settings.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" +#include "VideoCommon/VertexShaderManager.h" +#include "VideoCommon/VideoConfig.h" + +constexpr const char* DUBOIS_ALGORITHM_SHADER = "dubois"; + +HotkeyScheduler::HotkeyScheduler() : m_stop_requested(false) +{ + HotkeyManagerEmu::Initialize(); + HotkeyManagerEmu::LoadConfig(); + HotkeyManagerEmu::Enable(true); +} + +HotkeyScheduler::~HotkeyScheduler() +{ + Stop(); +} + +void HotkeyScheduler::Start() +{ + m_stop_requested.Set(false); + m_thread = std::thread(&HotkeyScheduler::Run, this); +} + +void HotkeyScheduler::Stop() +{ + m_stop_requested.Set(true); + + if (m_thread.joinable()) + m_thread.join(); +} + +static bool IsHotkey(int id, bool held = false) +{ + return HotkeyManagerEmu::IsPressed(id, held); +} + +static void HandleFrameskipHotkeys() +{ + constexpr int MAX_FRAME_SKIP_DELAY = 60; + constexpr int FRAME_STEP_DELAY = 30; + + static int frame_step_count = 0; + static int frame_step_delay = 1; + static int frame_step_delay_count = 0; + static bool frame_step_hold = false; + + if (IsHotkey(HK_FRAME_ADVANCE_INCREASE_SPEED)) + { + frame_step_delay = std::min(frame_step_delay + 1, MAX_FRAME_SKIP_DELAY); + return; + } + + if (IsHotkey(HK_FRAME_ADVANCE_DECREASE_SPEED)) + { + frame_step_delay = std::max(frame_step_delay - 1, 0); + return; + } + + if (IsHotkey(HK_FRAME_ADVANCE_RESET_SPEED)) + { + frame_step_delay = 1; + return; + } + + if (IsHotkey(HK_FRAME_ADVANCE, true)) + { + if (frame_step_delay_count < frame_step_delay && frame_step_hold) + frame_step_delay_count++; + + // TODO GUI Update (Depends on an unimplemented feature) + // if ((frame_step_count == 0 || frame_step_count == FRAME_STEP_DELAY) && !frame_step_hold) + + if (frame_step_count < FRAME_STEP_DELAY) + { + ++frame_step_count; + if (frame_step_hold) + frame_step_hold = false; + } + + if (frame_step_count == FRAME_STEP_DELAY && frame_step_hold && + frame_step_delay_count >= frame_step_delay) + { + frame_step_hold = false; + frame_step_delay_count = 0; + } + + return; + } + + if (frame_step_count > 0) + { + // Reset frame advance + frame_step_count = 0; + frame_step_hold = false; + frame_step_delay_count = 0; + } +} + +void HotkeyScheduler::Run() +{ + while (!m_stop_requested.IsSet()) + { + Common::SleepCurrentThread(1000 / 60); + + if (!HotkeyManagerEmu::IsEnabled()) + continue; + + if (Core::GetState() == Core::State::Uninitialized || Core::GetState() == Core::State::Paused) + g_controller_interface.UpdateInput(); + + if (Core::GetState() != Core::State::Stopping) + { + HotkeyManagerEmu::GetStatus(); + + if (!Core::IsRunningAndStarted()) + continue; + + // Fullscreen + if (IsHotkey(HK_FULLSCREEN)) + emit FullScreenHotkey(); + + // Pause and Unpause + if (IsHotkey(HK_PLAY_PAUSE)) + emit PauseHotkey(); + + // Stop + if (IsHotkey(HK_STOP)) + emit StopHotkey(); + + // Frameskipping + HandleFrameskipHotkeys(); + + // Screenshot + if (IsHotkey(HK_SCREENSHOT)) + emit ScreenShotHotkey(); + + // Exit + if (IsHotkey(HK_EXIT)) + emit ExitHotkey(); + + // Volume + if (IsHotkey(HK_VOLUME_DOWN)) + AudioCommon::DecreaseVolume(3); + + if (IsHotkey(HK_VOLUME_UP)) + AudioCommon::IncreaseVolume(3); + + if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) + AudioCommon::ToggleMuteVolume(); + + auto& settings = Settings::Instance(); + + // Wiimote + if (settings.IsBluetoothPassthroughEnabled()) + { + const auto ios = IOS::HLE::GetIOS(); + auto device = ios ? ios->GetDeviceByName("/dev/usb/oh1/57e/305") : nullptr; + + if (device != nullptr) + std::static_pointer_cast(device)->UpdateSyncButtonState( + IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); + } + + // TODO Debugging shortcuts (Separate PR) + + if (settings.IsWiiGameRunning()) + { + int wiimote_id = -1; + if (IsHotkey(HK_WIIMOTE1_CONNECT)) + wiimote_id = 0; + if (IsHotkey(HK_WIIMOTE2_CONNECT)) + wiimote_id = 1; + if (IsHotkey(HK_WIIMOTE3_CONNECT)) + wiimote_id = 2; + if (IsHotkey(HK_WIIMOTE4_CONNECT)) + wiimote_id = 3; + if (IsHotkey(HK_BALANCEBOARD_CONNECT)) + wiimote_id = 4; + + // TODO Implement Wiimote connecting / disconnecting (Separate PR) + // if (wiimote_id > -1) + } + + // Graphics + if (IsHotkey(HK_INCREASE_IR)) + ++g_Config.iEFBScale; + if (IsHotkey(HK_DECREASE_IR)) + g_Config.iEFBScale = std::max(g_Config.iEFBScale - 1, static_cast(SCALE_AUTO)); + if (IsHotkey(HK_TOGGLE_CROP)) + g_Config.bCrop = !g_Config.bCrop; + if (IsHotkey(HK_TOGGLE_AR)) + g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3; + if (IsHotkey(HK_TOGGLE_EFBCOPIES)) + g_Config.bSkipEFBCopyToRam = !g_Config.bSkipEFBCopyToRam; + if (IsHotkey(HK_TOGGLE_FOG)) + g_Config.bDisableFog = !g_Config.bDisableFog; + if (IsHotkey(HK_TOGGLE_DUMPTEXTURES)) + g_Config.bDumpTextures = !g_Config.bDumpTextures; + if (IsHotkey(HK_TOGGLE_TEXTURES)) + g_Config.bHiresTextures = !g_Config.bHiresTextures; + + Core::SetIsThrottlerTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true)); + + if (IsHotkey(HK_DECREASE_EMULATION_SPEED)) + { + auto speed = settings.GetEmulationSpeed() - 0.1; + speed = (speed <= 0 || (speed >= 0.95 && speed <= 1.05)) ? 1.0 : speed; + settings.SetEmulationSpeed(speed); + } + + if (IsHotkey(HK_INCREASE_EMULATION_SPEED)) + { + auto speed = settings.GetEmulationSpeed() + 0.1; + speed = (speed >= 0.95 && speed <= 1.05) ? 1.0 : speed; + settings.SetEmulationSpeed(speed); + } + + // Slot Saving / Loading + if (IsHotkey(HK_SAVE_STATE_SLOT_SELECTED)) + emit StateSaveSlotHotkey(); + + if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED)) + emit StateLoadSlotHotkey(); + + // Stereoscopy + if (IsHotkey(HK_TOGGLE_STEREO_SBS) || IsHotkey(HK_TOGGLE_STEREO_TAB)) + { + if (g_Config.iStereoMode != STEREO_SBS) + { + // Disable post-processing shader, as stereoscopy itself is currently a shader + if (g_Config.sPostProcessingShader == DUBOIS_ALGORITHM_SHADER) + g_Config.sPostProcessingShader = ""; + + g_Config.iStereoMode = IsHotkey(HK_TOGGLE_STEREO_SBS) ? STEREO_SBS : STEREO_TAB; + } + else + { + g_Config.iStereoMode = STEREO_OFF; + } + } + + if (IsHotkey(HK_TOGGLE_STEREO_ANAGLYPH)) + { + if (g_Config.iStereoMode != STEREO_ANAGLYPH) + { + g_Config.iStereoMode = STEREO_ANAGLYPH; + g_Config.sPostProcessingShader = DUBOIS_ALGORITHM_SHADER; + } + else + { + g_Config.iStereoMode = STEREO_OFF; + g_Config.sPostProcessingShader = ""; + } + } + + if (IsHotkey(HK_TOGGLE_STEREO_3DVISION)) + { + if (g_Config.iStereoMode != STEREO_3DVISION) + { + if (g_Config.sPostProcessingShader == DUBOIS_ALGORITHM_SHADER) + g_Config.sPostProcessingShader = ""; + + g_Config.iStereoMode = STEREO_3DVISION; + } + else + { + g_Config.iStereoMode = STEREO_OFF; + } + } + } + + if (IsHotkey(HK_DECREASE_DEPTH, true)) + g_Config.iStereoDepth = std::max(g_Config.iStereoDepth - 1, 0); + + if (IsHotkey(HK_INCREASE_DEPTH, true)) + g_Config.iStereoDepth = std::min(g_Config.iStereoDepth + 1, 100); + + if (IsHotkey(HK_DECREASE_CONVERGENCE, true)) + g_Config.iStereoConvergence = std::max(g_Config.iStereoConvergence - 5, 0); + + if (IsHotkey(HK_INCREASE_CONVERGENCE, true)) + g_Config.iStereoConvergence = std::min(g_Config.iStereoConvergence + 5, 500); + + // Freelook + static float fl_speed = 1.0; + + if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true)) + fl_speed /= 1.1f; + + if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true)) + fl_speed *= 1.1f; + + if (IsHotkey(HK_FREELOOK_RESET_SPEED, true)) + fl_speed = 1.0; + + if (IsHotkey(HK_FREELOOK_UP, true)) + VertexShaderManager::TranslateView(0.0, 0.0, -fl_speed); + + if (IsHotkey(HK_FREELOOK_DOWN, true)) + VertexShaderManager::TranslateView(0.0, 0.0, fl_speed); + + if (IsHotkey(HK_FREELOOK_LEFT, true)) + VertexShaderManager::TranslateView(fl_speed, 0.0); + + if (IsHotkey(HK_FREELOOK_RIGHT, true)) + VertexShaderManager::TranslateView(-fl_speed, 0.0); + + if (IsHotkey(HK_FREELOOK_ZOOM_IN, true)) + VertexShaderManager::TranslateView(0.0, fl_speed); + + if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true)) + VertexShaderManager::TranslateView(0.0, -fl_speed); + + if (IsHotkey(HK_FREELOOK_RESET, true)) + VertexShaderManager::ResetView(); + + // Savestates + for (u32 i = 0; i < State::NUM_STATES; i++) + { + if (IsHotkey(HK_LOAD_STATE_SLOT_1 + i)) + State::Load(i + 1); + + if (IsHotkey(HK_SAVE_STATE_SLOT_1 + i)) + State::Save(i + 1); + + if (IsHotkey(HK_LOAD_LAST_STATE_1 + i)) + State::LoadLastSaved(i + 1); + + if (IsHotkey(HK_SELECT_STATE_SLOT_1 + i)) + emit SetStateSlotHotkey(i + 1); + } + + if (IsHotkey(HK_SAVE_FIRST_STATE)) + State::SaveFirstSaved(); + + if (IsHotkey(HK_UNDO_LOAD_STATE)) + State::UndoLoadState(); + + if (IsHotkey(HK_UNDO_SAVE_STATE)) + State::UndoSaveState(); + } +} diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.h b/Source/Core/DolphinQt2/HotkeyScheduler.h new file mode 100644 index 0000000000..2deebbce16 --- /dev/null +++ b/Source/Core/DolphinQt2/HotkeyScheduler.h @@ -0,0 +1,37 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +#include + +#include "Common/Flag.h" + +class HotkeyScheduler : public QObject +{ + Q_OBJECT +public: + explicit HotkeyScheduler(); + ~HotkeyScheduler(); + + void Start(); + void Stop(); +signals: + void ExitHotkey(); + void FullScreenHotkey(); + void StopHotkey(); + void PauseHotkey(); + void ScreenShotHotkey(); + void SetStateSlotHotkey(int slot); + void StateLoadSlotHotkey(); + void StateSaveSlotHotkey(); + +private: + void Run(); + + Common::Flag m_stop_requested; + std::thread m_thread; +}; diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index a8049826f2..71e72f6fea 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -9,6 +9,7 @@ #include "Common/Common.h" +#include "Core/Boot/Boot.h" #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -24,9 +25,13 @@ #include "DolphinQt2/AboutDialog.h" #include "DolphinQt2/Config/ControllersWindow.h" + +#include "DolphinQt2/Config/Mapping/MappingWindow.h" #include "DolphinQt2/Config/SettingsWindow.h" #include "DolphinQt2/Host.h" +#include "DolphinQt2/HotkeyScheduler.h" #include "DolphinQt2/MainWindow.h" +#include "DolphinQt2/QtUtils/FocusEventFilter.h" #include "DolphinQt2/Resources.h" #include "DolphinQt2/Settings.h" @@ -64,16 +69,32 @@ void MainWindow::InitControllers() Pad::Initialize(); Keyboard::Initialize(); Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); - HotkeyManagerEmu::Initialize(); + m_hotkey_scheduler = new HotkeyScheduler(); + m_hotkey_scheduler->Start(); + + ConnectHotkeys(); } void MainWindow::ShutdownControllers() { + m_hotkey_scheduler->Stop(); + g_controller_interface.Shutdown(); Pad::Shutdown(); Keyboard::Shutdown(); Wiimote::Shutdown(); HotkeyManagerEmu::Shutdown(); + + m_hotkey_scheduler->deleteLater(); +} + +static void InstallHotkeyFilter(QDialog* dialog) +{ + auto* filter = new FocusEventFilter(); + dialog->installEventFilter(filter); + + filter->connect(filter, &FocusEventFilter::focusOutEvent, [] { HotkeyManagerEmu::Enable(true); }); + filter->connect(filter, &FocusEventFilter::focusInEvent, [] { HotkeyManagerEmu::Enable(false); }); } void MainWindow::CreateComponents() @@ -85,6 +106,11 @@ void MainWindow::CreateComponents() m_stack = new QStackedWidget(this); m_controllers_window = new ControllersWindow(this); m_settings_window = new SettingsWindow(this); + m_hotkey_window = new MappingWindow(this, 0); + + InstallHotkeyFilter(m_hotkey_window); + InstallHotkeyFilter(m_controllers_window); + InstallHotkeyFilter(m_settings_window); } void MainWindow::ConnectMenuBar() @@ -113,6 +139,9 @@ void MainWindow::ConnectMenuBar() connect(m_menu_bar, &MenuBar::StateSaveOldest, this, &MainWindow::StateSaveOldest); connect(m_menu_bar, &MenuBar::SetStateSlot, this, &MainWindow::SetStateSlot); + // Options + connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog); + // View connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView); connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView); @@ -130,6 +159,22 @@ void MainWindow::ConnectMenuBar() [=]() { m_controllers_window->OnEmulationStateChanged(false); }); } +void MainWindow::ConnectHotkeys() +{ + connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close); + connect(m_hotkey_scheduler, &HotkeyScheduler::PauseHotkey, this, &MainWindow::Pause); + connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::Stop); + connect(m_hotkey_scheduler, &HotkeyScheduler::ScreenShotHotkey, this, &MainWindow::ScreenShot); + connect(m_hotkey_scheduler, &HotkeyScheduler::FullScreenHotkey, this, &MainWindow::FullScreen); + + connect(m_hotkey_scheduler, &HotkeyScheduler::StateLoadSlotHotkey, this, + &MainWindow::StateLoadSlot); + connect(m_hotkey_scheduler, &HotkeyScheduler::StateSaveSlotHotkey, this, + &MainWindow::StateSaveSlot); + connect(m_hotkey_scheduler, &HotkeyScheduler::SetStateSlotHotkey, this, + &MainWindow::SetStateSlot); +} + void MainWindow::ConnectToolBar() { addToolBar(m_tool_bar); @@ -287,7 +332,7 @@ void MainWindow::StartGame(const QString& path) return; } // Boot up, show an error if it fails to load the game. - if (!BootManager::BootCore(path.toStdString(), SConfig::BOOT_DEFAULT)) + if (!BootManager::BootCore(BootParameters::GenerateFromFile(path.toStdString()))) { QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok); return; @@ -364,6 +409,14 @@ void MainWindow::ShowAboutDialog() about->show(); } +void MainWindow::ShowHotkeyDialog() +{ + m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS); + m_hotkey_window->show(); + m_hotkey_window->raise(); + m_hotkey_window->activateWindow(); +} + void MainWindow::StateLoad() { QString path = QFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(), diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index 5e089c2572..2b9b2c4e90 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -14,6 +14,8 @@ #include "DolphinQt2/RenderWidget.h" #include "DolphinQt2/ToolBar.h" +class HotkeyScheduler; +class MappingWindow; class SettingsWindow; class ControllersWindow; @@ -58,6 +60,7 @@ private: void CreateComponents(); void ConnectGameList(); + void ConnectHotkeys(); void ConnectMenuBar(); void ConnectRenderWidget(); void ConnectStack(); @@ -73,6 +76,7 @@ private: void ShowSettingsWindow(); void ShowControllersWindow(); void ShowAboutDialog(); + void ShowHotkeyDialog(); QStackedWidget* m_stack; ToolBar* m_tool_bar; @@ -82,6 +86,8 @@ private: bool m_rendering_to_main; int m_state_slot = 1; + HotkeyScheduler* m_hotkey_scheduler; ControllersWindow* m_controllers_window; SettingsWindow* m_settings_window; + MappingWindow* m_hotkey_window; }; diff --git a/Source/Core/DolphinQt2/MenuBar.cpp b/Source/Core/DolphinQt2/MenuBar.cpp index ef9a449621..011649e0e1 100644 --- a/Source/Core/DolphinQt2/MenuBar.cpp +++ b/Source/Core/DolphinQt2/MenuBar.cpp @@ -20,7 +20,7 @@ MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent) AddFileMenu(); AddEmulationMenu(); addMenu(tr("Movie")); - addMenu(tr("Options")); + AddOptionsMenu(); AddToolsMenu(); AddViewMenu(); AddHelpMenu(); @@ -171,6 +171,12 @@ void MenuBar::AddViewMenu() AddTableColumnsMenu(view_menu); } +void MenuBar::AddOptionsMenu() +{ + QMenu* options_menu = addMenu(tr("Options")); + options_menu->addAction(tr("Hotkey Settings"), this, &MenuBar::ConfigureHotkeys); +} + void MenuBar::AddHelpMenu() { QMenu* help_menu = addMenu(tr("Help")); diff --git a/Source/Core/DolphinQt2/MenuBar.h b/Source/Core/DolphinQt2/MenuBar.h index fa8c67cc38..a0346f4277 100644 --- a/Source/Core/DolphinQt2/MenuBar.h +++ b/Source/Core/DolphinQt2/MenuBar.h @@ -38,6 +38,9 @@ signals: void StateSaveOldest(); void SetStateSlot(int slot); + // Options + void ConfigureHotkeys(); + // View void ShowTable(); void ShowList(); @@ -66,6 +69,7 @@ private: void AddGameListTypeSection(QMenu* view_menu); void AddTableColumnsMenu(QMenu* view_menu); + void AddOptionsMenu(); void AddToolsMenu(); void AddHelpMenu(); diff --git a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp b/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp new file mode 100644 index 0000000000..c6023f4ff7 --- /dev/null +++ b/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp @@ -0,0 +1,19 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include + +#include "DolphinQt2/QtUtils/FocusEventFilter.h" + +bool FocusEventFilter::eventFilter(QObject* object, QEvent* event) +{ + if (event->type() == QEvent::FocusOut) + emit focusOutEvent(); + + if (event->type() == QEvent::FocusIn) + emit focusInEvent(); + + return false; +} diff --git a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h b/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h new file mode 100644 index 0000000000..0783622b0f --- /dev/null +++ b/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h @@ -0,0 +1,18 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class FocusEventFilter : public QObject +{ + Q_OBJECT +signals: + void focusInEvent(); + void focusOutEvent(); + +private: + bool eventFilter(QObject* object, QEvent* event) override; +}; diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index ffca4d0273..2a536c95e6 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -146,11 +146,12 @@ void CCodeWindow::OnProfilerMenu(wxCommandEvent& event) File::CreateFullPath(filename); Profiler::WriteProfileResults(filename); - wxFileType* filetype = nullptr; - if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("txt"))) + wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("txt"); + if (!filetype) { // From extension failed, trying with MIME type now - if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"))) + filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"); + if (!filetype) // MIME type failed, aborting mission break; } @@ -173,8 +174,9 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!Core::IsRunning()) return; - std::string existing_map_file, writable_map_file, title_id_str; - bool map_exists = CBoot::FindMapFile(&existing_map_file, &writable_map_file, &title_id_str); + const std::string& title_id_str = SConfig::GetInstance().m_debugger_game_id; + std::string existing_map_file, writable_map_file; + bool map_exists = CBoot::FindMapFile(&existing_map_file, &writable_map_file); switch (event.GetId()) { case IDM_CLEAR_SYMBOLS: diff --git a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp index 922fd3c0c7..8c4be0c3f4 100644 --- a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp @@ -32,7 +32,7 @@ static DSPDebuggerLLE* m_DebuggerFrame = nullptr; DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id) : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("DSP LLE Debugger")), - m_CachedStepCounter(-1), m_toolbar_item_size(FromDIP(wxSize(16, 16))) + m_CachedStepCounter(UINT64_MAX), m_toolbar_item_size(FromDIP(wxSize(16, 16))) { Bind(wxEVT_MENU, &DSPDebuggerLLE::OnChangeState, this, ID_RUNTOOL, ID_SHOWPCTOOL); diff --git a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp index 6d6b1450e7..ac870c8804 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp @@ -154,7 +154,7 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& event) bool Log = m_radioLog->GetValue() || m_radioBreakLog->GetValue(); bool Break = m_radioBreak->GetValue() || m_radioBreakLog->GetValue(); - u32 StartAddress, EndAddress; + u32 StartAddress = UINT32_MAX, EndAddress = 0; bool EndAddressOK = EndAddressString.Len() && AsciiToHex(WxStrToStr(EndAddressString), EndAddress); diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index 5846e30916..08d8a1770c 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -40,8 +40,6 @@ $(ExternalsDir)ffmpeg\lib;$(ExternalsDir)OpenAL\lib;%(AdditionalLibraryDirectories) avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;%(AdditionalDependencies) - - /NODEFAULTLIB:libcmt %(AdditionalOptions) $(ExternalsDir)wxWidgets3\include;%(AdditionalIncludeDirectories) diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index a0635321f8..4d5a7282dd 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,8 @@ #include #endif +struct BootParameters; + // Class declarations class CGameListCtrl; class CCodeWindow; @@ -184,7 +187,7 @@ private: void InitializeTASDialogs(); void InitializeCoreCallbacks(); - void StartGame(const std::string& filename, SConfig::EBootBS2 type = SConfig::BOOT_DEFAULT); + void StartGame(std::unique_ptr boot); void SetDebuggerStartupParameters() const; // Utility diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 22f0096cb6..8ac6fd7e08 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -30,6 +30,7 @@ #include "Common/NandPaths.h" #include "Common/StringUtil.h" +#include "Core/Boot/Boot.h" #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -53,6 +54,7 @@ #include "Core/PowerPC/PowerPC.h" #include "Core/State.h" +#include "DiscIO/Enums.h" #include "DiscIO/NANDContentLoader.h" #include "DiscIO/NANDImporter.h" #include "DiscIO/VolumeWad.h" @@ -315,7 +317,7 @@ void CFrame::BootGame(const std::string& filename) } if (!bootfile.empty()) { - StartGame(bootfile); + StartGame(BootParameters::GenerateFromFile(bootfile)); } } @@ -627,7 +629,7 @@ void CFrame::ToggleDisplayMode(bool bFullscreen) } // Prepare the GUI to start the game. -void CFrame::StartGame(const std::string& filename, SConfig::EBootBS2 type) +void CFrame::StartGame(std::unique_ptr boot) { if (m_is_game_loading) return; @@ -705,7 +707,7 @@ void CFrame::StartGame(const std::string& filename, SConfig::EBootBS2 type) SetDebuggerStartupParameters(); - if (!BootManager::BootCore(filename, type)) + if (!BootManager::BootCore(std::move(boot))) { DoFullscreen(false); @@ -1169,17 +1171,17 @@ void CFrame::OnMemcard(wxCommandEvent& WXUNUSED(event)) void CFrame::OnLoadGameCubeIPLJAP(wxCommandEvent&) { - StartGame("", SConfig::BOOT_BS2_JAP); + StartGame(std::make_unique(BootParameters::IPL{DiscIO::Region::NTSC_J})); } void CFrame::OnLoadGameCubeIPLUSA(wxCommandEvent&) { - StartGame("", SConfig::BOOT_BS2_USA); + StartGame(std::make_unique(BootParameters::IPL{DiscIO::Region::NTSC_U})); } void CFrame::OnLoadGameCubeIPLEUR(wxCommandEvent&) { - StartGame("", SConfig::BOOT_BS2_EUR); + StartGame(std::make_unique(BootParameters::IPL{DiscIO::Region::PAL})); } void CFrame::OnExportAllSaves(wxCommandEvent& WXUNUSED(event)) diff --git a/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp b/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp index aee2f5dedf..13f52fecb8 100644 --- a/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp @@ -20,11 +20,15 @@ GuitarInputConfigDialog::GuitarInputConfigDialog(wxWindow* const parent, InputCo Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Buttons), this, this); auto* const group_left_strum = new ControlGroupBox( Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Strum), this, this); + auto* const group_slider_bar = new ControlGroupBox( + Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::SliderBar), this, this); - auto* const buttons_strum_sizer = new wxBoxSizer(wxVERTICAL); - buttons_strum_sizer->Add(group_box_buttons, 0, wxEXPAND); - buttons_strum_sizer->AddSpacer(space5); - buttons_strum_sizer->Add(group_left_strum, 0, wxEXPAND); + auto* const buttons_strum_slider_bar_sizer = new wxBoxSizer(wxVERTICAL); + buttons_strum_slider_bar_sizer->Add(group_box_buttons, 0, wxEXPAND); + buttons_strum_slider_bar_sizer->AddSpacer(space5); + buttons_strum_slider_bar_sizer->Add(group_left_strum, 0, wxEXPAND); + buttons_strum_slider_bar_sizer->AddSpacer(space5); + buttons_strum_slider_bar_sizer->Add(group_slider_bar, 0, wxEXPAND); auto* const group_box_frets = new ControlGroupBox( Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Frets), this, this); @@ -41,7 +45,7 @@ GuitarInputConfigDialog::GuitarInputConfigDialog(wxWindow* const parent, InputCo auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL); controls_sizer->AddSpacer(space5); - controls_sizer->Add(buttons_strum_sizer, 0, wxEXPAND); + controls_sizer->Add(buttons_strum_slider_bar_sizer, 0, wxEXPAND); controls_sizer->AddSpacer(space5); controls_sizer->Add(frets_whammy_sizer, 0, wxEXPAND); controls_sizer->AddSpacer(space5); diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index 65dc4c3603..22490e4ad5 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -1322,11 +1322,11 @@ void VideoConfigDiag::PopulatePostProcessingShaders() void VideoConfigDiag::PopulateAAList() { - const std::vector& aa_modes = vconfig.backend_info.AAModes; + const auto& aa_modes = vconfig.backend_info.AAModes; const bool supports_ssaa = vconfig.backend_info.bSupportsSSAA; m_msaa_modes = 0; - for (int mode : aa_modes) + for (auto mode : aa_modes) { if (mode == 1) { @@ -1342,7 +1342,7 @@ void VideoConfigDiag::PopulateAAList() if (supports_ssaa) { - for (int mode : aa_modes) + for (auto mode : aa_modes) { if (mode != 1) choice_aamode->AppendString(std::to_string(mode) + "x SSAA"); diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index 2cb7819d9d..a422e2635e 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -266,27 +266,26 @@ static bool CheckDeviceAccess(libusb_device* device) } return false; } - else if ((ret = libusb_kernel_driver_active(s_handle, 0)) == 1) + else { - if ((ret = libusb_detach_kernel_driver(s_handle, 0)) && ret != LIBUSB_ERROR_NOT_SUPPORTED) + ret = libusb_kernel_driver_active(s_handle, 0); + if (ret == 1) { - ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); + ret = libusb_detach_kernel_driver(s_handle, 0); + if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) + ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); } } // this split is needed so that we don't avoid claiming the interface when // detaching the kernel driver is successful if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) - { return false; - } - else if ((ret = libusb_claim_interface(s_handle, 0))) - { + + ret = libusb_claim_interface(s_handle, 0); + if (ret) ERROR_LOG(SERIALINTERFACE, "libusb_claim_interface failed with error: %d", ret); - } else - { return true; - } } return false; } diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 8000f15a31..327fece109 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -240,12 +240,12 @@ D3D_FEATURE_LEVEL GetFeatureLevel(IDXGIAdapter* adapter) return feat_level; } -static bool SupportsS3TCTextures(ID3D11Device* device) +static bool SupportsS3TCTextures(ID3D11Device* dev) { UINT bc1_support, bc2_support, bc3_support; - if (FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &bc1_support)) || - FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC2_UNORM, &bc2_support)) || - FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &bc3_support))) + if (FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &bc1_support)) || + FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC2_UNORM, &bc2_support)) || + FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &bc3_support))) { return false; } @@ -320,7 +320,7 @@ HRESULT Create(HWND wnd) return desc.Count == g_Config.iMultisamples; }) == aa_modes.end()) { - Config::SetCurrent(Config::GFX_MSAA, 1); + Config::SetCurrent(Config::GFX_MSAA, UINT32_C(1)); UpdateActiveConfig(); } diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index ebec5e98a9..ec709c152b 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -63,7 +63,7 @@ static std::unique_ptr s_raster_font; // 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA. static int s_MSAASamples = 1; -static int s_last_multisamples = 1; +static u32 s_last_multisamples = 1; static bool s_last_stereo_mode = false; static bool s_last_xfb_mode = false; @@ -519,7 +519,7 @@ Renderer::Renderer() { // GLES 3.1 can't support stereo rendering and MSAA OSD::AddMessage("MSAA Stereo rendering isn't supported by your GPU.", 10000); - Config::SetCurrent(Config::GFX_MSAA, 1); + Config::SetCurrent(Config::GFX_MSAA, UINT32_C(1)); } } else diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 2031d7e220..169dec0bc5 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -370,9 +370,9 @@ TextureCache::TextureCache() { CompileShaders(); - s_ActiveTexture = -1; + s_ActiveTexture = UINT32_MAX; for (auto& gtex : s_Textures) - gtex = -1; + gtex = UINT32_MAX; if (g_ActiveConfig.backend_info.bSupportsPaletteConversion) { @@ -519,8 +519,8 @@ bool TextureCache::CompileShaders() s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat"); s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat"); - s_ColorCbufid = -1; - s_DepthCbufid = -1; + s_ColorCbufid = UINT32_MAX; + s_DepthCbufid = UINT32_MAX; s_ColorCopyPositionUniform = glGetUniformLocation(s_ColorCopyProgram.glprogid, "copy_position"); s_ColorMatrixPositionUniform = diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 94087bdc1f..81bd7671cd 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -1106,7 +1106,7 @@ void Renderer::CheckForSurfaceChange() void Renderer::CheckForConfigChanges() { // Save the video config so we can compare against to determine which settings have changed. - int old_multisamples = g_ActiveConfig.iMultisamples; + u32 old_multisamples = g_ActiveConfig.iMultisamples; int old_anisotropy = g_ActiveConfig.iMaxAnisotropy; int old_stereo_mode = g_ActiveConfig.iStereoMode; int old_aspect_ratio = g_ActiveConfig.iAspectRatio; diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index dc4e806f6a..6a7590f034 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -159,8 +159,9 @@ bool AVIDump::CreateVideoFile() const AVCodec* codec = nullptr; - if (!(codec = avcodec_find_encoder(codec_id)) || - !(s_codec_context = avcodec_alloc_context3(codec))) + codec = avcodec_find_encoder(codec_id); + s_codec_context = avcodec_alloc_context3(codec); + if (!codec || !s_codec_context) { ERROR_LOG(VIDEO, "Could not find encoder or allocate codec context"); return false; @@ -203,8 +204,8 @@ bool AVIDump::CreateVideoFile() return false; #endif - if (!(s_stream = avformat_new_stream(s_format_context, codec)) || - !AVStreamCopyContext(s_stream, s_codec_context)) + s_stream = avformat_new_stream(s_format_context, codec); + if (!s_stream || !AVStreamCopyContext(s_stream, s_codec_context)) { ERROR_LOG(VIDEO, "Could not create stream"); return false; @@ -299,9 +300,10 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const s_src_frame->height = s_height; // Convert image from {BGR24, RGBA} to desired pixel format - if ((s_sws_context = - sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, - s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr))) + s_sws_context = + sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, + s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr); + if (s_sws_context) { sws_scale(s_sws_context, s_src_frame->data, s_src_frame->linesize, 0, height, s_scaled_frame->data, s_scaled_frame->linesize); diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 377d7d5010..cedbea5432 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -353,7 +353,7 @@ void RunGpuLoop() DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false); Common::AtomicStore(fifo.CPReadPointer, readPtr); - Common::AtomicAdd(fifo.CPReadWriteDistance, -32); + Common::AtomicAdd(fifo.CPReadWriteDistance, static_cast(-32)); if ((write_ptr - s_video_buffer_read_ptr) == 0) Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer); diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index 6156ca2cb1..e7930a18c6 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -21,6 +21,11 @@ bool SaveData(const std::string& filename, const std::string& data) return true; } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4611) +#endif + /* TextureToPng @@ -31,20 +36,16 @@ row_stride: Determines the amount of bytes per row of pixels. bool TextureToPng(const u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha) { - bool success = false; - if (!data) return false; + bool success = false; char title[] = "Dolphin Screenshot"; char title_key[] = "Title"; png_structp png_ptr = nullptr; png_infop info_ptr = nullptr; std::vector buffer; - if (!saveAlpha) - buffer.resize(width * 4); - // Open file for writing (binary mode) File::IOFile fp(filename, "wb"); if (!fp.IsOpen()) @@ -70,13 +71,22 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i goto finalise; } - // Setup Exception handling + // Classical libpng error handling uses longjmp to do C-style unwind. + // Modern libpng does support a user callback, but it's required to operate + // in the same way (just gives a chance to do stuff before the longjmp). + // Instead of futzing with it, we use gotos specifically so the compiler + // will still generate proper destructor calls for us (hopefully). + // We also do not use any local variables outside the region longjmp may + // have been called from if they were modified inside that region (they + // would need to be volatile). if (setjmp(png_jmpbuf(png_ptr))) { PanicAlert("Screenshot failed: Error during PNG creation"); goto finalise; } + // Begin region which may call longjmp + png_init_io(png_ptr, fp.GetHandle()); // Write header (8 bit color depth) @@ -91,6 +101,9 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i png_write_info(png_ptr, info_ptr); + if (!saveAlpha) + buffer.resize(width * 4); + // Write image data for (auto y = 0; y < height; ++y) { @@ -114,6 +127,8 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i // End write png_write_end(png_ptr, nullptr); + // End region which may call longjmp + success = true; finalise: @@ -124,3 +139,7 @@ finalise: return success; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 79dbc92597..74f6a8a728 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -16,7 +16,7 @@ u16* IndexGenerator::index_buffer_current; u16* IndexGenerator::BASEIptr; u32 IndexGenerator::base_index; -static const u16 s_primitive_restart = -1; +static const u16 s_primitive_restart = UINT16_MAX; static u16* (*primitive_table[8])(u16*, u32, u32); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 613f2dfed9..72978f6752 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -994,7 +994,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo float* const ColorMask = colmat + 20; ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f; - unsigned int cbufid = -1; + unsigned int cbufid = UINT_MAX; u32 srcFormat = bpmem.zcontrol.pixel_format; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; diff --git a/Source/Core/VideoCommon/VertexLoaderBase.h b/Source/Core/VideoCommon/VertexLoaderBase.h index a895300466..509ccb4310 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.h +++ b/Source/Core/VideoCommon/VertexLoaderBase.h @@ -36,7 +36,7 @@ public: private: size_t CalculateHash() const { - size_t h = -1; + size_t h = SIZE_MAX; for (auto word : vid) { diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 707afae84c..03d102eb62 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -70,7 +70,7 @@ struct VideoConfig final bool bShaderCache; // Enhancements - int iMultisamples; + u32 iMultisamples; bool bSSAA; int iEFBScale; bool bForceFiltering; @@ -167,7 +167,7 @@ struct VideoConfig final APIType api_type; std::vector Adapters; // for D3D - std::vector AAModes; + std::vector AAModes; // TODO: merge AdapterName and Adapters array std::string AdapterName; // for OpenGL diff --git a/Source/UnitTests/UnitTests.vcxproj b/Source/UnitTests/UnitTests.vcxproj index c7f442c1f6..6f527c3bda 100644 --- a/Source/UnitTests/UnitTests.vcxproj +++ b/Source/UnitTests/UnitTests.vcxproj @@ -48,8 +48,6 @@ $(ExternalsDir)OpenAL\lib;$(ExternalsDir)ffmpeg\lib;%(AdditionalLibraryDirectories) avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;%(AdditionalDependencies) Console - - /NODEFAULTLIB:libcmt %(AdditionalOptions) diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 00e4d41af2..300dbda26b 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -76,7 +76,7 @@ higher declaration can be contained to just the XAudio2/XInput related code. --> _WIN32_WINNT=0x0602;%(PreprocessorDefinitions) - Level3 + Level4 true true false @@ -95,13 +95,34 @@ OldStyle Caret 4996;4351 + + 4201;4127;4100;4244;4121;4324;4714;%(DisableSpecificWarnings) + + 4245;%(DisableSpecificWarnings) + + /w44263 /w44265 /w44946 %(AdditionalOptions) @@ -137,6 +158,8 @@ ucrtFreadWorkaround + + /NODEFAULTLIB:libcmt %(AdditionalOptions) true diff --git a/Source/VSProps/QtCompile.props b/Source/VSProps/QtCompile.props index ac6c57a73f..63e414a148 100644 --- a/Source/VSProps/QtCompile.props +++ b/Source/VSProps/QtCompile.props @@ -27,6 +27,11 @@ $(QtIncludeDir)QtCore;%(AdditionalIncludeDirectories) $(QtIncludeDir)QtGui;%(AdditionalIncludeDirectories) $(QtIncludeDir)QtWidgets;%(AdditionalIncludeDirectories) + + %(AdditionalOptions) /wd4946 $(QtLibDir);%(AdditionalLibraryDirectories)