Skip to content

Commit

Permalink
Gamecube JP Support (HarbourMasters#14)
Browse files Browse the repository at this point in the history
* Compressed gc jp support

* message_data_static_jp

* jp text support

* add break
  • Loading branch information
inspectredc authored Apr 27, 2024
1 parent e63db40 commit e2a9f5e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ZAPD/ZRom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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());
Expand Down
41 changes: 41 additions & 0 deletions ZAPD/ZTextMM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion ZAPD/ZTextMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e2a9f5e

Please sign in to comment.