VarAction2: Remove trivially resolvable deterministic sprite groups
This commit is contained in:
@@ -5492,7 +5492,26 @@ static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 grou
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cur.spritegroups[groupid];
|
const SpriteGroup *result = _cur.spritegroups[groupid];
|
||||||
|
while (result != nullptr) {
|
||||||
|
if (result->type == SGT_DETERMINISTIC) {
|
||||||
|
const DeterministicSpriteGroup *sg = static_cast<const DeterministicSpriteGroup *>(result);
|
||||||
|
if (sg->adjusts.size() == 1 && sg->adjusts[0].variable == 0x1A) {
|
||||||
|
/* Deterministic sprite group can be trivially resolved, skip it */
|
||||||
|
uint32 value = EvaluateDeterministicSpriteGroupAdjust(sg->size, sg->adjusts[0], nullptr, 0, UINT_MAX);
|
||||||
|
result = sg->default_group;
|
||||||
|
for (const auto &range : sg->ranges) {
|
||||||
|
if (range.low <= value && value <= range.high) {
|
||||||
|
result = range.group;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -282,13 +282,7 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co
|
|||||||
auto check_1A_range = [&]() -> bool {
|
auto check_1A_range = [&]() -> bool {
|
||||||
if (this->adjusts.size() == 1 && this->adjusts[0].variable == 0x1A) {
|
if (this->adjusts.size() == 1 && this->adjusts[0].variable == 0x1A) {
|
||||||
/* Not clear why some GRFs do this, perhaps a way of commenting out a branch */
|
/* Not clear why some GRFs do this, perhaps a way of commenting out a branch */
|
||||||
uint32 value = 0;
|
uint32 value = EvaluateDeterministicSpriteGroupAdjust(this->size, this->adjusts[0], nullptr, 0, UINT_MAX);
|
||||||
switch (this->size) {
|
|
||||||
case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (this->adjusts[0], nullptr, 0, UINT_MAX); break;
|
|
||||||
case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(this->adjusts[0], nullptr, 0, UINT_MAX); break;
|
|
||||||
case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(this->adjusts[0], nullptr, 0, UINT_MAX); break;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
for (const auto &range : this->ranges) {
|
for (const auto &range : this->ranges) {
|
||||||
if (range.low <= value && value <= range.high) {
|
if (range.low <= value && value <= range.high) {
|
||||||
if (range.group != nullptr) range.group->AnalyseCallbacks(op);
|
if (range.group != nullptr) range.group->AnalyseCallbacks(op);
|
||||||
|
Reference in New Issue
Block a user