mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-15 12:24:39 +00:00
Add ZAPD flags to override virtual address / start offset / end offset
This commit is contained in:
parent
378c661d69
commit
8e0199bcc0
4 changed files with 37 additions and 4 deletions
|
@ -118,10 +118,13 @@ ZAPD also accepts the following list of extra parameters:
|
||||||
- `-s` / `--static` : Mark every asset as `static`.
|
- `-s` / `--static` : Mark every asset as `static`.
|
||||||
- This behaviour can be overridden per asset using `Static=` in the respective XML node.
|
- This behaviour can be overridden per asset using `Static=` in the respective XML node.
|
||||||
- `--cs-float` : How cutscene floats should be extracted.
|
- `--cs-float` : How cutscene floats should be extracted.
|
||||||
- Valid values:
|
- Valid values:
|
||||||
- `hex`
|
- `hex`
|
||||||
- `float`
|
- `float`
|
||||||
- `both`
|
- `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
|
- `-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.
|
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.
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
|
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
|
||||||
TextureType texType;
|
TextureType texType;
|
||||||
CsFloatType floatType = CsFloatType::FloatOnly;
|
CsFloatType floatType = CsFloatType::FloatOnly;
|
||||||
|
int baseAddress = -1;
|
||||||
|
int startOffset = -1;
|
||||||
|
int endOffset = -1;
|
||||||
ZGame game;
|
ZGame game;
|
||||||
GameConfig cfg;
|
GameConfig cfg;
|
||||||
bool verboseUnaccounted = false;
|
bool verboseUnaccounted = false;
|
||||||
|
|
|
@ -37,6 +37,9 @@ void Arg_EnableGCCCompat(int& i, char* argv[]);
|
||||||
void Arg_ForceStatic(int& i, char* argv[]);
|
void Arg_ForceStatic(int& i, char* argv[]);
|
||||||
void Arg_ForceUnaccountedStatic(int& i, char* argv[]);
|
void Arg_ForceUnaccountedStatic(int& i, char* argv[]);
|
||||||
void Arg_CsFloatMode(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[]);
|
int main(int argc, char* argv[]);
|
||||||
|
|
||||||
|
@ -254,6 +257,9 @@ void ParseArgs(int& argc, char* argv[])
|
||||||
{"-us", &Arg_ForceUnaccountedStatic},
|
{"-us", &Arg_ForceUnaccountedStatic},
|
||||||
{"--unaccounted-static", &Arg_ForceUnaccountedStatic},
|
{"--unaccounted-static", &Arg_ForceUnaccountedStatic},
|
||||||
{"--cs-float", &Arg_CsFloatMode},
|
{"--cs-float", &Arg_CsFloatMode},
|
||||||
|
{"--base-address", &Arg_BaseAddress},
|
||||||
|
{"--start-offset", &Arg_StartOffset},
|
||||||
|
{"--end-offset", &Arg_EndOffset},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int32_t i = 2; i < argc; i++)
|
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)
|
int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
|
||||||
{
|
{
|
||||||
bool procFileModeSuccess = false;
|
bool procFileModeSuccess = false;
|
||||||
|
|
|
@ -120,6 +120,9 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
|
||||||
if (reader->Attribute("BaseAddress") != nullptr)
|
if (reader->Attribute("BaseAddress") != nullptr)
|
||||||
baseAddress = StringHelper::StrToL(reader->Attribute("BaseAddress"), 16);
|
baseAddress = StringHelper::StrToL(reader->Attribute("BaseAddress"), 16);
|
||||||
|
|
||||||
|
if (mode == ZFileMode::Extract && Globals::Instance->baseAddress != -1)
|
||||||
|
baseAddress = Globals::Instance->baseAddress;
|
||||||
|
|
||||||
if (reader->Attribute("RangeStart") != nullptr)
|
if (reader->Attribute("RangeStart") != nullptr)
|
||||||
rangeStart = StringHelper::StrToL(reader->Attribute("RangeStart"), 16);
|
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());
|
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)
|
if (reader->Attribute("RangeEnd") == nullptr)
|
||||||
rangeEnd = rawData.size();
|
rangeEnd = rawData.size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue