diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2021-04-13 07:49:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 07:49:30 -0400 |
| commit | 420508d2d872e8653081d95a43bf2ad8f85d894c (patch) | |
| tree | 9019e0a87ad719c4a3b1e38c61e7b67feebfa63a /ZAPD/Main.cpp | |
| parent | 95bf5fc0080135f20f3ab17082f79b9e539e80a5 (diff) | |
Refactoring and various features added (#108)
* ZAPD prints out git hash
* Refactor: ZResource constructor sets parent always.
ZOverlay also no longer a ZResource, since it did not make much sense.
* Organized ZResource a bit
* A number of bug fixes, cleanup, and feature improvements.
* Prepping for legacy dlist disasm
* Fixed some merging issues. Fixed compilation issues with MSVC. Added in proper support for legacy display list disassembler. Refactored parts of ZFile.
* Merge with upstream
* Finished ZFile refactor, and other tidying.
* Fixed up merge issues
* Minor cleanup
* Got rid of libgfxd_win.a
* Fixed matching issue
* Fixed up a few bugs
* Fixed issue with exceptions
* Fixed up merge issues with ZPrerender, along with cleaning up some code
* Additional cleanup
* Fixed merge issues with ZMtx and fixed a bug with ZDisplayList
* Fixes based on PR feedback
* run clang-format (#7)
Signed-off-by: angie <angheloalf95@gmail.com>
* Fixed merge issues with Roz's PR
* Misc fixes
* Fixed MM bug, removed redundant file.
* Removed some commented out code
Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
Diffstat (limited to 'ZAPD/Main.cpp')
| -rw-r--r-- | ZAPD/Main.cpp | 119 |
1 files changed, 69 insertions, 50 deletions
diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index 6b2ae4e..963b77c 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -85,11 +85,11 @@ int main(int argc, char* argv[]) int NewMain(int argc, char* argv[]) { - // Syntax: ZAPD.exe [mode (b/btex/bovl/e)] (Arbritrary Number of Arguments) + // Syntax: ZAPD.exe [mode (btex/bovl/e)] (Arbritrary Number of Arguments) if (argc < 2) { - printf("ZAPD.exe [mode (b/btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n"); + printf("ZAPD.exe (%s) [mode (btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n", gBuildHash); return 1; } @@ -97,9 +97,7 @@ int NewMain(int argc, char* argv[]) string buildMode = argv[1]; ZFileMode fileMode = ZFileMode::Invalid; - if (buildMode == "b") - fileMode = ZFileMode::Build; - else if (buildMode == "btex") + if (buildMode == "btex") fileMode = ZFileMode::BuildTexture; else if (buildMode == "bren") fileMode = ZFileMode::BuildPrerender; @@ -130,6 +128,10 @@ int NewMain(int argc, char* argv[]) if (arg == "-o" || arg == "--outputpath") // Set output path { Globals::Instance->outputPath = argv[i + 1]; + + if (Globals::Instance->sourceOutputPath == "") + Globals::Instance->sourceOutputPath = Globals::Instance->outputPath; + i++; } else if (arg == "-i" || arg == "--inputpath") // Set input path @@ -142,6 +144,11 @@ int NewMain(int argc, char* argv[]) Globals::Instance->baseRomPath = argv[i + 1]; i++; } + else if (arg == "-osf") // Set source output path + { + Globals::Instance->sourceOutputPath = argv[i + 1]; + i++; + } else if (arg == "-gsf") // Generate source file during extraction { Globals::Instance->genSourceFile = string(argv[i + 1]) == "1"; @@ -157,6 +164,11 @@ int NewMain(int argc, char* argv[]) Globals::Instance->testMode = string(argv[i + 1]) == "1"; i++; } + else if (arg == "-ulzdl") // Use Legacy ZDisplay List (Linux builds only) + { + Globals::Instance->useLegacyZDList = string(argv[i + 1]) == "1"; + i++; + } else if (arg == "-profile") // Profile { Globals::Instance->profile = string(argv[i + 1]) == "1"; @@ -201,6 +213,8 @@ int NewMain(int argc, char* argv[]) #if !defined(_MSC_VER) && !defined(__CYGWIN__) signal(SIGSEGV, ErrorHandler); signal(SIGABRT, ErrorHandler); +#else + printf("Warning: Tried to set error handler, but this build lacks support for one.\n"); #endif } else if (arg == "-v") // Verbose @@ -212,55 +226,62 @@ int NewMain(int argc, char* argv[]) if (Globals::Instance->verbosity >= VERBOSITY_INFO) printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash); - if (fileMode == ZFileMode::Build || fileMode == ZFileMode::Extract || - fileMode == ZFileMode::BuildSourceFile) + try { - bool parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, - Globals::Instance->outputPath, fileMode); - if (!parseSuccessful) + if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile) { - return 1; + bool parseSuccessful = + Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, + Globals::Instance->outputPath, fileMode); + + if (!parseSuccessful) + return 1; } - } - else if (fileMode == ZFileMode::BuildTexture) - { - TextureType texType = Globals::Instance->texType; - string pngFilePath = Globals::Instance->inputPath; - string outFilePath = Globals::Instance->outputPath; + else if (fileMode == ZFileMode::BuildTexture) + { + TextureType texType = Globals::Instance->texType; + string pngFilePath = Globals::Instance->inputPath; + string outFilePath = Globals::Instance->outputPath; - BuildAssetTexture(pngFilePath, texType, outFilePath); - } - else if (fileMode == ZFileMode::BuildPrerender) - { - string imageFilePath = Globals::Instance->inputPath; - string outFilePath = Globals::Instance->outputPath; + BuildAssetTexture(pngFilePath, texType, outFilePath); + } + else if (fileMode == ZFileMode::BuildPrerender) + { + string imageFilePath = Globals::Instance->inputPath; + string outFilePath = Globals::Instance->outputPath; - BuildAssetPrerender(imageFilePath, outFilePath); - } - else if (fileMode == ZFileMode::BuildBlob) - { - string blobFilePath = Globals::Instance->inputPath; - string outFilePath = Globals::Instance->outputPath; + BuildAssetPrerender(imageFilePath, outFilePath); + } + else if (fileMode == ZFileMode::BuildBlob) + { + string blobFilePath = Globals::Instance->inputPath; + string outFilePath = Globals::Instance->outputPath; - BuildAssetBlob(blobFilePath, outFilePath); - } - else if (fileMode == ZFileMode::BuildModelIntermediette) - { - BuildAssetModelIntermediette(Globals::Instance->inputPath, Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildAnimationIntermediette) - { - BuildAssetAnimationIntermediette(Globals::Instance->inputPath, - Globals::Instance->outputPath); + BuildAssetBlob(blobFilePath, outFilePath); + } + else if (fileMode == ZFileMode::BuildModelIntermediette) + { + BuildAssetModelIntermediette(Globals::Instance->inputPath, + Globals::Instance->outputPath); + } + else if (fileMode == ZFileMode::BuildAnimationIntermediette) + { + BuildAssetAnimationIntermediette(Globals::Instance->inputPath, + Globals::Instance->outputPath); + } + else if (fileMode == ZFileMode::BuildOverlay) + { + ZOverlay* overlay = + ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath), + Path::GetDirectoryName(Globals::Instance->cfgPath)); + + if (overlay) + File::WriteAllText(Globals::Instance->outputPath, overlay->GetSourceOutputCode("")); + } } - else if (fileMode == ZFileMode::BuildOverlay) + catch (std::runtime_error e) { - ZOverlay* overlay = - ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath), - Path::GetDirectoryName(Globals::Instance->cfgPath)); - - if (overlay) - File::WriteAllText(Globals::Instance->outputPath, overlay->GetSourceOutputCode("")); + printf("Exception occurred: %s\n", e.what()); } return 0; @@ -298,9 +319,7 @@ bool Parse(const std::string& xmlFilePath, const std::string& basePath, const st for (ZFile* file : Globals::Instance->files) { - if (fileMode == ZFileMode::Build) - file->BuildResources(); - else if (fileMode == ZFileMode::BuildSourceFile) + if (fileMode == ZFileMode::BuildSourceFile) file->BuildSourceFile(outPath); else file->ExtractResources(outPath); @@ -337,7 +356,7 @@ void BuildAssetTexture(const std::string& pngFilePath, TextureType texType, void BuildAssetPrerender(const std::string& imageFilePath, const std::string& outPath) { - ZPrerender prerender; + ZPrerender prerender = ZPrerender(nullptr); prerender.ParseBinaryFile(imageFilePath, false); |
