decomp: decompile remaining particle files (#865)

* decomp: finish `beach-part`

* decomp: finish `citadel-part`

* decomp: finish `robotboss-part`

* decomp: finish `sage-finalboss-part`

* decomp: finish `jungle-part`

* decomp: finish `flut-part`

* decomp: finish `firecanyon-part`

* decomp: finish `village2-part2`

* decomp: finish `swamp-part`

* decomp: finish `maincave-part`

* decomp: finish `sunken-part0-5`

* decomp: finish `ogre-part`

* decomp: finish `robocave-part` and `snow-part`

* decomp: finish `collectables-part`

* decomp: finish `village1-part`

* decomp: finish `village1-part2

* decomp: finish `training-part`

* decomp: finish `misty-part`

* decomp: finish `village2-part`

* decomp: finish `village3-part`

* decomp: finish `lavatube-part`

* decomp: finish `hud-h`, `target-racer-h`, `racer-part`

* address feedback
This commit is contained in:
Tyler Wilding
2021-09-29 20:33:40 -04:00
committed by GitHub
parent b1e987c42f
commit fbcc1542f3
76 changed files with 119899 additions and 933 deletions
+12 -5
View File
@@ -353,16 +353,20 @@ goos::Object decomp_ref_to_inline_array_guess_size(
int end_label_idx =
index_of_closest_following_label_in_segment(start_label.offset, my_seg, labels);
int end_offset = all_words.at(my_seg).size() * 4;
if (end_label_idx < 0) {
throw std::runtime_error(
lg::warn(
"Failed to find label: likely just an unimplemented case for when the data is the last "
"thing in the file.");
} else {
const auto& end_label = labels.at(end_label_idx);
end_offset = end_label.offset;
}
const auto& end_label = labels.at(end_label_idx);
// fmt::print("Data is from {} to {}\n", start_label.name, end_label.name);
// now we can figure out the size
int size_bytes = end_label.offset - start_label.offset;
int size_bytes = end_offset - start_label.offset;
int size_elts = size_bytes / stride; // 32 bytes per ocean-near-index
int leftover_bytes = size_bytes % stride;
// fmt::print("Size is {} bytes ({} elts), with {} bytes left over\n", size_bytes,
@@ -375,8 +379,8 @@ goos::Object decomp_ref_to_inline_array_guess_size(
// .type <some-other-basic's type tag>
// L21: ; label some other basic
// <other basic's data>
int padding_start = end_label.offset - leftover_bytes;
int padding_end = end_label.offset;
int padding_start = end_offset - leftover_bytes;
int padding_end = end_offset;
for (int pad_byte_idx = padding_start; pad_byte_idx < padding_end; pad_byte_idx++) {
auto& word = all_words.at(my_seg).at(pad_byte_idx / 4);
switch (word.kind) {
@@ -782,6 +786,9 @@ goos::Object decompile_structure(const TypeSpec& type,
auto& word = obj_words.at(field_start / 4);
if (word.kind == LinkedWord::PTR) {
if (field.type() == TypeSpec("symbol")) {
continue;
}
field_defs_out.emplace_back(
field.name(),
decompile_at_label(field.type(), labels.at(word.label_id), labels, words, ts, file));