aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2021-11-20 12:09:13 +0100
committerArisotura <thetotalworm@gmail.com>2021-11-20 12:09:13 +0100
commit7a0286a43d69adaf97d1a3f373a3e9c026c537f5 (patch)
tree857a589a0bc14e9bc22cc2ff6bcd4486d7da3fbf /src
parent593eb7c81c1f9183ba82a4021cdac4748fe6ecff (diff)
make firmware settings override also apply in DSi mode
Diffstat (limited to 'src')
-rw-r--r--src/DSi.cpp2
-rw-r--r--src/DSi_NAND.cpp33
-rw-r--r--src/DSi_NAND.h2
3 files changed, 34 insertions, 3 deletions
diff --git a/src/DSi.cpp b/src/DSi.cpp
index 88f0265..1150d74 100644
--- a/src/DSi.cpp
+++ b/src/DSi.cpp
@@ -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();
diff --git a/src/DSi_NAND.cpp b/src/DSi_NAND.cpp
index f4f68d4..a3d1e40 100644
--- a/src/DSi_NAND.cpp
+++ b/src/DSi_NAND.cpp
@@ -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;
diff --git a/src/DSi_NAND.h b/src/DSi_NAND.h
index d80f298..64c40fa 100644
--- a/src/DSi_NAND.h
+++ b/src/DSi_NAND.h
@@ -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);