remove shitty strings from the config system. bahahahahha

This commit is contained in:
Arisotura
2021-12-12 16:27:57 +01:00
parent c72089df5e
commit b5d276b683
13 changed files with 406 additions and 399 deletions

View File

@ -21,6 +21,7 @@
#include "types.h" #include "types.h"
#include <string>
#include <vector> #include <vector>
namespace Frontend namespace Frontend
@ -93,17 +94,17 @@ void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16], u16 (&sequence)[
int Reset(); int Reset();
// get the filename associated with the given savestate slot (1-8) // get the filename associated with the given savestate slot (1-8)
void GetSavestateName(int slot, char* filename, int len); std::string GetSavestateName(int slot);
// determine whether the given savestate slot does contain a savestate // determine whether the given savestate slot does contain a savestate
bool SavestateExists(int slot); bool SavestateExists(int slot);
// load the given savestate file // load the given savestate file
// if successful, emulation will continue from the savestate's point // if successful, emulation will continue from the savestate's point
bool LoadState(const char* filename); bool LoadState(std::string filename);
// save the current emulator state to the given file // save the current emulator state to the given file
bool SaveState(const char* filename); bool SaveState(std::string filename);
// undo the latest savestate load // undo the latest savestate load
void UndoStateLoad(); void UndoStateLoad();

View File

@ -19,23 +19,25 @@
#ifndef SHAREDCONFIG_H #ifndef SHAREDCONFIG_H
#define SHAREDCONFIG_H #define SHAREDCONFIG_H
#include <string>
namespace Config namespace Config
{ {
extern int ConsoleType; extern int ConsoleType;
extern int DirectBoot; extern bool DirectBoot;
extern int SavestateRelocSRAM; extern bool SavestateRelocSRAM;
extern int ExternalBIOSEnable; extern bool ExternalBIOSEnable;
extern char BIOS9Path[1024]; extern std::string BIOS9Path;
extern char BIOS7Path[1024]; extern std::string BIOS7Path;
extern char FirmwarePath[1024]; extern std::string FirmwarePath;
extern char DSiBIOS9Path[1024]; extern std::string DSiBIOS9Path;
extern char DSiBIOS7Path[1024]; extern std::string DSiBIOS7Path;
extern char DSiFirmwarePath[1024]; extern std::string DSiFirmwarePath;
extern char DSiNANDPath[1024]; extern std::string DSiNANDPath;
} }

View File

@ -666,9 +666,11 @@ int Reset()
// SAVESTATE TODO // SAVESTATE TODO
// * configurable paths. not everyone wants their ROM directory to be polluted, I guess. // * configurable paths. not everyone wants their ROM directory to be polluted, I guess.
void GetSavestateName(int slot, char* filename, int len) std::string GetSavestateName(int slot)
{ {
int pos; int pos;
char filename[1024] = {0};
int len = 1024;
if (ROMPath[ROMSlot_NDS][0] == '\0') // running firmware, no ROM if (ROMPath[ROMSlot_NDS][0] == '\0') // running firmware, no ROM
{ {
@ -699,16 +701,17 @@ void GetSavestateName(int slot, char* filename, int len)
strcpy(&filename[pos], ".ml"); strcpy(&filename[pos], ".ml");
filename[pos+3] = '0'+slot; filename[pos+3] = '0'+slot;
filename[pos+4] = '\0'; filename[pos+4] = '\0';
return filename;
} }
bool SavestateExists(int slot) bool SavestateExists(int slot)
{ {
char ssfile[1024]; std::string ssfile = GetSavestateName(slot);
GetSavestateName(slot, ssfile, 1024);
return Platform::FileExists(ssfile); return Platform::FileExists(ssfile);
} }
bool LoadState(const char* filename) bool LoadState(std::string filename)
{ {
u32 oldGBACartCRC = GBACart::CartCRC; u32 oldGBACartCRC = GBACart::CartCRC;
@ -719,7 +722,7 @@ bool LoadState(const char* filename)
bool failed = false; bool failed = false;
Savestate* state = new Savestate(filename, false); Savestate* state = new Savestate(filename.c_str(), false);
if (state->Error) if (state->Error)
{ {
delete state; delete state;
@ -740,7 +743,7 @@ bool LoadState(const char* filename)
{ {
strncpy(PrevSRAMPath[ROMSlot_NDS], SRAMPath[0], 1024); strncpy(PrevSRAMPath[ROMSlot_NDS], SRAMPath[0], 1024);
strncpy(SRAMPath[ROMSlot_NDS], filename, 1019); strncpy(SRAMPath[ROMSlot_NDS], filename.c_str(), 1019);
int len = strlen(SRAMPath[ROMSlot_NDS]); int len = strlen(SRAMPath[ROMSlot_NDS]);
strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav"); strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav");
SRAMPath[ROMSlot_NDS][len+4] = '\0'; SRAMPath[ROMSlot_NDS][len+4] = '\0';
@ -775,9 +778,9 @@ bool LoadState(const char* filename)
return !failed; return !failed;
} }
bool SaveState(const char* filename) bool SaveState(std::string filename)
{ {
Savestate* state = new Savestate(filename, true); Savestate* state = new Savestate(filename.c_str(), true);
if (state->Error) if (state->Error)
{ {
delete state; delete state;
@ -790,7 +793,7 @@ bool SaveState(const char* filename)
if (Config::SavestateRelocSRAM && ROMPath[ROMSlot_NDS][0]!='\0') if (Config::SavestateRelocSRAM && ROMPath[ROMSlot_NDS][0]!='\0')
{ {
strncpy(SRAMPath[ROMSlot_NDS], filename, 1019); strncpy(SRAMPath[ROMSlot_NDS], filename.c_str(), 1019);
int len = strlen(SRAMPath[ROMSlot_NDS]); int len = strlen(SRAMPath[ROMSlot_NDS]);
strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav"); strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav");
SRAMPath[ROMSlot_NDS][len+4] = '\0'; SRAMPath[ROMSlot_NDS][len+4] = '\0';

View File

@ -62,7 +62,7 @@ AudioSettingsDialog::AudioSettingsDialog(QWidget* parent) : QDialog(parent), ui(
connect(grpMicMode, SIGNAL(buttonClicked(int)), this, SLOT(onChangeMicMode(int))); connect(grpMicMode, SIGNAL(buttonClicked(int)), this, SLOT(onChangeMicMode(int)));
grpMicMode->button(Config::MicInputType)->setChecked(true); grpMicMode->button(Config::MicInputType)->setChecked(true);
ui->txtMicWavPath->setText(Config::MicWavPath); ui->txtMicWavPath->setText(QString::fromStdString(Config::MicWavPath));
bool iswav = (Config::MicInputType == 3); bool iswav = (Config::MicInputType == 3);
ui->txtMicWavPath->setEnabled(iswav); ui->txtMicWavPath->setEnabled(iswav);
@ -77,7 +77,7 @@ AudioSettingsDialog::~AudioSettingsDialog()
void AudioSettingsDialog::on_AudioSettingsDialog_accepted() void AudioSettingsDialog::on_AudioSettingsDialog_accepted()
{ {
Config::MicInputType = grpMicMode->checkedId(); Config::MicInputType = grpMicMode->checkedId();
strncpy(Config::MicWavPath, ui->txtMicWavPath->text().toStdString().c_str(), 1023); Config::MicWavPath[1023] = '\0'; Config::MicWavPath = ui->txtMicWavPath->text().toStdString();
Config::Save(); Config::Save();
closeDlg(); closeDlg();

View File

@ -36,284 +36,283 @@ int JoystickID;
int WindowWidth; int WindowWidth;
int WindowHeight; int WindowHeight;
int WindowMaximized; bool WindowMaximized;
int ScreenRotation; int ScreenRotation;
int ScreenGap; int ScreenGap;
int ScreenLayout; int ScreenLayout;
int ScreenSwap; bool ScreenSwap;
int ScreenSizing; int ScreenSizing;
int IntegerScaling; bool IntegerScaling;
int ScreenAspectTop; int ScreenAspectTop;
int ScreenAspectBot; int ScreenAspectBot;
int ScreenFilter; bool ScreenFilter;
int ScreenUseGL; bool ScreenUseGL;
int ScreenVSync; bool ScreenVSync;
int ScreenVSyncInterval; int ScreenVSyncInterval;
int _3DRenderer; int _3DRenderer;
int Threaded3D; bool Threaded3D;
int GL_ScaleFactor; int GL_ScaleFactor;
int GL_BetterPolygons; bool GL_BetterPolygons;
int LimitFPS; bool LimitFPS;
int AudioSync; bool AudioSync;
int ShowOSD; bool ShowOSD;
int ConsoleType; int ConsoleType;
int DirectBoot; bool DirectBoot;
#ifdef JIT_ENABLED #ifdef JIT_ENABLED
int JIT_Enable = false; bool JIT_Enable = false;
int JIT_MaxBlockSize = 32; int JIT_MaxBlockSize = 32;
int JIT_BranchOptimisations = true; bool JIT_BranchOptimisations = true;
int JIT_LiteralOptimisations = true; bool JIT_LiteralOptimisations = true;
int JIT_FastMemory = true; bool JIT_FastMemory = true;
#endif #endif
int ExternalBIOSEnable; bool ExternalBIOSEnable;
char BIOS9Path[1024]; std::string BIOS9Path;
char BIOS7Path[1024]; std::string BIOS7Path;
char FirmwarePath[1024]; std::string FirmwarePath;
char DSiBIOS9Path[1024]; std::string DSiBIOS9Path;
char DSiBIOS7Path[1024]; std::string DSiBIOS7Path;
char DSiFirmwarePath[1024]; std::string DSiFirmwarePath;
char DSiNANDPath[1024]; std::string DSiNANDPath;
int DLDIEnable; bool DLDIEnable;
char DLDISDPath[1024]; std::string DLDISDPath;
int DLDISize; int DLDISize;
int DLDIReadOnly; bool DLDIReadOnly;
int DLDIFolderSync; bool DLDIFolderSync;
char DLDIFolderPath[1024]; std::string DLDIFolderPath;
int DSiSDEnable; bool DSiSDEnable;
char DSiSDPath[1024]; std::string DSiSDPath;
int DSiSDSize; int DSiSDSize;
int DSiSDReadOnly; bool DSiSDReadOnly;
int DSiSDFolderSync; bool DSiSDFolderSync;
char DSiSDFolderPath[1024]; std::string DSiSDFolderPath;
int FirmwareOverrideSettings; bool FirmwareOverrideSettings;
char FirmwareUsername[64]; std::string FirmwareUsername;
int FirmwareLanguage; int FirmwareLanguage;
int FirmwareBirthdayMonth; int FirmwareBirthdayMonth;
int FirmwareBirthdayDay; int FirmwareBirthdayDay;
int FirmwareFavouriteColour; int FirmwareFavouriteColour;
char FirmwareMessage[1024]; std::string FirmwareMessage;
char FirmwareMAC[18]; std::string FirmwareMAC;
int RandomizeMAC; bool RandomizeMAC;
int SocketBindAnyAddr; bool SocketBindAnyAddr;
char LANDevice[128]; std::string LANDevice;
int DirectLAN; bool DirectLAN;
int SavestateRelocSRAM; bool SavestateRelocSRAM;
int AudioInterp; int AudioInterp;
int AudioBitrate; int AudioBitrate;
int AudioVolume; int AudioVolume;
int MicInputType; int MicInputType;
char MicWavPath[1024]; std::string MicWavPath;
char LastROMFolder[1024]; std::string LastROMFolder;
char RecentROMList[10][1024]; std::string RecentROMList[10];
int EnableCheats; bool EnableCheats;
int MouseHide; bool MouseHide;
int MouseHideSeconds; int MouseHideSeconds;
int PauseLostFocus; bool PauseLostFocus;
const char* kConfigFile = "melonDS.ini"; const char* kConfigFile = "melonDS.ini";
ConfigEntry ConfigFile[] = ConfigEntry ConfigFile[] =
{ {
{"Key_A", 0, &KeyMapping[0], -1, NULL, 0}, {"Key_A", 0, &KeyMapping[0], -1},
{"Key_B", 0, &KeyMapping[1], -1, NULL, 0}, {"Key_B", 0, &KeyMapping[1], -1},
{"Key_Select", 0, &KeyMapping[2], -1, NULL, 0}, {"Key_Select", 0, &KeyMapping[2], -1},
{"Key_Start", 0, &KeyMapping[3], -1, NULL, 0}, {"Key_Start", 0, &KeyMapping[3], -1},
{"Key_Right", 0, &KeyMapping[4], -1, NULL, 0}, {"Key_Right", 0, &KeyMapping[4], -1},
{"Key_Left", 0, &KeyMapping[5], -1, NULL, 0}, {"Key_Left", 0, &KeyMapping[5], -1},
{"Key_Up", 0, &KeyMapping[6], -1, NULL, 0}, {"Key_Up", 0, &KeyMapping[6], -1},
{"Key_Down", 0, &KeyMapping[7], -1, NULL, 0}, {"Key_Down", 0, &KeyMapping[7], -1},
{"Key_R", 0, &KeyMapping[8], -1, NULL, 0}, {"Key_R", 0, &KeyMapping[8], -1},
{"Key_L", 0, &KeyMapping[9], -1, NULL, 0}, {"Key_L", 0, &KeyMapping[9], -1},
{"Key_X", 0, &KeyMapping[10], -1, NULL, 0}, {"Key_X", 0, &KeyMapping[10], -1},
{"Key_Y", 0, &KeyMapping[11], -1, NULL, 0}, {"Key_Y", 0, &KeyMapping[11], -1},
{"Joy_A", 0, &JoyMapping[0], -1, NULL, 0}, {"Joy_A", 0, &JoyMapping[0], -1},
{"Joy_B", 0, &JoyMapping[1], -1, NULL, 0}, {"Joy_B", 0, &JoyMapping[1], -1},
{"Joy_Select", 0, &JoyMapping[2], -1, NULL, 0}, {"Joy_Select", 0, &JoyMapping[2], -1},
{"Joy_Start", 0, &JoyMapping[3], -1, NULL, 0}, {"Joy_Start", 0, &JoyMapping[3], -1},
{"Joy_Right", 0, &JoyMapping[4], -1, NULL, 0}, {"Joy_Right", 0, &JoyMapping[4], -1},
{"Joy_Left", 0, &JoyMapping[5], -1, NULL, 0}, {"Joy_Left", 0, &JoyMapping[5], -1},
{"Joy_Up", 0, &JoyMapping[6], -1, NULL, 0}, {"Joy_Up", 0, &JoyMapping[6], -1},
{"Joy_Down", 0, &JoyMapping[7], -1, NULL, 0}, {"Joy_Down", 0, &JoyMapping[7], -1},
{"Joy_R", 0, &JoyMapping[8], -1, NULL, 0}, {"Joy_R", 0, &JoyMapping[8], -1},
{"Joy_L", 0, &JoyMapping[9], -1, NULL, 0}, {"Joy_L", 0, &JoyMapping[9], -1},
{"Joy_X", 0, &JoyMapping[10], -1, NULL, 0}, {"Joy_X", 0, &JoyMapping[10], -1},
{"Joy_Y", 0, &JoyMapping[11], -1, NULL, 0}, {"Joy_Y", 0, &JoyMapping[11], -1},
{"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], -1, NULL, 0}, {"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], -1},
{"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], -1, NULL, 0}, {"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], -1},
{"HKKey_Pause", 0, &HKKeyMapping[HK_Pause], -1, NULL, 0}, {"HKKey_Pause", 0, &HKKeyMapping[HK_Pause], -1},
{"HKKey_Reset", 0, &HKKeyMapping[HK_Reset], -1, NULL, 0}, {"HKKey_Reset", 0, &HKKeyMapping[HK_Reset], -1},
{"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], -1, NULL, 0}, {"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], -1},
{"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1, NULL, 0}, {"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1},
{"HKKey_FullscreenToggle", 0, &HKKeyMapping[HK_FullscreenToggle], -1, NULL, 0}, {"HKKey_FullscreenToggle", 0, &HKKeyMapping[HK_FullscreenToggle], -1},
{"HKKey_SwapScreens", 0, &HKKeyMapping[HK_SwapScreens], -1, NULL, 0}, {"HKKey_SwapScreens", 0, &HKKeyMapping[HK_SwapScreens], -1},
{"HKKey_SolarSensorDecrease", 0, &HKKeyMapping[HK_SolarSensorDecrease], -1, NULL, 0}, {"HKKey_SolarSensorDecrease", 0, &HKKeyMapping[HK_SolarSensorDecrease], -1},
{"HKKey_SolarSensorIncrease", 0, &HKKeyMapping[HK_SolarSensorIncrease], -1, NULL, 0}, {"HKKey_SolarSensorIncrease", 0, &HKKeyMapping[HK_SolarSensorIncrease], -1},
{"HKKey_FrameStep", 0, &HKKeyMapping[HK_FrameStep], -1, NULL, 0}, {"HKKey_FrameStep", 0, &HKKeyMapping[HK_FrameStep], -1},
{"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0}, {"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1},
{"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0}, {"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1},
{"HKJoy_Pause", 0, &HKJoyMapping[HK_Pause], -1, NULL, 0}, {"HKJoy_Pause", 0, &HKJoyMapping[HK_Pause], -1},
{"HKJoy_Reset", 0, &HKJoyMapping[HK_Reset], -1, NULL, 0}, {"HKJoy_Reset", 0, &HKJoyMapping[HK_Reset], -1},
{"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1, NULL, 0}, {"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1},
{"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1, NULL, 0}, {"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1},
{"HKJoy_FullscreenToggle", 0, &HKJoyMapping[HK_FullscreenToggle], -1, NULL, 0}, {"HKJoy_FullscreenToggle", 0, &HKJoyMapping[HK_FullscreenToggle], -1},
{"HKJoy_SwapScreens", 0, &HKJoyMapping[HK_SwapScreens], -1, NULL, 0}, {"HKJoy_SwapScreens", 0, &HKJoyMapping[HK_SwapScreens], -1},
{"HKJoy_SolarSensorDecrease", 0, &HKJoyMapping[HK_SolarSensorDecrease], -1, NULL, 0}, {"HKJoy_SolarSensorDecrease", 0, &HKJoyMapping[HK_SolarSensorDecrease], -1},
{"HKJoy_SolarSensorIncrease", 0, &HKJoyMapping[HK_SolarSensorIncrease], -1, NULL, 0}, {"HKJoy_SolarSensorIncrease", 0, &HKJoyMapping[HK_SolarSensorIncrease], -1},
{"HKJoy_FrameStep", 0, &HKJoyMapping[HK_FrameStep], -1, NULL, 0}, {"HKJoy_FrameStep", 0, &HKJoyMapping[HK_FrameStep], -1},
{"JoystickID", 0, &JoystickID, 0, NULL, 0}, {"JoystickID", 0, &JoystickID, 0},
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0}, {"WindowWidth", 0, &WindowWidth, 256},
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0}, {"WindowHeight", 0, &WindowHeight, 384},
{"WindowMax", 0, &WindowMaximized, 0, NULL, 0}, {"WindowMax", 1, &WindowMaximized, false},
{"ScreenRotation", 0, &ScreenRotation, 0, NULL, 0}, {"ScreenRotation", 0, &ScreenRotation, 0},
{"ScreenGap", 0, &ScreenGap, 0, NULL, 0}, {"ScreenGap", 0, &ScreenGap, 0},
{"ScreenLayout", 0, &ScreenLayout, 0, NULL, 0}, {"ScreenLayout", 0, &ScreenLayout, 0},
{"ScreenSwap", 0, &ScreenSwap, 0, NULL, 0}, {"ScreenSwap", 1, &ScreenSwap, false},
{"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, {"ScreenSizing", 0, &ScreenSizing, 0},
{"IntegerScaling", 0, &IntegerScaling, 0, NULL, 0}, {"IntegerScaling", 1, &IntegerScaling, false},
{"ScreenAspectTop",0, &ScreenAspectTop,0, NULL, 0}, {"ScreenAspectTop",0, &ScreenAspectTop,0},
{"ScreenAspectBot",0, &ScreenAspectBot,0, NULL, 0}, {"ScreenAspectBot",0, &ScreenAspectBot,0},
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, {"ScreenFilter", 1, &ScreenFilter, true},
{"ScreenUseGL", 0, &ScreenUseGL, 0, NULL, 0}, {"ScreenUseGL", 1, &ScreenUseGL, false},
{"ScreenVSync", 0, &ScreenVSync, 0, NULL, 0}, {"ScreenVSync", 1, &ScreenVSync, false},
{"ScreenVSyncInterval", 0, &ScreenVSyncInterval, 1, NULL, 0}, {"ScreenVSyncInterval", 0, &ScreenVSyncInterval, 1},
{"3DRenderer", 0, &_3DRenderer, 0, NULL, 0}, {"3DRenderer", 0, &_3DRenderer, 0},
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0}, {"Threaded3D", 1, &Threaded3D, true},
{"GL_ScaleFactor", 0, &GL_ScaleFactor, 1, NULL, 0}, {"GL_ScaleFactor", 0, &GL_ScaleFactor, 1},
{"GL_BetterPolygons", 0, &GL_BetterPolygons, 0, NULL, 0}, {"GL_BetterPolygons", 1, &GL_BetterPolygons, false},
{"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, {"LimitFPS", 1, &LimitFPS, true},
{"AudioSync", 0, &AudioSync, 0, NULL, 0}, {"AudioSync", 1, &AudioSync, false},
{"ShowOSD", 0, &ShowOSD, 1, NULL, 0}, {"ShowOSD", 1, &ShowOSD, true},
{"ConsoleType", 0, &ConsoleType, 0, NULL, 0}, {"ConsoleType", 0, &ConsoleType, 0},
{"DirectBoot", 0, &DirectBoot, 1, NULL, 0}, {"DirectBoot", 1, &DirectBoot, true},
#ifdef JIT_ENABLED #ifdef JIT_ENABLED
{"JIT_Enable", 0, &JIT_Enable, 0, NULL, 0}, {"JIT_Enable", 1, &JIT_Enable, false},
{"JIT_MaxBlockSize", 0, &JIT_MaxBlockSize, 32, NULL, 0}, {"JIT_MaxBlockSize", 0, &JIT_MaxBlockSize, 32},
{"JIT_BranchOptimisations", 0, &JIT_BranchOptimisations, 1, NULL, 0}, {"JIT_BranchOptimisations", 1, &JIT_BranchOptimisations, true},
{"JIT_LiteralOptimisations", 0, &JIT_LiteralOptimisations, 1, NULL, 0}, {"JIT_LiteralOptimisations", 1, &JIT_LiteralOptimisations, true},
#ifdef __APPLE__ #ifdef __APPLE__
{"JIT_FastMemory", 0, &JIT_FastMemory, 0, NULL, 0}, {"JIT_FastMemory", 1, &JIT_FastMemory, false},
#else #else
{"JIT_FastMemory", 0, &JIT_FastMemory, 1, NULL, 0}, {"JIT_FastMemory", 1, &JIT_FastMemory, true},
#endif #endif
#endif #endif
{"ExternalBIOSEnable", 0, &ExternalBIOSEnable, 0, NULL, 0}, {"ExternalBIOSEnable", 1, &ExternalBIOSEnable, false},
{"BIOS9Path", 1, BIOS9Path, 0, "", 1023}, {"BIOS9Path", 2, &BIOS9Path, ""},
{"BIOS7Path", 1, BIOS7Path, 0, "", 1023}, {"BIOS7Path", 2, &BIOS7Path, ""},
{"FirmwarePath", 1, FirmwarePath, 0, "", 1023}, {"FirmwarePath", 2, &FirmwarePath, ""},
{"DSiBIOS9Path", 1, DSiBIOS9Path, 0, "", 1023}, {"DSiBIOS9Path", 2, &DSiBIOS9Path, ""},
{"DSiBIOS7Path", 1, DSiBIOS7Path, 0, "", 1023}, {"DSiBIOS7Path", 2, &DSiBIOS7Path, ""},
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023}, {"DSiFirmwarePath", 2, &DSiFirmwarePath, ""},
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023}, {"DSiNANDPath", 2, &DSiNANDPath, ""},
{"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0}, {"DLDIEnable", 1, &DLDIEnable, false},
{"DLDISDPath", 1, DLDISDPath, 0, "dldi.bin", 1023}, {"DLDISDPath", 2, &DLDISDPath, "dldi.bin"},
{"DLDISize", 0, &DLDISize, 0, NULL, 0}, {"DLDISize", 0, &DLDISize, 0},
{"DLDIReadOnly", 0, &DLDIReadOnly, 0, NULL, 0}, {"DLDIReadOnly", 1, &DLDIReadOnly, false},
{"DLDIFolderSync", 0, &DLDIFolderSync, 0, NULL, 0}, {"DLDIFolderSync", 1, &DLDIFolderSync, false},
{"DLDIFolderPath", 1, DLDIFolderPath, 0, "", 1023}, {"DLDIFolderPath", 2, &DLDIFolderPath, ""},
{"DSiSDEnable", 0, &DSiSDEnable, 0, NULL, 0}, {"DSiSDEnable", 1, &DSiSDEnable, false},
{"DSiSDPath", 1, DSiSDPath, 0, "dsisd.bin", 1023}, {"DSiSDPath", 2, &DSiSDPath, "dsisd.bin"},
{"DSiSDSize", 0, &DSiSDSize, 0, NULL, 0}, {"DSiSDSize", 0, &DSiSDSize, 0},
{"DSiSDReadOnly", 0, &DSiSDReadOnly, 0, NULL, 0}, {"DSiSDReadOnly", 1, &DSiSDReadOnly, false},
{"DSiSDFolderSync", 0, &DSiSDFolderSync, 0, NULL, 0}, {"DSiSDFolderSync", 1, &DSiSDFolderSync, false},
{"DSiSDFolderPath", 1, DSiSDFolderPath, 0, "", 1023}, {"DSiSDFolderPath", 2, &DSiSDFolderPath, ""},
{"FirmwareOverrideSettings", 0, &FirmwareOverrideSettings, false, NULL, 0}, {"FirmwareOverrideSettings", 1, &FirmwareOverrideSettings, false},
{"FirmwareUsername", 1, FirmwareUsername, 0, "melonDS", 63}, {"FirmwareUsername", 2, &FirmwareUsername, "melonDS"},
{"FirmwareLanguage", 0, &FirmwareLanguage, 1, NULL, 0}, {"FirmwareLanguage", 0, &FirmwareLanguage, 1},
{"FirmwareBirthdayMonth", 0, &FirmwareBirthdayMonth, 0, NULL, 0}, {"FirmwareBirthdayMonth", 0, &FirmwareBirthdayMonth, 1},
{"FirmwareBirthdayDay", 0, &FirmwareBirthdayDay, 0, NULL, 0}, {"FirmwareBirthdayDay", 0, &FirmwareBirthdayDay, 1},
{"FirmwareFavouriteColour", 0, &FirmwareFavouriteColour, 0, NULL, 0}, {"FirmwareFavouriteColour", 0, &FirmwareFavouriteColour, 0},
{"FirmwareMessage", 1, FirmwareMessage, 0, "", 1023}, {"FirmwareMessage", 2, &FirmwareMessage, ""},
{"FirmwareMAC", 1, FirmwareMAC, 0, "", 17}, {"FirmwareMAC", 2, &FirmwareMAC, ""},
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0}, {"RandomizeMAC", 1, &RandomizeMAC, false},
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0}, {"SockBindAnyAddr", 1, &SocketBindAnyAddr, false},
{"LANDevice", 1, LANDevice, 0, "", 127}, {"LANDevice", 2, &LANDevice, ""},
{"DirectLAN", 0, &DirectLAN, 0, NULL, 0}, {"DirectLAN", 1, &DirectLAN, false},
{"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 0, NULL, 0}, {"SavStaRelocSRAM", 1, &SavestateRelocSRAM, false},
{"AudioInterp", 0, &AudioInterp, 0, NULL, 0}, {"AudioInterp", 0, &AudioInterp, 0},
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0}, {"AudioBitrate", 0, &AudioBitrate, 0},
{"AudioVolume", 0, &AudioVolume, 256, NULL, 0}, {"AudioVolume", 0, &AudioVolume, 256},
{"MicInputType", 0, &MicInputType, 1, NULL, 0}, {"MicInputType", 0, &MicInputType, 1},
{"MicWavPath", 1, MicWavPath, 0, "", 1023}, {"MicWavPath", 2, &MicWavPath, ""},
{"LastROMFolder", 1, LastROMFolder, 0, "", 1023}, {"LastROMFolder", 2, &LastROMFolder, ""},
{"RecentROM_0", 1, RecentROMList[0], 0, "", 1023}, {"RecentROM_0", 2, &RecentROMList[0], ""},
{"RecentROM_1", 1, RecentROMList[1], 0, "", 1023}, {"RecentROM_1", 2, &RecentROMList[1], ""},
{"RecentROM_2", 1, RecentROMList[2], 0, "", 1023}, {"RecentROM_2", 2, &RecentROMList[2], ""},
{"RecentROM_3", 1, RecentROMList[3], 0, "", 1023}, {"RecentROM_3", 2, &RecentROMList[3], ""},
{"RecentROM_4", 1, RecentROMList[4], 0, "", 1023}, {"RecentROM_4", 2, &RecentROMList[4], ""},
{"RecentROM_5", 1, RecentROMList[5], 0, "", 1023}, {"RecentROM_5", 2, &RecentROMList[5], ""},
{"RecentROM_6", 1, RecentROMList[6], 0, "", 1023}, {"RecentROM_6", 2, &RecentROMList[6], ""},
{"RecentROM_7", 1, RecentROMList[7], 0, "", 1023}, {"RecentROM_7", 2, &RecentROMList[7], ""},
{"RecentROM_8", 1, RecentROMList[8], 0, "", 1023}, {"RecentROM_8", 2, &RecentROMList[8], ""},
{"RecentROM_9", 1, RecentROMList[9], 0, "", 1023}, {"RecentROM_9", 2, &RecentROMList[9], ""},
{"EnableCheats", 0, &EnableCheats, 0, NULL, 0}, {"EnableCheats", 1, &EnableCheats, false},
{"MouseHide", 0, &MouseHide, 0, NULL, 0}, {"MouseHide", 1, &MouseHide, false},
{"MouseHideSeconds", 0, &MouseHideSeconds, 5, NULL, 0}, {"MouseHideSeconds", 0, &MouseHideSeconds, 5},
{"PauseLostFocus", 0, &PauseLostFocus, 0, NULL, 0}, {"PauseLostFocus", 1, &PauseLostFocus, false},
{"", -1, NULL, 0, NULL, 0} {"", -1, nullptr, 0}
}; };
void Load() void Load()
{ {printf("LOADZORZ\n");
ConfigEntry* entry = &ConfigFile[0]; ConfigEntry* entry = &ConfigFile[0];
for (;;) for (;;)
{ {
if (!entry->Value) break; if (!entry->Value) break;
printf("GETTING ENTRY %s %d\n", entry->Name, entry->Type);
if (entry->Type == 0) switch (entry->Type)
*(int*)entry->Value = entry->DefaultInt;
else
{ {
strncpy((char*)entry->Value, entry->DefaultStr, entry->StrLength); case 0: *(int*)entry->Value = std::get<int>(entry->Default); break;
((char*)entry->Value)[entry->StrLength] = '\0'; case 1: *(bool*)entry->Value = std::get<bool>(entry->Default); break;
case 2: *(std::string*)entry->Value = std::get<std::string>(entry->Default); break;
} }
entry++; entry++;
@ -341,10 +340,12 @@ void Load()
if (!strncmp(entry->Name, entryname, 32)) if (!strncmp(entry->Name, entryname, 32))
{ {
if (entry->Type == 0) switch (entry->Type)
*(int*)entry->Value = strtol(entryval, NULL, 10); {
else case 0: *(int*)entry->Value = strtol(entryval, NULL, 10); break;
strncpy((char*)entry->Value, entryval, entry->StrLength); case 1: *(bool*)entry->Value = strtol(entryval, NULL, 10) ? true:false; break;
case 2: *(std::string*)entry->Value = entryval; break;
}
break; break;
} }
@ -366,10 +367,12 @@ void Save()
{ {
if (!entry->Value) break; if (!entry->Value) break;
if (entry->Type == 0) switch (entry->Type)
fprintf(f, "%s=%d\r\n", entry->Name, *(int*)entry->Value); {
else case 0: fprintf(f, "%s=%d\r\n", entry->Name, *(int*)entry->Value); break;
fprintf(f, "%s=%s\r\n", entry->Name, (char*)entry->Value); case 1: fprintf(f, "%s=%d\r\n", entry->Name, *(bool*)entry->Value ? 1:0); break;
case 2: fprintf(f, "%s=%s\r\n", entry->Name, (*(std::string*)entry->Value).c_str()); break;
}
entry++; entry++;
} }

View File

@ -19,6 +19,9 @@
#ifndef PLATFORMCONFIG_H #ifndef PLATFORMCONFIG_H
#define PLATFORMCONFIG_H #define PLATFORMCONFIG_H
#include <variant>
#include <string>
enum enum
{ {
HK_Lid = 0, HK_Lid = 0,
@ -41,11 +44,9 @@ namespace Config
struct ConfigEntry struct ConfigEntry
{ {
char Name[32]; char Name[32];
int Type; int Type; // 0=int 1=bool 2=string
void* Value; void* Value; // pointer to the value variable
int DefaultInt; std::variant<int, bool, std::string> Default;
const char* DefaultStr;
int StrLength; // should be set to actual array length minus one
}; };
@ -59,99 +60,99 @@ extern int JoystickID;
extern int WindowWidth; extern int WindowWidth;
extern int WindowHeight; extern int WindowHeight;
extern int WindowMaximized; extern bool WindowMaximized;
extern int ScreenRotation; extern int ScreenRotation;
extern int ScreenGap; extern int ScreenGap;
extern int ScreenLayout; extern int ScreenLayout;
extern int ScreenSwap; extern bool ScreenSwap;
extern int ScreenSizing; extern int ScreenSizing;
extern int ScreenAspectTop; extern int ScreenAspectTop;
extern int ScreenAspectBot; extern int ScreenAspectBot;
extern int IntegerScaling; extern bool IntegerScaling;
extern int ScreenFilter; extern bool ScreenFilter;
extern int ScreenUseGL; extern bool ScreenUseGL;
extern int ScreenVSync; extern bool ScreenVSync;
extern int ScreenVSyncInterval; extern int ScreenVSyncInterval;
extern int _3DRenderer; extern int _3DRenderer;
extern int Threaded3D; extern bool Threaded3D;
extern int GL_ScaleFactor; extern int GL_ScaleFactor;
extern int GL_BetterPolygons; extern bool GL_BetterPolygons;
extern int LimitFPS; extern bool LimitFPS;
extern int AudioSync; extern bool AudioSync;
extern int ShowOSD; extern bool ShowOSD;
extern int ConsoleType; extern int ConsoleType;
extern int DirectBoot; extern bool DirectBoot;
#ifdef JIT_ENABLED #ifdef JIT_ENABLED
extern int JIT_Enable; extern bool JIT_Enable;
extern int JIT_MaxBlockSize; extern int JIT_MaxBlockSize;
extern int JIT_BranchOptimisations; extern bool JIT_BranchOptimisations;
extern int JIT_LiteralOptimisations; extern bool JIT_LiteralOptimisations;
extern int JIT_FastMemory; extern bool JIT_FastMemory;
#endif #endif
extern int ExternalBIOSEnable; extern bool ExternalBIOSEnable;
extern char BIOS9Path[1024]; extern std::string BIOS9Path;
extern char BIOS7Path[1024]; extern std::string BIOS7Path;
extern char FirmwarePath[1024]; extern std::string FirmwarePath;
extern char DSiBIOS9Path[1024]; extern std::string DSiBIOS9Path;
extern char DSiBIOS7Path[1024]; extern std::string DSiBIOS7Path;
extern char DSiFirmwarePath[1024]; extern std::string DSiFirmwarePath;
extern char DSiNANDPath[1024]; extern std::string DSiNANDPath;
extern int DLDIEnable; extern bool DLDIEnable;
extern char DLDISDPath[1024]; extern std::string DLDISDPath;
extern int DLDISize; extern int DLDISize;
extern int DLDIReadOnly; extern bool DLDIReadOnly;
extern int DLDIFolderSync; extern bool DLDIFolderSync;
extern char DLDIFolderPath[1024]; extern std::string DLDIFolderPath;
extern int DSiSDEnable; extern bool DSiSDEnable;
extern char DSiSDPath[1024]; extern std::string DSiSDPath;
extern int DSiSDSize; extern int DSiSDSize;
extern int DSiSDReadOnly; extern bool DSiSDReadOnly;
extern int DSiSDFolderSync; extern bool DSiSDFolderSync;
extern char DSiSDFolderPath[1024]; extern std::string DSiSDFolderPath;
extern int FirmwareOverrideSettings; extern bool FirmwareOverrideSettings;
extern char FirmwareUsername[64]; extern std::string FirmwareUsername;
extern int FirmwareLanguage; extern int FirmwareLanguage;
extern int FirmwareBirthdayMonth; extern int FirmwareBirthdayMonth;
extern int FirmwareBirthdayDay; extern int FirmwareBirthdayDay;
extern int FirmwareFavouriteColour; extern int FirmwareFavouriteColour;
extern char FirmwareMessage[1024]; extern std::string FirmwareMessage;
extern char FirmwareMAC[18]; extern std::string FirmwareMAC;
extern int RandomizeMAC; extern bool RandomizeMAC;
extern int SocketBindAnyAddr; extern bool SocketBindAnyAddr;
extern char LANDevice[128]; extern std::string LANDevice;
extern int DirectLAN; extern bool DirectLAN;
extern int SavestateRelocSRAM; extern bool SavestateRelocSRAM;
extern int AudioInterp; extern int AudioInterp;
extern int AudioBitrate; extern int AudioBitrate;
extern int AudioVolume; extern int AudioVolume;
extern int MicInputType; extern int MicInputType;
extern char MicWavPath[1024]; extern std::string MicWavPath;
extern char LastROMFolder[1024]; extern std::string LastROMFolder;
extern char RecentROMList[10][1024]; extern std::string RecentROMList[10];
extern int EnableCheats; extern bool EnableCheats;
extern int MouseHide; extern bool MouseHide;
extern int MouseHideSeconds; extern int MouseHideSeconds;
extern int PauseLostFocus; extern bool PauseLostFocus;
void Load(); void Load();

View File

@ -42,27 +42,27 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->chkExternalBIOS->setChecked(Config::ExternalBIOSEnable != 0); ui->chkExternalBIOS->setChecked(Config::ExternalBIOSEnable);
ui->txtBIOS9Path->setText(Config::BIOS9Path); ui->txtBIOS9Path->setText(QString::fromStdString(Config::BIOS9Path));
ui->txtBIOS7Path->setText(Config::BIOS7Path); ui->txtBIOS7Path->setText(QString::fromStdString(Config::BIOS7Path));
ui->txtFirmwarePath->setText(Config::FirmwarePath); ui->txtFirmwarePath->setText(QString::fromStdString(Config::FirmwarePath));
ui->txtDSiBIOS9Path->setText(Config::DSiBIOS9Path); ui->txtDSiBIOS9Path->setText(QString::fromStdString(Config::DSiBIOS9Path));
ui->txtDSiBIOS7Path->setText(Config::DSiBIOS7Path); ui->txtDSiBIOS7Path->setText(QString::fromStdString(Config::DSiBIOS7Path));
ui->txtDSiFirmwarePath->setText(Config::DSiFirmwarePath); ui->txtDSiFirmwarePath->setText(QString::fromStdString(Config::DSiFirmwarePath));
ui->txtDSiNANDPath->setText(Config::DSiNANDPath); ui->txtDSiNANDPath->setText(QString::fromStdString(Config::DSiNANDPath));
ui->cbxConsoleType->addItem("DS"); ui->cbxConsoleType->addItem("DS");
ui->cbxConsoleType->addItem("DSi (experimental)"); ui->cbxConsoleType->addItem("DSi (experimental)");
ui->cbxConsoleType->setCurrentIndex(Config::ConsoleType); ui->cbxConsoleType->setCurrentIndex(Config::ConsoleType);
ui->chkDirectBoot->setChecked(Config::DirectBoot != 0); ui->chkDirectBoot->setChecked(Config::DirectBoot);
#ifdef JIT_ENABLED #ifdef JIT_ENABLED
ui->chkEnableJIT->setChecked(Config::JIT_Enable != 0); ui->chkEnableJIT->setChecked(Config::JIT_Enable);
ui->chkJITBranchOptimisations->setChecked(Config::JIT_BranchOptimisations != 0); ui->chkJITBranchOptimisations->setChecked(Config::JIT_BranchOptimisations);
ui->chkJITLiteralOptimisations->setChecked(Config::JIT_LiteralOptimisations != 0); ui->chkJITLiteralOptimisations->setChecked(Config::JIT_LiteralOptimisations);
ui->chkJITFastMemory->setChecked(Config::JIT_FastMemory != 0); ui->chkJITFastMemory->setChecked(Config::JIT_FastMemory);
#ifdef __APPLE__ #ifdef __APPLE__
ui->chkJITFastMemory->setDisabled(true); ui->chkJITFastMemory->setDisabled(true);
#endif #endif
@ -101,20 +101,20 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
ui->cbxDSiSDSize->addItem(sizelbl); ui->cbxDSiSDSize->addItem(sizelbl);
} }
ui->cbDLDIEnable->setChecked(Config::DLDIEnable != 0); ui->cbDLDIEnable->setChecked(Config::DLDIEnable);
ui->txtDLDISDPath->setText(Config::DLDISDPath); ui->txtDLDISDPath->setText(QString::fromStdString(Config::DLDISDPath));
ui->cbxDLDISize->setCurrentIndex(Config::DLDISize); ui->cbxDLDISize->setCurrentIndex(Config::DLDISize);
ui->cbDLDIReadOnly->setChecked(Config::DLDIReadOnly != 0); ui->cbDLDIReadOnly->setChecked(Config::DLDIReadOnly);
ui->cbDLDIFolder->setChecked(Config::DLDIFolderSync != 0); ui->cbDLDIFolder->setChecked(Config::DLDIFolderSync);
ui->txtDLDIFolder->setText(Config::DLDIFolderPath); ui->txtDLDIFolder->setText(QString::fromStdString(Config::DLDIFolderPath));
on_cbDLDIEnable_toggled(); on_cbDLDIEnable_toggled();
ui->cbDSiSDEnable->setChecked(Config::DSiSDEnable != 0); ui->cbDSiSDEnable->setChecked(Config::DSiSDEnable);
ui->txtDSiSDPath->setText(Config::DSiSDPath); ui->txtDSiSDPath->setText(QString::fromStdString(Config::DSiSDPath));
ui->cbxDSiSDSize->setCurrentIndex(Config::DSiSDSize); ui->cbxDSiSDSize->setCurrentIndex(Config::DSiSDSize);
ui->cbDSiSDReadOnly->setChecked(Config::DSiSDReadOnly != 0); ui->cbDSiSDReadOnly->setChecked(Config::DSiSDReadOnly);
ui->cbDSiSDFolder->setChecked(Config::DSiSDFolderSync != 0); ui->cbDSiSDFolder->setChecked(Config::DSiSDFolderSync);
ui->txtDSiSDFolder->setText(Config::DSiSDFolderPath); ui->txtDSiSDFolder->setText(QString::fromStdString(Config::DSiSDFolderPath));
on_cbDSiSDEnable_toggled(); on_cbDSiSDEnable_toggled();
} }
@ -140,8 +140,7 @@ void EmuSettingsDialog::verifyFirmware()
// looked at has 0x180 bytes from the header repeated at 0x3FC80, but // looked at has 0x180 bytes from the header repeated at 0x3FC80, but
// bytes 0x0C-0x14 are different. // bytes 0x0C-0x14 are different.
char filename[1024]; std::string filename = ui->txtFirmwarePath->text().toStdString();
strncpy(filename, ui->txtFirmwarePath->text().toStdString().c_str(), 1023); filename[1023] = '\0';
FILE* f = Platform::OpenLocalFile(filename, "rb"); FILE* f = Platform::OpenLocalFile(filename, "rb");
if (!f) return; if (!f) return;
u8 chk1[0x180], chk2[0x180]; u8 chk1[0x180], chk2[0x180];
@ -175,24 +174,24 @@ void EmuSettingsDialog::done(int r)
verifyFirmware(); verifyFirmware();
int consoleType = ui->cbxConsoleType->currentIndex(); int consoleType = ui->cbxConsoleType->currentIndex();
int directBoot = ui->chkDirectBoot->isChecked() ? 1:0; bool directBoot = ui->chkDirectBoot->isChecked();
int jitEnable = ui->chkEnableJIT->isChecked() ? 1:0; bool jitEnable = ui->chkEnableJIT->isChecked();
int jitMaxBlockSize = ui->spnJITMaximumBlockSize->value(); int jitMaxBlockSize = ui->spnJITMaximumBlockSize->value();
int jitBranchOptimisations = ui->chkJITBranchOptimisations->isChecked() ? 1:0; bool jitBranchOptimisations = ui->chkJITBranchOptimisations->isChecked();
int jitLiteralOptimisations = ui->chkJITLiteralOptimisations->isChecked() ? 1:0; bool jitLiteralOptimisations = ui->chkJITLiteralOptimisations->isChecked();
int jitFastMemory = ui->chkJITFastMemory->isChecked() ? 1:0; bool jitFastMemory = ui->chkJITFastMemory->isChecked();
int externalBiosEnable = ui->chkExternalBIOS->isChecked() ? 1:0; bool externalBiosEnable = ui->chkExternalBIOS->isChecked();
std::string bios9Path = ui->txtBIOS9Path->text().toStdString(); std::string bios9Path = ui->txtBIOS9Path->text().toStdString();
std::string bios7Path = ui->txtBIOS7Path->text().toStdString(); std::string bios7Path = ui->txtBIOS7Path->text().toStdString();
std::string firmwarePath = ui->txtFirmwarePath->text().toStdString(); std::string firmwarePath = ui->txtFirmwarePath->text().toStdString();
int dldiEnable = ui->cbDLDIEnable->isChecked() ? 1:0; bool dldiEnable = ui->cbDLDIEnable->isChecked();
std::string dldiSDPath = ui->txtDLDISDPath->text().toStdString(); std::string dldiSDPath = ui->txtDLDISDPath->text().toStdString();
int dldiSize = ui->cbxDLDISize->currentIndex(); int dldiSize = ui->cbxDLDISize->currentIndex();
int dldiReadOnly = ui->cbDLDIReadOnly->isChecked() ? 1:0; bool dldiReadOnly = ui->cbDLDIReadOnly->isChecked();
int dldiFolderSync = ui->cbDLDIFolder->isChecked() ? 1:0; bool dldiFolderSync = ui->cbDLDIFolder->isChecked();
std::string dldiFolderPath = ui->txtDLDIFolder->text().toStdString(); std::string dldiFolderPath = ui->txtDLDIFolder->text().toStdString();
std::string dsiBios9Path = ui->txtDSiBIOS9Path->text().toStdString(); std::string dsiBios9Path = ui->txtDSiBIOS9Path->text().toStdString();
@ -200,11 +199,11 @@ void EmuSettingsDialog::done(int r)
std::string dsiFirmwarePath = ui->txtDSiFirmwarePath->text().toStdString(); std::string dsiFirmwarePath = ui->txtDSiFirmwarePath->text().toStdString();
std::string dsiNANDPath = ui->txtDSiNANDPath->text().toStdString(); std::string dsiNANDPath = ui->txtDSiNANDPath->text().toStdString();
int dsiSDEnable = ui->cbDSiSDEnable->isChecked() ? 1:0; bool dsiSDEnable = ui->cbDSiSDEnable->isChecked();
std::string dsiSDPath = ui->txtDSiSDPath->text().toStdString(); std::string dsiSDPath = ui->txtDSiSDPath->text().toStdString();
int dsiSDSize = ui->cbxDSiSDSize->currentIndex(); int dsiSDSize = ui->cbxDSiSDSize->currentIndex();
int dsiSDReadOnly = ui->cbDSiSDReadOnly->isChecked() ? 1:0; bool dsiSDReadOnly = ui->cbDSiSDReadOnly->isChecked();
int dsiSDFolderSync = ui->cbDSiSDFolder->isChecked() ? 1:0; bool dsiSDFolderSync = ui->cbDSiSDFolder->isChecked();
std::string dsiSDFolderPath = ui->txtDSiSDFolder->text().toStdString(); std::string dsiSDFolderPath = ui->txtDSiSDFolder->text().toStdString();
if (consoleType != Config::ConsoleType if (consoleType != Config::ConsoleType
@ -217,25 +216,25 @@ void EmuSettingsDialog::done(int r)
|| jitFastMemory != Config::JIT_FastMemory || jitFastMemory != Config::JIT_FastMemory
#endif #endif
|| externalBiosEnable != Config::ExternalBIOSEnable || externalBiosEnable != Config::ExternalBIOSEnable
|| strcmp(Config::BIOS9Path, bios9Path.c_str()) != 0 || bios9Path != Config::BIOS9Path
|| strcmp(Config::BIOS7Path, bios7Path.c_str()) != 0 || bios7Path != Config::BIOS7Path
|| strcmp(Config::FirmwarePath, firmwarePath.c_str()) != 0 || firmwarePath != Config::FirmwarePath
|| dldiEnable != Config::DLDIEnable || dldiEnable != Config::DLDIEnable
|| strcmp(Config::DLDISDPath, dldiSDPath.c_str()) != 0 || dldiSDPath != Config::DLDISDPath
|| dldiSize != Config::DLDISize || dldiSize != Config::DLDISize
|| dldiReadOnly != Config::DLDIReadOnly || dldiReadOnly != Config::DLDIReadOnly
|| dldiFolderSync != Config::DLDIFolderSync || dldiFolderSync != Config::DLDIFolderSync
|| strcmp(Config::DLDIFolderPath, dldiFolderPath.c_str()) != 0 || dldiFolderPath != Config::DLDIFolderPath
|| strcmp(Config::DSiBIOS9Path, dsiBios9Path.c_str()) != 0 || dsiBios9Path != Config::DSiBIOS9Path
|| strcmp(Config::DSiBIOS7Path, dsiBios7Path.c_str()) != 0 || dsiBios7Path != Config::DSiBIOS7Path
|| strcmp(Config::DSiFirmwarePath, dsiFirmwarePath.c_str()) != 0 || dsiFirmwarePath != Config::DSiFirmwarePath
|| strcmp(Config::DSiNANDPath, dsiNANDPath.c_str()) != 0 || dsiNANDPath != Config::DSiNANDPath
|| dsiSDEnable != Config::DSiSDEnable || dsiSDEnable != Config::DSiSDEnable
|| strcmp(Config::DSiSDPath, dsiSDPath.c_str()) != 0 || dsiSDPath != Config::DSiSDPath
|| dsiSDSize != Config::DSiSDSize || dsiSDSize != Config::DSiSDSize
|| dsiSDReadOnly != Config::DSiSDReadOnly || dsiSDReadOnly != Config::DSiSDReadOnly
|| dsiSDFolderSync != Config::DSiSDFolderSync || dsiSDFolderSync != Config::DSiSDFolderSync
|| strcmp(Config::DSiSDFolderPath, dsiSDFolderPath.c_str()) != 0) || dsiSDFolderPath != Config::DSiSDFolderPath)
{ {
if (RunningSomething if (RunningSomething
&& QMessageBox::warning(this, "Reset necessary to apply changes", && QMessageBox::warning(this, "Reset necessary to apply changes",
@ -244,28 +243,28 @@ void EmuSettingsDialog::done(int r)
return; return;
Config::ExternalBIOSEnable = externalBiosEnable; Config::ExternalBIOSEnable = externalBiosEnable;
strncpy(Config::BIOS9Path, bios9Path.c_str(), 1023); Config::BIOS9Path[1023] = '\0'; Config::BIOS9Path = bios9Path;
strncpy(Config::BIOS7Path, bios7Path.c_str(), 1023); Config::BIOS7Path[1023] = '\0'; Config::BIOS7Path = bios7Path;
strncpy(Config::FirmwarePath, firmwarePath.c_str(), 1023); Config::FirmwarePath[1023] = '\0'; Config::FirmwarePath = firmwarePath;
Config::DLDIEnable = dldiEnable; Config::DLDIEnable = dldiEnable;
strncpy(Config::DLDISDPath, dldiSDPath.c_str(), 1023); Config::DLDISDPath[1023] = '\0'; Config::DLDISDPath = dldiSDPath;
Config::DLDISize = dldiSize; Config::DLDISize = dldiSize;
Config::DLDIReadOnly = dldiReadOnly; Config::DLDIReadOnly = dldiReadOnly;
Config::DLDIFolderSync = dldiFolderSync; Config::DLDIFolderSync = dldiFolderSync;
strncpy(Config::DLDIFolderPath, dldiFolderPath.c_str(), 1023); Config::DLDIFolderPath[1023] = '\0'; Config::DLDIFolderPath = dldiFolderPath;
strncpy(Config::DSiBIOS9Path, dsiBios9Path.c_str(), 1023); Config::DSiBIOS9Path[1023] = '\0'; Config::DSiBIOS9Path = dsiBios9Path;
strncpy(Config::DSiBIOS7Path, dsiBios7Path.c_str(), 1023); Config::DSiBIOS7Path[1023] = '\0'; Config::DSiBIOS7Path = dsiBios7Path;
strncpy(Config::DSiFirmwarePath, dsiFirmwarePath.c_str(), 1023); Config::DSiFirmwarePath[1023] = '\0'; Config::DSiFirmwarePath = dsiFirmwarePath;
strncpy(Config::DSiNANDPath, dsiNANDPath.c_str(), 1023); Config::DSiNANDPath[1023] = '\0'; Config::DSiNANDPath = dsiNANDPath;
Config::DSiSDEnable = dsiSDEnable; Config::DSiSDEnable = dsiSDEnable;
strncpy(Config::DSiSDPath, dsiSDPath.c_str(), 1023); Config::DSiSDPath[1023] = '\0'; Config::DSiSDPath = dsiSDPath;
Config::DSiSDSize = dsiSDSize; Config::DSiSDSize = dsiSDSize;
Config::DSiSDReadOnly = dsiSDReadOnly; Config::DSiSDReadOnly = dsiSDReadOnly;
Config::DSiSDFolderSync = dsiSDFolderSync; Config::DSiSDFolderSync = dsiSDFolderSync;
strncpy(Config::DSiSDFolderPath, dsiSDFolderPath.c_str(), 1023); Config::DSiSDFolderPath[1023] = '\0'; Config::DSiSDFolderPath = dsiSDFolderPath;
#ifdef JIT_ENABLED #ifdef JIT_ENABLED
Config::JIT_Enable = jitEnable; Config::JIT_Enable = jitEnable;

View File

@ -35,7 +35,7 @@ FirmwareSettingsDialog::FirmwareSettingsDialog(QWidget* parent) : QDialog(parent
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->usernameEdit->setText(Config::FirmwareUsername); ui->usernameEdit->setText(QString::fromStdString(Config::FirmwareUsername));
ui->languageBox->addItems(languages); ui->languageBox->addItems(languages);
ui->languageBox->setCurrentIndex(Config::FirmwareLanguage); ui->languageBox->setCurrentIndex(Config::FirmwareLanguage);
@ -59,12 +59,12 @@ FirmwareSettingsDialog::FirmwareSettingsDialog(QWidget* parent) : QDialog(parent
} }
ui->colorsEdit->setCurrentIndex(Config::FirmwareFavouriteColour); ui->colorsEdit->setCurrentIndex(Config::FirmwareFavouriteColour);
ui->messageEdit->setText(Config::FirmwareMessage); ui->messageEdit->setText(QString::fromStdString(Config::FirmwareMessage));
ui->overrideFirmwareBox->setChecked(Config::FirmwareOverrideSettings); ui->overrideFirmwareBox->setChecked(Config::FirmwareOverrideSettings);
ui->txtMAC->setText(Config::FirmwareMAC); ui->txtMAC->setText(QString::fromStdString(Config::FirmwareMAC));
ui->cbRandomizeMAC->setChecked(Config::RandomizeMAC != 0); ui->cbRandomizeMAC->setChecked(Config::RandomizeMAC);
on_cbRandomizeMAC_toggled(); on_cbRandomizeMAC_toggled();
} }
@ -123,7 +123,7 @@ void FirmwareSettingsDialog::done(int r)
return; return;
} }
int newOverride = ui->overrideFirmwareBox->isChecked(); bool newOverride = ui->overrideFirmwareBox->isChecked();
std::string newName = ui->usernameEdit->text().toStdString(); std::string newName = ui->usernameEdit->text().toStdString();
int newLanguage = ui->languageBox->currentIndex(); int newLanguage = ui->languageBox->currentIndex();
@ -133,16 +133,16 @@ void FirmwareSettingsDialog::done(int r)
std::string newMessage = ui->messageEdit->text().toStdString(); std::string newMessage = ui->messageEdit->text().toStdString();
std::string newMAC = ui->txtMAC->text().toStdString(); std::string newMAC = ui->txtMAC->text().toStdString();
int newRandomizeMAC = ui->cbRandomizeMAC->isChecked() ? 1:0; bool newRandomizeMAC = ui->cbRandomizeMAC->isChecked();
if ( newOverride != Config::FirmwareOverrideSettings if ( newOverride != Config::FirmwareOverrideSettings
|| strcmp(newName.c_str(), Config::FirmwareUsername) != 0 || newName != Config::FirmwareUsername
|| newLanguage != Config::FirmwareLanguage || newLanguage != Config::FirmwareLanguage
|| newFavColor != Config::FirmwareFavouriteColour || newFavColor != Config::FirmwareFavouriteColour
|| newBirthdayDay != Config::FirmwareBirthdayDay || newBirthdayDay != Config::FirmwareBirthdayDay
|| newBirthdayMonth != Config::FirmwareBirthdayMonth || newBirthdayMonth != Config::FirmwareBirthdayMonth
|| strcmp(newMessage.c_str(), Config::FirmwareMessage) != 0 || newMessage != Config::FirmwareMessage
|| strcmp(newMAC.c_str(), Config::FirmwareMAC) != 0 || newMAC != Config::FirmwareMAC
|| newRandomizeMAC != Config::RandomizeMAC) || newRandomizeMAC != Config::RandomizeMAC)
{ {
if (RunningSomething if (RunningSomething
@ -153,14 +153,14 @@ void FirmwareSettingsDialog::done(int r)
Config::FirmwareOverrideSettings = newOverride; Config::FirmwareOverrideSettings = newOverride;
strncpy(Config::FirmwareUsername, newName.c_str(), 63); Config::FirmwareUsername[63] = '\0'; Config::FirmwareUsername = newName;
Config::FirmwareLanguage = newLanguage; Config::FirmwareLanguage = newLanguage;
Config::FirmwareFavouriteColour = newFavColor; Config::FirmwareFavouriteColour = newFavColor;
Config::FirmwareBirthdayDay = newBirthdayDay; Config::FirmwareBirthdayDay = newBirthdayDay;
Config::FirmwareBirthdayMonth = newBirthdayMonth; Config::FirmwareBirthdayMonth = newBirthdayMonth;
strncpy(Config::FirmwareMessage, newMessage.c_str(), 1023); Config::FirmwareMessage[1023] = '\0'; Config::FirmwareMessage = newMessage;
strncpy(Config::FirmwareMAC, newMAC.c_str(), 17); Config::FirmwareMAC[17] = '\0'; Config::FirmwareMAC = newMAC;
Config::RandomizeMAC = newRandomizeMAC; Config::RandomizeMAC = newRandomizeMAC;
Config::Save(); Config::Save();

View File

@ -318,7 +318,7 @@ bool Init(bool open_adapter)
PCapAdapterData = &Adapters[0]; PCapAdapterData = &Adapters[0];
for (int i = 0; i < NumAdapters; i++) for (int i = 0; i < NumAdapters; i++)
{ {
if (!strncmp(Adapters[i].DeviceName, Config::LANDevice, 128)) if (!strncmp(Adapters[i].DeviceName, Config::LANDevice.c_str(), 128))
PCapAdapterData = &Adapters[i]; PCapAdapterData = &Adapters[i];
} }

View File

@ -207,7 +207,7 @@ bool GetConfigArray(ConfigEntry entry, void* data)
{ {
case Firm_MAC: case Firm_MAC:
{ {
char* mac_in = Config::FirmwareMAC; std::string& mac_in = Config::FirmwareMAC;
u8* mac_out = (u8*)data; u8* mac_out = (u8*)data;
int o = 0; int o = 0;

View File

@ -130,7 +130,7 @@ void ROMInfoDialog::on_saveIconButton_clicked()
{ {
QString filename = QFileDialog::getSaveFileName(this, QString filename = QFileDialog::getSaveFileName(this,
"Save Icon", "Save Icon",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"PNG Images (*.png)"); "PNG Images (*.png)");
if (filename.isEmpty()) if (filename.isEmpty())
return; return;

View File

@ -55,7 +55,7 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
ui->rbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)"); ui->rbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)");
ui->cbBindAnyAddr->setChecked(Config::SocketBindAnyAddr != 0); ui->cbBindAnyAddr->setChecked(Config::SocketBindAnyAddr);
int sel = 0; int sel = 0;
for (int i = 0; i < LAN_PCap::NumAdapters; i++) for (int i = 0; i < LAN_PCap::NumAdapters; i++)
@ -64,13 +64,14 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
ui->cbxDirectAdapter->addItem(QString(adapter->FriendlyName)); ui->cbxDirectAdapter->addItem(QString(adapter->FriendlyName));
if (!strncmp(adapter->DeviceName, Config::LANDevice, 128)) if (!strncmp(adapter->DeviceName, Config::LANDevice.c_str(), 128))
sel = i; sel = i;
} }
ui->cbxDirectAdapter->setCurrentIndex(sel); ui->cbxDirectAdapter->setCurrentIndex(sel);
ui->rbDirectMode->setChecked(Config::DirectLAN != 0); // errrr???
ui->rbIndirectMode->setChecked(Config::DirectLAN == 0); ui->rbDirectMode->setChecked(Config::DirectLAN);
ui->rbIndirectMode->setChecked(!Config::DirectLAN);
if (!haspcap) ui->rbDirectMode->setEnabled(false); if (!haspcap) ui->rbDirectMode->setEnabled(false);
updateAdapterControls(); updateAdapterControls();
@ -87,19 +88,18 @@ void WifiSettingsDialog::done(int r)
if (r == QDialog::Accepted) if (r == QDialog::Accepted)
{ {
Config::SocketBindAnyAddr = ui->cbBindAnyAddr->isChecked() ? 1:0; Config::SocketBindAnyAddr = ui->cbBindAnyAddr->isChecked();
Config::DirectLAN = ui->rbDirectMode->isChecked() ? 1:0; Config::DirectLAN = ui->rbDirectMode->isChecked();
int sel = ui->cbxDirectAdapter->currentIndex(); int sel = ui->cbxDirectAdapter->currentIndex();
if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0; if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0;
if (LAN_PCap::NumAdapters < 1) if (LAN_PCap::NumAdapters < 1)
{ {
Config::LANDevice[0] = '\0'; Config::LANDevice = "";
} }
else else
{ {
strncpy(Config::LANDevice, LAN_PCap::Adapters[sel].DeviceName, 127); Config::LANDevice = LAN_PCap::Adapters[sel].DeviceName;
Config::LANDevice[127] = '\0';
} }
Config::Save(); Config::Save();

View File

@ -181,7 +181,7 @@ void micClose()
micDevice = 0; micDevice = 0;
} }
void micLoadWav(const char* name) void micLoadWav(std::string name)
{ {
SDL_AudioSpec format; SDL_AudioSpec format;
memset(&format, 0, sizeof(SDL_AudioSpec)); memset(&format, 0, sizeof(SDL_AudioSpec));
@ -192,7 +192,7 @@ void micLoadWav(const char* name)
u8* buf; u8* buf;
u32 len; u32 len;
if (!SDL_LoadWAV(name, &format, &buf, &len)) if (!SDL_LoadWAV(name.c_str(), &format, &buf, &len))
return; return;
const u64 dstfreq = 44100; const u64 dstfreq = 44100;
@ -1274,7 +1274,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
oldW = Config::WindowWidth; oldW = Config::WindowWidth;
oldH = Config::WindowHeight; oldH = Config::WindowHeight;
oldMax = Config::WindowMaximized!=0; oldMax = Config::WindowMaximized;
setWindowTitle("melonDS " MELONDS_VERSION); setWindowTitle("melonDS " MELONDS_VERSION);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -1295,9 +1295,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
recentMenu = menu->addMenu("Open recent"); recentMenu = menu->addMenu("Open recent");
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
char* item = Config::RecentROMList[i]; std::string item = Config::RecentROMList[i];
if (strlen(item) > 0) if (!item.empty())
recentFileList.push_back(item); recentFileList.push_back(QString::fromStdString(item));
} }
updateRecentFilesMenu(); updateRecentFilesMenu();
@ -1591,13 +1591,13 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actFrameStep->setEnabled(false); actFrameStep->setEnabled(false);
actSetupCheats->setEnabled(false); actSetupCheats->setEnabled(false);
actTitleManager->setEnabled(strlen(Config::DSiNANDPath) > 0); actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
actEnableCheats->setChecked(Config::EnableCheats != 0); actEnableCheats->setChecked(Config::EnableCheats);
actROMInfo->setEnabled(false); actROMInfo->setEnabled(false);
actSavestateSRAMReloc->setChecked(Config::SavestateRelocSRAM != 0); actSavestateSRAMReloc->setChecked(Config::SavestateRelocSRAM);
actScreenRotation[Config::ScreenRotation]->setChecked(true); actScreenRotation[Config::ScreenRotation]->setChecked(true);
@ -1612,18 +1612,18 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actScreenLayout[Config::ScreenLayout]->setChecked(true); actScreenLayout[Config::ScreenLayout]->setChecked(true);
actScreenSizing[Config::ScreenSizing]->setChecked(true); actScreenSizing[Config::ScreenSizing]->setChecked(true);
actIntegerScaling->setChecked(Config::IntegerScaling != 0); actIntegerScaling->setChecked(Config::IntegerScaling);
actScreenSwap->setChecked(Config::ScreenSwap != 0); actScreenSwap->setChecked(Config::ScreenSwap);
actScreenAspectTop[Config::ScreenAspectTop]->setChecked(true); actScreenAspectTop[Config::ScreenAspectTop]->setChecked(true);
actScreenAspectBot[Config::ScreenAspectBot]->setChecked(true); actScreenAspectBot[Config::ScreenAspectBot]->setChecked(true);
actScreenFiltering->setChecked(Config::ScreenFilter != 0); actScreenFiltering->setChecked(Config::ScreenFilter);
actShowOSD->setChecked(Config::ShowOSD != 0); actShowOSD->setChecked(Config::ShowOSD);
actLimitFramerate->setChecked(Config::LimitFPS != 0); actLimitFramerate->setChecked(Config::LimitFPS);
actAudioSync->setChecked(Config::AudioSync != 0); actAudioSync->setChecked(Config::AudioSync);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -1885,7 +1885,7 @@ void MainWindow::loadROM(QByteArray *romData, QString archiveFileName, QString r
updateRecentFilesMenu(); updateRecentFilesMenu();
// Strip entire archive name and get folder path // Strip entire archive name and get folder path
strncpy(Config::LastROMFolder, QFileInfo(archiveFileName).absolutePath().toStdString().c_str(), 1024); Config::LastROMFolder = QFileInfo(archiveFileName).absolutePath().toStdString();
QString sramFileName = QFileInfo(archiveFileName).absolutePath() + QDir::separator() + QFileInfo(romFileName).completeBaseName() + ".sav"; QString sramFileName = QFileInfo(archiveFileName).absolutePath() + QDir::separator() + QFileInfo(romFileName).completeBaseName() + ".sav";
@ -1937,26 +1937,23 @@ void MainWindow::loadROM(QString filename)
// * ensure the binary offsets are sane // * ensure the binary offsets are sane
// * etc // * etc
// this shit is stupid std::string file = filename.toStdString();
char file[1024]; int pos = file.length() - 1;
strncpy(file, filename.toStdString().c_str(), 1023); file[1023] = '\0';
int pos = strlen(file)-1;
while (file[pos] != '/' && file[pos] != '\\' && pos > 0) pos--; while (file[pos] != '/' && file[pos] != '\\' && pos > 0) pos--;
strncpy(Config::LastROMFolder, file, pos); Config::LastROMFolder = file.substr(0, pos);
Config::LastROMFolder[pos] = '\0';
char* ext = &file[strlen(file)-3]; std::string ext = file.substr(file.length() - 3);
int slot; int res; int slot; int res;
if (!strcasecmp(ext, "gba")) if (ext == "gba")
{ {
slot = 1; slot = 1;
res = Frontend::LoadROM(file, Frontend::ROMSlot_GBA); res = Frontend::LoadROM(file.c_str(), Frontend::ROMSlot_GBA);
} }
else else
{ {
slot = 0; slot = 0;
res = Frontend::LoadROM(file, Frontend::ROMSlot_NDS); res = Frontend::LoadROM(file.c_str(), Frontend::ROMSlot_NDS);
} }
if (res != Frontend::Load_OK) if (res != Frontend::Load_OK)
@ -1983,7 +1980,7 @@ void MainWindow::onOpenFile()
QString filename = QFileDialog::getOpenFileName(this, QString filename = QFileDialog::getOpenFileName(this,
"Open ROM", "Open ROM",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"DS ROMs (*.nds *.dsi *.srl);;GBA ROMs (*.gba *.zip);;Any file (*.*)"); "DS ROMs (*.nds *.dsi *.srl);;GBA ROMs (*.gba *.zip);;Any file (*.*)");
if (filename.isEmpty()) if (filename.isEmpty())
{ {
@ -2000,7 +1997,7 @@ void MainWindow::onOpenFileArchive()
QString archiveFileName = QFileDialog::getOpenFileName(this, QString archiveFileName = QFileDialog::getOpenFileName(this,
"Open ROM Archive", "Open ROM Archive",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"Archived ROMs (*.zip *.7z *.rar *.tar *.tar.gz *.tar.xz *.tar.bz2);;Any file (*.*)"); "Archived ROMs (*.zip *.7z *.rar *.tar *.tar.gz *.tar.xz *.tar.bz2);;Any file (*.*)");
if (archiveFileName.isEmpty()) if (archiveFileName.isEmpty())
{ {
@ -2073,7 +2070,8 @@ QString MainWindow::pickAndExtractFileFromArchive(QString archiveFileName, QByte
void MainWindow::onClearRecentFiles() void MainWindow::onClearRecentFiles()
{ {
recentFileList.clear(); recentFileList.clear();
memset(Config::RecentROMList, 0, 10 * 1024); for (int i = 0; i < 10; i++)
Config::RecentROMList[i] = "";
updateRecentFilesMenu(); updateRecentFilesMenu();
} }
@ -2109,8 +2107,8 @@ void MainWindow::updateRecentFilesMenu()
actRecentFile_i->setData(item_full); actRecentFile_i->setData(item_full);
connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile); connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile);
if(i < 10) if (i < 10)
strncpy(Config::RecentROMList[i], recentFileList.at(i).toStdString().c_str(), 1024); Config::RecentROMList[i] = recentFileList.at(i).toStdString();
} }
recentMenu->addSeparator(); recentMenu->addSeparator();
@ -2177,17 +2175,17 @@ void MainWindow::onSaveState()
emuThread->emuPause(); emuThread->emuPause();
char filename[1024]; std::string filename;
if (slot > 0) if (slot > 0)
{ {
Frontend::GetSavestateName(slot, filename, 1024); filename = Frontend::GetSavestateName(slot);
} }
else else
{ {
// TODO: specific 'last directory' for savestate files? // TODO: specific 'last directory' for savestate files?
QString qfilename = QFileDialog::getSaveFileName(this, QString qfilename = QFileDialog::getSaveFileName(this,
"Save state", "Save state",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"melonDS savestates (*.mln);;Any file (*.*)"); "melonDS savestates (*.mln);;Any file (*.*)");
if (qfilename.isEmpty()) if (qfilename.isEmpty())
{ {
@ -2195,7 +2193,7 @@ void MainWindow::onSaveState()
return; return;
} }
strncpy(filename, qfilename.toStdString().c_str(), 1023); filename[1023] = '\0'; filename = qfilename.toStdString();
} }
if (Frontend::SaveState(filename)) if (Frontend::SaveState(filename))
@ -2221,17 +2219,17 @@ void MainWindow::onLoadState()
emuThread->emuPause(); emuThread->emuPause();
char filename[1024]; std::string filename;
if (slot > 0) if (slot > 0)
{ {
Frontend::GetSavestateName(slot, filename, 1024); filename = Frontend::GetSavestateName(slot);
} }
else else
{ {
// TODO: specific 'last directory' for savestate files? // TODO: specific 'last directory' for savestate files?
QString qfilename = QFileDialog::getOpenFileName(this, QString qfilename = QFileDialog::getOpenFileName(this,
"Load state", "Load state",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"melonDS savestates (*.ml*);;Any file (*.*)"); "melonDS savestates (*.ml*);;Any file (*.*)");
if (qfilename.isEmpty()) if (qfilename.isEmpty())
{ {
@ -2239,7 +2237,7 @@ void MainWindow::onLoadState()
return; return;
} }
strncpy(filename, qfilename.toStdString().c_str(), 1023); filename[1023] = '\0'; filename = qfilename.toStdString();
} }
if (!Platform::FileExists(filename)) if (!Platform::FileExists(filename))
@ -2286,7 +2284,7 @@ void MainWindow::onImportSavefile()
emuThread->emuPause(); emuThread->emuPause();
QString path = QFileDialog::getOpenFileName(this, QString path = QFileDialog::getOpenFileName(this,
"Select savefile", "Select savefile",
Config::LastROMFolder, QString::fromStdString(Config::LastROMFolder),
"Savefiles (*.sav *.bin *.dsv);;Any file (*.*)"); "Savefiles (*.sav *.bin *.dsv);;Any file (*.*)");
if (!path.isEmpty()) if (!path.isEmpty())
@ -2424,7 +2422,7 @@ void MainWindow::onEmuSettingsDialogFinished(int res)
onReset(); onReset();
if (!RunningSomething) if (!RunningSomething)
actTitleManager->setEnabled(strlen(Config::DSiNANDPath) > 0); actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
} }
void MainWindow::onOpenInputConfig() void MainWindow::onOpenInputConfig()
@ -2736,7 +2734,7 @@ void MainWindow::onEmuStop()
actFrameStep->setEnabled(false); actFrameStep->setEnabled(false);
actSetupCheats->setEnabled(false); actSetupCheats->setEnabled(false);
actTitleManager->setEnabled(strlen(Config::DSiNANDPath) > 0); actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
actROMInfo->setEnabled(false); actROMInfo->setEnabled(false);
} }