summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom/Commands/SetActorList.cpp
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2021-01-23 14:23:51 -0500
committerGitHub <noreply@github.com>2021-01-23 14:23:51 -0500
commitee42172389c0aebfbc0c2d5bbabab4ec858bc8cd (patch)
tree3c6afd903bb9983602f6f79a1333106fe2306745 /ZAPD/ZRoom/Commands/SetActorList.cpp
parent2e1174063f3ed6bcf929bc7093cd2d1b05f8518b (diff)
WIP F3DEX Support, Bug Fixes, Game definable in XML (#75)
* WIP F3DEX support * Additional work on F3DEX support, fixed bug with actorlist * Fixed crash bug * Adds ZFile attribute "Game" to be able to change the game mode for ZAPD. * Additional changes to support F3DEX * Fixed bug with cullDL and with dlist type selection * F3DEX Opcode fix * Fixed up a few bugs * Cleaned up some code and fixed bug with directory creation. * ZAPD now supports correct bitpacking for gsSPSetOtherMode on F3DEX * Fixes syntax error in ZDisplayList.h * Updates Actor and Object Lists * Updated actor and object list * G_MTX updated for F3DEX * Fixed bug with transition actor list * Updated G_Texture for F3DEX * SW97 maps: Removes actor 0x22, and shifts actors 0x23 and above down by one to match retail enum. * Fixes issue in reuse of actorCount variable in SetActorList::GetActorListArraySize. Co-authored-by: Kenix3
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetActorList.cpp')
-rw-r--r--ZAPD/ZRoom/Commands/SetActorList.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/ZAPD/ZRoom/Commands/SetActorList.cpp b/ZAPD/ZRoom/Commands/SetActorList.cpp
index 7404f18..35c2af5 100644
--- a/ZAPD/ZRoom/Commands/SetActorList.cpp
+++ b/ZAPD/ZRoom/Commands/SetActorList.cpp
@@ -4,6 +4,7 @@
#include "../ActorList.h"
#include "../../BitConverter.h"
#include "../../StringHelper.h"
+#include "../../Globals.h"
using namespace std;
@@ -63,19 +64,32 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
int index = 0;
for (ActorSpawnEntry* entry : actors)
{
- if (entry->actorNum < sizeof(ActorList) / sizeof(ActorList[0]))
- declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", ActorList[entry->actorNum].c_str(), entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ uint16_t actorNum = entry->actorNum;
+
+ // SW97 Actor 0x22 was removed, so we want to not output a working actor.
+ if (actorNum == 0x22 && Globals::Instance->game == ZGame::OOT_SW97)
+ declaration += StringHelper::Sprintf("\t//{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", StringHelper::Sprintf("SW_REMOVED_0x%04X", actorNum), entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
else
- declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", entry->actorNum, entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ {
+ // SW97 Actor 0x23 and above are shifted up by one because 0x22 was removed between SW97 and retail.
+ // We need to shift down by one
+ if (Globals::Instance->game == ZGame::OOT_SW97 && actorNum >= 0x23)
+ actorNum--;
+
+ if (actorNum < sizeof(ActorList) / sizeof(ActorList[0]))
+ declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", ActorList[actorNum].c_str(), entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ else
+ declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", actorNum, entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
- if (index < actors.size() - 1)
- declaration += "\n";
+ if (index < actors.size() - 1)
+ declaration += "\n";
+ }
index++;
}
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, actors.size() * 16,
- "ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset), actors.size(), declaration);
+ "ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset), GetActorListArraySize(), declaration);
return sourceOutput;
}
@@ -85,9 +99,31 @@ int32_t SetActorList::GetRawDataSize()
return ZRoomCommand::GetRawDataSize() + ((int)actors.size() * 16);
}
+int SetActorList::GetActorListArraySize()
+{
+ int 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 (ActorSpawnEntry* entry : actors)
+ if (entry->actorNum != 0x22)
+ actorCount++;
+ }
+ else
+ {
+ actorCount = (int)actors.size();
+ }
+
+ return actorCount;
+}
+
string SetActorList::GenerateExterns()
{
- return StringHelper::Sprintf("extern ActorEntry %sActorList0x%06X[%i];\n", zRoom->GetName().c_str(), segmentOffset, (int)actors.size());
+ return StringHelper::Sprintf("extern ActorEntry %sActorList0x%06X[%i];\n", zRoom->GetName().c_str(), segmentOffset, GetActorListArraySize());
}
string SetActorList::GetCommandCName()