diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/apt/bcfnt/bcfnt.cpp | 110 | ||||
-rw-r--r-- | src/core/hle/service/apt/bcfnt/bcfnt.h | 92 |
2 files changed, 0 insertions, 202 deletions
diff --git a/src/core/hle/service/apt/bcfnt/bcfnt.cpp b/src/core/hle/service/apt/bcfnt/bcfnt.cpp deleted file mode 100644 index 6d2474702..000000000 --- a/src/core/hle/service/apt/bcfnt/bcfnt.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/apt/bcfnt/bcfnt.h" -#include "core/hle/service/service.h" - -namespace Service { -namespace APT { -namespace BCFNT { - -void RelocateSharedFont(Kernel::SharedPtr<Kernel::SharedMemory> shared_font, VAddr new_address) { - static const u32 SharedFontStartOffset = 0x80; - const u8* cfnt_ptr = shared_font->GetPointer(SharedFontStartOffset); - - CFNT cfnt; - memcpy(&cfnt, cfnt_ptr, sizeof(cfnt)); - - u32 assumed_cmap_offset = 0; - u32 assumed_cwdh_offset = 0; - u32 assumed_tglp_offset = 0; - u32 first_cmap_offset = 0; - u32 first_cwdh_offset = 0; - u32 first_tglp_offset = 0; - - // First discover the location of sections so that the rebase offset can be auto-detected - u32 current_offset = SharedFontStartOffset + cfnt.header_size; - for (unsigned block = 0; block < cfnt.num_blocks; ++block) { - const u8* data = shared_font->GetPointer(current_offset); - - SectionHeader section_header; - memcpy(§ion_header, data, sizeof(section_header)); - - if (first_cmap_offset == 0 && memcmp(section_header.magic, "CMAP", 4) == 0) { - first_cmap_offset = current_offset; - } else if (first_cwdh_offset == 0 && memcmp(section_header.magic, "CWDH", 4) == 0) { - first_cwdh_offset = current_offset; - } else if (first_tglp_offset == 0 && memcmp(section_header.magic, "TGLP", 4) == 0) { - first_tglp_offset = current_offset; - } else if (memcmp(section_header.magic, "FINF", 4) == 0) { - BCFNT::FINF finf; - memcpy(&finf, data, sizeof(finf)); - - assumed_cmap_offset = finf.cmap_offset - sizeof(SectionHeader); - assumed_cwdh_offset = finf.cwdh_offset - sizeof(SectionHeader); - assumed_tglp_offset = finf.tglp_offset - sizeof(SectionHeader); - } - - current_offset += section_header.section_size; - } - - u32 previous_base = assumed_cmap_offset - first_cmap_offset; - ASSERT(previous_base == assumed_cwdh_offset - first_cwdh_offset); - ASSERT(previous_base == assumed_tglp_offset - first_tglp_offset); - - u32 offset = new_address - previous_base; - - // Reset pointer back to start of sections and do the actual rebase - current_offset = SharedFontStartOffset + cfnt.header_size; - for (unsigned block = 0; block < cfnt.num_blocks; ++block) { - u8* data = shared_font->GetPointer(current_offset); - - SectionHeader section_header; - memcpy(§ion_header, data, sizeof(section_header)); - - if (memcmp(section_header.magic, "FINF", 4) == 0) { - BCFNT::FINF finf; - memcpy(&finf, data, sizeof(finf)); - - // Relocate the offsets in the FINF section - finf.cmap_offset += offset; - finf.cwdh_offset += offset; - finf.tglp_offset += offset; - - memcpy(data, &finf, sizeof(finf)); - } else if (memcmp(section_header.magic, "CMAP", 4) == 0) { - BCFNT::CMAP cmap; - memcpy(&cmap, data, sizeof(cmap)); - - // Relocate the offsets in the CMAP section - if (cmap.next_cmap_offset != 0) - cmap.next_cmap_offset += offset; - - memcpy(data, &cmap, sizeof(cmap)); - } else if (memcmp(section_header.magic, "CWDH", 4) == 0) { - BCFNT::CWDH cwdh; - memcpy(&cwdh, data, sizeof(cwdh)); - - // Relocate the offsets in the CWDH section - if (cwdh.next_cwdh_offset != 0) - cwdh.next_cwdh_offset += offset; - - memcpy(data, &cwdh, sizeof(cwdh)); - } else if (memcmp(section_header.magic, "TGLP", 4) == 0) { - BCFNT::TGLP tglp; - memcpy(&tglp, data, sizeof(tglp)); - - // Relocate the offsets in the TGLP section - tglp.sheet_data_offset += offset; - - memcpy(data, &tglp, sizeof(tglp)); - } - - current_offset += section_header.section_size; - } -} - -} // namespace BCFNT -} // namespace APT -} // namespace Service
\ No newline at end of file diff --git a/src/core/hle/service/apt/bcfnt/bcfnt.h b/src/core/hle/service/apt/bcfnt/bcfnt.h deleted file mode 100644 index 453bf7606..000000000 --- a/src/core/hle/service/apt/bcfnt/bcfnt.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "common/swap.h" -#include "core/hle/kernel/shared_memory.h" -#include "core/hle/service/service.h" - -namespace Service { -namespace APT { -namespace BCFNT { ///< BCFNT Shared Font file structures - -struct CFNT { - u8 magic[4]; - u16_le endianness; - u16_le header_size; - u32_le version; - u32_le file_size; - u32_le num_blocks; -}; - -struct SectionHeader { - u8 magic[4]; - u32_le section_size; -}; - -struct FINF { - u8 magic[4]; - u32_le section_size; - u8 font_type; - u8 line_feed; - u16_le alter_char_index; - u8 default_width[3]; - u8 encoding; - u32_le tglp_offset; - u32_le cwdh_offset; - u32_le cmap_offset; - u8 height; - u8 width; - u8 ascent; - u8 reserved; -}; - -struct TGLP { - u8 magic[4]; - u32_le section_size; - u8 cell_width; - u8 cell_height; - u8 baseline_position; - u8 max_character_width; - u32_le sheet_size; - u16_le num_sheets; - u16_le sheet_image_format; - u16_le num_columns; - u16_le num_rows; - u16_le sheet_width; - u16_le sheet_height; - u32_le sheet_data_offset; -}; - -struct CMAP { - u8 magic[4]; - u32_le section_size; - u16_le code_begin; - u16_le code_end; - u16_le mapping_method; - u16_le reserved; - u32_le next_cmap_offset; -}; - -struct CWDH { - u8 magic[4]; - u32_le section_size; - u16_le start_index; - u16_le end_index; - u32_le next_cwdh_offset; -}; - -/** - * Relocates the internal addresses of the BCFNT Shared Font to the new base. The current base will - * be auto-detected based on the file headers. - * - * @param shared_font SharedMemory object that contains the Shared Font - * @param new_address New base for the offsets in the structure. - */ -void RelocateSharedFont(Kernel::SharedPtr<Kernel::SharedMemory> shared_font, VAddr new_address); - -} // namespace BCFNT -} // namespace APT -} // namespace Service |