Added/Restored the ability to render Hiragana characters using GFXP_HIRAGANA macro

This commit is contained in:
nclok1405 2025-06-13 23:42:08 +09:00
commit 2f32363f45
2 changed files with 23 additions and 5 deletions

View file

@ -1704,6 +1704,7 @@ extern "C" void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size) {
std::wstring StringToU16(const std::string& s) { std::wstring StringToU16(const std::string& s) {
std::vector<unsigned long> result; std::vector<unsigned long> result;
size_t i = 0; size_t i = 0;
while (i < s.size()) { while (i < s.size()) {
unsigned long uni; unsigned long uni;
size_t nbytes = 0; size_t nbytes = 0;
@ -1712,7 +1713,13 @@ std::wstring StringToU16(const std::string& s) {
if (c < 0x80) { // ascii if (c < 0x80) { // ascii
uni = c; uni = c;
nbytes = 0; nbytes = 0;
} else if (c <= 0xBF) { // assuming kata/hiragana delimiter } else if (c == GFXP_HIRAGANA_CHAR) { // Start Hiragana Mode
uni = c;
nbytes = 0;
} else if (c == GFXP_KATAKANA_CHAR) { // Start Katakana Mode
uni = c;
nbytes = 0;
} else if (c <= 0xBF) { // Invalid Characters (Skipped)
nbytes = 0; nbytes = 0;
uni = '\1'; uni = '\1';
} else if (c <= 0xDF) { } else if (c <= 0xDF) {
@ -1769,13 +1776,23 @@ extern "C" void OTRGfxPrint(const char* str, void* printer, void (*printImpl)(vo
}; };
std::wstring wstr = StringToU16(str); std::wstring wstr = StringToU16(str);
bool hiraganaMode = false;
for (const auto& c : wstr) { for (const auto& c : wstr) {
unsigned char convt = ' ';
if (c < 0x80) { if (c < 0x80) {
printImpl(printer, c); printImpl(printer, c);
} else if (c == GFXP_HIRAGANA_CHAR) {
hiraganaMode = true;
} else if (c == GFXP_KATAKANA_CHAR) {
hiraganaMode = false;
} else if (c >= u'' && c <= u'') { // katakana (hankaku) } else if (c >= u'' && c <= u'') { // katakana (hankaku)
printImpl(printer, c - 0xFEC0); if (hiraganaMode && c >= u'' && c <= u'ソ') {
printImpl(printer, c - 0xFEC0 - 0x20); // Hiragana Mode, Block 1
} else if (hiraganaMode && c >= u'' && c <= u'') {
printImpl(printer, c - 0xFEC0 + 0x20); // Hiragana Mode, Block 2
} else {
printImpl(printer, c - 0xFEC0);
}
} else if (c == u' ') { // zenkaku space } else if (c == u' ') { // zenkaku space
printImpl(printer, u' '); printImpl(printer, u' ');
} else { } else {

View file

@ -386,8 +386,9 @@ static SceneSelectEntry sScenes[] = {
}; };
// Note about Japanese scene names: // Note about Japanese scene names:
// * SoH currently lacks the ability to render Hiragana characters using GFXP_HIRAGANA macro. // * SoH originally lacked the ability to render Hiragana characters using GFXP_HIRAGANA macro.
// So instead Hiragana characters are written directly. // This is not the case anymore, but Hiragana characters are still written directly here
// for the sake of readability and editability.
// * Dakuten (濁点) characters must be explicitly written using '゛' or '゜'. // * Dakuten (濁点) characters must be explicitly written using '゛' or '゜'.
// Combined characters (such as 'が', 'げ', 'ば', etc) won't render. // Combined characters (such as 'が', 'げ', 'ば', etc) won't render.
static BetterSceneSelectEntry sBetterScenes[] = { static BetterSceneSelectEntry sBetterScenes[] = {