Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jak3 Build Environment #3098

Merged
merged 27 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7331c03
Add Jak 3 to ./common
jabermony Oct 14, 2023
dcad01c
Add PAL override to jak3 decompiler config
jabermony Oct 14, 2023
a05217b
Add Jak 3 to update-env.py script
jabermony Oct 14, 2023
0032abc
Add initial draft of Jak3 build config
jabermony Oct 20, 2023
f6beb29
Add inline-array-class + int varients to all-types
jabermony Oct 21, 2023
76f9270
Add gkernel-h deftype clock to all-types
jabermony Oct 21, 2023
08212f0
Update gkernel-h deftype state for Jak 3
jabermony Oct 21, 2023
524941f
Update gkernel-h deftype kernel-context for Jak 3
jabermony Oct 21, 2023
c04455d
Add Jak3 case to goal_src/goal-lib.gc
jabermony Oct 22, 2023
94422ff
Add stubs for game\assets\jak3
jabermony Oct 22, 2023
616a7ed
Stub out animations for Jak3 game.gp
jabermony Oct 22, 2023
61be6ce
Update Jak3 game.gp MUSIC section
jabermony Oct 21, 2023
08016d6
Remove MUS references from Jak3 game.gp
jabermony Oct 22, 2023
59964d4
Update dgo files generation script to work with game.gp
jabermony Oct 22, 2023
a396085
Add Jak3 dgos to goal_src
jabermony Oct 21, 2023
6c23e43
Add updated project-lib.gp for Jak3
jabermony Oct 22, 2023
4fe5783
Add initial attempt at cgo-file entries for Jak3 game.gp
jabermony Oct 22, 2023
50551d7
Add Jak3 case to ObjectGenerator
jabermony Oct 22, 2023
8b81e41
Add freshly generated Jak 3 all-types.gc
jabermony Oct 22, 2023
4cbf2ea
Fix formatting in versions.cpp to please linter
jabermony Oct 22, 2023
f7f628c
Update decompiler checks for '== Jak2' to '>= Jak2'
jabermony Oct 25, 2023
da8722d
Merge remote-tracking branch 'open-goal/master' into jak3-build
xTVaser Jan 15, 2024
36e49f8
d/j3: update all-types
xTVaser Jan 16, 2024
74ddf88
d/j3: fix mis-identification of virtual state
xTVaser Jan 16, 2024
c173754
d/j3: revert symbol handling
xTVaser Jan 16, 2024
5d2cbad
d/j3: re-generate all-types again
xTVaser Jan 16, 2024
50e398b
lint: formatting and fix prettier since nlohmann::json's jsonc parser…
xTVaser Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"endOfLine": "auto",
"overrides": [
{
"files": ["**/*.jsonc"],
"options": {
"parser": "json"
}
}
]
}
17 changes: 8 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,23 @@ tasks:
msg: "Couldn't locate compiler executable in '{{.GOALC_BIN_RELEASE_DIR}}/goalc'"
cmds:
- "{{.GOALC_BIN_RELEASE_DIR}}/goalc --user-auto --game {{.GAME}}"
format:
format-json:
desc: "Format code"
cmds:
- cmd: python ./scripts/cpp/format-includes.py
- cmd: python ./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test tools lsp -i
# npm install -g prettier
- cmd: npx prettier --write ./decompiler/config/jak1/**/*.jsonc
ignore_error: true
- cmd: npx prettier --write ./decompiler/config/jak2/**/*.jsonc
ignore_error: true
format-json:
- cmd: npx prettier --write ./decompiler/config/jak3/**/*.jsonc
ignore_error: true
format:
desc: "Format code"
cmds:
# npm install -g prettier
- cmd: npx prettier --write ./decompiler/config/jak1/**/*.jsonc
ignore_error: true
- cmd: npx prettier --write ./decompiler/config/jak2/**/*.jsonc
ignore_error: true
- cmd: python ./scripts/cpp/format-includes.py
- cmd: python ./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test tools lsp -i
- task: format-json

# DECOMPILING
decomp:
cmds:
Expand Down
11 changes: 9 additions & 2 deletions common/versions/versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ GameVersion game_name_to_version(const std::string& name) {
return GameVersion::Jak1;
} else if (name == "jak2") {
return GameVersion::Jak2;
} else if (name == "jak3") {
return GameVersion::Jak3;
} else {
ASSERT_MSG(false, fmt::format("invalid game name: {}", name));
}
}

bool valid_game_version(const std::string& name) {
return name == "jak1" || name == "jak2";
return name == "jak1" || name == "jak2" || name == "jak3";
}

std::string version_to_game_name(GameVersion v) {
Expand All @@ -26,6 +28,8 @@ std::string version_to_game_name(GameVersion v) {
return "jak1";
case GameVersion::Jak2:
return "jak2";
case GameVersion::Jak3:
return "jak3";
default:
ASSERT_MSG(false, fmt::format("no game_name for version: {} found", fmt::underlying(v)));
}
Expand All @@ -37,13 +41,16 @@ std::string version_to_game_name_external(GameVersion v) {
return "Jak 1";
case GameVersion::Jak2:
return "Jak 2";
case GameVersion::Jak3:
return "Jak 3";
default:
ASSERT_MSG(false, fmt::format("no game_name for version: {} found", fmt::underlying(v)));
}
}

std::vector<std::string> valid_game_version_names() {
return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2]};
return {game_version_names[GameVersion::Jak1], game_version_names[GameVersion::Jak2],
game_version_names[GameVersion::Jak3]};
}

std::string build_revision() {
Expand Down
4 changes: 2 additions & 2 deletions decompiler/IR2/AtomicOpTypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ TP_Type SimpleExpression::get_type(const TypeState& input,
return TP_Type::make_from_ts("float");
}
// new for jak 2:
if (env.version == GameVersion::Jak2 && in_type.is_integer_constant() &&
if (env.version >= GameVersion::Jak2 && in_type.is_integer_constant() &&
(s64)((s32)in_type.get_integer_constant()) == (s64)in_type.get_integer_constant()) {
return TP_Type::make_from_ts("float");
}
Expand Down Expand Up @@ -406,7 +406,7 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input,
}

if (m_kind == Kind::RIGHT_SHIFT_ARITH) {
if (env.version == GameVersion::Jak2 && arg0_type.typespec().base_type() == "float") {
if (env.version >= GameVersion::Jak2 && arg0_type.typespec().base_type() == "float") {
return TP_Type::make_from_ts(TypeSpec("float"));
}
return TP_Type::make_from_ts(TypeSpec("int"));
Expand Down
2 changes: 1 addition & 1 deletion decompiler/IR2/ExpressionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ FormElement* handle_get_property_struct(const std::vector<Form*>& forms,
const Env& env) {
return handle_get_property_data_or_structure(
forms, pool, env, ResLumpMacroElement::Kind::STRUCT,
env.version == GameVersion::Jak2 ? "(the-as structure #f)" : "#f", TypeSpec("structure"));
env.version >= GameVersion::Jak2 ? "(the-as structure #f)" : "#f", TypeSpec("structure"));
}

FormElement* handle_get_property_value(const std::vector<Form*>& forms,
Expand Down
2 changes: 1 addition & 1 deletion decompiler/IR2/Form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,7 @@ goos::Object DefpartgroupElement::to_form_internal(const Env& env) const {

if (offset) {
// jak2 has switched this field to a signed 16 bit number
if (env.version == GameVersion::Jak2) {
if (env.version >= GameVersion::Jak2) {
result += fmt::format(" :offset {}", (s16)offset);
} else {
result += fmt::format(" :offset {}", offset);
Expand Down
10 changes: 5 additions & 5 deletions decompiler/IR2/FormExpressionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Form* try_cast_simplify(Form* in,
return in;
}

if (env.version == GameVersion::Jak2) {
if (env.version >= GameVersion::Jak2) {
if (new_type == TypeSpec("float")) {
auto ic = get_goal_integer_constant(in, env);
if (ic) {
Expand All @@ -138,7 +138,7 @@ Form* try_cast_simplify(Form* in,
if (new_type == TypeSpec("meters")) {
auto fc = get_goal_float_constant(in);

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

if (env.version == GameVersion::Jak2) {
if (env.version >= GameVersion::Jak2) {
token_matchers = {DerefTokenMatcher::string("quad")};
}

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

auto as_simple_expr = m_base->try_as_element<SimpleExpressionElement>();
if (env.version == GameVersion::Jak2 && as_simple_expr && as_simple_expr->expr().is_identity() &&
if (env.version >= GameVersion::Jak2 && as_simple_expr && as_simple_expr->expr().is_identity() &&
as_simple_expr->expr().get_arg(0).is_sym_val() &&
as_simple_expr->expr().get_arg(0).get_str() == "*game-info*" && m_tokens.size() >= 2 &&
m_tokens.at(0).is_field_name("sub-task-list") && m_tokens.at(1).is_int()) {
Expand Down
4 changes: 2 additions & 2 deletions decompiler/ObjectFile/LinkedObjectFileCreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
const uint8_t* code_end =
&data.at(code_offset + code_size - 1) + 1; // get the pointer to one past the end.

if (version == GameVersion::Jak2) {
if (version >= GameVersion::Jak2) {
while (((code_end - code_start) % 4)) {
code_end++;
}
Expand Down Expand Up @@ -689,7 +689,7 @@ static void link_v3(LinkedObjectFile& f,
segment_size++;
}

if (game_version == GameVersion::Jak2) {
if (game_version >= GameVersion::Jak2) {
while (segment_size % 4) {
segment_size++;
}
Expand Down
4 changes: 2 additions & 2 deletions decompiler/ObjectFile/ObjectFileDB_IR2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF
}

constexpr bool kForceNewTypes = false;
if (config.game_version == GameVersion::Jak2 || kForceNewTypes) {
// use new types for jak 2 always
if (config.game_version != GameVersion::Jak1 || kForceNewTypes) {
// use new types for jak 2/3 always
types2::Input in;
types2::Output out;
in.func = &func;
Expand Down
19 changes: 18 additions & 1 deletion decompiler/analysis/analyze_inspect_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,24 @@ void inspect_top_level_for_metadata(Function& top_level,
if (state_name.empty()) {
continue;
}
objectFile.state_methods[type_match][method_id] = state_name;
// Ensure there are no labels between now and when the `method-set!` is actually called
bool was_another_label = false;
for (int j = i; j < (int)top_level.ir2.atomic_ops->ops.size(); j++) {
const auto& temp_aop = top_level.ir2.atomic_ops->ops.at(j);
const std::string temp_as_str = temp_aop.get()->to_string(top_level.ir2.env);
if (temp_as_str.find("call!") != std::string::npos) {
break;
}
auto temp_label_match =
get_regex_match(temp_as_str, std::regex("\\(set!\\s[^\\s]*\\s(L.*)\\)"));
if (!temp_label_match.empty()) {
was_another_label = true;
break;
}
}
if (!was_another_label) {
objectFile.state_methods[type_match][method_id] = state_name;
}
}
}

Expand Down
Loading