77 _spritegroup_count = 0; |
77 _spritegroup_count = 0; |
78 } |
78 } |
79 |
79 |
80 TemporaryStorageArray<uint32, 0x110> _temp_store; |
80 TemporaryStorageArray<uint32, 0x110> _temp_store; |
81 |
81 |
82 |
|
83 static inline bool Is8BitCallback(const ResolverObject *object) |
|
84 { |
|
85 /* Var 0x7E procedure results are always 15 bit */ |
|
86 if (object == NULL || object->procedure_call) return false; |
|
87 |
|
88 switch (object->callback) { |
|
89 /* All these functions are 15 bit callbacks */ |
|
90 case CBID_STATION_SPRITE_LAYOUT: |
|
91 case CBID_VEHICLE_REFIT_CAPACITY: |
|
92 case CBID_HOUSE_COLOUR: |
|
93 case CBID_HOUSE_CARGO_ACCEPTANCE: |
|
94 case CBID_INDUSTRY_LOCATION: |
|
95 case CBID_HOUSE_ACCEPT_CARGO: |
|
96 case CBID_INDTILE_CARGO_ACCEPTANCE: |
|
97 case CBID_INDTILE_ACCEPT_CARGO: |
|
98 case CBID_VEHICLE_COLOUR_MAPPING: |
|
99 case CBID_HOUSE_PRODUCE_CARGO: |
|
100 case CBID_INDTILE_SHAPE_CHECK: |
|
101 case CBID_VEHICLE_SOUND_EFFECT: |
|
102 case CBID_VEHICLE_MODIFY_PROPERTY: // depends on queried property |
|
103 case CBID_CARGO_PROFIT_CALC: |
|
104 case CBID_SOUNDS_AMBIENT_EFFECT: |
|
105 case CBID_CARGO_STATION_RATING_CALC: |
|
106 return false; |
|
107 |
|
108 /* The rest is a 8 bit callback, which should be truncated properly */ |
|
109 default: |
|
110 return true; |
|
111 } |
|
112 } |
|
113 |
82 |
114 static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
83 static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
115 { |
84 { |
116 /* First handle variables common with Action7/9/D */ |
85 /* First handle variables common with Action7/9/D */ |
117 uint32 value; |
86 uint32 value; |
234 object->last_value = last_value; |
203 object->last_value = last_value; |
235 |
204 |
236 if (group->g.determ.num_ranges == 0) { |
205 if (group->g.determ.num_ranges == 0) { |
237 /* nvar == 0 is a special case -- we turn our value into a callback result */ |
206 /* nvar == 0 is a special case -- we turn our value into a callback result */ |
238 nvarzero.type = SGT_CALLBACK; |
207 nvarzero.type = SGT_CALLBACK; |
239 nvarzero.g.callback.result = GB(value, 0, Is8BitCallback(object) ? 8 : 15); |
208 nvarzero.g.callback.result = value; |
240 return &nvarzero; |
209 return &nvarzero; |
241 } |
210 } |
242 |
211 |
243 for (i = 0; i < group->g.determ.num_ranges; i++) { |
212 for (i = 0; i < group->g.determ.num_ranges; i++) { |
244 if (group->g.determ.ranges[i].low <= value && value <= group->g.determ.ranges[i].high) { |
213 if (group->g.determ.ranges[i].low <= value && value <= group->g.determ.ranges[i].high) { |
292 |
261 |
293 switch (group->type) { |
262 switch (group->type) { |
294 case SGT_REAL: return object->ResolveReal(object, group); |
263 case SGT_REAL: return object->ResolveReal(object, group); |
295 case SGT_DETERMINISTIC: return ResolveVariable(group, object); |
264 case SGT_DETERMINISTIC: return ResolveVariable(group, object); |
296 case SGT_RANDOMIZED: return ResolveRandom(group, object); |
265 case SGT_RANDOMIZED: return ResolveRandom(group, object); |
297 case SGT_CALLBACK: { |
|
298 if (!Is8BitCallback(object)) return group; |
|
299 |
|
300 static SpriteGroup result8bit; |
|
301 result8bit.type = SGT_CALLBACK; |
|
302 result8bit.g.callback.result = GB(group->g.callback.result, 0, 8); |
|
303 return &result8bit; |
|
304 } |
|
305 default: return group; |
266 default: return group; |
306 } |
267 } |
307 } |
268 } |