Migrate shared font to cmrc

This commit is contained in:
wheremyfoodat 2023-08-21 14:53:50 +03:00
parent d26789571c
commit dd6508eb26
7 changed files with 31 additions and 262165 deletions

View file

@ -1,5 +1,4 @@
#include "kernel.hpp"
#include "services/shared_font.hpp"
namespace Operation {
enum : u32 {
@ -137,7 +136,7 @@ void Kernel::mapMemoryBlock() {
break;
case KernelHandles::FontSharedMemHandle:
std::memcpy(ptr, _shared_font_bin, _shared_font_len);
mem.copySharedFont(ptr);
break;
default: Helpers::panic("Mapping unknown shared memory block: %X", block);

View file

@ -2,12 +2,15 @@
#include <cassert>
#include <chrono> // For time since epoch
#include <cmrc/cmrc.hpp>
#include <ctime>
#include "config_mem.hpp"
#include "resource_limits.hpp"
#include "services/ptm.hpp"
CMRC_DECLARE(ConsoleFonts);
using namespace KernelMemoryTypes;
Memory::Memory(u64& cpuTicks, const EmulatorConfig& config) : cpuTicks(cpuTicks), config(config) {
@ -46,6 +49,12 @@ void Memory::reset() {
// Initialize shared memory blocks and reserve memory for them
for (auto& e : sharedMemBlocks) {
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.mapped = false;
e.paddr = allocateSysMemory(e.size);
}
@ -499,3 +508,9 @@ Regions Memory::getConsoleRegion() {
// For now we pick one based on the ROM header
return region;
}
void Memory::copySharedFont(u8* pointer) {
auto fonts = cmrc::ConsoleFonts::get_filesystem();
auto font = fonts.open("CitraSharedFontUSRelocated.bin");
std::memcpy(pointer, font.begin(), font.size());
}

Binary file not shown.

File diff suppressed because it is too large Load diff