1
0
Fork 0

Add: [NewGRF] More basic bitwise operators for varact2.

Adds ANDN, NAND, NOR and XNOR operators for whoever might find them useful.
pull/13566/head
Peter Nelson 2025-02-15 15:44:04 +00:00
parent cb23bc5e2a
commit 7912a69246
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
2 changed files with 8 additions and 0 deletions

View File

@ -175,6 +175,10 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver
case DSGA_OP_SHL: return (uint32_t)(U)last_value << ((U)value & 0x1F); // Same behaviour as in ParamSet, mask 'value' to 5 bits, which should behave the same on all architectures.
case DSGA_OP_SHR: return (uint32_t)(U)last_value >> ((U)value & 0x1F);
case DSGA_OP_SAR: return (int32_t)(S)last_value >> ((U)value & 0x1F);
case DSGA_OP_ANDN: return last_value & ~value;
case DSGA_OP_NAND: return ~(last_value & value);
case DSGA_OP_NOR: return ~(last_value | value);
case DSGA_OP_XNOR: return ~(last_value ^ value);
default: return value;
}
}

View File

@ -141,6 +141,10 @@ enum DeterministicSpriteGroupAdjustOperation : uint8_t {
DSGA_OP_SHL, ///< a << b
DSGA_OP_SHR, ///< (unsigned) a >> b
DSGA_OP_SAR, ///< (signed) a >> b
DSGA_OP_ANDN, ///< x & ~y
DSGA_OP_NAND, ///< ~(x & y)
DSGA_OP_NOR, ///< ~(x | y)
DSGA_OP_XNOR, ///< ~(x ^ y)
};