From adca7671b9b8ee1adce7aff3a3752cda2b0423f4 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Wed, 22 May 2024 03:23:40 +0100 Subject: [PATCH 1/4] extract jp text --- ZAPD/ZText.cpp | 129 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 36 deletions(-) diff --git a/ZAPD/ZText.cpp b/ZAPD/ZText.cpp index 95e4b52..6eb1153 100644 --- a/ZAPD/ZText.cpp +++ b/ZAPD/ZText.cpp @@ -13,6 +13,7 @@ ZText::ZText(ZFile* nParent) : ZResource(nParent) { RegisterRequiredAttribute("CodeOffset"); RegisterOptionalAttribute("LangOffset", "0"); + RegisterOptionalAttribute("Language", "English"); } void ZText::ParseRawData() @@ -23,6 +24,12 @@ void ZText::ParseRawData() uint32_t currentPtr = StringHelper::StrToL(registeredAttributes.at("CodeOffset").value, 16); uint32_t langPtr = currentPtr; bool isPalLang = false; + bool isJpnLang = false; + + if (registeredAttributes.at("Language").value == "Japanese") + { + isJpnLang = true; + } if (StringHelper::StrToL(registeredAttributes.at("LangOffset").value, 16) != 0) { @@ -43,8 +50,8 @@ void ZText::ParseRawData() { MessageEntry msgEntry; msgEntry.id = BitConverter::ToInt16BE(codeData, currentPtr + 0); - msgEntry.textboxType = (codeData[currentPtr + 2] & 0xF0) >> 4; - msgEntry.textboxYPos = (codeData[currentPtr + 2] & 0x0F); + + uint32_t msgPtr = msgEntry.msgOffset; if (isPalLang) { @@ -57,52 +64,102 @@ void ZText::ParseRawData() msgEntry.msgOffset = BitConverter::ToInt32BE(codeData, langPtr + 4) & 0x00FFFFFF; } - uint32_t msgPtr = msgEntry.msgOffset; - - unsigned char c = rawData[msgPtr]; - unsigned int extra = 0; - bool stop = false; - // Continue parsing until we are told to stop and all extra bytes are read - while ((c != '\0' && !stop) || extra > 0) + if (isJpnLang) { - msgEntry.msg += c; - msgPtr++; + msgEntry.textboxType = (codeData[currentPtr + 2] & 0xF0) >> 4; + msgEntry.textboxYPos = (codeData[currentPtr + 2] & 0x0F); - // Some control codes require reading extra bytes - if (extra == 0) - { - // End marker, so stop this message and do not read anything else - if (c == 0x02) - { - stop = true; - } - else if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || c == 0x06 || - c == 0x14) + uint16_t c = BitConverter::ToUInt16BE(rawData, msgPtr); + unsigned int extra = 0; + bool stop = false; + + while (!stop && extra > 0) { + msgEntry.msg += rawData[msgPtr + 1]; + msgEntry.msg += rawData[msgPtr]; + msgPtr+=2; + + // Some control codes require reading extra bytes + if (extra == 0) { - extra = 1; + // End marker, so stop this message and do not read anything else + if (c == 0x8170) + { + stop = true; + } + else if (c == 0x000B || c == 0x819A || c == 0x819E || c == 0x81A3 || c == 0x869F || + c == 0x86C7 || c == 0x86C9 || c == 0x81F3) + { + extra = 1; + } + // "Continue to new text ID", so stop this message and read one more short for the text ID + else if (c == 0x81CB) + { + extra = 1; + stop = true; + } + else if (c == 0x86B3) + { + extra = 2; + } } - // "Continue to new text ID", so stop this message and read two more bytes for the text ID - else if (c == 0x07) + else { - extra = 2; - stop = true; + extra--; } - else if (c == 0x12 || c == 0x11) + + c = BitConverter::ToUInt16BE(rawData, msgPtr); + } + } + else + { + unsigned char c = rawData[msgPtr]; + unsigned int extra = 0; + bool stop = false; + + msgEntry.textboxType = (codeData[currentPtr + 2] & 0xF0) >> 4; + msgEntry.textboxYPos = (codeData[currentPtr + 2] & 0x0F); + // Continue parsing until we are told to stop and all extra bytes are read + while ((c != '\0' && !stop) || extra > 0) + { + msgEntry.msg += c; + msgPtr++; + + // Some control codes require reading extra bytes + if (extra == 0) { - extra = 2; + // End marker, so stop this message and do not read anything else + if (c == 0x02) + { + stop = true; + } + else if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || c == 0x06 || + c == 0x14) + { + extra = 1; + } + // "Continue to new text ID", so stop this message and read two more bytes for the text ID + else if (c == 0x07) + { + extra = 2; + stop = true; + } + else if (c == 0x12 || c == 0x11) + { + extra = 2; + } + else if (c == 0x15) + { + extra = 3; + } } - else if (c == 0x15) + else { - extra = 3; + extra--; } - } - else - { - extra--; - } - c = rawData[msgPtr]; + c = rawData[msgPtr]; + } } messages.push_back(msgEntry); From 30563ae27b2a16a8a8716d0ba162024a50893f3e Mon Sep 17 00:00:00 2001 From: inspectredc Date: Thu, 23 May 2024 02:13:16 +0100 Subject: [PATCH 2/4] fix msgptr initialisation --- ZAPD/ZText.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ZAPD/ZText.cpp b/ZAPD/ZText.cpp index 6eb1153..33d4dd7 100644 --- a/ZAPD/ZText.cpp +++ b/ZAPD/ZText.cpp @@ -51,8 +51,6 @@ void ZText::ParseRawData() MessageEntry msgEntry; msgEntry.id = BitConverter::ToInt16BE(codeData, currentPtr + 0); - uint32_t msgPtr = msgEntry.msgOffset; - if (isPalLang) { msgEntry.segmentId = (codeData[langPtr + 0]); @@ -64,6 +62,7 @@ void ZText::ParseRawData() msgEntry.msgOffset = BitConverter::ToInt32BE(codeData, langPtr + 4) & 0x00FFFFFF; } + uint32_t msgPtr = msgEntry.msgOffset; if (isJpnLang) { From 62c81b630226debd8b9593de91e1e84f4e1de074 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Thu, 30 May 2024 11:33:16 +0100 Subject: [PATCH 3/4] Fix jp text extraction --- ZAPD/ZText.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZAPD/ZText.cpp b/ZAPD/ZText.cpp index 33d4dd7..16704a4 100644 --- a/ZAPD/ZText.cpp +++ b/ZAPD/ZText.cpp @@ -73,7 +73,7 @@ void ZText::ParseRawData() unsigned int extra = 0; bool stop = false; - while (!stop && extra > 0) { + while (!stop || extra > 0) { msgEntry.msg += rawData[msgPtr + 1]; msgEntry.msg += rawData[msgPtr]; msgPtr+=2; From 0af57090eecba100aa620f65338e560eb08224f1 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Fri, 31 May 2024 13:03:38 +0100 Subject: [PATCH 4/4] use ntsc 1.2 file list --- ZAPD/ZRom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZAPD/ZRom.cpp b/ZAPD/ZRom.cpp index e9b583b..10552d9 100644 --- a/ZAPD/ZRom.cpp +++ b/ZAPD/ZRom.cpp @@ -115,7 +115,7 @@ ZRom::ZRom(std::string romPath) break; case OOT_NTSC_12: version.version = "N64 NTSC 1.2"; - version.listPath = "ntsc_oot.txt"; + version.listPath = "ntsc_12_oot.txt"; version.offset = OOT_OFF_NTSC_12; break; case OOT_PAL_10: