From 2a8badeb2c60445eb38860f39b46dadd50f463e7 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Tue, 21 Jun 2022 05:21:14 +0100 Subject: [PATCH] add PAL support to extractor --- .vs/launch.vs.json | 2 +- common/util/read_iso_file.cpp | 24 +++++++++++++++++------- common/util/read_iso_file.h | 5 ++++- decompiler/config/jak1_pal.jsonc | 19 +++++++++++++++++-- decompiler/extractor/main.cpp | 20 +++++++++++++++----- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.vs/launch.vs.json b/.vs/launch.vs.json index 2aee440c17..6ca4d8c457 100644 --- a/.vs/launch.vs.json +++ b/.vs/launch.vs.json @@ -138,7 +138,7 @@ "project" : "CMakeLists.txt", "projectTarget" : "extractor.exe (bin\\extractor.exe)", "name" : "Run - Extractor - Extract", - "args" : [ "\"E:\\ISOs\\Jak\\Jak 1.iso\"", "--extract", "--proj-path", "C:\\Users\\xtvas\\Repositories\\opengoal\\launcher\\bundle-test\\data"] + "args" : [ "\"C:\\Game\\PS2SMB\\DVD\\SCES_503.61.Jak & Daxter - TPL (PAL).iso\""] } ] } diff --git a/common/util/read_iso_file.cpp b/common/util/read_iso_file.cpp index 85ef213c60..6e65ddf43f 100644 --- a/common/util/read_iso_file.cpp +++ b/common/util/read_iso_file.cpp @@ -1,5 +1,5 @@ #include "read_iso_file.h" -#include "third-party/fmt/core.h" +#include "common/log/log.h" #include "common/common_types.h" #include "common/util/Assert.h" #include "common/util/FileUtil.h" @@ -79,14 +79,18 @@ void add_from_dir(FILE* fp, u32 sector, u32 size, IsoFile::Entry* parent) { void unpack_entry(FILE* fp, IsoFile& iso, const IsoFile::Entry& entry, - const std::filesystem::path& dest) { + const std::filesystem::path& dest, + bool print_progress) { std::filesystem::path path_to_entry = dest / entry.name; if (entry.is_dir) { std::filesystem::create_directory(path_to_entry); for (const auto& child : entry.children) { - unpack_entry(fp, iso, child, path_to_entry); + unpack_entry(fp, iso, child, path_to_entry, print_progress); } } else { + if (print_progress) { + lg::info("Extracting {}...", entry.name); + } std::vector buffer(entry.size); if (fseek(fp, entry.offset_in_file, SEEK_SET)) { ASSERT_MSG(false, "Failed to fseek iso when unpacking"); @@ -113,13 +117,19 @@ IsoFile find_files_in_iso(FILE* fp) { return result; } -void unpack_iso_files(FILE* fp, IsoFile& layout, const std::filesystem::path& dest) { - unpack_entry(fp, layout, layout.root, dest); +void unpack_iso_files(FILE* fp, + IsoFile& layout, + const std::filesystem::path& dest, + bool print_progress) { + unpack_entry(fp, layout, layout.root, dest, print_progress); } -IsoFile unpack_iso_files(FILE* fp, const std::filesystem::path& dest, const bool hashFiles) { +IsoFile unpack_iso_files(FILE* fp, + const std::filesystem::path& dest, + bool print_progress, + const bool hashFiles) { auto file = find_files_in_iso(fp); file.shouldHash = hashFiles; - unpack_iso_files(fp, file, dest); + unpack_iso_files(fp, file, dest, print_progress); return file; } diff --git a/common/util/read_iso_file.h b/common/util/read_iso_file.h index e71a4a7c19..6109d90cce 100644 --- a/common/util/read_iso_file.h +++ b/common/util/read_iso_file.h @@ -34,4 +34,7 @@ struct IsoFile { IsoFile find_files_in_iso(FILE* fp); void unpack_iso_files(FILE* fp, IsoFile& layout, const std::filesystem::path& dest); -IsoFile unpack_iso_files(FILE* fp, const std::filesystem::path& dest, const bool hashFiles = false); +IsoFile unpack_iso_files(FILE* fp, + const std::filesystem::path& dest, + bool print_progress, + const bool hashFiles = false); diff --git a/decompiler/config/jak1_pal.jsonc b/decompiler/config/jak1_pal.jsonc index 9118f7c101..9621d7d2bc 100644 --- a/decompiler/config/jak1_pal.jsonc +++ b/decompiler/config/jak1_pal.jsonc @@ -92,10 +92,25 @@ //////////////////////////// // turn this on to extract level background graphics data - "levels_extract": false, + "levels_extract": true, // turn this on if you want extracted levels to be saved out as .obj files "levels_convert_to_obj": false, // should we extract collision meshes? // these can be displayed in game, but makes the .fr3 files slightly larger - "extract_collision": true + "extract_collision": true, + + //////////////////////////// + // PATCHING OPTIONS + //////////////////////////// + + // these are options related to xdelta3 patches on specific objects + // this allows us to get a more consistent input + + // set to true to write new patch files + "write_patches": false, + // set to true to apply patch files + "apply_patches": true, + // what to patch an object to and the patch file is + "object_patches": { + } } diff --git a/decompiler/extractor/main.cpp b/decompiler/extractor/main.cpp index 166c8d0f11..6de90dfe04 100644 --- a/decompiler/extractor/main.cpp +++ b/decompiler/extractor/main.cpp @@ -16,7 +16,8 @@ enum class ExtractorErrorCode { VALIDATION_ELF_MISSING_FROM_DB = 4002, VALIDATION_BAD_ISO_CONTENTS = 4010, VALIDATION_INCORRECT_EXTRACTION_COUNT = 4011, - VALIDATION_BAD_EXTRACTION = 4020 + VALIDATION_BAD_EXTRACTION = 4020, + VALIDATION_BAD_DECOMP = 4021 }; struct ISOMetadata { @@ -34,8 +35,12 @@ struct ISOMetadata { static std::map> isoDatabase{ {"SCUS-97124", {{7280758013604870207U, - {"Jak and Daxter: The Precursor Legacy - Black Label", "NTSC-U", 337, 11363853835861842434U, - "jak1_ntsc_black_label"}}}}}; + {"Jak & Daxterâ„¢: The Precursor Legacy (Black Label)", "NTSC-U", 337, 11363853835861842434U, + "jak1_ntsc_black_label"}}}}, + {"SCES-50361", + {{12150718117852276522U, + {"Jak & Daxterâ„¢: The Precursor Legacy (PAL)", "PAL", 338, 16850370297611763875U, + "jak1_pal"}}}}}; void setup_global_decompiler_stuff(std::optional project_path_override) { decompiler::init_opcode_info(); @@ -50,7 +55,7 @@ IsoFile extract_files(std::filesystem::path data_dir_path, auto fp = fopen(data_dir_path.string().c_str(), "rb"); ASSERT_MSG(fp, "failed to open input ISO file\n"); - IsoFile iso = unpack_iso_files(fp, extracted_iso_path, true); + IsoFile iso = unpack_iso_files(fp, extracted_iso_path, true, true); fclose(fp); return iso; } @@ -388,7 +393,12 @@ int main(int argc, char** argv) { } if (flag_runall || flag_decompile) { - decompile(path_to_iso_files); + try { + decompile(path_to_iso_files); + } catch (std::exception& e) { + lg::error("Error during decompile: {}", e.what()); + return static_cast(ExtractorErrorCode::VALIDATION_BAD_DECOMP); + } } if (flag_runall || flag_compile) {