decomp3: more engine stuff, detect non-virtual state inheritance (#3377)

- `speech`
- `ambient`
- `water-h`
- `vol-h`
- `generic-obs`
- `carry-h`
- `pilot-h`
- `board-h`
- `gun-h`
- `flut-h`
- `indax-h`
- `lightjak-h`
- `darkjak-h`
- `target-util`
- `history`
- `collide-reaction-target`
- `logic-target`
- `sidekick`
- `projectile`
- `voicebox`
- `ragdoll-edit`
- most of `ragdoll` (not added to gsrc yet)
- `curves`
- `find-nearest`
- `lightjak-wings`
- `target-handler`
- `target-anim`
- `target`
- `target2`
- `target-swim`
- `target-lightjak`
- `target-invisible`
- `target-death`
- `target-gun`
- `gun-util`
- `board-util`
- `target-board`
- `board-states`
- `mech-h`
- `vol`
- `vent`
- `viewer`
- `gem-pool`
- `collectables`
- `crates`
- `secrets-menu`

Additionally:

- Detection of non-virtual state inheritance
- Added a config file that allows overriding the process stack size set
by `stack-size-set!` calls
- Fix for integer multiplication with `r0`
- Fixed detection for the following macros:
	- `static-attack-info`
- `defpart` and `defpartgroup` (probably still needs adjustments, uses
Jak 2 implementation at the moment)
- `sound-play` (Jak 3 seems to always call `sound-play-by-name` with a
`sound-group` of 0, so the macro has been temporarily defaulted to use
that)

One somewhat significant change made here that should be noted is that
the return type of `process::init-from-entity!` was changed to `object`.
I've been thinking about this for a while, since it looks a bit nicer
without the `(none)` at the end and I have recently encountered init
methods that early return `0`.
This commit is contained in:
Hat Kid
2024-03-03 21:15:27 +01:00
committed by GitHub
parent 6822e5cc71
commit 2969833b2d
222 changed files with 124199 additions and 4345 deletions
+29 -9
View File
@@ -1497,7 +1497,13 @@ void SimpleExpressionElement::update_from_stack_force_ui_2(const Env& env,
FormStack& stack,
std::vector<FormElement*>* result,
bool allow_side_effects) {
auto arg0_u = is_uint_type(env, m_my_idx, m_expr.get_arg(0).var());
bool arg0_constant = !m_expr.get_arg(0).is_var();
bool arg0_u;
if (!arg0_constant) {
arg0_u = is_uint_type(env, m_my_idx, m_expr.get_arg(0).var());
} else {
arg0_u = m_expr.get_arg(0).is_int();
}
bool arg1_u = true;
bool arg1_reg = m_expr.get_arg(1).is_var();
if (arg1_reg) {
@@ -1507,12 +1513,17 @@ void SimpleExpressionElement::update_from_stack_force_ui_2(const Env& env,
}
std::vector<Form*> args;
if (arg1_reg) {
args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, env, pool, stack,
allow_side_effects);
if (arg0_constant) {
args = pop_to_forms({m_expr.get_arg(1).var()}, env, pool, stack, allow_side_effects);
args.push_back(pool.form<SimpleAtomElement>(m_expr.get_arg(0)));
} else {
args = pop_to_forms({m_expr.get_arg(0).var()}, env, pool, stack, allow_side_effects);
args.push_back(pool.form<SimpleAtomElement>(m_expr.get_arg(1)));
if (arg1_reg) {
args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, env, pool, stack,
allow_side_effects);
} else {
args = pop_to_forms({m_expr.get_arg(0).var()}, env, pool, stack, allow_side_effects);
args.push_back(pool.form<SimpleAtomElement>(m_expr.get_arg(1)));
}
}
if (!arg0_u) {
@@ -3442,6 +3453,15 @@ void FunctionCallElement::update_from_stack(const Env& env,
}
}
}
} else if (env.func->process_stack_size > 0 && head_obj.is_symbol("stack-size-set!")) {
// override process stack size
auto old_size = arg_forms.at(1)->to_form(env);
if (old_size.is_int()) {
arg_forms.at(1) = pool.alloc_single_element_form<ConstantTokenElement>(
arg_forms.at(1)->parent_element, std::to_string(env.func->process_stack_size));
env.func->warnings.info("Process stack size was changed from {} to {}",
old_size.as_int(), env.func->process_stack_size);
}
}
}
@@ -3532,10 +3552,10 @@ void FunctionCallElement::update_from_stack(const Env& env,
}
auto elt_group = arg_forms.at(5)->try_as_element<GenericElement>();
if (elt_group && elt_group->op().is_func() &&
elt_group->op().func()->to_form(env).is_symbol("sound-group") &&
elt_group->elts().size() == 1) {
elt_group->op().func()->to_form(env).is_symbol("sound-group")) {
Form* so_group_f = nullptr;
if (!elt_group->elts().at(0)->to_form(env).is_symbol("sfx")) {
if (elt_group->elts().size() == 1 &&
!elt_group->elts().at(0)->to_form(env).is_symbol("sfx")) {
so_group_f = pool.form<ConstantTokenElement>(
elt_group->elts().at(0)->to_form(env).as_symbol().name_ptr);
}