diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2021-05-10 12:25:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-10 12:25:39 -0400 |
| commit | 769f5702a422d14bfb0a60a39319da4b4bf9ec1f (patch) | |
| tree | 11e12a20fb2880792722babdee0b5222ea86504f /ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp | |
| parent | a357277e412b5e8f0f2f0578c7d7d213e8744c8d (diff) | |
ZRoom refactor (#124)
* Remove redundant methods
* first pass os cleaning
* More cleaning
* Fix compilation errors
* Fix dumb crashes
* Fix dumb issues
* Removing most uses of GenerateSourceCodePass1
* more cleanup
* Move segmentOffset to ZRoomCommand
* Half of ParseRawData
* somehow broken...
* fix broken stuff
* This may or may not be broken
* More cleaning
* Remove GenerateSourceCodePass2
* More cleanup and pointer removal
* Use PolygonType2 in SetMesh
* another small cleanup
* Merge PolygonDlist and PolygonDlist2
* More code merging
* GetDeclarationPtrName
* Remove most repeated externs and a bit of redundant code
* Dumb MM fixes
* small fix
(cherry picked from commit 0813fd69538491c5aceb00d79d19bf59fd082ca7)
* Another dumb fix
* Remove GenerateExterns
* Change DeclareReferences signature
* Refactor SetAnimatedTextureList
* const std::vector<uint8_t>&
* another small bunch of changes
* last parserawdata and declarereferences separation probably
* Move parserawdata
* Remove GenerateSourceCodePass1
* Use macros for commands
* Make ZRoomCommand inherit ZResource
* shrink scenes tluts
* ProcessTextureIntersections
* small output improvements
* Small changes
* run format
* SCENE_CMD -> SCENECMD
* fix merge errors
* run format
* fix some warnings
* update macros names
* Add again different commands for each game ni SCENE_CMD_ROOM_BEHAVIOR
* macro update
* More booleans
* Move declaration to its own file
* minor changes
* Update according to latest reviews in oot
* run format
* Yet another cutscene change
* Remove special scene/room segment code
* This is crashing and I don't know why
* remove includeFilePrefix
* fix merge issues
* always pass a parent to zresource
* move path to its own zclass and properly implement parserawdata in commands
* Fix GetDeclarationPtrName uses
* Some ZPath fixes (still broken tho)
* Fix ZPath declarations
* Fix weird problem
* Add `Path` to the docs
* run format
* clean syotes code
* A bunch of changes for MM
* run format
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp')
| -rw-r--r-- | ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp index a01c555..c5f9387 100644 --- a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp +++ b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp @@ -1,64 +1,62 @@ #include "SetAlternateHeaders.h" -#include "../../BitConverter.h" -#include "../../StringHelper.h" -#include "../../ZFile.h" -SetAlternateHeaders::SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData, - uint32_t rawDataIndex) - : ZRoomCommand(nZRoom, rawData, rawDataIndex) +#include "BitConverter.h" +#include "StringHelper.h" +#include "ZFile.h" + +SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent) { - segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)); +} +void SetAlternateHeaders::DeclareReferences(const std::string& prefix) +{ if (segmentOffset != 0) - zRoom->parent->AddDeclarationPlaceholder(segmentOffset); - - _rawData = rawData; - _rawDataIndex = rawDataIndex; + parent->AddDeclarationPlaceholder(segmentOffset); } -std::string SetAlternateHeaders::GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) +void SetAlternateHeaders::ParseRawDataLate() { - std::string sourceOutput = ""; - int32_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; + int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; for (int32_t i = 0; i < numHeaders; i++) { - int32_t address = BitConverter::ToInt32BE(_rawData, segmentOffset + (i * 4)); + int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4)); headers.push_back(address); if (address != 0) zRoom->commandSets.push_back(CommandSet(address)); } +} - sourceOutput += - StringHelper::Sprintf("%s 0, (u32)&%sAlternateHeaders0x%06X", - ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), - roomName.c_str(), segmentOffset); - - std::string declaration = ""; - - for (int32_t i = 0; i < numHeaders; i++) +void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix) +{ + if (!headers.empty()) { - // sprintf(line, " 0x%06X,\n", headers[i]); + std::string declaration = ""; - if (headers[i] == 0) - declaration += StringHelper::Sprintf(" 0,\n"); - else - declaration += StringHelper::Sprintf(" (u32)&%sSet%04XCmd00,\n", roomName.c_str(), - headers[i] & 0x00FFFFFF); - } + for (size_t i = 0; i < headers.size(); i++) + { + if (headers.at(i) == 0) + declaration += StringHelper::Sprintf("\tNULL,"); + else + declaration += + StringHelper::Sprintf("\t%sSet%04X,", prefix.c_str(), GETSEGOFFSET(headers[i])); - zRoom->parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, headers.size() * 4, "u32", - StringHelper::Sprintf("%sAlternateHeaders0x%06X", roomName.c_str(), segmentOffset), 0, - declaration); + if (i + 1 < headers.size()) + declaration += "\n"; + } - return sourceOutput; + parent->AddDeclarationArray( + segmentOffset, DeclarationAlignment::None, headers.size() * 4, "SCmdBase*", + StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset), 0, + declaration); + } } -size_t SetAlternateHeaders::GetRawDataSize() const +std::string SetAlternateHeaders::GetBodySourceCode() const { - return ZRoomCommand::GetRawDataSize() + 0; + std::string listName = parent->GetDeclarationPtrName(cmdArg2); + return StringHelper::Sprintf("SCENE_CMD_ALTERNATE_HEADER_LIST(%s)", listName.c_str()); } std::string SetAlternateHeaders::GetCommandCName() const @@ -69,4 +67,4 @@ std::string SetAlternateHeaders::GetCommandCName() const RoomCommand SetAlternateHeaders::GetRoomCommand() const { return RoomCommand::SetAlternateHeaders; -}
\ No newline at end of file +} |
