* remove more Config dependencies from the core

* also use less shitty strings
This commit is contained in:
Arisotura
2021-11-17 20:42:11 +01:00
parent 69715043ca
commit 5bb8f4c922
10 changed files with 102 additions and 64 deletions

View File

@ -26,6 +26,17 @@ extern int ConsoleType;
extern int DirectBoot;
extern int SavestateRelocSRAM;
extern int ExternalBIOSEnable;
extern char BIOS9Path[1024];
extern char BIOS7Path[1024];
extern char FirmwarePath[1024];
extern char DSiBIOS9Path[1024];
extern char DSiBIOS7Path[1024];
extern char DSiFirmwarePath[1024];
extern char DSiNANDPath[1024];
}
#endif
#endif

View File

@ -43,6 +43,7 @@
#endif
#include <QStandardPaths>
#include <QString>
#include <QDir>
#include <QThread>
#include <QSemaphore>
@ -133,7 +134,9 @@ int GetConfigInt(ConfigEntry entry)
switch (entry)
{
#ifdef JIT_ENABLED
case JIT_MaxBlockSize: return Config::JIT_MaxBlockSize;
#endif
case DLDI_ImageSize: return imgsizes[Config::DLDISize];
@ -147,10 +150,14 @@ bool GetConfigBool(ConfigEntry entry)
{
switch (entry)
{
#ifdef JIT_ENABLED
case JIT_Enable: return Config::JIT_Enable != 0;
case JIT_LiteralOptimizations: return Config::JIT_LiteralOptimisations != 0;
case JIT_BranchOptimizations: return Config::JIT_BranchOptimisations != 0;
case JIT_FastMemory: return Config::JIT_FastMemory != 0;
#endif
case ExternalBIOSEnable: return Config::ExternalBIOSEnable != 0;
case DLDI_Enable: return Config::DLDIEnable != 0;
case DLDI_ReadOnly: return Config::DLDIReadOnly != 0;
@ -168,6 +175,15 @@ std::string GetConfigString(ConfigEntry entry)
{
switch (entry)
{
case BIOS9Path: return Config::BIOS9Path;
case BIOS7Path: return Config::BIOS7Path;
case FirmwarePath: return Config::FirmwarePath;
case DSi_BIOS9Path: return Config::DSiBIOS9Path;
case DSi_BIOS7Path: return Config::DSiBIOS7Path;
case DSi_FirmwarePath: return Config::DSiFirmwarePath;
case DSi_NANDPath: return Config::DSiNANDPath;
case DLDI_ImagePath: return Config::DLDISDPath;
case DLDI_FolderPath: return Config::DLDIFolderPath;
@ -179,9 +195,9 @@ std::string GetConfigString(ConfigEntry entry)
}
FILE* OpenFile(const char* path, const char* mode, bool mustexist)
FILE* OpenFile(std::string path, std::string mode, bool mustexist)
{
QFile f(path);
QFile f(path.c_str());
if (mustexist && !f.exists())
{
@ -189,11 +205,11 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
}
QIODevice::OpenMode qmode;
if (strlen(mode) > 1 && mode[0] == 'r' && mode[1] == '+')
if (mode.length() > 1 && mode[0] == 'r' && mode[1] == '+')
{
qmode = QIODevice::OpenModeFlag::ReadWrite;
}
else if (strlen(mode) > 1 && mode[0] == 'w' && mode[1] == '+')
else if (mode.length() > 1 && mode[0] == 'w' && mode[1] == '+')
{
qmode = QIODevice::OpenModeFlag::Truncate | QIODevice::OpenModeFlag::ReadWrite;
}
@ -207,36 +223,36 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
}
f.open(qmode);
FILE* file = fdopen(dup(f.handle()), mode);
FILE* file = fdopen(dup(f.handle()), mode.c_str());
f.close();
return file;
}
FILE* OpenLocalFile(const char* path, const char* mode)
FILE* OpenLocalFile(std::string path, std::string mode)
{
QDir dir(path);
QDir dir(path.c_str());
QString fullpath;
if (dir.isAbsolute())
{
// If it's an absolute path, just open that.
fullpath = path;
fullpath = path.c_str();
}
else
{
#ifdef PORTABLE
fullpath = QString(EmuDirectory) + QDir::separator() + path;
fullpath = QString(EmuDirectory) + QDir::separator() + path.c_str();
#else
// Check user configuration directory
QDir config(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
config.mkdir("melonDS");
fullpath = config.absolutePath() + "/melonDS/";
fullpath.append(path);
fullpath.append(path.c_str());
#endif
}
return OpenFile(fullpath.toUtf8(), mode, mode[0] != 'w');
return OpenFile(fullpath.toStdString(), mode, mode[0] != 'w');
}
Thread* Thread_Create(std::function<void()> func)

View File

@ -71,6 +71,17 @@ int JIT_LiteralOptimisations = true;
int JIT_FastMemory = true;
#endif
int ExternalBIOSEnable;
char BIOS9Path[1024];
char BIOS7Path[1024];
char FirmwarePath[1024];
char DSiBIOS9Path[1024];
char DSiBIOS7Path[1024];
char DSiFirmwarePath[1024];
char DSiNANDPath[1024];
int DLDIEnable;
char DLDISDPath[1024];
int DLDISize;
@ -206,6 +217,17 @@ ConfigEntry PlatformConfigFile[] =
#endif
#endif
{"ExternalBIOSEnable", 0, &ExternalBIOSEnable, 0, NULL, 0},
{"BIOS9Path", 1, BIOS9Path, 0, "", 1023},
{"BIOS7Path", 1, BIOS7Path, 0, "", 1023},
{"FirmwarePath", 1, FirmwarePath, 0, "", 1023},
{"DSiBIOS9Path", 1, DSiBIOS9Path, 0, "", 1023},
{"DSiBIOS7Path", 1, DSiBIOS7Path, 0, "", 1023},
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023},
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023},
{"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0},
{"DLDISDPath", 1, DLDISDPath, 0, "dldi.bin", 1023},
{"DLDISize", 0, &DLDISize, 0, NULL, 0},

View File

@ -87,6 +87,17 @@ extern int JIT_LiteralOptimisations;
extern int JIT_FastMemory;
#endif
extern int ExternalBIOSEnable;
extern char BIOS9Path[1024];
extern char BIOS7Path[1024];
extern char FirmwarePath[1024];
extern char DSiBIOS9Path[1024];
extern char DSiBIOS7Path[1024];
extern char DSiFirmwarePath[1024];
extern char DSiNANDPath[1024];
extern int DLDIEnable;
extern char DLDISDPath[1024];
extern int DLDISize;