VarAction2: Fix calculated result groups being incorrectly pruned

pull/393/head
Jonathan G Rennison 2 years ago
parent d6015194c1
commit 994dc683a2

@ -5526,7 +5526,7 @@ static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 grou
while (result != nullptr) {
if (result->type == SGT_DETERMINISTIC) {
const DeterministicSpriteGroup *sg = static_cast<const DeterministicSpriteGroup *>(result);
if (sg->adjusts.size() == 0 || (sg->adjusts.size() == 1 && sg->adjusts[0].variable == 0x1A && (sg->adjusts[0].operation == DSGA_OP_ADD || sg->adjusts[0].operation == DSGA_OP_RST))) {
if (sg->GroupMayBeBypassed()) {
/* Deterministic sprite group can be trivially resolved, skip it */
uint32 value = (sg->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(sg->size, sg->adjusts[0], nullptr, 0, UINT_MAX) : 0;
result = sg->default_group;

@ -286,7 +286,7 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co
}
auto check_1A_range = [&]() -> bool {
if (this->adjusts.size() == 0 || (this->adjusts.size() == 1 && this->adjusts[0].variable == 0x1A && (this->adjusts[0].operation == DSGA_OP_ADD || this->adjusts[0].operation == DSGA_OP_RST))) {
if (this->GroupMayBeBypassed()) {
/* Not clear why some GRFs do this, perhaps a way of commenting out a branch */
uint32 value = (this->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(this->size, this->adjusts[0], nullptr, 0, UINT_MAX) : 0;
for (const auto &range : this->ranges) {
@ -442,6 +442,14 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co
}
}
bool DeterministicSpriteGroup::GroupMayBeBypassed() const
{
if (this->calculated_result) return false;
if (this->adjusts.size() == 0) return true;
if ((this->adjusts.size() == 1 && this->adjusts[0].variable == 0x1A && (this->adjusts[0].operation == DSGA_OP_ADD || this->adjusts[0].operation == DSGA_OP_RST))) return true;
return false;
}
void CallbackResultSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) const
{
if (op.mode == ACOM_FIND_CB_RESULT) op.cb_result_found = true;

@ -316,6 +316,7 @@ struct DeterministicSpriteGroup : SpriteGroup {
const SpriteGroup *error_group; // was first range, before sorting ranges
void AnalyseCallbacks(AnalyseCallbackOperation &op) const override;
bool GroupMayBeBypassed() const;
protected:
const SpriteGroup *Resolve(ResolverObject &object) const override;

Loading…
Cancel
Save