1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-02-22 06:45:31 +00:00

Add ZAPD flags to override virtual address / start offset / end offset

This commit is contained in:
cadmic 2024-06-19 11:56:54 -07:00
parent 378c661d69
commit 8e0199bcc0
4 changed files with 37 additions and 4 deletions

View file

@ -118,10 +118,13 @@ ZAPD also accepts the following list of extra parameters:
- `-s` / `--static` : Mark every asset as `static`.
- This behaviour can be overridden per asset using `Static=` in the respective XML node.
- `--cs-float` : How cutscene floats should be extracted.
- Valid values:
- `hex`
- `float`
- `both`
- Valid values:
- `hex`
- `float`
- `both`
- `--base-address ADDRESS`: Override base virtual address for input files.
- `--start-offset OFFSET`: Override start offset for input files.
- `--end-offset OFFSET`: Override end offset for input files.
- `-W...`: warning flags, see below
Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed.

View file

@ -39,6 +39,9 @@ public:
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
TextureType texType;
CsFloatType floatType = CsFloatType::FloatOnly;
int baseAddress = -1;
int startOffset = -1;
int endOffset = -1;
ZGame game;
GameConfig cfg;
bool verboseUnaccounted = false;

View file

@ -37,6 +37,9 @@ void Arg_EnableGCCCompat(int& i, char* argv[]);
void Arg_ForceStatic(int& i, char* argv[]);
void Arg_ForceUnaccountedStatic(int& i, char* argv[]);
void Arg_CsFloatMode(int& i, char* argv[]);
void Arg_BaseAddress(int& i, char* argv[]);
void Arg_StartOffset(int& i, char* argv[]);
void Arg_EndOffset(int& i, char* argv[]);
int main(int argc, char* argv[]);
@ -254,6 +257,9 @@ void ParseArgs(int& argc, char* argv[])
{"-us", &Arg_ForceUnaccountedStatic},
{"--unaccounted-static", &Arg_ForceUnaccountedStatic},
{"--cs-float", &Arg_CsFloatMode},
{"--base-address", &Arg_BaseAddress},
{"--start-offset", &Arg_StartOffset},
{"--end-offset", &Arg_EndOffset},
};
for (int32_t i = 2; i < argc; i++)
@ -420,6 +426,21 @@ void Arg_CsFloatMode([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
}
}
void Arg_BaseAddress(int& i, char* argv[])
{
Globals::Instance->baseAddress = std::stoul(argv[++i], nullptr, 16);
}
void Arg_StartOffset(int& i, char* argv[])
{
Globals::Instance->startOffset = std::stoul(argv[++i], nullptr, 16);
}
void Arg_EndOffset(int& i, char* argv[])
{
Globals::Instance->endOffset = std::stoul(argv[++i], nullptr, 16);
}
int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
{
bool procFileModeSuccess = false;

View file

@ -120,6 +120,9 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
if (reader->Attribute("BaseAddress") != nullptr)
baseAddress = StringHelper::StrToL(reader->Attribute("BaseAddress"), 16);
if (mode == ZFileMode::Extract && Globals::Instance->baseAddress != -1)
baseAddress = Globals::Instance->baseAddress;
if (reader->Attribute("RangeStart") != nullptr)
rangeStart = StringHelper::StrToL(reader->Attribute("RangeStart"), 16);
@ -197,6 +200,9 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
}
rawData = File::ReadAllBytes((basePath / name).string());
if (mode == ZFileMode::Extract && Globals::Instance->startOffset != -1 && Globals::Instance->endOffset != -1)
rawData = std::vector<uint8_t>(rawData.begin() + Globals::Instance->startOffset,
rawData.begin() + Globals::Instance->endOffset);
if (reader->Attribute("RangeEnd") == nullptr)
rangeEnd = rawData.size();