Skip to content

Commit 0742779

Browse files
jabermonyxTVaser
andauthored
Jak3 Build Environment (#3098)
This sets out the bones of a Jak 3 build, many things are stubbed out, guessed, or copied from Jak 2 but it should at least be good enough to: run `task set-game-jak3` launch the repl run builds from the repl build outputs themselves are untested but the build itself runs without errors --------- Co-authored-by: Tyler Wilding <[email protected]>
1 parent 637b043 commit 0742779

File tree

324 files changed

+72457
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+72457
-379
lines changed

.prettierrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"endOfLine": "auto",
3+
"overrides": [
4+
{
5+
"files": ["**/*.jsonc"],
6+
"options": {
7+
"parser": "json"
8+
}
9+
}
10+
]
11+
}

Taskfile.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,23 @@ tasks:
7474
msg: "Couldn't locate compiler executable in '{{.GOALC_BIN_RELEASE_DIR}}/goalc'"
7575
cmds:
7676
- "{{.GOALC_BIN_RELEASE_DIR}}/goalc --user-auto --game {{.GAME}}"
77-
format:
77+
format-json:
7878
desc: "Format code"
7979
cmds:
80-
- cmd: python ./scripts/cpp/format-includes.py
81-
- cmd: python ./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test tools lsp -i
8280
# npm install -g prettier
8381
- cmd: npx prettier --write ./decompiler/config/jak1/**/*.jsonc
8482
ignore_error: true
8583
- cmd: npx prettier --write ./decompiler/config/jak2/**/*.jsonc
8684
ignore_error: true
87-
format-json:
85+
- cmd: npx prettier --write ./decompiler/config/jak3/**/*.jsonc
86+
ignore_error: true
87+
format:
8888
desc: "Format code"
8989
cmds:
90-
# npm install -g prettier
91-
- cmd: npx prettier --write ./decompiler/config/jak1/**/*.jsonc
92-
ignore_error: true
93-
- cmd: npx prettier --write ./decompiler/config/jak2/**/*.jsonc
94-
ignore_error: true
90+
- cmd: python ./scripts/cpp/format-includes.py
91+
- cmd: python ./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test tools lsp -i
92+
- task: format-json
93+
9594
# DECOMPILING
9695
decomp:
9796
cmds:

common/versions/versions.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ GameVersion game_name_to_version(const std::string& name) {
1111
return GameVersion::Jak1;
1212
} else if (name == "jak2") {
1313
return GameVersion::Jak2;
14+
} else if (name == "jak3") {
15+
return GameVersion::Jak3;
1416
} else {
1517
ASSERT_MSG(false, fmt::format("invalid game name: {}", name));
1618
}
1719
}
1820

1921
bool valid_game_version(const std::string& name) {
20-
return name == "jak1" || name == "jak2";
22+
return name == "jak1" || name == "jak2" || name == "jak3";
2123
}
2224

2325
std::string version_to_game_name(GameVersion v) {
@@ -26,6 +28,8 @@ std::string version_to_game_name(GameVersion v) {
2628
return "jak1";
2729
case GameVersion::Jak2:
2830
return "jak2";
31+
case GameVersion::Jak3:
32+
return "jak3";
2933
default:
3034
ASSERT_MSG(false, fmt::format("no game_name for version: {} found", fmt::underlying(v)));
3135
}
@@ -37,13 +41,16 @@ std::string version_to_game_name_external(GameVersion v) {
3741
return "Jak 1";
3842
case GameVersion::Jak2:
3943
return "Jak 2";
44+
case GameVersion::Jak3:
45+
return "Jak 3";
4046
default:
4147
ASSERT_MSG(false, fmt::format("no game_name for version: {} found", fmt::underlying(v)));
4248
}
4349
}
4450

4551
std::vector<std::string> valid_game_version_names() {
46-
return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2]};
52+
return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2],
53+
game_version_names[GameVersion::Jak3]};
4754
}
4855

4956
std::string build_revision() {

decompiler/IR2/AtomicOpTypeAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ TP_Type SimpleExpression::get_type(const TypeState& input,
191191
return TP_Type::make_from_ts("float");
192192
}
193193
// new for jak 2:
194-
if (env.version == GameVersion::Jak2 && in_type.is_integer_constant() &&
194+
if (env.version >= GameVersion::Jak2 && in_type.is_integer_constant() &&
195195
(s64)((s32)in_type.get_integer_constant()) == (s64)in_type.get_integer_constant()) {
196196
return TP_Type::make_from_ts("float");
197197
}
@@ -406,7 +406,7 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input,
406406
}
407407

408408
if (m_kind == Kind::RIGHT_SHIFT_ARITH) {
409-
if (env.version == GameVersion::Jak2 && arg0_type.typespec().base_type() == "float") {
409+
if (env.version >= GameVersion::Jak2 && arg0_type.typespec().base_type() == "float") {
410410
return TP_Type::make_from_ts(TypeSpec("float"));
411411
}
412412
return TP_Type::make_from_ts(TypeSpec("int"));

decompiler/IR2/ExpressionHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ FormElement* handle_get_property_struct(const std::vector<Form*>& forms,
170170
const Env& env) {
171171
return handle_get_property_data_or_structure(
172172
forms, pool, env, ResLumpMacroElement::Kind::STRUCT,
173-
env.version == GameVersion::Jak2 ? "(the-as structure #f)" : "#f", TypeSpec("structure"));
173+
env.version >= GameVersion::Jak2 ? "(the-as structure #f)" : "#f", TypeSpec("structure"));
174174
}
175175

176176
FormElement* handle_get_property_value(const std::vector<Form*>& forms,

decompiler/IR2/Form.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,7 @@ goos::Object DefpartgroupElement::to_form_internal(const Env& env) const {
32553255

32563256
if (offset) {
32573257
// jak2 has switched this field to a signed 16 bit number
3258-
if (env.version == GameVersion::Jak2) {
3258+
if (env.version >= GameVersion::Jak2) {
32593259
result += fmt::format(" :offset {}", (s16)offset);
32603260
} else {
32613261
result += fmt::format(" :offset {}", offset);

decompiler/IR2/FormExpressionAnalysis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Form* try_cast_simplify(Form* in,
122122
return in;
123123
}
124124

125-
if (env.version == GameVersion::Jak2) {
125+
if (env.version >= GameVersion::Jak2) {
126126
if (new_type == TypeSpec("float")) {
127127
auto ic = get_goal_integer_constant(in, env);
128128
if (ic) {
@@ -138,7 +138,7 @@ Form* try_cast_simplify(Form* in,
138138
if (new_type == TypeSpec("meters")) {
139139
auto fc = get_goal_float_constant(in);
140140

141-
if (!fc && env.version == GameVersion::Jak2) {
141+
if (!fc && env.version >= GameVersion::Jak2) {
142142
auto ic = get_goal_integer_constant(in, env);
143143
if (ic) {
144144
ASSERT((s64)*ic == (s64)(s32)*ic);
@@ -2853,7 +2853,7 @@ bool try_to_rewrite_vector_inline_ctor(const Env& env,
28532853
token_matchers = {DerefTokenMatcher::string("quad")};
28542854
}
28552855

2856-
if (env.version == GameVersion::Jak2) {
2856+
if (env.version >= GameVersion::Jak2) {
28572857
token_matchers = {DerefTokenMatcher::string("quad")};
28582858
}
28592859

@@ -3376,7 +3376,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
33763376
argset = argset.substr(1);
33773377
auto argsym = arg_forms.at(1)->to_string(env);
33783378
// convert the float param
3379-
if (env.version == GameVersion::Jak2) {
3379+
if (env.version >= GameVersion::Jak2) {
33803380
static const std::unordered_set<std::string> use_degrees_settings = {
33813381
"matrix-blend-max-angle",
33823382
"fov",
@@ -4081,7 +4081,7 @@ void DerefElement::update_from_stack(const Env& env,
40814081
}
40824082

40834083
auto as_simple_expr = m_base->try_as_element<SimpleExpressionElement>();
4084-
if (env.version == GameVersion::Jak2 && as_simple_expr && as_simple_expr->expr().is_identity() &&
4084+
if (env.version >= GameVersion::Jak2 && as_simple_expr && as_simple_expr->expr().is_identity() &&
40854085
as_simple_expr->expr().get_arg(0).is_sym_val() &&
40864086
as_simple_expr->expr().get_arg(0).get_str() == "*game-info*" && m_tokens.size() >= 2 &&
40874087
m_tokens.at(0).is_field_name("sub-task-list") && m_tokens.at(1).is_int()) {

decompiler/ObjectFile/LinkedObjectFileCreation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
263263
const uint8_t* code_end =
264264
&data.at(code_offset + code_size - 1) + 1; // get the pointer to one past the end.
265265

266-
if (version == GameVersion::Jak2) {
266+
if (version >= GameVersion::Jak2) {
267267
while (((code_end - code_start) % 4)) {
268268
code_end++;
269269
}
@@ -689,7 +689,7 @@ static void link_v3(LinkedObjectFile& f,
689689
segment_size++;
690690
}
691691

692-
if (game_version == GameVersion::Jak2) {
692+
if (game_version >= GameVersion::Jak2) {
693693
while (segment_size % 4) {
694694
segment_size++;
695695
}

decompiler/ObjectFile/ObjectFileDB_IR2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF
647647
}
648648

649649
constexpr bool kForceNewTypes = false;
650-
if (config.game_version == GameVersion::Jak2 || kForceNewTypes) {
651-
// use new types for jak 2 always
650+
if (config.game_version != GameVersion::Jak1 || kForceNewTypes) {
651+
// use new types for jak 2/3 always
652652
types2::Input in;
653653
types2::Output out;
654654
in.func = &func;

0 commit comments

Comments
 (0)