Skip to content

Commit

Permalink
Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
louist103 committed Jan 30, 2024
2 parents e065ace + 5b25e45 commit c488b36
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 88 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ jobs:
- name: Setup OOT
run: |
cd oot
cp ~/baserom_original.z64 ./baserom_original.z64
mkdir -p baseroms/gc-eu-mq-dbg
cp ~/baserom_original.z64 ./baseroms/gc-eu-mq-dbg/baserom.z64
make venv
make -C tools -j
cp ../ZAPD.out tools/ZAPD/
python3 fixbaserom.py
python3 extract_baserom.py
python3 extract_assets.py
.venv/bin/python3 tools/decompress_baserom.py gc-eu-mq-dbg
.venv/bin/python3 extract_baserom.py
.venv/bin/python3 extract_assets.py -j 4
- name: Install Python dependencies
run: |
Expand All @@ -68,6 +70,7 @@ jobs:
- name: Build oot
run: |
cd oot
make venv
make -j
- name: Build mm
Expand Down
51 changes: 31 additions & 20 deletions ZAPD/OtherStructs/CutsceneMM_Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const

/**** CAMERA ****/

CutsceneSubCommandEntry_SplineCamPoint::CutsceneSubCommandEntry_SplineCamPoint(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex)
CutsceneSubCommandEntry_SplineCamPoint::CutsceneSubCommandEntry_SplineCamPoint(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
interpType = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0);
weight = BitConverter::ToUInt8BE(rawData, rawDataIndex + 1);
Expand All @@ -144,17 +145,19 @@ std::string CutsceneSubCommandEntry_SplineCamPoint::GetBodySourceCode() const
const auto interpTypeMap = &Globals::Instance->cfg.enumData.interpType;
const auto relToMap = &Globals::Instance->cfg.enumData.relTo;

return StringHelper::Sprintf("CS_CAM_POINT(%s, 0x%02X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, %s)", interpTypeMap->at(interpType).c_str(), weight, duration, posX, posY, posZ, relToMap->at(relTo).c_str());
return StringHelper::Sprintf("CS_CAM_POINT(%s, 0x%02X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, %s)",
interpTypeMap->at(interpType).c_str(), weight, duration, posX,
posY, posZ, relToMap->at(relTo).c_str());
}

size_t CutsceneSubCommandEntry_SplineCamPoint::GetRawSize() const
{
return 0x0C;
}


CutsceneSubCommandEntry_SplineMiscPoint::CutsceneSubCommandEntry_SplineMiscPoint(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex)
CutsceneSubCommandEntry_SplineMiscPoint::CutsceneSubCommandEntry_SplineMiscPoint(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0);
roll = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2);
Expand All @@ -164,16 +167,18 @@ CutsceneSubCommandEntry_SplineMiscPoint::CutsceneSubCommandEntry_SplineMiscPoint

std::string CutsceneSubCommandEntry_SplineMiscPoint::GetBodySourceCode() const
{
return StringHelper::Sprintf("CS_CAM_MISC(0x%04X, 0x%04X, 0x%04X, 0x%04X)", unused0, roll, fov, unused1);
return StringHelper::Sprintf("CS_CAM_MISC(0x%04X, 0x%04X, 0x%04X, 0x%04X)", unused0, roll, fov,
unused1);
}

size_t CutsceneSubCommandEntry_SplineMiscPoint::GetRawSize() const
{
return 0x08;
}

CutsceneSubCommandEntry_SplineHeader::CutsceneSubCommandEntry_SplineHeader(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex)
CutsceneSubCommandEntry_SplineHeader::CutsceneSubCommandEntry_SplineHeader(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
numEntries = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0);
unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2);
Expand All @@ -183,25 +188,28 @@ CutsceneSubCommandEntry_SplineHeader::CutsceneSubCommandEntry_SplineHeader(const

std::string CutsceneSubCommandEntry_SplineHeader::GetBodySourceCode() const
{
return StringHelper::Sprintf("CS_CAM_SPLINE(0x%04X, 0x%04X, 0x%04X, 0x%04X)", numEntries, unused0, unused1, duration);

return StringHelper::Sprintf("CS_CAM_SPLINE(0x%04X, 0x%04X, 0x%04X, 0x%04X)", numEntries,
unused0, unused1, duration);
}

size_t CutsceneSubCommandEntry_SplineHeader::GetRawSize() const
{
return 0x08;
}

CutsceneSubCommandEntry_SplineFooter::CutsceneSubCommandEntry_SplineFooter(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex): CutsceneSubCommandEntry(rawData, rawDataIndex)
CutsceneSubCommandEntry_SplineFooter::CutsceneSubCommandEntry_SplineFooter(
const std::vector<uint8_t>& rawData, offset_t rawDataIndex)
: CutsceneSubCommandEntry(rawData, rawDataIndex)
{
uint16_t firstHalfWord = BitConverter::ToUInt16BE(rawData, rawDataIndex);
uint16_t secondHalfWord = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2);

if (firstHalfWord != 0xFFFF || secondHalfWord != 4) {
if (firstHalfWord != 0xFFFF || secondHalfWord != 4)
{
HANDLE_ERROR(WarningType::InvalidExtractedData, "Invalid Spline Footer",
StringHelper::Sprintf("Invalid Spline footer. Was expecting 0xFFFF, 0x0004. Got 0x%04X, 0x%04X",
firstHalfWord, secondHalfWord));
StringHelper::Sprintf(
"Invalid Spline footer. Was expecting 0xFFFF, 0x0004. Got 0x%04X, 0x%04X",
firstHalfWord, secondHalfWord));
}
}

Expand All @@ -223,16 +231,18 @@ CutsceneMMCommand_Spline::CutsceneMMCommand_Spline(const std::vector<uint8_t>& r
totalCommands = 0;
rawDataIndex += 4;

while(1) {
if (BitConverter::ToUInt16BE(rawData, rawDataIndex) == 0xFFFF) {
while (1)
{
if (BitConverter::ToUInt16BE(rawData, rawDataIndex) == 0xFFFF)
{
break;
}
numHeaders++;

auto* header = new CutsceneSubCommandEntry_SplineHeader(rawData, rawDataIndex);
rawDataIndex += header->GetRawSize();
entries.push_back(header);

totalCommands += header->numEntries;

for (uint32_t i = 0; i < header->numEntries; i++)
Expand Down Expand Up @@ -269,7 +279,8 @@ std::string CutsceneMMCommand_Spline::GetCommandMacro() const

size_t CutsceneMMCommand_Spline::GetCommandSize() const
{
// 8 Bytes once for the spline command, 8 Bytes per spline the header, two groups of size 12, 1 group of size 8, 4 bytes for the footer.
// 8 Bytes once for the spline command, 8 Bytes per spline the header, two groups of size 12, 1
// group of size 8, 4 bytes for the footer.
return 8 + (8 * numHeaders) + ((totalCommands * 2) * 0xC) + (totalCommands * 8) + 4;
}

Expand Down
16 changes: 10 additions & 6 deletions ZAPD/OtherStructs/CutsceneMM_Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ class CutsceneSubCommandEntry_SplineCamPoint : public CutsceneSubCommandEntry
uint16_t posZ;
uint16_t relTo;

CutsceneSubCommandEntry_SplineCamPoint(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
CutsceneSubCommandEntry_SplineCamPoint(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex);

std::string GetBodySourceCode() const override;

Expand All @@ -296,8 +297,9 @@ class CutsceneSubCommandEntry_SplineMiscPoint : public CutsceneSubCommandEntry
uint16_t roll;
uint16_t fov;
uint16_t unused1;

CutsceneSubCommandEntry_SplineMiscPoint(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);

CutsceneSubCommandEntry_SplineMiscPoint(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex);

std::string GetBodySourceCode() const override;

Expand All @@ -306,8 +308,9 @@ class CutsceneSubCommandEntry_SplineMiscPoint : public CutsceneSubCommandEntry

class CutsceneSubCommandEntry_SplineFooter : public CutsceneSubCommandEntry
{
public:
CutsceneSubCommandEntry_SplineFooter(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
public:
CutsceneSubCommandEntry_SplineFooter(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex);

std::string GetBodySourceCode() const override;

Expand All @@ -321,7 +324,8 @@ class CutsceneSubCommandEntry_SplineHeader : public CutsceneSubCommandEntry
uint16_t unused0;
uint16_t unused1;
uint16_t duration;
CutsceneSubCommandEntry_SplineHeader(const std::vector<uint8_t>& rawData, offset_t rawDataIndex);
CutsceneSubCommandEntry_SplineHeader(const std::vector<uint8_t>& rawData,
offset_t rawDataIndex);

std::string GetBodySourceCode() const override;

Expand Down
80 changes: 36 additions & 44 deletions ZAPD/ZCKeyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ZKeyFrameLimb::ZKeyFrameLimb(ZFile* nParent) : ZResource(nParent)
{
}


ZKeyFrameStandardLimb::ZKeyFrameStandardLimb(ZFile* nParent) : ZKeyFrameLimb(nParent)
{
}
Expand Down Expand Up @@ -54,15 +53,13 @@ void ZKeyFrameSkel::ParseXML(tinyxml2::XMLElement* reader)
ZResource::ParseXML(reader);

std::string limbTypeStr = registeredAttributes.at("LimbType").value;

limbType = ZKeyFrameLimbList::ParseLimbTypeStr(limbTypeStr);
if (limbType == ZKeyframeSkelType::Error)
HANDLE_ERROR_RESOURCE(
WarningType::InvalidXML, parent, this, rawDataIndex, "Invalid limb type",
StringHelper::Sprintf("Invalid limb type. Was expecting 'Flex' or 'Normal'. Got %s.",
limbTypeStr.c_str()));


}
void ZKeyFrameLimbList::ParseXML(tinyxml2::XMLElement* reader)
{
Expand All @@ -77,7 +74,7 @@ void ZKeyFrameLimbList::ParseXML(tinyxml2::XMLElement* reader)
HANDLE_ERROR_RESOURCE(
WarningType::InvalidXML, parent, this, rawDataIndex, "Invalid limb type",
StringHelper::Sprintf("Invalid limb type. Was expecting 'Flex' or 'Normal'. Got %s.",
limbTypeStr.c_str()));
limbTypeStr.c_str()));

numLimbs = (uint8_t)StringHelper::StrToL(numLimbStr);
}
Expand All @@ -90,7 +87,7 @@ void ZKeyFrameSkel::ParseRawData()
limbCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0);
dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 1);
limbsPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4);

limbList = std::make_unique<ZKeyFrameLimbList>(parent, limbCount, limbType);
limbList->SetRawDataIndex(GETSEGOFFSET(limbsPtr));
limbList->ParseRawData();
Expand All @@ -106,25 +103,24 @@ void ZKeyFrameSkel::DeclareReferences(const std::string& prefix)

ZResource::DeclareReferences(defaultPrefix);
declaration += limbList->GetBodySourceCode();
parent->AddDeclarationArray(GETSEGOFFSET(limbsPtr), DeclarationAlignment::Align4, limbList->GetRawDataSize(),
parent->AddDeclarationArray(
GETSEGOFFSET(limbsPtr), DeclarationAlignment::Align4, limbList->GetRawDataSize(),
limbList->GetSourceTypeName(),
StringHelper::Sprintf("%s_KeyFrameLimbs_%06X", prefix.c_str(), rawDataIndex),limbList->limbs.size(),
declaration);
StringHelper::Sprintf("%s_KeyFrameLimbs_%06X", prefix.c_str(), rawDataIndex),
limbList->limbs.size(), declaration);
}

std::string ZKeyFrameSkel::GetBodySourceCode() const
{

std::string limbStr;

if (limbType == ZKeyframeSkelType::Normal)
Globals::Instance->GetSegmentedPtrName(limbsPtr, parent, "KeyFrameStandardLimb", limbStr);
else
else
Globals::Instance->GetSegmentedPtrName(limbsPtr, parent, "KeyFrameFlexLimb", limbStr);


return StringHelper::Sprintf("\n\t0x%02X, 0x%02X, %s\n", limbCount, dListCount, limbStr.c_str());

return StringHelper::Sprintf("\n\t0x%02X, 0x%02X, %s\n", limbCount, dListCount,
limbStr.c_str());
}

size_t ZKeyFrameSkel::GetRawDataSize() const
Expand All @@ -142,13 +138,11 @@ ZResourceType ZKeyFrameSkel::GetResourceType() const
return ZResourceType::KeyFrameSkel;
}


size_t ZKeyFrameStandardLimb::GetRawDataSize() const
{
return 0xC;
}


size_t ZKeyFrameFlexLimb::GetRawDataSize() const
{
return 0x8;
Expand All @@ -161,7 +155,7 @@ size_t ZKeyFrameLimbList::GetRawDataSize() const
limbSize = 0x8;
else
limbSize = 0xC;

return limbSize * numLimbs;
}

Expand All @@ -184,21 +178,20 @@ void ZKeyFrameLimb::ParseRawData()
flags = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x5);
}


void ZKeyFrameStandardLimb::ParseRawData()
{
const auto& rawData = parent->GetRawData();

ZKeyFrameLimb::ParseRawData();
translation.x = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6);
translation.y = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8);
translation.z = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA);
}

void ZKeyFrameFlexLimb::ParseRawData()
{
{
const auto& rawData = parent->GetRawData();

ZKeyFrameLimb::ParseRawData();
callbackIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x6);
}
Expand Down Expand Up @@ -239,26 +232,25 @@ std::string ZKeyFrameStandardLimb::GetBodySourceCode() const

Globals::Instance->GetSegmentedArrayIndexedName(dlist, 8, parent, "Gfx", dlString);

declaration += StringHelper::Sprintf("%s, 0x%02X, 0x%02X, { 0x%04X, 0x%04X, 0x%04X},", dlString.c_str(), numChildren, flags, translation.x, translation.y, translation.z);
declaration +=
StringHelper::Sprintf("%s, 0x%02X, 0x%02X, { 0x%04X, 0x%04X, 0x%04X},", dlString.c_str(),
numChildren, flags, translation.x, translation.y, translation.z);
return declaration;
}

std::string ZKeyFrameFlexLimb::GetBodySourceCode() const
{
std::string declaration;

std::string dlString;

Globals::Instance->GetSegmentedArrayIndexedName(dlist, 8, parent, "Gfx", dlString);

declaration +=
StringHelper::Sprintf("%s, 0x%02X, 0x%02X, 0x%02X", dlString.c_str(),
numChildren, flags, callbackIndex);
declaration += StringHelper::Sprintf("%s, 0x%02X, 0x%02X, 0x%02X", dlString.c_str(),
numChildren, flags, callbackIndex);
return declaration;
}



std::string ZKeyFrameStandardLimb::GetSourceTypeName() const
{
return "KeyFrameStandardLimb";
Expand All @@ -273,14 +265,14 @@ std::string ZKeyFrameLimbList::GetSourceTypeName() const
{
switch (limbType)
{
case ZKeyframeSkelType::Flex:
return "KeyFrameFlexLimb";
case ZKeyframeSkelType::Normal:
return "KeyFrameStandardLimb";
default:
HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex,
"Invalid limb type", "");
break;
case ZKeyframeSkelType::Flex:
return "KeyFrameFlexLimb";
case ZKeyframeSkelType::Normal:
return "KeyFrameStandardLimb";
default:
HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex,
"Invalid limb type", "");
break;
}
}

Expand All @@ -298,13 +290,13 @@ ZResourceType ZKeyFrameLimbList::GetResourceType() const
{
switch (limbType)
{
case ZKeyframeSkelType::Flex:
return ZResourceType::KeyFrameFlexLimb;
case ZKeyframeSkelType::Normal:
return ZResourceType::KeyFrameStandardLimb;
default:
HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex,
"Invalid limb type", "");
break;
case ZKeyframeSkelType::Flex:
return ZResourceType::KeyFrameFlexLimb;
case ZKeyframeSkelType::Normal:
return ZResourceType::KeyFrameStandardLimb;
default:
HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex,
"Invalid limb type", "");
break;
}
}
Loading

0 comments on commit c488b36

Please sign in to comment.