VarAction2: Delete provably zero adjustment operations

pull/393/head
Jonathan G Rennison 2 years ago
parent 502980ba61
commit e3df522111

@ -5626,6 +5626,15 @@ static void NewSpriteGroup(ByteReader *buf)
} else {
adjust.add_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. */

@ -163,6 +163,24 @@ enum DeterministicSpriteGroupAdjustOperation {
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 {
DeterministicSpriteGroupAdjustOperation operation;

Loading…
Cancel
Save