Implement shared font relocation

This commit is contained in:
wheremyfoodat 2024-10-22 19:13:25 +03:00
parent 238d84ba3b
commit 8c80099339
8 changed files with 204 additions and 9 deletions

View file

@ -7,6 +7,7 @@
#include "config_mem.hpp"
#include "resource_limits.hpp"
#include "services/fonts.hpp"
#include "services/ptm.hpp"
CMRC_DECLARE(ConsoleFonts);
@ -51,7 +52,7 @@ void Memory::reset() {
if (e.handle == KernelHandles::FontSharedMemHandle) {
// Read font size from the cmrc filesystem the font is stored in
auto fonts = cmrc::ConsoleFonts::get_filesystem();
e.size = fonts.open("CitraSharedFontUSRelocated.bin").size();
e.size = fonts.open("SharedFontReplacement.bin").size();
}
e.mapped = false;
@ -520,10 +521,13 @@ Regions Memory::getConsoleRegion() {
return region;
}
void Memory::copySharedFont(u8* pointer) {
void Memory::copySharedFont(u8* pointer, u32 vaddr) {
auto fonts = cmrc::ConsoleFonts::get_filesystem();
auto font = fonts.open("CitraSharedFontUSRelocated.bin");
auto font = fonts.open("SharedFontReplacement.bin");
std::memcpy(pointer, font.begin(), font.size());
// Relocate shared font to the address it's being loaded to
HLE::Fonts::relocateSharedFont(pointer, vaddr);
}
std::optional<u64> Memory::getProgramID() {