1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-17 20:42:23 +00:00

git subrepo pull --force tools/ZAPD (#1457)

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "dcf56d93e"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "dcf56d93e"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "dbb99be"

* Add files via upload

* Update Config.xml
This commit is contained in:
louist103 2022-12-08 13:15:18 -05:00 committed by GitHub
parent 48cdaa5c6c
commit 629757b3ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 2366 additions and 5678 deletions

View file

@ -14,8 +14,9 @@ void SetActorCutsceneList::ParseRawData()
{
ZRoomCommand::ParseRawData();
int numCutscenes = cmdArg1;
int32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
cutscenes.reserve(numCutscenes);
for (int32_t i = 0; i < numCutscenes; i++)
{
ActorCutsceneEntry entry(parent->GetRawData(), currentPtr);

View file

@ -1,10 +1,10 @@
#include "SetActorList.h"
#include <cassert>
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent)
@ -15,104 +15,38 @@ void SetActorList::ParseRawData()
{
ZRoomCommand::ParseRawData();
numActors = cmdArg1;
actorList = new ZActorList(parent);
actorList->ExtractFromBinary(segmentOffset, numActors);
}
void SetActorList::DeclareReferences(const std::string& prefix)
{
if (numActors != 0 && cmdArg2 != 0)
if (parent->HasDeclaration(segmentOffset))
{
std::string varName =
StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationPlaceholder(segmentOffset, varName);
}
}
void SetActorList::ParseRawDataLate()
{
ZRoomCommand::ParseRawDataLate();
size_t actorsAmount = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 0x10;
uint32_t currentPtr = segmentOffset;
for (size_t i = 0; i < actorsAmount; i++)
{
ActorSpawnEntry entry(parent->GetRawData(), currentPtr);
currentPtr += entry.GetRawDataSize();
actors.push_back(entry);
}
}
void SetActorList::DeclareReferencesLate(const std::string& prefix)
{
if (actors.empty())
delete actorList;
actorList = static_cast<ZActorList*>(parent->FindResource(segmentOffset));
assert(actorList != nullptr);
assert(actorList->GetResourceType() == ZResourceType::ActorList);
return;
std::string declaration;
size_t largestlength = 0;
for (const auto& entry : actors)
{
size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size();
if (actorNameLength > largestlength)
largestlength = actorNameLength;
}
size_t index = 0;
for (auto& entry : actors)
if (actorList->GetName() == "")
{
entry.SetLargestActorName(largestlength);
declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str());
if (index < actors.size() - 1)
declaration += "\n";
index++;
actorList->SetName(actorList->GetDefaultName(prefix));
}
const auto& entry = actors.front();
std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4,
actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(),
varName, GetActorListArraySize(), declaration);
actorList->DeclareVar(prefix, "");
parent->AddResource(actorList);
}
std::string SetActorList::GetBodySourceCode() const
{
std::string listName;
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName);
if (numActors != actors.size())
{
printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors,
actors.size());
}
return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str());
}
size_t SetActorList::GetActorListArraySize() const
{
size_t actorCount = 0;
// Doing an else-if here so we only do the loop when the game is SW97.
// Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count
// for it.
if (Globals::Instance->game == ZGame::OOT_SW97)
{
actorCount = 0;
for (const auto& entry : actors)
if (entry.GetActorId() != 0x22)
actorCount++;
}
else
{
actorCount = actors.size();
}
return actorCount;
}
std::string SetActorList::GetCommandCName() const
{
return "SCmdActorList";
@ -122,58 +56,3 @@ RoomCommand SetActorList::GetRoomCommand() const
{
return RoomCommand::SetActorList;
}
ActorSpawnEntry::ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
}
std::string ActorSpawnEntry::GetBodySourceCode() const
{
std::string body;
std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1);
body =
StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str());
body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ);
if (Globals::Instance->game == ZGame::MM_RETAIL)
body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)"
", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ",
(rotX >> 7) & 0b111111111, rotX & 0b1111111,
(rotY >> 7) & 0b111111111, rotY & 0b1111111,
(rotZ >> 7) & 0b111111111, rotZ & 0b1111111);
else
body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ);
body += StringHelper::Sprintf("0x%04X", initVar);
return body;
}
std::string ActorSpawnEntry::GetSourceTypeName() const
{
return "ActorEntry";
}
int32_t ActorSpawnEntry::GetRawDataSize() const
{
return 16;
}
uint16_t ActorSpawnEntry::GetActorId() const
{
return actorNum;
}
void ActorSpawnEntry::SetLargestActorName(size_t nameSize)
{
largestActorName = nameSize;
}

View file

@ -1,45 +1,19 @@
#pragma once
#include "ZActorList.h"
#include "ZRoom/ZRoomCommand.h"
class ActorSpawnEntry
{
public:
uint16_t actorNum;
int16_t posX;
int16_t posY;
int16_t posZ;
uint16_t rotX;
uint16_t rotY;
uint16_t rotZ;
uint16_t initVar;
size_t largestActorName = 16;
ActorSpawnEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex);
std::string GetBodySourceCode() const;
std::string GetSourceTypeName() const;
int32_t GetRawDataSize() const;
uint16_t GetActorId() const;
void SetLargestActorName(size_t nameSize);
};
class SetActorList : public ZRoomCommand
{
public:
uint8_t numActors;
std::vector<ActorSpawnEntry> actors;
uint32_t numActors;
ZActorList* actorList = nullptr;
SetActorList(ZFile* nParent);
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
void ParseRawDataLate() override;
void DeclareReferencesLate(const std::string& prefix) override;
std::string GetBodySourceCode() const override;
RoomCommand GetRoomCommand() const override;

View file

@ -21,9 +21,10 @@ void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string&
void SetAlternateHeaders::ParseRawDataLate()
{
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
for (int32_t i = 0; i < numHeaders; i++)
headers.reserve(numHeaders);
for (uint32_t i = 0; i < numHeaders; i++)
{
int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4));
headers.push_back(address);

View file

@ -18,6 +18,7 @@ void SetCsCamera::ParseRawData()
uint32_t currentPtr = segmentOffset;
int32_t numPoints = 0;
cameras.reserve(numCameras);
for (int32_t i = 0; i < numCameras; i++)
{
CsCameraEntry entry(parent->GetRawData(), currentPtr);
@ -31,6 +32,7 @@ void SetCsCamera::ParseRawData()
{
uint32_t currentPtr = cameras.at(0).GetSegmentOffset();
points.reserve(numPoints);
for (int32_t i = 0; i < numPoints; i++)
{
ZVector vec(parent);

View file

@ -20,6 +20,7 @@ void SetCutscenes::ParseRawData()
{
int32_t currentPtr = segmentOffset;
cutsceneEntries.reserve(numCutscenes);
for (uint8_t i = 0; i < numCutscenes; i++)
{
CutsceneEntry entry(parent->GetRawData(), currentPtr);

View file

@ -24,10 +24,11 @@ void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& pref
void SetEntranceList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numEntrances; i++)
entrances.reserve(numEntrances);
for (uint32_t i = 0; i < numEntrances; i++)
{
EntranceEntry entry(parent->GetRawData(), currentPtr);
entrances.push_back(entry);

View file

@ -4,6 +4,7 @@
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZNames.h"
#include "ZRoom/ZRoom.h"
SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent)
@ -23,10 +24,11 @@ void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
void SetExitList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numEntrances; i++)
exits.reserve(numEntrances);
for (uint32_t i = 0; i < numEntrances; i++)
{
uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr);
exits.push_back(exit);
@ -43,7 +45,8 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref
for (size_t i = 0; i < exits.size(); i++)
{
declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i));
declaration +=
StringHelper::Sprintf(" %s,", ZNames::GetEntranceName(exits[i]).c_str());
if (i + 1 < exits.size())
declaration += "\n";
}

View file

@ -15,6 +15,8 @@ void SetLightList::ParseRawData()
numLights = cmdArg1;
int32_t currentPtr = segmentOffset;
lights.reserve(this->numLights);
for (int i = 0; i < this->numLights; i++)
{
LightInfo light(parent->GetRawData(), currentPtr);

View file

@ -15,6 +15,7 @@ void SetLightingSettings::ParseRawData()
ZRoomCommand::ParseRawData();
uint8_t numLights = cmdArg1;
settings.reserve(numLights);
for (int i = 0; i < numLights; i++)
settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22)));
}

View file

@ -442,6 +442,8 @@ void PolygonType1::DeclareReferences(const std::string& prefix)
{
listAddress = Seg2Filespace(list, parent->baseAddress);
uint32_t auxPtr = listAddress;
multiList.reserve(count);
for (size_t i = 0; i < count; ++i)
{
BgImage bg(false, prefix, auxPtr, parent);
@ -545,6 +547,8 @@ void PolygonType2::ParseRawData()
end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08);
uint32_t currentPtr = GETSEGOFFSET(start);
polyDLists.reserve(num);
for (size_t i = 0; i < num; i++)
{
PolygonDlist entry(parent);

View file

@ -15,8 +15,9 @@ void SetMinimapChests::ParseRawData()
ZRoomCommand::ParseRawData();
int numChests = cmdArg1;
int32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
chests.reserve(numChests);
for (int32_t i = 0; i < numChests; i++)
{
MinimapChest chest(parent->GetRawData(), currentPtr);

View file

@ -17,8 +17,9 @@ void SetMinimapList::ParseRawData()
listSegmentOffset = GETSEGOFFSET(listSegmentAddr);
unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4);
int32_t currentPtr = listSegmentOffset;
uint32_t currentPtr = listSegmentOffset;
minimaps.reserve(zRoom->roomCount);
for (int32_t i = 0; i < zRoom->roomCount; i++)
{
MinimapEntry entry(parent->GetRawData(), currentPtr);

View file

@ -17,6 +17,7 @@ void SetObjectList::ParseRawData()
uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1);
uint32_t currentPtr = segmentOffset;
objects.reserve(objectCnt);
for (uint8_t i = 0; i < objectCnt; i++)
{
uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr);

View file

@ -69,6 +69,7 @@ void RomFile::ParseRawData()
uint32_t currentPtr = rawDataIndex;
rooms.reserve(numRooms);
for (int32_t i = 0; i < numRooms; i++)
{
RoomEntry entry(parent->GetRawData(), currentPtr);
@ -104,8 +105,9 @@ std::string RomFile::GetBodySourceCode() const
if (!isFirst)
declaration += "\n";
declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },",
roomName.c_str(), roomName.c_str());
declaration += StringHelper::Sprintf(
"\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%sSegmentRomEnd },",
roomName.c_str(), roomName.c_str());
isFirst = false;
}
}

View file

@ -16,9 +16,10 @@ void SetStartPositionList::ParseRawData()
ZRoomCommand::ParseRawData();
uint8_t numActors = cmdArg1;
uint32_t currentPtr = segmentOffset;
offset_t currentPtr = segmentOffset;
for (int32_t i = 0; i < numActors; i++)
actors.reserve(numActors);
for (uint32_t i = 0; i < numActors; i++)
{
actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr));
currentPtr += 16;

View file

@ -17,6 +17,7 @@ void SetTransitionActorList::ParseRawData()
int numActors = cmdArg1;
uint32_t currentPtr = segmentOffset;
transitionActors.reserve(numActors);
for (int32_t i = 0; i < numActors; i++)
{
TransitionActorEntry entry(parent->GetRawData(), currentPtr);

View file

@ -12,17 +12,17 @@ public:
{
if (id >= Globals::Instance->cfg.objectList.size())
return StringHelper::Sprintf("0x%04X", id);
return Globals::Instance->cfg.objectList.at(id);
return Globals::Instance->cfg.objectList[id];
}
static std::string GetActorName(int32_t id)
static std::string GetActorName(uint16_t id)
{
switch (Globals::Instance->game)
{
case ZGame::OOT_RETAIL:
case ZGame::OOT_SW97:
if (id < ZNames::GetNumActors())
return Globals::Instance->cfg.actorList.at(id);
return Globals::Instance->cfg.actorList[id];
else
return StringHelper::Sprintf("0x%04X", id);
case ZGame::MM_RETAIL:
@ -31,7 +31,7 @@ public:
id &= 0xFFF;
std::string name;
if (id < ZNames::GetNumActors())
name = Globals::Instance->cfg.actorList.at(id);
name = Globals::Instance->cfg.actorList[id];
else
name = StringHelper::Sprintf("0x%04X", id);
@ -45,5 +45,20 @@ public:
return "";
}
static int32_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); }
static std::string GetEntranceName(uint16_t id)
{
if (ZNames::GetNumEntrances() == 0 || ZNames::GetNumSpecialEntrances() == 0)
return StringHelper::Sprintf("0x%04X", id);
if (id < ZNames::GetNumEntrances())
return Globals::Instance->cfg.entranceList[id];
else if ((id >= 0x7FF9 && id <= 0x7FFF) && !((id - 0x7FF9U) > GetNumSpecialEntrances())) // Special entrances
return Globals::Instance->cfg.specialEntranceList[id - 0x7FF9];
else
return StringHelper::Sprintf("0x%04X", id);
}
static size_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); }
static size_t GetNumEntrances() { return Globals::Instance->cfg.entranceList.size(); }
static size_t GetNumSpecialEntrances() { return Globals::Instance->cfg.specialEntranceList.size(); }
};