summaryrefslogtreecommitdiff
path: root/ZAPD/ZTextMM.cpp
diff options
context:
space:
mode:
authorinspectredc <78732756+inspectredc@users.noreply.github.com>2026-01-21 00:14:31 +0000
committerGitHub <noreply@github.com>2026-01-21 00:14:31 +0000
commit6859565909d8cfe02d813964afa0ae8a6da4018d (patch)
tree395942a9f45ea19c0d2e2511fb6986a2f78990ab /ZAPD/ZTextMM.cpp
parentee3397a365c5f350a60538c88f0643f155944836 (diff)
MM PAL Support (#32)
* Support MM GC PAL * Fix GC PAL Yar compression and add Message Table File Support * Add PAL 1.1 Support
Diffstat (limited to 'ZAPD/ZTextMM.cpp')
-rw-r--r--ZAPD/ZTextMM.cpp48
1 files changed, 43 insertions, 5 deletions
diff --git a/ZAPD/ZTextMM.cpp b/ZAPD/ZTextMM.cpp
index 5c63676..7c57941 100644
--- a/ZAPD/ZTextMM.cpp
+++ b/ZAPD/ZTextMM.cpp
@@ -11,7 +11,8 @@ REGISTER_ZFILENODE(TextMM, ZTextMM);
ZTextMM::ZTextMM(ZFile* nParent) : ZResource(nParent)
{
- RegisterRequiredAttribute("CodeOffset");
+ RegisterOptionalAttribute("CodeOffset");
+ RegisterOptionalAttribute("SegmentName");
RegisterOptionalAttribute("LangOffset", "0");
}
@@ -25,7 +26,19 @@ void ZTextMM::ParseRawData()
void ZTextMM::ParseMM()
{
const auto& rawData = parent->GetRawData();
- uint32_t currentPtr = StringHelper::StrToL(registeredAttributes.at("CodeOffset").value, 16);
+ uint32_t currentPtr;
+ bool messageTableInOwnSegment = false;
+
+ if (StringHelper::StrToL(registeredAttributes.at("CodeOffset").value, 16) != 0)
+ {
+ currentPtr = StringHelper::StrToL(registeredAttributes.at("CodeOffset").value, 16);
+ messageTableInOwnSegment = false;
+ }
+ else
+ {
+ currentPtr = 0;
+ messageTableInOwnSegment = true;
+ }
uint32_t langPtr = currentPtr;
bool isPalLang = false;
@@ -40,10 +53,35 @@ void ZTextMM::ParseMM()
std::vector<uint8_t> codeData;
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
- codeData = Globals::Instance->GetBaseromFile("code");
+ if (messageTableInOwnSegment)
+ {
+ if (registeredAttributes.at("SegmentName").value == "")
+ {
+ throw std::runtime_error(
+ StringHelper::Sprintf("ZTextMM: Missing one of required attributes: CodeOffset or SegmentName"));
+ }
+
+ codeData = Globals::Instance->GetBaseromFile(registeredAttributes.at("SegmentName").value);
+ }
+ else {
+ codeData = Globals::Instance->GetBaseromFile("code");
+ }
else
- codeData =
- Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code");
+ if (messageTableInOwnSegment)
+ {
+ if (registeredAttributes.at("SegmentName").value == "")
+ {
+ throw std::runtime_error(
+ StringHelper::Sprintf("ZTextMM: Missing one of required attributes: CodeOffset or SegmentName"));
+ }
+ codeData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string()
+ + registeredAttributes.at("SegmentName").value);
+ }
+ else
+ {
+ codeData =
+ Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code");
+ }
while (true)
{