mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
This commit is contained in:
parent
726ea01d6c
commit
ed2b6f4f72
|
@ -106,6 +106,21 @@ static inline uint32 GetVariable(const ResolverObject *object, byte variable, by
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotate val rot times to the right
|
||||||
|
* @param val the value to rotate
|
||||||
|
* @param rot the amount of times to rotate
|
||||||
|
* @return the rotated value
|
||||||
|
*/
|
||||||
|
static uint32 RotateRight(uint32 val, uint32 rot)
|
||||||
|
{
|
||||||
|
/* Do not rotate more than necessary */
|
||||||
|
rot %= 32;
|
||||||
|
|
||||||
|
return (val >> rot) | (val << (32 - rot));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Evaluate an adjustment for a variable of the given size.
|
/* Evaluate an adjustment for a variable of the given size.
|
||||||
* U is the unsigned type and S is the signed type to use. */
|
* U is the unsigned type and S is the signed type to use. */
|
||||||
template <typename U, typename S>
|
template <typename U, typename S>
|
||||||
|
@ -140,6 +155,9 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ResolverObjec
|
||||||
case DSGA_OP_STO: _temp_store.Store(value, last_value); return last_value;
|
case DSGA_OP_STO: _temp_store.Store(value, last_value); return last_value;
|
||||||
case DSGA_OP_RST: return value;
|
case DSGA_OP_RST: return value;
|
||||||
case DSGA_OP_STOP: if (object->psa != NULL) object->psa->Store(value, last_value); return last_value;
|
case DSGA_OP_STOP: if (object->psa != NULL) object->psa->Store(value, last_value); return last_value;
|
||||||
|
case DSGA_OP_ROR: return RotateRight(last_value, value);
|
||||||
|
case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2);
|
||||||
|
case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2);
|
||||||
default: return value;
|
default: return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,9 @@ enum DeterministicSpriteGroupAdjustOperation {
|
||||||
DSGA_OP_STO, ///< store a into temporary storage, indexed by b. return a
|
DSGA_OP_STO, ///< store a into temporary storage, indexed by b. return a
|
||||||
DSGA_OP_RST, ///< return b
|
DSGA_OP_RST, ///< return b
|
||||||
DSGA_OP_STOP, ///< store a into persistent storage, indexed by b, return a
|
DSGA_OP_STOP, ///< store a into persistent storage, indexed by b, return a
|
||||||
|
DSGA_OP_ROR, ///< rotate a b positions to the right
|
||||||
|
DSGA_OP_SCMP, ///< (signed) comparision (a < b -> 0, a == b = 1, a > b = 2)
|
||||||
|
DSGA_OP_UCMP, ///< (unsigned) comparision (a < b -> 0, a == b = 1, a > b = 2)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue