GRF analysis: Check for indtile anim next frame callback per layout subset

wip-string
Jonathan G Rennison 6 months ago
parent 91d872c88e
commit ef77a9be28

@ -183,6 +183,16 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co
}
if (op.mode == ACOM_INDUSTRY_TILE && adjust.variable == 0xC) {
if (adjust.shift_num == 0 && (adjust.and_mask & 0xFF) == 0xFF && adjust.type == DSGA_TYPE_NONE) {
/* Check for CBID_INDTILE_ANIM_NEXT_FRAME, mark layout subset as animated if found */
if (op.data.indtile->check_anim_next_frame_cb) {
for (const auto &range : this->ranges) {
if (range.low <= CBID_INDTILE_ANIM_NEXT_FRAME && CBID_INDTILE_ANIM_NEXT_FRAME <= range.high) {
/* Found a CBID_INDTILE_ANIM_NEXT_FRAME */
*(op.data.indtile->result_mask) &= ~op.data.indtile->check_mask;
}
}
}
/* Callback switch, skip to the default/graphics chain */
for (const auto &range : this->ranges) {
if (range.low == 0) {
@ -279,7 +289,6 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co
}
if (op.mode == ACOM_INDUSTRY_TILE && this->var_scope == VSG_SCOPE_SELF && (adjust.variable == 0x44 || (adjust.variable == 0x61 && adjust.parameter == 0))) {
*(op.data.indtile->result_mask) &= ~op.data.indtile->check_mask;
return;
}
if (op.mode == ACOM_INDUSTRY_TILE && ((this->var_scope == VSG_SCOPE_SELF && adjust.variable == 0x61) || (this->var_scope == VSG_SCOPE_PARENT && adjust.variable == 0x63))) {
op.data.indtile->anim_state_at_offset = true;

@ -430,11 +430,6 @@ void AnalyseIndustryTileSpriteGroups()
const IndustryTileSpec &tilespec = _industry_tile_specs[gfx];
if (tilespec.grf_prop.spritegroup[0] == nullptr) continue;
if (HasBit(tilespec.callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) {
/* There may be sound effects, or custom animation start/stop behaviour, don't inhibit */
continue;
}
anim_mask |= current;
AnalyseCallbackOperationIndustryTileData data;
@ -443,6 +438,7 @@ void AnalyseIndustryTileSpriteGroups()
data.result_mask = &anim_mask;
data.layout_index = idx + 1;
data.anim_state_at_offset = false;
data.check_anim_next_frame_cb = HasBit(tilespec.callback_mask, CBM_INDT_ANIM_NEXT_FRAME);
AnalyseCallbackOperation op(ACOM_INDUSTRY_TILE);
op.data.indtile = &data;

@ -18,6 +18,7 @@ struct AnalyseCallbackOperationIndustryTileData {
uint64 *result_mask;
uint8 layout_index;
bool anim_state_at_offset;
bool check_anim_next_frame_cb;
};
#endif /* NEWGRF_INDUSTRYTILES_ANALYSIS_H */

Loading…
Cancel
Save