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
-
-
- $(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