@@ -25,7 +25,7 @@
|
||||
SpriteGroupPool _spritegroup_pool("SpriteGroup");
|
||||
INSTANTIATE_POOL_METHODS(SpriteGroup)
|
||||
|
||||
TemporaryStorageArray<int32, 0x110> _temp_store;
|
||||
TemporaryStorageArray<int32_t, 0x110> _temp_store;
|
||||
|
||||
std::map<const DeterministicSpriteGroup *, DeterministicSpriteGroupShadowCopy> _deterministic_sg_shadows;
|
||||
std::map<const RandomizedSpriteGroup *, RandomizedSpriteGroupShadowCopy> _randomized_sg_shadows;
|
||||
@@ -82,9 +82,9 @@ GrfSpecFeature GetGrfSpecFeatureForParentScope(GrfSpecFeature feature)
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, uint16 variable, uint32 parameter, GetVariableExtra *extra)
|
||||
static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, uint16_t variable, uint32_t parameter, GetVariableExtra *extra)
|
||||
{
|
||||
uint32 value;
|
||||
uint32_t value;
|
||||
switch (variable) {
|
||||
case 0x0C: return object.callback;
|
||||
case 0x10: return object.callback_param1;
|
||||
@@ -112,7 +112,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
* Get a few random bits. Default implementation has no random bits.
|
||||
* @return Random bits.
|
||||
*/
|
||||
/* virtual */ uint32 ScopeResolver::GetRandomBits() const
|
||||
/* virtual */ uint32_t ScopeResolver::GetRandomBits() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
* Get the triggers. Base class returns \c 0 to prevent trouble.
|
||||
* @return The triggers.
|
||||
*/
|
||||
/* virtual */ uint32 ScopeResolver::GetTriggers() const
|
||||
/* virtual */ uint32_t ScopeResolver::GetTriggers() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
* @param[out] available Set to false, in case the variable does not exist.
|
||||
* @return Value
|
||||
*/
|
||||
/* virtual */ uint32 ScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32_t ScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
DEBUG(grf, 1, "Unhandled scope variable 0x%X", variable);
|
||||
extra->available = false;
|
||||
@@ -143,7 +143,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
/**
|
||||
* Store a value into the persistent storage area (PSA). Default implementation does nothing (for newgrf classes without storage).
|
||||
*/
|
||||
/* virtual */ void ScopeResolver::StorePSA(uint reg, int32 value) {}
|
||||
/* virtual */ void ScopeResolver::StorePSA(uint reg, int32_t value) {}
|
||||
|
||||
/**
|
||||
* Get the real sprites of the grf.
|
||||
@@ -170,7 +170,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||
/* Evaluate an adjustment for a variable of the given size.
|
||||
* U is the unsigned type and S is the signed type to use. */
|
||||
template <typename U, typename S>
|
||||
static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, U last_value, uint32 value, const DeterministicSpriteGroupAdjust **adjust_iter = nullptr)
|
||||
static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, U last_value, uint32_t value, const DeterministicSpriteGroupAdjust **adjust_iter = nullptr)
|
||||
{
|
||||
value >>= adjust.shift_num;
|
||||
value &= adjust.and_mask;
|
||||
@@ -212,12 +212,12 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver
|
||||
case DSGA_OP_STO: _temp_store.StoreValue((U)value, (S)last_value); return last_value;
|
||||
case DSGA_OP_RST: return value;
|
||||
case DSGA_OP_STOP: scope->StorePSA((U)value, (S)last_value); return last_value;
|
||||
case DSGA_OP_ROR: return ROR<uint32>((U)last_value, (U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
case DSGA_OP_ROR: return ROR<uint32_t>((U)last_value, (U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
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);
|
||||
case DSGA_OP_SHL: return (uint32)(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)(U)last_value >> ((U)value & 0x1F);
|
||||
case DSGA_OP_SAR: return (int32)(S)last_value >> ((U)value & 0x1F);
|
||||
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_TERNARY: return (last_value != 0) ? value : adjust.add_val;
|
||||
case DSGA_OP_EQ: return (last_value == value) ? 1 : 0;
|
||||
case DSGA_OP_SLT: return ((S)last_value < (S)value) ? 1 : 0;
|
||||
@@ -236,12 +236,12 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver
|
||||
}
|
||||
}
|
||||
|
||||
uint32 EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32 last_value, uint32 value)
|
||||
uint32_t EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32_t last_value, uint32_t value)
|
||||
{
|
||||
switch (size) {
|
||||
case DSG_SIZE_BYTE: return EvalAdjustT<uint8, int8> (adjust, scope, last_value, value); break;
|
||||
case DSG_SIZE_WORD: return EvalAdjustT<uint16, int16>(adjust, scope, last_value, value); break;
|
||||
case DSG_SIZE_DWORD: return EvalAdjustT<uint32, int32>(adjust, scope, last_value, value); break;
|
||||
case DSG_SIZE_BYTE: return EvalAdjustT<uint8_t, int8_t> (adjust, scope, last_value, value); break;
|
||||
case DSG_SIZE_WORD: return EvalAdjustT<uint16_t, int16_t>(adjust, scope, last_value, value); break;
|
||||
case DSG_SIZE_DWORD: return EvalAdjustT<uint32_t, int32_t>(adjust, scope, last_value, value); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
@@ -258,8 +258,8 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con
|
||||
return &cbfail;
|
||||
}
|
||||
|
||||
uint32 last_value = 0;
|
||||
uint32 value = 0;
|
||||
uint32_t last_value = 0;
|
||||
uint32_t value = 0;
|
||||
|
||||
ScopeResolver *scope = object.GetScope(this->var_scope, this->var_scope_count);
|
||||
|
||||
@@ -313,9 +313,9 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con
|
||||
}
|
||||
|
||||
switch (this->size) {
|
||||
case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, scope, last_value, value, &iter); break;
|
||||
case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, scope, last_value, value, &iter); break;
|
||||
case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, scope, last_value, value, &iter); break;
|
||||
case DSG_SIZE_BYTE: value = EvalAdjustT<uint8_t, int8_t> (adjust, scope, last_value, value, &iter); break;
|
||||
case DSG_SIZE_WORD: value = EvalAdjustT<uint16_t, int16_t>(adjust, scope, last_value, value, &iter); break;
|
||||
case DSG_SIZE_DWORD: value = EvalAdjustT<uint32_t, int32_t>(adjust, scope, last_value, value, &iter); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
last_value = value;
|
||||
@@ -370,7 +370,7 @@ const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject &object) const
|
||||
}
|
||||
}
|
||||
|
||||
uint32 mask = ((uint)this->groups.size() - 1) << this->lowest_randbit;
|
||||
uint32_t mask = ((uint)this->groups.size() - 1) << this->lowest_randbit;
|
||||
byte index = (scope->GetRandomBits() & mask) >> this->lowest_randbit;
|
||||
|
||||
return SpriteGroup::Resolve(this->groups[index], object, false);
|
||||
@@ -388,7 +388,7 @@ const SpriteGroup *RealSpriteGroup::Resolve(ResolverObject &object) const
|
||||
* @param[in,out] stage Construction stage (0-3), or nullptr if not applicable.
|
||||
* @return sprite layout to draw.
|
||||
*/
|
||||
const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8 *stage) const
|
||||
const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8_t *stage) const
|
||||
{
|
||||
if (!this->dts.NeedsPreprocessing()) {
|
||||
if (stage != nullptr && this->dts.consistent_max_offset > 0) *stage = GetConstructionStageOffset(*stage, this->dts.consistent_max_offset);
|
||||
@@ -396,7 +396,7 @@ const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8 *stage) con
|
||||
}
|
||||
|
||||
static DrawTileSprites result;
|
||||
uint8 actual_stage = stage != nullptr ? *stage : 0;
|
||||
uint8_t actual_stage = stage != nullptr ? *stage : 0;
|
||||
this->dts.PrepareLayout(0, 0, 0, actual_stage, false);
|
||||
this->dts.ProcessRegisters(0, 0, false);
|
||||
result.seq = this->dts.GetLayout(&result.ground);
|
||||
@@ -480,7 +480,7 @@ static char *GetAdjustOperationName(char *str, const char *last, DeterministicSp
|
||||
return str + seprintf(str, last, "\?\?\?(0x%X)", operation);
|
||||
}
|
||||
|
||||
char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32 &highlight_tag, uint &conditional_indent)
|
||||
char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent)
|
||||
{
|
||||
if (adjust.variable == 0x7D) {
|
||||
/* Temp storage load */
|
||||
@@ -591,7 +591,7 @@ char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const
|
||||
|
||||
void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *padding, uint flags)
|
||||
{
|
||||
uint32 highlight_tag = 0;
|
||||
uint32_t highlight_tag = 0;
|
||||
auto print = [&]() {
|
||||
this->print_fn(sg, DSGPO_PRINT, highlight_tag, this->buffer);
|
||||
highlight_tag = 0;
|
||||
@@ -848,7 +848,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi
|
||||
}
|
||||
seprintf(b, lastof(this->buffer), ", register flags: %X", reg->flags);
|
||||
print();
|
||||
auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8 flag_reg) {
|
||||
auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8_t flag_reg) {
|
||||
if (reg->flags & flag) {
|
||||
highlight_tag = (1 << 16) | flag_reg;
|
||||
seprintf(this->buffer, lastof(this->buffer), "%s %s reg: %X", padding, name, flag_reg);
|
||||
|
Reference in New Issue
Block a user