decomp3: more engine files, get-texture macro, use print method in autogenerated inspect, fix bitfield float print (#3432)

- `fma-sphere`
- `prim-beam-h`
- `cam-start`
- `ragdoll`
- `light-trails-h`
- `light-trails`
- `menu`
- `water`
- `water-flow`
- `hud`
- `hud-classes`
- `progress`
- `progress-draw`

---

The `get-texture` macro replaces calls to `lookup-texture-by-id` and
`lookup-texture-by-id-fast`. The `defpart` macro detection was modified
to print a pair like `(texture-name tpage-name)` for the texture field
that gets turned into a `texture-id` constant. Only used in Jak 3 at the
moment, I'll probably go through the other games at a later point.
This commit is contained in:
Hat Kid
2024-03-23 14:25:11 +01:00
committed by GitHub
parent 9a9f203d8b
commit 99866cec88
120 changed files with 61355 additions and 1038 deletions
+17 -3
View File
@@ -401,9 +401,22 @@ void assert_spec_flag_float(const std::vector<LinkedWord>& words, const std::str
std::string decompile_sparticle_texture(const std::vector<LinkedWord>& words,
const TypeSystem& ts,
const std::string& flag_name) {
const std::string& flag_name,
const Env& env) {
assert_spec_flag_int_single_field(words, flag_name);
// try to use texture constants
auto textures = env.dts->textures;
auto combo_id = words.at(1).data;
u16 tpage = (combo_id & 0xfff00000) >> 20;
u16 idx = (combo_id & 0x000fff00) >> 8;
auto fixed_id = tpage << 16 | idx;
if (!textures.empty() && textures.find(fixed_id) != textures.end()) {
auto tex = textures.at(fixed_id);
return pretty_print::build_list(tex.name, tex.tpage_name).print();
}
// default to texture id if it fails
const auto tex_id_type = TypeSpec("texture-id");
auto tex_id_str = bitfield_defs_print(
tex_id_type, decompile_bitfield_from_int(tex_id_type, ts, words.at(1).data));
@@ -660,7 +673,8 @@ goos::Object decompile_sparticle_field_init(const std::vector<decompiler::Linked
goos::Object sound_spec,
goos::Object userdata,
const TypeSystem& ts,
GameVersion version) {
GameVersion version,
const Env& env) {
auto field_name = decompile_int_enum_from_int(TypeSpec("sp-field-id"), ts, field_id);
const auto& field_info = field_kinds.at(version)[field_id];
if (!field_info.known) {
@@ -690,7 +704,7 @@ goos::Object decompile_sparticle_field_init(const std::vector<decompiler::Linked
// let's handle things on a more specific level now
switch (field_info.kind) {
case FieldKind::TEXTURE_ID:
result = decompile_sparticle_texture(words, ts, flag_name);
result = decompile_sparticle_texture(words, ts, flag_name, env);
break;
case FieldKind::FLOAT:
result = decompile_sparticle_float(words, flag_name, false);