Merge branch 'master' into fix-unittests

This commit is contained in:
shuffle2 2017-06-07 21:20:06 -07:00 committed by GitHub
commit ffd8309aca
192 changed files with 2141 additions and 945 deletions

View File

@ -1,7 +1,6 @@
root = true
[*]
end_of_line = lf
indent_size = 2
trim_trailing_whitespace = true

View File

@ -61,6 +61,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />

View File

@ -45,15 +45,15 @@
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -25,8 +25,7 @@ private:
public:
StreamingVoiceContext(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent);
~StreamingVoiceContext();
virtual ~StreamingVoiceContext();
void Stop();
void Play();

View File

@ -25,8 +25,7 @@ private:
public:
StreamingVoiceContext2_7(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent);
~StreamingVoiceContext2_7();
virtual ~StreamingVoiceContext2_7();
void Stop();
void Play();

View File

@ -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);

View File

@ -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

View File

@ -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()

View File

@ -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;

View File

@ -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;

View File

@ -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<u32>(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;

View File

@ -49,6 +49,11 @@
#include <unistd.h> // 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

View File

@ -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<DWORD>(-1);
info.dwFlags = 0;
__try

View File

@ -10,6 +10,8 @@
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#ifdef _WIN32
#include <windows.h>
@ -469,7 +471,8 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* 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",

View File

@ -21,6 +21,7 @@
#include <algorithm>
#include <atomic>
#include <cstdarg>
#include <iterator>
#include <mutex>
#include <string>

View File

@ -4,13 +4,17 @@
#include "Core/Boot/Boot.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <string>
#include <unordered_set>
#include <vector>
#include <zlib.h>
#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> 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<std::string> 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<BootParameters>(Disc{path, std::move(volume)});
}
if (extension == ".elf")
return std::make_unique<BootParameters>(Executable{path, std::make_unique<ElfReader>(path)});
if (extension == ".dol")
return std::make_unique<BootParameters>(Executable{path, std::make_unique<DolReader>(path)});
if (extension == ".dff")
return std::make_unique<BootParameters>(DFF{path});
if (DiscIO::NANDContentManager::Access().GetNANDLoader(path).IsValid())
return std::make_unique<BootParameters>(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<BootParameters> 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<u8>& bytes) : m_bytes(bytes)
{
}
BootExecutableReader::~BootExecutableReader() = default;

View File

@ -5,15 +5,15 @@
#pragma once
#include <cstdlib>
#include <memory>
#include <optional>
#include <string>
#include <variant>
#include <vector>
#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<DiscIO::Volume> volume;
};
struct Executable
{
std::string path;
std::unique_ptr<BootExecutableReader> 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> disc;
};
struct DFF
{
std::string dff_path;
};
static std::unique_ptr<BootParameters> GenerateFromFile(const std::string& path);
using Parameters = std::variant<Disc, Executable, NAND, IPL, DFF>;
BootParameters(Parameters&& parameters_);
Parameters parameters;
};
class CBoot
{
public:
static bool BootUp();
static bool IsElfWii(const std::string& filename);
static bool BootUp(std::unique_ptr<BootParameters> 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<u8>& 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<u8> m_bytes;
};

View File

@ -1,89 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#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<u8[]>(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<u8[]>(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;
}

View File

@ -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));

View File

@ -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 <cstring>
#include <string>
@ -12,29 +12,19 @@
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
CDolLoader::CDolLoader(const std::vector<u8>& buffer)
DolReader::DolReader(const std::vector<u8>& 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<u8> 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<u8>& buffer)
bool DolReader::Initialize(const std::vector<u8>& buffer)
{
if (buffer.size() < sizeof(SDolHeader))
return false;
@ -97,17 +87,30 @@ bool CDolLoader::Initialize(const std::vector<u8>& 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;
}

View File

@ -8,20 +8,20 @@
#include <vector>
#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<u8>& 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<u8>& 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
{

View File

@ -66,7 +66,19 @@ static void byteswapSection(Elf32_Shdr& sec)
bswap(sec.sh_type);
}
ElfReader::ElfReader(void* ptr)
ElfReader::ElfReader(const std::vector<u8>& 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;
}

View File

@ -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<u8>& 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;
};

View File

@ -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<BootParameters> 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<BootParameters::IPL>(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<BootParameters::Disc>(boot->parameters);
if (load_ipl)
{
PanicAlertT("Couldn't init the core.\nCheck your configuration.");
return false;
return Core::Init(std::make_unique<BootParameters>(BootParameters::IPL{
StartUp.m_region, std::move(std::get<BootParameters::Disc>(boot->parameters))}));
}
return true;
return Core::Init(std::move(boot));
}
void Stop()

View File

@ -4,13 +4,16 @@
#pragma once
#include <memory>
#include <string>
#include "Core/ConfigManager.h"
struct BootParameters;
namespace BootManager
{
bool BootCore(const std::string& filename, SConfig::EBootBS2 type);
bool BootCore(std::unique_ptr<BootParameters> parameters);
// Stop the emulation core and restore the configuration.
void Stop();

View File

@ -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

View File

@ -57,7 +57,7 @@ const ConfigInfo<bool> GFX_ENABLE_GPU_TEXTURE_DECODING{
const ConfigInfo<bool> GFX_ENABLE_PIXEL_LIGHTING{{System::GFX, "Settings", "EnablePixelLighting"},
false};
const ConfigInfo<bool> GFX_FAST_DEPTH_CALC{{System::GFX, "Settings", "FastDepthCalc"}, true};
const ConfigInfo<int> GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1};
const ConfigInfo<u32> GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1};
const ConfigInfo<bool> GFX_SSAA{{System::GFX, "Settings", "SSAA"}, false};
const ConfigInfo<int> GFX_EFB_SCALE{{System::GFX, "Settings", "EFBScale"},
static_cast<int>(SCALE_1X)};

View File

@ -47,7 +47,7 @@ extern const ConfigInfo<bool> GFX_INTERNAL_RESOLUTION_FRAME_DUMPS;
extern const ConfigInfo<bool> GFX_ENABLE_GPU_TEXTURE_DECODING;
extern const ConfigInfo<bool> GFX_ENABLE_PIXEL_LIGHTING;
extern const ConfigInfo<bool> GFX_FAST_DEPTH_CALC;
extern const ConfigInfo<int> GFX_MSAA;
extern const ConfigInfo<u32> GFX_MSAA;
extern const ConfigInfo<bool> GFX_SSAA;
extern const ConfigInfo<int> GFX_EFB_SCALE;
extern const ConfigInfo<bool> GFX_TEXFMT_OVERLAY_ENABLE;

View File

@ -5,6 +5,7 @@
#include <cstring>
#include <list>
#include <map>
#include <memory>
#include <string>
#include "Common/CommonPaths.h"

View File

@ -4,7 +4,9 @@
#include <algorithm>
#include <array>
#include <list>
#include <map>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cstring>
#include <memory>
#include <string>
#include "Common/CommonFuncs.h"

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#include "Common/CommonPaths.h"
#include "Common/Config/Config.h"
#include "Common/FileUtil.h"

View File

@ -6,6 +6,8 @@
#include <climits>
#include <memory>
#include <optional>
#include <sstream>
#include <variant>
#include "AudioCommon/AudioCommon.h"
@ -22,7 +24,6 @@
#include "Core/Analytics.h"
#include "Core/Boot/Boot.h"
#include "Core/Boot/Boot_DOL.h"
#include "Core/Config/Config.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
@ -753,6 +754,20 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, u64 title_id, u
m_title_id = title_id;
m_revision = revision;
if (game_id.length() == 6)
{
m_debugger_game_id = game_id;
}
else if (title_id != 0)
{
m_debugger_game_id =
StringFromFormat("%08X_%08X", static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
}
else
{
m_debugger_game_id.clear();
}
if (!was_changed)
return;
@ -881,165 +896,98 @@ std::string SConfig::GetBootROMPath(const std::string& region_directory) const
return path;
}
// Sets m_region to the region parameter, or to PAL if the region parameter
// is invalid. Set directory_name to the value returned by GetDirectoryForRegion
// for m_region. Returns false if the region parameter is invalid.
bool SConfig::SetRegion(DiscIO::Region region, std::string* directory_name)
struct SetGameMetadata
{
SetGameMetadata(SConfig* config_, DiscIO::Region* region_) : config(config_), region(region_) {}
bool operator()(const BootParameters::Disc& disc) const
{
config->SetRunningGameMetadata(*disc.volume, disc.volume->GetGamePartition());
config->bWii = disc.volume->GetVolumeType() == DiscIO::Platform::WII_DISC;
config->m_disc_booted_from_game_list = true;
*region = disc.volume->GetRegion();
return true;
}
bool operator()(const BootParameters::Executable& executable) const
{
if (!executable.reader->IsValid())
return false;
config->bWii = executable.reader->IsWii();
// TODO: Right now GC homebrew boots in NTSC and Wii homebrew in PAL.
// This is intentional so that Wii homebrew can boot in both 50Hz and 60Hz,
// without forcing all GC homebrew to 50Hz.
// In the future, it probably makes sense to add a Region setting for homebrew somewhere in
// the emulator config.
*region = config->bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U;
// Strip the .elf/.dol file extension and directories before the name
SplitPath(executable.path, nullptr, &config->m_debugger_game_id, nullptr);
return true;
}
bool operator()(const BootParameters::NAND& nand) const
{
const auto& loader = DiscIO::NANDContentManager::Access().GetNANDLoader(nand.content_path);
if (!loader.IsValid())
return false;
const IOS::ES::TMDReader& tmd = loader.GetTMD();
config->SetRunningGameMetadata(tmd);
config->bWii = true;
*region = tmd.GetRegion();
return true;
}
bool operator()(const BootParameters::IPL& ipl) const
{
config->bWii = false;
*region = ipl.region;
return true;
}
bool operator()(const BootParameters::DFF& dff) const
{
std::unique_ptr<FifoDataFile> dff_file(FifoDataFile::Load(dff.dff_path, true));
if (!dff_file)
return false;
config->bWii = dff_file->GetIsWii();
*region = DiscIO::Region::NTSC_U;
return true;
}
private:
SConfig* config;
DiscIO::Region* region;
};
bool SConfig::SetPathsAndGameMetadata(const BootParameters& boot)
{
m_is_mios = false;
m_disc_booted_from_game_list = false;
DiscIO::Region region;
if (!std::visit(SetGameMetadata(this, &region), boot.parameters))
return false;
// Set up region
const char* retrieved_region_dir = GetDirectoryForRegion(region);
m_region = retrieved_region_dir ? region : DiscIO::Region::PAL;
*directory_name = retrieved_region_dir ? retrieved_region_dir : EUR_DIR;
return !!retrieved_region_dir;
}
bool SConfig::AutoSetup(EBootBS2 _BootBS2)
{
std::string set_region_dir(EUR_DIR);
switch (_BootBS2)
const std::string set_region_dir = retrieved_region_dir ? retrieved_region_dir : EUR_DIR;
if (!retrieved_region_dir &&
!PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)."
"\nContinue with PAL region?"))
{
case BOOT_DEFAULT:
{
bool bootDrive = cdio_is_cdrom(m_strFilename);
// Check if the file exist, we may have gotten it from a --elf command line
// that gave an incorrect file name
if (!bootDrive && !File::Exists(m_strFilename))
{
PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str());
return false;
}
std::string Extension;
SplitPath(m_strFilename, nullptr, nullptr, &Extension);
if (!strcasecmp(Extension.c_str(), ".gcm") || !strcasecmp(Extension.c_str(), ".iso") ||
!strcasecmp(Extension.c_str(), ".tgc") || !strcasecmp(Extension.c_str(), ".wbfs") ||
!strcasecmp(Extension.c_str(), ".ciso") || !strcasecmp(Extension.c_str(), ".gcz") ||
bootDrive)
{
m_BootType = BOOT_ISO;
std::unique_ptr<DiscIO::Volume> pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename));
if (pVolume == nullptr)
{
if (bootDrive)
PanicAlertT("Could not read \"%s\". "
"There is no disc in the drive or it is not a GameCube/Wii backup. "
"Please note that Dolphin cannot play games directly from the original "
"GameCube and Wii discs.",
m_strFilename.c_str());
else
PanicAlertT("\"%s\" is an invalid GCM/ISO file, or is not a GC/Wii ISO.",
m_strFilename.c_str());
return false;
}
SetRunningGameMetadata(*pVolume, pVolume->GetGamePartition());
// Check if we have a Wii disc
bWii = pVolume->GetVolumeType() == DiscIO::Platform::WII_DISC;
if (!SetRegion(pVolume->GetRegion(), &set_region_dir))
if (!PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)."
"\nContinue with PAL region?"))
return false;
}
else if (!strcasecmp(Extension.c_str(), ".elf"))
{
bWii = CBoot::IsElfWii(m_strFilename);
// TODO: Right now GC homebrew boots in NTSC and Wii homebrew in PAL.
// This is intentional so that Wii homebrew can boot in both 50Hz and 60Hz, without forcing
// all GC homebrew to 50Hz.
// In the future, it probably makes sense to add a Region setting for homebrew somewhere in
// the emulator config.
SetRegion(bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U, &set_region_dir);
m_BootType = BOOT_ELF;
}
else if (!strcasecmp(Extension.c_str(), ".dol"))
{
CDolLoader dolfile(m_strFilename);
bWii = dolfile.IsWii();
// TODO: See the ELF code above.
SetRegion(bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U, &set_region_dir);
m_BootType = BOOT_DOL;
}
else if (!strcasecmp(Extension.c_str(), ".dff"))
{
bWii = true;
SetRegion(DiscIO::Region::NTSC_U, &set_region_dir);
m_BootType = BOOT_DFF;
std::unique_ptr<FifoDataFile> ddfFile(FifoDataFile::Load(m_strFilename, true));
if (ddfFile)
{
bWii = ddfFile->GetIsWii();
}
}
else if (DiscIO::NANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
{
const DiscIO::NANDContentLoader& content_loader =
DiscIO::NANDContentManager::Access().GetNANDLoader(m_strFilename);
const IOS::ES::TMDReader& tmd = content_loader.GetTMD();
if (!IOS::ES::IsChannel(tmd.GetTitleId()))
{
PanicAlertT("This WAD is not bootable.");
return false;
}
SetRegion(tmd.GetRegion(), &set_region_dir);
SetRunningGameMetadata(tmd);
bWii = true;
m_BootType = BOOT_WII_NAND;
}
else
{
PanicAlertT("Could not recognize ISO file %s", m_strFilename.c_str());
return false;
}
}
break;
case BOOT_BS2_USA:
SetRegion(DiscIO::Region::NTSC_U, &set_region_dir);
m_strFilename.clear();
m_BootType = SConfig::BOOT_BS2;
break;
case BOOT_BS2_JAP:
SetRegion(DiscIO::Region::NTSC_J, &set_region_dir);
m_strFilename.clear();
m_BootType = SConfig::BOOT_BS2;
break;
case BOOT_BS2_EUR:
SetRegion(DiscIO::Region::PAL, &set_region_dir);
m_strFilename.clear();
m_BootType = SConfig::BOOT_BS2;
break;
return false;
}
// Setup paths
// Set up paths
CheckMemcardPath(SConfig::GetInstance().m_strMemoryCardA, set_region_dir, true);
CheckMemcardPath(SConfig::GetInstance().m_strMemoryCardB, set_region_dir, false);
m_strSRAM = File::GetUserPath(F_GCSRAM_IDX);
if (!bWii)
{
if (!bHLE_BS2)
{
m_strBootROM = GetBootROMPath(set_region_dir);
if (!File::Exists(m_strBootROM))
{
WARN_LOG(BOOT, "Bootrom file %s not found - using HLE.", m_strBootROM.c_str());
bHLE_BS2 = true;
}
}
}
else if (bWii && !bHLE_BS2)
{
WARN_LOG(BOOT, "GC bootrom file will not be loaded for Wii mode.");
bHLE_BS2 = true;
}
m_strBootROM = GetBootROMPath(set_region_dir);
return true;
}

View File

@ -51,6 +51,8 @@ enum GPUDeterminismMode
GPU_DETERMINISM_FAKE_COMPLETION,
};
struct BootParameters;
struct SConfig : NonCopyable
{
// Wii Devices
@ -129,6 +131,7 @@ struct SConfig : NonCopyable
bool bOverrideGCLanguage = false;
bool bWii = false;
bool m_is_mios = false;
// Interface settings
bool bConfirmStop = false;
@ -181,26 +184,6 @@ struct SConfig : NonCopyable
bool bEnableCustomRTC;
u32 m_customRTCValue;
enum EBootBS2
{
BOOT_DEFAULT,
BOOT_BS2_JAP,
BOOT_BS2_USA,
BOOT_BS2_EUR,
};
enum EBootType
{
BOOT_ISO,
BOOT_ELF,
BOOT_DOL,
BOOT_WII_NAND,
BOOT_MIOS,
BOOT_BS2,
BOOT_DFF
};
EBootType m_BootType;
DiscIO::Region m_region;
std::string m_strVideoBackend;
@ -210,7 +193,6 @@ struct SConfig : NonCopyable
GPUDeterminismMode m_GPUDeterminismMode;
// files
std::string m_strFilename;
std::string m_strBootROM;
std::string m_strSRAM;
std::string m_strDefaultISO;
@ -220,6 +202,10 @@ struct SConfig : NonCopyable
std::string m_perfDir;
std::string m_debugger_game_id;
// TODO: remove this as soon as the ticket view hack in IOS/ES/Views is dropped.
bool m_disc_booted_from_game_list = false;
const std::string& GetGameID() const { return m_game_id; }
const std::string& GetTitleDescription() const { return m_title_description; }
u64 GetTitleID() const { return m_title_id; }
@ -231,7 +217,7 @@ struct SConfig : NonCopyable
void LoadDefaults();
static const char* GetDirectoryForRegion(DiscIO::Region region);
std::string GetBootROMPath(const std::string& region_directory) const;
bool AutoSetup(EBootBS2 _BootBS2);
bool SetPathsAndGameMetadata(const BootParameters& boot);
void CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA);
DiscIO::Language GetCurrentLanguage(bool wii) const;
@ -389,7 +375,6 @@ private:
void SetRunningGameMetadata(const std::string& game_id, u64 title_id, u16 revision,
Core::TitleDatabase::TitleType type);
bool SetRegion(DiscIO::Region region, std::string* directory_name);
static SConfig* m_Instance;

View File

@ -10,6 +10,7 @@
#include <mutex>
#include <queue>
#include <utility>
#include <variant>
#ifdef _WIN32
#include <windows.h>
@ -122,7 +123,7 @@ static void InitIsCPUKey()
}
#endif
static void EmuThread();
static void EmuThread(std::unique_ptr<BootParameters> boot);
bool GetIsThrottlerTempDisabled()
{
@ -221,7 +222,7 @@ bool WantsDeterminism()
// This is called from the GUI thread. See the booting call schedule in
// BootManager.cpp
bool Init()
bool Init(std::unique_ptr<BootParameters> boot)
{
if (s_emu_thread.joinable())
{
@ -248,7 +249,7 @@ bool Init()
s_window_handle = Host_GetRenderHandle();
// Start the emu thread
s_emu_thread = std::thread(EmuThread);
s_emu_thread = std::thread(EmuThread, std::move(boot));
return true;
}
@ -412,21 +413,18 @@ static void FifoPlayerThread()
}
// Enter CPU run loop. When we leave it - we are done.
if (FifoPlayer::GetInstance().Open(_CoreParameter.m_strFilename))
if (auto cpu_core = FifoPlayer::GetInstance().GetCPUCore())
{
if (auto cpu_core = FifoPlayer::GetInstance().GetCPUCore())
{
PowerPC::InjectExternalCPUCore(cpu_core.get());
s_is_started = true;
PowerPC::InjectExternalCPUCore(cpu_core.get());
s_is_started = true;
CPUSetInitialExecutionState();
CPU::Run();
CPUSetInitialExecutionState();
CPU::Run();
s_is_started = false;
PowerPC::InjectExternalCPUCore(nullptr);
}
FifoPlayer::GetInstance().Close();
s_is_started = false;
PowerPC::InjectExternalCPUCore(nullptr);
}
FifoPlayer::GetInstance().Close();
// If we did not enter the CPU Run Loop above then run a fake one instead.
// We need to be IsRunningAndStarted() for DolphinWX to stop us.
@ -450,7 +448,7 @@ static void FifoPlayerThread()
// Initialize and create emulation thread
// Call browser: Init():s_emu_thread().
// See the BootManager.cpp file description for a complete call schedule.
static void EmuThread()
static void EmuThread(std::unique_ptr<BootParameters> boot)
{
const SConfig& core_parameter = SConfig::GetInstance();
s_is_booting.Set();
@ -470,16 +468,10 @@ static void EmuThread()
Common::SetCurrentThreadName("Emuthread - Starting");
if (SConfig::GetInstance().m_OCEnable)
DisplayMessage("WARNING: running at non-native CPU clock! Game may not be stable.", 8000);
DisplayMessage(cpu_info.brand_string, 8000);
DisplayMessage(cpu_info.Summarize(), 8000);
DisplayMessage(core_parameter.m_strFilename, 3000);
// For a time this acts as the CPU thread...
DeclareAsCPUThread();
Movie::Init();
Movie::Init(*boot);
Common::ScopeGuard movie_guard{Movie::Shutdown};
HW::Init();
@ -560,7 +552,15 @@ static void EmuThread()
// Load GCM/DOL/ELF whatever ... we boot with the interpreter core
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
CBoot::BootUp();
// Determine the CPU thread function
void (*cpuThreadFunc)();
if (std::holds_alternative<BootParameters::DFF>(boot->parameters))
cpuThreadFunc = FifoPlayerThread;
else
cpuThreadFunc = CpuThread;
if (!CBoot::BootUp(std::move(boot)))
return;
// This adds the SyncGPU handler to CoreTiming, so now CoreTiming::Advance might block.
Fifo::Prepare();
@ -583,13 +583,6 @@ static void EmuThread()
Host_UpdateDisasmDialog();
Host_UpdateMainFrame();
// Determine the CPU thread function
void (*cpuThreadFunc)(void);
if (core_parameter.m_BootType == SConfig::BOOT_DFF)
cpuThreadFunc = FifoPlayerThread;
else
cpuThreadFunc = CpuThread;
// ENTER THE VIDEO THREAD LOOP
if (core_parameter.bCPUThread)
{

View File

@ -11,11 +11,14 @@
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
struct BootParameters;
namespace Core
{
bool GetIsThrottlerTempDisabled();
@ -31,7 +34,7 @@ enum class State
Stopping
};
bool Init();
bool Init(std::unique_ptr<BootParameters> boot);
void Stop();
void Shutdown();

View File

@ -35,16 +35,6 @@
<Import Project="..\..\VSProps\PCHUse.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ActionReplay.cpp" />
<ClCompile Include="Analytics.cpp" />
@ -52,9 +42,8 @@
<ClCompile Include="BootManager.cpp" />
<ClCompile Include="Boot\Boot.cpp" />
<ClCompile Include="Boot\Boot_BS2Emu.cpp" />
<ClCompile Include="Boot\Boot_DOL.cpp" />
<ClCompile Include="Boot\Boot_ELF.cpp" />
<ClCompile Include="Boot\Boot_WiiWAD.cpp" />
<ClCompile Include="Boot\DolReader.cpp" />
<ClCompile Include="Boot\ElfReader.cpp" />
<ClCompile Include="Config\Config.cpp" />
<ClCompile Include="Config\GraphicsSettings.cpp" />
@ -215,7 +204,7 @@
<ClCompile Include="IOS\Network\KD\NetKDRequest.cpp" />
<ClCompile Include="IOS\Network\KD\NetKDTime.cpp" />
<ClCompile Include="IOS\Network\KD\NWC24Config.cpp" />
<ClCompile Include="IOS\Network\NCD\Config.cpp" />
<ClCompile Include="IOS\Network\NCD\WiiNetConfig.cpp" />
<ClCompile Include="IOS\Network\NCD\Manage.cpp" />
<ClCompile Include="IOS\Network\WD\Command.cpp" />
<ClCompile Include="IOS\SDIO\SDIOSlot0.cpp" />
@ -308,7 +297,7 @@
<ClInclude Include="ARDecrypt.h" />
<ClInclude Include="BootManager.h" />
<ClInclude Include="Boot\Boot.h" />
<ClInclude Include="Boot\Boot_DOL.h" />
<ClInclude Include="Boot\DolReader.h" />
<ClInclude Include="Boot\ElfReader.h" />
<ClInclude Include="Boot\ElfTypes.h" />
<ClInclude Include="Config\Config.h" />
@ -461,7 +450,7 @@
<ClInclude Include="IOS\Network\KD\NetKDRequest.h" />
<ClInclude Include="IOS\Network\KD\NetKDTime.h" />
<ClInclude Include="IOS\Network\KD\NWC24Config.h" />
<ClInclude Include="IOS\Network\NCD\Config.h" />
<ClInclude Include="IOS\Network\NCD\WiiNetConfig.h" />
<ClInclude Include="IOS\Network\NCD\Manage.h" />
<ClInclude Include="IOS\Network\WD\Command.h" />
<ClInclude Include="IOS\SDIO\SDIOSlot0.h" />

View File

@ -154,6 +154,12 @@
<Filter Include="IOS\WFS">
<UniqueIdentifier>{1fa9df3e-6741-4045-b2f6-457b4a0540a9}</UniqueIdentifier>
</Filter>
<Filter Include="Config">
<UniqueIdentifier>{a3d4778e-1891-458e-9bd1-009c2f5e8ed9}</UniqueIdentifier>
</Filter>
<Filter Include="PowerPC\SignatureDB">
<UniqueIdentifier>{f0b52c84-49f4-470a-b037-edeea5634b9e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BootManager.cpp" />
@ -182,15 +188,12 @@
<ClCompile Include="Boot\Boot_BS2Emu.cpp">
<Filter>Boot</Filter>
</ClCompile>
<ClCompile Include="Boot\Boot_DOL.cpp">
<Filter>Boot</Filter>
</ClCompile>
<ClCompile Include="Boot\Boot_ELF.cpp">
<Filter>Boot</Filter>
</ClCompile>
<ClCompile Include="Boot\Boot_WiiWAD.cpp">
<Filter>Boot</Filter>
</ClCompile>
<ClCompile Include="Boot\DolReader.cpp">
<Filter>Boot</Filter>
</ClCompile>
<ClCompile Include="Boot\ElfReader.cpp">
<Filter>Boot</Filter>
</ClCompile>
@ -293,7 +296,7 @@
<ClCompile Include="HLE\HLE_OS.cpp">
<Filter>HLE</Filter>
</ClCompile>
<ClCompile Include="HLE\HLE_VarArgs.cpp" />
<ClCompile Include="HLE\HLE_VarArgs.cpp">
<Filter>HLE</Filter>
</ClCompile>
<ClCompile Include="PowerPC\BreakPoints.cpp">
@ -690,10 +693,18 @@
<Filter>PowerPC\Jit64Common</Filter>
</ClCompile>
<ClCompile Include="Analytics.cpp" />
<ClCompile Include="PowerPC\SignatureDB\CSVSignatureDB.cpp" />
<ClCompile Include="PowerPC\SignatureDB\DSYSignatureDB.cpp" />
<ClCompile Include="PowerPC\SignatureDB\MEGASignatureDB.cpp" />
<ClCompile Include="PowerPC\SignatureDB\SignatureDB.cpp" />
<ClCompile Include="PowerPC\SignatureDB\CSVSignatureDB.cpp">
<Filter>PowerPC\SignatureDB</Filter>
</ClCompile>
<ClCompile Include="PowerPC\SignatureDB\DSYSignatureDB.cpp">
<Filter>PowerPC\SignatureDB</Filter>
</ClCompile>
<ClCompile Include="PowerPC\SignatureDB\MEGASignatureDB.cpp">
<Filter>PowerPC\SignatureDB</Filter>
</ClCompile>
<ClCompile Include="PowerPC\SignatureDB\SignatureDB.cpp">
<Filter>PowerPC\SignatureDB</Filter>
</ClCompile>
<ClCompile Include="IOS\USB\Bluetooth\BTBase.cpp">
<Filter>IOS\USB\Bluetooth</Filter>
</ClCompile>
@ -781,9 +792,6 @@
<ClCompile Include="IOS\Network\KD\NWC24Config.cpp">
<Filter>IOS\Network\KD</Filter>
</ClCompile>
<ClCompile Include="IOS\Network\NCD\Config.cpp">
<Filter>IOS\Network\NCD</Filter>
</ClCompile>
<ClCompile Include="IOS\Network\NCD\Manage.cpp">
<Filter>IOS\Network\NCD</Filter>
</ClCompile>
@ -859,8 +867,15 @@
<ClCompile Include="ConfigLoaders\IsSettingSaveable.cpp">
<Filter>ConfigLoader</Filter>
</ClCompile>
<ClCompile Include="Config\Config.cpp" />
<ClCompile Include="Config\GraphicsSettings.cpp" />
<ClCompile Include="Config\Config.cpp">
<Filter>Config</Filter>
</ClCompile>
<ClCompile Include="Config\GraphicsSettings.cpp">
<Filter>Config</Filter>
</ClCompile>
<ClCompile Include="IOS\Network\NCD\WiiNetConfig.cpp">
<Filter>IOS\Network\NCD</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BootManager.h" />
@ -888,7 +903,7 @@
<ClInclude Include="Boot\Boot.h">
<Filter>Boot</Filter>
</ClInclude>
<ClInclude Include="Boot\Boot_DOL.h">
<ClInclude Include="Boot\DolReader.h">
<Filter>Boot</Filter>
</ClInclude>
<ClInclude Include="Boot\ElfReader.h">
@ -1337,10 +1352,18 @@
<Filter>PowerPC\Jit64Common</Filter>
</ClInclude>
<ClInclude Include="Analytics.h" />
<ClInclude Include="PowerPC\SignatureDB\CSVSignatureDB.h" />
<ClInclude Include="PowerPC\SignatureDB\DSYSignatureDB.h" />
<ClInclude Include="PowerPC\SignatureDB\MEGASignatureDB.h" />
<ClInclude Include="PowerPC\SignatureDB\SignatureDB.h" />
<ClInclude Include="PowerPC\SignatureDB\CSVSignatureDB.h">
<Filter>PowerPC\SignatureDB</Filter>
</ClInclude>
<ClInclude Include="PowerPC\SignatureDB\DSYSignatureDB.h">
<Filter>PowerPC\SignatureDB</Filter>
</ClInclude>
<ClInclude Include="PowerPC\SignatureDB\MEGASignatureDB.h">
<Filter>PowerPC\SignatureDB</Filter>
</ClInclude>
<ClInclude Include="PowerPC\SignatureDB\SignatureDB.h">
<Filter>PowerPC\SignatureDB</Filter>
</ClInclude>
<ClInclude Include="IOS\USB\Bluetooth\BTBase.h">
<Filter>IOS\USB\Bluetooth</Filter>
</ClInclude>
@ -1407,9 +1430,6 @@
<ClInclude Include="IOS\Network\KD\NWC24Config.h">
<Filter>IOS\Network\KD</Filter>
</ClInclude>
<ClInclude Include="IOS\Network\NCD\Config.h">
<Filter>IOS\Network\NCD</Filter>
</ClInclude>
<ClInclude Include="IOS\Network\NCD\Manage.h">
<Filter>IOS\Network\NCD</Filter>
</ClInclude>
@ -1497,13 +1517,20 @@
<ClInclude Include="ConfigLoaders\NetPlayConfigLoader.h">
<Filter>ConfigLoader</Filter>
</ClInclude>
<ClInclude Include="Config\Config.h" />
<ClInclude Include="Config\GraphicsSettings.h" />
<ClInclude Include="ConfigLoaders\IsSettingSaveable.h">
<Filter>ConfigLoader</Filter>
</ClInclude>
<ClInclude Include="Config\Config.h">
<Filter>Config</Filter>
</ClInclude>
<ClInclude Include="Config\GraphicsSettings.h">
<Filter>Config</Filter>
</ClInclude>
<ClInclude Include="IOS\Network\NCD\WiiNetConfig.h">
<Filter>IOS\Network\NCD</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>

View File

@ -5,15 +5,17 @@
#include "Core/DSP/DSPAssembler.h"
#include <algorithm>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"

View File

@ -4,6 +4,7 @@
#include <cstring>
#include <memory>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"

View File

@ -9,6 +9,7 @@
#include <cstdlib>
#include <fstream>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"

View File

@ -5,6 +5,7 @@
#include "Core/DSP/DSPHWInterface.h"
#include <atomic>
#include <cstddef>
#include <cstring>

View File

@ -3,6 +3,10 @@
// Refer to the license.txt file included.
#include "Core/DSP/LabelMap.h"
#include <string>
#include <vector>
#include "Core/DSP/DSPTables.h"
namespace DSP

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstdio>
#include <functional>
#include <string>

View File

@ -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);
}

View File

@ -4,7 +4,11 @@
#include "Core/Debugger/RSO.h"
#include <cstddef>
#include <list>
#include <string>
#include <utility>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"

View File

@ -4,7 +4,9 @@
#include <algorithm>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include "Common/FileUtil.h"

View File

@ -4,6 +4,8 @@
#include "Core/FifoPlayer/FifoPlaybackAnalyzer.h"
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/FifoPlayer/FifoAnalyzer.h"
#include "Core/FifoPlayer/FifoDataFile.h"

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <cstring>
#include <mutex>
#include "Core/FifoPlayer/FifoRecorder.h"

View File

@ -5,6 +5,7 @@
#include "Core/GeckoCodeConfig.h"
#include <algorithm>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

View File

@ -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);

View File

@ -3,6 +3,9 @@
// Refer to the license.txt file included.
#include "Core/HW/DSPHLE/MailHandler.h"
#include <queue>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"

View File

@ -5,6 +5,7 @@
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
#include <cstring>
#include <memory>
#include <string>
#ifdef _WIN32

View File

@ -63,7 +63,7 @@ protected:
CMailHandler& m_mail_handler;
enum EDSP_Codes
enum EDSP_Codes : u32
{
DSP_INIT = 0xDCD10000,
DSP_RESUME = 0xDCD10001,

View File

@ -5,6 +5,7 @@
#include "Core/HW/DSPHLE/UCodes/Zelda.h"
#include <array>
#include <map>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

View File

@ -3,6 +3,9 @@
// Refer to the license.txt file included.
#include "Core/DSP/DSPHost.h"
#include <string>
#include "Common/CommonTypes.h"
#include "Common/Hash.h"
#include "Common/Logging/Log.h"

View File

@ -7,6 +7,7 @@
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "AudioCommon/AudioCommon.h"
@ -348,8 +349,8 @@ static void DTKStreamingCallback(const std::vector<u8>& 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)
{

View File

@ -157,7 +157,7 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string<TCHAR>& 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;

View File

@ -4,8 +4,10 @@
#include "Core/HW/EXI/EXI_DeviceAGP.h"
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

View File

@ -4,6 +4,8 @@
#include "Core/HW/EXI/EXI_DeviceDummy.h"
#include <string>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"

View File

@ -4,6 +4,7 @@
#include "Core/HW/EXI/EXI_DeviceEthernet.h"
#include <memory>
#include <string>
#include "Common/ChunkFile.h"

View File

@ -5,6 +5,7 @@
#include "Core/HW/EXI/EXI_DeviceIPL.h"
#include <cstring>
#include <string>
#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<u8*>(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));
}

View File

@ -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);
};

View File

@ -6,6 +6,7 @@
#include <array>
#include <cstring>
#include <functional>
#include <memory>
#include <string>

View File

@ -2,9 +2,12 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <cstring>
#include <mutex>
#include <cubeb/cubeb.h>
#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 <cubeb/cubeb.h>
namespace ExpansionInterface
{
void CEXIMic::StreamInit()

View File

@ -4,12 +4,14 @@
#include "Core/HW/GCMemcard/GCMemcardDirectory.h"
#include <algorithm>
#include <chrono>
#include <cinttypes>
#include <cstring>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"

View File

@ -7,7 +7,9 @@
#include <chrono>
#include <cstring>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

View File

@ -4,6 +4,7 @@
#include "Core/HW/GPFifo.h"
#include <cstddef>
#include <cstring>
#include "Common/ChunkFile.h"

View File

@ -20,14 +20,14 @@ template <typename T>
class ReadHandlingMethod
{
public:
virtual ~ReadHandlingMethod() {}
virtual ~ReadHandlingMethod() = default;
virtual void AcceptReadVisitor(ReadHandlingMethodVisitor<T>& v) const = 0;
};
template <typename T>
class WriteHandlingMethod
{
public:
virtual ~WriteHandlingMethod() {}
virtual ~WriteHandlingMethod() = default;
virtual void AcceptWriteVisitor(WriteHandlingMethodVisitor<T>& v) const = 0;
};
@ -39,7 +39,7 @@ class ConstantHandlingMethod : public ReadHandlingMethod<T>
{
public:
explicit ConstantHandlingMethod(T value) : value_(value) {}
virtual ~ConstantHandlingMethod() {}
virtual ~ConstantHandlingMethod() = default;
void AcceptReadVisitor(ReadHandlingMethodVisitor<T>& v) const override
{
v.VisitConstant(value_);
@ -62,7 +62,7 @@ class NopHandlingMethod : public WriteHandlingMethod<T>
{
public:
NopHandlingMethod() {}
virtual ~NopHandlingMethod() {}
virtual ~NopHandlingMethod() = default;
void AcceptWriteVisitor(WriteHandlingMethodVisitor<T>& v) const override { v.VisitNop(); }
};
template <typename T>
@ -79,7 +79,7 @@ class DirectHandlingMethod : public ReadHandlingMethod<T>, public WriteHandlingM
{
public:
DirectHandlingMethod(T* addr, u32 mask) : addr_(addr), mask_(mask) {}
virtual ~DirectHandlingMethod() {}
virtual ~DirectHandlingMethod() = default;
void AcceptReadVisitor(ReadHandlingMethodVisitor<T>& v) const override
{
v.VisitDirect(addr_, mask_);
@ -132,7 +132,7 @@ public:
{
}
virtual ~ComplexHandlingMethod() {}
virtual ~ComplexHandlingMethod() = default;
void AcceptReadVisitor(ReadHandlingMethodVisitor<T>& v) const override
{
v.VisitComplex(&read_lambda_);
@ -304,6 +304,8 @@ void ReadHandler<T>::ResetMethod(ReadHandlingMethod<T>* method)
struct FuncCreatorVisitor : public ReadHandlingMethodVisitor<T>
{
virtual ~FuncCreatorVisitor() = default;
std::function<T(u32)> ret;
void VisitConstant(T value) override
@ -356,6 +358,8 @@ void WriteHandler<T>::ResetMethod(WriteHandlingMethod<T>* method)
struct FuncCreatorVisitor : public WriteHandlingMethodVisitor<T>
{
virtual ~FuncCreatorVisitor() = default;
std::function<void(u32, T)> ret;
void VisitNop() override

View File

@ -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 <algorithm>
#include <cstring>
#include <memory>
@ -98,7 +99,7 @@ struct PhysicalMemoryRegion
u8** out_pointer;
u32 physical_address;
u32 size;
enum
enum : u32
{
ALWAYS = 0,
FAKE_VMEM = 1,

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cstdio>
#include <memory>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

View File

@ -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());

View File

@ -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;

View File

@ -7,6 +7,8 @@
#include <array>
#include <cassert>
#include <map>
#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<const ControlState, const u8> 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<u8, 6> guitar_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x03}};
constexpr std::array<u16, 5> 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<u8>((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;

View File

@ -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;
};
}

View File

@ -16,6 +16,7 @@
0x30 - 0x3f Input This file: Update() */
#include <fstream>
#include <mutex>
#include <queue>
#include <string>
#include <vector>

View File

@ -4,9 +4,11 @@
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <mutex>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

View File

@ -91,7 +91,8 @@ enum class GuitarGroup
Frets,
Strum,
Whammy,
Stick
Stick,
SliderBar
};
enum class DrumsGroup

View File

@ -6,6 +6,7 @@
#include <algorithm>
#include <cstdlib>
#include <mutex>
#include <queue>
#include <unordered_set>

View File

@ -4,6 +4,8 @@
#include "Core/HotkeyManager.h"
#include <algorithm>
#include <array>
#include <string>
#include <vector>

View File

@ -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; });

View File

@ -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);

View File

@ -5,10 +5,12 @@
#include "Core/IOS/ES/Formats.h"
#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstddef>
#include <cstring>
#include <locale>
#include <optional>
#include <string>
#include <utility>
#include <vector>

View File

@ -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)

View File

@ -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<CDolLoader>(content->m_Data->Get());
const auto dol_loader = std::make_unique<DolReader>(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

View File

@ -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 <typename T>
void WriteReturnValue(T value, u32 address)
{
Memory::Write_U32(static_cast<u32>(value), address);
}
// HLE for the IOS kernel: IPC, device management, syscalls, and Dolphin-specific, IOS-wide calls.
class Kernel
{

View File

@ -3,7 +3,10 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstring>
#include <vector>
#include <mbedtls/sha1.h>

View File

@ -134,8 +134,7 @@ bool Load()
return false;
}
std::vector<u8> 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;
}

View File

@ -3,6 +3,9 @@
// Refer to the license.txt file included.
#include "Core/IOS/MemoryValues.h"
#include <array>
#include "Common/CommonTypes.h"
namespace IOS

View File

@ -76,6 +76,11 @@ NetIPTop::~NetIPTop()
#endif
}
static constexpr u32 inet_addr(u8 a, u8 b, u8 c, u8 d)
{
return (static_cast<u32>(a) << 24) | (static_cast<u32>(b) << 16) | (static_cast<u32>(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<MIB_IPFORWARDTABLE> forwardTable;
std::unique_ptr<MIB_IPADDRTABLE> 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

View File

@ -13,7 +13,7 @@ namespace HLE
{
namespace NWC24
{
enum ErrorCode : int
enum ErrorCode : s32
{
WC24_OK = 0,
WC24_ERR_FATAL = -1,

View File

@ -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);

View File

@ -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
{

View File

@ -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 <cstring>

View File

@ -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;
}

View File

@ -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,

Some files were not shown because too many files have changed in this diff Show More