add PAL support to extractor

This commit is contained in:
ManDude
2022-06-21 05:21:14 +01:00
parent e32cd4422a
commit 2a8badeb2c
5 changed files with 54 additions and 16 deletions
+1 -1
View File
@@ -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\""]
}
]
}
+17 -7
View File
@@ -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<u8> 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;
}
+4 -1
View File
@@ -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);
+17 -2
View File
@@ -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": {
}
}
+15 -5
View File
@@ -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<std::string, std::map<xxh::hash64_t, ISOMetadata>> 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<std::filesystem::path> 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<int>(ExtractorErrorCode::VALIDATION_BAD_DECOMP);
}
}
if (flag_runall || flag_compile) {