mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
decouple more config shit from the core. bahahah
This commit is contained in:
@ -28,28 +28,12 @@ namespace Config
|
|||||||
|
|
||||||
const char* kConfigFile = "melonDS.ini";
|
const char* kConfigFile = "melonDS.ini";
|
||||||
|
|
||||||
char FirmwareUsername[64];
|
|
||||||
int FirmwareLanguage;
|
|
||||||
bool FirmwareOverrideSettings;
|
|
||||||
int FirmwareBirthdayMonth;
|
|
||||||
int FirmwareBirthdayDay;
|
|
||||||
int FirmwareFavouriteColour;
|
|
||||||
char FirmwareMessage[1024];
|
|
||||||
|
|
||||||
int RandomizeMAC;
|
|
||||||
int AudioBitrate;
|
int AudioBitrate;
|
||||||
|
|
||||||
ConfigEntry ConfigFile[] =
|
ConfigEntry ConfigFile[] =
|
||||||
{
|
{
|
||||||
{"FirmwareUsername", 1, FirmwareUsername, 0, "melonDS", 63},
|
|
||||||
{"FirmwareLanguage", 0, &FirmwareLanguage, 1, NULL, 0},
|
|
||||||
{"FirmwareOverrideSettings", 0, &FirmwareOverrideSettings, false, NULL, 0},
|
|
||||||
{"FirmwareBirthdayMonth", 0, &FirmwareBirthdayMonth, 0, NULL, 0},
|
|
||||||
{"FirmwareBirthdayDay", 0, &FirmwareBirthdayDay, 0, NULL, 0},
|
|
||||||
{"FirmwareFavouriteColour", 0, &FirmwareFavouriteColour, 0, NULL, 0},
|
|
||||||
{"FirmwareMessage", 1, FirmwareMessage, 0, "", 1023},
|
|
||||||
|
|
||||||
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
|
||||||
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
|
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
|
||||||
|
|
||||||
{"", -1, NULL, 0, NULL, 0}
|
{"", -1, NULL, 0, NULL, 0}
|
||||||
|
@ -41,15 +41,7 @@ bool HasConfigFile(const char* fileName);
|
|||||||
void Load();
|
void Load();
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
extern char FirmwareUsername[64];
|
|
||||||
extern int FirmwareLanguage;
|
|
||||||
extern bool FirmwareOverrideSettings;
|
|
||||||
extern int FirmwareBirthdayMonth;
|
|
||||||
extern int FirmwareBirthdayDay;
|
|
||||||
extern int FirmwareFavouriteColour;
|
|
||||||
extern char FirmwareMessage[1024];
|
|
||||||
|
|
||||||
extern int RandomizeMAC;
|
|
||||||
extern int AudioBitrate;
|
extern int AudioBitrate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,15 @@ enum ConfigEntry
|
|||||||
DSiSD_ReadOnly,
|
DSiSD_ReadOnly,
|
||||||
DSiSD_FolderSync,
|
DSiSD_FolderSync,
|
||||||
DSiSD_FolderPath,
|
DSiSD_FolderPath,
|
||||||
|
|
||||||
|
Firm_RandomizeMAC,
|
||||||
|
Firm_OverrideSettings,
|
||||||
|
Firm_Username,
|
||||||
|
Firm_Language,
|
||||||
|
Firm_BirthdayMonth,
|
||||||
|
Firm_BirthdayDay,
|
||||||
|
Firm_Color,
|
||||||
|
Firm_Message,
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetConfigInt(ConfigEntry entry);
|
int GetConfigInt(ConfigEntry entry);
|
||||||
|
19
src/SPI.cpp
19
src/SPI.cpp
@ -23,7 +23,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include "Config.h"
|
|
||||||
#include "NDS.h"
|
#include "NDS.h"
|
||||||
#include "DSi.h"
|
#include "DSi.h"
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
@ -171,23 +170,25 @@ void LoadFirmwareFromFile(FILE* f)
|
|||||||
void LoadUserSettingsFromConfig()
|
void LoadUserSettingsFromConfig()
|
||||||
{
|
{
|
||||||
// setting up username
|
// setting up username
|
||||||
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(Config::FirmwareUsername);
|
std::string orig_username = Platform::GetConfigString(Platform::Firm_Username);
|
||||||
|
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(orig_username);
|
||||||
size_t usernameLength = std::min(username.length(), (size_t) 10);
|
size_t usernameLength = std::min(username.length(), (size_t) 10);
|
||||||
memcpy(Firmware + UserSettings + 0x06, username.data(), usernameLength * sizeof(char16_t));
|
memcpy(Firmware + UserSettings + 0x06, username.data(), usernameLength * sizeof(char16_t));
|
||||||
Firmware[UserSettings+0x1A] = usernameLength;
|
Firmware[UserSettings+0x1A] = usernameLength;
|
||||||
|
|
||||||
// setting language
|
// setting language
|
||||||
Firmware[UserSettings+0x64] = Config::FirmwareLanguage;
|
Firmware[UserSettings+0x64] = Platform::GetConfigInt(Platform::Firm_Language);
|
||||||
|
|
||||||
// setting up color
|
// setting up color
|
||||||
Firmware[UserSettings+0x02] = Config::FirmwareFavouriteColour;
|
Firmware[UserSettings+0x02] = Platform::GetConfigInt(Platform::Firm_Color);
|
||||||
|
|
||||||
// setting up birthday
|
// setting up birthday
|
||||||
Firmware[UserSettings+0x03] = Config::FirmwareBirthdayMonth;
|
Firmware[UserSettings+0x03] = Platform::GetConfigInt(Platform::Firm_BirthdayMonth);
|
||||||
Firmware[UserSettings+0x04] = Config::FirmwareBirthdayDay;
|
Firmware[UserSettings+0x04] = Platform::GetConfigInt(Platform::Firm_BirthdayDay);
|
||||||
|
|
||||||
// setup message
|
// setup message
|
||||||
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(Config::FirmwareMessage);
|
std::string orig_message = Platform::GetConfigString(Platform::Firm_Message);
|
||||||
|
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(orig_message);
|
||||||
size_t messageLength = std::min(message.length(), (size_t) 26);
|
size_t messageLength = std::min(message.length(), (size_t) 26);
|
||||||
memcpy(Firmware + UserSettings + 0x1C, message.data(), messageLength * sizeof(char16_t));
|
memcpy(Firmware + UserSettings + 0x1C, message.data(), messageLength * sizeof(char16_t));
|
||||||
Firmware[UserSettings+0x50] = messageLength;
|
Firmware[UserSettings+0x50] = messageLength;
|
||||||
@ -225,7 +226,7 @@ void Reset()
|
|||||||
|
|
||||||
UserSettings = userdata;
|
UserSettings = userdata;
|
||||||
|
|
||||||
if (!f || Config::FirmwareOverrideSettings)
|
if (!f || Platform::GetConfigBool(Platform::Firm_OverrideSettings))
|
||||||
LoadUserSettingsFromConfig();
|
LoadUserSettingsFromConfig();
|
||||||
|
|
||||||
// fix touchscreen coords
|
// fix touchscreen coords
|
||||||
@ -243,7 +244,7 @@ void Reset()
|
|||||||
|
|
||||||
*(u16*)&Firmware[userdata+0x72] = CRC16(&Firmware[userdata], 0x70, 0xFFFF);
|
*(u16*)&Firmware[userdata+0x72] = CRC16(&Firmware[userdata], 0x70, 0xFFFF);
|
||||||
|
|
||||||
if (Config::RandomizeMAC)
|
if (Platform::GetConfigBool(Platform::Firm_RandomizeMAC))
|
||||||
{
|
{
|
||||||
// replace MAC address with random address
|
// replace MAC address with random address
|
||||||
Firmware[0x36] = 0x00;
|
Firmware[0x36] = 0x00;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "PlatformConfig.h"
|
||||||
#include "FirmwareSettingsDialog.h"
|
#include "FirmwareSettingsDialog.h"
|
||||||
#include "ui_FirmwareSettingsDialog.h"
|
#include "ui_FirmwareSettingsDialog.h"
|
||||||
|
|
||||||
|
@ -135,6 +135,11 @@ int GetConfigInt(ConfigEntry entry)
|
|||||||
case DLDI_ImageSize: return imgsizes[Config::DLDISize];
|
case DLDI_ImageSize: return imgsizes[Config::DLDISize];
|
||||||
|
|
||||||
case DSiSD_ImageSize: return imgsizes[Config::DSiSDSize];
|
case DSiSD_ImageSize: return imgsizes[Config::DSiSDSize];
|
||||||
|
|
||||||
|
case Firm_Language: return Config::FirmwareLanguage;
|
||||||
|
case Firm_BirthdayMonth: return Config::FirmwareBirthdayMonth;
|
||||||
|
case Firm_BirthdayDay: return Config::FirmwareBirthdayDay;
|
||||||
|
case Firm_Color: return Config::FirmwareFavouriteColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -160,6 +165,9 @@ bool GetConfigBool(ConfigEntry entry)
|
|||||||
case DSiSD_Enable: return Config::DSiSDEnable != 0;
|
case DSiSD_Enable: return Config::DSiSDEnable != 0;
|
||||||
case DSiSD_ReadOnly: return Config::DSiSDReadOnly != 0;
|
case DSiSD_ReadOnly: return Config::DSiSDReadOnly != 0;
|
||||||
case DSiSD_FolderSync: return Config::DSiSDFolderSync != 0;
|
case DSiSD_FolderSync: return Config::DSiSDFolderSync != 0;
|
||||||
|
|
||||||
|
case Firm_RandomizeMAC: return Config::RandomizeMAC != 0;
|
||||||
|
case Firm_OverrideSettings: return Config::FirmwareOverrideSettings != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -183,6 +191,9 @@ std::string GetConfigString(ConfigEntry entry)
|
|||||||
|
|
||||||
case DSiSD_ImagePath: return Config::DSiSDPath;
|
case DSiSD_ImagePath: return Config::DSiSDPath;
|
||||||
case DSiSD_FolderPath: return Config::DSiSDFolderPath;
|
case DSiSD_FolderPath: return Config::DSiSDFolderPath;
|
||||||
|
|
||||||
|
case Firm_Username: return Config::FirmwareUsername;
|
||||||
|
case Firm_Message: return Config::FirmwareMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -96,6 +96,15 @@ int DSiSDReadOnly;
|
|||||||
int DSiSDFolderSync;
|
int DSiSDFolderSync;
|
||||||
char DSiSDFolderPath[1024];
|
char DSiSDFolderPath[1024];
|
||||||
|
|
||||||
|
int RandomizeMAC;
|
||||||
|
bool FirmwareOverrideSettings;
|
||||||
|
char FirmwareUsername[64];
|
||||||
|
int FirmwareLanguage;
|
||||||
|
int FirmwareBirthdayMonth;
|
||||||
|
int FirmwareBirthdayDay;
|
||||||
|
int FirmwareFavouriteColour;
|
||||||
|
char FirmwareMessage[1024];
|
||||||
|
|
||||||
int SocketBindAnyAddr;
|
int SocketBindAnyAddr;
|
||||||
char LANDevice[128];
|
char LANDevice[128];
|
||||||
int DirectLAN;
|
int DirectLAN;
|
||||||
@ -242,6 +251,15 @@ ConfigEntry PlatformConfigFile[] =
|
|||||||
{"DSiSDFolderSync", 0, &DSiSDFolderSync, 0, NULL, 0},
|
{"DSiSDFolderSync", 0, &DSiSDFolderSync, 0, NULL, 0},
|
||||||
{"DSiSDFolderPath", 1, DSiSDFolderPath, 0, "", 1023},
|
{"DSiSDFolderPath", 1, DSiSDFolderPath, 0, "", 1023},
|
||||||
|
|
||||||
|
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
||||||
|
{"FirmwareOverrideSettings", 0, &FirmwareOverrideSettings, false, NULL, 0},
|
||||||
|
{"FirmwareUsername", 1, FirmwareUsername, 0, "melonDS", 63},
|
||||||
|
{"FirmwareLanguage", 0, &FirmwareLanguage, 1, NULL, 0},
|
||||||
|
{"FirmwareBirthdayMonth", 0, &FirmwareBirthdayMonth, 0, NULL, 0},
|
||||||
|
{"FirmwareBirthdayDay", 0, &FirmwareBirthdayDay, 0, NULL, 0},
|
||||||
|
{"FirmwareFavouriteColour", 0, &FirmwareFavouriteColour, 0, NULL, 0},
|
||||||
|
{"FirmwareMessage", 1, FirmwareMessage, 0, "", 1023},
|
||||||
|
|
||||||
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
|
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
|
||||||
{"LANDevice", 1, LANDevice, 0, "", 127},
|
{"LANDevice", 1, LANDevice, 0, "", 127},
|
||||||
{"DirectLAN", 0, &DirectLAN, 0, NULL, 0},
|
{"DirectLAN", 0, &DirectLAN, 0, NULL, 0},
|
||||||
|
@ -112,6 +112,15 @@ extern int DSiSDReadOnly;
|
|||||||
extern int DSiSDFolderSync;
|
extern int DSiSDFolderSync;
|
||||||
extern char DSiSDFolderPath[1024];
|
extern char DSiSDFolderPath[1024];
|
||||||
|
|
||||||
|
extern int RandomizeMAC;
|
||||||
|
extern bool FirmwareOverrideSettings;
|
||||||
|
extern char FirmwareUsername[64];
|
||||||
|
extern int FirmwareLanguage;
|
||||||
|
extern int FirmwareBirthdayMonth;
|
||||||
|
extern int FirmwareBirthdayDay;
|
||||||
|
extern int FirmwareFavouriteColour;
|
||||||
|
extern char FirmwareMessage[1024];
|
||||||
|
|
||||||
extern int SocketBindAnyAddr;
|
extern int SocketBindAnyAddr;
|
||||||
extern char LANDevice[128];
|
extern char LANDevice[128];
|
||||||
extern int DirectLAN;
|
extern int DirectLAN;
|
||||||
|
Reference in New Issue
Block a user