2013-04-17 22:43:11 -04:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
// File description
|
|
|
|
// -------------
|
|
|
|
// Purpose of this file: Collect boot settings for Core::Init()
|
|
|
|
|
|
|
|
// Call sequence: This file has one of the first function called when a game is booted,
|
|
|
|
// the boot sequence in the code is:
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2011-03-03 04:35:03 +00:00
|
|
|
// DolphinWX: FrameTools.cpp StartGame
|
|
|
|
// Core BootManager.cpp BootCore
|
|
|
|
// Core.cpp Init Thread creation
|
2011-02-12 22:31:57 +00:00
|
|
|
// EmuThread Calls CBoot::BootUp
|
|
|
|
// Boot.cpp CBoot::BootUp()
|
|
|
|
// CBoot::EmulatedBS2_Wii() / GC() or Load_BS2()
|
|
|
|
|
|
|
|
|
|
|
|
// Includes
|
|
|
|
// ----------------
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2013-10-19 18:58:02 -04:00
|
|
|
#include "CommonTypes.h"
|
2013-09-07 23:02:49 +02:00
|
|
|
#include "CommonPaths.h"
|
2011-02-12 22:31:57 +00:00
|
|
|
#include "IniFile.h"
|
|
|
|
#include "BootManager.h"
|
|
|
|
#include "Volume.h"
|
|
|
|
#include "VolumeCreator.h"
|
|
|
|
#include "ConfigManager.h"
|
|
|
|
#include "SysConf.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Host.h"
|
2012-09-23 17:54:23 -05:00
|
|
|
#include "VideoBackendBase.h"
|
2012-10-18 04:18:40 -04:00
|
|
|
#include "Movie.h"
|
2013-09-07 00:27:35 -04:00
|
|
|
#include "NetPlayProto.h"
|
2014-01-01 06:59:01 -05:00
|
|
|
#include "HW/WiimoteReal/WiimoteReal.h"
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
namespace BootManager
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO this is an ugly hack which allows us to restore values trampled by per-game settings
|
|
|
|
// Apply fire liberally
|
|
|
|
struct ConfigCache
|
|
|
|
{
|
2013-07-31 21:35:22 -04:00
|
|
|
bool valid, bCPUThread, bSkipIdle, bEnableFPRF, bMMU, bDCBZOFF, m_EnableJIT, bDSPThread,
|
2013-10-23 13:45:03 -04:00
|
|
|
bVBeamSpeedHack, bSyncGPU, bFastDiscSpeed, bMergeBlocks, bDSPHLE, bHLE_BS2, bTLBHack, bUseFPS;
|
2013-09-28 08:31:28 -04:00
|
|
|
int iCPUCore, Volume;
|
2014-01-01 06:59:01 -05:00
|
|
|
int iWiimoteSource[5];
|
|
|
|
int iSetWiimoteSource[5];
|
2013-10-23 13:45:03 -04:00
|
|
|
unsigned int framelimit;
|
2013-09-04 19:16:28 -05:00
|
|
|
TEXIDevices m_EXIDevice[2];
|
2013-09-28 08:31:28 -04:00
|
|
|
std::string strBackend, sBackend;
|
2011-02-12 22:31:57 +00:00
|
|
|
};
|
|
|
|
static ConfigCache config_cache;
|
|
|
|
|
|
|
|
// Boot the ISO or file
|
|
|
|
bool BootCore(const std::string& _rFilename)
|
|
|
|
{
|
|
|
|
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
|
|
|
|
|
|
|
// Use custom settings for debugging mode
|
|
|
|
Host_SetStartupDebuggingParameters();
|
|
|
|
|
|
|
|
StartUp.m_BootType = SCoreStartupParameter::BOOT_ISO;
|
|
|
|
StartUp.m_strFilename = _rFilename;
|
|
|
|
SConfig::GetInstance().m_LastFilename = _rFilename;
|
2013-05-24 19:04:06 -04:00
|
|
|
SConfig::GetInstance().SaveSettings();
|
2011-02-12 22:31:57 +00:00
|
|
|
StartUp.bRunCompareClient = false;
|
|
|
|
StartUp.bRunCompareServer = false;
|
|
|
|
|
|
|
|
StartUp.hInstance = Host_GetInstance();
|
|
|
|
|
|
|
|
// If for example the ISO file is bad we return here
|
2013-04-16 23:14:36 -04:00
|
|
|
if (!StartUp.AutoSetup(SCoreStartupParameter::BOOT_DEFAULT))
|
|
|
|
return false;
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
// Load game specific settings
|
|
|
|
std::string unique_id = StartUp.GetUniqueID();
|
2013-09-23 02:39:14 -04:00
|
|
|
std::string revision_specific = StartUp.m_strRevisionSpecificUniqueID;
|
2013-09-07 23:02:49 +02:00
|
|
|
StartUp.m_strGameIniDefault = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + unique_id + ".ini";
|
2013-09-23 02:39:14 -04:00
|
|
|
if (revision_specific != "")
|
|
|
|
StartUp.m_strGameIniDefaultRevisionSpecific = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + revision_specific + ".ini";
|
|
|
|
else
|
|
|
|
StartUp.m_strGameIniDefaultRevisionSpecific = "";
|
2013-09-07 23:02:49 +02:00
|
|
|
StartUp.m_strGameIniLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + unique_id + ".ini";
|
|
|
|
|
|
|
|
if (unique_id.size() == 6)
|
2011-02-12 22:31:57 +00:00
|
|
|
{
|
2013-09-23 02:39:14 -04:00
|
|
|
IniFile game_ini = StartUp.LoadGameIni();
|
2013-09-07 23:02:49 +02:00
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
config_cache.valid = true;
|
|
|
|
config_cache.bCPUThread = StartUp.bCPUThread;
|
|
|
|
config_cache.bSkipIdle = StartUp.bSkipIdle;
|
2012-12-27 09:42:20 -05:00
|
|
|
config_cache.iCPUCore = StartUp.iCPUCore;
|
2011-02-12 22:31:57 +00:00
|
|
|
config_cache.bEnableFPRF = StartUp.bEnableFPRF;
|
|
|
|
config_cache.bMMU = StartUp.bMMU;
|
2013-01-20 13:09:38 +11:00
|
|
|
config_cache.bDCBZOFF = StartUp.bDCBZOFF;
|
2013-09-28 08:07:23 -04:00
|
|
|
config_cache.bTLBHack = StartUp.bTLBHack;
|
2013-04-16 21:18:53 +10:00
|
|
|
config_cache.bVBeamSpeedHack = StartUp.bVBeamSpeedHack;
|
2013-02-16 12:51:09 +11:00
|
|
|
config_cache.bSyncGPU = StartUp.bSyncGPU;
|
2011-02-12 22:31:57 +00:00
|
|
|
config_cache.bFastDiscSpeed = StartUp.bFastDiscSpeed;
|
|
|
|
config_cache.bMergeBlocks = StartUp.bMergeBlocks;
|
|
|
|
config_cache.bDSPHLE = StartUp.bDSPHLE;
|
2012-09-23 16:02:11 -05:00
|
|
|
config_cache.strBackend = StartUp.m_strVideoBackend;
|
2012-12-27 09:42:20 -05:00
|
|
|
config_cache.bHLE_BS2 = StartUp.bHLE_BS2;
|
2013-07-19 18:48:27 -04:00
|
|
|
config_cache.m_EnableJIT = SConfig::GetInstance().m_EnableJIT;
|
2013-08-04 02:34:39 -04:00
|
|
|
config_cache.bDSPThread = StartUp.bDSPThread;
|
2013-09-04 19:16:28 -05:00
|
|
|
config_cache.m_EXIDevice[0] = SConfig::GetInstance().m_EXIDevice[0];
|
|
|
|
config_cache.m_EXIDevice[1] = SConfig::GetInstance().m_EXIDevice[1];
|
2013-09-28 08:31:28 -04:00
|
|
|
config_cache.Volume = SConfig::GetInstance().m_Volume;
|
|
|
|
config_cache.sBackend = SConfig::GetInstance().sBackend;
|
2013-10-23 13:45:03 -04:00
|
|
|
config_cache.framelimit = SConfig::GetInstance().m_Framelimit;
|
|
|
|
config_cache.bUseFPS = SConfig::GetInstance().b_UseFPS;
|
2014-01-01 06:59:01 -05:00
|
|
|
for (unsigned int i = 0; i < 5; ++i)
|
|
|
|
{
|
|
|
|
config_cache.iWiimoteSource[i] = g_wiimote_sources[i];
|
|
|
|
}
|
|
|
|
std::fill_n(config_cache.iSetWiimoteSource, 5, -1);
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
// General settings
|
|
|
|
game_ini.Get("Core", "CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
|
|
|
game_ini.Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle);
|
|
|
|
game_ini.Get("Core", "EnableFPRF", &StartUp.bEnableFPRF, StartUp.bEnableFPRF);
|
|
|
|
game_ini.Get("Core", "MMU", &StartUp.bMMU, StartUp.bMMU);
|
2013-09-28 08:07:23 -04:00
|
|
|
game_ini.Get("Core", "TLBHack", &StartUp.bTLBHack, StartUp.bTLBHack);
|
2013-01-20 13:09:38 +11:00
|
|
|
game_ini.Get("Core", "DCBZ", &StartUp.bDCBZOFF, StartUp.bDCBZOFF);
|
2013-04-16 21:18:53 +10:00
|
|
|
game_ini.Get("Core", "VBeam", &StartUp.bVBeamSpeedHack, StartUp.bVBeamSpeedHack);
|
2013-02-16 12:51:09 +11:00
|
|
|
game_ini.Get("Core", "SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
|
2011-02-12 22:31:57 +00:00
|
|
|
game_ini.Get("Core", "FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
|
|
|
|
game_ini.Get("Core", "BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks);
|
|
|
|
game_ini.Get("Core", "DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
2013-08-02 14:21:34 +02:00
|
|
|
game_ini.Get("Core", "DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread);
|
2012-09-23 16:02:11 -05:00
|
|
|
game_ini.Get("Core", "GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend.c_str());
|
2012-12-27 09:42:20 -05:00
|
|
|
game_ini.Get("Core", "CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
|
|
|
game_ini.Get("Core", "HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
2013-10-23 13:45:03 -04:00
|
|
|
game_ini.Get("Core", "FrameLimit", &SConfig::GetInstance().m_Framelimit, SConfig::GetInstance().m_Framelimit);
|
|
|
|
game_ini.Get("Core", "UseFPS", &SConfig::GetInstance().b_UseFPS,SConfig::GetInstance().b_UseFPS);
|
2013-09-28 08:31:28 -04:00
|
|
|
game_ini.Get("DSP", "Volume", &SConfig::GetInstance().m_Volume, SConfig::GetInstance().m_Volume);
|
|
|
|
game_ini.Get("DSP", "EnableJIT", &SConfig::GetInstance().m_EnableJIT, SConfig::GetInstance().m_EnableJIT);
|
|
|
|
game_ini.Get("DSP", "Backend", &SConfig::GetInstance().sBackend, SConfig::GetInstance().sBackend.c_str());
|
2012-09-23 17:54:23 -05:00
|
|
|
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// Wii settings
|
|
|
|
if (StartUp.bWii)
|
|
|
|
{
|
|
|
|
// Flush possible changes to SYSCONF to file
|
|
|
|
SConfig::GetInstance().m_SYSCONF->Save();
|
2014-01-01 06:59:01 -05:00
|
|
|
|
|
|
|
int source;
|
|
|
|
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
|
|
|
{
|
2014-01-01 07:45:20 -05:00
|
|
|
game_ini.Get("Controls", StringFromFormat("WiimoteSource%u", i).c_str(), &source, -1);
|
2014-01-01 06:59:01 -05:00
|
|
|
if (source != -1 && g_wiimote_sources[i] != source && source >= WIIMOTE_SRC_NONE && source <= WIIMOTE_SRC_HYBRID)
|
|
|
|
{
|
|
|
|
config_cache.iSetWiimoteSource[i] = source;
|
|
|
|
g_wiimote_sources[i] = source;
|
|
|
|
WiimoteReal::ChangeWiimoteSource(i, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
game_ini.Get("Controls", "WiimoteSourceBB", &source, -1);
|
|
|
|
if (source != -1 && g_wiimote_sources[WIIMOTE_BALANCE_BOARD] != source && (source == WIIMOTE_SRC_NONE || source == WIIMOTE_SRC_REAL))
|
|
|
|
{
|
|
|
|
config_cache.iSetWiimoteSource[WIIMOTE_BALANCE_BOARD] = source;
|
|
|
|
g_wiimote_sources[WIIMOTE_BALANCE_BOARD] = source;
|
|
|
|
WiimoteReal::ChangeWiimoteSource(4, source);
|
|
|
|
}
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
2013-10-29 01:23:17 -04:00
|
|
|
}
|
2011-02-12 22:31:57 +00:00
|
|
|
|
2013-05-19 19:44:37 +02:00
|
|
|
// movie settings
|
|
|
|
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
|
|
|
{
|
|
|
|
StartUp.bCPUThread = Movie::IsDualCore();
|
|
|
|
StartUp.bSkipIdle = Movie::IsSkipIdle();
|
|
|
|
StartUp.bDSPHLE = Movie::IsDSPHLE();
|
|
|
|
StartUp.bProgressive = Movie::IsProgressive();
|
|
|
|
StartUp.bFastDiscSpeed = Movie::IsFastDiscSpeed();
|
|
|
|
StartUp.iCPUCore = Movie::GetCPUMode();
|
2013-06-20 06:08:17 -04:00
|
|
|
StartUp.bSyncGPU = Movie::IsSyncGPU();
|
2013-05-19 19:44:37 +02:00
|
|
|
if (Movie::IsUsingMemcard() && Movie::IsStartingFromClearSave() && !StartUp.bWii)
|
|
|
|
{
|
2013-07-01 17:44:42 -04:00
|
|
|
if (File::Exists(File::GetUserPath(D_GCUSER_IDX) + "Movie.raw"))
|
|
|
|
File::Delete(File::GetUserPath(D_GCUSER_IDX) + "Movie.raw");
|
2013-05-19 19:44:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-05 04:56:30 -04:00
|
|
|
if (NetPlay::IsNetPlayRunning())
|
2013-07-19 18:48:27 -04:00
|
|
|
{
|
2013-08-18 01:43:49 -04:00
|
|
|
StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread;
|
2013-07-19 18:48:27 -04:00
|
|
|
StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE;
|
2013-07-22 06:15:08 -04:00
|
|
|
StartUp.bEnableMemcardSaving = g_NetPlaySettings.m_WriteToMemcard;
|
2013-07-19 18:48:27 -04:00
|
|
|
SConfig::GetInstance().m_EnableJIT = g_NetPlaySettings.m_DSPEnableJIT;
|
2013-09-04 19:16:28 -05:00
|
|
|
SConfig::GetInstance().m_EXIDevice[0] = g_NetPlaySettings.m_EXIDevice[0];
|
|
|
|
SConfig::GetInstance().m_EXIDevice[1] = g_NetPlaySettings.m_EXIDevice[1];
|
2013-07-19 18:48:27 -04:00
|
|
|
}
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// Run the game
|
|
|
|
// Init the core
|
|
|
|
if (!Core::Init())
|
|
|
|
{
|
|
|
|
PanicAlertT("Couldn't init the core.\nCheck your configuration.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stop()
|
|
|
|
{
|
|
|
|
Core::Stop();
|
|
|
|
|
|
|
|
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
|
|
|
|
2013-01-09 15:03:43 -05:00
|
|
|
StartUp.m_strUniqueID = "00000000";
|
2011-02-12 22:31:57 +00:00
|
|
|
if (config_cache.valid)
|
|
|
|
{
|
|
|
|
config_cache.valid = false;
|
|
|
|
StartUp.bCPUThread = config_cache.bCPUThread;
|
|
|
|
StartUp.bSkipIdle = config_cache.bSkipIdle;
|
2012-12-27 09:42:20 -05:00
|
|
|
StartUp.iCPUCore = config_cache.iCPUCore;
|
2011-02-12 22:31:57 +00:00
|
|
|
StartUp.bEnableFPRF = config_cache.bEnableFPRF;
|
|
|
|
StartUp.bMMU = config_cache.bMMU;
|
2013-01-20 13:09:38 +11:00
|
|
|
StartUp.bDCBZOFF = config_cache.bDCBZOFF;
|
2013-09-28 08:07:23 -04:00
|
|
|
StartUp.bTLBHack = config_cache.bTLBHack;
|
2013-04-16 21:18:53 +10:00
|
|
|
StartUp.bVBeamSpeedHack = config_cache.bVBeamSpeedHack;
|
2013-02-16 12:51:09 +11:00
|
|
|
StartUp.bSyncGPU = config_cache.bSyncGPU;
|
2011-02-12 22:31:57 +00:00
|
|
|
StartUp.bFastDiscSpeed = config_cache.bFastDiscSpeed;
|
|
|
|
StartUp.bMergeBlocks = config_cache.bMergeBlocks;
|
|
|
|
StartUp.bDSPHLE = config_cache.bDSPHLE;
|
2013-07-31 21:35:22 -04:00
|
|
|
StartUp.bDSPThread = config_cache.bDSPThread;
|
2012-09-23 16:02:11 -05:00
|
|
|
StartUp.m_strVideoBackend = config_cache.strBackend;
|
2012-09-24 17:16:34 -05:00
|
|
|
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
|
2012-12-27 09:42:20 -05:00
|
|
|
StartUp.bHLE_BS2 = config_cache.bHLE_BS2;
|
2013-10-23 13:45:03 -04:00
|
|
|
SConfig::GetInstance().m_Framelimit = config_cache.framelimit;
|
|
|
|
SConfig::GetInstance().b_UseFPS = config_cache.bUseFPS;
|
2013-07-19 18:48:27 -04:00
|
|
|
SConfig::GetInstance().m_EnableJIT = config_cache.m_EnableJIT;
|
2013-09-04 19:16:28 -05:00
|
|
|
SConfig::GetInstance().m_EXIDevice[0] = config_cache.m_EXIDevice[0];
|
|
|
|
SConfig::GetInstance().m_EXIDevice[1] = config_cache.m_EXIDevice[1];
|
2013-09-28 08:31:28 -04:00
|
|
|
SConfig::GetInstance().m_Volume = config_cache.Volume;
|
|
|
|
SConfig::GetInstance().sBackend = config_cache.sBackend;
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
2014-01-01 06:59:01 -05:00
|
|
|
|
|
|
|
if (StartUp.bWii)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
|
|
|
|
{
|
|
|
|
// If user changed wiimote settings mid game, keep their new setting, otherwise revert to what it was before booting the game.
|
|
|
|
if (config_cache.iSetWiimoteSource[i] == g_wiimote_sources[i])
|
|
|
|
{
|
|
|
|
g_wiimote_sources[i] = config_cache.iWiimoteSource[i];
|
|
|
|
WiimoteReal::ChangeWiimoteSource(i, config_cache.iWiimoteSource[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|