summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinspectredc <78732756+inspectredc@users.noreply.github.com>2025-03-28 15:46:53 +0000
committerGitHub <noreply@github.com>2025-03-28 11:46:53 -0400
commit8a26737d4783a5282fb2c25ce7028556cbe5a394 (patch)
tree4a0949531086b5834657dbf6eca7a60d5cd4ca6b
parent04d42249d2c15c3b442a0282a90bc8b7bda25b03 (diff)
NTSC Support (#26)
* extract jp text * fix msgptr initialisation * Fix jp text extraction * use ntsc 1.2 file list
-rw-r--r--ZAPD/ZRom.cpp2
-rw-r--r--ZAPD/ZText.cpp126
2 files changed, 92 insertions, 36 deletions
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:
diff --git a/ZAPD/ZText.cpp b/ZAPD/ZText.cpp
index 95e4b52..16704a4 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,6 @@ 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);
if (isPalLang)
{
@@ -59,50 +64,101 @@ void ZText::ParseRawData()
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);