38 if (group == NULL)
return NULL;
40 _temp_store.ClearChanges();
45 RealSpriteGroup::~RealSpriteGroup()
51 DeterministicSpriteGroup::~DeterministicSpriteGroup()
57 RandomizedSpriteGroup::~RandomizedSpriteGroup()
62 static inline uint32 GetVariable(
const ResolverObject &
object,
ScopeResolver *scope, byte variable, uint32 parameter,
bool *available)
66 case 0x0C:
return object.callback;
67 case 0x10:
return object.callback_param1;
68 case 0x18:
return object.callback_param2;
69 case 0x1C:
return object.last_value;
73 case 0x7D:
return _temp_store.GetValue(parameter);
76 if (
object.grffile == NULL)
return 0;
77 return object.grffile->GetParam(parameter);
81 if (variable < 0x40 &&
GetGlobalVariable(variable, &value,
object.grffile))
return value;
83 return scope->
GetVariable(variable, parameter, available);
114 DEBUG(grf, 1,
"Unhandled scope variable 0x%X", variable);
158 return (val >> rot) | (val << (32 - rot));
164 template <
typename U,
typename S>
167 value >>= adjust->shift_num;
168 value &= adjust->and_mask;
170 switch (adjust->type) {
171 case DSGA_TYPE_DIV: value = ((S)value + (S)adjust->add_val) / (S)adjust->divmod_val;
break;
172 case DSGA_TYPE_MOD: value = ((S)value + (S)adjust->add_val) % (S)adjust->divmod_val;
break;
173 case DSGA_TYPE_NONE:
break;
176 switch (adjust->operation) {
183 case DSGA_OP_SDIV:
return value == 0 ? (S)last_value : (S)last_value / (S)value;
184 case DSGA_OP_SMOD:
return value == 0 ? (S)last_value : (S)last_value % (S)value;
185 case DSGA_OP_UDIV:
return value == 0 ? (U)last_value : (U)last_value / (U)value;
186 case DSGA_OP_UMOD:
return value == 0 ? (U)last_value : (U)last_value % (U)value;
191 case DSGA_OP_STO: _temp_store.StoreValue((U)value, (S)last_value);
return last_value;
195 case DSGA_OP_SCMP:
return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2);
196 case DSGA_OP_UCMP:
return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2);
197 case DSGA_OP_SHL:
return (uint32)(U)last_value << ((U)value & 0x1F);
198 case DSGA_OP_SHR:
return (uint32)(U)last_value >> ((U)value & 0x1F);
199 case DSGA_OP_SAR:
return (int32)(S)last_value >> ((U)value & 0x1F);
200 default:
return value;
207 return range.high < value;
212 uint32 last_value = 0;
218 for (i = 0; i < this->num_adjusts; i++) {
222 bool available =
true;
223 if (adjust->variable == 0x7E) {
225 if (subgroup == NULL) {
228 value = subgroup->GetCallbackResult();
232 }
else if (adjust->variable == 0x7B) {
233 value = GetVariable(
object, scope, adjust->
parameter, last_value, &available);
235 value = GetVariable(
object, scope, adjust->variable, adjust->
parameter, &available);
244 switch (this->size) {
245 case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, scope, last_value, value);
break;
246 case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, scope, last_value, value);
break;
247 case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, scope, last_value, value);
break;
248 default: NOT_REACHED();
253 object.last_value = last_value;
255 if (this->calculated_result) {
259 nvarzero.result = value;
263 if (this->num_ranges > 4) {
265 if (lower != this->ranges + this->num_ranges && lower->low <= value) {
266 assert(lower->low <= value && value <= lower->high);
270 for (i = 0; i < this->num_ranges; i++) {
271 if (this->ranges[i].low <= value && value <= this->ranges[i].high) {
286 byte match = this->triggers &
object.waiting_triggers;
287 bool res = (this->
cmp_mode == RSG_CMP_ANY) ? (match != 0) : (match == this->triggers);
290 object.used_triggers |= match;
304 return object.ResolveReal(
this);
322 uint8 actual_stage = stage != NULL ? *stage : 0;
328 if (stage != NULL) *stage = 0;