make firmware settings override also apply in DSi mode

This commit is contained in:
Arisotura 2021-11-20 12:09:13 +01:00
parent 593eb7c81c
commit 7a0286a43d
3 changed files with 34 additions and 3 deletions

View File

@ -816,7 +816,7 @@ bool LoadNAND()
memcpy(&ARM7Init[0x0254], &ARM7iBIOS[0xC6D0], 0x1048);
memcpy(&ARM7Init[0x129C], &ARM7iBIOS[0xD718], 0x1048);
DSi_NAND::PatchTSC();
DSi_NAND::PatchUserData();
DSi_NAND::DeInit();

View File

@ -21,6 +21,7 @@
#include "DSi.h"
#include "DSi_AES.h"
#include "DSi_NAND.h"
#include "Platform.h"
#include "sha1/sha1.hpp"
#include "tiny-AES-c/aes.hpp"
@ -510,7 +511,7 @@ void ReadUserData(u8* data)
f_close(&file);
}
void PatchTSC()
void PatchUserData()
{
FRESULT res;
@ -532,6 +533,36 @@ void PatchTSC()
f_lseek(&file, 0);
f_read(&file, contents, 0x1B0, &nres);
// override user settings, if needed
if (Platform::GetConfigBool(Platform::Firm_OverrideSettings))
{
// setting up username
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);
memset(contents + 0xD0, 0, 11 * sizeof(char16_t));
memcpy(contents + 0xD0, username.data(), usernameLength * sizeof(char16_t));
// setting language
contents[0x8E] = Platform::GetConfigInt(Platform::Firm_Language);
// setting up color
contents[0xCC] = Platform::GetConfigInt(Platform::Firm_Color);
// setting up birthday
contents[0xCE] = Platform::GetConfigInt(Platform::Firm_BirthdayMonth);
contents[0xCF] = Platform::GetConfigInt(Platform::Firm_BirthdayDay);
// setup message
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);
memset(contents + 0xE6, 0, 27 * sizeof(char16_t));
memcpy(contents + 0xE6, message.data(), messageLength * sizeof(char16_t));
// TODO: make other items configurable?
}
// fix touchscreen coords
*(u16*)&contents[0xB8] = 0;
*(u16*)&contents[0xBA] = 0;

View File

@ -42,7 +42,7 @@ void GetIDs(u8* emmc_cid, u64& consoleid);
void ReadHardwareInfo(u8* dataS, u8* dataN);
void ReadUserData(u8* data);
void PatchTSC();
void PatchUserData();
void ListTitles(u32 category, std::vector<u32>& titlelist);
bool TitleExists(u32 category, u32 titleid);