mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 22:03:36 -07:00
Added/Restored the ability to render Hiragana characters using GFXP_HIRAGANA macro
This commit is contained in:
parent
953a522f81
commit
2f32363f45
2 changed files with 23 additions and 5 deletions
|
@ -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::vector<unsigned long> result;
|
||||
size_t i = 0;
|
||||
|
||||
while (i < s.size()) {
|
||||
unsigned long uni;
|
||||
size_t nbytes = 0;
|
||||
|
@ -1712,7 +1713,13 @@ std::wstring StringToU16(const std::string& s) {
|
|||
if (c < 0x80) { // ascii
|
||||
uni = c;
|
||||
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;
|
||||
uni = '\1';
|
||||
} 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);
|
||||
bool hiraganaMode = false;
|
||||
|
||||
for (const auto& c : wstr) {
|
||||
unsigned char convt = ' ';
|
||||
if (c < 0x80) {
|
||||
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)
|
||||
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
|
||||
printImpl(printer, u' ');
|
||||
} else {
|
||||
|
|
|
@ -386,8 +386,9 @@ static SceneSelectEntry sScenes[] = {
|
|||
};
|
||||
|
||||
// Note about Japanese scene names:
|
||||
// * SoH currently lacks the ability to render Hiragana characters using GFXP_HIRAGANA macro.
|
||||
// So instead Hiragana characters are written directly.
|
||||
// * SoH originally lacked the ability to render Hiragana characters using GFXP_HIRAGANA macro.
|
||||
// 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 '゜'.
|
||||
// Combined characters (such as 'が', 'げ', 'ば', etc) won't render.
|
||||
static BetterSceneSelectEntry sBetterScenes[] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue