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
+29 -1
View File
@@ -717,7 +717,8 @@ void ObjectFileDB::find_and_write_scripts(const fs::path& output_dir) {
std::string ObjectFileDB::process_tpages(TextureDB& tex_db,
const fs::path& output_path,
const Config& cfg) {
const Config& cfg,
const fs::path& dump_out) {
lg::info("- Finding textures in tpages...");
std::string tpage_string = "tpage-";
int total = 0, success = 0;
@@ -766,6 +767,27 @@ std::string ObjectFileDB::process_tpages(TextureDB& tex_db,
lg::warn("Did not find tpage-dir.");
return {};
}
if (cfg.write_tpage_imports) {
file_util::create_dir_if_needed(dump_out);
std::string tpage_dump;
std::string tex_dump;
for (auto& tpage : tex_db.tpage_names) {
tpage_dump += print_tpage_for_dump(tpage.second, tpage.first);
}
for (auto& tex : tex_db.textures) {
auto tpage_name = tex_db.tpage_names[tex.second.page];
dts.textures.emplace(tex.first, TexInfo{tex.second.name, tpage_name, tex.first & 0x0000ffff});
tex_dump += print_tex_for_dump(tex.second.name, tpage_name, tex.first & 0x0000ffff);
}
auto tpage_dump_out = dump_out / "tpages.gc";
auto tex_dump_out = dump_out / "textures.gc";
file_util::write_text_file(tpage_dump_out, tpage_dump);
file_util::write_text_file(tex_dump_out, tex_dump);
}
return result;
}
@@ -1107,4 +1129,10 @@ std::string print_art_elt_for_dump(const std::string& group_name,
std::string print_jg_for_dump(const std::string& jg_name, const std::string& joint_name, int idx) {
return fmt::format("(def-joint-node {} \"{}\" {})\n", jg_name, joint_name, idx);
}
std::string print_tpage_for_dump(const std::string& debug_name, u32 id) {
return fmt::format("(defconstant {} {})\n", debug_name, id);
}
std::string print_tex_for_dump(const std::string& name, const std::string& page_name, u32 idx) {
return fmt::format("(def-tex {} {} {})\n", name, page_name, idx);
}
} // namespace decompiler