mirror of
https://github.com/open-goal/jak-project
synced 2026-09-02 18:12:50 -04:00
[decomp] fix up gun decomp (#2067)
I did some manual modifications in a few places to work around some truly mysterious control flow, and some unsupported stack array stuff. Also fixes a bug in decompiling static improper lists. As far as I can tell, guns work, other than some graphical issues and the crazy particle spawning issue, but I strongly suspect these are problems with the sparticle/graphics side.
This commit is contained in:
@@ -1600,6 +1600,14 @@ goos::Object decompile_pair_elt(const LinkedWord& word,
|
||||
(int)word.kind(), word.data));
|
||||
}
|
||||
}
|
||||
|
||||
bool is_pointer_to_pair(const LinkedWord& word, const std::vector<DecompilerLabel>& labels) {
|
||||
if (word.kind() != LinkedWord::PTR) {
|
||||
return false;
|
||||
}
|
||||
auto& dest_label = labels.at(word.label_id());
|
||||
return (dest_label.offset % 8) == 2;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
goos::Object decompile_pair(const DecompilerLabel& label,
|
||||
@@ -1649,7 +1657,7 @@ goos::Object decompile_pair(const DecompilerLabel& label,
|
||||
}
|
||||
}
|
||||
// if pointer
|
||||
if (cdr_word.kind() == LinkedWord::PTR) {
|
||||
if (is_pointer_to_pair(cdr_word, labels)) {
|
||||
to_print = labels.at(cdr_word.label_id());
|
||||
continue;
|
||||
}
|
||||
@@ -1662,21 +1670,8 @@ goos::Object decompile_pair(const DecompilerLabel& label,
|
||||
return pretty_print::build_list(list_tokens);
|
||||
}
|
||||
} else {
|
||||
if ((to_print.offset % 4) != 0) {
|
||||
throw std::runtime_error(
|
||||
fmt::format("Invalid alignment for pair {}\n", to_print.offset % 16));
|
||||
} else {
|
||||
// improper
|
||||
list_tokens.push_back(pretty_print::to_symbol("."));
|
||||
list_tokens.push_back(
|
||||
decompile_pair_elt(words.at(to_print.target_segment).at(to_print.offset / 4), labels,
|
||||
words, ts, file, version));
|
||||
if (add_quote) {
|
||||
return pretty_print::build_list("quote", pretty_print::build_list(list_tokens));
|
||||
} else {
|
||||
return pretty_print::build_list(list_tokens);
|
||||
}
|
||||
}
|
||||
throw std::runtime_error(
|
||||
fmt::format("Invalid alignment for pair {}\n", to_print.offset % 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user