Fix UTF-16 handling for titles (3DS/NDS)

This commit is contained in:
d0k3 2018-03-17 17:00:10 +01:00
parent 3581ee97d8
commit 05af82a4ad
2 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include "nds.h" #include "nds.h"
#include "vff.h" #include "vff.h"
#include "utf.h"
#define CRC16_TABVAL 0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400 #define CRC16_TABVAL 0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
@ -67,7 +68,7 @@ u32 LoadTwlMetaData(const char* path, TwlHeader* hdr, TwlIconData* icon) {
u32 GetTwlTitle(char* desc, const TwlIconData* twl_icon) { u32 GetTwlTitle(char* desc, const TwlIconData* twl_icon) {
const u16* title = twl_icon->title_eng; // english title const u16* title = twl_icon->title_eng; // english title
memset(desc, 0, TWLICON_SIZE_DESC + 1); memset(desc, 0, TWLICON_SIZE_DESC + 1);
for (u32 i = 0; i < TWLICON_SIZE_DESC; i++) desc[i] = (title[i] >= 0x80) ? ' ' : title[i]; utf16_to_utf8((u8*) desc, title, TWLICON_SIZE_DESC, TWLICON_SIZE_DESC);
return 0; return 0;
} }

View File

@ -1,6 +1,7 @@
#include "smdh.h" #include "smdh.h"
#include "utf.h"
#define SMDH_STRING(str, src, len) for (u32 i = 0; i < len; i++) str[i] = (src[i] >= 0x80) ? ' ' : src[i] #define SMDH_STRING(str, src, len) utf16_to_utf8((u8*) str, src, len, len)
// shamelessly stolen from bch2obj.py / 3ds_hb_menu :) // shamelessly stolen from bch2obj.py / 3ds_hb_menu :)
#define SMDH_LUT 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, \ #define SMDH_LUT 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, \
4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, \ 4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, \