diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index 0a3844d625..3cfb897524 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -3447,7 +3447,7 @@ goos::Object DefpartElement::to_form_internal(const Env& env) const { break; } item_forms.push_back(decompile_sparticle_field_init(e.data, e.field_id, e.flags, e.sound_spec, - e.userdata, env.dts->ts, env.version)); + e.userdata, env.dts->ts, env.version, env)); } if (!item_forms.empty()) { forms.push_back(pretty_print::to_symbol(":init-specs")); diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index d8457c4fb3..64ff160c51 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3300,6 +3300,36 @@ void FunctionCallElement::update_from_stack(const Env& env, return; } + // tpage and texture macros + { + auto func = Matcher::symbol("lookup-texture-by-id"); + auto func_fast = Matcher::symbol("lookup-texture-by-id-fast"); + auto mr = match(func, unstacked.at(0)); + auto mr_fast = match(func_fast, unstacked.at(0)); + if (mr.matched || mr_fast.matched) { + auto tex_id = Matcher::any_integer(0); + auto mr2 = match(tex_id, unstacked.at(1)); + if (mr2.matched) { + auto id = mr2.maps.ints.at(0); + u16 tpage = (id & 0xfff00000) >> 20; + u16 idx = (id & 0x000fff00) >> 8; + auto fixed_id = tpage << 16 | idx; + if (!env.dts->textures.empty() && + env.dts->textures.find(fixed_id) != env.dts->textures.end()) { + std::vector