From e2a9f5ed09845891b465e54a29b549d64957cffc Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Sat, 27 Apr 2024 04:24:01 +0100 Subject: [PATCH] Gamecube JP Support (#14) * Compressed gc jp support * message_data_static_jp * jp text support * add break --- ZAPD/ZRom.cpp | 8 ++++++++ ZAPD/ZTextMM.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ ZAPD/ZTextMM.h | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ZAPD/ZRom.cpp b/ZAPD/ZRom.cpp index ed0bd24..2536589 100644 --- a/ZAPD/ZRom.cpp +++ b/ZAPD/ZRom.cpp @@ -44,6 +44,7 @@ namespace fs = std::filesystem; #define MM_OFF_US_10 0x1A500 #define MM_OFF_US_GC 0x1AE90 +#define MM_OFF_JP_GC 0x1AE90 #define MM_OFF_JP_10 0x1C110 #define MM_OFF_JP_11 0x1C050 #define MM_OFF_DBG 0x24F60 @@ -70,6 +71,7 @@ namespace fs = std::filesystem; #define MM_NTSC_10 0x5354631C #define MM_NTSC_10_UNCOMPRESSED 0xDA6983E7 #define MM_NTSC_GC 0xB443EB08 +#define MM_NTSC_JP_GC 0x8473D0C1 bool ZRom::IsMQ() { int crc = BitConverter::ToInt32BE(romData, 0x10); @@ -91,6 +93,7 @@ bool ZRom::IsMQ() { case MM_NTSC_10: case MM_NTSC_10_UNCOMPRESSED: case MM_NTSC_GC: + case MM_NTSC_JP_GC: default: return false; case OOT_NTSC_JP_MQ: @@ -212,6 +215,11 @@ ZRom::ZRom(std::string romPath) version.listPath = "mm_gc.txt"; version.offset = MM_OFF_US_GC; break; + case MM_NTSC_JP_GC: + version.version = "MM JP GC"; + version.listPath = "mm_gc_jp.txt"; + version.offset = MM_OFF_JP_GC; + break; } auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str()); diff --git a/ZAPD/ZTextMM.cpp b/ZAPD/ZTextMM.cpp index 448f529..5c63676 100644 --- a/ZAPD/ZTextMM.cpp +++ b/ZAPD/ZTextMM.cpp @@ -109,6 +109,47 @@ void ZTextMM::ParseMM() msgPtr++; c = rawData[msgPtr]; } + } else if (parent->GetName() == "message_data_static_jp") { + msgEntry.textboxType = (rawData[msgPtr + 0]); + msgEntry.textboxYPos = (rawData[msgPtr + 1]); + msgEntry.icon = BitConverter::ToUInt16BE(rawData, msgPtr + 2); + msgEntry.nextMessageID = BitConverter::ToInt16BE(rawData, msgPtr + 4); + msgEntry.firstItemCost = BitConverter::ToInt16BE(rawData, msgPtr + 6); + msgEntry.secondItemCost = BitConverter::ToInt16BE(rawData, msgPtr + 8); + + msgPtr += 12; + + uint16_t c = BitConverter::ToUInt16BE(rawData, msgPtr); + + // Read until end marker (0x0500) + while (true) { + msgEntry.msg += rawData[msgPtr + 1]; + msgEntry.msg += rawData[msgPtr]; + + if (c == 0x0500) { // End marker + break; + } + + switch (c) { + case 0x001F: // Shift: Print 00xx Spaces + msgEntry.msg += rawData[msgPtr + 3]; + msgEntry.msg += rawData[msgPtr + 2]; + msgPtr += 2; + break; + case 0x0110: // Box Break Delay: Delay for xxxx Before Printing Remaining Text + case 0x0111: // Fade: Keep Text on Screen for xxxx Before Closing + case 0x0112: // Fade Skippable: Delay for xxxx Before Ending Conversation + case 0x0120: // SFX: Play Sound Effect xxxx + case 0x0128: // Delay: Delay for xxxx Before Resuming Text Flow + msgEntry.msg += rawData[msgPtr + 3]; + msgEntry.msg += rawData[msgPtr + 2]; + msgPtr += 2; + break; + } + + msgPtr += 2; + c = BitConverter::ToUInt16BE(rawData, msgPtr); + } } else { // NES // NES has a header with extra information, parse that and move the ptr forward msgEntry.textboxType = (rawData[msgPtr + 0]); diff --git a/ZAPD/ZTextMM.h b/ZAPD/ZTextMM.h index 80b70d7..48c7d78 100644 --- a/ZAPD/ZTextMM.h +++ b/ZAPD/ZTextMM.h @@ -9,7 +9,7 @@ class MessageEntryMM uint16_t id; uint8_t textboxType; uint8_t textboxYPos; - uint8_t icon; + uint16_t icon; uint16_t nextMessageID; uint16_t firstItemCost; uint16_t secondItemCost;