Kill some horribly ugly hackery :( It's just not right to pass entire IniFile objects across DLLs. Only POD (plain-old-data, like int, float, char, char[] etc) are safe to pass across DLL boundaries.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4257 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-09-13 08:54:46 +00:00
parent 700f2ff694
commit 512053fa5e
20 changed files with 87 additions and 149 deletions

View File

@ -705,7 +705,7 @@ void Callback_VideoCopiedToXFB(bool video_update)
double wait_frametime = (1000.0 / targetfps);
if (Timer.GetTimeDifference() >= wait_frametime * frames)
no_framelimit=Timer.GetTimeDifference();
no_framelimit = (u32)Timer.GetTimeDifference();
while (Timer.GetTimeDifference() < wait_frametime * frames)
{
@ -756,7 +756,7 @@ void Callback_VideoCopiedToXFB(bool video_update)
int TargetVPS = (int)(VideoInterface::TargetRefreshRate + 0.5);
float Speed = ((VPS > 0 ? VPS : VideoInterface::ActualRefreshRate) / TargetVPS) * 100.0f;
float Speed = ((VPS > 0.0f ? VPS : VideoInterface::ActualRefreshRate) / TargetVPS) * 100.0f;
// Settings are shown the same for both extended and summary info
std::string SSettings = StringFromFormat(" | Core: %s %s",

View File

@ -47,8 +47,6 @@ void SCoreStartupParameter::LoadDefaults()
bWii = false;
SelectedLanguage = 0;
iTLBHack = 0;
delete gameIni;
gameIni = NULL;
bJITOff = false; // debugger only settings
bJITLoadStoreOff = false;

View File

@ -37,9 +37,6 @@ struct SCoreStartupParameter
// Windows/GUI related
void* hMainWindow;
// game ini
IniFile *gameIni;
// Settings
bool bEnableDebugging; bool bAutomaticStart; bool bBootToPause;
bool bUseJIT;
@ -116,6 +113,7 @@ struct SCoreStartupParameter
std::string m_strDVDRoot;
std::string m_strUniqueID;
std::string m_strName;
std::string m_strGameIni;
// Constructor just calls LoadDefaults
SCoreStartupParameter();

View File

@ -338,8 +338,8 @@ static u32 s_lineCount = 0;
static u32 s_upperFieldBegin = 0;
static u32 s_lowerFieldBegin = 0;
double TargetRefreshRate = 0.0;
double ActualRefreshRate = 0.0;
float TargetRefreshRate = 0.0;
float ActualRefreshRate = 0.0;
s64 SyncTicksProgress = 0;
void DoState(PointerWrap &p)

View File

@ -44,8 +44,8 @@ namespace VideoInterface
void Update();
// urgh, ugly externs.
extern double ActualRefreshRate;
extern double TargetRefreshRate;
extern float ActualRefreshRate;
extern float TargetRefreshRate;
extern s64 SyncTicksProgress;
// UpdateInterrupts: check if we have to generate a new VI Interrupt

View File

@ -15,15 +15,11 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// File description
/* ------------
This file controls when plugins are loaded and unloaded from memory. Its functions scan for valid
plugins when Dolphin is booted, and open the debugging and config windows. The PluginManager is
created once when Dolphin starts and is closed when Dolphin is closed.
*/
// Include
@ -58,7 +54,6 @@ CPluginManager::CPluginManager()
// Start LogManager
m_PluginGlobals->logManager = LogManager::GetInstance();
m_PluginGlobals->eventHandler = EventHandler::GetInstance();
m_PluginGlobals->config = (void *)&SConfig::GetInstance();
m_params = &(SConfig::GetInstance().m_LocalCoreStartupParameter);
@ -104,6 +99,13 @@ CPluginManager::~CPluginManager()
// Function: Point the m_pad[] and other variables to a certain plugin
bool CPluginManager::InitPlugins()
{
// Update pluginglobals.
if (SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.size() == 0)
{
PanicAlert("Bad gameini filename");
}
strcpy(m_PluginGlobals->game_ini, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str());
strcpy(m_PluginGlobals->unique_id, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str());
if (!GetDSP()) {
PanicAlert("Can't init DSP Plugin");
return false;

View File

@ -71,11 +71,7 @@ namespace BootManager
extern "C" HINSTANCE wxGetInstance();
#endif
// Boot the ISO or file
// ----------------
bool BootCore(const std::string& _rFilename)
{
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
@ -117,40 +113,28 @@ bool BootCore(const std::string& _rFilename)
// ====================================================
// Load game specific settings
// ----------------
// Released when you LoadDefaults
IniFile *ini = new IniFile();
IniFile game_ini;
std::string unique_id = StartUp.GetUniqueID();
if (unique_id.size() == 6 && ini->Load((FULL_GAMECONFIG_DIR + unique_id + ".ini").c_str()))
StartUp.m_strGameIni = FULL_GAMECONFIG_DIR + unique_id + ".ini";
if (unique_id.size() == 6 && game_ini.Load(StartUp.m_strGameIni.c_str()))
{
StartUp.gameIni = ini;
// ------------------------------------------------
// General settings
// ----------------
ini->Get("Core", "UseDualCore", &StartUp.bUseDualCore, StartUp.bUseDualCore);
ini->Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle);
ini->Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers);
ini->Get("Core", "EnableFPRF", &StartUp.bEnableFPRF, StartUp.bEnableFPRF);
ini->Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack);
// ------------------------------------------------
game_ini.Get("Core", "UseDualCore", &StartUp.bUseDualCore, StartUp.bUseDualCore);
game_ini.Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle);
game_ini.Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers);
game_ini.Get("Core", "EnableFPRF", &StartUp.bEnableFPRF, StartUp.bEnableFPRF);
game_ini.Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack);
// Wii settings
// ----------------
if (StartUp.bWii)
{
//bRefreshList = false;
FILE* pStream; // file handle
u16 IPL_PGS = 0x17CC; // progressive scan
u16 IPL_AR = 0x04D9; // widescreen
ini->Get("Wii", "ProgressiveScan", &StartUp.bProgressiveScan, StartUp.bProgressiveScan);
ini->Get("Wii", "Widescreen", &StartUp.bWidescreen, StartUp.bWidescreen);
game_ini.Get("Wii", "ProgressiveScan", &StartUp.bProgressiveScan, StartUp.bProgressiveScan);
game_ini.Get("Wii", "Widescreen", &StartUp.bWidescreen, StartUp.bWidescreen);
// Save the update Wii SYSCONF settings
pStream = NULL;
pStream = fopen(WII_SYSCONF_FILE, "r+b");
if (pStream != NULL)
FILE* pStream = fopen(WII_SYSCONF_FILE, "r+b");
if (pStream)
{
const int IPL_PGS = 0x17CC; // progressive scan
const int IPL_AR = 0x04D9; // widescreen
fseek(pStream, IPL_PGS, 0);
fputc(StartUp.bProgressiveScan ? 1 : 0, pStream);
fseek(pStream, IPL_AR, 0);
@ -162,15 +146,8 @@ bool BootCore(const std::string& _rFilename)
PanicAlert("Could not write to %s", WII_SYSCONF_FILE);
}
}
// ---------------
} else {
delete ini;
ini = NULL;
}
// =====================
// =================================================================
// Run the game
// --------------
#if defined(HAVE_WX) && HAVE_WX

View File

@ -105,40 +105,20 @@ void Config::Load(const char *ini_file)
SetEnableAlert(bTmp);
}
void Config::GameIniLoad(IniFile *iniFile)
void Config::GameIniLoad(const char *ini_file)
{
if (! iniFile)
return;
if (iniFile->Exists("Video", "ForceFiltering"))
iniFile->Get("Video", "ForceFiltering", &bForceFiltering, 0);
if (iniFile->Exists("Video", "MaxAnisotropy"))
iniFile->Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
if (iniFile->Exists("Video", "EFBCopyDisable"))
iniFile->Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0);
if (iniFile->Exists("Video", "EFBCopyDisableHotKey"))
iniFile->Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0);
if (iniFile->Exists("Video", "EFBToRAMEnable"))
iniFile->Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0);
if (iniFile->Exists("Video", "SafeTextureCache"))
iniFile->Get("Video", "SafeTextureCache", &bSafeTextureCache, false);
if (iniFile->Exists("Video", "MSAA"))
iniFile->Get("Video", "MSAA", &iMultisampleMode, 0);
if (iniFile->Exists("Video", "DstAlphaPass"))
iniFile->Get("Video", "DstAlphaPass", &bDstAlphaPass, false);
if (iniFile->Exists("Video", "UseXFB"))
iniFile->Get("Video", "UseXFB", &bUseXFB, 0);
if (iniFile->Exists("Video", "ProjectionHack"))
iniFile->Get("Video", "ProjectionHack", &iPhackvalue, 0);
IniFile iniFile;
iniFile.Load(ini_file);
iniFile.Get("Video", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
iniFile.Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0);
iniFile.Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0);
iniFile.Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0);
iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false);
iniFile.Get("Video", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false);
iniFile.Get("Video", "UseXFB", &bUseXFB, 0);
iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0);
}
void Config::Save(const char *ini_file)

View File

@ -55,7 +55,7 @@ struct Config
{
Config();
void Load(const char *ini_file);
void GameIniLoad(IniFile *iniFile);
void GameIniLoad(const char *ini_file);
void Save(const char *ini_file);
void UpdateProjectionHack();

View File

@ -84,9 +84,6 @@ enum PLUGIN_TYPE {
#define STATE_MODE_MEASURE 3
// Export structs
// ------------
typedef struct
@ -96,16 +93,16 @@ typedef struct
char Name[100]; // Name of the DLL
} PLUGIN_INFO;
// TODO: Remove, or at least remove the void pointers and replace with data.
// This design is just wrong and ugly - the plugins shouldn't have this much access.
typedef struct
{
void *eventHandler;
void *config;
void *logManager;
char game_ini[MAX_PATH];
char unique_id[16];
} PLUGIN_GLOBALS;
// GLOBAL I N T E R F A C E
// ____________________________________________________________________________
// Function: GetDllInfo

View File

@ -49,12 +49,13 @@ void CConfig::Save()
file.Save(FULL_CONFIG_DIR "DSP.ini");
}
void CConfig::GameIniLoad() {
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
if (! iniFile)
return;
if (iniFile->Exists("HLEaudio", "UseRE0Fix"))
iniFile->Get("HLEaudio", "UseRE0Fix", &m_EnableRE0Fix, 0);
void CConfig::GameIniLoad(const char *game_ini)
{
if (game_ini && strlen(game_ini))
{
IniFile iniFile;
iniFile.Load(game_ini);
iniFile.Get("HLEaudio", "UseRE0Fix", &m_EnableRE0Fix, 0);
}
}

View File

@ -28,7 +28,7 @@ struct CConfig
CConfig();
void Load();
void GameIniLoad();
void GameIniLoad(const char *game_ini);
void Save();
};

View File

@ -31,10 +31,6 @@ END_EVENT_TABLE()
DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
// Load config settings
g_Config.Load();
g_Config.GameIniLoad();
// Center window
CenterOnParent();

View File

@ -78,7 +78,7 @@ void CUCode_AX::SaveLogFile(std::string f, int resizeTo, bool type, bool Wii)
ci << (resizeTo - 1); // write ci
cType << type; // write cType
std::string FileName = FULL_MAIL_LOGS_DIR + ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID();
std::string FileName = FULL_MAIL_LOGS_DIR + std::string(globals->unique_id);
FileName += "_sep"; FileName += ci.str(); FileName += "_sep"; FileName += cType.str();
FileName += Wii ? "_sepWii_sep" : "_sepGC_sep"; FileName += ".log";
@ -109,13 +109,12 @@ if(m_DebuggerFrame->ScanMails)
{
if (saveNext && saveNext < 100) // limit because saveNext is not initialized
{
// Save the timestamps and comment
std::ostringstream ci;
ci << (saveNext - 1);
TmpMailLog += "\n\n";
TmpMailLog += "-----------------------------------------------------------------------\n";
TmpMailLog += "Current mail: " + ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID() + " mail " + ci.str() + "\n";
// TmpMailLog += "Current mail: " + std::string(globals->unique_id) + " mail " + ci + "\n";
if (Wii)
TmpMailLog += "Current CRC: " + StringFromFormat("0x%08x \n\n", _CRC);

View File

@ -179,6 +179,10 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
void DllConfig(HWND _hParent)
{
#if defined(HAVE_WX) && HAVE_WX
// Load config settings
g_Config.Load();
g_Config.GameIniLoad(globals->game_ini);
if (!m_ConfigFrame)
m_ConfigFrame = new DSPConfigDialogHLE(GetParentedWxWindow(_hParent));
else if (!m_ConfigFrame->GetParent()->IsShown())

View File

@ -33,8 +33,6 @@
#include "TextureDecoder.h"
#include "TextureCache.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
u8 *TextureCache::temp = NULL;
TextureCache::TexCache TextureCache::textures;
@ -235,7 +233,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
char szTemp[MAX_PATH];
char szDir[MAX_PATH];
const char* uniqueId = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str();
const char* uniqueId = globals->unique_id;
bool bCheckedDumpDir = false;
sprintf(szDir,"%s/%s",FULL_DUMP_TEXTURES_DIR,uniqueId);

View File

@ -177,8 +177,7 @@ void UpdateFPSDisplay(const char *text)
bool Init()
{
g_Config.Load(FULL_CONFIG_DIR "gfx_dx9.ini");
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
g_Config.GameIniLoad(globals->game_ini);
UpdateProjectionHack(g_Config.iPhackvalue); // DX9 projection hack could be disabled by commenting out this line
if (initCount == 0)

View File

@ -52,8 +52,6 @@
#include "FileUtil.h"
#include "HiresTextures.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
u8 *TextureMngr::temp = NULL;
TextureMngr::TexCache TextureMngr::textures;
@ -161,7 +159,7 @@ void TextureMngr::Init()
{
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
HiresTextures::Init(((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str());
HiresTextures::Init(globals->unique_id);
}
void TextureMngr::Invalidate(bool shutdown)
@ -342,7 +340,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
int oldWidth = width;
int oldHeight = height;
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, texHash, tex_format);
dfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp);
if (dfmt != PC_TEX_FMT_NONE)
@ -467,7 +465,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
char szTemp[MAX_PATH];
char szDir[MAX_PATH];
const char* uniqueId = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str();
const char* uniqueId = globals->unique_id;
bool bCheckedDumpDir = false;
sprintf(szDir,"%s/%s",FULL_DUMP_TEXTURES_DIR,uniqueId);

View File

@ -70,11 +70,6 @@ GFXDebuggerOGL *m_DebuggerFrame = NULL;
#endif // HAVE_WX
#include "Config.h"
// Having to include this is TERRIBLY ugly. FIXME x100
#include "Globals.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
#include "LookUpTables.h"
#include "ImageWrite.h"
#include "Render.h"
@ -286,9 +281,7 @@ void CocaAddResolutions() {
void DllConfig(HWND _hParent)
{
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
g_Config.GameIniLoad(globals->game_ini);
g_Config.UpdateProjectionHack();
UpdateActiveConfig();
#if defined(HAVE_WX) && HAVE_WX
@ -326,9 +319,7 @@ void Initialize(void *init)
InitXFBConvTables();
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
g_Config.GameIniLoad(globals->game_ini);
#if defined(HAVE_WX) && HAVE_WX
g_Config.UpdateProjectionHack();