Skip to content

Commit

Permalink
decomp loader (#3373)
Browse files Browse the repository at this point in the history
fixes `defskelgroup` being broken in jak 2

switches jak 3 to the jak 3 font (currently identical to jak 2)
  • Loading branch information
ManDude authored Feb 13, 2024
1 parent d8181fb commit c99f9a4
Show file tree
Hide file tree
Showing 38 changed files with 6,133 additions and 428 deletions.
30 changes: 26 additions & 4 deletions common/util/FontUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
const std::unordered_map<std::string, GameTextVersion> sTextVerEnumMap = {
{"jak1-v1", GameTextVersion::JAK1_V1},
{"jak1-v2", GameTextVersion::JAK1_V2},
{"jak2", GameTextVersion::JAK2}};
{"jak2", GameTextVersion::JAK2},
{"jak3", GameTextVersion::JAK3}};

const std::string& get_text_version_name(GameTextVersion version) {
for (auto& [name, ver] : sTextVerEnumMap) {
Expand Down Expand Up @@ -261,7 +262,8 @@ bool GameTextFontBank::valid_char_range(const char in) const {
return ((in >= '0' && in <= '9') || (in >= 'A' && in <= 'Z') ||
m_passthrus->find(in) != m_passthrus->end()) &&
in != '\\';
} else if (m_version == GameTextVersion::JAK2) {
} else if (m_version == GameTextVersion::JAK2 || m_version == GameTextVersion::JAK3 ||
m_version == GameTextVersion::JAKX) {
return ((in >= '0' && in <= '9') || (in >= 'A' && in <= 'Z') || (in >= 'a' && in <= 'z') ||
m_passthrus->find(in) != m_passthrus->end()) &&
in != '\\';
Expand Down Expand Up @@ -913,7 +915,9 @@ GameTextFontBank g_font_bank_jak1_v2(GameTextVersion::JAK1_V2,
* GAME TEXT FONT BANK - JAK 2
* ================================
* This font is used in:
* - Jak 2 - NTSC - v1
* - Jak II
* - Jak II: Renegade
* - ジャックXダクスター2
*/

static std::unordered_set<char> s_passthrus_jak2 = {'~', ' ', ',', '.', '-', '+', '(', ')',
Expand Down Expand Up @@ -1904,6 +1908,21 @@ GameTextFontBank g_font_bank_jak2(GameTextVersion::JAK2,
&s_replace_info_jak2,
&s_passthrus_jak2);

/*!
* ================================
* GAME TEXT FONT BANK - JAK 3
* ================================
* This font is used in:
* - Jak 3
*/

// TODO cyrillic

GameTextFontBank g_font_bank_jak3(GameTextVersion::JAK3,
&s_encode_info_jak2,
&s_replace_info_jak2,
&s_passthrus_jak2);

/*!
* ========================
* GAME TEXT FONT BANK LIST
Expand All @@ -1914,7 +1933,8 @@ GameTextFontBank g_font_bank_jak2(GameTextVersion::JAK2,
std::map<GameTextVersion, GameTextFontBank*> g_font_banks = {
{GameTextVersion::JAK1_V1, &g_font_bank_jak1_v1},
{GameTextVersion::JAK1_V2, &g_font_bank_jak1_v2},
{GameTextVersion::JAK2, &g_font_bank_jak2}};
{GameTextVersion::JAK2, &g_font_bank_jak2},
{GameTextVersion::JAK3, &g_font_bank_jak3}};

const GameTextFontBank* get_font_bank(GameTextVersion version) {
return g_font_banks.at(version);
Expand All @@ -1927,6 +1947,8 @@ const GameTextFontBank* get_font_bank_from_game_version(GameVersion version) {
return get_font_bank(GameTextVersion::JAK1_V2);
case GameVersion::Jak2:
return get_font_bank(GameTextVersion::JAK2);
case GameVersion::Jak3:
return get_font_bank(GameTextVersion::JAK3);
default:
ASSERT_MSG(false, "Unsupported game for get_font_bank_from_game_version");
}
Expand Down
24 changes: 13 additions & 11 deletions decompiler/IR2/Form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3269,18 +3269,20 @@ goos::Object DefskelgroupElement::to_form_internal(const Env& env) const {
forms.push_back(
pretty_print::to_symbol(fmt::format(":light-index {}", m_static_info.light_index)));
}
if (m_static_info.global_effects != 0) {
forms.push_back(
pretty_print::to_symbol(fmt::format(":global-effects {}", m_static_info.global_effects)));
}
if (!m_static_info.clothing.empty()) {
std::vector<goos::Object> cloth_list;
forms.push_back(pretty_print::to_symbol(":clothing"));
for (const auto& p : m_static_info.clothing) {
auto macro = p.to_list(m_static_info.art_group_name + "-ag", env);
cloth_list.push_back(macro);
if (env.version != GameVersion::Jak2) {
if (m_static_info.global_effects != 0) {
forms.push_back(pretty_print::to_symbol(
fmt::format(":global-effects {}", m_static_info.global_effects)));
}
if (!m_static_info.clothing.empty()) {
std::vector<goos::Object> cloth_list;
forms.push_back(pretty_print::to_symbol(":clothing"));
for (const auto& p : m_static_info.clothing) {
auto macro = p.to_list(m_static_info.art_group_name + "-ag", env);
cloth_list.push_back(macro);
}
forms.push_back(pretty_print::build_list(cloth_list));
}
forms.push_back(pretty_print::build_list(cloth_list));
}
}

Expand Down
173 changes: 96 additions & 77 deletions decompiler/config/jak3/all-types.gc

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions decompiler/config/jak3/jak3_config.jsonc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"game_version": 3,
"text_version": 20,
"text_version": 30,

"game_name": "jak3",
"expected_elf_name": "SCUS_973.30",

// if you want to filter to only some object names.
// it will make the decompiler much faster.
"allowed_objects": [],
"banned_objects": [],
"banned_objects": ["collide-shape", "spatial-hash", "entity"],

////////////////////////////
// CODE ANALYSIS OPTIONS
Expand All @@ -35,7 +35,7 @@
// unpack textures to assets folder
"process_tpages": true,
// unpack game text to assets folder
"process_game_text": false,
"process_game_text": true,
// unpack game count to assets folder
"process_game_count": false,
// write goal imports for art groups
Expand Down
4 changes: 3 additions & 1 deletion decompiler/config/jak3/ntsc_v1/hacks.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@
"bsp-camera-asm": [1, 2, 3, 4, 6, 7],
"level-remap-texture": [2, 3, 4, 5, 6],
"start-perf-stat-collection": [26],
"end-perf-stat-collection": [0]
"end-perf-stat-collection": [0],

"(method 23 gui-control)": [10, 46, 50, 58, 81, 90, 101]
},

// Sometimes the game might use format strings that are fetched dynamically,
Expand Down
4 changes: 1 addition & 3 deletions decompiler/config/jak3/ntsc_v1/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,5 @@
["L303", "cloth-params"],
["L296", "cloth-params"]
],
"joint-mod": [
["L212", "(inline-array vector)", 3]
]
"joint-mod": [["L212", "(inline-array vector)", 3]]
}
3 changes: 2 additions & 1 deletion decompiler/config/jak3/ntsc_v1/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@
"joint-mod-joint-set-world-handler": [
[32, "vector"],
[48, "vector"]
]
],
"(method 13 gui-control)": [[16, ["array", "sound-id", 4]]]
}
53 changes: 47 additions & 6 deletions decompiler/config/jak3/ntsc_v1/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@
[15, "gp", "collide-shape-moving"],
[35, "gp", "collide-shape-moving"]
],
"joint-mod-rotate-world-callback": [
[[0, 24], "s3", "joint-mod-rotate-world"]
],
"joint-mod-set-local-callback": [[[1, 24], "v1", "joint-mod-set-local"]],
"joint-mod-add-local-callback": [[[1, 37], "s4", "joint-mod-add-local"]],
"joint-mod-set-world-callback": [[[1, 4], "v1", "joint-mod-set-local"]],
Expand Down Expand Up @@ -426,7 +423,6 @@
],
"ear-trans": [[32, "s5", "process-focusable"]],
"loader-test-command": [[[5, 10], "v1", "sound-rpc-test-cmd"]],
"(method 11 connection)": [[5, "a1", "pointer"]],
"update-light-hash": [
[[234, 239], "a1", "light-hash-bucket"],
[[207, 211], "a0", "light-hash-bucket"]
Expand Down Expand Up @@ -529,7 +525,6 @@
"texture-usage-init": [[27, "a1", "vector"]],
"(method 9 art)": [[9, "v1", "pointer"]],
"(code pov-camera-start-playing pov-camera)": [[24, "v0", "joint"]],
"(method 9 art)": [[9, "v1", "pointer"]],
"(method 9 art-mesh-geo)": [
[20, "s4", "(pointer int16)"],
[[14, 19], "a0", "drawable"],
Expand Down Expand Up @@ -649,5 +644,51 @@
[[78, 79], "a1", "drawable-tree-instance-tie"],
[123, "a1", "drawable-tree-instance-shrub"],
[[129, 133], "a2", "(inline-array prototype-bucket-shrub)"]
]
],
"drawable-load": [[16, "v0", "drawable"]],
"art-load": [[7, "v0", "art"]],
"art-group-load-check": [[21, "v0", "art-group"]],
"(method 9 external-art-control)": [
[[170, 191], "s4", "external-art-buffer"]
],
"(method 11 external-art-control)": [[19, "s5", "process-drawable"]],
"(method 15 gui-control)": [
[13, "s1", "gui-connection"],
[36, "s1", "gui-connection"],
[43, "s1", "gui-connection"],
[8, "s1", "gui-connection"]
],
"(method 14 gui-control)": [[[7, 41], "s2", "gui-connection"]],
"(method 13 gui-control)": [
[64, "s3", "gui-connection"],
[71, "s3", "gui-connection"]
],
"(method 17 gui-control)": [
[[45, 262], "gp", "gui-connection"],
[13, "v1", "gui-connection"]
],
"(method 16 gui-control)": [[[19, 118], "s1", "gui-connection"]],
"(method 9 gui-control)": [
[131, "v1", "gui-connection"],
[17, "v1", "gui-connection"],
[24, "v1", "gui-connection"],
[[115, 125], "v1", "gui-connection"],
[129, "v1", "gui-connection"],
[127, "a0", "gui-connection"]
],
"(method 10 gui-control)": [[[9, 32], "s3", "gui-connection"]],
"(method 12 gui-control)": [
[128, "v1", "gui-connection"],
[177, "v1", "process-drawable"],
[214, "v1", "gui-connection"]
],
"(method 22 gui-control)": [[54, "v1", "process-drawable"]],
"(method 21 gui-control)": [
[28, "v1", "process-drawable"],
[31, "v1", "process-drawable"],
[45, "s4", "process-drawable"],
[48, "s4", "process-drawable"],
[5, "v0", "sound-rpc-set-param"]
],
"(method 23 gui-control)": [[285, "v0", "sound-rpc-set-param"]]
}
Loading

0 comments on commit c99f9a4

Please sign in to comment.