summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinspectredc <78732756+inspectredc@users.noreply.github.com>2025-03-28 15:46:53 +0000
committerlouist103 <35883445+louist103@users.noreply.github.com>2025-04-09 19:57:26 -0400
commit687d5c44076525db0502763f13bd893c9648500b (patch)
tree9050a876a3c917496dc863208b3ed96aba21e8d3
parentc3ee03cfe3072fc01df256d365115a1f3ccaf012 (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.cpp140
2 files changed, 95 insertions, 47 deletions
diff --git a/ZAPD/ZRom.cpp b/ZAPD/ZRom.cpp
index 20b0eab..db2be0f 100644
--- a/ZAPD/ZRom.cpp
+++ b/ZAPD/ZRom.cpp
@@ -127,7 +127,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 5855d4a..16704a4 100644
--- a/ZAPD/ZText.cpp
+++ b/ZAPD/ZText.cpp
@@ -13,23 +13,23 @@ ZText::ZText(ZFile* nParent) : ZResource(nParent)
{
RegisterRequiredAttribute("CodeOffset");
RegisterOptionalAttribute("LangOffset", "0");
+ RegisterOptionalAttribute("Language", "English");
}
void ZText::ParseRawData()
{
ZResource::ParseRawData();
- ParseOoT();
-
- int bp2 = 0;
-}
-
-void ZText::ParseOoT()
-{
const auto& rawData = parent->GetRawData();
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)
{
@@ -44,15 +44,12 @@ void ZText::ParseOoT()
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
codeData = Globals::Instance->GetBaseromFile("code");
else
- codeData =
- Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code");
+ codeData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code");
while (true)
{
MessageEntry msgEntry;
msgEntry.id = BitConverter::ToInt16BE(codeData, currentPtr + 0);
- msgEntry.textboxType = (codeData[currentPtr + 2] & 0xF0) >> 4;
- msgEntry.textboxYPos = (codeData[currentPtr + 2] & 0x0F);
if (isPalLang)
{
@@ -67,51 +64,101 @@ void ZText::ParseOoT()
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);
@@ -126,8 +173,9 @@ void ZText::ParseOoT()
else
langPtr += 8;
}
-}
+ int bp2 = 0;
+}
std::string ZText::GetSourceTypeName() const
{