VarAction2: Delete provably zero adjustment operations
This commit is contained in:
@@ -5626,6 +5626,15 @@ static void NewSpriteGroup(ByteReader *buf)
|
|||||||
} else {
|
} else {
|
||||||
adjust.add_val = 0;
|
adjust.add_val = 0;
|
||||||
adjust.divmod_val = 0;
|
adjust.divmod_val = 0;
|
||||||
|
if (group->adjusts.size() > 1) {
|
||||||
|
/* Not the first adjustment */
|
||||||
|
if (adjust.variable != 0x7E) {
|
||||||
|
if (adjust.and_mask == 0 && IsEvalAdjustWithZeroRemovable(adjust.operation)) {
|
||||||
|
/* Delete useless zero operations */
|
||||||
|
group->adjusts.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Continue reading var adjusts while bit 5 is set. */
|
/* Continue reading var adjusts while bit 5 is set. */
|
||||||
|
@@ -163,6 +163,24 @@ enum DeterministicSpriteGroupAdjustOperation {
|
|||||||
DSGA_OP_END,
|
DSGA_OP_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool IsEvalAdjustWithZeroRemovable(DeterministicSpriteGroupAdjustOperation op)
|
||||||
|
{
|
||||||
|
switch (op) {
|
||||||
|
case DSGA_OP_ADD:
|
||||||
|
case DSGA_OP_SUB:
|
||||||
|
case DSGA_OP_OR:
|
||||||
|
case DSGA_OP_XOR:
|
||||||
|
case DSGA_OP_ROR:
|
||||||
|
case DSGA_OP_SHL:
|
||||||
|
case DSGA_OP_SHR:
|
||||||
|
case DSGA_OP_SAR:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct DeterministicSpriteGroupAdjust {
|
struct DeterministicSpriteGroupAdjust {
|
||||||
DeterministicSpriteGroupAdjustOperation operation;
|
DeterministicSpriteGroupAdjustOperation operation;
|
||||||
|
Reference in New Issue
Block a user