mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add new ImageId struct
This commit is contained in:
parent
f23e3368b1
commit
583855d639
|
@ -15,6 +15,7 @@
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
|
#include "../sprites.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "../world/Water.h"
|
#include "../world/Water.h"
|
||||||
|
|
||||||
|
@ -465,6 +466,32 @@ const translucent_window_palette TranslucentWindowPalettes[COLOUR_COUNT] = {
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
ImageCatalogue ImageId::GetCatalogue() const
|
||||||
|
{
|
||||||
|
auto index = GetIndex();
|
||||||
|
if (index == SPR_TEMP)
|
||||||
|
{
|
||||||
|
return ImageCatalogue::TEMPORARY;
|
||||||
|
}
|
||||||
|
else if (index < SPR_RCTC_G1_END)
|
||||||
|
{
|
||||||
|
return ImageCatalogue::G1;
|
||||||
|
}
|
||||||
|
else if (index < SPR_G2_END)
|
||||||
|
{
|
||||||
|
return ImageCatalogue::G2;
|
||||||
|
}
|
||||||
|
else if (index < SPR_CSG_END)
|
||||||
|
{
|
||||||
|
return ImageCatalogue::CSG;
|
||||||
|
}
|
||||||
|
else if (index < SPR_IMAGE_LIST_END)
|
||||||
|
{
|
||||||
|
return ImageCatalogue::OBJECT;
|
||||||
|
}
|
||||||
|
return ImageCatalogue::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
void (*mask_fn)(
|
void (*mask_fn)(
|
||||||
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
||||||
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap)
|
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap)
|
||||||
|
|
|
@ -230,6 +230,92 @@ struct rct_size16
|
||||||
int16_t height;
|
int16_t height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ImageCatalogue
|
||||||
|
{
|
||||||
|
UNKNOWN,
|
||||||
|
G1,
|
||||||
|
G2,
|
||||||
|
CSG,
|
||||||
|
OBJECT,
|
||||||
|
TEMPORARY,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a specific image from a catalogue such as G1, G2, CSG etc. with remap
|
||||||
|
* colours and flags.
|
||||||
|
*
|
||||||
|
* This is currently all stored as a single 32-bit integer, but will allow easy
|
||||||
|
* extension to 64-bits or higher so that more images can be used.
|
||||||
|
*/
|
||||||
|
struct ImageId
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// clang-format off
|
||||||
|
static constexpr uint32_t MASK_INDEX = 0b00000000000001111111111111111111;
|
||||||
|
static constexpr uint32_t MASK_PRIMARY = 0b00000000111110000000000000000000;
|
||||||
|
static constexpr uint32_t MASK_SECONDARY = 0b00011111000000000000000000000000;
|
||||||
|
static constexpr uint32_t FLAG_PRIMARY = 0b00100000000000000000000000000000;
|
||||||
|
static constexpr uint32_t FLAG_TRANSPARENT = 0b01000000000000000000000000000000;
|
||||||
|
static constexpr uint32_t FLAG_SECONDARY = 0b10000000000000000000000000000000;
|
||||||
|
static constexpr uint32_t SHIFT_PRIMARY = 19;
|
||||||
|
static constexpr uint32_t SHIFT_SECONDARY = 24;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
uint32_t _value;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ImageId(uint32_t index)
|
||||||
|
: _value(index & MASK_INDEX)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageId(uint32_t index, colour_t primaryColour)
|
||||||
|
: ImageId(ImageId(index).WithPrimary(primaryColour))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageId(uint32_t index, colour_t primaryColour, colour_t secondaryColour)
|
||||||
|
: ImageId(ImageId(index).WithPrimary(primaryColour).WithSecondary(secondaryColour))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ToUInt32() const
|
||||||
|
{
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetIndex() const
|
||||||
|
{
|
||||||
|
return _value & MASK_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
|
colour_t GetPrimary() const
|
||||||
|
{
|
||||||
|
return _value & MASK_PRIMARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
colour_t GetSecondary() const
|
||||||
|
{
|
||||||
|
return _value & MASK_SECONDARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageCatalogue GetCatalogue() const;
|
||||||
|
|
||||||
|
ImageId WithPrimary(colour_t colour)
|
||||||
|
{
|
||||||
|
ImageId result = *this;
|
||||||
|
result._value = (_value & ~MASK_PRIMARY) | ((colour << SHIFT_PRIMARY) & MASK_PRIMARY) | FLAG_PRIMARY;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageId WithSecondary(colour_t colour)
|
||||||
|
{
|
||||||
|
ImageId result = *this;
|
||||||
|
result._value = (_value & ~MASK_SECONDARY) | ((colour << SHIFT_SECONDARY) & MASK_SECONDARY) | FLAG_SECONDARY;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#define SPRITE_ID_PALETTE_COLOUR_1(colourId) (IMAGE_TYPE_REMAP | ((colourId) << 19))
|
#define SPRITE_ID_PALETTE_COLOUR_1(colourId) (IMAGE_TYPE_REMAP | ((colourId) << 19))
|
||||||
#define SPRITE_ID_PALETTE_COLOUR_2(primaryId, secondaryId) \
|
#define SPRITE_ID_PALETTE_COLOUR_2(primaryId, secondaryId) \
|
||||||
(IMAGE_TYPE_REMAP_2_PLUS | IMAGE_TYPE_REMAP | (((primaryId) << 19) | ((secondaryId) << 24)))
|
(IMAGE_TYPE_REMAP_2_PLUS | IMAGE_TYPE_REMAP | (((primaryId) << 19) | ((secondaryId) << 24)))
|
||||||
|
|
Loading…
Reference in New Issue