PAL & NTSC-J support + updates (#1490)

* PAL dumps files

* alrighty then

* make PAL warning slightly more specific

* PAL patches for `title-obs`

* Update all-types.gc

* PAL patch `beach-obs`

* `process-taskable` PAL patch

* `ambient` PAL patch

* `yakow` PAL patch

* `village-obs` PAL patch

* `sparticle-launcher` patch

* `swamp-obs` PAL patch

* `sequence-a-village1` PAL patch

* typo

* errors

* `powerups` PAL patch

* `ogreboss` PAL patch

* jak 1 v2 encoding

* `load-boundary` PAL patch

* `flying-lurker` PAL patch

* `mayor` PAL patch

* update game encoding to PAL (v2) encoding

* `cam-debug` and `cam-update` PAL patch

* `fisher` PAL patch

* `target` PAL patch

* `target2` PAL patch and fix text compiling

* `target-death` PAL patch

* `target-racer-h` PAL patch

* `logic-target` PAL patch

* `main` PAL patch

* `snow-flutflut-obs` PAL patch

* `rolling-obs` PAL patch

* `gsound` PAL patch

* update refs

* `progress` and `progress-draw` PAL patches

* clang

* wrong.

* complain

* clang

* fix test

* fix blurry jp text

* fix weird interrupt lag from setting window size

* patch more text lines, special handling for credits

* Update FontUtils.cpp

* Add xdelta3 and file patching interface

* add window lock toggle and update settings ver

* better particle hacks

* add PAL support to extractor

* Fix credits

* also NTSC-J support

* make xdelta3 a separate library

* address feedback

Co-authored-by: water <awaterford111445@gmail.com>
This commit is contained in:
ManDude
2022-06-22 05:16:34 +01:00
committed by GitHub
parent 90a049dcc5
commit 7d5045ab3f
92 changed files with 14446 additions and 9934 deletions
+40 -16
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,
DECOMPILATION_GENERIC_ERROR = 4030
};
struct ISOMetadata {
@@ -31,11 +32,19 @@ struct ISOMetadata {
// this will let the installer reject (or gracefully handle) jak2 isos on the jak1 page, etc.
// { SERIAL : { ELF_HASH : ISOMetadataDatabase } }
static std::map<std::string, std::map<xxh::hash64_t, ISOMetadata>> isoDatabase{
static const 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"}}}},
{"SCPS-15021",
{{16909372048085114219U,
{"ジャックXダクスター  旧世界の遺産", "NTSC-J", 338, 1262350561338887717,
"jak1_jp"}}}}};
void setup_global_decompiler_stuff(std::optional<std::filesystem::path> project_path_override) {
decompiler::init_opcode_info();
@@ -50,7 +59,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;
}
@@ -108,8 +117,7 @@ ExtractorErrorCode validate(const IsoFile& iso_file,
}
// Find the game in our tracking database
auto dbEntry = isoDatabase.find(serial.value());
if (dbEntry == isoDatabase.end()) {
if (auto dbEntry = isoDatabase.find(serial.value()); dbEntry == isoDatabase.end()) {
fmt::print(stderr, "ERROR: Serial '{}' not found in the validation database\n", serial.value());
if (!error_code.has_value()) {
error_code = std::make_optional(ExtractorErrorCode::VALIDATION_SERIAL_MISSING_FROM_DB);
@@ -176,7 +184,7 @@ ExtractorErrorCode validate(const IsoFile& iso_file,
} else {
fmt::print(stderr,
"Validation has failed to match with expected values, see the above errors for "
"specific. This may be an error in the validation database!\n");
"specifics. This may be an error in the validation database!\n");
}
return error_code.value();
}
@@ -242,7 +250,7 @@ void decompile(std::filesystem::path jak1_input_files) {
// grab all the object files we need (just text)
for (const auto& obj_name : config.object_file_names) {
if (obj_name.length() > 3 && obj_name.substr(obj_name.length() - 3) == "TXT") {
// ends in DGO, it's a level
// ends in TXT
objs.push_back((jak1_input_files / obj_name).string());
}
}
@@ -349,6 +357,12 @@ int main(int argc, char** argv) {
fmt::print("Running all steps, no flags provided!\n");
flag_runall = true;
}
if (flag_runall) {
flag_extract = true;
flag_decompile = true;
flag_compile = true;
flag_play = true;
}
// todo: print revision here.
if (!project_path_override.empty()) {
@@ -357,8 +371,7 @@ int main(int argc, char** argv) {
setup_global_decompiler_stuff(std::nullopt);
}
std::filesystem::path path_to_iso_files = file_util::get_jak_project_dir() / "iso_data" / "jak1";
std::filesystem::create_directories(path_to_iso_files);
std::filesystem::path path_to_iso_files = file_util::get_jak_project_dir() / "iso_data" / "_temp";
// make sure the input looks right
if (!std::filesystem::exists(data_dir_path)) {
@@ -366,7 +379,13 @@ int main(int argc, char** argv) {
return 1;
}
if (flag_runall || flag_extract) {
if (flag_extract) {
if (data_dir_path != path_to_iso_files) {
// in case input is also output, don't just wipe everything (weird)
std::filesystem::remove_all(path_to_iso_files);
}
std::filesystem::create_directories(path_to_iso_files);
if (std::filesystem::is_regular_file(data_dir_path)) {
// it's a file, treat it as an ISO
auto iso_file = extract_files(data_dir_path, path_to_iso_files);
@@ -387,15 +406,20 @@ int main(int argc, char** argv) {
}
}
if (flag_runall || flag_decompile) {
decompile(path_to_iso_files);
if (flag_decompile) {
try {
decompile(path_to_iso_files);
} catch (std::exception& e) {
lg::error("Error during decompile: {}", e.what());
return static_cast<int>(ExtractorErrorCode::DECOMPILATION_GENERIC_ERROR);
}
}
if (flag_runall || flag_compile) {
if (flag_compile) {
compile(path_to_iso_files);
}
if (flag_runall || flag_play) {
if (flag_play) {
launch_game();
}